Skip to content

ext/intl: odn, collator, msgformat using fast ZPP #14421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions ext/intl/collator/collator_create.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,16 @@
/* {{{ */
static int collator_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_handling, bool *error_handling_replaced)
{
const char* locale;
char* locale;
size_t locale_len = 0;
zval* object;
Collator_object* co;

intl_error_reset( NULL );
object = return_value;
/* Parse parameters. */
if( zend_parse_parameters( ZEND_NUM_ARGS(), "s",
&locale, &locale_len ) == FAILURE )
{
return FAILURE;
}
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_STRING(locale, locale_len)
ZEND_PARSE_PARAMETERS_END_EX(return FAILURE);

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

if(locale_len == 0) {
locale = intl_locale_get_default();
locale = (char *)intl_locale_get_default();
}

/* Open ICU collator. */
Expand Down
11 changes: 7 additions & 4 deletions ext/intl/idn/idn.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,13 @@ static void php_intl_idn_handoff(INTERNAL_FUNCTION_PARAMETERS, int mode)

intl_error_reset(NULL);

if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|llz",
&domain, &option, &variant, &idna_info) == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_START(1, 4)
Z_PARAM_STR(domain)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(option)
Z_PARAM_LONG(variant)
Z_PARAM_ZVAL(idna_info)
ZEND_PARSE_PARAMETERS_END();

if (ZSTR_LEN(domain) == 0) {
zend_argument_value_error(1, "cannot be empty");
Expand Down
14 changes: 6 additions & 8 deletions ext/intl/msgformat/msgformat.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/* {{{ */
static int msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_handling, bool *error_handling_replaced)
{
const char* locale;
char* locale;
char* pattern;
size_t locale_len = 0, pattern_len = 0;
UChar* spattern = NULL;
Expand All @@ -38,12 +38,10 @@ static int msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_
intl_error_reset( NULL );

object = return_value;
/* Parse parameters. */
if( zend_parse_parameters( ZEND_NUM_ARGS(), "ss",
&locale, &locale_len, &pattern, &pattern_len ) == FAILURE )
{
return FAILURE;
}
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_STRING(locale, locale_len)
Z_PARAM_STRING(pattern, pattern_len)
ZEND_PARSE_PARAMETERS_END_EX(return FAILURE);

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

if(locale_len == 0) {
locale = intl_locale_get_default();
locale = (char *)intl_locale_get_default();
}

#ifdef MSG_FORMAT_QUOTE_APOS
Expand Down
15 changes: 7 additions & 8 deletions ext/intl/msgformat/msgformat_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,18 @@ PHP_FUNCTION( msgfmt_parse_message )
int spattern_len = 0;
char *pattern = NULL;
size_t pattern_len = 0;
const char *slocale = NULL;
char *slocale = NULL;
size_t slocale_len = 0;
char *source = NULL;
size_t src_len = 0;
MessageFormatter_object mf;
MessageFormatter_object *mfo = &mf;

/* Parse parameters. */
if( zend_parse_parameters( ZEND_NUM_ARGS(), "sss",
&slocale, &slocale_len, &pattern, &pattern_len, &source, &src_len ) == FAILURE )
{
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_START(3, 3)
Z_PARAM_STRING(slocale, slocale_len)
Z_PARAM_STRING(pattern, pattern_len)
Z_PARAM_STRING(source, src_len)
ZEND_PARSE_PARAMETERS_END();

INTL_CHECK_LOCALE_LEN(slocale_len);
memset(mfo, 0, sizeof(*mfo));
Expand All @@ -111,7 +110,7 @@ PHP_FUNCTION( msgfmt_parse_message )
}

if(slocale_len == 0) {
slocale = intl_locale_get_default();
slocale = (char *)intl_locale_get_default();
}

#ifdef MSG_FORMAT_QUOTE_APOS
Expand Down
Loading