* ar.c (full_pathname): New static variable.

(map_over_members): Call normalize on command line parameter.
	(usage): Mention P modifier.
	(normalize): If full_pathname is true, don't do anything.
	(main): Accept P modifier.
	* binutils.texi, ar.1: Document P modifier.
This commit is contained in:
Ian Lance Taylor 1999-09-12 17:34:19 +00:00
parent 71add73133
commit fe84ea5db2
4 changed files with 45 additions and 4 deletions

View File

@ -1,3 +1,12 @@
1999-09-12 Ian Lance Taylor <ian@zembu.com>
* ar.c (full_pathname): New static variable.
(map_over_members): Call normalize on command line parameter.
(usage): Mention P modifier.
(normalize): If full_pathname is true, don't do anything.
(main): Accept P modifier.
* binutils.texi, ar.1: Document P modifier.
1999-09-09 Andreas Schwab <schwab@suse.de> 1999-09-09 Andreas Schwab <schwab@suse.de>
* binutils.texi: Add info dir entries for all programs described * binutils.texi: Add info dir entries for all programs described

View File

@ -1,6 +1,6 @@
.\" Copyright (c) 1991 Free Software Foundation .\" Copyright (c) 1991, 1992, 1993, 1995, 1998, 1999 Free Software Foundation
.\" See section COPYING for conditions for redistribution .\" See section COPYING for conditions for redistribution
.TH ar 1 "5 November 1991" "cygnus support" "GNU Development Tools" .TH ar 1 "1999" "Cygnus Solutions" "GNU Development Tools"
.de BP .de BP
.sp .sp
.ti \-.2i .ti \-.2i
@ -384,6 +384,18 @@ program on some systems. If this is a concern, the
modifier may be used to truncate file names when putting them in the modifier may be used to truncate file names when putting them in the
archive. archive.
.TP
.B P
Use the full path name when matching names in the archive.
.B ar
can not create an archive with a full path name (such archives are not
POSIX complaint), but other archive creators can. This option will
cause
.B ar
to match file names using a complete path name, which can be
convenient when extracting a single file from an archive created by
another tool.
.TP .TP
.B i .B i
Insert new files \c Insert new files \c
@ -491,7 +503,7 @@ The GNU Binary Utilities\c
\&. \&.
.SH COPYING .SH COPYING
Copyright (c) 1991 Free Software Foundation, Inc. Copyright (c) 1991, 1992, 1993, 1995, 1998, 1999 Free Software Foundation, Inc.
.PP .PP
Permission is granted to make and distribute verbatim copies of Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice this manual provided the copyright notice and this permission notice

View File

@ -150,6 +150,11 @@ get_pos_bfd PARAMS ((bfd **, enum pos, const char *));
/* Whether to truncate names of files stored in the archive. */ /* Whether to truncate names of files stored in the archive. */
static boolean ar_truncate = false; static boolean ar_truncate = false;
/* Whether to use a full file name match when searching an archive.
This is convenient for archives created by the Microsoft lib
program. */
static boolean full_pathname = false;
int interactive = 0; int interactive = 0;
static void static void
@ -202,7 +207,7 @@ map_over_members (arch, function, files, count)
bfd_stat_arch_elt (head, &buf); bfd_stat_arch_elt (head, &buf);
} }
if ((head->filename != NULL) && if ((head->filename != NULL) &&
(!strcmp (*files, head->filename))) (!strcmp (normalize (*files, arch), head->filename)))
{ {
found = true; found = true;
function (head); function (head);
@ -242,6 +247,7 @@ usage (help)
fprintf (s, _(" [a] - put file(s) after [member-name]\n")); fprintf (s, _(" [a] - put file(s) after [member-name]\n"));
fprintf (s, _(" [b] - put file(s) before [member-name] (same as [i])\n")); fprintf (s, _(" [b] - put file(s) before [member-name] (same as [i])\n"));
fprintf (s, _(" [f] - truncate inserted file names\n")); fprintf (s, _(" [f] - truncate inserted file names\n"));
fprintf (s, _(" [P] - use full path names when matching\n"));
fprintf (s, _(" [o] - preserve original dates\n")); fprintf (s, _(" [o] - preserve original dates\n"));
fprintf (s, _(" [u] - only replace files that are newer than current archive contents\n")); fprintf (s, _(" [u] - only replace files that are newer than current archive contents\n"));
fprintf (s, _(" generic modifiers:\n")); fprintf (s, _(" generic modifiers:\n"));
@ -273,6 +279,9 @@ normalize (file, abfd)
{ {
const char *filename; const char *filename;
if (full_pathname)
return filename;
filename = strrchr (file, '/'); filename = strrchr (file, '/');
if (filename != (char *) NULL) if (filename != (char *) NULL)
filename++; filename++;
@ -501,6 +510,9 @@ main (argc, argv)
case 'f': case 'f':
ar_truncate = true; ar_truncate = true;
break; break;
case 'P':
full_pathname = true;
break;
default: default:
/* xgettext:c-format */ /* xgettext:c-format */
fprintf (stderr, _("%s: illegal option -- %c\n"), program_name, c); fprintf (stderr, _("%s: illegal option -- %c\n"), program_name, c);

View File

@ -387,6 +387,14 @@ not compatible with the native @code{ar} program on some systems. If
this is a concern, the @samp{f} modifier may be used to truncate file this is a concern, the @samp{f} modifier may be used to truncate file
names when putting them in the archive. names when putting them in the archive.
@item P
Use the full path name when matching names in the archive. @sc{gnu}
@code{ar} can not create an archive with a full path name (such archives
are not POSIX complaint), but other archive creators can. This option
will cause @sc{gnu} @code{ar} to match file names using a complete path
name, which can be convenient when extracting a single file from an
archive created by another tool.
@item i @item i
Insert new files @emph{before} an existing member of the Insert new files @emph{before} an existing member of the
archive. If you use the modifier @samp{i}, the name of an existing archive archive. If you use the modifier @samp{i}, the name of an existing archive