+ if (make_thin_archive || bfd_is_thin_archive (iarch))
+ bfd_is_thin_archive (obfd) = 1;
+
+ if (!bfd_set_archive_head (obfd, contents_head))
+ bfd_fatal (old_name);
+
+ if (!bfd_close (obfd))
+ bfd_fatal (old_name);
+
+ output_bfd = NULL;
+ output_filename = NULL;
+
+ /* We don't care if this fails; we might be creating the archive. */
+ bfd_close (iarch);
+
+ if (smart_rename (new_name, old_name, 0) != 0)
+ xexit (1);
+ free (old_name);
+ free (new_name);
+}
+
+/* Return a pointer to the pointer to the entry which should be rplacd'd
+ into when altering. DEFAULT_POS should be how to interpret pos_default,
+ and should be a pos value. */
+
+static bfd **
+get_pos_bfd (bfd **contents, enum pos default_pos, const char *default_posname)
+{
+ bfd **after_bfd = contents;
+ enum pos realpos;
+ const char *realposname;
+
+ if (postype == pos_default)
+ {
+ realpos = default_pos;
+ realposname = default_posname;
+ }
+ else
+ {
+ realpos = postype;
+ realposname = posname;
+ }
+
+ if (realpos == pos_end)
+ {
+ while (*after_bfd)
+ after_bfd = &((*after_bfd)->archive_next);
+ }
+ else
+ {
+ for (; *after_bfd; after_bfd = &(*after_bfd)->archive_next)
+ if (FILENAME_CMP ((*after_bfd)->filename, realposname) == 0)
+ {
+ if (realpos == pos_after)
+ after_bfd = &(*after_bfd)->archive_next;
+ break;
+ }
+ }
+ return after_bfd;
+}
+
+static void
+delete_members (bfd *arch, char **files_to_delete)
+{
+ bfd **current_ptr_ptr;
+ bfd_boolean found;
+ bfd_boolean something_changed = FALSE;
+ int match_count;
+
+ for (; *files_to_delete != NULL; ++files_to_delete)
+ {
+ /* In a.out systems, the armap is optional. It's also called
+ __.SYMDEF. So if the user asked to delete it, we should remember
+ that fact. This isn't quite right for COFF systems (where
+ __.SYMDEF might be regular member), but it's very unlikely
+ to be a problem. FIXME */
+
+ if (!strcmp (*files_to_delete, "__.SYMDEF"))
+ {
+ arch->has_armap = FALSE;
+ write_armap = -1;
+ continue;
+ }
+
+ found = FALSE;
+ match_count = 0;
+ current_ptr_ptr = &(arch->archive_next);
+ while (*current_ptr_ptr)
+ {
+ if (FILENAME_CMP (normalize (*files_to_delete, arch),
+ (*current_ptr_ptr)->filename) == 0)
+ {
+ ++match_count;
+ if (counted_name_mode
+ && match_count != counted_name_counter)
+ {
+ /* Counting, and didn't match on count; go on to the
+ next one. */
+ }
+ else
+ {
+ found = TRUE;
+ something_changed = TRUE;
+ if (verbose)
+ printf ("d - %s\n",
+ *files_to_delete);
+ *current_ptr_ptr = ((*current_ptr_ptr)->archive_next);
+ goto next_file;
+ }