This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gfortran,patch] temporary files directory
- From: FX Coudert <fxcoudert at gmail dot com>
- To: patch <gcc-patches at gcc dot gnu dot org>, gfortran <fortran at gcc dot gnu dot org>
- Date: Sun, 07 Aug 2005 00:28:21 +0200
- Subject: [gfortran,patch] temporary files directory
Attached patch changes the default directory for temporary files from
/var/tmp to /tmp since the former does not exist on all systems (mingw
is an example). It enables libgfortran to look at the TEMP environment
variable (in addition to TMP and GFORTRAN_TEMPDIR) when looking for the
place to put its dirty temp files.
Built on i386-mingw32, testing under way on i686-linux. OK for mainline
and 4.0?
FX
2005-08-07 Francois-Xavier Coudert <coudert@clipper.ens.fr>
* io/io.h: Change DEFAULT_TEMPDIR to /tmp instead of /var/tmp.
* io/unix.c (tempfile): Look at the TEMP environment variable
to find the temporary files directory. Whitespace correction.
Index: io.h
===================================================================
RCS file: /cvsroot/gcc/gcc/libgfortran/io/io.h,v
retrieving revision 1.22
diff -p -u -r1.22 io.h
--- io.h 14 Jul 2005 06:21:58 -0000 1.22
+++ io.h 6 Aug 2005 22:22:07 -0000
@@ -33,7 +33,7 @@ Boston, MA 02111-1307, USA. */
#include <setjmp.h>
#include "libgfortran.h"
-#define DEFAULT_TEMPDIR "/var/tmp"
+#define DEFAULT_TEMPDIR "/tmp"
/* Basic types used in data transfers. */
Index: unix.c
===================================================================
RCS file: /cvsroot/gcc/gcc/libgfortran/io/unix.c,v
retrieving revision 1.31
diff -p -u -r1.31 unix.c
--- unix.c 6 Aug 2005 15:38:49 -0000 1.31
+++ unix.c 6 Aug 2005 22:22:07 -0000
@@ -984,6 +984,8 @@ tempfile (void)
if (tempdir == NULL)
tempdir = getenv ("TMP");
if (tempdir == NULL)
+ tempdir = getenv ("TEMP");
+ if (tempdir == NULL)
tempdir = DEFAULT_TEMPDIR;
template = get_mem (strlen (tempdir) + 20);
@@ -998,7 +1000,7 @@ tempfile (void)
if (mktemp (template))
do
- fd = open (template, O_RDWR |O_CREAT | O_EXCL, S_IREAD | S_IWRITE);
+ fd = open (template, O_RDWR | O_CREAT | O_EXCL, S_IREAD | S_IWRITE);
while (!(fd == -1 && errno == EEXIST) && mktemp (template));
else
fd = -1;