Fix #216: enough-namestring with relative pathname fails

The current behavior of enough-namestring is to fail if the pathname has a relative directory component. But that shouldn't prevent enough-namestring from working. In this case it should just return the relative pathname as is. This is how clisp and ecl handle this case.

Merge request reports

Loading
+2 −2
Changes for src/code/filesys.lisp: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -610,8 +610,8 @@
			 ;; We are an absolute pathname, so we can just use it.
			 pathname-directory)
			(t
			 ;; We are a relative directory.  So we lose.
			 (lose)))))
			 ;; We are a relative directory, so just return it as is.
			 pathname-directory))))
	    (strings (unparse-unix-directory-list result-dir)))
	  (let* ((pathname-version (%pathname-version pathname))
		 (version-needed (and pathname-version
+9 −0
Changes for tests/issues.lisp: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -977,3 +977,12 @@
  (assert-true (equal (make-pathname :version :newest)
		      (make-pathname :version :unspecific)))
)

(define-test issue.216.enough-namestring-relative-dir
    (:tag :issues)
  (let ((pathname #p"foo/bar.lisp"))
  (dolist (defaults '(#p"/tmp/zot/" #p"/tmp/zot/foo/"))
    (let ((enough (enough-namestring pathname defaults)))
      ;; This is the condition from the CLHS entry for enough-namestring
      (assert-equal (merge-pathnames enough defaults)
		    (merge-pathnames (parse-namestring pathname nil defaults) defaults))))))
Loading