[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gettext] Bug#608181: /usr/bin/xgettext: xgettext segmentation f
From: |
Bruno Haible |
Subject: |
Re: [bug-gettext] Bug#608181: /usr/bin/xgettext: xgettext segmentation fault (fwd) |
Date: |
Sat, 30 Jul 2011 04:18:04 +0200 |
User-agent: |
KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; ) |
Hello Jean-Luc,
> While trying to extract translatable strings (from WordPress), I get
> a Segmentation fault.
>
> I use the following command:
>
> xgettext --width=80 --from-code=utf-8 \
> --keyword=__ --keyword=_e --keyword=esc_attr__ --keyword=esc_attr_e \
> --keyword=esc_html__ --keyword=esc_html_e \
> --keyword=_x:1,2c --keyword=esc_attr_x:1,2c
> --keyword=esc_html_x:1,2c \
> --keyword=_n:1,2 --keyword=_nx:1,2,4c \
> --keyword=_ex:1,2c \
> --keyword=_n_noop:1,2 --keyword=_nx_noop:1,2,3c \
> --default-domain=wp \
> --language=php \
> --files-from=fichiersphp.lst \
> --exclude-file=cities.pot \
> --exclude-file=ms.pot \
> --output=wp.pot
>
> If I remove the option "--exclude-file=ms.pot" (this file is extracted a
> similar way), I've not the Segmentation Fault.
Thanks for the report. I can reproduce it with the wp-mini-gettext-pb.tar.bz2
tarball that you provided. Here is a fix, which I'm applying for the next
release.
2011-07-29 Bruno Haible <address@hidden>
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 <address@hidden> via
Santiago Vila <address@hidden>.
--- gettext-tools/src/x-smalltalk.c.orig Sat Jul 30 04:07:04 2011
+++ gettext-tools/src/x-smalltalk.c Sat Jul 30 04:00:34 2011
@@ -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 <address@hidden>, 2002.
@@ -562,9 +562,10 @@
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;
}
--- gettext-tools/src/x-ycp.c.orig Sat Jul 30 04:07:04 2011
+++ gettext-tools/src/x-ycp.c Sat Jul 30 04:05:09 2011
@@ -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 <address@hidden>, 2001.
@@ -640,6 +640,7 @@
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 @@
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);
--- gettext-tools/src/xgettext.c.orig Sat Jul 30 04:07:04 2011
+++ gettext-tools/src/xgettext.c Sat Jul 30 03:57:55 2011
@@ -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 <address@hidden>, April 1995.
This program is free software: you can redistribute it and/or modify
@@ -2934,7 +2934,7 @@
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,
--- gettext-tools/src/xgettext.h.orig Sat Jul 30 04:07:04 2011
+++ gettext-tools/src/xgettext.h Sat Jul 30 03:56:05 2011
@@ -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 <address@hidden>
and Bruno Haible <address@hidden>, 2001.
@@ -247,7 +247,8 @@
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,
--
In memoriam Pavel Dybenko <http://en.wikipedia.org/wiki/Pavel_Dybenko>