diff options
author | Florian Anderiasch <fa@php.net> | 2011-11-03 16:20:11 +0000 |
---|---|---|
committer | Florian Anderiasch <fa@php.net> | 2011-11-03 16:20:11 +0000 |
commit | 8343d05e85996ce08889d35bf1a1c433fa587a6c (patch) | |
tree | 0445ca02ad6a18fb8fc42688e08db9a573c1029d /ext/intl/collator | |
parent | 10a1121a37f0322e9ad954460635ab80eeb73c12 (diff) | |
download | php-git-8343d05e85996ce08889d35bf1a1c433fa587a6c.tar.gz |
Redid the fix for #60192 with suggestions by Pierre and Kalle
Diffstat (limited to 'ext/intl/collator')
-rwxr-xr-x | ext/intl/collator/collator_compare.c | 12 | ||||
-rwxr-xr-x | ext/intl/collator/collator_locale.c | 7 | ||||
-rwxr-xr-x | ext/intl/collator/collator_sort.c | 33 |
3 files changed, 36 insertions, 16 deletions
diff --git a/ext/intl/collator/collator_compare.c b/ext/intl/collator/collator_compare.c index f7d01949cc..4384558ac6 100755 --- a/ext/intl/collator/collator_compare.c +++ b/ext/intl/collator/collator_compare.c @@ -58,6 +58,14 @@ PHP_FUNCTION( collator_compare ) /* Fetch the object. */ COLLATOR_METHOD_FETCH_OBJECT; + if (!co || !co->ucoll) { + intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC ); + intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), + "Object not initialized", 0 TSRMLS_CC ); + php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized"); + + RETURN_FALSE; + } /* * Compare given strings (converting them to UTF-16 first). @@ -99,10 +107,6 @@ PHP_FUNCTION( collator_compare ) RETURN_FALSE; } - if (!co || !co->ucoll) { - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized"); - } - /* Then compare them. */ result = ucol_strcoll( co->ucoll, diff --git a/ext/intl/collator/collator_locale.c b/ext/intl/collator/collator_locale.c index eaa7e6ba35..b30b021ee8 100755 --- a/ext/intl/collator/collator_locale.c +++ b/ext/intl/collator/collator_locale.c @@ -52,7 +52,12 @@ PHP_FUNCTION( collator_get_locale ) COLLATOR_METHOD_FETCH_OBJECT; if (!co || !co->ucoll) { - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized"); + intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC ); + intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), + "Object not initialized", 0 TSRMLS_CC ); + php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized"); + + RETURN_FALSE; } /* Get locale by specified type. */ diff --git a/ext/intl/collator/collator_sort.c b/ext/intl/collator/collator_sort.c index a8fbd18e5e..a871c90a8e 100755 --- a/ext/intl/collator/collator_sort.c +++ b/ext/intl/collator/collator_sort.c @@ -73,9 +73,12 @@ static int collator_regular_compare_function(zval *result, zval *op1, zval *op2 /* Fetch collator object. */ co = (Collator_object *) zend_object_store_get_object( INTL_G(current_collator) TSRMLS_CC ); - if (!co || !co->ucoll) { - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized"); - } + if (!co || !co->ucoll) { + intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC ); + intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), + "Object not initialized", 0 TSRMLS_CC ); + php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized"); + } /* Compare the strings using ICU. */ result->value.lval = ucol_strcoll( @@ -391,6 +394,14 @@ PHP_FUNCTION( collator_sort_with_sort_keys ) /* Fetch the object. */ COLLATOR_METHOD_FETCH_OBJECT; + if (!co || !co->ucoll) { + intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC ); + intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), + "Object not initialized", 0 TSRMLS_CC ); + php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized"); + + RETURN_FALSE; + } /* * Sort specified array. @@ -445,10 +456,6 @@ PHP_FUNCTION( collator_sort_with_sort_keys ) /* Get sort key, reallocating the buffer if needed. */ bufLeft = sortKeyBufSize - sortKeyBufOffset; - if (!co || !co->ucoll) { - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized"); - } - sortKeyLen = ucol_getSortKey( co->ucoll, utf16_buf, utf16_len, @@ -559,6 +566,14 @@ PHP_FUNCTION( collator_get_sort_key ) /* Fetch the object. */ COLLATOR_METHOD_FETCH_OBJECT; + if (!co || !co->ucoll) { + intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC ); + intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), + "Object not initialized", 0 TSRMLS_CC ); + php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized"); + + RETURN_FALSE; + } /* * Compare given strings (converting them to UTF-16 first). @@ -579,10 +594,6 @@ PHP_FUNCTION( collator_get_sort_key ) RETURN_FALSE; } - if (!co || !co->ucoll) { - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized"); - } - key_len = ucol_getSortKey(co->ucoll, ustr, ustr_len, key, 0); if(!key_len) { efree( ustr ); |