texlive[49446] Build/source/texk/kpathsea: restore -var-value

commits+karl at tug.org commits+karl at tug.org
Tue Dec 18 02:40:49 CET 2018


Revision: 49446
          http://tug.org/svn/texlive?view=revision&revision=49446
Author:   karl
Date:     2018-12-18 02:40:49 +0100 (Tue, 18 Dec 2018)
Log Message:
-----------
restore -var-value behavior; new option -var-brace-value

Modified Paths:
--------------
    trunk/Build/source/texk/kpathsea/ChangeLog
    trunk/Build/source/texk/kpathsea/doc/kpathsea.info
    trunk/Build/source/texk/kpathsea/doc/kpathsea.texi
    trunk/Build/source/texk/kpathsea/kpsewhich.c

Modified: trunk/Build/source/texk/kpathsea/ChangeLog
===================================================================
--- trunk/Build/source/texk/kpathsea/ChangeLog	2018-12-18 01:23:26 UTC (rev 49445)
+++ trunk/Build/source/texk/kpathsea/ChangeLog	2018-12-18 01:40:49 UTC (rev 49446)
@@ -1,3 +1,14 @@
+2018-12-17  Karl Berry  <karl at freefriends.org>
+
+	* kpsewhich.c (--var-brace-value, var_to_brace_value): new option
+	and corresponding option.
+	(main): new case for it. For --var-value, go back to just variable
+	(kpathsea_var_value) expansion.
+	* doc/kpathsea.texi (Auxiliary tasks): document the new option,
+	try to explain the difference.
+	Follow-up report from jbglaw,
+	https://github.com/TeX-Live/texlive-source/issues/3.
+
 2018-12-14  Karl Berry  <karl at tug.org>
 
 	* c-pathch.h (IS_KPSE_SEP): check for both : and ; only on Unix.

Modified: trunk/Build/source/texk/kpathsea/doc/kpathsea.info
===================================================================
--- trunk/Build/source/texk/kpathsea/doc/kpathsea.info	2018-12-18 01:23:26 UTC (rev 49445)
+++ trunk/Build/source/texk/kpathsea/doc/kpathsea.info	2018-12-18 01:40:49 UTC (rev 49446)
@@ -1469,13 +1469,34 @@
      integer can be used, just as with '--format', described in the
      previous section.
 
+'--var-brace-value=VARIABLE'
+     Like '--var-value' (next), but also expands '{...}' constructs.
+     (*note Brace expansion::).  Thus, the value is assumed to possibly
+     be several path elements, and '~' is expanded at the beginning of
+     each.  The path separator is changed to that of the current system
+     in the expansion.
+
+     Example: 'FOO='.;~' kpsewhich --var-brace-value=FOO' outputs (on a
+     Unix-ish system) '.:/home/karl', supposing the latter is the
+     current user's home directory.  Note that the ';' in the source
+     value, as commonly used in 'texmf.cnf', has changed to a ':', as
+     the normal path separator on the current system.  (On a Windows-ish
+     system, the ';' would remain.)
+
 '--var-value=VARIABLE'
-     Outputs the value of VARIABLE (a simple identifier like 'TEXMF',
-     with no '$' or other constructs), expanding '{...}' (*note Brace
-     expansion::), '$' (*note Variable expansion::) and '~' (*note Tilde
-     expansion::) constructs, considered as strings, but not looking on
-     the filesystem.
+     Outputs the value of VARIABLE (a simple identifier like
+     'TEXMFDIST', with no '$' or other constructs), expanding '$' (*note
+     Variable expansion::) and '~' (*note Tilde expansion::) constructs
+     in the value.  '~' expansion happens at the beginning of the
+     overall value and at the beginning of a variable expansion, but not
+     arbitrarily within the string.  Braces are not expanded.
 
+     Example: '--var-value=texmf_casefold_search' outputs (if the
+     default is not changed) '1'.
+
+     Example to contrast with '--var-brace-value': 'FOO='.;~' kpsewhich
+     --var-value=FOO' outputs '.;~', i.e., the same as the input value.
+
 
 File: kpathsea.info,  Node: Standard options,  Prev: Auxiliary tasks,  Up: Invoking kpsewhich
 
@@ -2975,7 +2996,8 @@
 * --show-path=NAME:                      Auxiliary tasks.     (line  51)
 * --subdir=STRING:                       Path searching options.
                                                               (line 164)
-* --var-value=VARIABLE:                  Auxiliary tasks.     (line  57)
+* --var-brace-value=VARIABLE:            Auxiliary tasks.     (line  57)
+* --var-value=VARIABLE:                  Auxiliary tasks.     (line  71)
 * --version:                             Standard options.    (line  11)
 * --with-mktextex-default:               mktex configuration. (line  12)
 * --without-mktexfmt-default:            mktex configuration. (line  12)
@@ -3871,34 +3893,34 @@
 Node: Path searching options49940
 Node: Specially-recognized files58459
 Node: Auxiliary tasks59814
-Node: Standard options62282
-Node: TeX support62638
-Node: Supported file formats63992
-Node: File lookup71657
-Node: Glyph lookup73406
-Node: Basic glyph lookup74530
-Node: Fontmap75410
-Node: Fallback font77939
-Node: Suppressing warnings78851
-Node: mktex scripts79978
-Node: mktex configuration81193
-Node: mktex script names86996
-Node: mktex script arguments88382
-Node: Programming89261
-Node: Programming overview89834
-Node: Calling sequence92695
-Node: Program-specific files99227
-Node: Programming with config files100250
-Node: Reporting bugs101562
-Node: Bug checklist102240
-Node: Mailing lists105712
-Node: Debugging106387
-Node: Logging111464
-Node: Common problems113331
-Node: Unable to find files113808
-Node: Slow path searching116218
-Node: Unable to generate fonts117593
-Node: TeX or Metafont failing120064
-Node: Index121266
+Node: Standard options63353
+Node: TeX support63709
+Node: Supported file formats65063
+Node: File lookup72728
+Node: Glyph lookup74477
+Node: Basic glyph lookup75601
+Node: Fontmap76481
+Node: Fallback font79010
+Node: Suppressing warnings79922
+Node: mktex scripts81049
+Node: mktex configuration82264
+Node: mktex script names88067
+Node: mktex script arguments89453
+Node: Programming90332
+Node: Programming overview90905
+Node: Calling sequence93766
+Node: Program-specific files100298
+Node: Programming with config files101321
+Node: Reporting bugs102633
+Node: Bug checklist103311
+Node: Mailing lists106783
+Node: Debugging107458
+Node: Logging112535
+Node: Common problems114402
+Node: Unable to find files114879
+Node: Slow path searching117289
+Node: Unable to generate fonts118664
+Node: TeX or Metafont failing121135
+Node: Index122337
 
 End Tag Table

Modified: trunk/Build/source/texk/kpathsea/doc/kpathsea.texi
===================================================================
--- trunk/Build/source/texk/kpathsea/doc/kpathsea.texi	2018-12-18 01:23:26 UTC (rev 49445)
+++ trunk/Build/source/texk/kpathsea/doc/kpathsea.texi	2018-12-18 01:40:49 UTC (rev 49446)
@@ -1822,14 +1822,37 @@
 or an integer can be used, just as with @samp{--format}, described in
 the previous section.
 
+ at item --var-brace-value=@var{variable}
+ at opindex --var-brace-value=@var{variable}
+Like @samp{--var-value} (next), but also expands @samp{@{...@}}
+constructs.  (@pxref{Brace expansion}).  Thus, the value is assumed to
+possibly be several path elements, and @samp{~} is expanded at the
+beginning of each.  The path separator is changed to that of the
+current system in the expansion.
+
+Example: @samp{FOO='.;~' kpsewhich --var-brace-value=FOO} outputs (on
+a Unix-ish system) @samp{.:/home/karl}, supposing the latter is the
+current user's home directory.  Note that the @samp{;} in the source
+value, as commonly used in @file{texmf.cnf}, has changed to a
+ at samp{:}, as the normal path separator on the current system. (On a
+Windows-ish system, the @samp{;} would remain.)
+
 @item --var-value=@var{variable}
 @opindex --var-value=@var{variable}
 Outputs the value of @var{variable} (a simple identifier like
- at samp{TEXMF}, with no @samp{$} or other constructs), expanding
- at samp{@{...@}} (@pxref{Brace expansion}), @samp{$} (@pxref{Variable
-expansion}) and @samp{~} (@pxref{Tilde expansion}) constructs,
-considered as strings, but not looking on the filesystem.
+ at samp{TEXMFDIST}, with no @samp{$} or other constructs), expanding
+ at samp{$} (@pxref{Variable expansion}) and @samp{~} (@pxref{Tilde
+expansion}) constructs in the value.  @samp{~} expansion happens at the
+beginning of the overall value and at the beginning of a variable
+expansion, but not arbitrarily within the string.  Braces are not expanded.
 
+Example: @samp{--var-value=texmf_casefold_search} outputs (if the
+default is not changed) @samp{1}.
+
+Example to contrast with @samp{--var-brace-value}: @samp{FOO='.;~'
+kpsewhich --var-value=FOO} outputs @samp{.;~}, i.e., the same as the
+input value.
+
 @end table
 
 

Modified: trunk/Build/source/texk/kpathsea/kpsewhich.c
===================================================================
--- trunk/Build/source/texk/kpathsea/kpsewhich.c	2018-12-18 01:23:26 UTC (rev 49445)
+++ trunk/Build/source/texk/kpathsea/kpsewhich.c	2018-12-18 01:40:49 UTC (rev 49446)
@@ -31,12 +31,13 @@
 #include <kpathsea/version.h>
 
 /* For variable and path expansion.  (-expand-var, -expand-path,
-   -show-path) */
+   -show-path, etc.)  */
 string var_to_expand = NULL;
 string braces_to_expand = NULL;
 string path_to_expand = NULL;
 string path_to_show = NULL;
 string var_to_value = NULL;
+string var_to_brace_value = NULL;
 
 /* Base resolution. (-D, -dpi) */
 unsigned dpi = 600;
@@ -493,7 +494,8 @@
 -show-path=TYPE        output search path for file type TYPE\n\
                          (list shown by -help-formats).\n\
 -subdir=STRING         only output matches whose directory ends with STRING.\n\
--var-value=STRING      output the expanded value of variable $STRING.\n\
+-var-brace-value=STRING output brace-expanded value of variable $STRING.\n\
+-var-value=STRING       output variable-expanded value of variable $STRING.\n\
 -version               display version information number and exit.\n \
 "
 
@@ -607,6 +609,7 @@
       { "safe-out-name",        1, 0, 0 },
       { "subdir",               1, 0, 0 },
       { "show-path",            1, 0, 0 },
+      { "var-brace-value",      1, 0, 0 },
       { "var-value",            1, 0, 0 },
       { "version",              0, 0, 0 },
       { 0, 0, 0, 0 } };
@@ -694,6 +697,9 @@
     } else if (ARGUMENT_IS ("subdir")) {
       str_list_add (&subdir_paths, optarg);
 
+    } else if (ARGUMENT_IS ("var-brace-value")) {
+      var_to_brace_value = optarg;
+
     } else if (ARGUMENT_IS ("var-value")) {
       var_to_value = optarg;
 
@@ -718,7 +724,7 @@
 
   if (optind == argc
       && !var_to_expand && !braces_to_expand && !path_to_expand
-      && !path_to_show && !var_to_value
+      && !path_to_show && !var_to_value && !var_to_brace_value
       && !safe_in_name && !safe_out_name) {
     fputs ("Missing argument. Try `kpsewhich --help' for more information.\n",
            stderr);
@@ -829,7 +835,7 @@
     }
   }
 
-  /* Var to value. */
+  /* Var to value.  */
   if (var_to_value) {
     const_string value = kpathsea_var_value (kpse, var_to_value);
     if (!value) {
@@ -836,14 +842,25 @@
       unfound++;
       value = "";
     }
+    puts (value);
+  }
 
-    /* It is helpful for users to output the fully-expanded (as a
-       string, no filesystem checks) value. We can't call brace_expand
-       as part of kpathsea_var_value, though, because unfortunately it
-       is not reentrant. We use var_value in lots of places in the
-       source, and it clobbers the static buffer in the kpse structure.  */
-    value = kpathsea_brace_expand (kpse, value);
-
+  /* Var to brace-expanded value. This is separate from --var-value for
+     compatibility; people use --var-value for non-path values, where
+     changing commas to colons, which brace expansion does, is not right.  */
+  if (var_to_brace_value) {
+    const_string value = kpathsea_var_value (kpse, var_to_brace_value);
+    if (!value) {
+      unfound++;
+      value = "";
+    } else {
+      /* Sometimes users want the fully-expanded (as a string, no
+         filesystem checks) value.  We can't call brace_expand as part of
+         kpathsea_var_value, though, because unfortunately it is not
+         reentrant.  We use var_value in lots of places in the source,
+         and it clobbers the static buffer in the kpse structure.  */
+      value = kpathsea_brace_expand (kpse, value);
+    }
     puts (value);
   }
 



More information about the tex-live-commits mailing list