From 1d984a7ffd60a36875e04cbc2d4bbf1d4b1524c8 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Mon, 28 Feb 2011 15:18:27 +0000 Subject: Fixed bug #54089 (token_get_all() does not stop after __halt_compiler). --- ext/tokenizer/tests/bug54089.phpt | 40 +++++++++++++++ ext/tokenizer/tests/token_get_all_variation16.phpt | 57 ++++------------------ ext/tokenizer/tokenizer.c | 4 ++ 3 files changed, 54 insertions(+), 47 deletions(-) create mode 100644 ext/tokenizer/tests/bug54089.phpt (limited to 'ext/tokenizer') diff --git a/ext/tokenizer/tests/bug54089.phpt b/ext/tokenizer/tests/bug54089.phpt new file mode 100644 index 0000000000..e1f6d79e9c --- /dev/null +++ b/ext/tokenizer/tests/bug54089.phpt @@ -0,0 +1,40 @@ +--TEST-- +Bug #54089 (token_get_all() does not stop after __halt_compiler) +--SKIPIF-- + +--FILE-- +\x02"; +$tokens = token_get_all($code); + +var_dump($tokens); + +$code = ''; +foreach ($tokens as $t) +{ + $code .= isset($t[1]) ? $t[1] : $t; +} +var_dump($code); +?> +--EXPECTF-- +array(2) { + [0]=> + array(3) { + [0]=> + int(%d) + [1]=> + string(6) " + int(1) + } + [1]=> + array(3) { + [0]=> + int(%d) + [1]=> + string(15) "__halt_compiler" + [2]=> + int(1) + } +} +string(21) " --EXPECTF-- *** Testing token_get_all() : with different function constructs *** -array(142) { +array(135) { [0]=> array(3) { [0]=> @@ -114,11 +114,11 @@ array(142) { [9]=> array(3) { [0]=> - int(262) + int(%d) [1]=> string(7) "include" [2]=> - int(%d) + int(3) } [10]=> string(1) "(" @@ -129,7 +129,7 @@ array(142) { [1]=> string(13) ""addfile.php"" [2]=> - int(%d) + int(3) } [12]=> string(1) ")" @@ -143,12 +143,12 @@ array(142) { string(1) " " [2]=> - int(%d) + int(3) } [15]=> array(3) { [0]=> - int(259) + int(%d) [1]=> string(7) "require" [2]=> @@ -590,7 +590,7 @@ array(142) { [79]=> array(3) { [0]=> - int(267) + int(%d) [1]=> string(3) ">>=" [2]=> @@ -659,7 +659,7 @@ array(142) { [88]=> array(3) { [0]=> - int(285) + int(%d) [1]=> string(2) "<=" [2]=> @@ -738,7 +738,7 @@ array(142) { [98]=> array(3) { [0]=> - int(266) + int(%d) [1]=> string(5) "print" [2]=> @@ -889,7 +889,7 @@ array(142) { [123]=> array(3) { [0]=> - int(279) + int(%d) [1]=> string(2) "&&" [2]=> @@ -960,42 +960,5 @@ array(142) { [2]=> int(26) } - [135]=> - string(1) "(" - [136]=> - string(1) ")" - [137]=> - string(1) ";" - [138]=> - array(3) { - [0]=> - int(%d) - [1]=> - string(1) " -" - [2]=> - int(26) - } - [139]=> - string(1) "}" - [140]=> - array(3) { - [0]=> - int(%d) - [1]=> - string(1) " -" - [2]=> - int(27) - } - [141]=> - array(3) { - [0]=> - int(%d) - [1]=> - string(2) "?>" - [2]=> - int(28) - } } Done diff --git a/ext/tokenizer/tokenizer.c b/ext/tokenizer/tokenizer.c index bab549bad7..add3168f7c 100644 --- a/ext/tokenizer/tokenizer.c +++ b/ext/tokenizer/tokenizer.c @@ -151,6 +151,10 @@ static void tokenize(zval *return_value TSRMLS_DC) ZVAL_NULL(&token); token_line = CG(zend_lineno); + + if (token_type == T_HALT_COMPILER) { + break; + } } } -- cgit v1.2.1