Pathanme translation bugs when TO contains complex patterns

Bug #1738548 reported by Richard M Kreuter on 2017-12-16
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

(Apologies for this two-fer, but inspecting one bug uncovered the second, and they touch the same function.)


1. Pathname translation doesn't perform lettercase translation correctly when the TO pathname's wildcard field is a complex pattern and the portions of FROM pathname are in a different lettercase than the non-wild portions of the TO pathname's wildcard field. (This can only be seen when translating logical pathnames to physical pathnames, as that's the only circumstance where SBCL tries to do lettercase translation.)

$ sh ./ --no-userinit --no-sysinit
(running SBCL from: .)
This is SBCL, an implementation of ANSI Common Lisp.
More information about SBCL is available at <>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
* (setf (logical-pathname-translations "foo") ()) ; establish the LPN host


* (translate-pathname "foo:a" "foo:*" "/*") ; NAME is :WILD, i.e., not complex

* (translate-pathname "foo:ab" "foo:a*" "/z*") ; NAME is a #<PATTERN "a" :MULTI-CHAR-WILD>


* (translate-pathname "foo:ab;" "foo:a*;" "/z*/") ; DIRECTORY contains a PATTERN


* (translate-pathname #p"foo:ab" #p"foo:a*" #p"/X*") ; NAME is a pattern



I expected the portions of SOURCE that matched wild syntax in FROM to be downcased in the result *and* alpha-chars in the pathname designated by TO to make it through translation verbatim.

2. When the field in TO corresponding to a wild field in FROM is a complex pattern prefixed by a constant string and the portion of SOURCE matching the wild field in FROM is also a complex pattern, the result of the translation contains the prefix twice:

(translate-pathname "a*" "*" "x*")


I expected #P"xa*".

It looks like the culprit for these two cases is SB-IMPL::SUBSTITUTE-INTO in src/code/target-pathname.lisp. In short, the maybe-diddling ought to happen once per portion of the source to be substituted into the result, and the loop should clear the STRINGS accumulator when concatenating a piece. The attached patch achieves the desired effects for the above cases.

Other things requested in the bug reporting guidelines:

$ uname -a
Darwin m5.localdomain 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64

* *features*


To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers