From cfc3d4f5c13a237b288087ebcbe5834360036bc7 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 22 Jul 2014 17:36:15 +0000 Subject: have kpsewhich --help display (for each format) variable names considered, the original path string, and the final expanded path git-svn-id: svn://tug.org/texlive/trunk@34693 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/kpathsea/ChangeLog | 7 +++++++ Build/source/texk/kpathsea/kpsewhich.c | 11 +++++++++-- Build/source/texk/kpathsea/tex-file.c | 27 ++++++++++++++++++++------- Build/source/texk/kpathsea/tex-file.h | 16 ++++++++++++---- 4 files changed, 48 insertions(+), 13 deletions(-) (limited to 'Build/source') diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog index 7ca8955c5e4..512c1dc666f 100644 --- a/Build/source/texk/kpathsea/ChangeLog +++ b/Build/source/texk/kpathsea/ChangeLog @@ -1,3 +1,10 @@ +2014-07-22 Karl Berry + + * tex-file.h, + * tex-file.c (kpathsea_init_format_return_varlist): new fn + to expose list of environment/config variable names considered. + * kpsewhich.c (help_message): use it. + 2014-07-18 Karl Berry * mktex.opt: don't basename-ify the program name, that's diff --git a/Build/source/texk/kpathsea/kpsewhich.c b/Build/source/texk/kpathsea/kpsewhich.c index 80787c1e7db..3078fe3086a 100644 --- a/Build/source/texk/kpathsea/kpsewhich.c +++ b/Build/source/texk/kpathsea/kpsewhich.c @@ -462,7 +462,9 @@ help_message (kpathsea kpse, string *argv) puts ("\nRecognized format names and their (abbreviations) and suffixes:"); for (f = 0; f < kpse_last_format; f++) { const_string *ext; - kpathsea_init_format (kpse, (kpse_file_format_type)f); + + const_string envvar_list = + kpathsea_init_format_return_varlist (kpse, (kpse_file_format_type) f); printf ("%s", kpse->format_info[f].type); /* Show abbreviation if we accept one. We repeatedly go through the @@ -494,7 +496,12 @@ help_message (kpathsea kpse, string *argv) fputs (*ext, stdout); } - putchar ('\n'); + printf (" [variables: %s]\n", envvar_list); + + printf (" [original path (from %s) = %s]\n", + kpse->format_info[f].path_source, kpse->format_info[f].raw_path); + printf (" [expanded path = %s]\n", + kpse->format_info[f].path); } exit (0); diff --git a/Build/source/texk/kpathsea/tex-file.c b/Build/source/texk/kpathsea/tex-file.c index 323e744c48d..4dcade9f566 100644 --- a/Build/source/texk/kpathsea/tex-file.c +++ b/Build/source/texk/kpathsea/tex-file.c @@ -1,7 +1,7 @@ /* tex-file.c: high-level file searching by format. Copyright 1993, 1994, 1995, 1996, 1997, 2007, 2008, 2009, 2010, 2011 - 2012 Karl Berry. + 2012, 2014 Karl Berry. Copyright 1998-2005 Olaf Weber. This library is free software; you can redistribute it and/or @@ -492,16 +492,29 @@ concatn_with_spaces (const_string str1, ...) } -/* Initialize everything for FORMAT. */ +/* Initialize everything for FORMAT. Return its search path. */ const_string kpathsea_init_format (kpathsea kpse, kpse_file_format_type format) { - string envvar_list; /* only for debug output, set in INIT_FORMAT */ - /* If we get called twice, don't redo all the work. */ - if (FMT_INFO.path) - return FMT_INFO.path; + if (! FMT_INFO.path) { + /* Don't care about the list of variable names. */ + (void) kpathsea_init_format_return_varlist (kpse, format); + } + + return FMT_INFO.path; +} + +/* Initialize everything for FORMAT. Return the list of + environment/config variable names considered, which is not otherwise + saved. Although in principle we could add that list to our format + struct, it seems a waste, since this is only used by kpsewhich --help. */ + +const_string +kpathsea_init_format_return_varlist(kpathsea kpse,kpse_file_format_type format) +{ + string envvar_list; /* only for debug output, set in INIT_FORMAT */ switch (format) { /* We might be able to avoid repeating `gf' or whatever so many @@ -877,7 +890,7 @@ kpathsea_init_format (kpathsea kpse, kpse_file_format_type format) } #endif /* KPSE_DEBUG */ - return FMT_INFO.path; + return envvar_list; } #if defined (KPSE_COMPAT_API) diff --git a/Build/source/texk/kpathsea/tex-file.h b/Build/source/texk/kpathsea/tex-file.h index 1310b51a8e7..1796bc63093 100644 --- a/Build/source/texk/kpathsea/tex-file.h +++ b/Build/source/texk/kpathsea/tex-file.h @@ -1,6 +1,7 @@ /* tex-file.h: find files in a particular format. - Copyright 1993, 1994, 1995, 1996, 2007, 2008, 2009, 2010 Karl Berry. + Copyright 1993, 1994, 1995, 1996, 2007, 2008, 2009, 2010, 2013, + 2014 Karl Berry. Copyright 1998-2005 Olaf Weber. This library is free software; you can redistribute it and/or @@ -51,12 +52,19 @@ extern KPSEDLL void kpathsea_maketex_option (kpathsea kpse, extern KPSEDLL void kpathsea_set_suffixes (kpathsea kpse, kpse_file_format_type format, boolean alternate, ...); -/* Initialize the info for the given format. This is called - automatically by `kpse_find_file', but the glyph searching (for - example) can't use that function, so make it available. */ +/* Initialize the info for the given format, returning the final search + path. This is called automatically by `kpse_find_file', but the + glyph searching (for example) can't use that function, so it + must also be available separately. */ extern KPSEDLL const_string kpathsea_init_format (kpathsea kpse, kpse_file_format_type format); +/* Like kpathsea_init_format, but return the list of (environment/config) + variable names considered, which is not otherwise saved. This is + only used by kpsewhich --help. */ +extern KPSEDLL const_string kpathsea_init_format_return_varlist (kpathsea kpse, + kpse_file_format_type format); + /* If FORMAT has a non-null `suffix' member, append it to NAME "." and call `kpse_path_search' with the result and the other arguments. If that fails, try just NAME. */ -- cgit v1.2.3