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
This commit is contained in:
Kai Tietz 2010-04-24 12:24:33 +00:00 committed by Kai Tietz
parent a3ba29377f
commit 01d42eb543
2 changed files with 14 additions and 8 deletions

View File

@ -1,3 +1,8 @@
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>
PR fortran/39997

View File

@ -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 */