daily update
[deliverable/binutils-gdb.git] / binutils / ar.c
index d8f6678db3a83e4b8d116cd8f61ce41b0da2ee46..206c7a9781d7cb66a66575710fda6c23207a484b 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, 2010
+   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
 
    This file is part of GNU Binutils.
@@ -290,6 +290,7 @@ usage (int help)
   fprintf (s, _("  [v]          - be verbose\n"));
   fprintf (s, _("  [V]          - display the version number\n"));
   fprintf (s, _("  @<file>      - read options from <file>\n"));
+  fprintf (s, _("  --target=BFDNAME - specify the target object format as BFDNAME\n"));
 #if BFD_SUPPORTS_PLUGINS
   fprintf (s, _(" optional:\n"));
   fprintf (s, _("  --plugin <p> - load the specified plugin\n"));
@@ -585,7 +586,7 @@ ranlib_main (int argc, char **argv)
   if (show_version)
     print_version ("ranlib");
 
-  arg_index = 1;
+  arg_index = optind;
 
   while (arg_index < argc)
     {
@@ -1068,6 +1069,7 @@ write_archive (bfd *iarch)
 
   if (smart_rename (new_name, old_name, 0) != 0)
     xexit (1);
+  free (old_name);
 }
 
 /* Return a pointer to the pointer to the entry which should be rplacd'd
@@ -1117,6 +1119,7 @@ delete_members (bfd *arch, char **files_to_delete)
   bfd_boolean found;
   bfd_boolean something_changed = FALSE;
   int match_count;
+  const char * tmp = NULL;
 
   for (; *files_to_delete != NULL; ++files_to_delete)
     {
@@ -1138,8 +1141,10 @@ delete_members (bfd *arch, char **files_to_delete)
       current_ptr_ptr = &(arch->archive_next);
       while (*current_ptr_ptr)
        {
-         if (FILENAME_CMP (normalize (*files_to_delete, arch),
-                           (*current_ptr_ptr)->filename) == 0)
+         if (tmp != NULL)
+           free ((char *) tmp);
+         tmp = normalize (*files_to_delete, arch);
+         if (FILENAME_CMP (tmp, (*current_ptr_ptr)->filename) == 0)
            {
              ++match_count;
              if (counted_name_mode
@@ -1176,6 +1181,9 @@ delete_members (bfd *arch, char **files_to_delete)
     write_archive (arch);
   else
     output_filename = NULL;
+
+  if (tmp != NULL)
+    free ((char *) tmp);
 }
 
 
@@ -1184,8 +1192,9 @@ delete_members (bfd *arch, char **files_to_delete)
 static void
 move_members (bfd *arch, char **files_to_move)
 {
-  bfd **after_bfd;             /* New entries go after this one */
-  bfd **current_ptr_ptr;       /* cdr pointer into contents */
+  bfd **after_bfd;             /* New entries go after this one.  */
+  bfd **current_ptr_ptr;       /* cdr pointer into contents.  */
+  const char *tmp = NULL;
 
   for (; *files_to_move; ++files_to_move)
     {
@@ -1193,8 +1202,11 @@ move_members (bfd *arch, char **files_to_move)
       while (*current_ptr_ptr)
        {
          bfd *current_ptr = *current_ptr_ptr;
-         if (FILENAME_CMP (normalize (*files_to_move, arch),
-                           current_ptr->filename) == 0)
+
+         if (tmp != NULL)
+           free ((char *) tmp);
+         tmp = normalize (*files_to_move, arch);
+         if (FILENAME_CMP (tmp, current_ptr->filename) == 0)
            {
              /* Move this file to the end of the list - first cut from
                 where it is.  */
@@ -1218,10 +1230,13 @@ move_members (bfd *arch, char **files_to_move)
       /* xgettext:c-format */
       fatal (_("no entry %s in archive %s!"), *files_to_move, arch->filename);
 
-    next_file:;
+    next_file:
+      ;
     }
 
   write_archive (arch);
+  if (tmp != NULL)
+    free ((char *) tmp);
 }
 
 /* Ought to default to replacing in place, but this is existing practice!  */
This page took 0.024214 seconds and 4 git commands to generate.