[tex-k] [patch] kpathsea subdir bug
Manuel Pégourié-Gonnard
mpg at elzevir.fr
Sun Jun 12 21:29:55 CEST 2011
Hi,
% kpsewhich -format=texmfscripts foo/foobar.ext
/home/mpg/texmf/scripts/foobar.ext
That doesn't sound quite right (notice the lack of foo directory in the
output). It happens only in ls-R indexed trees (I made my texmfhome
indexed just to for the occasion). If the tree is not indexed, the
spurious result is not returned.
The patch below fixes the problem (tested) and should not have any side
effect. I didn't commit it since I'm not sure if it's okay to do so at
this stage of our release planning. Karl?
FYI, I was first hit by this bug in the following subtle but really
annoying form: with progname=texdoc, files whose basename began with
"texdoc" were found first in TEXMFMAIN even if they were present in
TEXMFHOME, since kpathsea "believed" there was one additional texdoc/
subdir in TEXMFMAIN (indexed) than in TEXMFHOME (not indexed) so the
files were found first, due to the {$progname,$enginename,} in the
definition of TEXMFSCRIPTS.
Manuel.
Index: db.c
===================================================================
--- db.c (révision 22912)
+++ db.c (copie de travail)
@@ -257,13 +257,16 @@
separator. On the other hand, if PATH_ELT ended with a / (as in
`vf/'), FILENAME being the same `vf/ptmr.vf', we'll be at the
`p'. Upshot: if we're at a dir separator in FILENAME, skip it.
- But if not, that's ok, as long as there are no more dir separators. */
+ Then we must be just after a dir separator or at the beginning of
+ FILENAME and there must be no more dir separators. */
if (IS_DIR_SEP (*filename))
filename++;
- while (*filename && !IS_DIR_SEP (*filename))
- filename++;
- matched = *filename == 0;
+ if (original_filename == filename || IS_DIR_SEP (filename[-1])) {
+ while (*filename && !IS_DIR_SEP (*filename))
+ filename++;
+ matched = *filename == 0;
+ }
}
return matched;
More information about the tex-k
mailing list