diff --git a/src/code/pathname.lisp b/src/code/pathname.lisp
index 217bbc919137e7a46e5f95beb4f75a478c4fcedb..12f627f51fbdb32f4183048b660392c12c5f7468 100644
--- a/src/code/pathname.lisp
+++ b/src/code/pathname.lisp
@@ -1219,6 +1219,32 @@ a host-structure or string."
 	(:version (frob (%pathname-version pathname)))))))
 
 
+(defun %%pathname-match-p (pathname wildname)
+  (macrolet ((frob (field &optional (op 'components-match ))
+		   `(or (null (,field wildname))
+			(,op (,field pathname) (,field wildname)))))
+	(and (or (null (%pathname-host wildname))
+		 (eq (%pathname-host wildname) (%pathname-host pathname)))
+	     (frob %pathname-device)
+	     (frob %pathname-directory directory-components-match)
+	     (frob %pathname-name)
+	     (frob %pathname-type)
+	     (frob %pathname-version))))
+
+;; Like PATHNAME-MATCH-P but the pathnames should not be search-lists.
+;; Primarily intended for TRANSLATE-LOGICAL-PATHNAME and friends,
+;; because PATHNAME-MATCH-P calls TRANSLATE-LOGICAL-PATHNAME, causing
+;; infinite recursion.
+(defun %pathname-match-p (in-pathname in-wildname)
+  "Pathname matches the wildname template?"
+  (declare (type path-designator in-pathname)
+	   ;; Not path-designator because a file-stream can't have a
+	   ;; wild pathname.
+	   (type (or string pathname) in-wildname))
+  (with-pathname (pathname in-pathname)
+    (with-pathname (wildname in-wildname)
+      (%%pathname-match-p pathname wildname))))
+
 ;;; PATHNAME-MATCH-P -- Interface
 ;;;
 (defun pathname-match-p (in-pathname in-wildname)
@@ -1231,17 +1257,8 @@ a host-structure or string."
     (enumerate-search-list (pathname in-path)
       (with-pathname (in-wild in-wildname)
 	(enumerate-search-list (wildname in-wild)
-	  (macrolet ((frob (field &optional (op 'components-match ))
-		       `(or (null (,field wildname))
-			    (,op (,field pathname) (,field wildname)))))
-	    (when (and (or (null (%pathname-host wildname))
-			   (eq (%pathname-host wildname) (%pathname-host pathname)))
-		       (frob %pathname-device)
-		       (frob %pathname-directory directory-components-match)
-		       (frob %pathname-name)
-		       (frob %pathname-type)
-		       (frob %pathname-version))
-	      (return-from pathname-match-p pathname))))))))
+	  (when (%%pathname-match-p pathname wildname)
+	    (return-from pathname-match-p pathname)))))))
 
 
 ;;; SUBSTITUTE-INTO -- Internal
@@ -1476,7 +1493,7 @@ a host-structure or string."
   (with-pathname (source source)
     (with-pathname (from from-wildname)
       (with-pathname (to to-wildname)
-	  (unless (pathname-match-p source from)
+	  (unless (%pathname-match-p source from)
 	    (didnt-match-error source from))
 	  (let* ((source-host (%pathname-host source))
 		 (to-host (%pathname-host to))
@@ -2171,7 +2188,7 @@ a host-structure or string."
 		       :format-control (intl:gettext "No translation for ~S")
 		       :format-arguments (list pathname)))
        (destructuring-bind (from to) x
-	 (when (pathname-match-p pathname from)
+	 (when (%pathname-match-p pathname from)
 	   (return (translate-logical-pathname
 		    (translate-pathname pathname from to)))))))
     (pathname pathname)
diff --git a/tests/pathname.lisp b/tests/pathname.lisp
index 73b31a1e3772a1af727a94dae6d920fbbb727835..6cff018cbf8c3eb4fe74068d5095cb0574eda08f 100644
--- a/tests/pathname.lisp
+++ b/tests/pathname.lisp
@@ -41,3 +41,35 @@
   
   ;; Tests where both args are search-lists.
   (assert-true "foo:foo.lisp" "bar:*"))
+
+;; Verify PATHNAME-MATCH-P works with logical pathnames.  (Issue 27)
+;; This test modeled after a test from asdf
+(defun setup-logical-host ()
+  (let ((root *default-pathname-defaults*)
+	(bin-type (pathname-type (compile-file-pathname "foo.lisp"))))
+    (setf (logical-pathname-translations "ASDFTEST")
+	  `((,(format nil "**;*.~a" bin-type)
+	      ,(merge-pathnames (make-pathname :directory '(:relative :wild-inferiors)
+					       :name :wild :type bin-type :version nil)))
+	    (,(format nil "**;*.~a.*" bin-type)
+	      ,(merge-pathnames (make-pathname :directory '(:relative "asdf-bin" :wild-inferiors)
+					       :name :wild :type bin-type
+					       :defaults root)))
+	    ("**;*.*.*"
+	     ,(merge-pathnames (make-pathname :directory '(:relative "asdf-src" :wild-inferiors)
+					      :name :wild :type :wild :version :wild)))
+	    ("**;*.*"
+	     ,(merge-pathnames (make-pathname :directory '(:relative "asdf-src" :wild-inferiors)
+					      :name :wild :type :wild :version nil)))
+	    ("**;*"
+	     ,(merge-pathnames (make-pathname :directory '(:relative "asdf-src" :wild-inferiors)
+					      :name :wild :type nil :version nil)))))))
+(setup-logical-host)
+
+(define-test pathname-match-p.logical-pathname
+  (assert-true (pathname-match-p
+		(make-pathname :host "ASDFTEST"
+			       :directory '(:absolute "system2" "module4")
+			       :name nil :type nil)
+		(parse-namestring "ASDFTEST:system2;module4;"))))
+