]> granicus.if.org Git - php/commitdiff
Fixed bug #36513 (comment will be outputed in last line)
authorDmitry Stogov <dmitry@php.net>
Thu, 13 Apr 2006 13:48:40 +0000 (13:48 +0000)
committerDmitry Stogov <dmitry@php.net>
Thu, 13 Apr 2006 13:48:40 +0000 (13:48 +0000)
Zend/tests/bug36513.phpt [new file with mode: 0755]
Zend/zend_language_scanner.l

diff --git a/Zend/tests/bug36513.phpt b/Zend/tests/bug36513.phpt
new file mode 100755 (executable)
index 0000000..f46da4e
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+Bug #36513 (comment will be outputed in last line)
+--FILE--
+<?php 
+function test($s) {
+  echo "'".trim(str_replace("&nbsp;", " ", htmlspecialchars_decode(strip_tags(highlight_string($s,1)))))."'\n";
+}
+
+eval('echo "1";//2');
+eval('echo 3; //{ 4?>5');
+echo "\n";
+
+//test('<?php echo "1";//');
+test('<?php echo "1";//2');
+test('<?php echo "1";//22');
+test('<?php echo 3; // 4 ?>5');
+?>
+--EXPECT--
+135
+'<?php echo "1";//2'
+'<?php echo "1";//22'
+'<?php echo 3; // 4 ?>5'
index 778e26a0f0478b7bb28857db4612402b3047456d..5baed5057dc5803395880cc7fae0ef6131126bc9 100644 (file)
@@ -2107,7 +2107,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
        yymore();
 }
 
-<ST_ONE_LINE_COMMENT>[^\n\r?%>]+{ANY_CHAR} {
+<ST_ONE_LINE_COMMENT>[^\n\r?%>]*{ANY_CHAR} {
        switch (yytext[yyleng-1]) {
                case '?': case '%': case '>':
                        yyless(yyleng-1);
@@ -2137,7 +2137,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
 <ST_ONE_LINE_COMMENT>"?>"|"%>" {
     if (CG(asp_tags) || yytext[yyleng-2] != '%') { /* asp comment? */
                Z_STRVAL_P(zendlval) = yytext; /* no copying - intentional */
-               Z_STRLEN_P(zendlval) = yyleng;
+               Z_STRLEN_P(zendlval) = yyleng-2;
                Z_TYPE_P(zendlval) = IS_STRING;
                yyless(yyleng-2);
                BEGIN(ST_IN_SCRIPTING);