From 9a3eca42663c7cb45bb499692d1aed1c90a02dee Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Tue, 7 May 2019 23:29:24 +0000 Subject: Apply a patch in https://tug.org/pipermail/tex-k/2019-May/003014.html git-svn-id: svn://tug.org/texlive/trunk@51041 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/ChangeLog | 6 +++ Build/source/texk/web2c/lib/ChangeLog | 8 ++++ Build/source/texk/web2c/lib/texmfmp.c | 58 ++++++++++++++++------------ Build/source/texk/web2c/pdftexdir/ChangeLog | 7 ++++ Build/source/texk/web2c/pdftexdir/writeimg.c | 6 +-- Build/source/texk/web2c/texmfmp.h | 1 + 6 files changed, 58 insertions(+), 28 deletions(-) diff --git a/Build/source/texk/web2c/ChangeLog b/Build/source/texk/web2c/ChangeLog index 1131f6a3279..8dc5ec005ca 100644 --- a/Build/source/texk/web2c/ChangeLog +++ b/Build/source/texk/web2c/ChangeLog @@ -1,3 +1,9 @@ +2019-05-08 Akira Kakuto + + * texmfmp.h: Define a new function find_input_file(integer s). + A report in tex-k list: + https://tug.org/pipermail/tex-k/2019-May/003014.html + 2019-04-07 Karl Berry * TeX Live 2019. diff --git a/Build/source/texk/web2c/lib/ChangeLog b/Build/source/texk/web2c/lib/ChangeLog index 5dd7cd63bc1..7296d55093c 100644 --- a/Build/source/texk/web2c/lib/ChangeLog +++ b/Build/source/texk/web2c/lib/ChangeLog @@ -1,3 +1,11 @@ +2019-05-08 Akira Kakuto + + * texmfmp.c: Introduce a new function find_input_file(s) + to fix a bug that in special cases getfilesize() etc. for + image files saved in "output-directory" do not work. + A report in tex-k list: + https://tug.org/pipermail/tex-k/2019-May/003014.html + 2019-03-30 Akira Kakuto * texmfmp.c: Improve to record texmf.cnf. (ptex and friends, diff --git a/Build/source/texk/web2c/lib/texmfmp.c b/Build/source/texk/web2c/lib/texmfmp.c index 64a7d31160b..0e372be2aa8 100644 --- a/Build/source/texk/web2c/lib/texmfmp.c +++ b/Build/source/texk/web2c/lib/texmfmp.c @@ -3094,6 +3094,33 @@ void initstarttime(void) } } +/* Search for an input file. If -output-directory is specified look + there first. If that fails, do the regular kpse search. */ +string +find_input_file(integer s) +{ + string filename; + +#if defined(XeTeX) + filename = gettexstring(s); +#else + filename = makecfilename(s); +#endif + /* Look in -output-directory first, if the filename is not + absolute. This is because we want the pdf* functions to + be able to find the same files as \openin */ + if (output_directory && !kpse_absolute_p (filename, false)) { + string pathname; + + pathname = concat3(output_directory, DIR_SEP_STRING, filename); + if (!access(pathname, R_OK) && !dir_p (pathname)) { + return pathname; + } + xfree (pathname); + } + return kpse_find_tex(filename); +} + #if !defined(XeTeX) char *makecstring(integer s) { @@ -3176,13 +3203,8 @@ void getcreationdate(void) void getfilemoddate(integer s) { struct stat file_data; -#if defined(XeTeX) - int i; - const_string orig_name = gettexstring(s); -#else - const_string orig_name = makecfilename(s); -#endif - char *file_name = kpse_find_tex(orig_name); + + char *file_name = find_input_file(s); if (file_name == NULL) { return; /* empty string */ } @@ -3206,6 +3228,8 @@ void getfilemoddate(integer s) /* error by str_toks that calls str_room(1) */ } else { #if defined(XeTeX) + int i; + for (i = 0; i < len; i++) strpool[poolptr++] = (uint16_t)time_str[i]; #else @@ -3224,11 +3248,7 @@ void getfilesize(integer s) struct stat file_data; int i; -#if defined(XeTeX) - char *file_name = kpse_find_tex(gettexstring(s)); -#else - char *file_name = kpse_find_tex(makecfilename(s)); -#endif + char *file_name = find_input_file(s); if (file_name == NULL) { return; /* empty string */ } @@ -3294,11 +3314,7 @@ void getfiledump(integer s, int offset, int length) return; } -#if defined(XeTeX) - file_name = kpse_find_tex(gettexstring(s)); -#else - file_name = kpse_find_tex(makecfilename(s)); -#endif + file_name = find_input_file(s); if (file_name == NULL) { return; /* empty string */ } @@ -3388,13 +3404,7 @@ void getmd5sum(strnumber s, boolean file) FILE *f; char *file_name; -#if defined(XeTeX) - xname = gettexstring (s); - file_name = kpse_find_tex (xname); - xfree (xname); -#else - file_name = kpse_find_tex(makecfilename(s)); -#endif + file_name = find_input_file(s); if (file_name == NULL) { return; /* empty string */ } diff --git a/Build/source/texk/web2c/pdftexdir/ChangeLog b/Build/source/texk/web2c/pdftexdir/ChangeLog index 0a43b927c82..82c291e6702 100644 --- a/Build/source/texk/web2c/pdftexdir/ChangeLog +++ b/Build/source/texk/web2c/pdftexdir/ChangeLog @@ -1,3 +1,10 @@ +2019-05-08 Akira Kakuto + + * writeimg.c: Use a new function find_input_file() to find + an image file. + A report in tex-k list: + https://tug.org/pipermail/tex-k/2019-May/003014.html + 2019-05-03 Akira Kakuto * pdftosrc-poppler0.76.0.cc, pdftoepdf-poppler0.76.0.cc: diff --git a/Build/source/texk/web2c/pdftexdir/writeimg.c b/Build/source/texk/web2c/pdftexdir/writeimg.c index 1ef3327599f..8455b03a5c7 100644 --- a/Build/source/texk/web2c/pdftexdir/writeimg.c +++ b/Build/source/texk/web2c/pdftexdir/writeimg.c @@ -302,12 +302,10 @@ integer readimage(strnumber s, integer page_num, strnumber page_name, already used by cur_file_name */ if (page_name != 0) dest = xstrdup(makecstring(page_name)); - cur_file_name = makecfilename(s); - img_name(img) = kpse_find_file(cur_file_name, kpse_tex_format, true); + cur_file_name = find_input_file(s); + img_name(img) = cur_file_name; if (img_name(img) == NULL) pdftex_fail("cannot find image file"); - /* kpse_find_file perhaps changed the file name */ - cur_file_name = img_name(img); recorder_record_input(cur_file_name); /* type checks */ checktypebyheader(img); diff --git a/Build/source/texk/web2c/texmfmp.h b/Build/source/texk/web2c/texmfmp.h index 5aead37b11d..b12281d1ffd 100644 --- a/Build/source/texk/web2c/texmfmp.h +++ b/Build/source/texk/web2c/texmfmp.h @@ -126,6 +126,7 @@ extern void pdftex_fail(const char *fmt, ...); #endif extern char start_time_str[]; extern void initstarttime(void); +extern string find_input_file(integer s); #if !defined(XeTeX) extern char *makecstring(integer s); extern char *makecfilename(integer s); -- cgit v1.2.3