From 401c93410a68aaa3d0c67d89c6de8405c2d8d8db Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 1 Jun 2024 21:39:42 +0100 Subject: [PATCH] ext/intl: odn, collator, msgformat using fast ZPP --- ext/intl/collator/collator_create.c | 13 +++++-------- ext/intl/idn/idn.c | 11 +++++++---- ext/intl/msgformat/msgformat.c | 14 ++++++-------- ext/intl/msgformat/msgformat_parse.c | 15 +++++++-------- 4 files changed, 25 insertions(+), 28 deletions(-) diff --git a/ext/intl/collator/collator_create.c b/ext/intl/collator/collator_create.c index 5fc4293e9773..1f04f23f0f70 100644 --- a/ext/intl/collator/collator_create.c +++ b/ext/intl/collator/collator_create.c @@ -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); @@ -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. */ diff --git a/ext/intl/idn/idn.c b/ext/intl/idn/idn.c index f3769affcc85..0b528799380f 100644 --- a/ext/intl/idn/idn.c +++ b/ext/intl/idn/idn.c @@ -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"); diff --git a/ext/intl/msgformat/msgformat.c b/ext/intl/msgformat/msgformat.c index c363dd9706fb..e35d86eb802d 100644 --- a/ext/intl/msgformat/msgformat.c +++ b/ext/intl/msgformat/msgformat.c @@ -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; @@ -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); @@ -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 diff --git a/ext/intl/msgformat/msgformat_parse.c b/ext/intl/msgformat/msgformat_parse.c index baa6dfcce74b..faecf6180225 100644 --- a/ext/intl/msgformat/msgformat_parse.c +++ b/ext/intl/msgformat/msgformat_parse.c @@ -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)); @@ -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