Commit:    d8b067e66f4b458108821df512090ede623df214
Author:    Gustavo André dos Santos Lopes <cataphr...@php.net>         Mon, 25 
Jun 2012 12:03:27 +0200
Parents:   5a9dca458a517f62fc596c57594a02c363c5a3c0
Branches:  master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=d8b067e66f4b458108821df512090ede623df214

Log:
BreakIterator: fix compat with old ICU versions

Changed paths:
  M  ext/intl/breakiterator/breakiterator_class.cpp
  M  ext/intl/breakiterator/codepointiterator_internal.cpp
  M  ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp
  M  ext/intl/tests/breakiter___construct_error.phpt
  M  ext/intl/tests/rbbiter_getBinaryRules_basic.phpt


Diff:
diff --git a/ext/intl/breakiterator/breakiterator_class.cpp 
b/ext/intl/breakiterator/breakiterator_class.cpp
index d193fc4..de4bfbb 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 e88f2ea..bf9239d 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 288179a..41ebfe5 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 e96086d..8d6a718 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 7bc0218..dce0714 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==


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to