Skip to content

Commit 9c42664

Browse files
committed
Fix Tokenizer extension after voidification of zend_prepare_string_for_scanning()
1 parent 29e1fc2 commit 9c42664

File tree

1 file changed

+19
-23
lines changed

1 file changed

+19
-23
lines changed

ext/tokenizer/tokenizer.c

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,7 @@ static zend_bool tokenize(zval *return_value, zend_string *source, zend_class_en
358358
ZVAL_STR_COPY(&source_zval, source);
359359
zend_save_lexical_state(&original_lex_state);
360360

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, "");
365362

366363
LANG_SCNG(yy_state) = yycINITIAL;
367364
zend_hash_init(&interned_strings, 0, NULL, NULL, 0);
@@ -484,6 +481,8 @@ static zend_bool tokenize_parse(
484481
zval *return_value, zend_string *source, zend_class_entry *token_class)
485482
{
486483
zval source_zval;
484+
struct event_context ctx;
485+
zval token_stream;
487486
zend_lex_state original_lex_state;
488487
zend_bool original_in_compilation;
489488
zend_bool success;
@@ -494,30 +493,27 @@ static zend_bool tokenize_parse(
494493
CG(in_compilation) = 1;
495494
zend_save_lexical_state(&original_lex_state);
496495

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);
504498

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;
510501

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;
516507

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);
519512
}
520513

514+
zend_ast_destroy(CG(ast));
515+
zend_arena_destroy(CG(ast_arena));
516+
521517
/* restore compiler and scanner global states */
522518
zend_restore_lexical_state(&original_lex_state);
523519
CG(in_compilation) = original_in_compilation;

0 commit comments

Comments
 (0)