summaryrefslogtreecommitdiff
path: root/ext/tokenizer/tokenizer.c
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2014-04-10 11:44:45 +0200
committerNikita Popov <nikic@php.net>2014-04-10 11:44:45 +0200
commitc6eba255718269bbcdc05046fa21af2b70d407e9 (patch)
treeeb23c31ae1f911487a97db9ca55bffcabba5c3f8 /ext/tokenizer/tokenizer.c
parenta6be32f59a0f0ae7088f5afc1e354e185a481130 (diff)
downloadphp-git-c6eba255718269bbcdc05046fa21af2b70d407e9.tar.gz
Port tokenizer extension
Diffstat (limited to 'ext/tokenizer/tokenizer.c')
-rw-r--r--ext/tokenizer/tokenizer.c44
1 files changed, 20 insertions, 24 deletions
diff --git a/ext/tokenizer/tokenizer.c b/ext/tokenizer/tokenizer.c
index 8e2aaab923..a9830910af 100644
--- a/ext/tokenizer/tokenizer.c
+++ b/ext/tokenizer/tokenizer.c
@@ -104,7 +104,7 @@ PHP_MINFO_FUNCTION(tokenizer)
static void tokenize(zval *return_value TSRMLS_DC)
{
zval token;
- zval *keyword;
+ zval keyword;
int token_type;
zend_bool destroy;
int token_line = 1;
@@ -130,18 +130,17 @@ static void tokenize(zval *return_value TSRMLS_DC)
}
if (token_type >= 256) {
- MAKE_STD_ZVAL(keyword);
- array_init(keyword);
- add_next_index_long(keyword, token_type);
+ array_init(&keyword);
+ add_next_index_long(&keyword, token_type);
if (token_type == T_END_HEREDOC) {
if (CG(increment_lineno)) {
token_line = ++CG(zend_lineno);
CG(increment_lineno) = 0;
}
}
- add_next_index_stringl(keyword, (char *)zendtext, zendleng, 1);
- add_next_index_long(keyword, token_line);
- add_next_index_zval(return_value, keyword);
+ add_next_index_stringl(&keyword, (char *)zendtext, zendleng, 1);
+ add_next_index_long(&keyword, token_line);
+ add_next_index_zval(return_value, &keyword);
} else {
add_next_index_stringl(return_value, (char *)zendtext, zendleng, 1);
}
@@ -158,12 +157,11 @@ static void tokenize(zval *return_value TSRMLS_DC)
) {
// fetch the rest into a T_INLINE_HTML
if (zendcursor != zendlimit) {
- MAKE_STD_ZVAL(keyword);
- array_init(keyword);
- add_next_index_long(keyword, T_INLINE_HTML);
- add_next_index_stringl(keyword, (char *)zendcursor, zendlimit - zendcursor, 1);
- add_next_index_long(keyword, token_line);
- add_next_index_zval(return_value, keyword);
+ array_init(&keyword);
+ add_next_index_long(&keyword, T_INLINE_HTML);
+ add_next_index_stringl(&keyword, (char *)zendcursor, zendlimit - zendcursor, 1);
+ add_next_index_long(&keyword, token_line);
+ add_next_index_zval(return_value, &keyword);
}
break;
}
@@ -179,20 +177,18 @@ static void tokenize(zval *return_value TSRMLS_DC)
*/
PHP_FUNCTION(token_get_all)
{
- char *source = NULL;
- int argc = ZEND_NUM_ARGS();
- int source_len;
- zval source_z;
+ zend_string *source;
+ zval source_zval;
zend_lex_state original_lex_state;
- if (zend_parse_parameters(argc TSRMLS_CC, "s", &source, &source_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &source) == FAILURE) {
return;
}
- ZVAL_STRINGL(&source_z, source, source_len, 1);
+ ZVAL_STR(&source_zval, STR_COPY(source));
zend_save_lexical_state(&original_lex_state TSRMLS_CC);
- if (zend_prepare_string_for_scanning(&source_z, "" TSRMLS_CC) == FAILURE) {
+ if (zend_prepare_string_for_scanning(&source_zval, "" TSRMLS_CC) == FAILURE) {
zend_restore_lexical_state(&original_lex_state TSRMLS_CC);
RETURN_FALSE;
}
@@ -202,7 +198,7 @@ PHP_FUNCTION(token_get_all)
tokenize(return_value TSRMLS_CC);
zend_restore_lexical_state(&original_lex_state TSRMLS_CC);
- zval_dtor(&source_z);
+ zval_dtor(&source_zval);
}
/* }}} */
@@ -210,13 +206,13 @@ PHP_FUNCTION(token_get_all)
*/
PHP_FUNCTION(token_name)
{
- int argc = ZEND_NUM_ARGS();
long type;
- if (zend_parse_parameters(argc TSRMLS_CC, "l", &type) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &type) == FAILURE) {
return;
}
- RETVAL_STRING(get_token_type_name(type), 1);
+
+ RETVAL_STRING(get_token_type_name(type));
}
/* }}} */