summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/kpathsea/ChangeLog9
-rw-r--r--Build/source/texk/kpathsea/doc/kpathsea.info47
-rw-r--r--Build/source/texk/kpathsea/doc/kpathsea.texi9
-rw-r--r--Build/source/texk/kpathsea/kpsewhich.c30
-rw-r--r--Build/source/texk/kpathsea/tex-file.c49
-rw-r--r--Build/source/texk/kpathsea/tex-file.h9
6 files changed, 118 insertions, 35 deletions
diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog
index a100e2f44d3..5f909eee39f 100644
--- a/Build/source/texk/kpathsea/ChangeLog
+++ b/Build/source/texk/kpathsea/ChangeLog
@@ -1,3 +1,12 @@
+2009-12-15 Karl Berry <karl@tug.org>
+
+ * kpsewhich.c (-safe-in-name, -safe-out-name): new options.
+ * doc/kpathsea.texi: document them.
+ * tex-file.c (kpathsea_name_ok): introduce silent argument;
+ change callers.
+ * tex-file.h (kpathsea_{in,out}_name_ok_silent): declare these,
+ now used in kpsewhich.
+
2009-12-14 Karl Berry <karl@tug.org>
* kpsewhich.c (separator): remove never-used variable/option.
diff --git a/Build/source/texk/kpathsea/doc/kpathsea.info b/Build/source/texk/kpathsea/doc/kpathsea.info
index 955e3f16f06..b9701102961 100644
--- a/Build/source/texk/kpathsea/doc/kpathsea.info
+++ b/Build/source/texk/kpathsea/doc/kpathsea.info
@@ -2770,6 +2770,13 @@ filename, and returns the first file found.
affect the search paths via the `.PROGNAM' feature in
configuration files (*note Config files::).
+`--safe-in-name=NAME'
+`--safe-out-name=NAME'
+ Exit successfully if NAME is safe to open for reading or writing,
+ respectively, else unsuccessfully. No output is written. These
+ tests take account of the related Kpathsea configuration settings
+ (*note Calling sequence::).
+
`--subdir=STRING'
Report only those matches whose directory part _ends_ with STRING
(compared literally, except case is ignored on a case-insensitive
@@ -3735,11 +3742,15 @@ Index
(line 131)
* --progname=NAME: Path searching options.
(line 140)
+* --safe-in-name=NAME: Path searching options.
+ (line 146)
+* --safe-out-name=NAME: Path searching options.
+ (line 146)
* --show-path=NAME: Auxiliary tasks. (line 41)
* --srcdir, for building multiple architectures: configure scenarios.
(line 18)
* --subdir=STRING: Path searching options.
- (line 145)
+ (line 152)
* --var-value=VARIABLE: Auxiliary tasks. (line 12)
* --version: Standard options. (line 10)
* --with options: configure options. (line 16)
@@ -4898,22 +4909,22 @@ Node: Filename aliases106289
Node: Database format107467
Node: Invoking kpsewhich108480
Node: Path searching options109425
-Node: Specially-recognized files116795
-Node: Auxiliary tasks118151
-Node: Standard options119976
-Node: TeX support120296
-Node: Supported file formats121587
-Node: File lookup129103
-Node: Glyph lookup130835
-Node: Basic glyph lookup131959
-Node: Fontmap132838
-Node: Fallback font135455
-Node: Suppressing warnings136368
-Node: Programming137473
-Node: Programming overview137986
-Node: Calling sequence140680
-Node: Program-specific files147203
-Node: Programming with config files148245
-Node: Index149557
+Node: Specially-recognized files117086
+Node: Auxiliary tasks118442
+Node: Standard options120267
+Node: TeX support120587
+Node: Supported file formats121878
+Node: File lookup129394
+Node: Glyph lookup131126
+Node: Basic glyph lookup132250
+Node: Fontmap133129
+Node: Fallback font135746
+Node: Suppressing warnings136659
+Node: Programming137764
+Node: Programming overview138277
+Node: Calling sequence140971
+Node: Program-specific files147494
+Node: Programming with config files148536
+Node: Index149848

End Tag Table
diff --git a/Build/source/texk/kpathsea/doc/kpathsea.texi b/Build/source/texk/kpathsea/doc/kpathsea.texi
index df404d10735..a76efe8aa4c 100644
--- a/Build/source/texk/kpathsea/doc/kpathsea.texi
+++ b/Build/source/texk/kpathsea/doc/kpathsea.texi
@@ -1215,6 +1215,15 @@ Set the program name to @var{name}; default is @samp{kpsewhich}. This
can affect the search paths via the @samp{.@var{prognam}} feature in
configuration files (@pxref{Config files}).
+@item --safe-in-name=@var{name}
+@itemx --safe-out-name=@var{name}
+@opindex --safe-in-name=@var{name}
+@opindex --safe-out-name=@var{name}
+Exit successfully if @var{name} is safe to open for reading or
+writing, respectively, else unsuccessfully. No output is written.
+These tests take account of the related Kpathsea configuration
+settings (@pxref{Calling sequence}).
+
@item --subdir=@var{string}
@opindex --subdir=@var{string}
Report only those matches whose directory part @emph{ends} with
diff --git a/Build/source/texk/kpathsea/kpsewhich.c b/Build/source/texk/kpathsea/kpsewhich.c
index dd4bc017404..7b8b6a89540 100644
--- a/Build/source/texk/kpathsea/kpsewhich.c
+++ b/Build/source/texk/kpathsea/kpsewhich.c
@@ -58,6 +58,10 @@ boolean must_exist = false;
/* The program name, for `.PROG' construct in texmf.cnf. (-program) */
string progname = NULL;
+/* Safe input and output names to check. (-safe-in-name and -safe-out-name) */
+string safe_in_name = NULL;
+string safe_out_name = NULL;
+
/* Return all matches, not just the first one? (-all) */
boolean show_all = false;
@@ -325,6 +329,8 @@ will return matching format files for any engine.\n\
-must-exist search the disk as well as ls-R if necessary.\n\
-path=STRING search in the path STRING.\n\
-progname=STRING set program name to STRING.\n\
+-safe-in-name=STRING check if STRING is ok to open for input.\n\
+-safe-out-name=STRING check if STRING is ok to open for output.\n\
-show-path=NAME output search path for file type NAME (list below).\n\
-subdir=STRING only output matches whose directory ends with STRING.\n\
-var-value=STRING output the value of variable $STRING.\n\
@@ -355,6 +361,8 @@ static struct option long_options[]
{ "path", 1, 0, 0 },
{ "no-mktex", 1, 0, 0 },
{ "progname", 1, 0, 0 },
+ { "safe-in-name", 1, 0, 0 },
+ { "safe-out-name", 1, 0, 0 },
{ "subdir", 1, 0, 0 },
{ "show-path", 1, 0, 0 },
{ "var-value", 1, 0, 0 },
@@ -448,6 +456,12 @@ read_command_line (kpathsea kpse, int argc, string *argv)
} else if (ARGUMENT_IS ("progname")) {
progname = optarg;
+ } else if (ARGUMENT_IS ("safe-in-name")) {
+ safe_in_name = optarg;
+
+ } else if (ARGUMENT_IS ("safe-out-name")) {
+ safe_out_name = optarg;
+
} else if (ARGUMENT_IS ("show-path")) {
path_to_show = optarg;
user_format_string = optarg;
@@ -477,8 +491,10 @@ There is NO WARRANTY, to the extent permitted by law.\n");
exit (1);
}
- if (optind == argc && !var_to_expand && !braces_to_expand && !path_to_expand
- && !path_to_show && !var_to_value) {
+ if (optind == argc
+ && !var_to_expand && !braces_to_expand && !path_to_expand
+ && !path_to_show && !var_to_value
+ && !safe_in_name && !safe_out_name) {
fputs ("Missing argument. Try `kpsewhich --help' for more information.\n",
stderr);
exit (1);
@@ -570,6 +586,16 @@ main (int argc, string *argv)
puts (value);
}
+ if (safe_in_name) {
+ if (!kpathsea_in_name_ok_silent (kpse, safe_in_name))
+ unfound++;
+ }
+
+ if (safe_out_name) {
+ if (!kpathsea_out_name_ok_silent (kpse, safe_out_name))
+ unfound++;
+ }
+
/* --subdir must imply --all, since we filter here after doing the
search, rather than inside the search itself. */
if (STR_LIST_LENGTH (subdir_paths) > 0) {
diff --git a/Build/source/texk/kpathsea/tex-file.c b/Build/source/texk/kpathsea/tex-file.c
index f9884097235..7be030a671a 100644
--- a/Build/source/texk/kpathsea/tex-file.c
+++ b/Build/source/texk/kpathsea/tex-file.c
@@ -1104,7 +1104,7 @@ static const_string ok_type_name[] = {
static boolean
kpathsea_name_ok (kpathsea kpse, const_string fname, const_string check_var,
- const_string default_choice, ok_type action)
+ const_string default_choice, ok_type action, boolean silent)
{
/* We distinguish three cases:
'a' (any) allows any file to be opened.
@@ -1180,28 +1180,37 @@ kpathsea_name_ok (kpathsea kpse, const_string fname, const_string check_var,
return true;
not_ok: /* Some test failed. */
- fprintf (stderr, "\n%s: Not %s %s (%s = %s).\n",
- kpse->invocation_name, ok_type_name[action], fname,
- check_var, open_choice);
+ if (!silent)
+ fprintf (stderr, "\n%s: Not %s %s (%s = %s).\n",
+ kpse->invocation_name, ok_type_name[action], fname,
+ check_var, open_choice);
return false;
}
+/* For input default to all. */
+
+boolean
+kpathsea_in_name_ok_silent (kpathsea kpse, const_string fname)
+{
+ return kpathsea_name_ok (kpse, fname, "openin_any", "a", ok_reading, true);
+}
+
boolean
kpathsea_in_name_ok (kpathsea kpse, const_string fname)
{
- /* For input default to all. */
- return kpathsea_name_ok (kpse, fname, "openin_any", "a", ok_reading);
+ return kpathsea_name_ok (kpse, fname, "openin_any", "a", ok_reading, false);
}
+
#if defined(WIN32) || defined(__MINGW32__) || defined(__CYGWIN__)
static int
Isspace (char c)
{
- return (c == ' ' || c == '\t');
+ return (c == ' ' || c == '\t');
}
static boolean
-executable_filep (kpathsea kpse, const_string fname)
+executable_filep (kpathsea kpse, const_string fname, boolean silent)
{
string p, q, base;
string *pp;
@@ -1240,8 +1249,8 @@ executable_filep (kpathsea kpse, const_string fname)
if (pp && q) {
while (*pp) {
if (strchr (fname, ':') || !strcmp (q, *pp)) {
- fprintf (stderr, "\n%s: Forbidden to open for writing\n",
- fname);
+ if (!silent)
+ fprintf (stderr, "\n%s: Forbidden to open for writing\n", fname);
free (base);
return true;
}
@@ -1256,16 +1265,28 @@ executable_filep (kpathsea kpse, const_string fname)
}
#endif /* WIN32 || __MINGW32__ || __CYGWIN__ */
-boolean
-kpathsea_out_name_ok (kpathsea kpse, const_string fname)
+static boolean
+kpathsea_out_name_ok_1 (kpathsea kpse, const_string fname, boolean silent)
{
#if defined(WIN32) || defined(__MINGW32__) || defined(__CYGWIN__)
/* Output of an executable file is restricted on Windows */
- if (executable_filep (kpse, fname))
+ if (executable_filep (kpse, fname, silent))
return false;
#endif /* WIN32 || __MINGW32__ || __CYGWIN__ */
/* For output, default to paranoid. */
- return kpathsea_name_ok (kpse, fname, "openout_any", "p", ok_writing);
+ return kpathsea_name_ok (kpse, fname, "openout_any", "p", ok_writing,silent);
+}
+
+boolean
+kpathsea_out_name_ok_silent (kpathsea kpse, const_string fname)
+{
+ return kpathsea_out_name_ok_1 (kpse, fname, true);
+}
+
+boolean
+kpathsea_out_name_ok (kpathsea kpse, const_string fname)
+{
+ return kpathsea_out_name_ok_1 (kpse, fname, false);
}
#if defined (KPSE_COMPAT_API)
diff --git a/Build/source/texk/kpathsea/tex-file.h b/Build/source/texk/kpathsea/tex-file.h
index 10b4be2364b..bad4b028a42 100644
--- a/Build/source/texk/kpathsea/tex-file.h
+++ b/Build/source/texk/kpathsea/tex-file.h
@@ -62,10 +62,17 @@ extern KPSEDLL string *kpathsea_find_file_generic (kpathsea kpse,
const_string name, kpse_file_format_type format, boolean must_exist,
boolean all);
-/* Return true if FNAME is acceptable to open for reading or writing. */
+/* Return true if FNAME is acceptable to open for reading or writing.
+ If not acceptable, write a message to stderr. */
extern KPSEDLL boolean kpathsea_in_name_ok (kpathsea kpse, const_string fname);
extern KPSEDLL boolean kpathsea_out_name_ok (kpathsea kpse,const_string fname);
+/* As above, but no error message. */
+extern KPSEDLL boolean kpathsea_in_name_ok_silent
+ (kpathsea kpse, const_string fname);
+extern KPSEDLL boolean kpathsea_out_name_ok_silent
+ (kpathsea kpse,const_string fname);
+
/* Don't just look up the name, actually open the file. */
extern KPSEDLL FILE *kpathsea_open_file (kpathsea kpse, const_string name,
kpse_file_format_type format);