summaryrefslogtreecommitdiff
path: root/binutils/bucomm.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2000-05-26 13:11:57 +0000
committerAlan Modra <amodra@bigpond.net.au>2000-05-26 13:11:57 +0000
commit0ec238fa07cba008eba87c85d917d849fcb4c492 (patch)
tree63de07d189bc1be9db1080c93c385aab223e0ede /binutils/bucomm.c
parent20b373ea5e261308d08c71629f0c6ac2b652b0ea (diff)
downloadbinutils-redhat-0ec238fa07cba008eba87c85d917d849fcb4c492.tar.gz
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 3406e1d6e6..76ffa60a17 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);