X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2Fnames.c;h=a3c6f58a899d387278c4ee648b8cd6d6cb2e41fd;hb=40dea1ae7fc892a54eae2efd30ddd8559c697525;hp=1146020b2458f5a07fa5c534ea1511e596f3b703;hpb=b7899bb121c496f95f3d6f071bc38e493f15370b;p=chaz%2Ftar diff --git a/src/names.c b/src/names.c index 1146020..a3c6f58 100644 --- a/src/names.c +++ b/src/names.c @@ -589,7 +589,7 @@ all_names_found (struct tar_stat_info *p) return true; } -static void +static int regex_usage_warning (const char *name) { static int warned_once = 0; @@ -603,6 +603,7 @@ regex_usage_warning (const char *name) _("Use --wildcards to enable pattern matching," " or --no-wildcards to suppress this warning"))); } + return warned_once; } /* Print the names of things in the namelist that were not matched. */ @@ -615,12 +616,11 @@ names_notfound (void) if (!WASFOUND (cursor) && cursor->name[0]) { regex_usage_warning (cursor->name); - if (cursor->found_count == 0) - ERROR ((0, 0, _("%s: Not found in archive"), - quotearg_colon (cursor->name))); - else - ERROR ((0, 0, _("%s: Required occurrence not found in archive"), - quotearg_colon (cursor->name))); + ERROR ((0, 0, + (cursor->found_count == 0) ? + _("%s: Not found in archive") : + _("%s: Required occurrence not found in archive"), + quotearg_colon (cursor->name))); } /* Don't bother freeing the name list; we're about to exit. */ @@ -639,6 +639,42 @@ names_notfound (void) } } } + +void +label_notfound (void) +{ + struct name const *cursor; + + if (!namelist) + return; + + for (cursor = namelist; cursor; cursor = cursor->next) + if (WASFOUND (cursor)) + return; + + if (verbose_option) + error (0, 0, _("Archive label mismatch")); + set_exit_status (TAREXIT_DIFFERS); + + for (cursor = namelist; cursor; cursor = cursor->next) + { + if (regex_usage_warning (cursor->name)) + break; + } + + /* Don't bother freeing the name list; we're about to exit. */ + namelist = NULL; + nametail = NULL; + + if (same_order_option) + { + const char *name; + + while ((name = name_next (1)) != NULL + && regex_usage_warning (name) == 0) + ; + } +} /* Sorting name lists. */ @@ -871,7 +907,7 @@ void collect_and_sort_names (void) { struct name *name; - struct name *next_name, *prev_name; + struct name *next_name, *prev_name = NULL; int num_names; struct stat statbuf; Hash_table *nametab; @@ -950,6 +986,7 @@ collect_and_sort_names (void) { if (p->child) rebase_child_list (p->child, name); + hash_delete (nametab, name); /* FIXME: remove_directory (p->caname); ? */ remname (p); free_name (p);