aboutsummaryrefslogtreecommitdiff
path: root/binutils/bucomm.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2000-05-26 13:11:57 +0000
committerAlan Modra <amodra@gmail.com>2000-05-26 13:11:57 +0000
commit5af11cab92a8d4ed9b0cd7a46f05cf02a8ba901e (patch)
tree43c01869523de4ad682493e6674e5e8a9fed1804 /binutils/bucomm.c
parent010c70e10fb422ae6151a8808215a122f461fce8 (diff)
downloadgdb-5af11cab92a8d4ed9b0cd7a46f05cf02a8ba901e.zip
gdb-5af11cab92a8d4ed9b0cd7a46f05cf02a8ba901e.tar.gz
gdb-5af11cab92a8d4ed9b0cd7a46f05cf02a8ba901e.tar.bz2
Eli Zaretskii's DOSish file name patches.
Diffstat (limited to 'binutils/bucomm.c')
-rw-r--r--binutils/bucomm.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/binutils/bucomm.c b/binutils/bucomm.c
index 3406e1d..76ffa60 100644
--- a/binutils/bucomm.c
+++ b/binutils/bucomm.c
@@ -25,6 +25,7 @@
#include "bfd.h"
#include "libiberty.h"
#include "bucomm.h"
+#include "filenames.h"
#include <sys/stat.h>
#include <time.h> /* ctime, maybe time_t */
@@ -214,9 +215,15 @@ make_tempname (filename)
char *tmpname;
char *slash = strrchr (filename, '/');
-#if defined (__DJGPP__) || defined (__GO32__) || defined (_WIN32)
- if (slash == NULL)
- slash = strrchr (filename, '\\');
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+ {
+ /* We could have foo/bar\\baz, or foo\\bar, or d:bar. */
+ char *bslash = strrchr (filename, '\\');
+ if (bslash > slash)
+ slash = bslash;
+ if (slash == NULL && filename[0] != '\0' && filename[1] == ':')
+ slash = filename + 1;
+ }
#endif
if (slash != (char *) NULL)
@@ -225,8 +232,15 @@ make_tempname (filename)
c = *slash;
*slash = 0;
- tmpname = xmalloc (strlen (filename) + sizeof (template) + 1);
+ tmpname = xmalloc (strlen (filename) + sizeof (template) + 2);
strcpy (tmpname, filename);
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+ /* If tmpname is "X:", appending a slash will make it a root
+ directory on drive X, which is NOT the same as the current
+ directory on drive X. */
+ if (tmpname[1] == ':' && tmpname[2] == '\0')
+ strcat (tmpname, ".");
+#endif
strcat (tmpname, "/");
strcat (tmpname, template);
mktemp (tmpname);