bug-gettext
[Top][All Lists]
Advanced

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

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


From: Daiki Ueno
Subject: Re: [bug-gettext] xgettext: fatal error after a warning when processing a pot file
Date: Wed, 23 Oct 2013 18:35:33 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Hi Emil,

Sorry for late response.

Emil Wojak <address@hidden> writes:

> I just debugged vanilla gettext-0.18.3.1 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.

Thanks for the report and investigation.  Though I'm not completely sure
about the original code, I think error_message_count should be
initialized before calling the PO parser.  Pushed the attached fix, as
all the tests pass.

>From f61631729611e9b6eefce863ee861de6edfd4aa9 Mon Sep 17 00:00:00 2001
From: Daiki Ueno <address@hidden>
Date: Wed, 23 Oct 2013 18:31:20 +0900
Subject: [PATCH] Clear error_message_count before parsing PO files.

---
 gettext-tools/src/ChangeLog               | 9 +++++++++
 gettext-tools/src/read-catalog-abstract.c | 3 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog
index 88846f5..cdd621f 100644
--- a/gettext-tools/src/ChangeLog
+++ b/gettext-tools/src/ChangeLog
@@ -1,3 +1,12 @@
+2013-10-23  Daiki Ueno  <address@hidden>
+
+       * read-catalog-abstract.c (catalog_reader_parse): Clear
+       error_message_count before parsing, rather than after.  The
+       variable may be > 0 before calling the PO parser, when xgettext
+       handles mutiple files.
+       Problem reported by Emil Wojak in
+       <https://lists.gnu.org/archive/html/bug-gettext/2013-10/msg00005.html>.
+
 2013-10-15  Peter Eisentraut  <address@hidden>  (tiny change)
 
        * msgl-check.c (check_header_entry): Adjust the default value of
diff --git a/gettext-tools/src/read-catalog-abstract.c 
b/gettext-tools/src/read-catalog-abstract.c
index cb713dc..d4e98ee 100644
--- a/gettext-tools/src/read-catalog-abstract.c
+++ b/gettext-tools/src/read-catalog-abstract.c
@@ -171,6 +171,8 @@ catalog_reader_parse (abstract_catalog_reader_ty *pop, FILE 
*fp,
                       const char *real_filename, const char *logical_filename,
                       catalog_input_format_ty input_syntax)
 {
+  error_message_count = 0;
+
   /* Parse the stream's content.  */
   parse_start (pop);
   input_syntax->parse (pop, fp, real_filename, logical_filename);
@@ -183,7 +185,6 @@ catalog_reader_parse (abstract_catalog_reader_ty *pop, FILE 
*fp,
                                     "found %d fatal errors",
                                     error_message_count),
                           error_message_count));
-  error_message_count = 0;
 }
 
 
-- 
1.8.3.1

Regards,
-- 
Daiki Ueno



reply via email to

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