#606 probe-pathname set :newest version

lisp error
closed-fixed
Sam Steingold
clisp (525)
5
2011-09-16
2011-09-06
Gabor Balazs
No

$ clisp --version
GNU CLISP 2.49 (2010-07-07) (built 3519331083) (memory 3519302729)
Software: GNU C 4.4.5
gcc -O2 -march=core2 -fomit-frame-pointer -pipe -Wa,--noexecstack -W -Wswitch -Wcomment -Wpointer-arith -Wimplicit -Wreturn-type -Wmissing-declarations -Wno-sign-compare -Wno-format-nonliteral -O -falign-functions=4 -DENABLE_UNICODE -DDYNAMIC_FFI -I. -Wl,-O1 -Wl,--as-needed /usr/lib64/libreadline.so -lncurses -ldl /usr/lib64/libavcall.a /usr/lib64/libcallback.a -L/usr/lib64 -lsigsegv -L/usr/lib64 -lc libgnu_cl.a
SAFETY=0 TYPECODES WIDE_HARD GENERATIONAL_GC SPVW_BLOCKS SPVW_MIXED TRIVIALMAP_MEMORY
libsigsegv 2.8
libreadline 6.1
Features:
(READLINE REGEXP SYSCALLS I18N LOOP COMPILER CLOS MOP CLISP ANSI-CL COMMON-LISP
LISP=CL INTERPRETER SOCKETS GENERIC-STREAMS LOGICAL-PATHNAMES SCREEN FFI
GETTEXT UNICODE BASE-CHAR=CHARACTER WORD-SIZE=64 PC386 UNIX)
C Modules: (clisp i18n syscalls regexp readline)
Installation directory: /usr/lib64/clisp-2.49/
User language: ENGLISH
Machine: X86_64 (X86_64) localhost [127.0.0.1]

The problem:

probe-pathname sets the version field to :NEWEST, and so this pathname is never EQUAL to another one returned by PATHNAME.

(pathname-version (probe-pathname "/tmp/"))
:NEWEST ; this should be NIL

(equal (probe-pathname "/tmp/") (pathname "/tmp/"))
NIL

Furthermore, MAKE-PATHNAME does not initializes the VERSION slot in the following case:

(defparameter *path* (probe-pathname "/tmp/"))
*PATH*

(pathname-version (make-pathname :version NIL :defaults *path*))
:NEWEST ; this should be NIL

This workaround can be done, but this is ugly:

(pathname-version (make-pathname :version NIL :name (pathname-name *path*) :defaults *path*))
NIL

Discussion

1 2 > >> (Page 1 of 2)
  • Gabor Balazs
    Gabor Balazs
    2011-09-11

    Unfortunately, there is even more related bugs like this.

    (length (directory "/tmp/*/"))
    13

    (length (directory "/tmp/*"))
    7

    So my /tmp directory has files and directories too, then:

    (pathname-version (car (directory "/tmp/*/")))
    NIL ; correct

    (pathname-version (car (directory "/tmp/*")))
    :NEWEST ; should be NIL!

    But the file pathname creation seems to be good

    (pathname-version (pathname "does-not-exist.dne"))
    NIL

     
  • Gabor Balazs
    Gabor Balazs
    2011-09-11

    Furthermore,

    (pathname-version (pathname "/tmp/"))
    NIL ; ok
    (pathname-version (pathname "dir/"))
    NIL ; ok
    (pathname-version (pathname "file"))
    NIL ; ok

    (pathname-version (merge-pathnames "dir/" "/tmp/"))
    :NEWEST ; should be NIL!
    (pathname-version (merge-pathnames "file" "/tmp/"))
    :NEWEST ; should be NIL!

     
  • Sam Steingold
    Sam Steingold
    2011-09-13

    This bug report is now marked as "pending"/"invalid".
    This means that we think that the problem you report is not a problem with CLISP.
    Unless you - the reporter - act within 2 weeks, the bug will be permanently closed.
    Sorry about the inconvenience - we hope your silence means that you agree that this is not a bug in CLISP.

     
  • Sam Steingold
    Sam Steingold
    2011-09-13

    • assigned_to: haible --> sds
    • status: open --> pending-invalid
     
  • Sam Steingold
    Sam Steingold
    2011-09-13

    http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/fun_merge-pathnames.html
    default-version---a valid pathname version. The default is :newest

    i.e., whenever pathnames are merged without an explicit default-version argument,
    the result will have the :newest version unless the original pathnames have non-trivial versions
    which is unlikely because no modern filesystem has a notion of a version built-in.

    i.e., the behavior you are complaining about is mandated by the standard.
    moreover, it is at least somewhat useful because it lets you know whether the pathname is a result of a merge with *default-pathname-defaults* or of raw parsing.

     
  • Gabor Balazs
    Gabor Balazs
    2011-09-13

    I see your point, but I think there are still problems.

    Problem #1:

    http://www.lispworks.com/documentation/HyperSpec/Body/f_merge_.htm
    The standard says: "If pathname does not specify a name, then the version, if not provided, will come from default-pathname, just like the other components."

    (pathname-version (merge-pathnames "dir/" "/tmp/"))
    :NEWEST ; so this should be NIL

    as fortunately
    (pathname-version "/tmp/")
    NIL

    Problem #2:

    (pathname-version (probe-pathname "/tmp/file"))
    NIL

    (pathname-version (probe-pathname "/tmp/dir/"))
    NIL

    (pathname-version (probe-pathname "/tmp/"))
    :NEWEST ; should be NIL

    I think CLISP should be consistent here. Why does it return :NEWEST in the last case?

    Problem #3:

    (pathname-version (car (directory "/tmp/*/")))
    NIL

    (pathname-version (car (directory "/tmp/*")))
    :NEWEST

    Is there any way to let CLISP's directory function return NIL in this last case?
    Otherwise I have to convert all the file pathnames if I want consistency.
    Eg, I want to compare pathnames with the equal function.

     
  • Gabor Balazs
    Gabor Balazs
    2011-09-13

    • status: pending-invalid --> open-invalid
     
  • Sam Steingold
    Sam Steingold
    2011-09-14

    1. set *parse-namestring-ansi* to T so that symbols are not treated as pathname designators.
    in your case when (probe-pathname "nonexistent") returns NIL, pathname-version converts it to a pathname with NIL version. see <http://clisp.org/impnotes/filename-misc.html#parsename>

    2. from what I can see, clisp always returns :newest for versions of truenames. I don't see any problems with that.

     
  • Sam Steingold
    Sam Steingold
    2011-09-14

    • status: open-invalid --> pending-invalid
     
  • Sam Steingold
    Sam Steingold
    2011-09-14

    1. set *parse-namestring-ansi* to T so that symbols are not treated as pathname designators.
    in your case when (probe-pathname "nonexistent") returns NIL, pathname-version converts it to a pathname with NIL version. see <http://clisp.org/impnotes/filename-misc.html#parsename>

    2. from what I can see, clisp always returns :newest for versions of truenames. I don't see any problems with that.

     
1 2 > >> (Page 1 of 2)