From: Daiki Ueno Date: Mon, 10 Mar 2014 09:28:44 +0000 (+0900) Subject: php: Recognize single and double quotes around heredoc label X-Git-Tag: v0.19~142 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c47fc6b0fcb0d1199e8834ccef41a93b8c1d243;p=thirdparty%2Fgettext.git php: Recognize single and double quotes around heredoc label Problem reported by Byrial Jensen in: . Based on the patch by Andreas Stricker posted as: . --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 64ea86dc9..0537dd243 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,12 @@ +2014-03-10 Daiki Ueno + + php: Recognize single and double quotes around heredoc label + Problem reported by Byrial Jensen in: + . + Based on the patch by Andreas Stricker posted as: + . + * x-php.c (phase4_get): Strip quotes around heredoc label. + 2013-11-20 Daiki Ueno xgettext: Add E4X support to JavaScript scanner diff --git a/gettext-tools/src/x-php.c b/gettext-tools/src/x-php.c index 4781005b5..74b8ece5c 100644 --- a/gettext-tools/src/x-php.c +++ b/gettext-tools/src/x-php.c @@ -1161,7 +1161,9 @@ phase4_get (token_ty *tp) int c3 = phase1_getc (); if (c3 == '<') { - /* Start of here document. + int label_start = 0; + + /* Start of here and now document. Parse whitespace, then label, then newline. */ do c = phase3_getc (); @@ -1179,7 +1181,14 @@ phase4_get (token_ty *tp) c = phase3_getc (); } while (c != EOF && c != '\n' && c != '\r'); - /* buffer[0..bufpos-1] now contains the label. */ + /* buffer[0..bufpos-1] now contains the label + (including single or double quotes). */ + + if (*buffer == '\'' || *buffer == '"') + { + label_start++; + bufpos--; + } /* Now skip the here document. */ for (;;) @@ -1189,7 +1198,7 @@ phase4_get (token_ty *tp) break; if (c == '\n' || c == '\r') { - int bufidx = 0; + int bufidx = label_start; while (bufidx < bufpos) { diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog index 518c5cb47..e260c63b2 100644 --- a/gettext-tools/tests/ChangeLog +++ b/gettext-tools/tests/ChangeLog @@ -1,3 +1,8 @@ +2014-03-10 Daiki Ueno + + php: Recognize single and double quotes around heredoc label + * xgettext-php-2: Add test cases to check quoted heredoc labels. + 2014-03-10 Daiki Ueno Remove unnecessary temporary file cleanup code. diff --git a/gettext-tools/tests/xgettext-php-2 b/gettext-tools/tests/xgettext-php-2 index b19b3b5dd..34f2e7fe8 100644 --- a/gettext-tools/tests/xgettext-php-2 +++ b/gettext-tools/tests/xgettext-php-2 @@ -43,6 +43,20 @@ EOF ${XGETTEXT} --omit-header --no-location -d xg-ph-2.tmp xg-ph-2.php || exit 1 LC_ALL=C tr -d '\r' < xg-ph-2.tmp.po > xg-ph-2.po || exit 1 +sed 's!<< xg-ph-2d.php || exit 1 +sed "s!<< xg-ph-2s.php || exit 1 + +: ${XGETTEXT=xgettext} + +${XGETTEXT} --omit-header --no-location -d xg-ph-2.tmp xg-ph-2.php || exit 1 +LC_ALL=C tr -d '\r' < xg-ph-2.tmp.po > xg-ph-2.po || exit 1 + +${XGETTEXT} --omit-header --no-location -d xg-ph-2d.tmp xg-ph-2d.php || exit 1 +LC_ALL=C tr -d '\r' < xg-ph-2d.tmp.po > xg-ph-2d.po || exit 1 + +${XGETTEXT} --omit-header --no-location -d xg-ph-2s.tmp xg-ph-2s.php || exit 1 +LC_ALL=C tr -d '\r' < xg-ph-2s.tmp.po > xg-ph-2s.po || exit 1 + cat < xg-ph-2.ok msgid "Egyptians" msgstr "" @@ -61,7 +75,17 @@ msgstr "" EOF : ${DIFF=diff} + ${DIFF} xg-ph-2.ok xg-ph-2.po result=$? +test $result = 0 || exit $result + +${DIFF} xg-ph-2.ok xg-ph-2d.po +result=$? +test $result = 0 || exit $result + +${DIFF} xg-ph-2.ok xg-ph-2s.po +result=$? +test $result = 0 || exit $result exit $result