Skip to content

Commit

Permalink
Fix regression in CL:DIRECTORY for wild pathnames
Browse files Browse the repository at this point in the history
We re-enable listing sub-directories of directories for wild pathnames
that have NAME and TYPE of :wild.  This behavior was inadvertently
disabled with
<889a505>.

This regression broke Quicklisp's indexing of local projects directory
which has implementation specific code which depends on

      (directory "~/quicklisp/*.*")

returning both immediate sub-directories as well as files under
<file:~/quicklisp/>.


According to
<http://www.lispworks.com/documentation/HyperSpec/Body/f_pn_mat.htm>
CL:PATHNAME-MATCH-P is supposed to be consistent with CL:DIRECTORY, but
this doesn't seem to be the case for SBCL, CCL, LWpro, but *is* true
for ECL.

      ;;; This should return (t t t …) for every wildcard that one can pass
      ;;; to DIRECTORY
        (let ((wildcard #p"/Users/evenson/quicklisp/local-projects/*.*"))
          (mapcar
           (lambda (e) (pathname-match-p e wildcard))
           (directory wildcard)))

At this time, we choose to be compatible with the previous behavior of
ABCL and the current behavior of SBCL/CCL rather than strict
conformance here.

This should fix <qitab/cl-protobufs#199>.
  • Loading branch information
easye committed Sep 9, 2020
1 parent 7769906 commit 7789522
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/org/armedbear/lisp/directory.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@

(in-package "SYSTEM")

(defun pathname-as-file (pathname)
;;; utility function for LIST-DIRECTORIES-WITH-WILDCARDS
(defun directory-as-file (pathname)
"Convert a PATHNAME referencing a directory to a file"
(let ((directory (pathname-directory pathname)))
(make-pathname :host nil
:device (pathname-device pathname)
Expand All @@ -41,6 +43,7 @@
:type nil
:version nil)))

;;; utility function for LIST-DIRECTORIES-WITH-WILDCARDS
(defun wild-inferiors-p (component)
(eq component :wild-inferiors))

Expand Down Expand Up @@ -142,7 +145,13 @@ error to its caller."
namestring nil resolve-symlinks))
matching-entries)
(dolist (entry entries)
(when (pathname-match-p entry pathname)
(when
(or
(and
(file-directory-p entry :wild-error-p nil)
(pathname-match-p
(directory-as-file entry) pathname))
(pathname-match-p entry pathname))
(push
(if resolve-symlinks
(truename entry)
Expand Down

0 comments on commit 7789522

Please sign in to comment.