felipe Mon, 12 Jul 2010 18:48:09 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=301212
Log: - Fixed line number on error messages Changed paths: U php/php-src/branches/LEMON/Zend/zend_compile.c U php/php-src/branches/LEMON/Zend/zend_compile.h U php/php-src/branches/LEMON/Zend/zend_highlight.c U php/php-src/branches/LEMON/Zend/zend_indent.c U php/php-src/branches/LEMON/Zend/zend_language_scanner.c U php/php-src/branches/LEMON/Zend/zend_language_scanner.l U php/php-src/branches/LEMON/Zend/zend_language_scanner_defs.h U php/php-src/branches/LEMON/ext/tokenizer/tokenizer.c
Modified: php/php-src/branches/LEMON/Zend/zend_compile.c =================================================================== --- php/php-src/branches/LEMON/Zend/zend_compile.c 2010-07-12 17:56:05 UTC (rev 301211) +++ php/php-src/branches/LEMON/Zend/zend_compile.c 2010-07-12 18:48:09 UTC (rev 301212) @@ -6109,13 +6109,15 @@ int zendparse(TSRMLS_D) /* {{{ */ { - int token, halting = 0; + int token, lineno = 0, halting = 0; void *pParser; if ((pParser = zend_lang_parseAlloc(malloc)) == NULL) { zend_lang_parseFree(pParser, free); return 1; } + + lineno = CG(zend_lineno); while (1) { znode zendlval; @@ -6126,12 +6128,13 @@ if (CG(increment_lineno)) { CG(zend_lineno)++; CG(increment_lineno) = 0; - } + lineno = CG(zend_lineno); + } again: Z_TYPE(zendlval.u.constant) = IS_LONG; /* Call the scanner */ - token = lex_scan(&zendlval.u.constant TSRMLS_CC); + token = lex_scan(&zendlval.u.constant, &lineno TSRMLS_CC); switch (token) { case T_COMMENT: @@ -6160,6 +6163,7 @@ break; } zend_lang_parse(pParser, token, zendlval TSRMLS_CC); + CG(zend_lineno) = lineno; if (token == 0) { break; } else if (halting == 1 && token == T_SEMICOLON) { Modified: php/php-src/branches/LEMON/Zend/zend_compile.h =================================================================== --- php/php-src/branches/LEMON/Zend/zend_compile.h 2010-07-12 17:56:05 UTC (rev 301211) +++ php/php-src/branches/LEMON/Zend/zend_compile.h 2010-07-12 18:48:09 UTC (rev 301212) @@ -380,7 +380,7 @@ extern ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC); extern ZEND_API zend_op_array *(*zend_compile_string)(zval *source_string, char *filename TSRMLS_DC); -ZEND_API int lex_scan(zval *zendlval TSRMLS_DC); +ZEND_API int lex_scan(zval *zendlval, int *lineno TSRMLS_DC); void startup_scanner(TSRMLS_D); void shutdown_scanner(TSRMLS_D); Modified: php/php-src/branches/LEMON/Zend/zend_highlight.c =================================================================== --- php/php-src/branches/LEMON/Zend/zend_highlight.c 2010-07-12 17:56:05 UTC (rev 301211) +++ php/php-src/branches/LEMON/Zend/zend_highlight.c 2010-07-12 18:48:09 UTC (rev 301212) @@ -90,7 +90,7 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini TSRMLS_DC) { zval token; - int token_type; + int token_type, lineno = 0; char *last_color = syntax_highlighter_ini->highlight_html; char *next_color; @@ -98,7 +98,7 @@ zend_printf("<span style=\"color: %s\">\n", last_color); /* highlight stuff coming back from zendlex() */ token.type = 0; - while ((token_type=lex_scan(&token TSRMLS_CC))) { + while ((token_type=lex_scan(&token, &lineno TSRMLS_CC))) { switch (token_type) { case T_INLINE_HTML: next_color = syntax_highlighter_ini->highlight_html; @@ -174,11 +174,11 @@ ZEND_API void zend_strip(TSRMLS_D) { zval token; - int token_type; + int token_type, lineno = 0; int prev_space = 0; token.type = 0; - while ((token_type=lex_scan(&token TSRMLS_CC))) { + while ((token_type=lex_scan(&token, &lineno TSRMLS_CC))) { switch (token_type) { case T_WHITESPACE: if (!prev_space) { @@ -195,7 +195,7 @@ zend_write(LANG_SCNG(yy_text), LANG_SCNG(yy_leng)); efree(token.value.str.val); /* read the following character, either newline or ; */ - if (lex_scan(&token TSRMLS_CC) != T_WHITESPACE) { + if (lex_scan(&token, &lineno TSRMLS_CC) != T_WHITESPACE) { zend_write(LANG_SCNG(yy_text), LANG_SCNG(yy_leng)); } zend_write("\n", sizeof("\n") - 1); Modified: php/php-src/branches/LEMON/Zend/zend_indent.c =================================================================== --- php/php-src/branches/LEMON/Zend/zend_indent.c 2010-07-12 17:56:05 UTC (rev 301211) +++ php/php-src/branches/LEMON/Zend/zend_indent.c 2010-07-12 18:48:09 UTC (rev 301212) @@ -52,7 +52,7 @@ zval token; int token_type; int in_string=0; - int nest_level=0; + int nest_level=0, lineno = 0; int emit_whitespace[256]; int i; TSRMLS_FETCH(); @@ -61,7 +61,7 @@ /* highlight stuff coming back from zendlex() */ token.type = 0; - while ((token_type=lex_scan(&token TSRMLS_CC))) { + while ((token_type=lex_scan(&token, &lineno TSRMLS_CC))) { switch (token_type) { case T_INLINE_HTML: zend_write(LANG_SCNG(yy_text), LANG_SCNG(yy_leng)); Modified: php/php-src/branches/LEMON/Zend/zend_language_scanner.c =================================================================== --- php/php-src/branches/LEMON/Zend/zend_language_scanner.c 2010-07-12 17:56:05 UTC (rev 301211) +++ php/php-src/branches/LEMON/Zend/zend_language_scanner.c 2010-07-12 18:48:09 UTC (rev 301212) @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Sun Jul 11 18:23:43 2010 */ +/* Generated by re2c 0.13.5 on Mon Jul 12 14:03:13 2010 */ #line 1 "Zend/zend_language_scanner.l" /* +----------------------------------------------------------------------+ @@ -98,7 +98,7 @@ \ while (p<boundary) { \ if (*p == '\n' || (*p == '\r' && (*(p+1) != '\n'))) { \ - CG(zend_lineno)++; \ + ++(*lineno); \ } \ p++; \ } \ @@ -107,7 +107,7 @@ #define HANDLE_NEWLINE(c) \ { \ if (c == '\n' || c == '\r') { \ - CG(zend_lineno)++; \ + ++(*lineno); \ } \ } @@ -730,7 +730,7 @@ zendlval->value.str.len = yyleng; #endif /* ZEND_MULTIBYTE */ -static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quote_type TSRMLS_DC) +static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quote_type, int *lineno TSRMLS_DC) { register char *s, *t; char *end; @@ -827,7 +827,7 @@ } if (*s == '\n' || (*s == '\r' && (*(s+1) != '\n'))) { - CG(zend_lineno)++; + ++(*lineno); } s++; } @@ -844,7 +844,7 @@ } -int lex_scan(zval *zendlval TSRMLS_DC) +int lex_scan(zval *zendlval, int *lineno TSRMLS_DC) { restart: SCNG(yy_text) = YYCURSOR; @@ -1470,7 +1470,7 @@ yyleng = YYCURSOR - SCNG(yy_text); - zend_scan_escape_string(zendlval, yytext, yyleng, '`' TSRMLS_CC); + zend_scan_escape_string(zendlval, yytext, yyleng, '`', lineno TSRMLS_CC); return T_ENCAPSED_AND_WHITESPACE; } #line 1477 "Zend/zend_language_scanner.c" @@ -1701,7 +1701,7 @@ double_quotes_scan_done: yyleng = YYCURSOR - SCNG(yy_text); - zend_scan_escape_string(zendlval, yytext, yyleng, '"' TSRMLS_CC); + zend_scan_escape_string(zendlval, yytext, yyleng, '"', lineno TSRMLS_CC); return T_ENCAPSED_AND_WHITESPACE; } #line 1708 "Zend/zend_language_scanner.c" @@ -1971,7 +1971,7 @@ heredoc_scan_done: yyleng = YYCURSOR - SCNG(yy_text); - zend_scan_escape_string(zendlval, yytext, yyleng - newline, 0 TSRMLS_CC); + zend_scan_escape_string(zendlval, yytext, yyleng - newline, 0, lineno TSRMLS_CC); return T_ENCAPSED_AND_WHITESPACE; } #line 1978 "Zend/zend_language_scanner.c" @@ -3066,7 +3066,7 @@ } /* fall through */ case '\n': - CG(zend_lineno)++; + ++(*lineno); break; case '%': if (!CG(asp_tags)) { @@ -3150,7 +3150,7 @@ } if (*s == '\n' || (*s == '\r' && (*(s+1) != '\n'))) { - CG(zend_lineno)++; + ++(*lineno); } s++; } @@ -3182,7 +3182,7 @@ switch (*YYCURSOR++) { case '"': yyleng = YYCURSOR - SCNG(yy_text); - zend_scan_escape_string(zendlval, yytext+bprefix+1, yyleng-bprefix-2, '"' TSRMLS_CC); + zend_scan_escape_string(zendlval, yytext+bprefix+1, yyleng-bprefix-2, '"', lineno TSRMLS_CC); return T_CONSTANT_ENCAPSED_STRING; case '$': if (IS_LABEL_START(*YYCURSOR) || *YYCURSOR == '{') { @@ -3875,7 +3875,7 @@ Z_STRVAL_P(zendlval) = CG(heredoc); Z_STRLEN_P(zendlval) = CG(heredoc_len); - CG(zend_lineno)++; + ++(*lineno); CG(heredoc_len) = yyleng-bprefix-3-1-(yytext[yyleng-2]=='\r'?1:0); s = yytext+bprefix+3; while ((*s == ' ') || (*s == '\t')) { @@ -4440,7 +4440,7 @@ yyleng = YYCURSOR - SCNG(yy_text); #line 1600 "Zend/zend_language_scanner.l" { - zendlval->value.lval = CG(zend_lineno); + zendlval->value.lval = *lineno; zendlval->type = IS_LONG; return T_LINE; } Modified: php/php-src/branches/LEMON/Zend/zend_language_scanner.l =================================================================== --- php/php-src/branches/LEMON/Zend/zend_language_scanner.l 2010-07-12 17:56:05 UTC (rev 301211) +++ php/php-src/branches/LEMON/Zend/zend_language_scanner.l 2010-07-12 18:48:09 UTC (rev 301212) @@ -96,7 +96,7 @@ \ while (p<boundary) { \ if (*p == '\n' || (*p == '\r' && (*(p+1) != '\n'))) { \ - CG(zend_lineno)++; \ + ++(*lineno); \ } \ p++; \ } \ @@ -105,7 +105,7 @@ #define HANDLE_NEWLINE(c) \ { \ if (c == '\n' || c == '\r') { \ - CG(zend_lineno)++; \ + ++(*lineno); \ } \ } @@ -728,7 +728,7 @@ zendlval->value.str.len = yyleng; #endif /* ZEND_MULTIBYTE */ -static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quote_type TSRMLS_DC) +static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quote_type, int *lineno TSRMLS_DC) { register char *s, *t; char *end; @@ -825,7 +825,7 @@ } if (*s == '\n' || (*s == '\r' && (*(s+1) != '\n'))) { - CG(zend_lineno)++; + ++(*lineno); } s++; } @@ -842,7 +842,7 @@ } -int lex_scan(zval *zendlval TSRMLS_DC) +int lex_scan(zval *zendlval, int *lineno TSRMLS_DC) { restart: SCNG(yy_text) = YYCURSOR; @@ -1598,7 +1598,7 @@ } <ST_IN_SCRIPTING>"__LINE__" { - zendlval->value.lval = CG(zend_lineno); + zendlval->value.lval = *lineno; zendlval->type = IS_LONG; return T_LINE; } @@ -1856,7 +1856,7 @@ } /* fall through */ case '\n': - CG(zend_lineno)++; + ++(*lineno); break; case '%': if (!CG(asp_tags)) { @@ -1990,7 +1990,7 @@ } if (*s == '\n' || (*s == '\r' && (*(s+1) != '\n'))) { - CG(zend_lineno)++; + ++(*lineno); } s++; } @@ -2016,7 +2016,7 @@ switch (*YYCURSOR++) { case '"': yyleng = YYCURSOR - SCNG(yy_text); - zend_scan_escape_string(zendlval, yytext+bprefix+1, yyleng-bprefix-2, '"' TSRMLS_CC); + zend_scan_escape_string(zendlval, yytext+bprefix+1, yyleng-bprefix-2, '"', lineno TSRMLS_CC); return T_CONSTANT_ENCAPSED_STRING; case '$': if (IS_LABEL_START(*YYCURSOR) || *YYCURSOR == '{') { @@ -2059,7 +2059,7 @@ Z_STRVAL_P(zendlval) = CG(heredoc); Z_STRLEN_P(zendlval) = CG(heredoc_len); - CG(zend_lineno)++; + ++(*lineno); CG(heredoc_len) = yyleng-bprefix-3-1-(yytext[yyleng-2]=='\r'?1:0); s = yytext+bprefix+3; while ((*s == ' ') || (*s == '\t')) { @@ -2183,7 +2183,7 @@ double_quotes_scan_done: yyleng = YYCURSOR - SCNG(yy_text); - zend_scan_escape_string(zendlval, yytext, yyleng, '"' TSRMLS_CC); + zend_scan_escape_string(zendlval, yytext, yyleng, '"', lineno TSRMLS_CC); return T_ENCAPSED_AND_WHITESPACE; } @@ -2225,7 +2225,7 @@ yyleng = YYCURSOR - SCNG(yy_text); - zend_scan_escape_string(zendlval, yytext, yyleng, '`' TSRMLS_CC); + zend_scan_escape_string(zendlval, yytext, yyleng, '`', lineno TSRMLS_CC); return T_ENCAPSED_AND_WHITESPACE; } @@ -2297,7 +2297,7 @@ heredoc_scan_done: yyleng = YYCURSOR - SCNG(yy_text); - zend_scan_escape_string(zendlval, yytext, yyleng - newline, 0 TSRMLS_CC); + zend_scan_escape_string(zendlval, yytext, yyleng - newline, 0, lineno TSRMLS_CC); return T_ENCAPSED_AND_WHITESPACE; } Modified: php/php-src/branches/LEMON/Zend/zend_language_scanner_defs.h =================================================================== --- php/php-src/branches/LEMON/Zend/zend_language_scanner_defs.h 2010-07-12 17:56:05 UTC (rev 301211) +++ php/php-src/branches/LEMON/Zend/zend_language_scanner_defs.h 2010-07-12 18:48:09 UTC (rev 301212) @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Sun Jul 11 18:23:43 2010 */ +/* Generated by re2c 0.13.5 on Mon Jul 12 14:03:13 2010 */ #line 3 "Zend/zend_language_scanner_defs.h" enum YYCONDTYPE { Modified: php/php-src/branches/LEMON/ext/tokenizer/tokenizer.c =================================================================== --- php/php-src/branches/LEMON/ext/tokenizer/tokenizer.c 2010-07-12 17:56:05 UTC (rev 301211) +++ php/php-src/branches/LEMON/ext/tokenizer/tokenizer.c 2010-07-12 18:48:09 UTC (rev 301212) @@ -105,12 +105,12 @@ zval *keyword; int token_type; zend_bool destroy; - int token_line = 1; + int token_line = 1, lineno = 0; array_init(return_value); ZVAL_NULL(&token); - while ((token_type = lex_scan(&token TSRMLS_CC))) { + while ((token_type = lex_scan(&token, &lineno TSRMLS_CC))) { destroy = 1; switch (token_type) { case T_CLOSE_TAG:
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php