Skip to content

Better parse-namestring defaults concerning "native" namestrings?

Hello, I had trouble porting an application using the "pathname-utils" library and pinpointed the problem to this:

(format t "~@{~S~%~}"
        #P"foo:bar/"
        (pathname-directory #P"foo:bar/")
        (uiop:parse-native-namestring "foo:bar/")
        (pathname-directory (uiop:parse-native-namestring "foo:bar/")))
#P"foo:bar/"
(:RELATIVE "bar")
#P"foo:bar/"
(:RELATIVE "foo:bar")

parse-namestring doesn't seem to handle "native" namestrings, but a more generic form that considers devices even on platforms without such.

Of course, I know this is no bug since pathnames are infamously underspecified, and uiop:parse-native-namestring does the job, but I wonder if some improvements to match other major impls (SBCL, CCL) on that point might be a good idea?

EDIT: actually, there might be a problem of roundtripping, maybe namestring should escape the colon (like CCL does, I think?):

> (defparameter *p* (make-pathname :directory '(:relative "foo:bar")))
*P*
> (pathname-directory *p*)
(:RELATIVE "foo:bar")
> (parse-namestring (namestring *p*))
#P"foo:bar/"
8
> (pathname-directory *)
(:RELATIVE "bar")
Version info
(format t "~&~@{~12@A ~S~%~}"
        :version (lisp-implementation-version)
        :vcs-id (ext:lisp-implementation-vcs-id)
        :os (software-type)
        :os-version (software-version)
        :machine-type (machine-type)
        :features *features*)
     VERSION "24.5.10"
      VCS-ID "UNKNOWN"
          OS "Linux"
  OS-VERSION "6.12.33-gentoo"
MACHINE-TYPE "x86_64"
    FEATURES (:WALKER :CDR-6 :GRAY-STREAMS-MODULE :CDR-1 :CDR-5 :LINUX
              :FORMATTER :CDR-7 :ECL-WEAK-HASH :LITTLE-ENDIAN
              :ECL-READ-WRITE-LOCK :SSE2 :LONG-LONG :UINT64-T :UINT32-T
              :UINT16-T :COMPLEX-FLOAT :LONG-FLOAT :UNICODE :DFFI :CLOS-STREAMS
              :CMU-FORMAT :UNIX :ECL-PDE :DLOPEN :CLOS :THREADS :BOEHM-GC
              :ANSI-CL :COMMON-LISP :FLOATING-POINT-EXCEPTIONS
              :IEEE-FLOATING-POINT :PACKAGE-LOCAL-NICKNAMES :CDR-14
              :PREFIXED-API :FFI :X86_64 :COMMON :ECL)
Edited by q3cpma