diff options
| author | Gustavo André dos Santos Lopes <cataphract@php.net> | 2012-06-25 12:03:27 +0200 |
|---|---|---|
| committer | Gustavo André dos Santos Lopes <cataphract@php.net> | 2012-06-25 12:05:13 +0200 |
| commit | d8b067e66f4b458108821df512090ede623df214 (patch) | |
| tree | 56d04447b6c72afa7f950356ce0625bf3ebc7b78 | |
| parent | 5a9dca458a517f62fc596c57594a02c363c5a3c0 (diff) | |
| download | php-git-d8b067e66f4b458108821df512090ede623df214.tar.gz | |
BreakIterator: fix compat with old ICU versions
5 files changed, 22 insertions, 2 deletions
diff --git a/ext/intl/breakiterator/breakiterator_class.cpp b/ext/intl/breakiterator/breakiterator_class.cpp index d193fc4457..de4bfbb7b0 100644 --- a/ext/intl/breakiterator/breakiterator_class.cpp +++ b/ext/intl/breakiterator/breakiterator_class.cpp @@ -312,7 +312,9 @@ static const zend_function_entry RuleBasedBreakIterator_class_functions[] = { PHP_ME_MAPPING(getRules, rbbi_get_rules, ainfo_biter_void, ZEND_ACC_PUBLIC) PHP_ME_MAPPING(getRuleStatus, rbbi_get_rule_status, ainfo_biter_void, ZEND_ACC_PUBLIC) PHP_ME_MAPPING(getRuleStatusVec, rbbi_get_rule_status_vec, ainfo_biter_void, ZEND_ACC_PUBLIC) +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48 PHP_ME_MAPPING(getBinaryRules, rbbi_get_binary_rules, ainfo_biter_void, ZEND_ACC_PUBLIC) +#endif PHP_FE_END }; /* }}} */ @@ -329,7 +331,7 @@ static const zend_function_entry CodePointBreakIterator_class_functions[] = { /* {{{ breakiterator_register_BreakIterator_class * Initialize 'BreakIterator' class */ -void breakiterator_register_BreakIterator_class(TSRMLS_D) +U_CFUNC void breakiterator_register_BreakIterator_class(TSRMLS_D) { zend_class_entry ce; diff --git a/ext/intl/breakiterator/codepointiterator_internal.cpp b/ext/intl/breakiterator/codepointiterator_internal.cpp index e88f2eaf6b..bf9239d531 100644 --- a/ext/intl/breakiterator/codepointiterator_internal.cpp +++ b/ext/intl/breakiterator/codepointiterator_internal.cpp @@ -212,6 +212,10 @@ int32_t CodePointBreakIterator::next(int32_t n) { UBool res = utext_moveIndex32(this->fText, n); +#ifndef UTEXT_CURRENT32 +#define UTEXT_CURRENT32 utext_current32 +#endif + if (res) { this->lastCodePoint = UTEXT_CURRENT32(this->fText); return (int32_t)UTEXT_GETNATIVEINDEX(this->fText); diff --git a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp index 288179a785..41ebfe5e0f 100644 --- a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp +++ b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp @@ -73,12 +73,18 @@ static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS) RETURN_NULL(); } } else { // compiled +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48 rbbi = new RuleBasedBreakIterator((uint8_t*)rules, rules_len, status); if (U_FAILURE(status)) { intl_error_set(NULL, status, "rbbi_create_instance: unable to " "creaete instance from compiled rules", 0 TSRMLS_CC); RETURN_NULL(); } +#else + intl_error_set(NULL, U_UNSUPPORTED_ERROR, "rbbi_create_instance: " + "compiled rules require ICU >= 4.8", 0 TSRMLS_CC); + RETURN_NULL(); +#endif } breakiterator_object_create(return_value, rbbi TSRMLS_CC); @@ -180,6 +186,7 @@ U_CFUNC PHP_FUNCTION(rbbi_get_rule_status_vec) delete[] rules; } +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48 U_CFUNC PHP_FUNCTION(rbbi_get_binary_rules) { BREAKITER_METHOD_INIT_VARS; @@ -209,3 +216,4 @@ U_CFUNC PHP_FUNCTION(rbbi_get_binary_rules) RETURN_STRINGL(ret_rules, rules_len, 0); } +#endif diff --git a/ext/intl/tests/breakiter___construct_error.phpt b/ext/intl/tests/breakiter___construct_error.phpt index e96086de56..8d6a7181ed 100644 --- a/ext/intl/tests/breakiter___construct_error.phpt +++ b/ext/intl/tests/breakiter___construct_error.phpt @@ -1,5 +1,8 @@ --TEST-- IntlRuleBasedBreakIterator::__construct(): arg errors +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip ICU >= 4.8 only'; ?> --FILE-- <?php ini_set("intl.error_level", E_WARNING); diff --git a/ext/intl/tests/rbbiter_getBinaryRules_basic.phpt b/ext/intl/tests/rbbiter_getBinaryRules_basic.phpt index 7bc0218846..dce0714d4d 100644 --- a/ext/intl/tests/rbbiter_getBinaryRules_basic.phpt +++ b/ext/intl/tests/rbbiter_getBinaryRules_basic.phpt @@ -1,5 +1,8 @@ --TEST-- IntlRuleBasedBreakIterator::getBinaryRules(): basic test +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip ICU >= 4.8 only'; ?> --FILE-- <?php ini_set("intl.error_level", E_WARNING); @@ -33,4 +36,4 @@ var_dump($rbbi->getRules() == $rbbi2->getRules()); string(128) "$LN = [[:letter:] [:number:]];$S = [.;,:];!!forward;$LN+ {1};$S+ {42};!!reverse;$LN+ {1};$S+ {42};!!safe_forward;!!safe_reverse;" string(128) "$LN = [[:letter:] [:number:]];$S = [.;,:];!!forward;$LN+ {1};$S+ {42};!!reverse;$LN+ {1};$S+ {42};!!safe_forward;!!safe_reverse;" bool(true) -==DONE==
\ No newline at end of file +==DONE== |
