summaryrefslogtreecommitdiff
path: root/ext/intl/formatter/formatter_parse.c
diff options
context:
space:
mode:
authorStanley Sufficool <ssufficool@php.net>2014-10-20 21:33:32 -0700
committerStanley Sufficool <ssufficool@php.net>2014-10-20 21:33:32 -0700
commit8defcb855ab01d9c8ab4759cb793d80149b55a8c (patch)
treeed51eb30a2cbc92b102557498fb3e4113da1bb07 /ext/intl/formatter/formatter_parse.c
parent9c7dbb0487f5991fde03873ea8f5e66d6688415f (diff)
parentbaddb1c73a170ef1d2c31bd54cddbc6e1ab596b9 (diff)
downloadphp-git-8defcb855ab01d9c8ab4759cb793d80149b55a8c.tar.gz
Merge branch 'master' of https://git.php.net/push/php-src
* 'master' of https://git.php.net/push/php-src: (6215 commits) Extra comma Moved proxy object support in ASSIGN_ADD (and family) from VM to slow paths of corresponding operators Simplification zend_get_property_info_quick() cleanup and optimization initialize lineno before calling compile file file in phar Use ADDREF instead of DUP, it must be enough. Removed old irrelevant comment fixed compilation error Fix bug #68262: Broken reference across cloned objects export functions needed for phpdbg Fixed compilation Optimized property access handlers. Removed EG(std_property_info). Fixed bug #68199 (PDO::pgsqlGetNotify doesn't support NOTIFY payloads) Don't make difference between undefined and unaccessible properies when call __get() and family Don't make useless CSE array_pop/array_shift optimization check for zlib headers as well as lib for mysqlnd a realpath cache key can be int or float, catching this News entry for new curl constants News entry for new curl constants ...
Diffstat (limited to 'ext/intl/formatter/formatter_parse.c')
-rw-r--r--ext/intl/formatter/formatter_parse.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/ext/intl/formatter/formatter_parse.c b/ext/intl/formatter/formatter_parse.c
index 6f3a3a12b5..0959d11830 100644
--- a/ext/intl/formatter/formatter_parse.c
+++ b/ext/intl/formatter/formatter_parse.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -36,11 +36,11 @@
*/
PHP_FUNCTION( numfmt_parse )
{
- long type = FORMAT_TYPE_DOUBLE;
+ zend_long type = FORMAT_TYPE_DOUBLE;
UChar* sstr = NULL;
int sstr_len = 0;
char* str = NULL;
- int str_len;
+ size_t str_len;
int32_t val32, position = 0;
int64_t val64;
double val_double;
@@ -50,7 +50,7 @@ PHP_FUNCTION( numfmt_parse )
FORMATTER_METHOD_INIT_VARS;
/* Parse parameters. */
- if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|lz!",
+ if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|lz/!",
&object, NumberFormatter_ce_ptr, &str, &str_len, &type, &zposition ) == FAILURE )
{
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
@@ -67,13 +67,16 @@ PHP_FUNCTION( numfmt_parse )
INTL_METHOD_CHECK_STATUS( nfo, "String conversion to UTF-16 failed" );
if(zposition) {
+ ZVAL_DEREF(zposition);
convert_to_long(zposition);
position = (int32_t)Z_LVAL_P( zposition );
position_p = &position;
}
#if ICU_LOCALE_BUG && defined(LC_NUMERIC)
- oldlocale = setlocale(LC_NUMERIC, "C");
+ /* need to copy here since setlocale may change it later */
+ oldlocale = estrdup(setlocale(LC_NUMERIC, NULL));
+ setlocale(LC_NUMERIC, "C");
#endif
switch(type) {
@@ -83,10 +86,10 @@ PHP_FUNCTION( numfmt_parse )
break;
case FORMAT_TYPE_INT64:
val64 = unum_parseInt64(FORMATTER_OBJECT(nfo), sstr, sstr_len, position_p, &INTL_DATA_ERROR_CODE(nfo));
- if(val64 > LONG_MAX || val64 < LONG_MIN) {
+ if(val64 > ZEND_LONG_MAX || val64 < ZEND_LONG_MIN) {
RETVAL_DOUBLE(val64);
} else {
- RETVAL_LONG((long)val64);
+ RETVAL_LONG((zend_long)val64);
}
break;
case FORMAT_TYPE_DOUBLE:
@@ -94,12 +97,13 @@ PHP_FUNCTION( numfmt_parse )
RETVAL_DOUBLE(val_double);
break;
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported format type %ld", type);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported format type %pd", type);
RETVAL_FALSE;
break;
}
#if ICU_LOCALE_BUG && defined(LC_NUMERIC)
setlocale(LC_NUMERIC, oldlocale);
+ efree(oldlocale);
#endif
if(zposition) {
zval_dtor(zposition);
@@ -128,14 +132,14 @@ PHP_FUNCTION( numfmt_parse_currency )
char *currency_str = NULL;
int currency_len = 0;
char *str;
- int str_len;
+ size_t str_len;
int32_t* position_p = NULL;
int32_t position = 0;
zval *zcurrency, *zposition = NULL;
FORMATTER_METHOD_INIT_VARS;
/* Parse parameters. */
- if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Osz|z!",
+ if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Osz/|z/!",
&object, NumberFormatter_ce_ptr, &str, &str_len, &zcurrency, &zposition ) == FAILURE )
{
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
@@ -152,6 +156,7 @@ PHP_FUNCTION( numfmt_parse_currency )
INTL_METHOD_CHECK_STATUS( nfo, "String conversion to UTF-16 failed" );
if(zposition) {
+ ZVAL_DEREF(zposition);
convert_to_long(zposition);
position = (int32_t)Z_LVAL_P( zposition );
position_p = &position;
@@ -171,7 +176,9 @@ PHP_FUNCTION( numfmt_parse_currency )
intl_convert_utf16_to_utf8(&currency_str, &currency_len, currency, u_strlen(currency), &INTL_DATA_ERROR_CODE(nfo));
INTL_METHOD_CHECK_STATUS( nfo, "Currency conversion to UTF-8 failed" );
zval_dtor( zcurrency );
- ZVAL_STRINGL(zcurrency, currency_str, currency_len, 0);
+ ZVAL_STRINGL(zcurrency, currency_str, currency_len);
+ //????
+ efree(currency_str);
RETVAL_DOUBLE( number );
}