Skip to content

Commit 8c08b03

Browse files
authored
ext/intl: odn, collator, msgformat using fast ZPP (#14421)
1 parent c39bcaa commit 8c08b03

File tree

4 files changed

+25
-28
lines changed

4 files changed

+25
-28
lines changed

ext/intl/collator/collator_create.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,16 @@
2424
/* {{{ */
2525
static int collator_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_handling, bool *error_handling_replaced)
2626
{
27-
const char* locale;
27+
char* locale;
2828
size_t locale_len = 0;
2929
zval* object;
3030
Collator_object* co;
3131

3232
intl_error_reset( NULL );
3333
object = return_value;
34-
/* Parse parameters. */
35-
if( zend_parse_parameters( ZEND_NUM_ARGS(), "s",
36-
&locale, &locale_len ) == FAILURE )
37-
{
38-
return FAILURE;
39-
}
34+
ZEND_PARSE_PARAMETERS_START(1, 1)
35+
Z_PARAM_STRING(locale, locale_len)
36+
ZEND_PARSE_PARAMETERS_END_EX(return FAILURE);
4037

4138
if (error_handling != NULL) {
4239
zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, error_handling);
@@ -47,7 +44,7 @@ static int collator_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *erro
4744
COLLATOR_METHOD_FETCH_OBJECT;
4845

4946
if(locale_len == 0) {
50-
locale = intl_locale_get_default();
47+
locale = (char *)intl_locale_get_default();
5148
}
5249

5350
/* Open ICU collator. */

ext/intl/idn/idn.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,13 @@ static void php_intl_idn_handoff(INTERNAL_FUNCTION_PARAMETERS, int mode)
118118

119119
intl_error_reset(NULL);
120120

121-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|llz",
122-
&domain, &option, &variant, &idna_info) == FAILURE) {
123-
RETURN_THROWS();
124-
}
121+
ZEND_PARSE_PARAMETERS_START(1, 4)
122+
Z_PARAM_STR(domain)
123+
Z_PARAM_OPTIONAL
124+
Z_PARAM_LONG(option)
125+
Z_PARAM_LONG(variant)
126+
Z_PARAM_ZVAL(idna_info)
127+
ZEND_PARSE_PARAMETERS_END();
125128

126129
if (ZSTR_LEN(domain) == 0) {
127130
zend_argument_value_error(1, "cannot be empty");

ext/intl/msgformat/msgformat.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
/* {{{ */
2828
static int msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_handling, bool *error_handling_replaced)
2929
{
30-
const char* locale;
30+
char* locale;
3131
char* pattern;
3232
size_t locale_len = 0, pattern_len = 0;
3333
UChar* spattern = NULL;
@@ -38,12 +38,10 @@ static int msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_
3838
intl_error_reset( NULL );
3939

4040
object = return_value;
41-
/* Parse parameters. */
42-
if( zend_parse_parameters( ZEND_NUM_ARGS(), "ss",
43-
&locale, &locale_len, &pattern, &pattern_len ) == FAILURE )
44-
{
45-
return FAILURE;
46-
}
41+
ZEND_PARSE_PARAMETERS_START(2, 2)
42+
Z_PARAM_STRING(locale, locale_len)
43+
Z_PARAM_STRING(pattern, pattern_len)
44+
ZEND_PARSE_PARAMETERS_END_EX(return FAILURE);
4745

4846
if (error_handling != NULL) {
4947
zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, error_handling);
@@ -63,7 +61,7 @@ static int msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_
6361
}
6462

6563
if(locale_len == 0) {
66-
locale = intl_locale_get_default();
64+
locale = (char *)intl_locale_get_default();
6765
}
6866

6967
#ifdef MSG_FORMAT_QUOTE_APOS

ext/intl/msgformat/msgformat_parse.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,18 @@ PHP_FUNCTION( msgfmt_parse_message )
7979
int spattern_len = 0;
8080
char *pattern = NULL;
8181
size_t pattern_len = 0;
82-
const char *slocale = NULL;
82+
char *slocale = NULL;
8383
size_t slocale_len = 0;
8484
char *source = NULL;
8585
size_t src_len = 0;
8686
MessageFormatter_object mf;
8787
MessageFormatter_object *mfo = &mf;
8888

89-
/* Parse parameters. */
90-
if( zend_parse_parameters( ZEND_NUM_ARGS(), "sss",
91-
&slocale, &slocale_len, &pattern, &pattern_len, &source, &src_len ) == FAILURE )
92-
{
93-
RETURN_THROWS();
94-
}
89+
ZEND_PARSE_PARAMETERS_START(3, 3)
90+
Z_PARAM_STRING(slocale, slocale_len)
91+
Z_PARAM_STRING(pattern, pattern_len)
92+
Z_PARAM_STRING(source, src_len)
93+
ZEND_PARSE_PARAMETERS_END();
9594

9695
INTL_CHECK_LOCALE_LEN(slocale_len);
9796
memset(mfo, 0, sizeof(*mfo));
@@ -111,7 +110,7 @@ PHP_FUNCTION( msgfmt_parse_message )
111110
}
112111

113112
if(slocale_len == 0) {
114-
slocale = intl_locale_get_default();
113+
slocale = (char *)intl_locale_get_default();
115114
}
116115

117116
#ifdef MSG_FORMAT_QUOTE_APOS

0 commit comments

Comments
 (0)