diff options
author | Kai Tietz <kai.tietz@onevision.com> | 2010-04-24 12:24:33 +0000 |
---|---|---|
committer | Kai Tietz <ktietz@gcc.gnu.org> | 2010-04-24 14:24:33 +0200 |
commit | 01d42eb543ba46aa8329ac3d5dee753a80472327 (patch) | |
tree | 8c691a6017f485114b88368272910fc7ea89c6c0 /libgfortran/io/unix.c | |
parent | a3ba29377f13a923aafa90c3df852a235986e58a (diff) | |
download | gcc-01d42eb543ba46aa8329ac3d5dee753a80472327.zip gcc-01d42eb543ba46aa8329ac3d5dee753a80472327.tar.gz gcc-01d42eb543ba46aa8329ac3d5dee753a80472327.tar.bz2 |
unix.c (tempfile): Correct logic for mktemp case.
2010-04-24 Kai Tietz <kai.tietz@onevision.com>
PR/43844
* io/unix.c (tempfile): Correct logic for mktemp case.
From-SVN: r158686
Diffstat (limited to 'libgfortran/io/unix.c')
-rw-r--r-- | libgfortran/io/unix.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c index 32f3890..b3bd438 100644 --- a/libgfortran/io/unix.c +++ b/libgfortran/io/unix.c @@ -889,25 +889,26 @@ tempfile (st_parameter_open *opp) template = get_mem (strlen (tempdir) + 20); - sprintf (template, "%s/gfortrantmpXXXXXX", tempdir); - #ifdef HAVE_MKSTEMP + sprintf (template, "%s/gfortrantmpXXXXXX", tempdir); fd = mkstemp (template); #else /* HAVE_MKSTEMP */ - - if (mktemp (template)) - do + fd = -1; + do + { + sprintf (template, "%s/gfortrantmpXXXXXX", tempdir); + if (!mktemp (template)) + break; #if defined(HAVE_CRLF) && defined(O_BINARY) fd = open (template, O_RDWR | O_CREAT | O_EXCL | O_BINARY, S_IREAD | S_IWRITE); #else fd = open (template, O_RDWR | O_CREAT | O_EXCL, S_IREAD | S_IWRITE); #endif - while (!(fd == -1 && errno == EEXIST) && mktemp (template)); - else - fd = -1; + } + while (fd == -1 && errno == EEXIST); #endif /* HAVE_MKSTEMP */ |