cvs: Zend(PHP_4_3) / zend_highlight.c zend_language_scanner.l php-src/ext/standard/tests/general_functions highlight_heredoc.phpt
php-src/ext/tokenizer tokenizer.c php-src/ext/tokenizer/tests bug26463.phpt

From: Date: Sat, 29 Nov 2003 19:06:00 +0000
Subject: cvs: Zend(PHP_4_3) / zend_highlight.c zend_language_scanner.l php-src/ext/standard/tests/general_functions highlight_heredoc.phpt
php-src/ext/tokenizer tokenizer.c php-src/ext/tokenizer/tests bug26463.phpt
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-2030@lists.php.net to get a copy of this message
iliaa Sat Nov 29 14:06:00 2003 EDT Added files: (Branch: PHP_4_3) /php-src/ext/standard/tests/general_functions highlight_heredoc.phpt /php-src/ext/tokenizer/tests bug26463.phpt Modified files: /php-src/ext/tokenizer tokenizer.c /Zend zend_language_scanner.l zend_highlight.c Log: MFH: Fixed bug #26463 (Incorrect handling of semicolons after heredoc) Index: php-src/ext/tokenizer/tokenizer.c diff -u php-src/ext/tokenizer/tokenizer.c:1.12.2.3 php-src/ext/tokenizer/tokenizer.c:1.12.2.4 --- php-src/ext/tokenizer/tokenizer.c:1.12.2.3 Sat Nov 29 13:22:46 2003 +++ php-src/ext/tokenizer/tokenizer.c Sat Nov 29 14:05:58 2003 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: tokenizer.c,v 1.12.2.3 2003/11/29 18:22:46 iliaa Exp $ */ +/* $Id: tokenizer.c,v 1.12.2.4 2003/11/29 19:05:58 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -346,7 +346,12 @@ MAKE_STD_ZVAL(keyword); array_init(keyword); add_next_index_long(keyword, token_type); - add_next_index_stringl(keyword, zendtext, zendleng, 1); + if (token_type == T_END_HEREDOC) { + add_next_index_stringl(keyword, Z_STRVAL(token), Z_STRLEN(token), 1); + efree(Z_STRVAL(token)); + } else { + add_next_index_stringl(keyword, zendtext, zendleng, 1); + } add_next_index_zval(return_value, keyword); } else { add_next_index_stringl(return_value, zendtext, zendleng, 1); @@ -354,9 +359,6 @@ if (destroy && Z_TYPE(token) != IS_NULL) { zval_dtor(&token); } - if (token_type == T_END_HEREDOC) { - efree(Z_STRVAL(token)); - } ZVAL_NULL(&token); } } Index: Zend/zend_language_scanner.l diff -u Zend/zend_language_scanner.l:1.54.2.24 Zend/zend_language_scanner.l:1.54.2.25 --- Zend/zend_language_scanner.l:1.54.2.24 Mon Sep 22 00:22:06 2003 +++ Zend/zend_language_scanner.l Sat Nov 29 14:05:59 2003 @@ -1619,8 +1619,8 @@ } if (label_len==CG(heredoc_len) && !memcmp(yytext, CG(heredoc), label_len)) { - zendlval->value.str.val = estrndup(yytext, yyleng); /* unput destroys yytext */ - zendlval->value.str.len = yyleng; + zendlval->value.str.val = estrndup(yytext, label_len); /* unput destroys yytext */ + zendlval->value.str.len = label_len; if (unput_semicolon) { unput(';'); } Index: Zend/zend_highlight.c diff -u Zend/zend_highlight.c:1.31.2.5 Zend/zend_highlight.c:1.31.2.6 --- Zend/zend_highlight.c:1.31.2.5 Thu Aug 28 12:08:11 2003 +++ Zend/zend_highlight.c Sat Nov 29 14:05:59 2003 @@ -177,13 +177,7 @@ break; } } else if (token_type == T_END_HEREDOC) { - zend_bool has_semicolon=(strchr(token.value.str.val, ';')?1:0); - efree(token.value.str.val); - if (has_semicolon) { - /* the following semicolon was unput(), ignore it */ - lex_scan(&token TSRMLS_CC); - } } token.type = 0; } Index: php-src/ext/standard/tests/general_functions/highlight_heredoc.phpt +++ php-src/ext/standard/tests/general_functions/highlight_heredoc.phpt --TEST-- highlight_string() handling of heredoc --FILE-- <?php $str = ' $x=<<<DD jhdsjkfhjdsh DD ""; $a=<<<DDDD jhdsjkfhjdsh DDDD; '; highlight_string($str); ?> --EXPECT-- <code><font color="#000000"> <br />$x=&lt;&lt;&lt;DD<br />jhdsjkfhjdsh<br />DD<br />."";<br />$a=&lt;&lt;&lt;DDDD<br />jhdsjkfhjdsh<br />DDDD;<br /></font> </code> Index: php-src/ext/tokenizer/tests/bug26463.phpt +++ php-src/ext/tokenizer/tests/bug26463.phpt --TEST-- Bug #26463 (token_get_all() does not correctly handle semicolons after T_END_HEREDOC) --FILE-- <?php $str = '<?php $x=<<<DD jhdsjkfhjdsh DD ""; $a=<<<DDDD jhdsjkfhjdsh DDDD; ?>'; var_dump(token_get_all($str)); ?> --EXPECT-- array(17) { [0]=> array(2) { [0]=> int(363) [1]=> string(6) "<?php " } [1]=> array(2) { [0]=> int(307) [1]=> string(2) "$x" } [2]=> string(1) "=" [3]=> array(2) { [0]=> int(367) [1]=> string(6) "<<<DD " } [4]=> array(2) { [0]=> int(305) [1]=> string(13) "jhdsjkfhjdsh " } [5]=> array(2) { [0]=> int(368) [1]=> string(2) "DD" } [6]=> string(1) "." [7]=> array(2) { [0]=> int(313) [1]=> string(2) """" } [8]=> string(1) ";" [9]=> array(2) { [0]=> int(366) [1]=> string(1) " " } [10]=> array(2) { [0]=> int(307) [1]=> string(2) "$a" } [11]=> string(1) "=" [12]=> array(2) { [0]=> int(367) [1]=> string(8) "<<<DDDD " } [13]=> array(2) { [0]=> int(305) [1]=> string(13) "jhdsjkfhjdsh " } [14]=> array(2) { [0]=> int(368) [1]=> string(4) "DDDD" } [15]=> string(1) ";" [16]=> array(2) { [0]=> int(365) [1]=> string(2) "?>" } }

« previous php.zend-engine.cvs (#2030) next »