Skip to content
Browse files

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

  • Loading branch information...
1 parent 85875e8 commit 7ade3b30cb9253341f18f7016e07f41a9fb478b5 @zsuraski zsuraski committed Aug 6, 2001
Showing with 12 additions and 2 deletions.
  1. +9 −0 Zend/zend_compile.c
  2. +2 −0 Zend/zend_globals.h
  3. +1 −2 Zend/zend_language_scanner.l
View
9 Zend/zend_compile.c
@@ -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
2 Zend/zend_globals.h
@@ -122,6 +122,8 @@ struct _zend_compiler_globals {
struct _zend_ini_parser_param *ini_parser_param;
int interactive;
+
+ zend_bool increment_lineno;
};
View
3 Zend/zend_language_scanner.l
@@ -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);

0 comments on commit 7ade3b3

Please sign in to comment.
Something went wrong with that request. Please try again.