[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gettext] xgettext: fatal error after a warning when processing a po

From: Emil Wojak
Subject: [bug-gettext] xgettext: fatal error after a warning when processing a pot file
Date: Fri, 18 Oct 2013 17:42:15 +0200
User-agent: Roundcube Webmail/0.9-git


This fails:
$ xgettext -o output.pot hello input.pot
xgettext: warning: file `hello' extension `' is unknown; will try C
xgettext: found 1 fatal error
$ ls output.pot
ls: cannot access output.pot: No such file or directory

This succeeds:
$ xgettext -o output.pot input.pot hello
xgettext: warning: file `hello' extension `' is unknown; will try C
$ ls output.pot

The outcome depends on the order of files to be processed. Their content is irrelevant provided the pot file has correct format. If I rename hello to hello.c then both invocations work fine.

I noticed that processing a pot file will fail with the "fatal error" message if any of files processed before that issues a warning.

I just debugged vanilla gettext- and I found the following. When xgettext processes a file without an extension it outputs the warning using a function that increments a variable called error_message_count.
From src/xgettext.c:
780 /* Derive the language from the extension, and the extractor
 781              function from the language.  */
 782           language = extension_to_language (extension);
 783           if (language == NULL)
 784             {
 785               error (0, 0, _("\
786 warning: file '%s' extension '%s' is unknown; will try C"), filename, extension);
 787               language = "C";
 788             }
 789           this_file_extractor = language_to_extractor (language);
This variable is not checked after processing the file.

On the other hand after processing a pot file there's a check if error_message_count > 0 and if so, it exits with the "fatal error" message.
From src/read-catalog-abstract.c:
174   /* Parse the stream's content.  */
175   parse_start (pop);
176   input_syntax->parse (pop, fp, real_filename, logical_filename);
177   parse_end (pop);
179   if (error_message_count > 0)
180     po_xerror (PO_SEVERITY_FATAL_ERROR, NULL,
181 /*real_filename*/ NULL, (size_t)(-1), (size_t)(-1), false,
182                xasprintf (ngettext ("found %d fatal error",
183                                     "found %d fatal errors",
184                                     error_message_count),
185                           error_message_count));
186   error_message_count = 0;
So if the warning is output before processing the pot file, then xgettext will exit with fatal error. Otherwise the warning will have no further consequences.

I consider this to be a bug in gettext. I would expect xgettext not to fail upon a warning.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]