diff options
Diffstat (limited to 'ext/intl/formatter/formatter_parse.c')
-rw-r--r-- | ext/intl/formatter/formatter_parse.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/ext/intl/formatter/formatter_parse.c b/ext/intl/formatter/formatter_parse.c index 347f929cbd..4ee14b3ce3 100644 --- a/ext/intl/formatter/formatter_parse.c +++ b/ext/intl/formatter/formatter_parse.c @@ -51,7 +51,7 @@ PHP_FUNCTION( numfmt_parse ) FORMATTER_METHOD_INIT_VARS; /* Parse parameters. */ - if( zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), "Os|lz/!", + if( zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), "Os|lz!", &object, NumberFormatter_ce_ptr, &str, &str_len, &type, &zposition ) == FAILURE ) { intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, @@ -60,6 +60,11 @@ PHP_FUNCTION( numfmt_parse ) RETURN_FALSE; } + if(zposition) { + position = (int32_t) zval_get_long(zposition); + position_p = &position; + } + /* Fetch the object. */ FORMATTER_METHOD_FETCH_OBJECT; @@ -67,12 +72,6 @@ PHP_FUNCTION( numfmt_parse ) intl_convert_utf8_to_utf16(&sstr, &sstr_len, str, str_len, &INTL_DATA_ERROR_CODE(nfo)); INTL_METHOD_CHECK_STATUS( nfo, "String conversion to UTF-16 failed" ); - if(zposition) { - ZVAL_DEREF(zposition); - position = (int32_t)zval_get_long( zposition ); - position_p = &position; - } - #if ICU_LOCALE_BUG && defined(LC_NUMERIC) /* need to copy here since setlocale may change it later */ oldlocale = estrdup(setlocale(LC_NUMERIC, NULL)); @@ -106,8 +105,7 @@ PHP_FUNCTION( numfmt_parse ) efree(oldlocale); #endif if(zposition) { - zval_ptr_dtor(zposition); - ZVAL_LONG(zposition, position); + ZEND_TRY_ASSIGN_LONG(zposition, position); } if (sstr) { @@ -138,7 +136,7 @@ PHP_FUNCTION( numfmt_parse_currency ) FORMATTER_METHOD_INIT_VARS; /* Parse parameters. */ - if( zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), "Osz/|z/!", + if( zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), "Osz/|z!", &object, NumberFormatter_ce_ptr, &str, &str_len, &zcurrency, &zposition ) == FAILURE ) { intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, @@ -155,15 +153,13 @@ PHP_FUNCTION( numfmt_parse_currency ) INTL_METHOD_CHECK_STATUS( nfo, "String conversion to UTF-16 failed" ); if(zposition) { - ZVAL_DEREF(zposition); - position = (int32_t)zval_get_long( zposition ); + position = (int32_t) zval_get_long(zposition); position_p = &position; } number = unum_parseDoubleCurrency(FORMATTER_OBJECT(nfo), sstr, sstr_len, position_p, currency, &INTL_DATA_ERROR_CODE(nfo)); if(zposition) { - zval_ptr_dtor(zposition); - ZVAL_LONG(zposition, position); + ZEND_TRY_ASSIGN_LONG(zposition, position); } if (sstr) { efree(sstr); |