]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
php: Recognize single and double quotes around heredoc label
authorDaiki Ueno <ueno@gnu.org>
Mon, 10 Mar 2014 09:28:44 +0000 (18:28 +0900)
committerDaiki Ueno <ueno@gnu.org>
Mon, 10 Mar 2014 09:44:45 +0000 (18:44 +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/ChangeLog
gettext-tools/src/x-php.c
gettext-tools/tests/ChangeLog
gettext-tools/tests/xgettext-php-2

index 64ea86dc93f23c0df6c82bde8785a55023c2c5c4..0537dd2430ad8a1e20e0953c46b37ec13bb51546 100644 (file)
@@ -1,3 +1,12 @@
+2014-03-10  Daiki Ueno  <ueno@gnu.org>
+
+       php: Recognize single and double quotes around heredoc label
+       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>.
+       * x-php.c (phase4_get): Strip quotes around heredoc label.
+
 2013-11-20  Daiki Ueno  <ueno@gnu.org>
 
        xgettext: Add E4X support to JavaScript scanner
index 4781005b5b0726902220aed59afa4cf06aeb4060..74b8ece5cdb1d0805612bc6808e6f9806189a3d2 100644 (file)
@@ -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)
                               {
index 518c5cb47cac0a1daa4f1e42eb6a41efc1726e6f..e260c63b25265a8ae9e1492543aa74fdd89b303c 100644 (file)
@@ -1,3 +1,8 @@
+2014-03-10  Daiki Ueno  <ueno@gnu.org>
+
+       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  <ueno@gnu.org>
 
        Remove unnecessary temporary file cleanup code.
index b19b3b5dd29721dc7e5b0bd5ed196e4265c07327..34f2e7fe8c3c7dde26e5bdb40b79004d07beb59e 100644 (file)
@@ -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!<<<EOTMARKER!<<<"EOTMARKER"!' xg-ph-2.php > xg-ph-2d.php || exit 1
+sed "s!<<<EOTMARKER!<<<'EOTMARKER'!" xg-ph-2.php > 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 <<EOF > 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