From: ktietz Date: Sat, 24 Apr 2010 12:24:33 +0000 (+0000) Subject: 2010-04-24 Kai Tietz X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=726fd258ffe36870ed3adf8f2dd5fd4e1579591e;p=thirdparty%2Fgcc.git 2010-04-24 Kai Tietz PR/43844 * io/unix.c (tempfile): Correct logic for mktemp case. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158686 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 78c6b04e9c9a..2c38ba39af1a 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,8 @@ +2010-04-24 Kai Tietz + + PR/43844 + * io/unix.c (tempfile): Correct logic for mktemp case. + 2010-04-06 Tobias Burnus PR fortran/39997 diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c index 32f38904f341..b3bd438c32dd 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 */