summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2007-12-23 19:24:59 +0000
committerKarl Berry <karl@freefriends.org>2007-12-23 19:24:59 +0000
commit275d7824b391713b920c21b3b04bc3f883029e3e (patch)
treed36602dcd43e0b9b29affdea027e7a20687c06c7 /Build
parentf8a9acf764391114433f94202ee066d132f94aac (diff)
begin subdir matching implementation
git-svn-id: svn://tug.org/texlive/trunk@5842 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/kpathsea/.gdbinit3
-rw-r--r--Build/source/texk/kpathsea/ChangeLog7
-rw-r--r--Build/source/texk/kpathsea/kpsewhich.c55
3 files changed, 62 insertions, 3 deletions
diff --git a/Build/source/texk/kpathsea/.gdbinit b/Build/source/texk/kpathsea/.gdbinit
index 68e9a2a87a0..cb95f4193fc 100644
--- a/Build/source/texk/kpathsea/.gdbinit
+++ b/Build/source/texk/kpathsea/.gdbinit
@@ -10,4 +10,5 @@ set env TEXINPUTS !!/home/texlive/karl/Master/texmf-dist/tex/latex//:!!/home/tex
# preload.cfg
#set env TEXMFDBS /home/texlive/karl/Master/texmf
#set env TEXINPUTS !!/home/texlive/karl/Master/texmf/tex/generic//:!!/home/texlive/karl/Master/texmf/tex//
-set args --all --debug=32 preload.cfg
+# --debug=32
+set args --all --subdir=tex/latex/base preload.cfg
diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog
index a83c47c0628..c5ad6292092 100644
--- a/Build/source/texk/kpathsea/ChangeLog
+++ b/Build/source/texk/kpathsea/ChangeLog
@@ -1,3 +1,10 @@
+2007-12-23 Karl Berry <karl@tug.org>
+
+ * kpsewhich.c (subdir_match): start implementation.
+ (lookup): call it if requested.
+ (subdir_paths): new global.
+ (read_command_line): new option --subdir.
+
2007-12-22 Karl Berry <karl@tug.org>
* kpsewhich.c (lookup): handle --all for regular lookups as well
diff --git a/Build/source/texk/kpathsea/kpsewhich.c b/Build/source/texk/kpathsea/kpsewhich.c
index 3595fd6b255..b0ac0dddc75 100644
--- a/Build/source/texk/kpathsea/kpsewhich.c
+++ b/Build/source/texk/kpathsea/kpsewhich.c
@@ -26,6 +26,7 @@
#include <kpathsea/line.h>
#include <kpathsea/pathsearch.h>
#include <kpathsea/proginit.h>
+#include <kpathsea/str-list.h>
#include <kpathsea/tex-file.h>
#include <kpathsea/tex-glyph.h>
#include <kpathsea/variable.h>
@@ -43,6 +44,9 @@ string path_to_expand = NULL;
string path_to_show = NULL;
string var_to_value = NULL;
+/* Only match files in given subdirs. (-subdir) */
+str_list_type subdir_paths;
+
/* The file type and path for lookups. (-format, -path) */
kpse_file_format_type user_format = kpse_last_format;
string user_format_string;
@@ -159,6 +163,36 @@ find_format P2C(string, name, boolean, is_filename)
return ret;
}
+
+
+
+/* Return newly-allocated NULL-terminated list of strings from MATCHES
+ that are prefixed with any of the subdirectories in SUBDIRS. That
+ is, for a string S in MATCHES, its dirname must end with one of the
+ elements in SUBDIRS. For instance, if subdir=foo/bar, that will
+ match a string foo/bar/baz or /some/texmf/foo/bar/baz.
+
+ We don't reallocate the actual strings, just the list elements.
+ Perhaps later we will implement wildcards or // or something. */
+
+static string *
+subdir_match P2C(str_list_type, subdirs, string *, matches)
+{
+ string *ret = XTALLOC1 (string);
+ unsigned len = 1;
+ unsigned m;
+
+ for (m = 0; matches[m]; m++) {
+ string s = matches[m];
+ ret = XRETALLOC (ret, len + 1, string);
+ ret[len-1] = s;
+ len++;
+ }
+ ret[len-1] = NULL;
+ return ret;
+}
+
+
/* Look up a single filename NAME. Return 0 if success, 1 if failure. */
@@ -209,8 +243,21 @@ lookup P1C(string, name)
}
}
- if (ret)
- puts (ret);
+ /* Turn single return into a null-terminated list for uniform treatment. */
+ if (ret) {
+ ret_list = XTALLOC (2, string);
+ ret_list[0] = ret;
+ ret_list[1] = NULL;
+ }
+
+ /* Filter by subdirectories, if specified. */
+ if (STR_LIST_LENGTH (subdir_paths) > 0) {
+ string *new_list = subdir_match (subdir_paths, ret_list);
+ free (ret_list);
+ ret_list = new_list;
+ }
+
+ /* Print output. */
if (ret_list) {
for (i = 0; ret_list[i]; i++)
puts (ret_list[i]);
@@ -271,6 +318,7 @@ static struct option long_options[]
{ "no-mktex", 1, 0, 0 },
{ "progname", 1, 0, 0 },
{ "separator", 1, 0, 0 },
+ { "subdir", 1, 0, 0 },
{ "show-path", 1, 0, 0 },
{ "var-value", 1, 0, 0 },
{ "version", 0, 0, 0 },
@@ -363,6 +411,9 @@ read_command_line P2C(int, argc, string *, argv)
path_to_show = optarg;
user_format_string = optarg;
+ } else if (ARGUMENT_IS ("subdir")) {
+ str_list_add (&subdir_paths, optarg);
+
} else if (ARGUMENT_IS ("var-value")) {
var_to_value = optarg;