#577 Conformity and convenience problems with pathnames

open
Bruno Haible
clisp (525)
5
2010-11-21
2010-11-21
No

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 clisp:
------------------------------------------------------------------------
[pjb@kuiper :0.0 ~]$ clisp -ansi -norc
i i i i i i i ooooo o ooooooo ooooo ooooo
I I I I I I I 8 8 8 8 8 o 8 8
I \ `+' / I 8 8 8 8 8 8
\ `-+-' / 8 8 8 ooooo 8oooo
`-__|__-' 8 8 8 8 8
| 8 o 8 8 o 8 8
------+------ ooooo 8oooooo ooo8ooo ooooo 8

Welcome to GNU CLISP 2.49 (2010-07-07) <http://clisp.cons.org/>

Copyright (c) Bruno Haible, Michael Stoll 1992, 1993
Copyright (c) Bruno Haible, Marcus Daniels 1994-1997
Copyright (c) Bruno Haible, Pierpaolo Bernardi, Sam Steingold 1998
Copyright (c) Bruno Haible, Sam Steingold 1999-2000
Copyright (c) Sam Steingold, Bruno Haible 2001-2010

Type :h and hit Enter for context help.

[1]> (load "/home/pjb/src/lisp/check-pathnames.lisp")
;; Loading file /home/pjb/src/lisp/check-pathnames.lisp ...
================================================================================

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".

================================================================================
The customary case for the file system of CLISP (2.49 (2010-07-07) (built
3498306068) (memory 3498306421)) is lower case.

================================================================================
(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: (DIRLIST= (PATHNAME-DIRECTORY PATH :CASE :COMMON) (POP EXPECTED-VALUES))
with: (PATHNAME-DIRECTORY PATH :CASE :COMMON) = (:ABSOLUTE "dir" "subdir")
and: (POP EXPECTED-VALUES) = (:ABSOLUTE "DIR" "SUBDIR")
--------------------------------------------------------------------------------
Failed assertion: (STRING= (PATHNAME-NAME PATH :CASE :COMMON) (POP EXPECTED-VALUES))
with: (PATHNAME-NAME PATH :CASE :COMMON) = "name"
and: (POP EXPECTED-VALUES) = "NAME"
--------------------------------------------------------------------------------
Failed assertion: (STRING= (PATHNAME-TYPE PATH :CASE :COMMON) (POP EXPECTED-VALUES))
with: (PATHNAME-TYPE PATH :CASE :COMMON) = "type"
and: (POP EXPECTED-VALUES) = "TYPE"
--------------------------------------------------------------------------------
Failed assertion: (STRING= EXPECTED-PRINTED (PRIN1-TO-STRING PATH))
with: EXPECTED-PRINTED = "#P\"LOGICAL:DIR;SUBDIR;NAME.TYPE\""
and: (PRIN1-TO-STRING PATH) = "#P\"LOGICAL:dir;subdir;name.type.NEWEST\""

It would be better if logical pathnames were printed using upper case
letters, mostly because of 19.3.1.1.7, and because:

22.1.1 Overview of The Lisp Printer

Reading a printed representation typically produces an object that is
equal to the originally printed object.

and

2.4.8.14 Sharpsign P

#P reads a following object, which must be a string.

#P<<expression>> is equivalent to #.(parse-namestring '<<expression>>),
except that #P is not affected by *read-eval*.

and

Function PARSE-NAMESTRING

* If host is nil and thing is a syntactically valid logical pathname
namestring containing an explicit host, then it is parsed as a
logical pathname namestring.

and

19.3.1.1.7 Lowercase Letters in a Logical Pathname Namestring
When parsing words and wildcard-words, lowercase letters are translated to uppercase.

Notice that means that a logical pathname built with mixed cases (or
lower case), cannot be printed readably with a conforming syntax (but
it doesn't matter, since it's not a conforming logical pathname
anyways).
--------------------------------------------------------------------------------
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.

================================================================================
(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: (DIRLIST= (PATHNAME-DIRECTORY PATH :CASE :COMMON) (POP EXPECTED-VALUES))
with: (PATHNAME-DIRECTORY PATH :CASE :COMMON) = (:ABSOLUTE "dir" "subdir")
and: (POP EXPECTED-VALUES) = (:ABSOLUTE "DIR" "SUBDIR")
--------------------------------------------------------------------------------
Failed assertion: (STRING= (PATHNAME-NAME PATH :CASE :COMMON) (POP EXPECTED-VALUES))
with: (PATHNAME-NAME PATH :CASE :COMMON) = "name"
and: (POP EXPECTED-VALUES) = "NAME"
--------------------------------------------------------------------------------
Failed assertion: (STRING= (PATHNAME-TYPE PATH :CASE :COMMON) (POP EXPECTED-VALUES))
with: (PATHNAME-TYPE PATH :CASE :COMMON) = "type"
and: (POP EXPECTED-VALUES) = "TYPE"
--------------------------------------------------------------------------------
Failed assertion: (STRING= EXPECTED-PRINTED (PRIN1-TO-STRING PATH))
with: EXPECTED-PRINTED = "#P\"LOGICAL:DIR;SUBDIR;NAME.TYPE\""
and: (PRIN1-TO-STRING PATH) = "#P\"LOGICAL:dir;subdir;name.type.NEWEST\""

It would be better if logical pathnames were printed using upper case
letters, mostly because of 19.3.1.1.7, and because:

22.1.1 Overview of The Lisp Printer

Reading a printed representation typically produces an object that is
equal to the originally printed object.

and

2.4.8.14 Sharpsign P

#P reads a following object, which must be a string.

#P<<expression>> is equivalent to #.(parse-namestring '<<expression>>),
except that #P is not affected by *read-eval*.

and

Function PARSE-NAMESTRING

* If host is nil and thing is a syntactically valid logical pathname
namestring containing an explicit host, then it is parsed as a
logical pathname namestring.

and

19.3.1.1.7 Lowercase Letters in a Logical Pathname Namestring
When parsing words and wildcard-words, lowercase letters are translated to uppercase.

Notice that means that a logical pathname built with mixed cases (or
lower case), cannot be printed readably with a conforming syntax (but
it doesn't matter, since it's not a conforming logical pathname
anyways).
--------------------------------------------------------------------------------
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:
(PATHNAME-EQUAL #P"LOGICAL:DIR;SUBDIR;NAME.TYPE.NEWEST"
(MAKE-PATHNAME :HOST "LOGICAL" :DEVICE :UNSPECIFIC :DIRECTORY
'(:ABSOLUTE "DIR" "SUBDIR") :NAME "NAME" :TYPE "TYPE" :VERSION :NEWEST :CASE
:COMMON))
with: #P"LOGICAL:DIR;SUBDIR;NAME.TYPE.NEWEST" = #P"LOGICAL:DIR;SUBDIR;NAME.TYPE.NEWEST"
and:
(MAKE-PATHNAME :HOST "LOGICAL" :DEVICE :UNSPECIFIC :DIRECTORY
'(:ABSOLUTE "DIR" "SUBDIR") :NAME "NAME" :TYPE "TYPE" :VERSION :NEWEST :CASE
:COMMON) = #P"LOGICAL:dir;subdir;name.type.NEWEST"

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
--------------------

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
--------------------
;; Loaded file /home/pjb/src/lisp/check-pathnames.lisp
T
[2]> (quit)
Bye.
[pjb@kuiper :0.0 ~]$

Discussion

  • New version of check-pathnames.lisp script.

     
    Attachments
  • Sam Steingold
    Sam Steingold
    2011-01-02

    there have been some discussion on c.l.l which seems to have invalidated some of these tests

     
  • Sam Steingold
    Sam Steingold
    2011-04-06

    does the latest version reflect the c.l.l consensus (such as there is)?