* top.c (stop_sig, float_handler, do_nothing): Remove.
[deliverable/binutils-gdb.git] / binutils / ar.c
index 4d6a32516a728fa6c2af3e732fecfd454cbbc985..fd1b9ecd176c0f38e834821a387e9fd9bc29964b 100644 (file)
@@ -1,6 +1,6 @@
 /* ar.c - Archive modify and extract.
    Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
 
    This file is part of GNU Binutils.
 #define EXT_NAME_LEN 6         /* Ditto for *NIX.  */
 #endif
 
-/* Kludge declaration from BFD!  This is ugly!  FIXME!  XXX  */
-
-struct ar_hdr *
-  bfd_special_undocumented_glue (bfd * abfd, const char *filename);
-
 /* Static declarations.  */
 
 static void mri_emul (void);
@@ -308,22 +303,7 @@ normalize (const char *file, bfd *abfd)
   if (full_pathname)
     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 (filename == NULL || (bslash != NULL && bslash > filename))
-      filename = bslash;
-    if (filename == NULL && file[0] != '\0' && file[1] == ':')
-      filename = file + 1;
-  }
-#endif
-  if (filename != (char *) NULL)
-    filename++;
-  else
-    filename = file;
+  filename = lbasename (file);
 
   if (ar_truncate
       && abfd != NULL
@@ -332,7 +312,7 @@ normalize (const char *file, bfd *abfd)
       char *s;
 
       /* Space leak.  */
-      s = xmalloc (abfd->xvec->ar_max_namelen + 1);
+      s = (char *) xmalloc (abfd->xvec->ar_max_namelen + 1);
       memcpy (s, filename, abfd->xvec->ar_max_namelen);
       s[abfd->xvec->ar_max_namelen] = '\0';
       filename = s;
@@ -372,7 +352,7 @@ main (int argc, char **argv)
   char c;
   enum
     {
-      none = 0, delete, replace, print_table,
+      none = 0, del, replace, print_table,
       print_files, extract, move, quick_append
     } operation = none;
   int arg_index;
@@ -402,24 +382,8 @@ main (int argc, char **argv)
 
   if (is_ranlib < 0)
     {
-      char *temp;
+      const char *temp = lbasename (program_name);
 
-      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 (temp == NULL || (bslash != NULL && 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
          && FILENAME_CMP (temp + strlen (temp) - 6, "ranlib") == 0)
        is_ranlib = 1;
@@ -540,7 +504,7 @@ main (int argc, char **argv)
              switch (c)
                {
                case 'd':
-                 operation = delete;
+                 operation = del;
                  operation_alters_arch = TRUE;
                  break;
                case 'm':
@@ -673,7 +637,7 @@ main (int argc, char **argv)
 
       if (counted_name_mode)
        {
-         if (operation != extract && operation != delete)
+         if (operation != extract && operation != del)
             fatal (_("`N' is only meaningful with the `x' and `d' options."));
          counted_name_counter = atoi (argv[arg_index++]);
          if (counted_name_counter <= 0)
@@ -705,7 +669,7 @@ main (int argc, char **argv)
          map_over_members (arch, extract_file, files, file_count);
          break;
 
-       case delete:
+       case del:
          if (files != NULL)
            delete_members (arch, files);
          else
@@ -843,7 +807,7 @@ static void
 print_contents (bfd *abfd)
 {
   size_t ncopied = 0;
-  char *cbuf = xmalloc (BUFSIZE);
+  char *cbuf = (char *) xmalloc (BUFSIZE);
   struct stat buf;
   size_t size;
   if (bfd_stat_arch_elt (abfd, &buf) != 0)
@@ -895,7 +859,7 @@ void
 extract_file (bfd *abfd)
 {
   FILE *ostream;
-  char *cbuf = xmalloc (BUFSIZE);
+  char *cbuf = (char *) xmalloc (BUFSIZE);
   size_t nread, tocopy;
   size_t ncopied = 0;
   size_t size;
@@ -989,7 +953,7 @@ write_archive (bfd *iarch)
   char *old_name, *new_name;
   bfd *contents_head = iarch->archive_next;
 
-  old_name = xmalloc (strlen (bfd_get_filename (iarch)) + 1);
+  old_name = (char *) xmalloc (strlen (bfd_get_filename (iarch)) + 1);
   strcpy (old_name, bfd_get_filename (iarch));
   new_name = make_tempname (old_name);
 
@@ -1168,14 +1132,14 @@ move_members (bfd *arch, char **files_to_move)
            {
              /* Move this file to the end of the list - first cut from
                 where it is.  */
-             bfd *link;
+             bfd *link_bfd;
              *current_ptr_ptr = current_ptr->archive_next;
 
              /* Now glue to end */
              after_bfd = get_pos_bfd (&arch->archive_next, pos_end, NULL);
-             link = *after_bfd;
+             link_bfd = *after_bfd;
              *after_bfd = current_ptr;
-             current_ptr->archive_next = link;
+             current_ptr->archive_next = link_bfd;
 
              if (verbose)
                printf ("m - %s\n", *files_to_move);
This page took 0.025316 seconds and 4 git commands to generate.