Commit 01d42eb5 by Kai Tietz Committed by Kai Tietz

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
parent a3ba2937
2010-04-24 Kai Tietz <kai.tietz@onevision.com>
PR/43844
* io/unix.c (tempfile): Correct logic for mktemp case.
2010-04-06 Tobias Burnus <burnus@net-b.de> 2010-04-06 Tobias Burnus <burnus@net-b.de>
PR fortran/39997 PR fortran/39997
......
...@@ -889,25 +889,26 @@ tempfile (st_parameter_open *opp) ...@@ -889,25 +889,26 @@ tempfile (st_parameter_open *opp)
template = get_mem (strlen (tempdir) + 20); template = get_mem (strlen (tempdir) + 20);
sprintf (template, "%s/gfortrantmpXXXXXX", tempdir);
#ifdef HAVE_MKSTEMP #ifdef HAVE_MKSTEMP
sprintf (template, "%s/gfortrantmpXXXXXX", tempdir);
fd = mkstemp (template); fd = mkstemp (template);
#else /* HAVE_MKSTEMP */ #else /* HAVE_MKSTEMP */
fd = -1;
if (mktemp (template)) do
do {
sprintf (template, "%s/gfortrantmpXXXXXX", tempdir);
if (!mktemp (template))
break;
#if defined(HAVE_CRLF) && defined(O_BINARY) #if defined(HAVE_CRLF) && defined(O_BINARY)
fd = open (template, O_RDWR | O_CREAT | O_EXCL | O_BINARY, fd = open (template, O_RDWR | O_CREAT | O_EXCL | O_BINARY,
S_IREAD | S_IWRITE); S_IREAD | S_IWRITE);
#else #else
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);
#endif #endif
while (!(fd == -1 && errno == EEXIST) && mktemp (template)); }
else while (fd == -1 && errno == EEXIST);
fd = -1;
#endif /* HAVE_MKSTEMP */ #endif /* HAVE_MKSTEMP */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment