gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: enough-namestring doesn't work?


From: Camm Maguire
Subject: Re: enough-namestring doesn't work?
Date: Mon, 29 May 2023 11:56:07 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

Greetings, and thanks for your feedback!

(enough-namestring #P"/a/b/c/d.txt" #P"/a/b/c/") -> "d.txt"

gcl's version does not unpack the directory component into segments but
just compares the pathanme components with the default as whole units:

(DEFUN ENOUGH-NAMESTRING
       (X &OPTIONAL (DEF *DEFAULT-PATHNAME-DEFAULTS*) &AUX
          (PX (PATHNAME X)) (PDEF (PATHNAME DEF)))
  (DECLARE (OPTIMIZE (SAFETY 1)))
  (CHECK-TYPE X PATHNAME-DESIGNATOR)
  (CHECK-TYPE DEF PATHNAME-DESIGNATOR)
  (NAMESTRING
      (MAKE-PATHNAME :HOST
          (LET ((K (PATHNAME-HOST PX)))
            (UNLESS (EQUAL K (PATHNAME-HOST PDEF)) K))
          :DEVICE
          (LET ((K (PATHNAME-DEVICE PX)))
            (UNLESS (EQUAL K (PATHNAME-DEVICE PDEF)) K))
          :DIRECTORY
          (LET ((K (PATHNAME-DIRECTORY PX)))
            (UNLESS (EQUAL K (PATHNAME-DIRECTORY PDEF)) K))
          :NAME
          (LET ((K (PATHNAME-NAME PX)))
            (UNLESS (EQUAL K (PATHNAME-NAME PDEF)) K))
          :TYPE
          (LET ((K (PATHNAME-TYPE PX)))
            (UNLESS (EQUAL K (PATHNAME-TYPE PDEF)) K))
          :VERSION
          (LET ((K (PATHNAME-VERSION PX)))
            (UNLESS (EQUAL K (PATHNAME-VERSION PDEF)) K)))))

It seems this is compliant given the spec:

=============================================================================
enough-namestring returns an abbreviated namestring that is just sufficient to 
identify the file named by pathname when considered relative to the defaults. 
It is required that

 (merge-pathnames (enough-namestring pathname defaults) defaults)
==  (merge-pathnames (parse-namestring pathname nil defaults) defaults)

in all cases, and the result of enough-namestring is the shortest reasonable 
string that will satisfy this criterion.

It is not necessarily possible to construct a valid namestring by concatenating 
some of the three shorter namestrings in some order.
=============================================================================

Perhaps this could be improved.

Take care,

Raymond Toy <toy.raymond@gmail.com> writes:

> I tried the followin: (enough-namestring #P"/a/b/c/d.txt" #P"/a/b/"). I was 
> expecting "c/d.txt". But gcl 2.6.13 release returns “/a/b/c/d.txt”. I 
> actually can’t find any example where enough-namestring produces anything 
> other than the namestring for the
> first arg.
>
> How do I invoke enough-namestring to produce what I want, like other lisps do?
>
>
>

-- 
Camm Maguire                                        camm@maguirefamily.org
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah



reply via email to

[Prev in Thread] Current Thread [Next in Thread]