Mail Archives: djgpp-workers/1999/08/01/10:49:17
These are the patches for the binutils subdirectory.
1999-07-31 Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
* ar.c: Include filenames.h.
(normalize) [DOSISH_FILENAMES]: 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) [DOSISH_FILENAMES]: 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.
* objdump.c (display_target_list, display_info_table): Call
bfd_close_all_done when done with each target.
1999-07-30 Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
* strings.c (O_BINARY, setmode, SET_BINARY): Define.
(main) [SET_BINARY]: Use SET_BINARY to switch stdin into binary
mode.
1999-07-27 Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
* objcopy.c: Include filenames.h.
(main) [DOSISH_FILENAMES]: 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.
*** binutils/ar.c1~ Fri May 1 18:49:30 1998
--- binutils/ar.c Sat Jul 31 12:28:48 1999
*************** Foundation, Inc., 59 Temple Place - Suit
*** 31,36 ****
--- 31,37 ----
#include "aout/ar.h"
#include "libbfd.h"
#include "arsup.h"
+ #include "filenames.h"
#include <sys/stat.h>
#ifdef HAVE_GOOD_UTIME_H
*************** map_over_members (arch, function, files,
*** 203,209 ****
bfd_stat_arch_elt (head, &buf);
}
if ((head->filename != NULL) &&
! (!strcmp (*files, head->filename)))
{
found = true;
function (head);
--- 204,210 ----
bfd_stat_arch_elt (head, &buf);
}
if ((head->filename != NULL) &&
! (FILENAME_CMP (*files, head->filename) == 0))
{
found = true;
function (head);
*************** normalize (file, abfd)
*** 251,256 ****
--- 252,266 ----
const char *filename;
filename = strrchr (file, '/');
+ #ifdef DOSISH_FILENAMES
+ /* We could have foo/bar\\baz, or foo\\bar, or d:bar. */
+ if (!filename || strchr (filename, '\\'))
+ {
+ filename = strrchr (filename ? filename : file, '\\');
+ if (!filename && *file && file[1] == ':')
+ filename = file + 1;
+ }
+ #endif
if (filename != (char *) NULL)
filename++;
else
*************** main (argc, argv)
*** 319,330 ****
char *temp;
temp = strrchr (program_name, '/');
if (temp == NULL)
temp = program_name;
else
++temp;
if (strlen (temp) >= 6
! && strcmp (temp + strlen (temp) - 6, "ranlib") == 0)
is_ranlib = 1;
else
is_ranlib = 0;
--- 329,352 ----
char *temp;
temp = strrchr (program_name, '/');
+ #ifdef DOSISH_FILENAMES
+ /* We could have foo/bar\\baz, or foo\\bar, or d:bar. */
+ if (!temp || strchr (temp, '\\'))
+ {
+ temp = strrchr (temp ? temp : program_name, '\\');
+ if (!temp && *program_name && program_name[1] == ':')
+ temp = program_name + 1;
+ }
+ /* Drop the .exe suffix, if any. */
+ if (FILENAME_CMP (temp + strlen (temp) - 4, ".exe") == 0)
+ temp[strlen (temp) - 4] = '\0';
+ #endif
if (temp == NULL)
temp = program_name;
else
++temp;
if (strlen (temp) >= 6
! && FILENAME_CMP (temp + strlen (temp) - 6, "ranlib") == 0)
is_ranlib = 1;
else
is_ranlib = 0;
*************** open_inarch (archive_filename, file)
*** 617,628 ****
if (stat (archive_filename, &sbuf) != 0)
{
! #ifndef __GO32__
/* KLUDGE ALERT! Temporary fix until I figger why
* stat() is wrong ... think it's buried in GO32's IDT
! * - Jax
! */
if (errno != ENOENT)
bfd_fatal (archive_filename);
#endif
--- 639,654 ----
if (stat (archive_filename, &sbuf) != 0)
{
! #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 */
if (errno != ENOENT)
bfd_fatal (archive_filename);
#endif
*************** do_quick_append (archive_filename, files
*** 859,865 ****
if (stat (archive_filename, &sbuf) != 0)
{
! #ifndef __GO32__
/* KLUDGE ALERT! Temporary fix until I figger why
* stat() is wrong ... think it's buried in GO32's IDT
--- 885,899 ----
if (stat (archive_filename, &sbuf) != 0)
{
! #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
*************** get_pos_bfd (contents, default_pos, defa
*** 1034,1040 ****
else
{
for (; *after_bfd; after_bfd = &(*after_bfd)->next)
! if (strcmp ((*after_bfd)->filename, realposname) == 0)
{
if (realpos == pos_after)
after_bfd = &(*after_bfd)->next;
--- 1068,1074 ----
else
{
for (; *after_bfd; after_bfd = &(*after_bfd)->next)
! if (FILENAME_CMP ((*after_bfd)->filename, realposname) == 0)
{
if (realpos == pos_after)
after_bfd = &(*after_bfd)->next;
*************** delete_members (arch, files_to_delete)
*** 1071,1077 ****
current_ptr_ptr = &(arch->next);
while (*current_ptr_ptr)
{
! if (strcmp (*files_to_delete, (*current_ptr_ptr)->filename) == 0)
{
found = true;
something_changed = true;
--- 1105,1112 ----
current_ptr_ptr = &(arch->next);
while (*current_ptr_ptr)
{
! if (FILENAME_CMP (*files_to_delete,
! (*current_ptr_ptr)->filename) == 0)
{
found = true;
something_changed = true;
*************** move_members (arch, files_to_move)
*** 1118,1125 ****
while (*current_ptr_ptr)
{
bfd *current_ptr = *current_ptr_ptr;
! if (strcmp (normalize (*files_to_move, arch),
! current_ptr->filename) == 0)
{
/* Move this file to the end of the list - first cut from
where it is. */
--- 1153,1160 ----
while (*current_ptr_ptr)
{
bfd *current_ptr = *current_ptr_ptr;
! 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. */
*************** replace_members (arch, files_to_move, qu
*** 1174,1181 ****
/* 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
&& current->arelt_data != NULL)
{
if (newer_only)
--- 1209,1216 ----
/* For compatibility with existing ar programs, we
permit the same file to be added multiple times. */
! if (FILENAME_CMP (normalize (*files_to_move, arch),
! normalize (current->filename, arch)) == 0
&& current->arelt_data != NULL)
{
if (newer_only)
*** binutils/bucomm.c1~ Fri May 1 18:49:30 1998
--- binutils/bucomm.c Sat Jul 31 12:43:12 1999
***************
*** 24,29 ****
--- 24,30 ----
#include "bfd.h"
#include "libiberty.h"
#include "bucomm.h"
+ #include "filenames.h"
#include <sys/stat.h>
#include <time.h> /* ctime, maybe time_t */
*************** make_tempname (filename)
*** 195,203 ****
char *tmpname;
char *slash = strrchr (filename, '/');
! #if defined (__DJGPP__) || defined (__GO32__) || defined (_WIN32)
! if (slash == NULL)
! slash = strrchr (filename, '\\');
#endif
if (slash != (char *) NULL)
--- 196,209 ----
char *tmpname;
char *slash = strrchr (filename, '/');
! #ifdef DOSISH_FILENAMES
! /* We could have foo/bar\\baz, or foo\\bar, or d:bar. */
! if (slash == (char *)NULL || strchr (slash, '\\') != (char *)NULL)
! {
! slash = strrchr (slash != (char *)NULL ? slash : filename, '\\');
! if (slash == (char *)NULL && *filename && filename[1] == ':')
! slash = filename + 2;
! }
#endif
if (slash != (char *) NULL)
*************** make_tempname (filename)
*** 206,213 ****
c = *slash;
*slash = 0;
! tmpname = xmalloc (strlen (filename) + sizeof (template) + 1);
strcpy (tmpname, filename);
strcat (tmpname, "/");
strcat (tmpname, template);
mktemp (tmpname);
--- 212,226 ----
c = *slash;
*slash = 0;
! tmpname = xmalloc (strlen (filename) + sizeof (template) + 2);
strcpy (tmpname, filename);
+ #ifdef DOSISH_FILENAMES
+ /* 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);
*** binutils/ieee.c1~ Fri May 1 18:49:32 1998
--- binutils/ieee.c Sat Jul 31 12:59:20 1999
***************
*** 30,35 ****
--- 30,36 ----
#include "libiberty.h"
#include "debug.h"
#include "budbg.h"
+ #include "filenames.h"
/* This structure holds an entry on the block stack. */
*************** ieee_start_compilation_unit (p, filename
*** 4931,4942 ****
info->filename = filename;
modname = strrchr (filename, '/');
if (modname != NULL)
! ++modname;
else
{
modname = strrchr (filename, '\\');
if (modname != NULL)
++modname;
else
modname = filename;
}
--- 4932,4954 ----
info->filename = filename;
modname = strrchr (filename, '/');
if (modname != NULL)
! {
! const char *backslash;
!
! ++modname;
! /* We could have a mixed forward-/back-slash case. */
! if ((backslash = strrchr (modname, '\\')) != NULL)
! modname = backslash + 1;
! }
else
{
modname = strrchr (filename, '\\');
if (modname != NULL)
++modname;
+ #ifdef DOSISH_FILENAMES
+ else if (filename[0] && filename[1] == ':')
+ modname = filename + 2;
+ #endif
else
modname = filename;
}
*************** ieee_add_bb11 (info, sec, low, high)
*** 5194,5205 ****
filename = bfd_get_filename (info->abfd);
modname = strrchr (filename, '/');
if (modname != NULL)
! ++modname;
else
{
modname = strrchr (filename, '\\');
if (modname != NULL)
++modname;
else
modname = filename;
}
--- 5206,5228 ----
filename = bfd_get_filename (info->abfd);
modname = strrchr (filename, '/');
if (modname != NULL)
! {
! const char *backslash;
!
! ++modname;
! /* We could have a mixed forward-/back-slash case. */
! if ((backslash = strrchr (modname, '\\')) != NULL)
! modname = backslash + 1;
! }
else
{
modname = strrchr (filename, '\\');
if (modname != NULL)
++modname;
+ #ifdef DOSISH_FILENAMES
+ else if (filename[0] && filename[1] == ':')
+ modname = filename + 2;
+ #endif
else
modname = filename;
}
*** binutils/objdump.c~0 Fri May 1 18:49:34 1998
--- binutils/objdump.c Sat Jul 31 16:58:20 1999
*************** display_target_list ()
*** 2491,2496 ****
--- 2491,2497 ----
{
if (bfd_get_error () != bfd_error_invalid_operation)
bfd_nonfatal (p->name);
+ bfd_close_all_done (abfd);
continue;
}
*************** display_target_list ()
*** 2498,2503 ****
--- 2499,2508 ----
if (bfd_set_arch_mach (abfd, (enum bfd_architecture) a, 0))
printf (" %s\n",
bfd_printable_arch_mach ((enum bfd_architecture) a, 0));
+ /* We are going to unlink the file below, so make sure it's not
+ left open, for those systems that don't like it when an open
+ file is unlinked. */
+ bfd_close_all_done (abfd);
}
unlink (dummy_name);
free (dummy_name);
*************** display_info_table (first, last)
*** 2565,2570 ****
--- 2570,2580 ----
putchar ('-');
putchar (' ');
}
+ /* We are going to unlink the file below, so make sure it's
+ not left open, for those systems that don't like it when
+ an open file is unlinked. */
+ if (abfd != NULL)
+ bfd_close_all_done (abfd);
}
putchar ('\n');
}
*** binutils/strings.c1~ Fri May 1 18:49:36 1998
--- binutils/strings.c Fri Jul 30 19:32:04 1999
***************
*** 58,63 ****
--- 58,78 ----
#include "bucomm.h"
#include "libiberty.h"
+ /* Some platforms need to put stdin into binary mode, to read
+ binary files. */
+ #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
+
#ifdef isascii
#define isgraphic(c) (isascii (c) && isprint (c))
#else
*************** main (argc, argv)
*** 213,218 ****
--- 228,236 ----
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;
}
*** binutils/objcopy.c1~ Fri May 1 18:49:34 1998
--- binutils/objcopy.c Tue Jul 27 19:15:42 1999
***************
*** 25,30 ****
--- 25,31 ----
#include "getopt.h"
#include "libiberty.h"
#include "budbg.h"
+ #include "filenames.h"
#include <sys/stat.h>
#ifdef HAVE_GOOD_UTIME_H
*************** main (argc, argv)
*** 2168,2174 ****
if (is_strip < 0)
{
int i = strlen (program_name);
! is_strip = (i >= 5 && strcmp (program_name + i - 5, "strip") == 0);
}
if (is_strip)
--- 2169,2183 ----
if (is_strip < 0)
{
int i = strlen (program_name);
! #ifdef DOSISH_FILENAMES
! /* Drop the .exe suffix, if any. */
! if (FILENAME_CMP (program_name + i - 4, ".exe") == 0)
! {
! program_name[i - 4] = '\0';
! i -= 4;
! }
! #endif
! is_strip = (i >= 5 && FILENAME_CMP (program_name + i - 5, "strip") == 0);
}
if (is_strip)
*** binutils/arsup.c1~ Fri May 1 18:49:30 1998
--- binutils/arsup.c Tue Jul 27 19:15:42 1999
*************** style librarian command syntax + 1 word
*** 30,35 ****
--- 30,36 ----
#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 *));
*************** map_over_list (arch, function, list)
*** 75,81 ****
for (head = arch->next; head; head = head->next)
{
if (head->filename != NULL
! && strcmp (ptr->name, head->filename) == 0)
{
found = true;
function (head, prev);
--- 76,82 ----
for (head = arch->next; head; head = head->next)
{
if (head->filename != NULL
! && FILENAME_CMP (ptr->name, head->filename) == 0)
{
found = true;
function (head, prev);
*************** DEFUN(ar_open,(name, t),
*** 159,165 ****
{
char *tname = (char *) xmalloc (strlen (name) + 10);
real_name = name;
! sprintf(tname, "%s-tmp", name);
obfd = bfd_openw(tname, NULL);
if (!obfd) {
--- 160,168 ----
{
char *tname = (char *) xmalloc (strlen (name) + 10);
real_name = 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) {
*************** DEFUN(ar_delete, (list),
*** 288,294 ****
bfd **prev = &(obfd->archive_head);
int found = 0;
while (member) {
! if (strcmp(member->filename, list->name) == 0) {
*prev = member->next;
found = 1;
}
--- 291,297 ----
bfd **prev = &(obfd->archive_head);
int found = 0;
while (member) {
! if (FILENAME_CMP(member->filename, list->name) == 0) {
*prev = member->next;
found = 1;
}
*************** DEFUN(ar_replace, (list),
*** 345,351 ****
int found = 0;
while (member)
{
! if (strcmp(member->filename, list->name) == 0)
{
/* Found the one to replace */
bfd *abfd = bfd_openr(list->name, 0);
--- 348,354 ----
int found = 0;
while (member)
{
! if (FILENAME_CMP(member->filename, list->name) == 0)
{
/* Found the one to replace */
bfd *abfd = bfd_openr(list->name, 0);
*************** DEFUN(ar_extract,(list),
*** 436,442 ****
int found = 0;
while (member && !found)
{
! if (strcmp(member->filename, list->name) == 0)
{
extract_file(member);
found = 1;
--- 439,445 ----
int found = 0;
while (member && !found)
{
! if (FILENAME_CMP(member->filename, list->name) == 0)
{
extract_file(member);
found = 1;
- Raw text -