break;
case move:
- if (files != NULL)
- move_members (arch, files);
- else
- output_filename = NULL;
- break;
+ /* PR 12558: Creating and moving at the same time does
+ not make sense. Just create the archive instead. */
+ if (! silent_create)
+ {
+ if (files != NULL)
+ move_members (arch, files);
+ else
+ output_filename = NULL;
+ break;
+ }
+ /* Fall through. */
case replace:
case quick_append:
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
bfd_boolean found;
bfd_boolean something_changed = FALSE;
int match_count;
- const char * tmp = NULL;
for (; *files_to_delete != NULL; ++files_to_delete)
{
current_ptr_ptr = &(arch->archive_next);
while (*current_ptr_ptr)
{
- if (tmp != NULL)
- free ((char *) tmp);
- tmp = normalize (*files_to_delete, arch);
- if (FILENAME_CMP (tmp, (*current_ptr_ptr)->filename) == 0)
+ if (FILENAME_CMP (normalize (*files_to_delete, arch),
+ (*current_ptr_ptr)->filename) == 0)
{
++match_count;
if (counted_name_mode
write_archive (arch);
else
output_filename = NULL;
-
- if (tmp != NULL)
- free ((char *) tmp);
}
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. */
- const char *tmp = NULL;
+ bfd **after_bfd; /* New entries go after this one */
+ bfd **current_ptr_ptr; /* cdr pointer into contents */
for (; *files_to_move; ++files_to_move)
{
while (*current_ptr_ptr)
{
bfd *current_ptr = *current_ptr_ptr;
-
- if (tmp != NULL)
- free ((char *) tmp);
- tmp = normalize (*files_to_move, arch);
- if (FILENAME_CMP (tmp, current_ptr->filename) == 0)
+ if (FILENAME_CMP (normalize (*files_to_move, arch),
+ current_ptr->filename) == 0)
{
/* Move this file to the end of the list - first cut from
where it is. */
/* 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! */