Skip to content

Commit 5d36f8a

Browse files
committed
Reviews
1 parent c50d3a4 commit 5d36f8a

File tree

5 files changed

+17
-19
lines changed

5 files changed

+17
-19
lines changed

ext/mbstring/php_mbregex.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -661,10 +661,10 @@ static bool _php_mb_regex_init_options(const char *parg, size_t narg, OnigOption
661661
*syntax = ONIG_SYNTAX_POSIX_EXTENDED;
662662
break;
663663
case 'e':
664-
zend_argument_value_error(option_arg_num, "option 'e' is not supported");
664+
zend_value_error("Option \"e\" is not supported");
665665
return false;
666666
default:
667-
// TODO Unsupported ValueError
667+
zend_value_error("Option \"%c\" is not supported", c);
668668
break;
669669
}
670670
}
@@ -929,7 +929,7 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase)
929929
string_len,
930930
php_mb_regex_get_mbctype_encoding()
931931
)) {
932-
zend_argument_value_error(2, "must be a valid string in '%s'", php_mb_regex_get_mbctype());
932+
zend_argument_value_error(2, "must be a valid string in \"%s\" encoding", php_mb_regex_get_mbctype());
933933
RETURN_THROWS();
934934
}
935935

@@ -1050,8 +1050,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp
10501050
}
10511051

10521052
if (!php_mb_check_encoding(string, string_len, enc)) {
1053-
zend_argument_value_error(3, "must be a valid string in '%s'", php_mb_regex_get_mbctype());
1054-
RETURN_THROWS();
1053+
RETURN_NULL();
10551054
}
10561055

10571056
if (option_str != NULL) {
@@ -1068,7 +1067,6 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp
10681067
/* create regex pattern buffer */
10691068
re = php_mbregex_compile_pattern(arg_pattern, arg_pattern_len, options, syntax);
10701069
if (re == NULL) {
1071-
// Should this be considered an error instead?
10721070
RETURN_FALSE;
10731071
}
10741072

@@ -1366,7 +1364,7 @@ static void _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mod
13661364
}
13671365

13681366
if (arg_options) {
1369-
_php_mb_regex_init_options(arg_options, arg_options_len, &option, &syntax, NULL);
1367+
_php_mb_regex_init_options(arg_options, arg_options_len, &option, &syntax, 2);
13701368
} else {
13711369
option |= MBREX(regex_default_options);
13721370
syntax = MBREX(regex_default_syntax);
@@ -1505,7 +1503,7 @@ PHP_FUNCTION(mb_ereg_search_init)
15051503

15061504
if (arg_options) {
15071505
option = 0;
1508-
_php_mb_regex_init_options(arg_options, arg_options_len, &option, &syntax, NULL);
1506+
_php_mb_regex_init_options(arg_options, arg_options_len, &option, &syntax, 3);
15091507
} else {
15101508
option = MBREX(regex_default_options);
15111509
syntax = MBREX(regex_default_syntax);

ext/mbstring/tests/bug69151.phpt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ try {
1616
}
1717
var_dump([] === $matches);
1818

19-
try {
20-
var_dump(NULL === mb_ereg_replace('.', "\\0", $str));
21-
} catch (\ValueError $e) {
22-
echo $e->getMessage() . \PHP_EOL;
23-
}
19+
var_dump(NULL === mb_ereg_replace('.', "\\0", $str));
2420

2521
try {
2622
var_dump(false === mb_ereg_search_init("\x80", '.'));
@@ -30,8 +26,8 @@ try {
3026
var_dump(false === mb_ereg_search());
3127
?>
3228
--EXPECT--
33-
mb_eregi(): Argument #2 ($string) must be a valid string in 'UTF-8'
29+
mb_eregi(): Argument #2 ($string) must be a valid string in "UTF-8" encoding
30+
bool(true)
3431
bool(true)
35-
mb_ereg_replace(): Argument #3 ($string) must be a valid string in 'UTF-8'
3632
mb_ereg_search_init(): Argument #1 ($string) must be a valid string in 'UTF-8'
3733
bool(true)

ext/mbstring/tests/bug72164.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ try {
1919

2020
?>
2121
--EXPECT--
22-
mb_ereg_replace(): Argument #4 ($option) option 'e' is not supported
22+
Option "e" is not supported

ext/mbstring/tests/bug73532.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ try {
1414
}
1515
?>
1616
--EXPECT--
17-
mb_eregi(): Argument #2 ($string) must be a valid string in 'UTF-8'
17+
mb_eregi(): Argument #2 ($string) must be a valid string in "UTF-8" encoding

ext/mbstring/tests/bug76999.phpt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ mb_regex_set_options("pr");
1111
var_dump(mb_regex_set_options("m"));
1212
var_dump(mb_regex_set_options("mdi"));
1313
var_dump(mb_regex_set_options("m"));
14-
var_dump(mb_regex_set_options("a"));
14+
try {
15+
var_dump(mb_regex_set_options("a"));
16+
} catch (\ValueError $e) {
17+
echo $e->getMessage() . \PHP_EOL;
18+
}
1519
var_dump(mb_regex_set_options());
1620
?>
1721
--EXPECT--
1822
string(2) "pr"
1923
string(2) "mr"
2024
string(3) "imd"
21-
string(2) "mr"
25+
Option "a" is not supported
2226
string(1) "r"

0 commit comments

Comments
 (0)