54
55
/* Bit mask of subsets to remove. */
57
REMOVE_UNTRANSLATED = 1 << 0,
58
REMOVE_TRANSLATED = 1 << 1,
59
REMOVE_FUZZY = 1 << 2,
60
REMOVE_NONFUZZY = 1 << 3,
61
REMOVE_OBSOLETE = 1 << 4,
62
REMOVE_NONOBSOLETE = 1 << 5
58
REMOVE_UNTRANSLATED = 1 << 0,
59
REMOVE_TRANSLATED = 1 << 1,
60
REMOVE_FUZZY = 1 << 2,
61
REMOVE_NONFUZZY = 1 << 3,
62
REMOVE_OBSOLETE = 1 << 4,
63
REMOVE_NONOBSOLETE = 1 << 5
64
65
static int to_remove;
66
67
/* Bit mask of actions to perform on all messages. */
71
SET_OBSOLETE = 1 << 2,
72
RESET_OBSOLETE = 1 << 3,
72
SET_OBSOLETE = 1 << 2,
73
RESET_OBSOLETE = 1 << 3,
75
76
static int to_change;
81
82
{ "clear-fuzzy", no_argument, NULL, CHAR_MAX + 8 },
82
83
{ "clear-obsolete", no_argument, NULL, CHAR_MAX + 10 },
83
84
{ "clear-previous", no_argument, NULL, CHAR_MAX + 18 },
85
{ "color", optional_argument, NULL, CHAR_MAX + 19 },
84
86
{ "directory", required_argument, NULL, 'D' },
85
87
{ "escape", no_argument, NULL, 'E' },
86
88
{ "force-po", no_argument, &force_po, 1 },
107
109
{ "stringtable-input", no_argument, NULL, CHAR_MAX + 16 },
108
110
{ "stringtable-output", no_argument, NULL, CHAR_MAX + 17 },
109
111
{ "strict", no_argument, NULL, 'S' },
112
{ "style", required_argument, NULL, CHAR_MAX + 20 },
110
113
{ "translated", no_argument, NULL, CHAR_MAX + 1 },
111
114
{ "untranslated", no_argument, NULL, CHAR_MAX + 2 },
112
115
{ "version", no_argument, NULL, 'V' },
170
173
ignore_file = NULL;
172
175
while ((optchar = getopt_long (argc, argv, "D:eEFhino:pPsVw:", long_options,
176
case '\0': /* Long option. */
179
case '\0': /* Long option. */
180
dir_list_append (optarg);
183
dir_list_append (optarg);
184
message_print_style_escape (false);
187
message_print_style_escape (false);
188
message_print_style_escape (true);
191
message_print_style_escape (true);
192
sort_by_filepos = true;
195
sort_by_filepos = true;
200
message_print_style_indent ();
203
message_print_style_indent ();
208
output_file = optarg;
211
output_file = optarg;
212
output_syntax = &output_format_properties;
215
output_syntax = &output_format_properties;
216
input_syntax = &input_format_properties;
219
input_syntax = &input_format_properties;
220
sort_by_msgid = true;
223
sort_by_msgid = true;
224
message_print_style_uniforum ();
227
message_print_style_uniforum ();
235
value = strtol (optarg, &endp, 10);
237
message_page_width_set (value);
238
value = strtol (optarg, &endp, 10);
240
message_page_width_set (value);
241
244
case CHAR_MAX + 1: /* --translated */
242
to_remove |= REMOVE_UNTRANSLATED;
245
to_remove |= REMOVE_UNTRANSLATED;
245
248
case CHAR_MAX + 2: /* --untranslated */
246
to_remove |= REMOVE_TRANSLATED;
249
to_remove |= REMOVE_TRANSLATED;
249
252
case CHAR_MAX + 3: /* --no-fuzzy */
250
to_remove |= REMOVE_FUZZY;
253
to_remove |= REMOVE_FUZZY;
253
256
case CHAR_MAX + 4: /* --only-fuzzy */
254
to_remove |= REMOVE_NONFUZZY;
257
to_remove |= REMOVE_NONFUZZY;
257
260
case CHAR_MAX + 5: /* --no-obsolete */
258
to_remove |= REMOVE_OBSOLETE;
261
to_remove |= REMOVE_OBSOLETE;
261
264
case CHAR_MAX + 6: /* --only-obsolete */
262
to_remove |= REMOVE_NONOBSOLETE;
265
to_remove |= REMOVE_NONOBSOLETE;
265
268
case CHAR_MAX + 7: /* --set-fuzzy */
266
to_change |= SET_FUZZY;
269
to_change |= SET_FUZZY;
269
272
case CHAR_MAX + 8: /* --clear-fuzzy */
270
to_change |= RESET_FUZZY;
273
to_change |= RESET_FUZZY;
273
276
case CHAR_MAX + 9: /* --set-obsolete */
274
to_change |= SET_OBSOLETE;
277
to_change |= SET_OBSOLETE;
277
280
case CHAR_MAX + 10: /* --clear-obsolete */
278
to_change |= RESET_OBSOLETE;
281
to_change |= RESET_OBSOLETE;
281
284
case CHAR_MAX + 11: /* --fuzzy */
282
to_remove |= REMOVE_NONFUZZY;
283
to_change |= RESET_FUZZY;
285
to_remove |= REMOVE_NONFUZZY;
286
to_change |= RESET_FUZZY;
286
289
case CHAR_MAX + 12: /* --obsolete */
287
to_remove |= REMOVE_NONOBSOLETE;
288
to_change |= RESET_OBSOLETE;
290
to_remove |= REMOVE_NONOBSOLETE;
291
to_change |= RESET_OBSOLETE;
291
294
case CHAR_MAX + 13: /* --no-wrap */
292
message_page_width_ignore ();
295
message_page_width_ignore ();
295
298
case CHAR_MAX + 14: /* --only-file */
299
302
case CHAR_MAX + 15: /* --ignore-file */
300
ignore_file = optarg;
303
ignore_file = optarg;
303
306
case CHAR_MAX + 16: /* --stringtable-input */
304
input_syntax = &input_format_stringtable;
307
input_syntax = &input_format_stringtable;
307
310
case CHAR_MAX + 17: /* --stringtable-output */
308
output_syntax = &output_format_stringtable;
311
output_syntax = &output_format_stringtable;
311
314
case CHAR_MAX + 18: /* --clear-previous */
312
to_change |= REMOVE_PREV;
315
to_change |= REMOVE_PREV;
318
case CHAR_MAX + 19: /* --color */
319
if (handle_color_option (optarg) || color_test_mode)
320
usage (EXIT_FAILURE);
323
case CHAR_MAX + 20: /* --style */
324
handle_style_option (optarg);
316
usage (EXIT_FAILURE);
328
usage (EXIT_FAILURE);
320
332
/* Version information requested. */
350
362
/* Verify selected options. */
351
363
if (!line_comment && sort_by_filepos)
352
364
error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"),
353
"--no-location", "--sort-by-file");
365
"--no-location", "--sort-by-file");
355
367
if (sort_by_msgid && sort_by_filepos)
356
368
error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"),
357
"--sort-output", "--sort-by-file");
369
"--sort-output", "--sort-by-file");
359
371
/* Read input file. */
360
372
result = read_catalog_file (input_file, input_syntax);
362
374
/* Read optional files that limit the extent of the attribute changes. */
363
375
only_mdlp = (only_file != NULL
364
? read_catalog_file (only_file, input_syntax)
376
? read_catalog_file (only_file, input_syntax)
366
378
ignore_mdlp = (ignore_file != NULL
367
? read_catalog_file (ignore_file, input_syntax)
379
? read_catalog_file (ignore_file, input_syntax)
370
382
/* Filter the messages and manipulate the attributes. */
371
383
result = process_msgdomain_list (result, only_mdlp, ignore_mdlp);
524
542
if ((to_remove & (REMOVE_UNTRANSLATED | REMOVE_TRANSLATED))
525
543
&& (mp->msgstr[0] == '\0'
526
? to_remove & REMOVE_UNTRANSLATED
527
: to_remove & REMOVE_TRANSLATED))
544
? to_remove & REMOVE_UNTRANSLATED
545
: to_remove & REMOVE_TRANSLATED))
530
548
if ((to_remove & (REMOVE_FUZZY | REMOVE_NONFUZZY))
532
? to_remove & REMOVE_FUZZY
533
: to_remove & REMOVE_NONFUZZY))
550
? to_remove & REMOVE_FUZZY
551
: to_remove & REMOVE_NONFUZZY))
536
554
if ((to_remove & (REMOVE_OBSOLETE | REMOVE_NONOBSOLETE))
538
? to_remove & REMOVE_OBSOLETE
539
: to_remove & REMOVE_NONOBSOLETE))
556
? to_remove & REMOVE_OBSOLETE
557
: to_remove & REMOVE_NONOBSOLETE))
558
576
for (j = 0; j < mlp->nitems; j++)
560
message_ty *mp = mlp->item[j];
578
message_ty *mp = mlp->item[j];
562
/* Attribute changes only affect messages listed in --only-file
563
and not listed in --ignore-file. */
565
? message_list_search (only_mlp, mp->msgctxt, mp->msgid) != NULL
568
? message_list_search (ignore_mlp, mp->msgctxt, mp->msgid) == NULL
571
if (to_change & SET_FUZZY)
573
if (to_change & RESET_FUZZY)
574
mp->is_fuzzy = false;
575
/* Always keep the header entry non-obsolete. */
576
if ((to_change & SET_OBSOLETE) && !is_header (mp))
578
if (to_change & RESET_OBSOLETE)
579
mp->obsolete = false;
580
if (to_change & REMOVE_PREV)
582
mp->prev_msgctxt = NULL;
583
mp->prev_msgid = NULL;
584
mp->prev_msgid_plural = NULL;
580
/* Attribute changes only affect messages listed in --only-file
581
and not listed in --ignore-file. */
583
? message_list_search (only_mlp, mp->msgctxt, mp->msgid) != NULL
586
? message_list_search (ignore_mlp, mp->msgctxt, mp->msgid) == NULL
589
if (to_change & SET_FUZZY)
591
if (to_change & RESET_FUZZY)
592
mp->is_fuzzy = false;
593
/* Always keep the header entry non-obsolete. */
594
if ((to_change & SET_OBSOLETE) && !is_header (mp))
596
if (to_change & RESET_OBSOLETE)
597
mp->obsolete = false;
598
if (to_change & REMOVE_PREV)
600
mp->prev_msgctxt = NULL;
601
mp->prev_msgid = NULL;
602
mp->prev_msgid_plural = NULL;
592
610
static msgdomain_list_ty *
593
611
process_msgdomain_list (msgdomain_list_ty *mdlp,
594
msgdomain_list_ty *only_mdlp,
595
msgdomain_list_ty *ignore_mdlp)
612
msgdomain_list_ty *only_mdlp,
613
msgdomain_list_ty *ignore_mdlp)
599
617
for (k = 0; k < mdlp->nitems; k++)
600
618
process_message_list (mdlp->item[k]->messages,
602
? msgdomain_list_sublist (only_mdlp,
603
mdlp->item[k]->domain,
607
? msgdomain_list_sublist (ignore_mdlp,
608
mdlp->item[k]->domain,
620
? msgdomain_list_sublist (only_mdlp,
621
mdlp->item[k]->domain,
625
? msgdomain_list_sublist (ignore_mdlp,
626
mdlp->item[k]->domain,