+2005-11-29 Colin Watson <cjwatson@ubuntu.com>
+
+ * msggrep.c (invert_match): New variable.
+ (long_options): Add --invert-match option.
+ (main): Handle --invert-match option.
+ (usage): Document --invert-match option.
+ (is_message_selected_no_invert): New function, extracted from
+ is_message_selected.
+ (is_message_selected): Call it. Handle match inversion.
+
2005-11-01 Bruno Haible <bruno@clisp.org>
* write-csharp.c (write_csharp_code): Add culture_name argument.
/* Force output of PO file even if empty. */
static int force_po;
+/* Output only non-matching messages. */
+static bool invert_match = false;
+
/* Selected source files. */
static string_list_ty *location_files;
{ "help", no_argument, NULL, 'h' },
{ "ignore-case", no_argument, NULL, 'i' },
{ "indent", no_argument, NULL, CHAR_MAX + 2 },
+ { "invert-match", no_argument, NULL, 'v' },
{ "location", required_argument, NULL, 'N' },
{ "msgctxt", no_argument, NULL, 'J' },
{ "msgid", no_argument, NULL, 'K' },
gt->case_insensitive = false;
}
- while ((opt = getopt_long (argc, argv, "CD:e:Ef:FhiJKM:N:o:pPTVw:",
+ while ((opt = getopt_long (argc, argv, "CD:e:Ef:FhiJKM:N:o:pPTvVw:",
long_options, NULL))
!= EOF)
switch (opt)
grep_pass = 2;
break;
+ case 'v':
+ invert_match = true;
+ break;
+
case 'V':
do_version = true;
break;
-e, --regexp=PATTERN use PATTERN as a regular expression\n\
-f, --file=FILE obtain PATTERN from FILE\n\
-i, --ignore-case ignore case distinctions\n\
+ -v, --invert-match output only the messages that do not match any\n\
+ selection criterion\n\
"));
printf ("\n");
printf (_("\
}
-/* Return true if a message matches. */
+/* Return true if a message matches, considering only the positive selection
+ criteria and ignoring --invert-match. */
static bool
-is_message_selected (const message_ty *mp)
+is_message_selected_no_invert (const message_ty *mp)
{
size_t i;
const char *msgstr;
size_t msgstr_len;
const char *p;
- /* Always keep the header entry. */
- if (is_header (mp))
- return true;
-
/* Test whether one of mp->filepos[] is selected. */
for (i = 0; i < mp->filepos_count; i++)
if (filename_list_match (location_files, mp->filepos[i].file_name))
}
+/* Return true if a message matches. */
+static bool
+is_message_selected (const message_ty *mp)
+{
+ bool result;
+
+ /* Always keep the header entry. */
+ if (is_header (mp))
+ return true;
+
+ result = is_message_selected_no_invert (mp);
+
+ if (invert_match)
+ return !result;
+ else
+ return result;
+}
+
+
static void
process_message_list (const char *domain, message_list_ty *mlp)
{