gdb/
[binutils-gdb.git] / libiberty / make-temp-file.c
index eadcf8502137f111a7463f0c6b59f6a633f58a3e..4e3876676e2721284b15ed6c4b7ee37e022ed5c7 100644 (file)
@@ -1,5 +1,5 @@
 /* Utility to pick a temporary filename prefix.
-   Copyright (C) 1996, 1997, 1998, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998, 2001, 2009 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
@@ -111,12 +111,22 @@ choose_tmpdir (void)
       char *tmpdir;
       unsigned int len;
       
+#ifdef VMS
+      /* Try VMS standard temp logical.  */
+      base = try_dir ("/sys$scratch", base);
+#else
       base = try_dir (getenv ("TMPDIR"), base);
       base = try_dir (getenv ("TMP"), base);
       base = try_dir (getenv ("TEMP"), base);
+#endif
       
 #ifdef P_tmpdir
-      base = try_dir (P_tmpdir, base);
+      /* We really want a directory name here as if concatenated with say \dir
+        we do not end up with a double \\ which defines an UNC path.  */
+      if (strcmp (P_tmpdir, "\\") == 0)
+       base = try_dir ("\\.", base);
+      else
+       base = try_dir (P_tmpdir, base);
 #endif
 
       /* Try /var/tmp, /usr/tmp, then /tmp.  */