* objcopy.c (setup_section): Copy entsize.
[binutils-gdb.git] / binutils / arsup.c
index 38fd6953c899df7380f1ebfaa30a94aa735eec54..1e864793955ff9ce5dda92765a09f6bedebaf6e2 100644 (file)
@@ -1,5 +1,6 @@
 /* arsup.c - Archive support for MRI compatibility
-   Copyright (C) 1992, 93, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc.
+   Copyright 1992, 1994, 1995, 1996, 1997, 2000
+   Free Software Foundation, Inc.
 
 This file is part of GNU Binutils.
 
@@ -30,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 *));
@@ -75,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);
@@ -95,7 +97,7 @@ FILE *outfile;
 static void
 ar_directory_doer (abfd, ignore)
      bfd *abfd;
-     bfd *ignore;
+     bfd *ignore ATTRIBUTE_UNUSED;
 {
     print_arelt_descr(outfile, abfd, verbose);
 }
@@ -158,8 +160,11 @@ DEFUN(ar_open,(name, t),
 
 {
   char *tname = (char *) xmalloc (strlen (name) + 10);
+  const char *bname = lbasename (name);
   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, "%.*stmp-%s", (int) (bname - name), name, bname);
   obfd = bfd_openw(tname, NULL);
 
   if (!obfd) {
@@ -288,7 +293,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;
        }
@@ -345,7 +350,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);
@@ -436,7 +441,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;