Subject: [clisp-list] Problems with MAKE-PATHNAME in clisp

From: Kent M Pitman <[email-masked]>
Date: Mon Nov 12 11:30:04 2001

In CLISP
"2.27.2 (released 2001-10-05) (built 3214510376) (memory 3214510483)"

if I do

 (make-pathname :name "FOO" :case :common :defaults #P"/home/kent/")

I get back #P"/HOME/KENT/foo" where I expect #P"/home/kent/foo".

The source (clisp/src/pathname.d) is impenetrable to me (not being
written in Lisp, and my German not being any good) but it looks to me
both from the effect and from some code comments you have where you
write (pathname-directory pathname) that maybe you are grabbing the
components of the defaults in the default case mode (which would be
:local if you call PATHNAME-DIRECTORY with no :case argument) and then
filling them in the case mode I supplied (which is :common), which
ends up flipping the case.

I personally believe the right thing is always to fill unsupplied
components from :defaults by grabbing them in :common case and storing
them in :common case, independent of what is supplied as the :case
argument.   [One might make the case that you could also grab them in
:local and store in :local (which you are not doing either), but I
think that is going to go wrong in pathological cases where you are
making a pathname from a filename with one neutral case convention 
and defaulting from a filename with a different neutral case convention.]

I hope this is enough information for you to figure out and correct
the problem.  I certainly know I have no hope of correcting the
problem.

(I'm somewhat surprised some of this stuff isn't coded in Lisp.)

---

From: Harley Gorrell <[email-masked]>
Date: Mon Nov 12 11:44:03 2001

> I get back #P"/HOME/KENT/foo" where I expect #P"/home/kent/foo".

   Humm... With a different version I get different answer.
Perhaps a downgrade would help?

| viano 1 harley $uname -a
| Linux viano.neomorphic.com 2.2.14-5.0smp #1 SMP Tue Mar 7 21:01:40 EST 2000 i686 unknown
|
| viano 2 harley $clisp --version
| GNU CLISP 2.27 (released 2001-07-17) (built 3211125895) (memory 3211126047)
|
| viano 3 harley $clisp
| [1]>  (make-pathname :name "FOO" :case :common :defaults #P"/home/kent/")
| #P"/home/kent/foo"

harley.

---

From: Sam Steingold <[email-masked]>
Date: Mon Nov 12 14:46:01 2001

> * In message <[email-masked]>
> * On the subject of "[clisp-list] Problems with MAKE-PATHNAME in clisp"
> * Sent on Mon, 12 Nov 2001 14:14:54 -0500
> * Honorable Kent M Pitman <[email-masked]> writes:
>
> In CLISP

this bug was introduced on 2001-07-20 in an attempt to to make the
following work (from a pathname test suite posted to c.l.l in July):

(defun foo (x)
  (let ((path (make-pathname
               :defaults (make-pathname :directory
                                        '(:relative :wild-inferiors)
                                        :type x :case :common)
               :host "CL-LIBRARY" :case :common)))
    (string= x (pathname-type path))))

(foo "c")
 ==> t

(foo "C")
 ==> t

You message, as well as issue PATHNAME-COMPONENT-CASE, appear to
indicate that :CASE does _not_ apply to the :DEFAULTS argument to
MAKE-PATHNAME (I.e., FOO should return NIL, not T).
Is this correct?
If it is, I can easily fix the problem (by reverting to the previous
behavior, which was taking the stuff out of defaults as is and putting
it into the new pathname as is).

Thanks for the bug report.
(I wish all our users were as clear as to what and _WHY_ they did not
like!)
 
-- 
Sam Steingold (http://www.podval.org/~sds)
Keep Jerusalem united! <http://www.onejerusalem.org/Petition.asp>
Read, think and remember! <http://www.iris.org.il> <http://www.memri.org/>
Winners never quit; quitters never win; idiots neither win nor quit.

---

From: Kent M Pitman <[email-masked]>
Date: Mon Nov 12 16:24:02 2001

Date: 12 Nov 2001 17:44:18 -0500
   From: Sam Steingold <[email-masked]>

   (defun foo (x)

   (foo "c")
    ==> t

   (foo "C")
    ==> t

I believe this is wrong.  IMO, both should return NIL.  They should return
T if you use :case :common to retrieve the type.  The change in case
is unpredictable if you store using :common case and retrieve with
:local case (which is lamentably the default if :case is not supplied).

Well, :case does not apply to any pathname.  :case is about a translation
mode when storing or retrieving individual components as strings.  The
actual internal case you use is not specified.  

But yes, my personal opinion is that FOO should return NIL.

LispWorks Enterprise 4.1.20 returns NIL.  (I checked this AFTER
deciding what I thought it should return, so my opinion counts as an
independent guess.)

I was going to check it in Allegro but my test license has expired. Sigh.

Let me see if I can explain what I think this is all about.

The purpose of common case is to solve the problem of defaulting between
hosted pathnames that have different notions of canonical case.  e.g.,
grabbing the NAME part from a TOPS-20 pathname and the TYPE part from
a Unix pathname.  The idea is to do a fetch during merging of any
given slot in :common and to store it in the same mode.  That way, it will
change case naturally to the proper case of the new system.  That's
what MERGE-PATHNAMES should do, for example.  But in the case of 
MAKE-PATHNAME, the user manually  calls PATHNAME-NAME and friends for
purposes the system doesn't know, so the user has to remember to do
the store back in the same mode. The system has lost track of the data
path between the extract and restore and so can't assure a consistent use
of :COMMON.

Note that in some Lisp implementations, and  yours may be one, it
might also work to consistently use :LOCAL.  I've never thought this through.
But in the general case, if you have access to file systems with
opposite notions of what case is canonical, if you extract in :LOCAL case
from a TOPS-20 you'll get "FOO" in the normal case of <JDOE>FOO.LISP
and when you store the same "FOO" back in :LOCAL to a Unix pathname,
you'll get FOO.lsp instead of foo.lsp.  But if you only have Unix
pathnames, it would work to use :local to both extract and deposit components.
(The reason I say I'm unsure is I don't recall what the canonical case
is for logical pathnames, and am too lazy to go look at this moment.
If it's uppercase, as I suspect it is, then 
 (make-pathname
    :host my-logical-host
    :name (pathname-name my-unix-pathname :type :local)
    :case :local)
will accidentally flip the case while
 (make-pathname
    :host my-logical-host
    :name (pathname-name my-unix-pathname :type :common)
    :case :common)
will not.

Not a problem.

---

From: Erik Arneson <[email-masked]>
Date: Mon Nov 12 16:29:04 2001

> I was going to check it in Allegro but my test license has expired. Sigh.

ACL returns T in both cases.

By the way, you can get new test licenses now for as long as you
want...they don't stop you anymore.

-- 
# Erik Arneson <[email-masked]>    AARG Net <http://www.aarg.net/> #
# GPG Key ID: 1024D/43AD6AB8           <http://erik.arneson.org/> #
# "Resistance to tyrants is obedience to God!" - Thomas Jefferson #

---

From: Kent M Pitman <[email-masked]>
Date: Mon Nov 12 16:41:04 2001

Date: Mon, 12 Nov 2001 16:28:08 -0800
   From: Erik Arneson <[email-masked]>

I hate to ask, but do they implement :case :common at all?

I'd love to see explained by what theory anyone tought this should
return T.  I understand my model of the universe but not the model of
whoever wrote that test case.

Yeah, I've heard that, too.  But every time I've had to deal with them
about licenses, I get a form asking me to fill out my life history.
It makes me want to procrastinate...