Tue Jul 4 14:48:42 1995 Ian Lance Taylor <ian@cygnus.com>
+ * ar.c (replace_members): In verbose messages, use 'r' when
+ replacing a member, and 'a' when adding one.
+
+ * ar.c (truncate): New static variable.
+ (normalize): Change return type to const char *. Add abfd
+ argument. Change all callers. If truncate, chop the filename to
+ abfd->ar_max_namelen.
+ (main): For the 'f' modifier, set truncate to true. Don't change
+ quick_append to replace to truncate is true.
+ (do_quick_append): If truncate, set BFD_TRADITIONAL_FORMAT.
+ (write_archive): Likewise.
+ * binutils.texi, ar.1: Document 'f' modifier.
+
* objcopy.c (enum strip_action): Define strip_unneeded.
(OPTION_STRIP_UNNEEDED): Define.
(strip_options): Add "strip-unneeded".
/* Forward declarations */
+static const char *
+normalize PARAMS ((const char *, bfd *));
+
static void
remove_output PARAMS ((void));
pos_default, pos_before, pos_after, pos_end
} postype = pos_default;
+/* Whether to truncate names of files stored in the archive. */
+static boolean truncate = false;
+
int interactive = 0;
void
/* Normalize a file name specified on the command line into a file
name which we will use in an archive. */
-static char *
-normalize (file)
- char *file;
+static const char *
+normalize (file, abfd)
+ const char *file;
+ bfd *abfd;
{
- char *filename = strrchr (file, '/');
+ const char *filename;
+
+ filename = strrchr (file, '/');
if (filename != (char *) NULL)
- {
- filename++;
- }
+ filename++;
else
+ filename = file;
+
+ if (truncate
+ && abfd != NULL
+ && strlen (filename) > abfd->xvec->ar_max_namelen)
{
- filename = file;
+ char *s;
+
+ /* Space leak. */
+ 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;
}
+
return filename;
}
mri_mode = 1;
break;
case 'f':
- /* On HP/UX 9, the f modifier means to truncate names to 14
- characters when comparing them to existing names. We
- always use an extended name table, so the truncation has
- no purpose for us. We ignore the modifier for
- compatibility with the AR_FLAGS definition in make. */
+ truncate = true;
break;
default:
fprintf (stderr, "%s: illegal option -- %c\n", program_name, c);
rebuild the name table. Unfortunately, at this point we
don't actually know the maximum name length permitted by this
object file format. So, we guess. FIXME. */
- if (operation == quick_append)
+ if (operation == quick_append && ! truncate)
{
char **chk;
for (chk = files; chk != NULL && *chk != '\0'; chk++)
{
- if (strlen (normalize (*chk)) > 14)
+ if (strlen (normalize (*chk, (bfd *) NULL)) > 14)
{
operation = replace;
break;
program_name, archive_filename);
}
+ if (truncate)
+ temp->flags |= BFD_TRADITIONAL_FORMAT;
+
/* assume it's an achive, go straight to the end, sans $200 */
fseek (ofile, 0, 2);
been explicitly requested not to. */
obfd->has_armap = write_armap >= 0;
+ if (truncate)
+ {
+ /* This should really use bfd_set_file_flags, but that rejects
+ archives. */
+ obfd->flags |= BFD_TRADITIONAL_FORMAT;
+ }
+
if (bfd_set_archive_head (obfd, contents_head) != true)
bfd_fatal (old_name);
while (*current_ptr_ptr)
{
bfd *current_ptr = *current_ptr_ptr;
- if (strcmp (normalize (*files_to_move), current_ptr->filename) == 0)
+ if (strcmp (normalize (*files_to_move, arch),
+ current_ptr->filename) == 0)
{
/* Move this file to the end of the list - first cut from
where it is. */
{
current = *current_ptr;
- if (!strcmp (normalize (*files_to_move),
- normalize (current->filename)))
+ if (!strcmp (normalize (*files_to_move, arch),
+ normalize (current->filename, arch)))
{
if (newer_only)
{
if (verbose)
{
- printf ("%c - %s\n", (postype == pos_after ? 'r' : 'a'),
- *files_to_move);
+ printf ("r - %s\n", *files_to_move);
}
goto next_file;
}
}
if (verbose)
{
- printf ("c - %s\n", *files_to_move);
+ printf ("a - %s\n", *files_to_move);
}
(*after_bfd)->next = temp;