Clozure / ccl

Clozure Common Lisp
http://ccl.clozure.com
Apache License 2.0
850 stars 103 forks source link

[Bug] CCL should not auto-normalize `:up` found in directory components passed to `make-pathname` #477

Open fosskers opened 8 months ago

fosskers commented 8 months ago

The implications of this line (and perhaps the usage of remove-up elsewhere) violate the spec's stated difference between :up and :back. :up requires a probe of the filesystem to determine what the path actually resolves to, while :back does not. I don't see remove-up doing such a probe.

Either way, automatically doing this even were :back present is inconsistent with how pathname literals are interpreted. For instance:

(inspect #p"/foo/bar/../stuff.txt")

You will see that :UP is still present in the struct and the path has not been normalized. Other main implementations also do not do auto-normalization within make-pathname.

Gleefre commented 8 months ago

FWIW there is no corresponding page in the CLHS: https://www.lispworks.com/documentation/HyperSpec/Body/19_bb.htm only lists sections up to 19.2.2.5.

This probably due to this (cited from the home page of cl-community-spec):

There are still some issues. One of them is that I started out using not the latest version of the draft, so that X3J13 changes were not included.

fosskers commented 8 months ago

The section numbers seem to be different, but here is the corresponding section from the LW Hyperspec: https://www.lispworks.com/documentation/HyperSpec/Body/19_bbdc.htm

The part in question is this:

``Syntactic'' means that the action of :back depends only on the pathname and not on the contents of the file system.

``Semantic'' means that the action of :up depends on the contents of the file system; to resolve a pathname containing :up to a pathname whose directory component contains only :absolute and strings requires probing the file system.

So there are two issues here:

  1. CCL is interpreting :up's behaviour as :back's behaviour.
  2. It is automatically normalizing paths via (1) when make-pathname is called.