Change bfd_target_vector from an array to a pointer
[deliverable/binutils-gdb.git] / binutils / bucomm.c
index a5b0054887aaeaf38bd01c99a56f1686d877db68..1cf904dd9ad2e9e40a06d9a472f8a585cf58261b 100644 (file)
@@ -1,5 +1,6 @@
 /* bucomm.c -- Bin Utils COMmon code.
-   Copyright (C) 1991, 92, 93, 94, 95, 1997, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1991, 92, 93, 94, 95, 97, 98, 2000
+   Free Software Foundation, Inc.
 
    This file is part of GNU Binutils.
 
@@ -24,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 */
 typedef long time_t;
 #endif
 #endif
-
-#ifdef ANSI_PROTOTYPES
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
 \f
 /* Error reporting */
 
@@ -64,7 +60,7 @@ bfd_fatal (string)
   xexit (1);
 }
 
-static void
+void
 report (format, args)
      const char * format;
      va_list args;
@@ -161,7 +157,7 @@ list_supported_targets (name, f)
      const char *name;
      FILE *f;
 {
-  extern bfd_target *bfd_target_vector[];
+  extern const bfd_target *const *bfd_target_vector;
   int t;
 
   if (name == NULL)
@@ -219,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 (slash == NULL || (bslash != NULL && bslash > slash))
+      slash = bslash;
+    if (slash == NULL && filename[0] != '\0' && filename[1] == ':')
+      slash = filename + 1;
+  }
 #endif
 
   if (slash != (char *) NULL)
@@ -230,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);
This page took 0.051922 seconds and 4 git commands to generate.