From 80d803753169299fe6a851e68b8718c7f11e00e7 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sat, 24 Aug 2013 02:54:21 -0700 Subject: replaced all the arg formats and Z_STRLEN won't work yet, just initial work to be done --- ext/mbstring/php_mbregex.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'ext/mbstring/php_mbregex.c') diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index 607921ebb6..67dab349bf 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -719,13 +719,13 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase) /* don't bother doing an extended regex with just a number */ } - if (!Z_STRVAL_PP(arg_pattern) || Z_STRLEN_PP(arg_pattern) == 0) { + if (!Z_STRVAL_PP(arg_pattern) || Z_STRSIZE_PP(arg_pattern) == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "empty pattern"); RETVAL_FALSE; goto out; } - re = php_mbregex_compile_pattern(Z_STRVAL_PP(arg_pattern), Z_STRLEN_PP(arg_pattern), options, MBREX(current_mbctype), MBREX(regex_default_syntax) TSRMLS_CC); + re = php_mbregex_compile_pattern(Z_STRVAL_PP(arg_pattern), Z_STRSIZE_PP(arg_pattern), options, MBREX(current_mbctype), MBREX(regex_default_syntax) TSRMLS_CC); if (re == NULL) { RETVAL_FALSE; goto out; @@ -856,7 +856,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp } if (Z_TYPE_PP(arg_pattern_zval) == IS_STRING) { arg_pattern = Z_STRVAL_PP(arg_pattern_zval); - arg_pattern_len = Z_STRLEN_PP(arg_pattern_zval); + arg_pattern_len = Z_STRSIZE_PP(arg_pattern_zval); } else { /* FIXME: this code is not multibyte aware! */ convert_to_long_ex(arg_pattern_zval); @@ -948,7 +948,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp /* result of eval */ convert_to_string(&v); - smart_str_appendl(&out_buf, Z_STRVAL(v), Z_STRLEN(v)); + smart_str_appendl(&out_buf, Z_STRVAL(v), Z_STRSIZE(v)); /* Clean up */ eval_buf.len = 0; zval_dtor(&v); @@ -974,7 +974,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp arg_replace_fci.retval_ptr_ptr = &retval_ptr; if (zend_call_function(&arg_replace_fci, &arg_replace_fci_cache TSRMLS_CC) == SUCCESS && arg_replace_fci.retval_ptr_ptr) { convert_to_string_ex(&retval_ptr); - smart_str_appendl(&out_buf, Z_STRVAL_P(retval_ptr), Z_STRLEN_P(retval_ptr)); + smart_str_appendl(&out_buf, Z_STRVAL_P(retval_ptr), Z_STRSIZE_P(retval_ptr)); eval_buf.len = 0; zval_ptr_dtor(&retval_ptr); } else { @@ -1208,7 +1208,7 @@ _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode) len = 0; if (MBREX(search_str) != NULL && Z_TYPE_P(MBREX(search_str)) == IS_STRING){ str = (OnigUChar *)Z_STRVAL_P(MBREX(search_str)); - len = Z_STRLEN_P(MBREX(search_str)); + len = Z_STRSIZE_P(MBREX(search_str)); } if (MBREX(search_re) == NULL) { @@ -1369,7 +1369,7 @@ PHP_FUNCTION(mb_ereg_search_getregs) array_init(return_value); str = (OnigUChar *)Z_STRVAL_P(MBREX(search_str)); - len = Z_STRLEN_P(MBREX(search_str)); + len = Z_STRSIZE_P(MBREX(search_str)); n = MBREX(search_regs)->num_regs; for (i = 0; i < n; i++) { beg = MBREX(search_regs)->beg[i]; @@ -1404,7 +1404,7 @@ PHP_FUNCTION(mb_ereg_search_setpos) return; } - if (position < 0 || (MBREX(search_str) != NULL && Z_TYPE_P(MBREX(search_str)) == IS_STRING && position >= Z_STRLEN_P(MBREX(search_str)))) { + if (position < 0 || (MBREX(search_str) != NULL && Z_TYPE_P(MBREX(search_str)) == IS_STRING && position >= Z_STRSIZE_P(MBREX(search_str)))) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Position is out of range"); MBREX(search_pos) = 0; RETURN_FALSE; -- cgit v1.2.1 From 9e4a7835c5940658d475558590a869fe3f17d8bc Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sat, 24 Aug 2013 03:24:06 -0700 Subject: fixed the mb_regex* stuff --- ext/mbstring/php_mbregex.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'ext/mbstring/php_mbregex.c') diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index 67dab349bf..f331fab6d7 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -657,10 +657,10 @@ PHP_FUNCTION(mb_regex_encoding) { size_t argc = ZEND_NUM_ARGS(); char *encoding; - int encoding_len; + zend_str_size_int encoding_len; OnigEncoding mbctype; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &encoding, &encoding_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S", &encoding, &encoding_len) == FAILURE) { return; } @@ -691,7 +691,7 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase) { zval **arg_pattern, *array; char *string; - int string_len; + zend_str_size_int string_len; php_mb_regex_t *re; OnigRegion *regs = NULL; int i, match_len, beg, end; @@ -700,7 +700,7 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase) array = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zs|z", &arg_pattern, &string, &string_len, &array) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZS|z", &arg_pattern, &string, &string_len, &array) == FAILURE) { RETURN_FALSE; } @@ -789,16 +789,16 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp zval **arg_pattern_zval; char *arg_pattern; - int arg_pattern_len; + zend_str_size_int arg_pattern_len; char *replace; - int replace_len; + zend_str_size_int replace_len; zend_fcall_info arg_replace_fci; zend_fcall_info_cache arg_replace_fci_cache; char *string; - int string_len; + zend_str_size_int string_len; char *p; php_mb_regex_t *re; @@ -827,10 +827,10 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp eval = 0; { char *option_str = NULL; - int option_str_len = 0; + zend_str_size_int option_str_len = 0; if (!is_callable) { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zss|s", + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZSS|S", &arg_pattern_zval, &replace, &replace_len, &string, &string_len, @@ -838,7 +838,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp RETURN_FALSE; } } else { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zfs|s", + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZfS|S", &arg_pattern_zval, &arg_replace_fci, &arg_replace_fci_cache, &string, &string_len, @@ -1051,17 +1051,17 @@ PHP_FUNCTION(mb_ereg_replace_callback) PHP_FUNCTION(mb_split) { char *arg_pattern; - int arg_pattern_len; + zend_str_size_int arg_pattern_len; php_mb_regex_t *re; OnigRegion *regs = NULL; char *string; OnigUChar *pos, *chunk_pos; - int string_len; + zend_str_size_int string_len; int n, err; long count = -1; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &arg_pattern, &arg_pattern_len, &string, &string_len, &count) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|l", &arg_pattern, &arg_pattern_len, &string, &string_len, &count) == FAILURE) { RETURN_FALSE; } @@ -1130,10 +1130,10 @@ PHP_FUNCTION(mb_split) PHP_FUNCTION(mb_ereg_match) { char *arg_pattern; - int arg_pattern_len; + zend_str_size_int arg_pattern_len; char *string; - int string_len; + zend_str_size_int string_len; php_mb_regex_t *re; OnigSyntaxType *syntax; @@ -1142,9 +1142,9 @@ PHP_FUNCTION(mb_ereg_match) { char *option_str = NULL; - int option_str_len = 0; + zend_str_size_int option_str_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|s", + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|S", &arg_pattern, &arg_pattern_len, &string, &string_len, &option_str, &option_str_len)==FAILURE) { RETURN_FALSE; @@ -1179,13 +1179,13 @@ _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode) { size_t argc = ZEND_NUM_ARGS(); char *arg_pattern, *arg_options; - int arg_pattern_len, arg_options_len; + zend_str_size_int arg_pattern_len, arg_options_len; int n, i, err, pos, len, beg, end; OnigOptionType option; OnigUChar *str; OnigSyntaxType *syntax; - if (zend_parse_parameters(argc TSRMLS_CC, "|ss", &arg_pattern, &arg_pattern_len, &arg_options, &arg_options_len) == FAILURE) { + if (zend_parse_parameters(argc TSRMLS_CC, "|SS", &arg_pattern, &arg_pattern_len, &arg_options, &arg_options_len) == FAILURE) { return; } @@ -1310,11 +1310,11 @@ PHP_FUNCTION(mb_ereg_search_init) size_t argc = ZEND_NUM_ARGS(); zval *arg_str; char *arg_pattern = NULL, *arg_options = NULL; - int arg_pattern_len = 0, arg_options_len = 0; + zend_str_size_int arg_pattern_len = 0, arg_options_len = 0; OnigSyntaxType *syntax = NULL; OnigOptionType option; - if (zend_parse_parameters(argc TSRMLS_CC, "z|ss", &arg_str, &arg_pattern, &arg_pattern_len, &arg_options, &arg_options_len) == FAILURE) { + if (zend_parse_parameters(argc TSRMLS_CC, "z|SS", &arg_str, &arg_pattern, &arg_pattern_len, &arg_options, &arg_options_len) == FAILURE) { return; } @@ -1436,10 +1436,10 @@ PHP_FUNCTION(mb_regex_set_options) OnigOptionType opt; OnigSyntaxType *syntax; char *string = NULL; - int string_len; + zend_str_size_int string_len; char buf[16]; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S", &string, &string_len) == FAILURE) { RETURN_FALSE; } -- cgit v1.2.1 From f88c30507c2a3a3f376c284117ff505e1cf8b234 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 21 Nov 2013 18:33:16 +0100 Subject: fixed param parsing in mbstring --- ext/mbstring/php_mbregex.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ext/mbstring/php_mbregex.c') diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index f331fab6d7..17ae2c1e81 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -1059,9 +1059,9 @@ PHP_FUNCTION(mb_split) zend_str_size_int string_len; int n, err; - long count = -1; + php_int_t count = -1; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|l", &arg_pattern, &arg_pattern_len, &string, &string_len, &count) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|i", &arg_pattern, &arg_pattern_len, &string, &string_len, &count) == FAILURE) { RETURN_FALSE; } @@ -1398,9 +1398,9 @@ PHP_FUNCTION(mb_ereg_search_getpos) Set search start position */ PHP_FUNCTION(mb_ereg_search_setpos) { - long position; + php_int_t position; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &position) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &position) == FAILURE) { return; } -- cgit v1.2.1 From b1abe4ca21e10b04a8bae2d00e8113f4b2b02567 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 18 Dec 2013 14:46:44 -0800 Subject: mass replacement for zend_size_t/php_size_t --- ext/mbstring/php_mbregex.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'ext/mbstring/php_mbregex.c') diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index 17ae2c1e81..cff5e39623 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -657,7 +657,7 @@ PHP_FUNCTION(mb_regex_encoding) { size_t argc = ZEND_NUM_ARGS(); char *encoding; - zend_str_size_int encoding_len; + php_size_t encoding_len; OnigEncoding mbctype; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S", &encoding, &encoding_len) == FAILURE) { @@ -691,7 +691,7 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase) { zval **arg_pattern, *array; char *string; - zend_str_size_int string_len; + php_size_t string_len; php_mb_regex_t *re; OnigRegion *regs = NULL; int i, match_len, beg, end; @@ -789,16 +789,16 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp zval **arg_pattern_zval; char *arg_pattern; - zend_str_size_int arg_pattern_len; + php_size_t arg_pattern_len; char *replace; - zend_str_size_int replace_len; + php_size_t replace_len; zend_fcall_info arg_replace_fci; zend_fcall_info_cache arg_replace_fci_cache; char *string; - zend_str_size_int string_len; + php_size_t string_len; char *p; php_mb_regex_t *re; @@ -827,7 +827,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp eval = 0; { char *option_str = NULL; - zend_str_size_int option_str_len = 0; + php_size_t option_str_len = 0; if (!is_callable) { if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZSS|S", @@ -1051,12 +1051,12 @@ PHP_FUNCTION(mb_ereg_replace_callback) PHP_FUNCTION(mb_split) { char *arg_pattern; - zend_str_size_int arg_pattern_len; + php_size_t arg_pattern_len; php_mb_regex_t *re; OnigRegion *regs = NULL; char *string; OnigUChar *pos, *chunk_pos; - zend_str_size_int string_len; + php_size_t string_len; int n, err; php_int_t count = -1; @@ -1130,10 +1130,10 @@ PHP_FUNCTION(mb_split) PHP_FUNCTION(mb_ereg_match) { char *arg_pattern; - zend_str_size_int arg_pattern_len; + php_size_t arg_pattern_len; char *string; - zend_str_size_int string_len; + php_size_t string_len; php_mb_regex_t *re; OnigSyntaxType *syntax; @@ -1142,7 +1142,7 @@ PHP_FUNCTION(mb_ereg_match) { char *option_str = NULL; - zend_str_size_int option_str_len = 0; + php_size_t option_str_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|S", &arg_pattern, &arg_pattern_len, &string, &string_len, @@ -1179,7 +1179,7 @@ _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode) { size_t argc = ZEND_NUM_ARGS(); char *arg_pattern, *arg_options; - zend_str_size_int arg_pattern_len, arg_options_len; + php_size_t arg_pattern_len, arg_options_len; int n, i, err, pos, len, beg, end; OnigOptionType option; OnigUChar *str; @@ -1310,7 +1310,7 @@ PHP_FUNCTION(mb_ereg_search_init) size_t argc = ZEND_NUM_ARGS(); zval *arg_str; char *arg_pattern = NULL, *arg_options = NULL; - zend_str_size_int arg_pattern_len = 0, arg_options_len = 0; + php_size_t arg_pattern_len = 0, arg_options_len = 0; OnigSyntaxType *syntax = NULL; OnigOptionType option; @@ -1436,7 +1436,7 @@ PHP_FUNCTION(mb_regex_set_options) OnigOptionType opt; OnigSyntaxType *syntax; char *string = NULL; - zend_str_size_int string_len; + php_size_t string_len; char buf[16]; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S", -- cgit v1.2.1 From f58d0b35edf25a8f39fad6bd5e0e4eeb5cdfe9a7 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 19 Dec 2013 05:07:37 -0800 Subject: massive update semantical LONG vs INT replacements --- ext/mbstring/php_mbregex.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'ext/mbstring/php_mbregex.c') diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index cff5e39623..2c779b2407 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -713,7 +713,7 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase) if (Z_TYPE_PP(arg_pattern) != IS_STRING) { /* we convert numbers to integers and treat them as a string */ if (Z_TYPE_PP(arg_pattern) == IS_DOUBLE) { - convert_to_long_ex(arg_pattern); /* get rid of decimal places */ + convert_to_int_ex(arg_pattern); /* get rid of decimal places */ } convert_to_string_ex(arg_pattern); /* don't bother doing an extended regex with just a number */ @@ -759,7 +759,7 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase) if (match_len == 0) { match_len = 1; } - RETVAL_LONG(match_len); + RETVAL_INT(match_len); out: if (regs != NULL) { onig_region_free(regs, 1); @@ -859,8 +859,8 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp arg_pattern_len = Z_STRSIZE_PP(arg_pattern_zval); } else { /* FIXME: this code is not multibyte aware! */ - convert_to_long_ex(arg_pattern_zval); - pat_buf[0] = (char)Z_LVAL_PP(arg_pattern_zval); + convert_to_int_ex(arg_pattern_zval); + pat_buf[0] = (char)Z_IVAL_PP(arg_pattern_zval); pat_buf[1] = '\0'; arg_pattern = pat_buf; @@ -1390,7 +1390,7 @@ PHP_FUNCTION(mb_ereg_search_getregs) Get search start position */ PHP_FUNCTION(mb_ereg_search_getpos) { - RETVAL_LONG(MBREX(search_pos)); + RETVAL_INT(MBREX(search_pos)); } /* }}} */ -- cgit v1.2.1 From 6125278290aa3ab2ac0a1ad22116b9d363b3e915 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 19 Dec 2013 08:40:41 -0800 Subject: more semantical replacements LONG vs. INT --- ext/mbstring/php_mbregex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ext/mbstring/php_mbregex.c') diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index 2c779b2407..10f1c608d8 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -1244,8 +1244,8 @@ _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode) array_init(return_value); beg = MBREX(search_regs)->beg[0]; end = MBREX(search_regs)->end[0]; - add_next_index_long(return_value, beg); - add_next_index_long(return_value, end - beg); + add_next_index_int(return_value, beg); + add_next_index_int(return_value, end - beg); break; case 2: array_init(return_value); -- cgit v1.2.1 From 63d3f0b844b3a5f1c94be3c97bca29235dc2b3fc Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 19 Aug 2014 08:07:31 +0200 Subject: basic macro replacements, all at once --- ext/mbstring/php_mbregex.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'ext/mbstring/php_mbregex.c') diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index ab03306f14..4c30eee8a9 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -711,19 +711,19 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase) if (Z_TYPE_P(arg_pattern) != IS_STRING) { /* we convert numbers to integers and treat them as a string */ if (Z_TYPE_P(arg_pattern) == IS_DOUBLE) { - convert_to_long_ex(arg_pattern); /* get rid of decimal places */ + convert_to_int_ex(arg_pattern); /* get rid of decimal places */ } convert_to_string_ex(arg_pattern); /* don't bother doing an extended regex with just a number */ } - if (!Z_STRVAL_P(arg_pattern) || Z_STRLEN_P(arg_pattern) == 0) { + if (!Z_STRVAL_P(arg_pattern) || Z_STRSIZE_P(arg_pattern) == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "empty pattern"); RETVAL_FALSE; goto out; } - re = php_mbregex_compile_pattern(Z_STRVAL_P(arg_pattern), Z_STRLEN_P(arg_pattern), options, MBREX(current_mbctype), MBREX(regex_default_syntax) TSRMLS_CC); + re = php_mbregex_compile_pattern(Z_STRVAL_P(arg_pattern), Z_STRSIZE_P(arg_pattern), options, MBREX(current_mbctype), MBREX(regex_default_syntax) TSRMLS_CC); if (re == NULL) { RETVAL_FALSE; goto out; @@ -758,7 +758,7 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase) if (match_len == 0) { match_len = 1; } - RETVAL_LONG(match_len); + RETVAL_INT(match_len); out: if (regs != NULL) { onig_region_free(regs, 1); @@ -855,11 +855,11 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp } if (Z_TYPE_P(arg_pattern_zval) == IS_STRING) { arg_pattern = Z_STRVAL_P(arg_pattern_zval); - arg_pattern_len = Z_STRLEN_P(arg_pattern_zval); + arg_pattern_len = Z_STRSIZE_P(arg_pattern_zval); } else { /* FIXME: this code is not multibyte aware! */ - convert_to_long_ex(arg_pattern_zval); - pat_buf[0] = (char)Z_LVAL_P(arg_pattern_zval); + convert_to_int_ex(arg_pattern_zval); + pat_buf[0] = (char)Z_IVAL_P(arg_pattern_zval); pat_buf[1] = '\0'; arg_pattern = pat_buf; @@ -947,7 +947,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp /* result of eval */ convert_to_string(&v); - smart_str_appendl(&out_buf, Z_STRVAL(v), Z_STRLEN(v)); + smart_str_appendl(&out_buf, Z_STRVAL(v), Z_STRSIZE(v)); /* Clean up */ eval_buf.s->len = 0; zval_dtor(&v); @@ -971,7 +971,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp if (zend_call_function(&arg_replace_fci, &arg_replace_fci_cache TSRMLS_CC) == SUCCESS && !Z_ISUNDEF(retval)) { convert_to_string_ex(&retval); - smart_str_appendl(&out_buf, Z_STRVAL(retval), Z_STRLEN(retval)); + smart_str_appendl(&out_buf, Z_STRVAL(retval), Z_STRSIZE(retval)); if (eval_buf.s) { eval_buf.s->len = 0; } @@ -1209,7 +1209,7 @@ _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode) len = 0; if (!Z_ISUNDEF(MBREX(search_str)) && Z_TYPE(MBREX(search_str)) == IS_STRING){ str = (OnigUChar *)Z_STRVAL(MBREX(search_str)); - len = Z_STRLEN(MBREX(search_str)); + len = Z_STRSIZE(MBREX(search_str)); } if (MBREX(search_re) == NULL) { @@ -1245,8 +1245,8 @@ _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode) array_init(return_value); beg = MBREX(search_regs)->beg[0]; end = MBREX(search_regs)->end[0]; - add_next_index_long(return_value, beg); - add_next_index_long(return_value, end - beg); + add_next_index_int(return_value, beg); + add_next_index_int(return_value, end - beg); break; case 2: array_init(return_value); @@ -1368,7 +1368,7 @@ PHP_FUNCTION(mb_ereg_search_getregs) array_init(return_value); str = (OnigUChar *)Z_STRVAL(MBREX(search_str)); - len = Z_STRLEN(MBREX(search_str)); + len = Z_STRSIZE(MBREX(search_str)); n = MBREX(search_regs)->num_regs; for (i = 0; i < n; i++) { beg = MBREX(search_regs)->beg[i]; @@ -1389,7 +1389,7 @@ PHP_FUNCTION(mb_ereg_search_getregs) Get search start position */ PHP_FUNCTION(mb_ereg_search_getpos) { - RETVAL_LONG(MBREX(search_pos)); + RETVAL_INT(MBREX(search_pos)); } /* }}} */ @@ -1403,7 +1403,7 @@ PHP_FUNCTION(mb_ereg_search_setpos) return; } - if (position < 0 || (!Z_ISUNDEF(MBREX(search_str)) && Z_TYPE(MBREX(search_str)) == IS_STRING && position >= Z_STRLEN(MBREX(search_str)))) { + if (position < 0 || (!Z_ISUNDEF(MBREX(search_str)) && Z_TYPE(MBREX(search_str)) == IS_STRING && position >= Z_STRSIZE(MBREX(search_str)))) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Position is out of range"); MBREX(search_pos) = 0; RETURN_FALSE; -- cgit v1.2.1 From 6428b498519442833afcd032f6648251d8b199fc Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 19 Aug 2014 19:42:16 +0200 Subject: ported ext/mbstring --- ext/mbstring/php_mbregex.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ext/mbstring/php_mbregex.c') diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index 4c30eee8a9..baf0a2d44a 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -1060,9 +1060,9 @@ PHP_FUNCTION(mb_split) int string_len; int n, err; - long count = -1; + php_int_t count = -1; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &arg_pattern, &arg_pattern_len, &string, &string_len, &count) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|i", &arg_pattern, &arg_pattern_len, &string, &string_len, &count) == FAILURE) { RETURN_FALSE; } @@ -1397,9 +1397,9 @@ PHP_FUNCTION(mb_ereg_search_getpos) Set search start position */ PHP_FUNCTION(mb_ereg_search_setpos) { - long position; + php_int_t position; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &position) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &position) == FAILURE) { return; } -- cgit v1.2.1 From c3e3c98ec666812daaaca896cf5ef758a8a6df14 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 25 Aug 2014 19:24:55 +0200 Subject: master renames phase 1 --- ext/mbstring/php_mbregex.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'ext/mbstring/php_mbregex.c') diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index baf0a2d44a..2237a318fe 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -717,13 +717,13 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase) /* don't bother doing an extended regex with just a number */ } - if (!Z_STRVAL_P(arg_pattern) || Z_STRSIZE_P(arg_pattern) == 0) { + if (!Z_STRVAL_P(arg_pattern) || Z_STRLEN_P(arg_pattern) == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "empty pattern"); RETVAL_FALSE; goto out; } - re = php_mbregex_compile_pattern(Z_STRVAL_P(arg_pattern), Z_STRSIZE_P(arg_pattern), options, MBREX(current_mbctype), MBREX(regex_default_syntax) TSRMLS_CC); + re = php_mbregex_compile_pattern(Z_STRVAL_P(arg_pattern), Z_STRLEN_P(arg_pattern), options, MBREX(current_mbctype), MBREX(regex_default_syntax) TSRMLS_CC); if (re == NULL) { RETVAL_FALSE; goto out; @@ -758,7 +758,7 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase) if (match_len == 0) { match_len = 1; } - RETVAL_INT(match_len); + RETVAL_LONG(match_len); out: if (regs != NULL) { onig_region_free(regs, 1); @@ -855,11 +855,11 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp } if (Z_TYPE_P(arg_pattern_zval) == IS_STRING) { arg_pattern = Z_STRVAL_P(arg_pattern_zval); - arg_pattern_len = Z_STRSIZE_P(arg_pattern_zval); + arg_pattern_len = Z_STRLEN_P(arg_pattern_zval); } else { /* FIXME: this code is not multibyte aware! */ convert_to_int_ex(arg_pattern_zval); - pat_buf[0] = (char)Z_IVAL_P(arg_pattern_zval); + pat_buf[0] = (char)Z_LVAL_P(arg_pattern_zval); pat_buf[1] = '\0'; arg_pattern = pat_buf; @@ -947,7 +947,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp /* result of eval */ convert_to_string(&v); - smart_str_appendl(&out_buf, Z_STRVAL(v), Z_STRSIZE(v)); + smart_str_appendl(&out_buf, Z_STRVAL(v), Z_STRLEN(v)); /* Clean up */ eval_buf.s->len = 0; zval_dtor(&v); @@ -971,7 +971,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp if (zend_call_function(&arg_replace_fci, &arg_replace_fci_cache TSRMLS_CC) == SUCCESS && !Z_ISUNDEF(retval)) { convert_to_string_ex(&retval); - smart_str_appendl(&out_buf, Z_STRVAL(retval), Z_STRSIZE(retval)); + smart_str_appendl(&out_buf, Z_STRVAL(retval), Z_STRLEN(retval)); if (eval_buf.s) { eval_buf.s->len = 0; } @@ -1060,9 +1060,9 @@ PHP_FUNCTION(mb_split) int string_len; int n, err; - php_int_t count = -1; + zend_long count = -1; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|i", &arg_pattern, &arg_pattern_len, &string, &string_len, &count) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &arg_pattern, &arg_pattern_len, &string, &string_len, &count) == FAILURE) { RETURN_FALSE; } @@ -1209,7 +1209,7 @@ _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode) len = 0; if (!Z_ISUNDEF(MBREX(search_str)) && Z_TYPE(MBREX(search_str)) == IS_STRING){ str = (OnigUChar *)Z_STRVAL(MBREX(search_str)); - len = Z_STRSIZE(MBREX(search_str)); + len = Z_STRLEN(MBREX(search_str)); } if (MBREX(search_re) == NULL) { @@ -1245,8 +1245,8 @@ _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode) array_init(return_value); beg = MBREX(search_regs)->beg[0]; end = MBREX(search_regs)->end[0]; - add_next_index_int(return_value, beg); - add_next_index_int(return_value, end - beg); + add_next_index_long(return_value, beg); + add_next_index_long(return_value, end - beg); break; case 2: array_init(return_value); @@ -1368,7 +1368,7 @@ PHP_FUNCTION(mb_ereg_search_getregs) array_init(return_value); str = (OnigUChar *)Z_STRVAL(MBREX(search_str)); - len = Z_STRSIZE(MBREX(search_str)); + len = Z_STRLEN(MBREX(search_str)); n = MBREX(search_regs)->num_regs; for (i = 0; i < n; i++) { beg = MBREX(search_regs)->beg[i]; @@ -1389,7 +1389,7 @@ PHP_FUNCTION(mb_ereg_search_getregs) Get search start position */ PHP_FUNCTION(mb_ereg_search_getpos) { - RETVAL_INT(MBREX(search_pos)); + RETVAL_LONG(MBREX(search_pos)); } /* }}} */ @@ -1397,13 +1397,13 @@ PHP_FUNCTION(mb_ereg_search_getpos) Set search start position */ PHP_FUNCTION(mb_ereg_search_setpos) { - php_int_t position; + zend_long position; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &position) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &position) == FAILURE) { return; } - if (position < 0 || (!Z_ISUNDEF(MBREX(search_str)) && Z_TYPE(MBREX(search_str)) == IS_STRING && position >= Z_STRSIZE(MBREX(search_str)))) { + if (position < 0 || (!Z_ISUNDEF(MBREX(search_str)) && Z_TYPE(MBREX(search_str)) == IS_STRING && position >= Z_STRLEN(MBREX(search_str)))) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Position is out of range"); MBREX(search_pos) = 0; RETURN_FALSE; -- cgit v1.2.1 From af59e92b24c8f624672720d47ef65bd8457728b9 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 25 Aug 2014 21:51:49 +0200 Subject: master renames phase 7 --- ext/mbstring/php_mbregex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ext/mbstring/php_mbregex.c') diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index 2237a318fe..35c741bb37 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -711,7 +711,7 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase) if (Z_TYPE_P(arg_pattern) != IS_STRING) { /* we convert numbers to integers and treat them as a string */ if (Z_TYPE_P(arg_pattern) == IS_DOUBLE) { - convert_to_int_ex(arg_pattern); /* get rid of decimal places */ + convert_to_long_ex(arg_pattern); /* get rid of decimal places */ } convert_to_string_ex(arg_pattern); /* don't bother doing an extended regex with just a number */ @@ -858,7 +858,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp arg_pattern_len = Z_STRLEN_P(arg_pattern_zval); } else { /* FIXME: this code is not multibyte aware! */ - convert_to_int_ex(arg_pattern_zval); + convert_to_long_ex(arg_pattern_zval); pat_buf[0] = (char)Z_LVAL_P(arg_pattern_zval); pat_buf[1] = '\0'; -- cgit v1.2.1 From 3234480827b27ff5d3469a732167afd289632a96 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 27 Aug 2014 15:31:48 +0200 Subject: first show to make 's' work with size_t --- ext/mbstring/php_mbregex.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'ext/mbstring/php_mbregex.c') diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index 35c741bb37..4977c9e9cd 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -689,7 +689,7 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase) { zval *arg_pattern, *array; char *string; - int string_len; + size_t string_len; php_mb_regex_t *re; OnigRegion *regs = NULL; int i, match_len, beg, end; @@ -788,16 +788,16 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp zval *arg_pattern_zval; char *arg_pattern; - int arg_pattern_len; + size_t arg_pattern_len; char *replace; - int replace_len; + size_t replace_len; zend_fcall_info arg_replace_fci; zend_fcall_info_cache arg_replace_fci_cache; char *string; - int string_len; + size_t string_len; char *p; php_mb_regex_t *re; @@ -826,7 +826,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp eval = 0; { char *option_str = NULL; - int option_str_len = 0; + size_t option_str_len = 0; if (!is_callable) { if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zss|s", @@ -1052,12 +1052,12 @@ PHP_FUNCTION(mb_ereg_replace_callback) PHP_FUNCTION(mb_split) { char *arg_pattern; - int arg_pattern_len; + size_t arg_pattern_len; php_mb_regex_t *re; OnigRegion *regs = NULL; char *string; OnigUChar *pos, *chunk_pos; - int string_len; + size_t string_len; int n, err; zend_long count = -1; @@ -1131,10 +1131,10 @@ PHP_FUNCTION(mb_split) PHP_FUNCTION(mb_ereg_match) { char *arg_pattern; - int arg_pattern_len; + size_t arg_pattern_len; char *string; - int string_len; + size_t string_len; php_mb_regex_t *re; OnigSyntaxType *syntax; @@ -1143,7 +1143,7 @@ PHP_FUNCTION(mb_ereg_match) { char *option_str = NULL; - int option_str_len = 0; + size_t option_str_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|s", &arg_pattern, &arg_pattern_len, &string, &string_len, @@ -1180,7 +1180,7 @@ _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode) { size_t argc = ZEND_NUM_ARGS(); char *arg_pattern, *arg_options; - int arg_pattern_len, arg_options_len; + size_t arg_pattern_len, arg_options_len; int n, i, err, pos, len, beg, end; OnigOptionType option; OnigUChar *str; @@ -1435,7 +1435,7 @@ PHP_FUNCTION(mb_regex_set_options) OnigOptionType opt; OnigSyntaxType *syntax; char *string = NULL; - int string_len; + size_t string_len; char buf[16]; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", -- cgit v1.2.1 From 6db8d4f829553f61822a794f94c55270e5478a13 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 27 Aug 2014 19:25:28 +0200 Subject: 's' works with size_t round 3 --- ext/mbstring/php_mbregex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ext/mbstring/php_mbregex.c') diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index 4977c9e9cd..9628ee2526 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -655,7 +655,7 @@ PHP_FUNCTION(mb_regex_encoding) { size_t argc = ZEND_NUM_ARGS(); char *encoding; - int encoding_len; + size_t encoding_len; OnigEncoding mbctype; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &encoding, &encoding_len) == FAILURE) { @@ -1311,7 +1311,7 @@ PHP_FUNCTION(mb_ereg_search_init) size_t argc = ZEND_NUM_ARGS(); zval *arg_str; char *arg_pattern = NULL, *arg_options = NULL; - int arg_pattern_len = 0, arg_options_len = 0; + size_t arg_pattern_len = 0, arg_options_len = 0; OnigSyntaxType *syntax = NULL; OnigOptionType option; -- cgit v1.2.1