/* This file exports two functions: choose_temp_base and make_temp_file. */
-/* This file lives in at least two places: libiberty and gcc.
- Don't change one without the other. */
-
-#if defined (IN_GCC) || defined (HAVE_CONFIG_H)
+#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef IN_GCC
-#include "system.h"
-#else
-
-/* If we are in gcc, system.h has handled everything. When not in
- gcc, if we have a config.h we assume that HAVE_SYS_FILE_H tells us
- whether to include sys/file.h. However, libiberty does not have a
- config.h, and instead arranges to define NO_SYS_FILE_H on the
- command line when there is no sys/file.h. */
-
-#if defined (HAVE_CONFIG_H) ? defined (HAVE_SYS_FILE_H) : ! defined (NO_SYS_FILE_H)
+#include <stdio.h> /* May get P_tmpdir. */
#include <sys/types.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_SYS_FILE_H
#include <sys/file.h> /* May get R_OK, etc. on some systems. */
#endif
#define X_OK 1
#endif
-#include <stdio.h> /* May get P_tmpdir. */
-#endif /* IN_GCC */
-
-#ifdef IN_GCC
-extern char *xmalloc ();
-extern int mkstemps ();
-#else
-#include "ansidecl.h"
#include "libiberty.h"
-#if defined (__MSDOS__) || defined (_WIN32)
+extern int mkstemps ();
+
+#ifndef IN_GCC
+#if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN__) && ! defined (_UWIN))
#define DIR_SEPARATOR '\\'
#endif
#endif
If success, DIR is returned.
Otherwise NULL is returned. */
-static char *
+static const char *try PARAMS ((const char *, const char *));
+
+static const char *
try (dir, base)
- char *dir, *base;
+ const char *dir, *base;
{
if (base != 0)
return base;
char *
choose_temp_base ()
{
- char *base = 0;
+ const char *base = 0;
char *temp_filename;
int len;
static char tmp[] = { DIR_SEPARATOR, 't', 'm', 'p', 0 };
char *
make_temp_file (suffix)
- char *suffix;
+ const char *suffix;
{
- char *base = 0;
+ const char *base = 0;
char *temp_filename;
int base_len, suffix_len;
int fd;