[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gettext] [PATCH] php: recognize single and double quotes around her
From: |
Daiki Ueno |
Subject: |
[bug-gettext] [PATCH] php: recognize single and double quotes around heredoc label |
Date: |
Fri, 31 Jan 2014 17:54:15 +0900 |
Problem reported by Byrial Jensen in:
<https://lists.gnu.org/archive/html/bug-gettext/2012-04/msg00001.html>.
Based on the patch by Andreas Stricker posted as:
<https://lists.gnu.org/archive/html/bug-gettext/2012-04/msg00002.html>.
---
gettext-tools/src/x-php.c | 15 ++++++++++++---
gettext-tools/tests/xgettext-php-2 | 35 ++++++++++++++++++++++++++++++++---
2 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/gettext-tools/src/x-php.c b/gettext-tools/src/x-php.c
index 4781005..74b8ece 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/xgettext-php-2
b/gettext-tools/tests/xgettext-php-2
index 028e832..6a8fe22 100755
--- a/gettext-tools/tests/xgettext-php-2
+++ b/gettext-tools/tests/xgettext-php-2
@@ -43,13 +43,34 @@ echo _("Franks");
?>
EOF
-tmpfiles="$tmpfiles xg-ph-2.tmp.po xg-ph-2.po"
+tmpfiles="$tmpfiles xg-ph-2d.php"
+sed 's!<<<EOTMARKER!<<<"EOTMARKER"!' xg-ph-2.php > xg-ph-2d.php
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+
+tmpfiles="$tmpfiles xg-ph-2s.php"
+sed 's!<<<EOTMARKER!<<<"EOTMARKER"!' xg-ph-2.php > xg-ph-2s.php
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+
: ${XGETTEXT=xgettext}
+
+tmpfiles="$tmpfiles xg-ph-2.tmp.po xg-ph-2.po"
${XGETTEXT} --omit-header --no-location -d xg-ph-2.tmp xg-ph-2.php
test $? = 0 || { rm -fr $tmpfiles; exit 1; }
LC_ALL=C tr -d '\r' < xg-ph-2.tmp.po > xg-ph-2.po
test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+tmpfiles="$tmpfiles xg-ph-2d.tmp.po xg-ph-2d.po"
+${XGETTEXT} --omit-header --no-location -d xg-ph-2d.tmp xg-ph-2d.php
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+LC_ALL=C tr -d '\r' < xg-ph-2d.tmp.po > xg-ph-2d.po
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+
+tmpfiles="$tmpfiles xg-ph-2s.tmp.po xg-ph-2s.po"
+${XGETTEXT} --omit-header --no-location -d xg-ph-2s.tmp xg-ph-2s.php
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+LC_ALL=C tr -d '\r' < xg-ph-2s.tmp.po > xg-ph-2s.po
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+
tmpfiles="$tmpfiles xg-ph-2.ok"
cat <<EOF > xg-ph-2.ok
msgid "Egyptians"
@@ -69,9 +90,17 @@ msgstr ""
EOF
: ${DIFF=diff}
+
${DIFF} xg-ph-2.ok xg-ph-2.po
result=$?
+test $result = 0 || { rm -fr $tmpfiles; exit $result; }
-rm -fr $tmpfiles
+${DIFF} xg-ph-2.ok xg-ph-2d.po
+result=$?
+test $result = 0 || { rm -fr $tmpfiles; exit $result; }
+
+${DIFF} xg-ph-2.ok xg-ph-2s.po
+result=$?
+test $result = 0 || { rm -fr $tmpfiles; exit $result; }
-exit $result
+rm -fr $tmpfiles
--
1.8.4.2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [bug-gettext] [PATCH] php: recognize single and double quotes around heredoc label,
Daiki Ueno <=