OSDN Git Service

Correct previous ChangeLog entry.
[pf3gnuchains/gcc-fork.git] / libiberty / make-temp-file.c
index 8429624..8833504 100644 (file)
@@ -45,28 +45,11 @@ Boston, MA 02111-1307, USA.  */
 #include "libiberty.h"
 extern int mkstemps PARAMS ((char *, int));
 
-#ifndef IN_GCC
-#if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN__) && ! defined (_UWIN))
-#define DIR_SEPARATOR '\\'
-#endif
-#endif
-
+/* '/' works just fine on MS-DOS based systems.  */
 #ifndef DIR_SEPARATOR
 #define DIR_SEPARATOR '/'
 #endif
 
-/* On MSDOS, write temp files in current dir
-   because there's no place else we can expect to use.  */
-/* ??? Although the current directory is tried as a last resort,
-   this is left in so that on MSDOS it is preferred to /tmp on the
-   off chance that someone requires this, since that was the previous
-   behaviour.  */
-#ifdef __MSDOS__
-#ifndef P_tmpdir
-#define P_tmpdir "."
-#endif
-#endif
-
 /* Name of temporary file.
    mktemp requires 6 trailing X's.  */
 #define TEMP_FILE "ccXXXXXX"
@@ -78,9 +61,9 @@ extern int mkstemps PARAMS ((char *, int));
    If success, DIR is returned.
    Otherwise NULL is returned.  */
 
-static const char *try PARAMS ((const char *, const char *));
+static inline const char *try PARAMS ((const char *, const char *));
 
-static const char *
+static inline const char *
 try (dir, base)
      const char *dir, *base;
 {
@@ -92,12 +75,25 @@ try (dir, base)
   return 0;
 }
 
-static char tmp[] = { DIR_SEPARATOR, 't', 'm', 'p', 0 };
-static char usrtmp[] =
+static const char tmp[] = { DIR_SEPARATOR, 't', 'm', 'p', 0 };
+static const char usrtmp[] =
 { DIR_SEPARATOR, 'u', 's', 'r', DIR_SEPARATOR, 't', 'm', 'p', 0 };
+static const char vartmp[] =
+{ DIR_SEPARATOR, 'v', 'a', 'r', DIR_SEPARATOR, 't', 'm', 'p', 0 };
 
 static char *memoized_tmpdir;
 
+/*
+
+@deftypefn Replacement char* choose_tmpdir ()
+
+Returns a pointer to a directory path suitable for creating temporary
+files in.
+
+@end deftypefn
+
+*/
+
 char *
 choose_tmpdir ()
 {
@@ -116,7 +112,8 @@ choose_tmpdir ()
   base = try (P_tmpdir, base);
 #endif
 
-  /* Try /usr/tmp, then /tmp.  */
+  /* Try /var/tmp, /usr/tmp, then /tmp.  */
+  base = try (vartmp, base);
   base = try (usrtmp, base);
   base = try (tmp, base);
  
@@ -136,9 +133,17 @@ choose_tmpdir ()
   return tmpdir;
 }
 
-/* Return a temporary file name (as a string) or NULL if unable to create
-   one.  SUFFIX is a suffix to append to the file name.  The string is
-   malloced, and the temporary file has been created.  */
+/*
+
+@deftypefn Replacement char* make_temp_file (const char *@var{suffix})
+
+Return a temporary file name (as a string) or @code{NULL} if unable to
+create one.  @var{suffix} is a suffix to append to the file name.  The
+string is @code{malloc}ed, and the temporary file has been created.
+
+@end deftypefn
+
+*/
 
 char *
 make_temp_file (suffix)