#include <errno.h>
#include <getopt.h>
+#include <limits.h>
#include <stdio.h>
#include <sys/param.h>
#include <sys/types.h>
static struct msg_domain *domain_list;
static struct msg_domain *current_domain;
-/* If not zero list duplicate message identifiers. */
-static int verbose_level;
+/* Be more verbose. Use only 'fprintf' and 'multiline_warning' but not
+ 'error' or 'multiline_error' to emit verbosity messages, because 'error'
+ and 'multiline_error' during PO file parsing cause the program to exit
+ with EXIT_FAILURE. See function lex_end(). */
+static bool verbose = false;
/* If true check strings according to format string rules for the
language. */
-static bool do_check = false;
+static bool check_format_strings = false;
+
+/* If true check the header entry is present and complete. */
+static bool check_header = false;
+
+/* Check that domain directives can be satisfied. */
+static bool check_domain = false;
+
+/* Check that msgfmt's behaviour is semantically compatible with
+ X/Open msgfmt or XView msgfmt. */
+static bool check_compatibility = false;
/* Counters for statistics on translations for the processed files. */
static int msgs_translated;
{
{ "alignment", required_argument, NULL, 'a' },
{ "check", no_argument, NULL, 'c' },
+ { "check-compatibility", no_argument, NULL, 'C' },
+ { "check-domain", no_argument, NULL, CHAR_MAX + 1 },
+ { "check-format", no_argument, NULL, CHAR_MAX + 2 },
+ { "check-header", no_argument, NULL, CHAR_MAX + 3 },
{ "directory", required_argument, NULL, 'D' },
{ "help", no_argument, NULL, 'h' },
{ "no-hash", no_argument, &no_hash_table, 1 },
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
- while ((opt = getopt_long (argc, argv, "a:cD:fho:vV", long_options, NULL))
+ while ((opt = getopt_long (argc, argv, "a:cCD:fho:vV", long_options, NULL))
!= EOF)
switch (opt)
{
}
break;
case 'c':
- do_check = true;
+ check_domain = true;
+ check_format_strings = true;
+ check_header = true;
+ break;
+ case 'C':
+ check_compatibility = true;
break;
case 'D':
dir_list_append (optarg);
strict_uniforum = true;
break;
case 'v':
- ++verbose_level;
+ verbose = true;
break;
case 'V':
do_version = true;
break;
+ case CHAR_MAX + 1:
+ check_domain = true;
+ break;
+ case CHAR_MAX + 2:
+ check_format_strings = true;
+ break;
+ case CHAR_MAX + 3:
+ check_header = true;
+ break;
default:
usage (EXIT_FAILURE);
break;
}
/* Print statistics if requested. */
- if (verbose_level > 0 || do_statistics)
+ if (verbose || do_statistics)
{
fprintf (stderr,
ngettext ("%d translated message", "%d translated messages",
/* xgettext: no-wrap */
printf (_("\
Input file interpretation:\n\
- -c, --check perform language dependent checks on strings\n\
+ -c, --check perform all the checks implied by\n\
+ --check-format, --check-header, --check-domain\n\
+ --check-format check language dependent format strings\n\
+ --check-header verify presence and contents of the header entry\n\
+ --check-domain check for conflicts between domain directives\n\
+ and the --output-file option\n\
+ -C, --check-compatibility check that GNU msgfmt behaves like X/Open msgfmt\n\
-f, --use-fuzzy use fuzzy entries in output\n\
"));
printf ("\n");
-h, --help display this help and exit\n\
-V, --version output version information and exit\n\
--statistics print statistics about translations\n\
- -v, --verbose list input file anomalies\n\
-Giving the -v option more than once increases the verbosity level.\n\
+ -v, --verbose increase verbosity level\n\
"));
printf ("\n");
fputs (_("Report bugs to <bug-gnu-gettext@gnu.org>.\n"), stdout);
{
msgfmt_class_ty *this = (msgfmt_class_ty *) that;
- /* Test whether header entry was found.
- FIXME: Should do this even if not in verbose mode, because the
- consequences are not harmless. But it breaks the test suite. */
- if (verbose_level > 0 && !this->has_header_entry)
+ /* Test whether header entry was found. */
+ if (check_header && !this->has_header_entry)
{
multiline_error (xasprintf ("%s: ", gram_pos.file_name),
xasprintf (_("\
}
else
{
- if (verbose_level > 0)
- /* We don't change the exit status here because this is really
- only an information. */
+ if (check_domain)
error (0, 0, _("`domain %s' directive ignored"), name);
/* NAME was allocated in po-gram.y but is not used anywhere. */
if (msgstr_string[0] == '\0'
|| (!include_all && this->is_fuzzy && msgid_string[0] != '\0'))
{
- if (verbose_level > 1)
+ if (check_compatibility)
{
- /* We don't change the exit status here because this is really
- only an information. */
error_with_progname = false;
error_at_line (0, 0, msgstr_pos->file_name, msgstr_pos->line_number,
(msgstr_string[0] == '\0'
this->has_header_entry = true;
/* Do some more tests on test contents of the header entry. */
- if (verbose_level > 0)
+ if (check_header)
{
static const char *required_fields[] =
{
/* We don't need the just constructed entry. */
free (entry);
- if (verbose_level > 0)
+ /* We give a fatal error about this, regardless whether the
+ translations are equal or different. This is for consistency
+ with msgmerge, msgcat and others. The user can use the
+ msguniq program to get rid of duplicates. */
+ find_entry (¤t_domain->symbol_tab, msgid_string,
+ strlen (msgid_string) + 1, (void **) &entry);
+ if (msgstr_len != entry->msgstr_len
+ || memcmp (msgstr_string, entry->msgstr, msgstr_len) != 0)
{
- /* We give a fatal error about this, but only if the
- translations are different. Tell the user the old
- definition for reference. */
- find_entry (¤t_domain->symbol_tab, msgid_string,
- strlen (msgid_string) + 1, (void **) &entry);
- if (msgstr_len != entry->msgstr_len
- || memcmp (msgstr_string, entry->msgstr, msgstr_len) != 0)
- {
- po_gram_error_at_line (msgid_pos, _("\
+ po_gram_error_at_line (msgid_pos, _("\
duplicate message definition"));
- po_gram_error_at_line (&entry->pos, _("\
+ po_gram_error_at_line (&entry->pos, _("\
...this is the location of the first definition"));
-
- /* FIXME Should this be always a reason for an
- exit status != 0? */
- exit_status = EXIT_FAILURE;
- }
}
/* We don't need the just constructed entries'
{
static bool warned = false;
- if (!include_all && verbose_level > 1 && !warned)
+ if (!include_all && check_compatibility && !warned)
{
warned = true;
error (0, 0, _("\
}
#undef TEST_NEWLINE
- if (do_check && msgid_plural == NULL)
+ if (check_compatibility && msgid_plural != NULL)
+ {
+ error_with_progname = false;
+ error_at_line (0, 0, msgid_pos->file_name, msgid_pos->line_number,
+ _("plural handling is a GNU gettext extension"));
+ error_with_progname = true;
+ exit_status = EXIT_FAILURE;
+ }
+
+ if (check_format_strings && msgid_plural == NULL)
/* Test 3: Check whether both formats strings contain the same number
of format specifications.
We check only those messages for which the msgid's is_format flag
msgid "Report bugs to <bug-gnu-utils@gnu.org>.\n"
msgstr ""
-#, c-format
-msgid "error while opening \"%s\" for reading"
-msgstr ""
-
msgid "this file may not contain domain directives"
msgstr ""
-#, c-format
-msgid "%s:%d: warning: keyword nested in keyword arg"
+msgid "standard input"
msgstr ""
#, c-format
-msgid "%s:%d: warning: keyword between outer keyword and its arg"
-msgstr ""
-
-msgid "duplicate message definition"
-msgstr ""
-
-msgid "...this is the location of the first definition"
+msgid "error while opening \"%s\" for reading"
msgstr ""
#, c-format
#, no-wrap
msgid ""
"Input file interpretation:\n"
-" -c, --check perform language dependent checks on strings\n"
+" -c, --check perform all the checks implied by\n"
+" --check-format, --check-header, --check-domain\n"
+" --check-format check language dependent format strings\n"
+" --check-header verify presence and contents of the header entry\n"
+" --check-domain check for conflicts between domain directives\n"
+" and the --output-file option\n"
+" -C, --check-compatibility check that GNU msgfmt behaves like X/Open msgfmt\n"
" -f, --use-fuzzy use fuzzy entries in output\n"
msgstr ""
" -h, --help display this help and exit\n"
" -V, --version output version information and exit\n"
" --statistics print statistics about translations\n"
-" -v, --verbose list input file anomalies\n"
-"Giving the -v option more than once increases the verbosity level.\n"
+" -v, --verbose increase verbosity level\n"
msgstr ""
msgid "while creating hash table"
msgid "field `%s' still has initial default value"
msgstr ""
+msgid "duplicate message definition"
+msgstr ""
+
+msgid "...this is the location of the first definition"
+msgstr ""
+
#, c-format
msgid "%s: warning: source file contains fuzzy translation"
msgstr ""
msgid "`msgid' and `msgstr' entries do not both end with '\\n'"
msgstr ""
-msgid "number of format specifications in `msgid' and `msgstr' does not match"
+msgid "plural handling is a GNU gettext extension"
msgstr ""
#, c-format
-msgid "format specifications for argument %lu are not the same"
+msgid "'msgstr' is not a valid %s format string, unlike 'msgid'"
msgstr ""
msgid "too many arguments"