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 From fba6e5a8cb3dd9de4478d3f2098520402e868073 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 15 Sep 2014 21:10:18 +0200 Subject: fix signed/unsigned mismatch warnings --- 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 9628ee2526..d78131fff5 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -1081,7 +1081,7 @@ PHP_FUNCTION(mb_split) err = 0; regs = onig_region_new(); /* churn through str, generating array entries as we go */ - while (count != 0 && (pos - (OnigUChar *)string) < string_len) { + while (count != 0 && (pos - (OnigUChar *)string) < (ptrdiff_t)string_len) { int beg, end; err = onig_search(re, (OnigUChar *)string, (OnigUChar *)(string + string_len), pos, (OnigUChar *)(string + string_len), regs, 0); if (err < 0) { @@ -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 >= (zend_long)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 49a6b485a0173b855e31ce8dc7800ac1672b6981 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 16 Sep 2014 12:48:15 +0200 Subject: redo the fix casting to size_t where applicable --- ext/mbstring/php_mbregex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/mbstring/php_mbregex.c') diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index d78131fff5..864d50a5ce 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -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 >= (zend_long)Z_STRLEN(MBREX(search_str)))) { + if (position < 0 || (!Z_ISUNDEF(MBREX(search_str)) && Z_TYPE(MBREX(search_str)) == IS_STRING && (size_t)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 bf7203e1e02f1313a3fd8beb3bbdb102a77f1388 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 19 Sep 2014 11:23:23 +0200 Subject: fix empty string check --- ext/mbstring/php_mbregex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/mbstring/php_mbregex.c') diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index 864d50a5ce..62b3e962f6 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -717,7 +717,7 @@ 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_STRLEN_P(arg_pattern) == 0) { + if (!Z_STRVAL_P(arg_pattern)[0] || Z_STRLEN_P(arg_pattern) == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "empty pattern"); RETVAL_FALSE; goto out; -- cgit v1.2.1 From 469c9bdb392ab0d8c91d7e2ab5ff93c650489143 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 19 Sep 2014 15:04:06 +0200 Subject: simplify condition --- ext/mbstring/php_mbregex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/mbstring/php_mbregex.c') diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index 62b3e962f6..36147e972c 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -717,7 +717,7 @@ 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)[0] || Z_STRLEN_P(arg_pattern) == 0) { + if (Z_STRLEN_P(arg_pattern) == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "empty pattern"); RETVAL_FALSE; goto out; -- cgit v1.2.1 From d0cb715373c3fbe9dc095378ec5ed8c71f799f67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Schl=C3=BCter?= Date: Fri, 19 Sep 2014 18:33:14 +0200 Subject: s/PHP 5/PHP 7/ --- ext/mbstring/php_mbregex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/mbstring/php_mbregex.c') diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index 36147e972c..246f2223d1 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -1,6 +1,6 @@ /* +----------------------------------------------------------------------+ - | PHP Version 5 | + | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ -- cgit v1.2.1 From e33f3d3b7c9a69fe069484045a27d282aa98b00e Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 20 Sep 2014 22:42:02 +0200 Subject: Move smart_str implementation into Zend/ So we can use it there as well... For now I've retained the zend_smart_str_public.h header, though it would probably be better to just move that one struct into zend_types.h. --- ext/mbstring/php_mbregex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/mbstring/php_mbregex.c') diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index 246f2223d1..de0bc768ad 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -28,7 +28,7 @@ #if HAVE_MBREGEX -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "ext/standard/info.h" #include "php_mbregex.h" #include "mbstring.h" -- cgit v1.2.1 From 43f1c94ddace679cac008b674ef983199a951542 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 9 Oct 2014 12:51:05 +0200 Subject: Review a few more SEPARATE_ZVAL_IF_NOT_REF usages --- ext/mbstring/php_mbregex.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'ext/mbstring/php_mbregex.c') diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index de0bc768ad..8be88c3fee 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -1343,8 +1343,7 @@ PHP_FUNCTION(mb_ereg_search_init) zval_ptr_dtor(&MBREX(search_str)); } - ZVAL_COPY(&MBREX(search_str), arg_str); - SEPARATE_ZVAL_IF_NOT_REF(&MBREX(search_str)); + ZVAL_DUP(&MBREX(search_str), arg_str); MBREX(search_pos) = 0; -- cgit v1.2.1