texlive[45565] Build/source/texk/web2c/lib: openclose.c: If opened

commits+kakuto at tug.org commits+kakuto at tug.org
Sat Oct 21 12:30:18 CEST 2017


Revision: 45565
          http://tug.org/svn/texlive?view=revision&revision=45565
Author:   kakuto
Date:     2017-10-21 12:30:18 +0200 (Sat, 21 Oct 2017)
Log Message:
-----------
openclose.c: If opened fname is a directory in output_directory, discard it in Unix platforms.

Modified Paths:
--------------
    trunk/Build/source/texk/web2c/lib/ChangeLog
    trunk/Build/source/texk/web2c/lib/openclose.c

Modified: trunk/Build/source/texk/web2c/lib/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/lib/ChangeLog	2017-10-21 00:17:48 UTC (rev 45564)
+++ trunk/Build/source/texk/web2c/lib/ChangeLog	2017-10-21 10:30:18 UTC (rev 45565)
@@ -1,3 +1,12 @@
+2017-10-21  Akira Kakuto  <kakuto at 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 at tug.org>
         and Akira Kakuto  <kakuto at fuk.kindai.ac.jp>
 

Modified: trunk/Build/source/texk/web2c/lib/openclose.c
===================================================================
--- trunk/Build/source/texk/web2c/lib/openclose.c	2017-10-21 00:17:48 UTC (rev 45564)
+++ trunk/Build/source/texk/web2c/lib/openclose.c	2017-10-21 10:30:18 UTC (rev 45565)
@@ -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 @@
    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 @@
     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);



More information about the tex-live-commits mailing list