Changeset 15587 for trunk/abcl/src


Ignore:
Timestamp:
05/23/22 06:23:44 (4 months ago)
Author:
Mark Evenson
Message:

Pathname directory wasn't handling . or .. in certain cases

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/Pathname.java

    r15569 r15587  
    297297      return result;
    298298    }
     299    if (s.startsWith("./"))
     300      { s = s.substring(2); }
    299301    if (s.equals("..") || s.equals("../")) {
    300302      result.setDirectory(list(Keyword.RELATIVE, Keyword.UP));
  • trunk/abcl/src/org/armedbear/lisp/directory.lisp

    r15376 r15587  
    124124
    125125  (let ((pathname (merge-pathnames pathspec)))
     126    (when (equalp (pathname-host pathname) '(:scheme "file"))
     127      (setq pathname (subseq (namestring pathname) #.(length "file://"))))
    126128    (when (logical-pathname-p pathname)
    127129      (setq pathname (translate-logical-pathname pathname)))
     
    144146                (let ((entries (list-directories-with-wildcards
    145147                                namestring nil resolve-symlinks))
    146                       matching-entries)
    147                   (dolist (entry entries)
    148                     (when
    149                         (or
    150                          (and
    151                           (file-directory-p entry :wild-error-p nil)
    152                           (pathname-match-p
    153                            (directory-as-file entry) pathname))
    154                          (pathname-match-p entry pathname))
    155                       (push
    156                        (if resolve-symlinks
    157                            (truename entry)
    158                            ;; Normalize nil DEVICE to :UNSPECIFIC under non-Windows
    159                            ;; fixes ANSI DIRECTORY.[67]
    160                            (if (and (not (find :windows *features*))
    161                                     (not (pathname-device entry)))
    162                                (make-pathname :defaults entry :device :unspecific)
    163                                entry))
    164                        matching-entries)))
    165                   matching-entries))))
     148                      (matching-entries nil))
     149      (flet ((no-dots (path)
     150         (merge-pathnames
     151          (make-pathname :directory
     152             (let ((reversed nil))
     153               (dolist (el (pathname-directory path))
     154                 (if (eq el :up)
     155               (pop reversed)
     156               (unless (equal el ".")
     157                 (push el reversed))))
     158               (reverse reversed)))
     159          path)))
     160        (let ((pathname (no-dots pathname)))
     161          (dolist (entry entries)
     162      (when
     163          (or
     164           (and
     165            (file-directory-p entry :wild-error-p nil)
     166            (pathname-match-p
     167             (directory-as-file entry) pathname))
     168           (pathname-match-p entry pathname))
     169        (push
     170         (if resolve-symlinks
     171             (truename entry)
     172             ;; Normalize nil DEVICE to :UNSPECIFIC under non-Windows
     173             ;; fixes ANSI DIRECTORY.[67]
     174             (if (and (not (find :windows *features*))
     175          (not (pathname-device entry)))
     176           (make-pathname :defaults entry :device :unspecific)
     177           entry))
     178         matching-entries)))))
     179    matching-entries))))
    166180        ;; Not wild.
    167181        (let ((truename (probe-file pathname)))
Note: See TracChangeset for help on using the changeset viewer.