diff options
author | Alan Modra <amodra@bigpond.net.au> | 2000-05-26 13:11:57 +0000 |
---|---|---|
committer | Alan Modra <amodra@bigpond.net.au> | 2000-05-26 13:11:57 +0000 |
commit | 3634d26f0c00a89b23b924e0c320ba9c635013b5 (patch) | |
tree | d23ef3464f6c0e3e50581a0797992c2ab9f871da | |
parent | 862f647c482042c314861e6fc7f0bb70f8da24ad (diff) | |
download | gdb-3634d26f0c00a89b23b924e0c320ba9c635013b5.tar.gz |
Eli Zaretskii's DOSish file name patches.
-rw-r--r-- | bfd/ChangeLog | 19 | ||||
-rw-r--r-- | bfd/aoutx.h | 6 | ||||
-rw-r--r-- | bfd/archive.c | 35 | ||||
-rw-r--r-- | bfd/cache.c | 10 | ||||
-rw-r--r-- | bfd/sysdep.h | 19 | ||||
-rw-r--r-- | include/ChangeLog | 6 | ||||
-rw-r--r-- | include/filenames.h | 51 |
7 files changed, 132 insertions, 14 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 9b51a5f5d20..ad7ba442019 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,24 @@ 2000-05-26 Alan Modra <alan@linuxcare.com.au> + * sysdep.h (gettext, dgettext, dcgettext, textdomain, + bindtextdomain): Replace defines with those from intl/libgettext.h + to quieten gcc warnings. + +2000-05-26 Eli Zaretskii <eliz@is.elta.co.il> + + * aoutx.h (find_nearest_line): Use IS_ABSOLUTE_PATH. + + * archive.c (normalize, bfd_bsd_truncate_arname, + bfd_gnu_truncate_arname) [HAVE_DOS_BASED_FILE_SYSTEM]: Support + file names with backslashes. + + * cache.c (bfd_open_file) [__MSDOS__]: Don't unlink the file + before opening it. + + * sysdep.h: Include filenames.h. + +2000-05-26 Alan Modra <alan@linuxcare.com.au> + * opncls.c (bfd_close_all_done): Mask file perms with 0777 not 0x777. 2000-05-26 Jakub Jelinek <jakub@redhat.com> diff --git a/bfd/aoutx.h b/bfd/aoutx.h index 01dd9eee4c0..4b0940d7ad5 100644 --- a/bfd/aoutx.h +++ b/bfd/aoutx.h @@ -1,5 +1,5 @@ /* BFD semi-generic back-end for a.out binaries. - Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. Written by Cygnus Support. @@ -2833,7 +2833,7 @@ NAME(aout,find_nearest_line) } if (main_file_name == NULL - || main_file_name[0] == '/' + || IS_ABSOLUTE_PATH (main_file_name) || directory_name == NULL) filelen = 0; else @@ -2857,7 +2857,7 @@ NAME(aout,find_nearest_line) if (main_file_name != NULL) { - if (main_file_name[0] == '/' || directory_name == NULL) + if (IS_ABSOLUTE_PATH (main_file_name) || directory_name == NULL) *filename_ptr = main_file_name; else { diff --git a/bfd/archive.c b/bfd/archive.c index 1e1c9fa8f20..5709f26e272 100644 --- a/bfd/archive.c +++ b/bfd/archive.c @@ -1,5 +1,5 @@ /* BFD back-end for archive files (libraries). - Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999 + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. Written by Cygnus Support. Mostly Gumby Henkel-Wallace's fault. @@ -1183,6 +1183,17 @@ normalize (abfd, file) { const char *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 @@ -1566,6 +1577,17 @@ bfd_bsd_truncate_arname (abfd, pathname, arhdr) CONST char *filename = strrchr (pathname, '/'); int maxlen = ar_maxnamelen (abfd); +#ifdef HAVE_DOS_BASED_FILE_SYSTEM + { + /* We could have foo/bar\\baz, or foo\\bar, or d:bar. */ + char *bslash = strrchr (pathname, '\\'); + if (bslash > filename) + filename = bslash; + if (filename == NULL && pathname[0] != '\0' && pathname[1] == ':') + filename = pathname + 1; + } +#endif + if (filename == NULL) filename = pathname; else @@ -1606,6 +1628,17 @@ bfd_gnu_truncate_arname (abfd, pathname, arhdr) CONST char *filename = strrchr (pathname, '/'); int maxlen = ar_maxnamelen (abfd); +#ifdef HAVE_DOS_BASED_FILE_SYSTEM + { + /* We could have foo/bar\\baz, or foo\\bar, or d:bar. */ + char *bslash = strrchr (pathname, '\\'); + if (bslash > filename) + filename = bslash; + if (filename == NULL && pathname[0] != '\0' && pathname[1] == ':') + filename = pathname + 1; + } +#endif + if (filename == NULL) filename = pathname; else diff --git a/bfd/cache.c b/bfd/cache.c index ad3140e1ed7..91b6c610854 100644 --- a/bfd/cache.c +++ b/bfd/cache.c @@ -1,5 +1,6 @@ /* BFD library -- caching of file descriptors. - Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 1996, 2000 + Free Software Foundation, Inc. Hacked by Steve Chamberlain of Cygnus Support (steve@cygnus.com). This file is part of BFD, the Binary File Descriptor library. @@ -300,10 +301,17 @@ bfd_open_file (abfd) So we unlink the output file if and only if it has non-zero size. */ +#ifndef __MSDOS__ + /* Don't do this for MSDOS: it doesn't care about overwriting + a running binary, but if this file is already open by + another BFD, we will be in deep trouble if we delete an + open file. In fact, objdump does just that if invoked with + the --info option. */ struct stat s; if (stat (abfd->filename, &s) == 0 && s.st_size != 0) unlink (abfd->filename); +#endif abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_WB); abfd->opened_once = true; } diff --git a/bfd/sysdep.h b/bfd/sysdep.h index 0a58983fa2d..77b5e50a9c3 100644 --- a/bfd/sysdep.h +++ b/bfd/sysdep.h @@ -1,5 +1,5 @@ /* sysdep.h -- handle host dependencies for the BFD library - Copyright 1995, 96, 97, 98, 1999 Free Software Foundation, Inc. + Copyright 1995, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -102,6 +102,8 @@ extern char *strrchr (); #define SEEK_CUR 1 #endif +#include "filenames.h" + #ifdef NEED_DECLARATION_STRSTR extern char *strstr (); #endif @@ -131,14 +133,13 @@ extern char *getenv (); #define N_(String) (String) #endif #else -/* Stubs that do something close enough. */ -#define textdomain(String) (String) -#define gettext(String) (String) -#define dgettext(Domain,Message) (Message) -#define dcgettext(Domain,Message,Type) (Message) -#define bindtextdomain(Domain,Directory) (Domain) -#define _(String) (String) -#define N_(String) (String) +# define gettext(Msgid) (Msgid) +# define dgettext(Domainname, Msgid) (Msgid) +# define dcgettext(Domainname, Msgid, Category) (Msgid) +# define textdomain(Domainname) while (0) /* nothing */ +# define bindtextdomain(Domainname, Dirname) while (0) /* nothing */ +# define _(String) (String) +# define N_(String) (String) #endif #endif /* ! defined (BFD_SYSDEP_H) */ diff --git a/include/ChangeLog b/include/ChangeLog index 76e73fb4eac..1937bcaf54a 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,9 @@ +2000-05-26 Eli Zaretskii <eliz@is.elta.co.il> + + * filenames.h: New file. + (HAVE_DOS_BASED_FILE_SYSTEM, IS_DIR_SEPARATOR) + (IS_ABSOLUTE_PATH, FILENAME_CMP): New macros. + 2000-05-17 S. Bharadwaj Yadavalli <sby@scrugs.lkg.dec.com> Rick Gorton <gorton@scrugs.lkg.dec.com> diff --git a/include/filenames.h b/include/filenames.h new file mode 100644 index 00000000000..ba933c8530e --- /dev/null +++ b/include/filenames.h @@ -0,0 +1,51 @@ +/* Macros for taking apart, interpreting and processing file names. + + These are here because some non-Posix (a.k.a. DOSish) systems have + drive letter brain-damage at the beginning of an absolute file name, + use forward- and back-slash in path names interchangeably, and + some of them have case-insensitive file names. + + Copyright 2000 Free Software Foundation, Inc. + +This file is part of BFD, the Binary File Descriptor library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef FILENAMES_H +#define FILENAMES_H + +#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) + +#ifndef HAVE_DOS_BASED_FILE_SYSTEM +#define HAVE_DOS_BASED_FILE_SYSTEM 1 +#endif + +#define IS_DIR_SEPARATOR(c) ((c) == '/' || (c) == '\\') +/* Note that IS_ABSOLUTE_PATH accepts d:foo as well, although it is + only semi-absolute. This is because the users of IS_ABSOLUTE_PATH + want to know whether to prepend the current working directory to + a file name, which should not be done with a name like d:foo. */ +#define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]) || (((f)[0]) && ((f)[1] == ':'))) +#define FILENAME_CMP(s1, s2) strcasecmp(s1, s2) + +#else /* not DOSish */ + +#define IS_DIR_SEPARATOR(c) ((c) == '/') +#define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0])) +#define FILENAME_CMP(s1, s2) strcmp(s1, s2) + +#endif /* not DOSish */ + +#endif /* FILENAMES_H */ |