aboutsummaryrefslogtreecommitdiff
path: root/binutils/ar.c
diff options
context:
space:
mode:
Diffstat (limited to 'binutils/ar.c')
-rw-r--r--binutils/ar.c90
1 files changed, 32 insertions, 58 deletions
diff --git a/binutils/ar.c b/binutils/ar.c
index 92d9b35..8876330 100644
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -3,29 +3,29 @@
2001, 2002
Free Software Foundation, Inc.
-This file is part of GNU Binutils.
+ This file is part of GNU Binutils.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*
Bugs: should use getopt the way tar does (complete w/optional -) and
should have long options too. GNU ar used to check file against filesystem
in quick_update and replace operations (would check mtime). Doesn't warn
when name truncated. No way to specify pos_end. Error messages should be
- more consistant.
-*/
+ more consistant. */
+
#include "bfd.h"
#include "libiberty.h"
#include "progress.h"
@@ -34,6 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "libbfd.h"
#include "arsup.h"
#include "filenames.h"
+#include "binemul.h"
#include <sys/stat.h>
#ifdef __GO32___
@@ -251,7 +252,7 @@ usage (help)
if (! is_ranlib)
{
/* xgettext:c-format */
- fprintf (s, _("Usage: %s [-X32_64] [-]{dmpqrstx}[abcfilNoPsSuvV] [member-name] [count] archive-file file...\n"),
+ fprintf (s, _("Usage: %s [emulation options] [-]{dmpqrstx}[abcfilNoPsSuvV] [member-name] [count] archive-file file...\n"),
program_name);
/* xgettext:c-format */
fprintf (s, _(" %s -M [<mri-script]\n"), program_name);
@@ -277,7 +278,8 @@ usage (help)
fprintf (s, _(" [S] - do not build a symbol table\n"));
fprintf (s, _(" [v] - be verbose\n"));
fprintf (s, _(" [V] - display the version number\n"));
- fprintf (s, _(" [-X32_64] - (ignored)\n"));
+
+ ar_emul_usage (s);
}
else
{
@@ -383,6 +385,7 @@ main (argc, argv)
int file_count;
char *inarch_filename;
int show_version;
+ int i;
#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
setlocale (LC_MESSAGES, "");
@@ -444,17 +447,12 @@ main (argc, argv)
xatexit (remove_output);
- /* Ignored for (partial) AIX compatibility. On AIX,
- the -X option can be used to ignore certain kinds
- of object files in the archive (the 64-bit objects
- or the 32-bit objects). GNU ar always looks at all
- kinds of objects in an archive. */
- while (argc > 1 && strcmp (argv[1], "-X32_64") == 0)
- {
- argv++;
- argc--;
- }
-
+ for (i = 1; i < argc; i++)
+ if (! ar_emul_parse_arg (argv[i]))
+ break;
+ argv += (i - 1);
+ argc -= (i - 1);
+
if (is_ranlib)
{
boolean touch = false;
@@ -1341,24 +1339,13 @@ replace_members (arch, files_to_move, quick)
after_bfd = get_pos_bfd (&arch->next, pos_after,
current->filename);
- temp = *after_bfd;
-
- *after_bfd = bfd_openr (*files_to_move, NULL);
- if (*after_bfd == (bfd *) NULL)
+ if (ar_emul_replace (after_bfd, *files_to_move,
+ verbose))
{
- bfd_fatal (*files_to_move);
+ /* Snip out this entry from the chain. */
+ *current_ptr = (*current_ptr)->next;
+ changed = true;
}
- (*after_bfd)->next = temp;
-
- /* snip out this entry from the chain */
- *current_ptr = (*current_ptr)->next;
-
- if (verbose)
- {
- printf ("r - %s\n", *files_to_move);
- }
-
- changed = true;
goto next_file;
}
@@ -1367,22 +1354,9 @@ replace_members (arch, files_to_move, quick)
}
/* Add to the end of the archive. */
-
after_bfd = get_pos_bfd (&arch->next, pos_end, NULL);
- temp = *after_bfd;
- *after_bfd = bfd_openr (*files_to_move, NULL);
- if (*after_bfd == (bfd *) NULL)
- {
- bfd_fatal (*files_to_move);
- }
- if (verbose)
- {
- printf ("a - %s\n", *files_to_move);
- }
-
- (*after_bfd)->next = temp;
-
- changed = true;
+ if (ar_emul_append (after_bfd, *files_to_move, verbose))
+ changed = true;
next_file:;