diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2017-10-21 10:30:18 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2017-10-21 10:30:18 +0000 |
commit | 10375f38cec7e121a602f2d39f212169ffbfe4bf (patch) | |
tree | 9648cb6e38e1a2778351122f48e7712a4c434d3b /Build | |
parent | bf2dd782af81b5d1bbd1759827a6b1c759a138b1 (diff) |
openclose.c: If opened fname is a directory in output_directory, discard it in Unix platforms.
git-svn-id: svn://tug.org/texlive/trunk@45565 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r-- | Build/source/texk/web2c/lib/ChangeLog | 9 | ||||
-rw-r--r-- | Build/source/texk/web2c/lib/openclose.c | 21 |
2 files changed, 30 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/lib/ChangeLog b/Build/source/texk/web2c/lib/ChangeLog index 96160bd4078..7875fda5b35 100644 --- a/Build/source/texk/web2c/lib/ChangeLog +++ b/Build/source/texk/web2c/lib/ChangeLog @@ -1,3 +1,12 @@ +2017-10-21 Akira Kakuto <kakuto@fuk.kindai.ac.jp> + + * openclose.c: If opened fname is a directory in + output_directory, discard it in Unix platforms. + In windows, fopen (fname, mode) is always NULL, in the case + where fname is a directory, thus it is discarded automatically. + Thanks to Hironobu Yamashita for the information: + http://tug.org/pipermail/tex-live/2017-October/040735.html. + 2017-09-05 Karl Berry <karl@tug.org> and Akira Kakuto <kakuto@fuk.kindai.ac.jp> diff --git a/Build/source/texk/web2c/lib/openclose.c b/Build/source/texk/web2c/lib/openclose.c index c5e1414ab3e..4ecf3827c93 100644 --- a/Build/source/texk/web2c/lib/openclose.c +++ b/Build/source/texk/web2c/lib/openclose.c @@ -12,6 +12,10 @@ #include <ptexenc/ptexenc.h> #endif +#if !defined(_WIN32) +#include <sys/stat.h> +#endif + #ifdef WIN32 #undef fopen #undef xfopen @@ -146,6 +150,14 @@ recorder_record_output (const_string name) whether or not the open succeeded. If it did, `nameoffile' is set to the full filename opened, and `namelength' to its length. */ +#if !defined(_WIN32) +static int is_dirp (char *buff) +{ + struct stat stats; + return stat (buff, &stats) == 0 && S_ISDIR (stats.st_mode); +} +#endif + boolean open_input (FILE **f_ptr, int filefmt, const_string fopen_mode) { @@ -173,6 +185,15 @@ open_input (FILE **f_ptr, int filefmt, const_string fopen_mode) if (output_directory && !kpse_absolute_p (nameoffile+1, false)) { fname = concat3 (output_directory, DIR_SEP_STRING, nameoffile + 1); *f_ptr = fopen (fname, fopen_mode); +#if !defined(_WIN32) +/* + if fname is a directory, discard it. +*/ + if (*f_ptr && is_dirp (fname)) { + fclose (*f_ptr); + *f_ptr = NULL; + } +#endif if (*f_ptr) { free (nameoffile); namelength = strlen (fname); |