]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext: PHP: Stop recognizing ASP tags <% and %> (removed in PHP 7.0).
authorBruno Haible <bruno@clisp.org>
Tue, 19 Nov 2024 17:03:45 +0000 (18:03 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 19 Nov 2024 17:03:45 +0000 (18:03 +0100)
Reported by David Robinson <dave@netterra.com> in
<https://lists.gnu.org/archive/html/bug-gettext/2021-10/msg00000.html>.

* gettext-tools/src/x-php.c (skip_html): Don't recognize '<%' and '<%='
any more.
(phase2_getc, phase3_getc, phase4_get): In comments, don't treat '%>' like '?>'
any more.

gettext-tools/src/x-php.c

index 0b8c0f325fcdf7637920c38c685256cf249e426b..19a7cc54c8dffadafed7bb6f660fee2a7f6fd5b1 100644 (file)
@@ -322,18 +322,6 @@ skip_html (struct php_extractor *xp)
               return;
             }
 
-          if (c2 == '%')
-            {
-              /* <% and <%= are recognized by PHP depending on a configuration
-                 setting.  */
-              int c3 = phase1_getc (xp);
-
-              if (c3 != '=')
-                phase1_ungetc (xp, c3);
-
-              return;
-            }
-
           if (c2 == '<')
             {
               phase1_ungetc (xp, c2);
@@ -549,7 +537,6 @@ phase2_getc (struct php_extractor *xp)
   switch (c)
     {
     case '?':
-    case '%':
       {
         int c2 = phase1_getc (xp);
         if (c2 == '>')
@@ -705,7 +692,7 @@ phase3_getc (struct php_extractor *xp)
           /* We skip all leading white space, but not EOLs.  */
           if (!(xp->buflen == 0 && (c == ' ' || c == '\t')))
             comment_add (xp, c);
-          last_was_qmark = (c == '?' || c == '%');
+          last_was_qmark = (c == '?');
         }
       xp->last_comment_line = lineno;
       return '\n';
@@ -792,7 +779,7 @@ phase3_getc (struct php_extractor *xp)
                 /* We skip all leading white space, but not EOLs.  */
                 if (!(xp->buflen == 0 && (c == ' ' || c == '\t')))
                   comment_add (xp, c);
-                last_was_qmark = (c == '?' || c == '%');
+                last_was_qmark = (c == '?');
               }
             xp->last_comment_line = lineno;
             return '\n';
@@ -1236,20 +1223,18 @@ phase4_get (struct php_extractor *xp, token_ty *tp)
           return;
 
         case '?':
-        case '%':
           {
             int c2 = phase1_getc (xp);
             if (c2 == '>')
               {
-                /* ?> and %> terminate PHP mode and switch back to HTML
-                   mode.  */
+                /* ?> terminates PHP mode and switches back to HTML mode.  */
                 skip_html (xp);
                 tp->type = token_type_other;
               }
             else
               {
                 phase1_ungetc (xp, c2);
-                tp->type = (c == '%' ? token_type_operator1 : token_type_other);
+                tp->type = token_type_other;
               }
             return;
           }