[armedbear-devel] Conformity and convenience problems with pathnames

Pascal J. Bourguignon pjb at informatimago.com
Sun Nov 21 03:19:14 UTC 2010


Hello,

It is well known that implementations of CL pathnames have been greatly
implementation dependant.  However, the standard still specifies clear
behavior for logical pathnames, for one thing, and for the other, since
there are several implementations working on the same POSIX systems
(unix including linux and MacOSX; and MS-Windows), it is desirable that
all implementations converge in their handling of pathnames on these
plateforms.

Personnaly, I resolved to use logical pathnames and logical-pathname
translations as much as possible, and to use make-pathname to build
portably physical pathnames. 

However, most implementations have problems dealing with these two
aspects.   To improve the situation, I wrote a little script to check
the behavior of implementations in these two aspects.

The script can be found at:

ftp://ftp.informatimago.com/users/pjb/lisp/check-pathnames.lisp

Since I'm sending a similar message to most implementation  lists, it
might be better, if there is any need for 'language lawyer' discussions,
to direct them to news:comp.lang.lisp.


Here are the results for the latest abcl (from svn):
------------------------------------------------------------------------
[pjb at kuiper :0.0 lisp]$ abcl --noinit --load check-pathnames.lisp
Armed Bear Common Lisp 0.24.0-dev
Java 1.6.0_22 Sun Microsystems Inc.
Java HotSpot(TM) 64-Bit Server VM
Low-level initialization completed in 0.244 seconds.
Startup completed in 0.766 seconds.
check-pathnames of Armed Bear Common Lisp (0.24.0-dev)

================================================================================

Test and probe conforming logical pathnames, and their translation to
unix physical pathnames.

We want to check the good working of logical pathnames, and the
translation of logical pathnames to physical pathnames, in a
semi-standard way on unix systems.

Namely, given the logical host and its translations:

  (setf (logical-pathname-translations "LOGICAL") nil)
  (setf (logical-pathname-translations "LOGICAL") 
        '((#P"LOGICAL:**;*.*" #P"/tmp/**/*.*")
          (#P"LOGICAL:**;*"   #P"/tmp/**/*")))

#P"LOGICAL:DIR;SUBDIR;NAME.TYPE.NEWEST"
must be the same as (make-pathname :host "LOGICAL"
                                   :directory '(:absolute "DIR" "SUBDIR")
                                   :name "NAME" :type "TYPE" :version :newest
                                   :case :common)
and must translate to: #P"/tmp/dir/subdir/name.type" on unix.



Merging physical pathnames specified with :case :common is also tested:

  (merge-pathnames (make-pathname :directory '(:relative "DIR" "SUBDIR")
                                  :name "NAME" :type "TYPE" :version :newest
                                  :case :common :default #1=#P"/tmp/")
                    #1# nil)

must give #P"/tmp/dir/subdir/name.type" on unix.

================================================================================
--------------------------------------------------------------------------------
Failed assertion: (IMPLY (EQL CUSTOMARY-CASE-1 :UPPER)
                         (EQL CUSTOMARY-CASE-2 :UPPER))
   with: (EQL CUSTOMARY-CASE-1 :UPPER) = T
    and: (EQL CUSTOMARY-CASE-2 :UPPER) = NIL
CUSTOMARY-CASE-1 = :UPPER
CUSTOMARY-CASE-2 = :LOWER



The customary case for the file system of Armed Bear Common Lisp (0.24.0-dev) 
seems to be lower case.


*FEATURES* = (:X86-64 :JAVA-1.6 :ARMEDBEAR :ABCL :COMMON-LISP :ANSI-CL :UNIX
              :LINUX :CDR6)





================================================================================
(MAKE-PATHNAME :HOST
               "LOGICAL"
               :DEVICE
               :UNSPECIFIC
               :DIRECTORY
               (:ABSOLUTE "DIR" "SUBDIR")
               :NAME
               "NAME"
               :TYPE
               "TYPE"
               :VERSION
               :NEWEST
               :CASE
               :COMMON)


LOGICAL-PATHNAME #P"LOGICAL:DIR;SUBDIR;NAME.TYPE.NEWEST"
--------------------  :case :local (default)
Host      : "LOGICAL"
Device    : :UNSPECIFIC
Directory : (:ABSOLUTE "DIR" "SUBDIR")
Name      : "NAME"
Type      : "TYPE"
Version   : :NEWEST
--------------------  :case :common
Host      : "LOGICAL"
Device    : :UNSPECIFIC
Directory : (:ABSOLUTE "DIR" "SUBDIR")
Name      : "NAME"
Type      : "TYPE"
Version   : :NEWEST
--------------------  
--------------------------------------------------------------------------------
Failed assertion: (STRING= (PATHNAME-HOST PATH :CASE :LOCAL)
                           (POP EXPECTED-VALUES))
   with: (PATHNAME-HOST PATH :CASE :LOCAL) = "LOGICAL"
    and: (POP EXPECTED-VALUES) = "logical"
19.2.2.1.2  makes no exception for pathname-host of logical pathnames.
--------------------------------------------------------------------------------
Failed assertion: (DIRLIST= (PATHNAME-DIRECTORY PATH :CASE :LOCAL)
                            (POP EXPECTED-VALUES))
   with: (PATHNAME-DIRECTORY PATH :CASE :LOCAL) = (:ABSOLUTE "DIR" "SUBDIR")
    and: (POP EXPECTED-VALUES) = (:ABSOLUTE "dir" "subdir")
--------------------------------------------------------------------------------
Failed assertion: (STRING= (PATHNAME-NAME PATH :CASE :LOCAL)
                           (POP EXPECTED-VALUES))
   with: (PATHNAME-NAME PATH :CASE :LOCAL) = "NAME"
    and: (POP EXPECTED-VALUES) = "name"
--------------------------------------------------------------------------------
Failed assertion: (STRING= (PATHNAME-TYPE PATH :CASE :LOCAL)
                           (POP EXPECTED-VALUES))
   with: (PATHNAME-TYPE PATH :CASE :LOCAL) = "TYPE"
    and: (POP EXPECTED-VALUES) = "type"



================================================================================
(MAKE-PATHNAME :HOST
               "logical"
               :DEVICE
               :UNSPECIFIC
               :DIRECTORY
               (:ABSOLUTE "dir" "subdir")
               :NAME
               "name"
               :TYPE
               "type"
               :VERSION
               :NEWEST
               :CASE
               :LOCAL)


LOGICAL-PATHNAME #P"LOGICAL:DIR;SUBDIR;NAME.TYPE.NEWEST"
--------------------  :case :local (default)
Host      : "LOGICAL"
Device    : :UNSPECIFIC
Directory : (:ABSOLUTE "DIR" "SUBDIR")
Name      : "NAME"
Type      : "TYPE"
Version   : :NEWEST
--------------------  :case :common
Host      : "LOGICAL"
Device    : :UNSPECIFIC
Directory : (:ABSOLUTE "DIR" "SUBDIR")
Name      : "NAME"
Type      : "TYPE"
Version   : :NEWEST
--------------------  
--------------------------------------------------------------------------------
Failed assertion: (STRING= (PATHNAME-HOST PATH :CASE :LOCAL)
                           (POP EXPECTED-VALUES))
   with: (PATHNAME-HOST PATH :CASE :LOCAL) = "LOGICAL"
    and: (POP EXPECTED-VALUES) = "logical"
19.2.2.1.2  makes no exception for pathname-host of logical pathnames.
--------------------------------------------------------------------------------
Failed assertion: (DIRLIST= (PATHNAME-DIRECTORY PATH :CASE :LOCAL)
                            (POP EXPECTED-VALUES))
   with: (PATHNAME-DIRECTORY PATH :CASE :LOCAL) = (:ABSOLUTE "DIR" "SUBDIR")
    and: (POP EXPECTED-VALUES) = (:ABSOLUTE "dir" "subdir")
--------------------------------------------------------------------------------
Failed assertion: (STRING= (PATHNAME-NAME PATH :CASE :LOCAL)
                           (POP EXPECTED-VALUES))
   with: (PATHNAME-NAME PATH :CASE :LOCAL) = "NAME"
    and: (POP EXPECTED-VALUES) = "name"
--------------------------------------------------------------------------------
Failed assertion: (STRING= (PATHNAME-TYPE PATH :CASE :LOCAL)
                           (POP EXPECTED-VALUES))
   with: (PATHNAME-TYPE PATH :CASE :LOCAL) = "TYPE"
    and: (POP EXPECTED-VALUES) = "type"

--------------------------------------------------------------------------------
Failed assertion: ((LAMBDA (DIRLIST PATH)
                     (EQUAL DIRLIST (PATHNAME-DIRECTORY PATH :CASE :LOCAL)))
                   '(:ABSOLUTE "tmp" "dir" "subdir")
                   (MERGE-PATHNAMES (MAKE-PATHNAME :DIRECTORY
                                                   '(:RELATIVE "DIR" "SUBDIR")
                                                   :NAME
                                                   "NAME"
                                                   :TYPE
                                                   "TYPE"
                                                   :CASE
                                                   :COMMON
                                                   :DEFAULTS
                                                   #P"/tmp/")
                                    #P"/tmp/"
                                    NIL))
   with: '(:ABSOLUTE "tmp" "dir" "subdir") = (:ABSOLUTE "tmp" "dir" "subdir")
    and: (MERGE-PATHNAMES (MAKE-PATHNAME :DIRECTORY
                                         '(:RELATIVE "DIR" "SUBDIR")
                                         :NAME
                                         "NAME"
                                         :TYPE
                                         "TYPE"
                                         :CASE
                                         :COMMON
                                         :DEFAULTS
                                         #P"/tmp/")
                          #P"/tmp/"
                          NIL) = #P"/tmp/DIR/SUBDIR/NAME.TYPE"

PATHNAME #P"/tmp/DIR/SUBDIR/NAME.TYPE"
--------------------  :case :local (default)
Host      : NIL
Device    : NIL
Directory : (:ABSOLUTE "tmp" "DIR" "SUBDIR")
Name      : "NAME"
Type      : "TYPE"
Version   : NIL
--------------------  :case :common
Host      : NIL
Device    : NIL
Directory : (:ABSOLUTE "tmp" "DIR" "SUBDIR")
Name      : "NAME"
Type      : "TYPE"
Version   : NIL
--------------------  
--------------------------------------------------------------------------------
Failed assertion: ((LAMBDA (NAME PATH)
                     (EQUAL NAME (PATHNAME-NAME PATH :CASE :LOCAL)))
                   "name"
                   (MERGE-PATHNAMES (MAKE-PATHNAME :DIRECTORY
                                                   '(:RELATIVE "DIR" "SUBDIR")
                                                   :NAME
                                                   "NAME"
                                                   :TYPE
                                                   "TYPE"
                                                   :CASE
                                                   :COMMON
                                                   :DEFAULTS
                                                   #P"/tmp/")
                                    #P"/tmp/"
                                    NIL))
   with: "name" = "name"
    and: (MERGE-PATHNAMES (MAKE-PATHNAME :DIRECTORY
                                         '(:RELATIVE "DIR" "SUBDIR")
                                         :NAME
                                         "NAME"
                                         :TYPE
                                         "TYPE"
                                         :CASE
                                         :COMMON
                                         :DEFAULTS
                                         #P"/tmp/")
                          #P"/tmp/"
                          NIL) = #P"/tmp/DIR/SUBDIR/NAME.TYPE"

PATHNAME #P"/tmp/DIR/SUBDIR/NAME.TYPE"
--------------------  :case :local (default)
Host      : NIL
Device    : NIL
Directory : (:ABSOLUTE "tmp" "DIR" "SUBDIR")
Name      : "NAME"
Type      : "TYPE"
Version   : NIL
--------------------  :case :common
Host      : NIL
Device    : NIL
Directory : (:ABSOLUTE "tmp" "DIR" "SUBDIR")
Name      : "NAME"
Type      : "TYPE"
Version   : NIL
--------------------  
--------------------------------------------------------------------------------
Failed assertion: ((LAMBDA (TYPE PATH)
                     (EQUAL TYPE (PATHNAME-TYPE PATH :CASE :LOCAL)))
                   "type"
                   (MERGE-PATHNAMES (MAKE-PATHNAME :DIRECTORY
                                                   '(:RELATIVE "DIR" "SUBDIR")
                                                   :NAME
                                                   "NAME"
                                                   :TYPE
                                                   "TYPE"
                                                   :CASE
                                                   :COMMON
                                                   :DEFAULTS
                                                   #P"/tmp/")
                                    #P"/tmp/"
                                    NIL))
   with: "type" = "type"
    and: (MERGE-PATHNAMES (MAKE-PATHNAME :DIRECTORY
                                         '(:RELATIVE "DIR" "SUBDIR")
                                         :NAME
                                         "NAME"
                                         :TYPE
                                         "TYPE"
                                         :CASE
                                         :COMMON
                                         :DEFAULTS
                                         #P"/tmp/")
                          #P"/tmp/"
                          NIL) = #P"/tmp/DIR/SUBDIR/NAME.TYPE"

PATHNAME #P"/tmp/DIR/SUBDIR/NAME.TYPE"
--------------------  :case :local (default)
Host      : NIL
Device    : NIL
Directory : (:ABSOLUTE "tmp" "DIR" "SUBDIR")
Name      : "NAME"
Type      : "TYPE"
Version   : NIL
--------------------  :case :common
Host      : NIL
Device    : NIL
Directory : (:ABSOLUTE "tmp" "DIR" "SUBDIR")
Name      : "NAME"
Type      : "TYPE"
Version   : NIL
--------------------  
Type ":help" for a list of available commands.
CL-USER(1): (quit)
[pjb at kuiper :0.0 lisp]$ 


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.





More information about the armedbear-devel mailing list