From ae6fe018190aafab0c17388b021db01622e5aa17 Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Mon, 12 Aug 2013 12:12:12 +0200 Subject: [PATCH] glade: handle multi-line extracted comments --- gettext-tools/src/ChangeLog | 7 +++++++ gettext-tools/src/xgettext.c | 24 +++++++++++++++++++++++- gettext-tools/tests/ChangeLog | 4 ++++ gettext-tools/tests/xgettext-glade-7 | 24 ++++++++++++++++-------- 4 files changed, 50 insertions(+), 9 deletions(-) diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 430e0faff..6cd501f40 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,10 @@ +2013-08-12 Daiki Ueno + + * xgettext.c (remember_a_message): Handle multi-line extracted + comments. + Reported by Gabor Kelemen in + . + 2013-07-11 Daiki Ueno Fix crash when parsing '..' with non-string argument. diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c index 702ceb072..507008fe2 100644 --- a/gettext-tools/src/xgettext.c +++ b/gettext-tools/src/xgettext.c @@ -2277,7 +2277,29 @@ meta information, not the empty string.\n"))); nitems_before = (mp->comment_dot != NULL ? mp->comment_dot->nitems : 0); if (extracted_comment != NULL) - message_comment_dot_append (mp, extracted_comment); + { + char *copy = xstrdup (extracted_comment); + char *rest; + + rest = copy; + while (*rest != '\0') + { + char *newline = strchr (rest, '\n'); + + if (newline != NULL) + { + *newline = '\0'; + message_comment_dot_append (mp, rest); + rest = newline + 1; + } + else + { + message_comment_dot_append (mp, rest); + break; + } + } + free (copy); + } add_all_remaining_comments = add_all_comments; for (j = 0; ; ++j) diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog index e342d7fbd..8e8b4dce5 100644 --- a/gettext-tools/tests/ChangeLog +++ b/gettext-tools/tests/ChangeLog @@ -1,3 +1,7 @@ +2013-08-12 Daiki Ueno + + * xgettext-glade-7: Add a test for multi-line extracted comments. + 2013-07-11 Daiki Ueno * xgettext-lua-1: Add test case for string concatenation. diff --git a/gettext-tools/tests/xgettext-glade-7 b/gettext-tools/tests/xgettext-glade-7 index 09624f856..f17eb59c6 100755 --- a/gettext-tools/tests/xgettext-glade-7 +++ b/gettext-tools/tests/xgettext-glade-7 @@ -66,6 +66,11 @@ cat < xg-gl-7.ui Please... 86855555 + + Hi + Comment + 999 + @@ -186,6 +191,7 @@ EOF tmpfiles="$tmpfiles xg-gl-7.pot" : ${XGETTEXT=xgettext} ${XGETTEXT} -o - xg-gl-7.ui | grep -v 'POT-Creation-Date' > xg-gl-7.pot +cp xg-gl-7.pot .. test $? = 0 || { rm -fr $tmpfiles; exit 1; } tmpfiles="$tmpfiles xg-gl-7.ok" @@ -208,13 +214,15 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: xg-gl-7.ui:30 +#: xg-gl-7.ui:30 xg-gl-7.ui:45 msgctxt "First row" msgid "Hi" msgstr "" #. A comment. -#: xg-gl-7.ui:31 +#. A multiline +#. comment. +#: xg-gl-7.ui:31 xg-gl-7.ui:46 msgid "Comment" msgstr "" @@ -234,37 +242,37 @@ msgid "Please..." msgstr "" #. This thing is the menu label -#: xg-gl-7.ui:62 +#: xg-gl-7.ui:67 msgctxt "Menu" msgid "One thing" msgstr "" #. This thing is the label in the inner menu. -#: xg-gl-7.ui:70 +#: xg-gl-7.ui:75 msgctxt "One thing" msgid "One thing" msgstr "" #. This is easy. -#: xg-gl-7.ui:87 +#: xg-gl-7.ui:92 msgctxt "Menu" msgid "H_elp" msgstr "" #. This one thing is for the second menu. -#: xg-gl-7.ui:95 +#: xg-gl-7.ui:100 msgctxt "Second menu" msgid "One thing" msgstr "" #. To you too. -#: xg-gl-7.ui:105 +#: xg-gl-7.ui:110 msgctxt "Second menu" msgid "Greetings" msgstr "" #. This one thing is the button. -#: xg-gl-7.ui:142 +#: xg-gl-7.ui:147 msgctxt "Button" msgid "One thing" msgstr "" -- 2.47.2