struct name const *cursor;
size_t len;
- if (test_label_option)
- return true;
if (!p->file_name || occurrence_option == 0 || p->had_trailing_slash)
return false;
len = strlen (p->file_name);
return true;
}
-static void
+static int
regex_usage_warning (const char *name)
{
static int warned_once = 0;
{
warned_once = 1;
WARN ((0, 0,
- /* TRANSLATORS: The following three msgids form a single sentence.
- */
- _("Pattern matching characters used in file names. Please,")));
+ _("Pattern matching characters used in file names")));
WARN ((0, 0,
- _("use --wildcards to enable pattern matching, or --no-wildcards to")));
- WARN ((0, 0,
- _("suppress this warning.")));
+ _("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. */
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. */
}
}
}
+
+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)
+ ;
+ }
+}
\f
/* Sorting name lists. */
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;