summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@gnu.org>2013-11-14 16:10:03 +0900
committerDaiki Ueno <ueno@gnu.org>2013-11-14 16:10:03 +0900
commit82dae3e3a124a220dbfe9de6c46d1ddc9cb22498 (patch)
treed44a9821578da47cc17791e332309a2b840281cb
parent64427a17b7d50d509d54f60aa159c7107bd0e5c6 (diff)
downloadexternal_gettext-82dae3e3a124a220dbfe9de6c46d1ddc9cb22498.zip
external_gettext-82dae3e3a124a220dbfe9de6c46d1ddc9cb22498.tar.gz
external_gettext-82dae3e3a124a220dbfe9de6c46d1ddc9cb22498.tar.bz2
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: <http://savannah.gnu.org/bugs/?40572>. * 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.
-rw-r--r--gettext-tools/src/ChangeLog6
-rw-r--r--gettext-tools/src/x-javascript.c5
-rwxr-xr-xgettext-tools/tests/xgettext-javascript-18
-rwxr-xr-xgettext-tools/tests/xgettext-javascript-32
4 files changed, 18 insertions, 3 deletions
diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog
index c15fd7d..97c3c1f 100644
--- a/gettext-tools/src/ChangeLog
+++ b/gettext-tools/src/ChangeLog
@@ -1,5 +1,11 @@
2013-11-14 Daiki Ueno <ueno@gnu.org>
+ * x-javascript.c (phase3_getc): Make sure to call comment_line_end
+ after parsing C++ style comment line.
+ Reported by Illimar Tambek at: <http://savannah.gnu.org/bugs/?40572>.
+
+2013-11-14 Daiki Ueno <ueno@gnu.org>
+
* x-javascript.c (comment_line_end): Add missing chars_to_remove
argument; all callers changed.
Reported by Illimar Tambek at: <http://savannah.gnu.org/bugs/?40573>.
diff --git a/gettext-tools/src/x-javascript.c b/gettext-tools/src/x-javascript.c
index 9d16671..c1503ce 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 2f8115f..83d8412 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 c7dd956..95ced52 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".