1
0
mirror of https://github.com/php/php-src.git synced 2026-04-13 19:14:16 +02:00

Fix an off by one lineno issue, in case of an implicit ;

This commit is contained in:
Zeev Suraski
2001-08-06 14:36:46 +00:00
parent 85875e83ae
commit 7ade3b30cb
3 changed files with 12 additions and 2 deletions

View File

@@ -2365,6 +2365,11 @@ int zendlex(znode *zendlval TSRMLS_DC)
{
int retval;
if (CG(increment_lineno)) {
CG(zend_lineno)++;
CG(increment_lineno) = 0;
}
zendlval->u.constant.type = IS_LONG;
retval = lex_scan(&zendlval->u.constant TSRMLS_CC);
switch(retval) {
@@ -2374,6 +2379,10 @@ int zendlex(znode *zendlval TSRMLS_DC)
retval = zendlex(zendlval TSRMLS_CC);
break;
case T_CLOSE_TAG:
if (LANG_SCNG(yy_text)[LANG_SCNG(yy_leng)-1]=='\n'
|| (LANG_SCNG(yy_text)[LANG_SCNG(yy_leng)-2]=='\r' && LANG_SCNG(yy_text)[LANG_SCNG(yy_leng)-1])) {
CG(increment_lineno) = 1;
}
retval = ';'; /* implicit ; */
break;
case T_OPEN_TAG_WITH_ECHO:

View File

@@ -122,6 +122,8 @@ struct _zend_compiler_globals {
struct _zend_ini_parser_param *ini_parser_param;
int interactive;
zend_bool increment_lineno;
};

View File

@@ -322,6 +322,7 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC)
zend_set_compiled_filename(file_path TSRMLS_CC);
CG(zend_lineno) = 1;
CG(increment_lineno) = 0;
return SUCCESS;
}
END_EXTERN_C()
@@ -1233,7 +1234,6 @@ NEWLINE ("\r"|"\n"|"\r\n")
zendlval->value.str.val = yytext; /* no copying - intentional */
zendlval->value.str.len = yyleng;
zendlval->type = IS_STRING;
HANDLE_NEWLINES(yytext, yyleng);
BEGIN(INITIAL);
return T_CLOSE_TAG; /* implicit ';' at php-end tag */
}
@@ -1245,7 +1245,6 @@ NEWLINE ("\r"|"\n"|"\r\n")
zendlval->value.str.len = yyleng;
zendlval->type = IS_STRING;
zendlval->value.str.val = yytext; /* no copying - intentional */
HANDLE_NEWLINES(yytext,yyleng);
return T_CLOSE_TAG; /* implicit ';' at php-end tag */
} else {
yyless(1);