@@ -358,10 +358,7 @@ static zend_bool tokenize(zval *return_value, zend_string *source, zend_class_en
358
358
ZVAL_STR_COPY (& source_zval , source );
359
359
zend_save_lexical_state (& original_lex_state );
360
360
361
- if (zend_prepare_string_for_scanning (& source_zval , "" ) == FAILURE ) {
362
- zend_restore_lexical_state (& original_lex_state );
363
- return 0 ;
364
- }
361
+ zend_prepare_string_for_scanning (& source_zval , "" );
365
362
366
363
LANG_SCNG (yy_state ) = yycINITIAL ;
367
364
zend_hash_init (& interned_strings , 0 , NULL , NULL , 0 );
@@ -484,6 +481,8 @@ static zend_bool tokenize_parse(
484
481
zval * return_value , zend_string * source , zend_class_entry * token_class )
485
482
{
486
483
zval source_zval ;
484
+ struct event_context ctx ;
485
+ zval token_stream ;
487
486
zend_lex_state original_lex_state ;
488
487
zend_bool original_in_compilation ;
489
488
zend_bool success ;
@@ -494,30 +493,27 @@ static zend_bool tokenize_parse(
494
493
CG (in_compilation ) = 1 ;
495
494
zend_save_lexical_state (& original_lex_state );
496
495
497
- if ((success = (zend_prepare_string_for_scanning (& source_zval , "" ) == SUCCESS ))) {
498
- struct event_context ctx ;
499
- zval token_stream ;
500
- array_init (& token_stream );
501
-
502
- ctx .tokens = & token_stream ;
503
- ctx .token_class = token_class ;
496
+ zend_prepare_string_for_scanning (& source_zval , "" );
497
+ array_init (& token_stream );
504
498
505
- CG (ast ) = NULL ;
506
- CG (ast_arena ) = zend_arena_create (1024 * 32 );
507
- LANG_SCNG (yy_state ) = yycINITIAL ;
508
- LANG_SCNG (on_event ) = on_event ;
509
- LANG_SCNG (on_event_context ) = & ctx ;
499
+ ctx .tokens = & token_stream ;
500
+ ctx .token_class = token_class ;
510
501
511
- if (( success = ( zendparse ( ) == SUCCESS ))) {
512
- ZVAL_COPY_VALUE ( return_value , & token_stream );
513
- } else {
514
- zval_ptr_dtor ( & token_stream ) ;
515
- }
502
+ CG ( ast ) = NULL ;
503
+ CG ( ast_arena ) = zend_arena_create ( 1024 * 32 );
504
+ LANG_SCNG ( yy_state ) = yycINITIAL ;
505
+ LANG_SCNG ( on_event ) = on_event ;
506
+ LANG_SCNG ( on_event_context ) = & ctx ;
516
507
517
- zend_ast_destroy (CG (ast ));
518
- zend_arena_destroy (CG (ast_arena ));
508
+ if ((success = (zendparse () == SUCCESS ))) {
509
+ ZVAL_COPY_VALUE (return_value , & token_stream );
510
+ } else {
511
+ zval_ptr_dtor (& token_stream );
519
512
}
520
513
514
+ zend_ast_destroy (CG (ast ));
515
+ zend_arena_destroy (CG (ast_arena ));
516
+
521
517
/* restore compiler and scanner global states */
522
518
zend_restore_lexical_state (& original_lex_state );
523
519
CG (in_compilation ) = original_in_compilation ;
0 commit comments