]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Fix xgettext crash when extracting a message with plural that is excluded.
authorBruno Haible <bruno@clisp.org>
Sat, 30 Jul 2011 02:14:27 +0000 (04:14 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 30 Jul 2011 02:15:11 +0000 (04:15 +0200)
gettext-tools/src/ChangeLog
gettext-tools/src/x-smalltalk.c
gettext-tools/src/x-ycp.c
gettext-tools/src/xgettext.c
gettext-tools/src/xgettext.h

index 7ede0067047c92dd31ad2aef39e03ce811efaaf8..842dada43a3572ec43fc6446ca0cb73b0718d7fc 100644 (file)
@@ -1,3 +1,15 @@
+2011-07-29  Bruno Haible  <bruno@clisp.org>
+
+       Fix xgettext crash when extracting a message with plural that is
+       excluded.
+       * xgettext.h (remember_a_message): Document the return value.
+       * xgettext.c (arglist_parser_done): Handle the case where
+       remember_a_message returned NULL.
+       * x-smalltalk.c (extract_smalltalk): Likewise.
+       * x-ycp.c (extract_parenthesized): Likewise.
+       Reported by Jean-Luc Coulon <jean-luc.coulon@wanadoo.fr> via
+       Santiago Vila <sanvila@unex.es>.
+
 2011-06-13  Bruno Haible  <bruno@clisp.org>
 
        Avoid compilation error on Solaris 7 with cc.
index dbd0aa57e9a2d0795413dcdb5985d87fe3ed8a38..c3f9699d84cae2c4ed80b2e479b16887c1398e30 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext Smalltalk backend.
-   Copyright (C) 2002-2003, 2005-2009 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2005-2009, 2011 Free Software Foundation, Inc.
 
    This file was written by Bruno Haible <haible@clisp.cons.org>, 2002.
 
@@ -562,9 +562,10 @@ extract_smalltalk (FILE *f,
                 lex_pos_ty pos;
                 pos.file_name = logical_file_name;
                 pos.line_number = token.line_number;
-                remember_a_message_plural (plural_mp, token.string,
-                                           null_context, &pos,
-                                           savable_comment);
+                if (plural_mp != NULL)
+                  remember_a_message_plural (plural_mp, token.string,
+                                             null_context, &pos,
+                                             savable_comment);
                 state = 0;
                 break;
               }
index 4e3b590ddbaff6ae2732f850bdad98415ae2ee46..ff8642bdb55cf29b3f328c1a1db16a5588dad11f 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext YCP backend.
-   Copyright (C) 2001-2003, 2005-2009 Free Software Foundation, Inc.
+   Copyright (C) 2001-2003, 2005-2009, 2011 Free Software Foundation, Inc.
 
    This file was written by Bruno Haible <haible@clisp.cons.org>, 2001.
 
@@ -640,6 +640,7 @@ extract_parenthesized (message_list_ty *mlp,
                        bool in_i18n)
 {
   int state; /* 1 or 2 inside _( ... ), otherwise 0 */
+  int plural_state = 0; /* defined only when in states 1 and 2 */
   message_ty *plural_mp = NULL; /* defined only when in states 1 and 2 */
   /* Context iterator that will be used if the next token is a '('.  */
   flag_context_list_iterator_ty next_context_iter =
@@ -678,20 +679,22 @@ extract_parenthesized (message_list_ty *mlp,
               pos.file_name = logical_file_name;
               pos.line_number = token.line_number;
 
-              if (plural_mp == NULL)
+              if (plural_state == 0)
                 {
                   /* Seen an msgid.  */
                   plural_mp = remember_a_message (mlp, NULL, token.string,
                                                   inner_context, &pos,
                                                   NULL, token.comment);
+                  plural_state = 1;
                   state = 2;
                 }
               else
                 {
                   /* Seen an msgid_plural.  */
-                  remember_a_message_plural (plural_mp, token.string,
-                                             inner_context, &pos,
-                                             token.comment);
+                  if (plural_mp != NULL)
+                    remember_a_message_plural (plural_mp, token.string,
+                                               inner_context, &pos,
+                                               token.comment);
                   state = 0;
                 }
               drop_reference (token.comment);
index faf816118e73a3445257353614eb56b64507f9bf..3388820a00a2569e1c22e367b1ec91c6a3996b2d 100644 (file)
@@ -1,5 +1,5 @@
 /* Extracts strings from C source file to Uniforum style .po file.
-   Copyright (C) 1995-1998, 2000-2010 Free Software Foundation, Inc.
+   Copyright (C) 1995-1998, 2000-2011 Free Software Foundation, Inc.
    Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, April 1995.
 
    This program is free software: you can redistribute it and/or modify
@@ -2934,7 +2934,7 @@ arglist_parser_done (struct arglist_parser *ap, int argnum)
                                      msgid_context,
                                      &best_cp->msgid_pos,
                                      NULL, best_cp->msgid_comment);
-            if (best_cp->msgid_plural != NULL)
+            if (mp != NULL && best_cp->msgid_plural != NULL)
               remember_a_message_plural (mp, best_cp->msgid_plural,
                                          msgid_plural_context,
                                          &best_cp->msgid_plural_pos,
index 6b2c53577760e703d76de9e6331df00624c0a96e..16540fe9ccf188818cc552bc92f433a2fc32a6e9 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext common functions.
-   Copyright (C) 2001-2003, 2005-2006, 2008-2009 Free Software Foundation, Inc.
+   Copyright (C) 2001-2003, 2005-2006, 2008-2009, 2011 Free Software Foundation, Inc.
    Written by Peter Miller <millerp@canb.auug.org.au>
    and Bruno Haible <haible@clisp.cons.org>, 2001.
 
@@ -247,7 +247,8 @@ extern void savable_comment_reset (void);
    or NULL.
    COMMENT may be savable_comment, or it may be a saved copy of savable_comment
    (then add_reference must be used when saving it, and drop_reference while
-   dropping it).  Clear savable_comment.  */
+   dropping it).  Clear savable_comment.
+   Return the new or found message, or NULL if the message is excluded.  */
 extern message_ty *remember_a_message (message_list_ty *mlp,
                                        char *msgctxt,
                                        char *msgid,