Improve temporary file name guess.
This commit is contained in:
parent
41239078a9
commit
4eea8720a0
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#ident "$Id: main.c,v 1.43 2002/07/14 23:32:31 steve Exp $"
|
#ident "$Id: main.c,v 1.44 2002/07/15 00:33:50 steve Exp $"
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
||||||
|
|
@ -44,6 +44,7 @@ const char HELP[] =
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <libiberty.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAVE_GETOPT_H
|
#if HAVE_GETOPT_H
|
||||||
|
|
@ -134,9 +135,18 @@ static const char*my_tempfile(const char*str, FILE**fout)
|
||||||
tmpdir = getenv("TMPDIR");
|
tmpdir = getenv("TMPDIR");
|
||||||
if (tmpdir == 0)
|
if (tmpdir == 0)
|
||||||
tmpdir = getenv("TEMP");
|
tmpdir = getenv("TEMP");
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
if (tmpdir == 0)
|
||||||
|
tmpdir = "C:\TEMP";
|
||||||
|
#else
|
||||||
|
if (tmpdir == 0)
|
||||||
|
tmpdir = "/tmp";
|
||||||
|
#endif
|
||||||
|
|
||||||
assert(tmpdir);
|
assert(tmpdir);
|
||||||
assert((strlen(tmpdir) + strlen(str)) < sizeof pathbuf - 10);
|
assert((strlen(tmpdir) + strlen(str)) < sizeof pathbuf - 10);
|
||||||
|
|
||||||
|
srand(getpid());
|
||||||
retry = 100;
|
retry = 100;
|
||||||
file = NULL;
|
file = NULL;
|
||||||
while ((retry > 0) && (file == NULL)) {
|
while ((retry > 0) && (file == NULL)) {
|
||||||
|
|
@ -746,6 +756,9 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: main.c,v $
|
* $Log: main.c,v $
|
||||||
|
* Revision 1.44 2002/07/15 00:33:50 steve
|
||||||
|
* Improve temporary file name guess.
|
||||||
|
*
|
||||||
* Revision 1.43 2002/07/14 23:32:31 steve
|
* Revision 1.43 2002/07/14 23:32:31 steve
|
||||||
* No longer need the .exe on generated files.
|
* No longer need the .exe on generated files.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue