This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Re: DOS/Windows patches, take 2
These are the patches for the bfd subdirectory:
2000-05-14 Eli Zaretskii <eliz@is.elta.co.il>
* aoutx.h (NAME(aout,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 (from include/ directory).
*** ./bfd/aoutx.h.orig Sun Apr 16 09:38:54 2000
--- ./bfd/aoutx.h Fri May 12 18:38:40 2000
*************** NAME(aout,find_nearest_line)
*** 2833,2839 ****
}
if (main_file_name == NULL
! || main_file_name[0] == '/'
|| directory_name == NULL)
filelen = 0;
else
--- 2833,2839 ----
}
if (main_file_name == NULL
! || IS_ABSOLUTE_PATH (main_file_name)
|| directory_name == NULL)
filelen = 0;
else
*************** NAME(aout,find_nearest_line)
*** 2857,2863 ****
if (main_file_name != NULL)
{
! if (main_file_name[0] == '/' || directory_name == NULL)
*filename_ptr = main_file_name;
else
{
--- 2857,2863 ----
if (main_file_name != NULL)
{
! if (IS_ABSOLUTE_PATH (main_file_name) || directory_name == NULL)
*filename_ptr = main_file_name;
else
{
*** ./bfd/archive.c.orig Tue Apr 25 17:15:10 2000
--- ./bfd/archive.c Fri May 12 18:38:40 2000
*************** normalize (abfd, file)
*** 1183,1188 ****
--- 1183,1198 ----
{
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 && bslash > filename)
+ filename = bslash;
+ if (filename == NULL && file[0] != '\0' && file[1] == ':')
+ filename = file + 1;
+ }
+ #endif
if (filename != (char *) NULL)
filename++;
else
*************** bfd_bsd_truncate_arname (abfd, pathname,
*** 1566,1571 ****
--- 1576,1591 ----
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 && bslash > filename)
+ filename = bslash;
+ if (filename == NULL && pathname[0] != '\0' && pathname[1] == ':')
+ filename = pathname + 1;
+ }
+ #endif
+
if (filename == NULL)
filename = pathname;
else
*************** bfd_gnu_truncate_arname (abfd, pathname,
*** 1606,1611 ****
--- 1626,1641 ----
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 && bslash > filename)
+ filename = bslash;
+ if (filename == NULL && pathname[0] != '\0' && pathname[1] == ':')
+ filename = pathname + 1;
+ }
+ #endif
+
if (filename == NULL)
filename = pathname;
else
*** ./bfd/cache.c.orig Sun Apr 16 09:38:54 2000
--- ./bfd/cache.c Fri May 12 18:40:46 2000
*************** bfd_open_file (abfd)
*** 300,309 ****
--- 300,316 ----
So we unlink the output file if and only if it has
non-zero size. */
+ #if !defined (__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;
}
*** ./bfd/sysdep.h.orig Mon May 3 03:28:58 1999
--- ./bfd/sysdep.h Fri May 12 18:38:40 2000
*************** extern char *strrchr ();
*** 102,107 ****
--- 102,109 ----
#define SEEK_CUR 1
#endif
+ #include "filenames.h"
+
#ifdef NEED_DECLARATION_STRSTR
extern char *strstr ();
#endif