diff options
author | Stanley Sufficool <ssufficool@php.net> | 2014-10-20 21:33:32 -0700 |
---|---|---|
committer | Stanley Sufficool <ssufficool@php.net> | 2014-10-20 21:33:32 -0700 |
commit | 8defcb855ab01d9c8ab4759cb793d80149b55a8c (patch) | |
tree | ed51eb30a2cbc92b102557498fb3e4113da1bb07 /ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp | |
parent | 9c7dbb0487f5991fde03873ea8f5e66d6688415f (diff) | |
parent | baddb1c73a170ef1d2c31bd54cddbc6e1ab596b9 (diff) | |
download | php-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/breakiterator/rulebasedbreakiterator_methods.cpp')
-rw-r--r-- | ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp index 454e5249fd..d3b36291b2 100644 --- a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp +++ b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp @@ -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 | @@ -33,7 +33,7 @@ static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS) { zval *object = getThis(); char *rules; - int rules_len; + size_t rules_len; zend_bool compiled = 0; UErrorCode status = U_ZERO_ERROR; intl_error_reset(NULL TSRMLS_CC); @@ -42,7 +42,8 @@ static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS) &rules, &rules_len, &compiled) == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "rbbi_create_instance: bad arguments", 0 TSRMLS_CC); - RETURN_NULL(); + Z_OBJ_P(return_value) = NULL; + return; } // instantiation of ICU object @@ -66,12 +67,13 @@ static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS) smart_str parse_error_str; parse_error_str = intl_parse_error_to_string(&parseError); spprintf(&msg, 0, "rbbi_create_instance: unable to create " - "RuleBasedBreakIterator from rules (%s)", parse_error_str.c); + "RuleBasedBreakIterator from rules (%s)", parse_error_str.s? parse_error_str.s->val : ""); smart_str_free(&parse_error_str); intl_error_set_custom_msg(NULL, msg, 1 TSRMLS_CC); efree(msg); delete rbbi; - RETURN_NULL(); + Z_OBJ_P(return_value) = NULL; + return; } } else { // compiled #if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48 @@ -79,17 +81,18 @@ static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS) if (U_FAILURE(status)) { intl_error_set(NULL, status, "rbbi_create_instance: unable to " "create instance from compiled rules", 0 TSRMLS_CC); - delete rbbi; - RETURN_NULL(); + Z_OBJ_P(return_value) = NULL; + return; } #else intl_error_set(NULL, U_UNSUPPORTED_ERROR, "rbbi_create_instance: " "compiled rules require ICU >= 4.8", 0 TSRMLS_CC); - RETURN_NULL(); + Z_OBJ_P(return_value) = NULL; + return; #endif } - breakiterator_object_create(return_value, rbbi TSRMLS_CC); + breakiterator_object_create(return_value, rbbi, 0 TSRMLS_CC); } U_CFUNC PHP_METHOD(IntlRuleBasedBreakIterator, __construct) @@ -97,12 +100,12 @@ U_CFUNC PHP_METHOD(IntlRuleBasedBreakIterator, __construct) zval orig_this = *getThis(); return_value = getThis(); - //changes this to IS_NULL (without first destroying) if there's an error _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU); - if (Z_TYPE_P(return_value) == IS_NULL) { - zend_object_store_ctor_failed(&orig_this TSRMLS_CC); + 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(); } } @@ -119,17 +122,20 @@ U_CFUNC PHP_FUNCTION(rbbi_get_rules) BREAKITER_METHOD_FETCH_OBJECT; + char *str; + int str_len; const UnicodeString rules = fetch_rbbi(bio)->getRules(); - Z_TYPE_P(return_value) = IS_STRING; - if (intl_charFromString(rules, &Z_STRVAL_P(return_value), - &Z_STRLEN_P(return_value), BREAKITER_ERROR_CODE_P(bio)) == FAILURE) + if (intl_charFromString(rules, &str, &str_len, BREAKITER_ERROR_CODE_P(bio)) == FAILURE) { intl_errors_set(BREAKITER_ERROR_P(bio), BREAKITER_ERROR_CODE(bio), "rbbi_hash_code: Error converting result to UTF-8 string", 0 TSRMLS_CC); RETURN_FALSE; } + RETVAL_STRINGL(str, str_len); + //??? + efree(str); } U_CFUNC PHP_FUNCTION(rbbi_get_rule_status) @@ -212,10 +218,10 @@ U_CFUNC PHP_FUNCTION(rbbi_get_binary_rules) RETURN_FALSE; } - char *ret_rules = static_cast<char*>(emalloc(rules_len + 1)); - memcpy(ret_rules, rules, rules_len); - ret_rules[rules_len] = '\0'; + zend_string *ret_rules = zend_string_alloc(rules_len, 0); + memcpy(ret_rules->val, rules, rules_len); + ret_rules->val[rules_len] = '\0'; - RETURN_STRINGL(ret_rules, rules_len, 0); + RETURN_STR(ret_rules); } #endif |