From: Daiki Ueno Date: Thu, 14 Nov 2013 07:10:03 +0000 (+0900) Subject: javascript: fix translator comment extraction in C++-style comments X-Git-Tag: v0.19~159 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=82dae3e3a124a220dbfe9de6c46d1ddc9cb22498;p=thirdparty%2Fgettext.git javascript: fix translator comment extraction in C++-style comments * src/x-javascript.c (phase3_getc): Make sure to call comment_line_end after parsing C++ style comment line. Reported by Illimar Tambek at: . * tests/xgettext-javascript-1: Add a test to extract translator comments from C++ style comment lines; only extract comments with TRANSLATORS: tag. * tests/xgettext-javascript-3: Only extract comments with TRANSLATORS: tag. --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index c15fd7dfa..97c3c1f32 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,9 @@ +2013-11-14 Daiki Ueno + + * x-javascript.c (phase3_getc): Make sure to call comment_line_end + after parsing C++ style comment line. + Reported by Illimar Tambek at: . + 2013-11-14 Daiki Ueno * x-javascript.c (comment_line_end): Add missing chars_to_remove diff --git a/gettext-tools/src/x-javascript.c b/gettext-tools/src/x-javascript.c index 9d166714f..c1503cef5 100644 --- a/gettext-tools/src/x-javascript.c +++ b/gettext-tools/src/x-javascript.c @@ -619,7 +619,10 @@ phase3_getc () { c = phase2_getc (); if (c == UEOF || c == '\n') - break; + { + comment_line_end (0); + break; + } /* We skip all leading white space, but not EOLs. */ if (!(comment_at_start () && (c == ' ' || c == '\t'))) comment_add (c); diff --git a/gettext-tools/tests/xgettext-javascript-1 b/gettext-tools/tests/xgettext-javascript-1 index 2f8115f92..83d841265 100755 --- a/gettext-tools/tests/xgettext-javascript-1 +++ b/gettext-tools/tests/xgettext-javascript-1 @@ -18,11 +18,13 @@ if (document.getElementsById("foo")[0].innerHTML == _("Extract this third string } /* TRANSLATORS: This is a translator comment. */ gettext('Extract this fourth string'); +// TRANSLATORS: This is another translator comment. +gettext('Extract this fifth string'); EOF tmpfiles="$tmpfiles xg-js-1.err xg-js-1.tmp xg-js-1.pot" : ${XGETTEXT=xgettext} -${XGETTEXT} --add-comments --no-location -o xg-js-1.tmp xg-js-1.js 2>xg-js-1.err +${XGETTEXT} --add-comments=TRANSLATORS: --no-location -o xg-js-1.tmp xg-js-1.js 2>xg-js-1.err test $? = 0 || { cat xg-js-1.err; rm -fr $tmpfiles; exit 1; } # Don't simplify this to "grep ... < xg-js-1.tmp", otherwise OpenBSD 4.0 grep # only outputs "Binary file (standard input) matches". @@ -60,6 +62,10 @@ msgstr "" #. TRANSLATORS: This is a translator comment. msgid "Extract this fourth string" msgstr "" + +#. TRANSLATORS: This is another translator comment. +msgid "Extract this fifth string" +msgstr "" EOF : ${DIFF=diff} diff --git a/gettext-tools/tests/xgettext-javascript-3 b/gettext-tools/tests/xgettext-javascript-3 index c7dd9565c..95ced524f 100755 --- a/gettext-tools/tests/xgettext-javascript-3 +++ b/gettext-tools/tests/xgettext-javascript-3 @@ -19,7 +19,7 @@ EOF tmpfiles="$tmpfiles xg-js-3.err xg-js-3.tmp xg-js-3.pot" : ${XGETTEXT=xgettext} -${XGETTEXT} --add-comments --no-location -o xg-js-3.tmp xg-js-3.js 2>xg-js-3.err +${XGETTEXT} --add-comments=TRANSLATORS: --no-location -o xg-js-3.tmp xg-js-3.js 2>xg-js-3.err test $? = 0 || { cat xg-js-3.err; rm -fr $tmpfiles; exit 1; } # Don't simplify this to "grep ... < xg-js-3.tmp", otherwise OpenBSD 4.0 grep # only outputs "Binary file (standard input) matches".