[Openmcl-devel] ENOUGH-NAMESTRING is broken

Hans Hübner hans at huebner.org
Wed Nov 14 08:28:22 PST 2007


Hi,

enough-namestring is broken for if P"/" is passed as the defaults parameter:

(enough-namestring "/foo/bar" "/") => "/foo/bar" ;; wrong

but

(enough-namestring "/foo" "/") => "foo"
and
(enough-namestring "/foo/bar/baz" "/foo/") => "bar/baz"

I looked at the source of enough-namestring, and for some reason that
is not apparent to me there is explicit code in there which creates
this behavior.  Is there a good reason for that?  It is a bug as the
spec says:

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

and this criterion would also be satisfied by (merge-pathnames
(parse-namestring "foo/bar" nil "/") defaults) as per the "WRONG"
example above.  But maybe I'm missing something, which is why I don't
include the rather trivial fix.

-Hans



More information about the Openmcl-devel mailing list