summaryrefslogtreecommitdiff
path: root/Build/source/texk/kpathsea
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-06-13 23:00:56 +0000
committerKarl Berry <karl@freefriends.org>2011-06-13 23:00:56 +0000
commit55b1dad1f932761ea946bbc2a48d385e49079d7a (patch)
tree069cd98ad05b3478496b901a11fd140db028ba91 /Build/source/texk/kpathsea
parent2602740545c73b318e47c6840d5e00acfdac056e (diff)
ensure being at a dir separator for final component match, so foobar does not match foo
git-svn-id: svn://tug.org/texlive/trunk@22960 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/kpathsea')
-rw-r--r--Build/source/texk/kpathsea/ChangeLog7
-rw-r--r--Build/source/texk/kpathsea/db.c37
2 files changed, 34 insertions, 10 deletions
diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog
index 82a2ea730d6..f5116d67071 100644
--- a/Build/source/texk/kpathsea/ChangeLog
+++ b/Build/source/texk/kpathsea/ChangeLog
@@ -1,3 +1,10 @@
+2011-06-13 Manuel P\'egour\'e-Gonnard <mpg@elzevir.fr>
+
+ * db.c (match): ensure that we are at a dir separator in
+ the filename before checking for being at the final component.
+ (We were erroneously matching "foobar" to "foo" in some cases.)
+ Report from Manuel, tex-k mail 12 Jun 2011 21:29:55.
+
2011-06-10 Karl Berry <karl@tug.org>
* configure.ac (AC_PROG_AWK): new test.
diff --git a/Build/source/texk/kpathsea/db.c b/Build/source/texk/kpathsea/db.c
index 43c3aac34d1..760748ecf9d 100644
--- a/Build/source/texk/kpathsea/db.c
+++ b/Build/source/texk/kpathsea/db.c
@@ -250,20 +250,37 @@ match (const_string filename, const_string path_elt)
}
/* If we've reached the end of PATH_ELT, check that we're at the last
- component of FILENAME, we've matched. */
+ component of FILENAME (that is, no directory separators remaining);
+ only then have we matched. */
if (!matched && *path_elt == 0) {
- /* Probably PATH_ELT ended with `vf' or some such, and FILENAME ends
- with `vf/ptmr.vf'. In that case, we'll be at a directory
- 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. */
+ /* Typically PATH_ELT ends with, say, `vf', and FILENAME ends with
+ `vf/ptmr.vf'. In that case, we'll be at the /. 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 sep in FILENAME, skip it. */
if (IS_DIR_SEP (*filename))
filename++;
- while (*filename && !IS_DIR_SEP (*filename))
- filename++;
- matched = *filename == 0;
+ /* Here are the basic possibilities for the check on being at the
+ last component:
+ 1) PATH_ELT is empty and FILENAME is `ptmr.vf' => match.
+ (we now have original_filename == filename)
+ 2) PATH_ELT is empty and FILENAME is `foo/ptmr.vf' => no match.
+ (we now have original_filename == filename)
+ 3) PATH_ELT is `vf/' and FILENAME is `vf/ptmr.vf'
+ (we are now after the / in each) => match.
+ 4) PATH_ELT is `vf' and FILENAME is `vfoo.ext'
+ (we are now after the f in each) => no match.
+
+ When (the original) PATH_ELT was the empty string, we want to match
+ a FILENAME without dir seps. (This could be argued, and may never
+ happen in practice, but is the historical behavior.) */
+ /* if original_filename != filename then original_filename < filename */
+ if (original_filename == filename || IS_DIR_SEP (filename[-1])) {
+ while (*filename && !IS_DIR_SEP (*filename))
+ filename++;
+ matched = *filename == 0;
+ }
}
return matched;