cvs: ZendEngine2(PHP_5_3) / zend_language_scanner.l
"Nuno Lopes" <[email protected]>
| Newsgroups | gmane.comp.php.cvs.zend |
|---|---|
| Message-ID | <cvsnlopess1215530195@cvsserver> |
nlopess Tue Jul 8 15:16:35 2008 UTC
Modified files: (Branch: PHP_5_3)
/ZendEngine2 zend_language_scanner.l
Log:
now really fix once and for all the #-style comments.
also remove some duplicated code in <?, <%, <%= handlers. this also has the side-effect of producing better bytecodes in some special cases
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_language_scanner.l?r1=1.131.2.11.2.13.2.21&r2=1.131.2.11.2.13.2.22&diff_format=u
Index: ZendEngine2/zend_language_scanner.l
diff -u ZendEngine2/zend_language_scanner.l:1.131.2.11.2.13.2.21 ZendEngine2/zend_language_scanner.l:1.131.2.11.2.13.2.22
--- ZendEngine2/zend_language_scanner.l:1.131.2.11.2.13.2.21 Sun Jul 6 16:20:51 2008
+++ ZendEngine2/zend_language_scanner.l Tue Jul 8 15:16:35 2008
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_language_scanner.l,v 1.131.2.11.2.13.2.21 2008/07/06 16:20:51 nlopess Exp $ */
+/* $Id: zend_language_scanner.l,v 1.131.2.11.2.13.2.22 2008/07/08 15:16:35 nlopess Exp $ */
#if 0
# define YYDEBUG(s, c) printf("state: %d char: %c\n", s, c)
@@ -832,6 +832,25 @@
return 0;
}
+ /* ignore first line when it's started with a # */
+ if (YYCURSOR == SCNG(yy_start) && *YYCURSOR == '#') {
+ while (++YYCURSOR < YYLIMIT) {
+ if (*YYCURSOR == '\n') {
+ ++YYCURSOR;
+ goto restart;
+ }
+
+ if (*YYCURSOR == '\r') {
+ if (++YYCURSOR < YYLIMIT && *YYCURSOR == '\n') { /* match \r\n as single newline */
+ ++YYCURSOR;
+ }
+ goto restart;
+ }
+ }
+
+ return 0; /* EOF */
+ }
+
/*!re2c
re2c:yyfill:check = 0;
LNUM [0-9]+
@@ -1549,10 +1568,7 @@
BEGIN(ST_IN_SCRIPTING);
return T_OPEN_TAG_WITH_ECHO;
} else {
- zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
- zendlval->value.str.len = yyleng;
- zendlval->type = IS_STRING;
- return T_INLINE_HTML;
+ goto inline_char_handler;
}
}
@@ -1565,10 +1581,7 @@
BEGIN(ST_IN_SCRIPTING);
return T_OPEN_TAG_WITH_ECHO;
} else {
- zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
- zendlval->value.str.len = yyleng;
- zendlval->type = IS_STRING;
- return T_INLINE_HTML;
+ goto inline_char_handler;
}
}
@@ -1581,10 +1594,7 @@
BEGIN(ST_IN_SCRIPTING);
return T_OPEN_TAG;
} else {
- zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
- zendlval->value.str.len = yyleng;
- zendlval->type = IS_STRING;
- return T_INLINE_HTML;
+ goto inline_char_handler;
}
}
@@ -1600,7 +1610,6 @@
<INITIAL>"<?" {
- HANDLE_NEWLINES(yytext, yyleng);
if (CG(short_tags)) {
zendlval->value.str.val = yytext; /* no copying - intentional */
zendlval->value.str.len = yyleng;
@@ -1608,19 +1617,6 @@
BEGIN(ST_IN_SCRIPTING);
return T_OPEN_TAG;
} else {
- zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
- zendlval->value.str.len = yyleng;
- zendlval->type = IS_STRING;
- return T_INLINE_HTML;
- }
-}
-
-<INITIAL>"#".+ {NEWLINE} {
- if ((YYCTYPE*)yytext == SCNG(yy_start)) {
- /* ignore first line when it's started with a # */
- goto restart;
- } else {
- YYCURSOR = yytext+1;
goto inline_char_handler;
}
}
@@ -1640,8 +1636,8 @@
} else {
YYCURSOR = ptr + 1;
- /* if it can be an opening tag, stop */
- if (YYCURSOR < YYLIMIT && (*YYCURSOR == '?' || *YYCURSOR == '%')) {
+ /* stop if it may be an opening tag (<?, <%, <script>). this condition is not optimal though */
+ if (YYCURSOR < YYLIMIT && (*YYCURSOR == '?' || *YYCURSOR == '%' || *YYCURSOR == 's')) {
--YYCURSOR;
yyleng = YYCURSOR - SCNG(yy_text);
break;
--
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php