aboutsummaryrefslogtreecommitdiff
path: root/binutils
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
parent010c70e10fb422ae6151a8808215a122f461fce8 (diff)
downloadgdb-5af11cab92a8d4ed9b0cd7a46f05cf02a8ba901e.zip
gdb-5af11cab92a8d4ed9b0cd7a46f05cf02a8ba901e.tar.gz
gdb-5af11cab92a8d4ed9b0cd7a46f05cf02a8ba901e.tar.bz2
Eli Zaretskii's DOSish file name patches.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog39
-rw-r--r--binutils/ar.c62
-rw-r--r--binutils/arsup.c15
-rw-r--r--binutils/bucomm.c22
-rw-r--r--binutils/config.in3
-rwxr-xr-xbinutils/configure2
-rw-r--r--binutils/configure.in2
-rw-r--r--binutils/ieee.c41
-rw-r--r--binutils/objcopy.c13
-rw-r--r--binutils/strings.c20
10 files changed, 173 insertions, 46 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 6365b71..6702d7c 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,42 @@
+2000-05-26 Eli Zaretskii <eliz@is.elta.co.il>
+
+ * ar.c: Include filenames.h.
+ (normalize) [HAVE_DOS_BASED_FILE_SYSTEM]: Support backslashes
+ and drive letters in file names.
+ (main): Support backslashes and drive letters in argv[0]. Drop
+ the .exe suffix, if any, in argv[0] if is_ranlib is negative. Use
+ FILENAME_CMP instead of strcmp to compare file names.
+ (open_inarch) [__GO32__]: Don't ifdef errno != ENOENT test for
+ DJGPP v2.
+ (do_quick_append) [__GO32__]: Ditto.
+ (get_pos_bfd, delete_members, move_members, replace_members):
+ Compare file names with FILENAME_CMP.
+
+ * bucomm.c: Include filenames.h.
+ (make_tempname) [HAVE_DOS_BASED_FILE_SYSTEM]: Support mixed
+ forward/backward slashes and drive letters in file names.
+
+ * ieee.c (ieee_start_compilation_unit, ieee_add_bb11): Support
+ mixed forward/backward slashes and drive letters in file names.
+
+ * strings.c (O_BINARY, setmode, SET_BINARY): Define.
+ (main) [SET_BINARY]: Use SET_BINARY to switch stdin into binary
+ mode.
+
+ * objcopy.c: Include filenames.h.
+ (main) [HAVE_DOS_BASED_FILE_SYSTEM]: Drop the .exe suffix
+ before comparing to "strip".
+ Use FILENAME_CMP to compare file names.
+
+ * arsup.c: Include filenames.h.
+ (map_over_list, ar_delete, ar_replace, ar_extract): Use
+ FILENAME_CMP to compare file names.
+ (ar_open): Prepend "tmp-" instead of appending "-tmp", to create
+ the temporary file name.
+
+ * configure.in: Check for setmode.
+ * configure: Regenerate.
+
2000-05-24 Alan Modra <alan@linuxcare.com.au>
* objdump.c (display_target_list): Close the bfd.
diff --git a/binutils/ar.c b/binutils/ar.c
index 17388a4..d67f4b3 100644
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -32,6 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "aout/ar.h"
#include "libbfd.h"
#include "arsup.h"
+#include "filenames.h"
#include <sys/stat.h>
#ifdef __GO32___
@@ -215,7 +216,7 @@ map_over_members (arch, function, files, count)
bfd_stat_arch_elt (head, &buf);
}
if ((head->filename != NULL) &&
- (!strcmp (normalize (*files, arch), head->filename)))
+ (!FILENAME_CMP (normalize (*files, arch), head->filename)))
{
++match_count;
if (counted_name_mode
@@ -302,6 +303,16 @@ normalize (file, abfd)
return file;
filename = strrchr (file, '/');
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+ {
+ /* We could have foo/bar\\baz, or foo\\bar, or d:bar. */
+ char *bslash = strrchr (file, '\\');
+ if (bslash > filename)
+ filename = bslash;
+ if (filename == NULL && file[0] != '\0' && file[1] == ':')
+ filename = file + 1;
+ }
+#endif
if (filename != (char *) NULL)
filename++;
else
@@ -377,12 +388,22 @@ main (argc, argv)
char *temp;
temp = strrchr (program_name, '/');
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+ {
+ /* We could have foo/bar\\baz, or foo\\bar, or d:bar. */
+ char *bslash = strrchr (program_name, '\\');
+ if (bslash > temp)
+ temp = bslash;
+ if (temp == NULL && program_name[0] != '\0' && program_name[1] == ':')
+ temp = program_name + 1;
+ }
+#endif
if (temp == NULL)
temp = program_name;
else
++temp;
if (strlen (temp) >= 6
- && strcmp (temp + strlen (temp) - 6, "ranlib") == 0)
+ && FILENAME_CMP (temp + strlen (temp) - 6, "ranlib") == 0)
is_ranlib = 1;
else
is_ranlib = 0;
@@ -697,12 +718,15 @@ open_inarch (archive_filename, file)
if (stat (archive_filename, &sbuf) != 0)
{
-#ifndef __GO32__
+#if !defined(__GO32__) || defined(__DJGPP__)
+
+ /* FIXME: I don't understand why this fragment was ifndef'ed
+ away for __GO32__; perhaps it was in the days of DJGPP v1.x.
+ stat() works just fine in v2.x, so I think this should be
+ removed. For now, I enable it for DJGPP v2. -- EZ. */
/* KLUDGE ALERT! Temporary fix until I figger why
- * stat() is wrong ... think it's buried in GO32's IDT
- * - Jax
- */
+ stat() is wrong ... think it's buried in GO32's IDT - Jax */
if (errno != ENOENT)
bfd_fatal (archive_filename);
#endif
@@ -932,12 +956,18 @@ do_quick_append (archive_filename, files_to_append)
if (stat (archive_filename, &sbuf) != 0)
{
-#ifndef __GO32__
+#if !defined(__GO32__) || defined(__DJGPP__)
+
+ /* FIXME: I don't understand why this fragment was ifndef'ed
+ away for __GO32__; perhaps it was in the days of DJGPP v1.x.
+ stat() works just fine in v2.x, so I think this should be
+ removed. For now, I enable it for DJGPP v2.
+
+ (And yes, I know this is all unused, but somebody, someday,
+ might wish to resurrect this again... -- EZ. */
/* KLUDGE ALERT! Temporary fix until I figger why
- * stat() is wrong ... think it's buried in GO32's IDT
- * - Jax
- */
+ stat() is wrong ... think it's buried in GO32's IDT - Jax */
if (errno != ENOENT)
bfd_fatal (archive_filename);
@@ -1107,7 +1137,7 @@ get_pos_bfd (contents, default_pos, default_posname)
else
{
for (; *after_bfd; after_bfd = &(*after_bfd)->next)
- if (strcmp ((*after_bfd)->filename, realposname) == 0)
+ if (FILENAME_CMP ((*after_bfd)->filename, realposname) == 0)
{
if (realpos == pos_after)
after_bfd = &(*after_bfd)->next;
@@ -1147,7 +1177,7 @@ delete_members (arch, files_to_delete)
current_ptr_ptr = &(arch->next);
while (*current_ptr_ptr)
{
- if (strcmp (normalize (*files_to_delete, arch),
+ if (FILENAME_CMP (normalize (*files_to_delete, arch),
(*current_ptr_ptr)->filename) == 0)
{
++match_count;
@@ -1204,8 +1234,8 @@ move_members (arch, files_to_move)
while (*current_ptr_ptr)
{
bfd *current_ptr = *current_ptr_ptr;
- if (strcmp (normalize (*files_to_move, arch),
- current_ptr->filename) == 0)
+ if (FILENAME_CMP (normalize (*files_to_move, arch),
+ current_ptr->filename) == 0)
{
/* Move this file to the end of the list - first cut from
where it is. */
@@ -1260,8 +1290,8 @@ replace_members (arch, files_to_move, quick)
/* For compatibility with existing ar programs, we
permit the same file to be added multiple times. */
- if (strcmp (normalize (*files_to_move, arch),
- normalize (current->filename, arch)) == 0
+ if (FILENAME_CMP (normalize (*files_to_move, arch),
+ normalize (current->filename, arch)) == 0
&& current->arelt_data != NULL)
{
if (newer_only)
diff --git a/binutils/arsup.c b/binutils/arsup.c
index d6809fc..eebee99 100644
--- a/binutils/arsup.c
+++ b/binutils/arsup.c
@@ -1,5 +1,5 @@
/* arsup.c - Archive support for MRI compatibility
- Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999
+ Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99, 2000
Free Software Foundation, Inc.
This file is part of GNU Binutils.
@@ -31,6 +31,7 @@ style librarian command syntax + 1 word LIST
#include "arsup.h"
#include "libiberty.h"
#include "bucomm.h"
+#include "filenames.h"
static void map_over_list
PARAMS ((bfd *, void (*function) (bfd *, bfd *), struct list *));
@@ -76,7 +77,7 @@ map_over_list (arch, function, list)
for (head = arch->next; head; head = head->next)
{
if (head->filename != NULL
- && strcmp (ptr->name, head->filename) == 0)
+ && FILENAME_CMP (ptr->name, head->filename) == 0)
{
found = true;
function (head, prev);
@@ -160,7 +161,9 @@ DEFUN(ar_open,(name, t),
{
char *tname = (char *) xmalloc (strlen (name) + 10);
real_name = name;
- sprintf(tname, "%s-tmp", name);
+ /* Prepend tmp- to the beginning, to avoid file-name clashes after
+ truncation on filesystems with limited namespaces (DOS). */
+ sprintf(tname, "tmp-%s", name);
obfd = bfd_openw(tname, NULL);
if (!obfd) {
@@ -289,7 +292,7 @@ DEFUN(ar_delete, (list),
bfd **prev = &(obfd->archive_head);
int found = 0;
while (member) {
- if (strcmp(member->filename, list->name) == 0) {
+ if (FILENAME_CMP(member->filename, list->name) == 0) {
*prev = member->next;
found = 1;
}
@@ -346,7 +349,7 @@ DEFUN(ar_replace, (list),
int found = 0;
while (member)
{
- if (strcmp(member->filename, list->name) == 0)
+ if (FILENAME_CMP(member->filename, list->name) == 0)
{
/* Found the one to replace */
bfd *abfd = bfd_openr(list->name, 0);
@@ -437,7 +440,7 @@ DEFUN(ar_extract,(list),
int found = 0;
while (member && !found)
{
- if (strcmp(member->filename, list->name) == 0)
+ if (FILENAME_CMP(member->filename, list->name) == 0)
{
extract_file(member);
found = 1;
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);
diff --git a/binutils/config.in b/binutils/config.in
index 3c26c5c..7b70d16 100644
--- a/binutils/config.in
+++ b/binutils/config.in
@@ -82,6 +82,9 @@
/* Define if you have the setlocale function. */
#undef HAVE_SETLOCALE
+/* Define if you have the setmode function. */
+#undef HAVE_SETMODE
+
/* Define if you have the stpcpy function. */
#undef HAVE_STPCPY
diff --git a/binutils/configure b/binutils/configure
index 43fe8a6..21270e9 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -4325,7 +4325,7 @@ EOF
fi
-for ac_func in sbrk utimes
+for ac_func in sbrk utimes setmode
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:4332: checking for $ac_func" >&5
diff --git a/binutils/configure.in b/binutils/configure.in
index 27a1486..6b5ae24 100644
--- a/binutils/configure.in
+++ b/binutils/configure.in
@@ -96,7 +96,7 @@ AC_SUBST(DEMANGLER_NAME)
AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h fcntl.h sys/file.h)
AC_HEADER_SYS_WAIT
AC_FUNC_ALLOCA
-AC_CHECK_FUNCS(sbrk utimes)
+AC_CHECK_FUNCS(sbrk utimes setmode)
# Some systems have frexp only in -lm, not in -lc.
AC_SEARCH_LIBS(frexp, m)
diff --git a/binutils/ieee.c b/binutils/ieee.c
index a3bb93b..27409cc 100644
--- a/binutils/ieee.c
+++ b/binutils/ieee.c
@@ -1,5 +1,5 @@
/* ieee.c -- Read and write IEEE-695 debugging information.
- Copyright (C) 1996, 1998, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1998, 1999, 2000 Free Software Foundation, Inc.
Written by Ian Lance Taylor <ian@cygnus.com>.
This file is part of GNU Binutils.
@@ -30,6 +30,7 @@
#include "libiberty.h"
#include "debug.h"
#include "budbg.h"
+#include "filenames.h"
/* This structure holds an entry on the block stack. */
@@ -4926,6 +4927,7 @@ ieee_start_compilation_unit (p, filename)
{
struct ieee_handle *info = (struct ieee_handle *) p;
const char *modname;
+ const char *backslash;
char *c, *s;
unsigned int nindx;
@@ -4937,16 +4939,20 @@ ieee_start_compilation_unit (p, filename)
info->filename = filename;
modname = strrchr (filename, '/');
+ /* We could have a mixed forward/back slash case. */
+ backslash = strrchr (modname, '\\');
+ if (backslash > modname)
+ modname = backslash;
+
if (modname != NULL)
++modname;
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+ else if (filename[0] && filename[1] == ':')
+ modname = filename + 2;
+#endif
else
- {
- modname = strrchr (filename, '\\');
- if (modname != NULL)
- ++modname;
- else
- modname = filename;
- }
+ modname = filename;
+
c = xstrdup (modname);
s = strrchr (c, '.');
if (s != NULL)
@@ -5194,22 +5200,25 @@ ieee_add_bb11 (info, sec, low, high)
}
else
{
- const char *filename, *modname;
+ const char *filename, *modname, *backslash;
char *c, *s;
/* Start the enclosing BB10 block. */
filename = bfd_get_filename (info->abfd);
modname = strrchr (filename, '/');
+ backslash = strrchr (modname, '\\');
+ if (backslash > modname)
+ modname = backslash;
+
if (modname != NULL)
++modname;
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+ else if (filename[0] && filename[1] == ':')
+ modname = filename + 2;
+#endif
else
- {
- modname = strrchr (filename, '\\');
- if (modname != NULL)
- ++modname;
- else
- modname = filename;
- }
+ modname = filename;
+
c = xstrdup (modname);
s = strrchr (c, '.');
if (s != NULL)
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 36d5f4c..b8a49c8 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -1,5 +1,5 @@
/* objcopy.c -- copy object file from input to output, optionally massaging it.
- Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 1999
+ Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000
Free Software Foundation, Inc.
This file is part of GNU Binutils.
@@ -25,6 +25,7 @@
#include "getopt.h"
#include "libiberty.h"
#include "budbg.h"
+#include "filenames.h"
#include <sys/stat.h>
/* A list of symbols to explicitly strip out, or to keep. A linked
@@ -2253,7 +2254,15 @@ main (argc, argv)
if (is_strip < 0)
{
int i = strlen (program_name);
- is_strip = (i >= 5 && strcmp (program_name + i - 5, "strip") == 0);
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+ /* Drop the .exe suffix, if any. */
+ if (i > 4 && FILENAME_CMP (program_name + i - 4, ".exe") == 0)
+ {
+ i -= 4;
+ program_name[i] = '\0';
+ }
+#endif
+ is_strip = (i >= 5 && FILENAME_CMP (program_name + i - 5, "strip") == 0);
}
if (is_strip)
diff --git a/binutils/strings.c b/binutils/strings.c
index ab845b0..54f29e4 100644
--- a/binutils/strings.c
+++ b/binutils/strings.c
@@ -59,6 +59,23 @@
#include "bucomm.h"
#include "libiberty.h"
+/* Some platforms need to put stdin into binary mode, to read
+ binary files. */
+#ifdef HAVE_SETMODE
+#ifndef O_BINARY
+#ifdef _O_BINARY
+#define O_BINARY _O_BINARY
+#define setmode _setmode
+#else
+#define O_BINARY 0
+#endif
+#endif
+#if O_BINARY
+#include <io.h>
+#define SET_BINARY(f) do { if (!isatty(f)) setmode(f,O_BINARY); } while (0)
+#endif
+#endif
+
#ifdef isascii
#define isgraphic(c) (isascii (c) && isprint (c))
#else
@@ -218,6 +235,9 @@ main (argc, argv)
if (optind >= argc)
{
datasection_only = false;
+#ifdef SET_BINARY
+ SET_BINARY (fileno (stdin));
+#endif
print_strings ("{standard input}", stdin, 0, 0, 0, (char *) NULL);
files_given = true;
}