diff options
Diffstat (limited to 'ext/intl/msgformat/msgformat.c')
-rw-r--r-- | ext/intl/msgformat/msgformat.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/ext/intl/msgformat/msgformat.c b/ext/intl/msgformat/msgformat.c index 6a9f04f32b..2ca8ed9186 100644 --- a/ext/intl/msgformat/msgformat.c +++ b/ext/intl/msgformat/msgformat.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 | @@ -28,9 +28,9 @@ /* {{{ */ static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS) { - char* locale; + const char* locale; char* pattern; - int locale_len = 0, pattern_len = 0; + size_t locale_len = 0, pattern_len = 0; UChar* spattern = NULL; int spattern_len = 0; zval* object; @@ -44,8 +44,8 @@ static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS) { intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "msgfmt_create: unable to parse input parameters", 0 TSRMLS_CC ); - zval_dtor(return_value); - RETURN_NULL(); + Z_OBJ_P(return_value) = NULL; + return; } INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value); @@ -97,6 +97,9 @@ PHP_FUNCTION( msgfmt_create ) { object_init_ex( return_value, MessageFormatter_ce_ptr ); msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU); + if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) { + RETURN_NULL(); + } } /* }}} */ @@ -105,8 +108,16 @@ PHP_FUNCTION( msgfmt_create ) */ PHP_METHOD( MessageFormatter, __construct ) { + zval orig_this = *getThis(); + return_value = getThis(); msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU); + + if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) { + zend_object_store_ctor_failed(Z_OBJ(orig_this) TSRMLS_CC); + zval_dtor(&orig_this); + ZEND_CTOR_MAKE_NULL(); + } } /* }}} */ @@ -130,7 +141,7 @@ PHP_FUNCTION( msgfmt_get_error_code ) RETURN_FALSE; } - mfo = (MessageFormatter_object *) zend_object_store_get_object( object TSRMLS_CC ); + mfo = Z_INTL_MESSAGEFORMATTER_P( object ); /* Return formatter's last error code. */ RETURN_LONG( INTL_DATA_ERROR_CODE(mfo) ); @@ -144,7 +155,7 @@ PHP_FUNCTION( msgfmt_get_error_code ) */ PHP_FUNCTION( msgfmt_get_error_message ) { - char* message = NULL; + zend_string* message = NULL; zval* object = NULL; MessageFormatter_object* mfo = NULL; @@ -158,11 +169,11 @@ PHP_FUNCTION( msgfmt_get_error_message ) RETURN_FALSE; } - mfo = (MessageFormatter_object *) zend_object_store_get_object( object TSRMLS_CC ); + mfo = Z_INTL_MESSAGEFORMATTER_P( object ); /* Return last error message. */ message = intl_error_get_message( &mfo->mf_data.error TSRMLS_CC ); - RETURN_STRING( message, 0); + RETURN_STR(message); } /* }}} */ |