From 25fc2380279171e139d14dc2efec5987161fb9a4 Mon Sep 17 00:00:00 2001 From: Francois-Rene Rideau <tunes@google.com> Date: Mon, 1 Dec 2014 08:10:58 -0500 Subject: [PATCH] Fix issues with 3.1.4.2: restore (when string ...) in parse-native-namestring; actually enforce empty-is-nil in getenv-pathnames. Reindenting a few forms. --- uiop/filesystem.lisp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/uiop/filesystem.lisp b/uiop/filesystem.lisp index 959a4e33..b825018e 100644 --- a/uiop/filesystem.lisp +++ b/uiop/filesystem.lisp @@ -45,13 +45,14 @@ a CL pathname satisfying all the specified constraints as per ENSURE-PATHNAME" (check-type string (or string null)) (let* ((pathname - (with-pathname-defaults () - #+clozure (ccl:native-to-pathname string) - #+sbcl (sb-ext:parse-native-namestring string) - #-(or clozure sbcl) - (if (os-unix-p) - (parse-unix-namestring string :ensure-directory ensure-directory) - (parse-namestring string)))) + (when string + (with-pathname-defaults () + #+clozure (ccl:native-to-pathname string) + #+sbcl (sb-ext:parse-native-namestring string) + #-(or clozure sbcl) + (if (os-unix-p) + (parse-unix-namestring string :ensure-directory ensure-directory) + (parse-namestring string))))) (pathname (if ensure-directory (and pathname (ensure-directory-pathname pathname)) @@ -502,11 +503,11 @@ Note that this operation is usually NOT thread-safe." "What character does the current OS conventionally uses to separate directories?" (if (os-unix-p) #\: #\;)) - (defun split-native-pathnames-string (string &rest constraints &key &allow-other-keys) - "Given a string of pathnames specified in native OS syntax, separate them in a list, + (defun split-native-pathnames-string (string &rest constraints &key &allow-other-keys) + "Given a string of pathnames specified in native OS syntax, separate them in a list, check constraints and normalize each one as per ENSURE-PATHNAME, where an empty string denotes NIL." - (loop :for namestring :in (split-string string :separator (string (inter-directory-separator))) + (loop :for namestring :in (split-string string :separator (string (inter-directory-separator))) :collect (unless (emptyp namestring) (apply 'parse-native-namestring namestring constraints)))) (defun getenv-pathname (x &rest constraints &key ensure-directory want-directory on-error &allow-other-keys) @@ -527,6 +528,7 @@ check constraints and normalize each one as per ENSURE-PATHNAME. (apply 'split-native-pathnames-string (getenvp x) :on-error (or on-error `(error "In (~S ~S), invalid pathname ~*~S: ~*~?" getenv-pathnames ,x)) + :empty-is-nil t constraints)) (defun getenv-absolute-directory (x) "Extract an absolute directory pathname from a user-configured environment variable, -- GitLab