]> granicus.if.org Git - php/commitdiff
BreakIterator: fix compat with old ICU versions
authorGustavo André dos Santos Lopes <cataphract@php.net>
Mon, 25 Jun 2012 10:03:27 +0000 (12:03 +0200)
committerGustavo André dos Santos Lopes <cataphract@php.net>
Mon, 25 Jun 2012 10:05:13 +0000 (12:05 +0200)
ext/intl/breakiterator/breakiterator_class.cpp
ext/intl/breakiterator/codepointiterator_internal.cpp
ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp
ext/intl/tests/breakiter___construct_error.phpt
ext/intl/tests/rbbiter_getBinaryRules_basic.phpt

index d193fc445779a8b1bf8e58104f641886b329a919..de4bfbb7b0dd1b3e02549949db494013f9c03838 100644 (file)
@@ -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;
 
index e88f2eaf6b88ef5a6ce1b60d5eb2e259e3152c0d..bf9239d531ffc8a637c3fbd9ebef14d34ae22a98 100644 (file)
@@ -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);
index 288179a78595d504f9bd33545746e681084656f2..41ebfe5e0f5ff8e52c4c7fa2c8bfb6b5a6a152e6 100644 (file)
@@ -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
index e96086de56756c648427bb4a272f8052e5895279..8d6a7181ed52df286c32bc7e0ddd664882f5edfa 100644 (file)
@@ -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);
index 7bc02188460b207e67e9ada72c896090fd4fc74d..dce0714d4dd4f985ef5dab8aaf71a14a01896c14 100644 (file)
@@ -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==