summaryrefslogtreecommitdiff
path: root/ext/intl
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2010-01-07 13:31:53 +0100
committerOndřej Surý <ondrej@sury.org>2010-01-07 13:31:53 +0100
commit0fab6db7cac8d2be99579dd049f812a8ff98e74f (patch)
tree91f01b0d06916c78262404096bfd466b8e95e5b5 /ext/intl
parentd3a8757891280dc6650ca7eead67830c794b0e7b (diff)
downloadphp-0fab6db7cac8d2be99579dd049f812a8ff98e74f.tar.gz
Imported Upstream version 5.3.1upstream/5.3.1
Diffstat (limited to 'ext/intl')
-rwxr-xr-xext/intl/config.w322
-rwxr-xr-xext/intl/doc/collator_api.php1
-rwxr-xr-xext/intl/doc/common_api.php2
-rwxr-xr-xext/intl/doc/datefmt_api.php3
-rwxr-xr-xext/intl/doc/formatter_api.php2
-rwxr-xr-xext/intl/doc/locale_api.php52
-rw-r--r--ext/intl/idn/idn.c12
-rw-r--r--ext/intl/idn/idn.h2
-rwxr-xr-xext/intl/intl_error.c3
-rwxr-xr-xext/intl/locale/locale.c2
-rwxr-xr-xext/intl/locale/locale.h2
-rwxr-xr-xext/intl/locale/locale_class.c2
-rwxr-xr-xext/intl/locale/locale_class.h2
-rwxr-xr-xext/intl/locale/locale_methods.c274
-rwxr-xr-xext/intl/locale/locale_methods.h2
-rwxr-xr-xext/intl/php_intl.c1
-rwxr-xr-xext/intl/php_intl.h1
-rw-r--r--ext/intl/tests/bug48227.phpt2
-rwxr-xr-xext/intl/tests/idn.phpt18
-rwxr-xr-xext/intl/tests/locale_lookup.phpt10
-rwxr-xr-xext/intl/tests/ut_common.inc776
21 files changed, 559 insertions, 612 deletions
diff --git a/ext/intl/config.w32 b/ext/intl/config.w32
index cb90ef26b..e7b61299c 100755
--- a/ext/intl/config.w32
+++ b/ext/intl/config.w32
@@ -1,4 +1,4 @@
-// $Id: config.w32,v 1.1.2.2 2009/01/26 22:34:49 pajoye Exp $
+// $Id: config.w32 274681 2009-01-26 22:34:49Z pajoye $
// vim:ft=javascript
ARG_ENABLE("intl", "Enable internationalization support", "no");
diff --git a/ext/intl/doc/collator_api.php b/ext/intl/doc/collator_api.php
index 38da2798f..542878375 100755
--- a/ext/intl/doc/collator_api.php
+++ b/ext/intl/doc/collator_api.php
@@ -395,4 +395,3 @@ function collator_get_error_code( $coll ) {}
* Collator API function call.
*/
function collator_get_error_message( $coll ) {}
-?>
diff --git a/ext/intl/doc/common_api.php b/ext/intl/doc/common_api.php
index 76ba9d88c..ce2329fe3 100755
--- a/ext/intl/doc/common_api.php
+++ b/ext/intl/doc/common_api.php
@@ -54,5 +54,3 @@ function intl_is_failure($code) {}
* @return string Error code name.
*/
function intl_error_name($code) {}
-
-?>
diff --git a/ext/intl/doc/datefmt_api.php b/ext/intl/doc/datefmt_api.php
index 37249292b..0c5002e28 100755
--- a/ext/intl/doc/datefmt_api.php
+++ b/ext/intl/doc/datefmt_api.php
@@ -434,6 +434,3 @@ class DateFormatter {
* @return string Description of the last error.
*/
function datefmt_get_error_message($fmt) {}
-
-
-?>
diff --git a/ext/intl/doc/formatter_api.php b/ext/intl/doc/formatter_api.php
index c75596e4c..754b16c62 100755
--- a/ext/intl/doc/formatter_api.php
+++ b/ext/intl/doc/formatter_api.php
@@ -498,5 +498,3 @@ function numfmt_get_error_code($formatter) {}
* @return string Description of the last occured error.
*/
function numfmt_get_error_message($formatter) {}
-
-?>
diff --git a/ext/intl/doc/locale_api.php b/ext/intl/doc/locale_api.php
index b16e36aa5..c6c41ede0 100755
--- a/ext/intl/doc/locale_api.php
+++ b/ext/intl/doc/locale_api.php
@@ -42,7 +42,7 @@ class Locale {
* The following static members are used with the getLocale methods of
* the various locale affected classes, such as numfmt.
*/
- const DEFAULT_LOCALE = default_locale;
+ const DEFAULT_LOCALE = null;
/**
* identifiers for the actual locale, valid locale
@@ -59,13 +59,13 @@ class Locale {
/**
* Valid locale tag and subtag values
*/
- LANG_TAG = "language";
- EXTLANG_TAG = "extlang";
- SCRIPT_TAG = "script";
- REGION_TAG = "region";
- VARIANT_TAG = "variant";
- GRANDFATHERED_LANG_TAG = "grandfathered";
- PRIVATE_TAG = "private";
+ const LANG_TAG = "language";
+ const EXTLANG_TAG = "extlang";
+ const SCRIPT_TAG = "script";
+ const REGION_TAG = "region";
+ const VARIANT_TAG = "variant";
+ const GRANDFATHERED_LANG_TAG = "grandfathered";
+ const PRIVATE_TAG = "private";
#############################################################################
@@ -206,9 +206,10 @@ class Locale {
*
* @param string $langtag the language tag to check
* @param string $locale the language range to check against
+ * @param bool $canonicalize Canonicalize parameters?
* @return boolean 'true' if $locale matches $langtag 'false' otherwise
*/
- public static function filterMatches($langtag, $locale) {}
+ public static function filterMatches($langtag, $locale, $canonicalize) {}
/**
* Searchs the items in $langtag for the best match to the language
@@ -263,7 +264,7 @@ class Locale {
*
* @return string the current runtime locale
*/
- public static function locale_get_default() {}
+ function locale_get_default() {}
/**
* sets the default runtime locale to $locale
@@ -273,7 +274,7 @@ class Locale {
* locale identifier. UAX #35 extensions are accepted.
* @return boolean 'true' if okay, 'false' if an error
*/
- public static function locale_set_default($locale) {}
+ function locale_set_default($locale) {}
/**
@@ -283,7 +284,7 @@ class Locale {
* @return string the language code associated with the language
* or null in case of error.
*/
- public static function locale_get_primary_language($locale) {}
+ function locale_get_primary_language($locale) {}
/**
@@ -292,7 +293,7 @@ class Locale {
* @param string $locale the locale to extract the script code from
* @return string the script subtag for the locale or null if not present
*/
- public static function locale_get_script($locale) {}
+ function locale_get_script($locale) {}
/**
@@ -301,7 +302,7 @@ class Locale {
* @param string $locale the locale to extract the region code from
* @return string the region subtag for the locale or null if not present
*/
- public static function locale_get_region($locale) {}
+ function locale_get_region($locale) {}
/**
@@ -311,7 +312,7 @@ class Locale {
* @return array the array containing the list of all variants
* subtag for the locale or null if not present
*/
- public static function locale_get_all_variants($locale) {}
+ function locale_get_all_variants($locale) {}
/**
@@ -320,7 +321,7 @@ class Locale {
* @param string $locale the locale to extract the keywords from
* @return array associative array containing the keyword-value pairs for this locale
*/
- public static function locale_get_keywords($locale) {}
+ function locale_get_keywords($locale) {}
/**
@@ -332,7 +333,7 @@ class Locale {
* @return string display name of the locale in the format
* appropriate for $in_locale.
*/
- public static function locale_get_display_name($locale, $in_locale = null) {}
+ function locale_get_display_name($locale, $in_locale = null) {}
/**
@@ -344,7 +345,7 @@ class Locale {
* @return string display name of the language for the $locale in the format
* appropriate for $in_locale.
*/
- public static function locale_get_display_language($lang, $in_locale = null) {}
+ function locale_get_display_language($lang, $in_locale = null) {}
/**
* Returns an appropriately localized display name for script of the input locale
@@ -355,7 +356,7 @@ class Locale {
* @return string display name of the script for the $locale in the format
* appropriate for $in_locale.
*/
- public static function locale_get_display_script($script, $in_locale = null) {}
+ function locale_get_display_script($script, $in_locale = null) {}
/**
@@ -367,7 +368,7 @@ class Locale {
* @return string display name of the region for the $locale in the format
* appropriate for $in_locale.
*/
- public static function locale_get_display_region($region, $in_locale = null) {}
+ function locale_get_display_region($region, $in_locale = null) {}
/**
@@ -379,7 +380,7 @@ class Locale {
* @return string display name of the variant for the $locale in the format
* appropriate for $in_locale.
*/
- public static function locale_get_display_variant($variant, $in_locale = null) {}
+ function locale_get_display_variant($variant, $in_locale = null) {}
/**
@@ -388,9 +389,10 @@ class Locale {
*
* @param string $langtag the language tag to check
* @param string $locale the language range to check against
+ * @param bool $canonicalize Canonicalize parameters?
* @return boolean 'true' if $locale matches $langtag 'false' otherwise
*/
- public static function locale_filter_matches($langtag, $locale) {}
+ function locale_filter_matches($langtag, $locale, $canonicalize) {}
/**
* Searchs the items in $langtag for the best match to the language
@@ -403,7 +405,7 @@ class Locale {
* @return string closest matching language tag, $default,
* or empty string
*/
- public static function locale_lookup(array $langtag, $locale, $default = null) {}
+ function locale_lookup(array $langtag, $locale, $default = null) {}
/**
@@ -415,7 +417,7 @@ class Locale {
*
* @return string the corresponding locale identifier.
*/
- public static function locale_compose_locale(array $subtags) {}
+ function locale_compose_locale(array $subtags) {}
/**
@@ -427,6 +429,6 @@ class Locale {
* the keys identify the particular locale ID subtags,
* and the values are the associated subtag values.
*/
- public static function locale_parse_locale($locale) {}
+ function locale_parse_locale($locale) {}
?>
diff --git a/ext/intl/idn/idn.c b/ext/intl/idn/idn.c
index c5f1a70ad..ca7e9e7ba 100644
--- a/ext/intl/idn/idn.c
+++ b/ext/intl/idn/idn.c
@@ -15,7 +15,7 @@
| Author: Pierre A. Joye <pierre@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: idn.c,v 1.1.2.2 2009/05/10 13:26:38 bjori Exp $ */
+/* $Id: idn.c 283618 2009-07-06 23:48:27Z stas $ */
/* {{{ includes */
#ifdef HAVE_CONFIG_H
@@ -67,7 +67,7 @@ static void php_intl_idn_to(INTERNAL_FUNCTION_PARAMETERS, int mode)
UChar converted[MAXPATHLEN];
int32_t converted_ret_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ll", (char **)&domain, &domain_len, &option, &status) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", (char **)&domain, &domain_len, &option) == FAILURE) {
return;
}
@@ -121,8 +121,8 @@ static void php_intl_idn_to(INTERNAL_FUNCTION_PARAMETERS, int mode)
RETURN_STRINGL(((char *)converted_utf8), converted_utf8_len, 0);
}
-/* {{{ proto int idn_to_ascii(string domain[, int options [, int status]])
- Converts a UTF-8 domain to ASCII, as defined in the IDNA RFC */
+/* {{{ proto int idn_to_ascii(string domain[, int options])
+ Converts an Unicode domain to ASCII representation, as defined in the IDNA RFC */
PHP_FUNCTION(idn_to_ascii)
{
php_intl_idn_to(INTERNAL_FUNCTION_PARAM_PASSTHRU, INTL_IDN_TO_ASCII);
@@ -130,8 +130,8 @@ PHP_FUNCTION(idn_to_ascii)
/* }}} */
-/* {{{ proto int idn_to_utf8(string domain[, int options[, int status]])
- Converts a UTF-8 domain to ASCII, as defined in the IDNA RFC */
+/* {{{ proto int idn_to_utf8(string domain[, int options])
+ Converts an ASCII representation of the domain to Unicode (UTF-8), as defined in the IDNA RFC */
PHP_FUNCTION(idn_to_utf8)
{
php_intl_idn_to(INTERNAL_FUNCTION_PARAM_PASSTHRU, INTL_IDN_TO_UTF8);
diff --git a/ext/intl/idn/idn.h b/ext/intl/idn/idn.h
index c738f4e5d..ee3b84768 100644
--- a/ext/intl/idn/idn.h
+++ b/ext/intl/idn/idn.h
@@ -15,7 +15,7 @@
| Author: Pierre A. Joye <pierre@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: idn.h,v 1.1.2.1 2009/01/26 22:30:57 pajoye Exp $ s*/
+/* $Id: idn.h 274679 2009-01-26 22:30:57Z pajoye $ s*/
#ifndef IDN_IDN_H
#define IDN_IDN_H
diff --git a/ext/intl/intl_error.c b/ext/intl/intl_error.c
index 44f668b19..79ae153bb 100755
--- a/ext/intl/intl_error.c
+++ b/ext/intl/intl_error.c
@@ -103,6 +103,9 @@ void intl_error_set_custom_msg( intl_error* err, char* msg, int copyMsg TSRMLS_D
if( !msg )
return;
+ if(!err && INTL_G(error_level)) {
+ php_error_docref(NULL TSRMLS_CC, INTL_G(error_level), "%s", msg);
+ }
if( !err && !( err = intl_g_error_get( TSRMLS_C ) ) )
return;
diff --git a/ext/intl/locale/locale.c b/ext/intl/locale/locale.c
index a2f1cd6d1..9c3b4e1c5 100755
--- a/ext/intl/locale/locale.c
+++ b/ext/intl/locale/locale.c
@@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: locale.c,v 1.1.2.2 2008/08/03 11:33:44 jani Exp $ */
+/* $Id: locale.c 264111 2008-08-03 11:33:45Z jani $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
diff --git a/ext/intl/locale/locale.h b/ext/intl/locale/locale.h
index 452fcbb42..1661d8849 100755
--- a/ext/intl/locale/locale.h
+++ b/ext/intl/locale/locale.h
@@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: locale.h,v 1.1.2.2 2008/08/03 11:33:45 jani Exp $ */
+/* $Id: locale.h 264111 2008-08-03 11:33:45Z jani $ */
#ifndef LOCALE_LOCALE_H
#define LOCALE_LOCALE_H
diff --git a/ext/intl/locale/locale_class.c b/ext/intl/locale/locale_class.c
index 3a93fa434..7cde68892 100755
--- a/ext/intl/locale/locale_class.c
+++ b/ext/intl/locale/locale_class.c
@@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: locale_class.c,v 1.1.2.7 2008/11/17 11:27:56 felipe Exp $ */
+/* $Id: locale_class.c 269153 2008-11-17 11:28:01Z felipe $ */
#include <unicode/uloc.h>
#include "php_intl.h"
diff --git a/ext/intl/locale/locale_class.h b/ext/intl/locale/locale_class.h
index 0bf3592c1..bf0b933a1 100755
--- a/ext/intl/locale/locale_class.h
+++ b/ext/intl/locale/locale_class.h
@@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: locale_class.h,v 1.1.2.2 2008/08/03 11:33:45 jani Exp $ */
+/* $Id: locale_class.h 264111 2008-08-03 11:33:45Z jani $ */
#ifndef LOCALE_CLASS_H
#define LOCALE_CLASS_H
diff --git a/ext/intl/locale/locale_methods.c b/ext/intl/locale/locale_methods.c
index b47b171f2..9abdcdf3f 100755
--- a/ext/intl/locale/locale_methods.c
+++ b/ext/intl/locale/locale_methods.c
@@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: locale_methods.c,v 1.1.2.7 2008/08/03 11:33:45 jani Exp $ */
+/* $Id: locale_methods.c 283367 2009-07-02 22:36:16Z stas $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -145,16 +145,16 @@ static char* getPreferredTag(char* gf_tag)
static int getStrrtokenPos(char* str, int savedPos)
{
int result =-1;
- int i=0;
+ int i;
- for( i=savedPos; i>=0 ;i--){
- if( isIDSeparator(*(str+i)) ){
+ for(i=savedPos-1; i>=0; i--) {
+ if(isIDSeparator(*(str+i)) ){
/* delimiter found; check for singleton */
- if( isIDSeparator(*(str+i-2)) ){
+ if(i>=2 && isIDSeparator(*(str+i-2)) ){
/* a singleton; so send the position of token before the singleton */
- result = i-3;
+ result = i-2;
} else {
- result = i-1;
+ result = i;
}
break;
}
@@ -512,25 +512,6 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME
RETURN_FALSE;
}
}
-
-/*
- int singletonPos = 0;
- //Handle singletons
- if( (strcmp(tag_name , LOC_LANG_TAG)==0) && isIDPrefix(loc_name) ){
- //return mod_loc_name;
- } else {
- singletonPos = getSingletonPos( loc_name );
- if( singletonPos == 0){
- //singleton at start of script, region , variant etc.
- //or invalid singleton at start of language
- RETURN_FALSE;
- }else if(singletonPos > 0){
- //singleton at some position except at start
- //strip off the singleton and rest of the loc_name
- mod_loc_name = estrndup( loc_name , singletonPos-1);
- }
- }
-*/
} /* end of if != LOC_CANONICAL_TAG */
if( mod_loc_name==NULL ){
@@ -1187,7 +1168,7 @@ PHP_FUNCTION(locale_get_all_variants)
/* }}} */
/*{{{
-* Converts to lower case and also replaces all hyphuns with the underscore
+* Converts to lower case and also replaces all hyphens with the underscore
*/
static int strToMatch(char* str ,char *retstr)
{
@@ -1196,7 +1177,7 @@ static int strToMatch(char* str ,char *retstr)
int result = 0;
int len = 0;
- if( (!str) || strlen(str) ==0){
+ if( (!str) || str[0] == '\0'){
return result;
} else {
anchor = retstr;
@@ -1221,11 +1202,11 @@ static int strToMatch(char* str ,char *retstr)
}
/* }}} */
-/* {{{ proto static boolean Locale::filterMatches(string $langtag, string $locale)
+/* {{{ proto static boolean Locale::filterMatches(string $langtag, string $locale[, bool $canonicalize])
* Checks if a $langtag filter matches with $locale according to RFC 4647's basic filtering algorithm
*/
/* }}} */
-/* {{{ proto boolean locale_filter_matches(string $langtag, string $locale)
+/* {{{ proto boolean locale_filter_matches(string $langtag, string $locale[, bool $canonicalize])
* Checks if a $langtag filter matches with $locale according to RFC 4647's basic filtering algorithm
*/
PHP_FUNCTION(locale_filter_matches)
@@ -1250,7 +1231,7 @@ PHP_FUNCTION(locale_filter_matches)
intl_error_reset( NULL TSRMLS_CC );
- if(zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "ssb",
+ if(zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "ss|b",
&lang_tag, &lang_tag_len , &loc_range , &loc_range_len ,
&boolCanonical) == FAILURE)
{
@@ -1396,38 +1377,36 @@ static void array_cleanup( char* arr[] , int arr_size)
{
int i=0;
for( i=0; i< arr_size; i++ ){
- if( arr[i] ){
- efree( arr[i]);
+ if( arr[i*2] ){
+ efree( arr[i*2]);
}
}
-
+ efree(arr);
}
+#define LOOKUP_CLEAN_RETURN(value) array_cleanup(cur_arr, cur_arr_len); return (value)
/* {{{
* returns the lookup result to lookup_loc_range_src_php
* internal function
*/
-static char* lookup_loc_range(char* loc_range, HashTable* hash_arr , int isCanonical TSRMLS_DC)
+static char* lookup_loc_range(char* loc_range, HashTable* hash_arr, int canonicalize TSRMLS_DC)
{
- int cur_arr_ind = 0;
- int i = 0;
- int cur_arr_len = 0;
- int result = 0;
+ int i = 0;
+ int cur_arr_len = 0;
+ int result = 0;
- char* lang_tag = NULL;
- zval** ele_value = NULL;
- char* cur_arr[MAX_NO_LOOKUP_LANG_TAG] ;
+ char* lang_tag = NULL;
+ zval** ele_value = NULL;
+ char** cur_arr = NULL;
- char* loc_range_to_cmp = NULL;
- char* cur_loc_range = NULL;
- char* can_loc_range = NULL;
- int saved_pos = 0;
+ char* cur_loc_range = NULL;
+ char* can_loc_range = NULL;
+ int saved_pos = 0;
- char* return_value = NULL;
- UErrorCode status = U_ZERO_ERROR;
- char* empty_result = "";
+ char* return_value = NULL;
- /* convert the array to lowercase , also replace hyphuns with the underscore and store it in cur_arr */
+ cur_arr = ecalloc(zend_hash_num_elements(hash_arr)*2, sizeof(char *));
+ /* convert the array to lowercase , also replace hyphens with the underscore and store it in cur_arr */
for(zend_hash_internal_pointer_reset(hash_arr);
zend_hash_has_more_elements(hash_arr) == SUCCESS;
zend_hash_move_forward(hash_arr)) {
@@ -1436,163 +1415,115 @@ static char* lookup_loc_range(char* loc_range, HashTable* hash_arr , int isCanon
/* Should never actually fail since the key is known to exist.*/
continue;
}
- if( Z_TYPE_PP(ele_value)!= IS_STRING ){
+ if(Z_TYPE_PP(ele_value)!= IS_STRING) {
/* element value is not a string */
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "lookup_loc_range: array element is not a string ",
- 0 TSRMLS_CC );
- return NULL;
- } else {
- if( lang_tag ){
- efree( lang_tag );
- }
- lang_tag = estrdup(Z_STRVAL_PP(ele_value) );
-
- if( isCanonical ==0 ){
- /* +1 for the terminating '\0' */
- cur_arr[cur_arr_ind] = ecalloc(1, strlen(lang_tag)+1 );
- result = strToMatch(lang_tag, cur_arr[cur_arr_ind]) ;
- } else {
- cur_arr[cur_arr_ind] = estrdup(lang_tag);
- }
-
- if( cur_arr_ind < MAX_NO_LOOKUP_LANG_TAG ){
- cur_arr_ind++ ;
- } else {
- break;
- }
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "lookup_loc_range: locale array element is not a string", 0 TSRMLS_CC);
+ LOOKUP_CLEAN_RETURN(NULL);
+ }
+ cur_arr[cur_arr_len*2] = estrndup(Z_STRVAL_PP(ele_value), Z_STRLEN_PP(ele_value));
+ result = strToMatch(Z_STRVAL_PP(ele_value), cur_arr[cur_arr_len*2]);
+ if(result == 0) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "lookup_loc_range: unable to canonicalize lang_tag", 0 TSRMLS_CC);
+ LOOKUP_CLEAN_RETURN(NULL);
}
+ cur_arr[cur_arr_len*2+1] = Z_STRVAL_PP(ele_value);
+ cur_arr_len++ ;
} /* end of for */
- if( lang_tag ){
- efree( lang_tag );
- }
-
- cur_arr_len = cur_arr_ind;
-
/* Canonicalize array elements */
- if( isCanonical ==1 ){
- for( i=0; i< cur_arr_ind; i++ ){
- lang_tag =get_icu_value_internal( cur_arr[i] , LOC_CANONICALIZE_TAG , &result , 0);
- efree( cur_arr[i] );
- cur_arr[i] = ecalloc(1, strlen(lang_tag)+1 );
- result = strToMatch(lang_tag, cur_arr[i]) ;
- efree( lang_tag);
- if( result ==0) {
- intl_error_set( NULL, status,
- "locale_lookup : unable to canonicalize lang_tag" , 0 TSRMLS_CC );
- if( lang_tag ){
- efree( lang_tag );
+ if(canonicalize) {
+ for(i=0; i<cur_arr_len; i++) {
+ lang_tag = get_icu_value_internal(cur_arr[i*2], LOC_CANONICALIZE_TAG, &result, 0);
+ if(result != 1 || lang_tag == NULL || !lang_tag[0]) {
+ if(lang_tag) {
+ efree(lang_tag);
}
- array_cleanup( cur_arr , cur_arr_len );
- return NULL;
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "lookup_loc_range: unable to canonicalize lang_tag" , 0 TSRMLS_CC);
+ LOOKUP_CLEAN_RETURN(NULL);
+ }
+ cur_arr[i*2] = erealloc(cur_arr[i*2], strlen(lang_tag)+1);
+ result = strToMatch(lang_tag, cur_arr[i*2]);
+ efree(lang_tag);
+ if(result == 0) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "lookup_loc_range: unable to canonicalize lang_tag" , 0 TSRMLS_CC);
+ LOOKUP_CLEAN_RETURN(NULL);
}
}
}
- if( isCanonical ==1 ){
+ if(canonicalize) {
/* Canonicalize the loc_range */
- can_loc_range =get_icu_value_internal( loc_range, LOC_CANONICALIZE_TAG , &result , 0);
- if( result != 1 ){
+ can_loc_range = get_icu_value_internal(loc_range, LOC_CANONICALIZE_TAG, &result , 0);
+ if( result != 1 || can_loc_range == NULL || !can_loc_range[0]) {
/* Error */
- intl_error_set( NULL, status,
- "locale_lookup : unable to canonicalize loc_range" , 0 TSRMLS_CC );
- if( lang_tag ){
- efree( lang_tag );
- }
- if( can_loc_range ){
- efree( can_loc_range );
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "lookup_loc_range: unable to canonicalize loc_range" , 0 TSRMLS_CC );
+ if(can_loc_range) {
+ efree(can_loc_range);
}
- array_cleanup( cur_arr , cur_arr_len );
- return NULL;
+ LOOKUP_CLEAN_RETURN(NULL);
} else {
- /* convert to lower and replace hyphuns */
- cur_loc_range = ecalloc( 1, strlen(can_loc_range) +1);
- result = strToMatch(can_loc_range , cur_loc_range);
+ loc_range = can_loc_range;
}
- } else {
- cur_loc_range = ecalloc( 1, strlen(loc_range) +1);
- /* convert to lower and replace hyphuns */
- result = strToMatch(loc_range , cur_loc_range);
- }
+ }
+ cur_loc_range = ecalloc(1, strlen(loc_range)+1);
+ /* convert to lower and replace hyphens */
+ result = strToMatch(loc_range, cur_loc_range);
+ if(can_loc_range) {
+ efree(can_loc_range);
+ }
+ if(result == 0) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "lookup_loc_range: unable to canonicalize lang_tag" , 0 TSRMLS_CC);
+ LOOKUP_CLEAN_RETURN(NULL);
+ }
/* Lookup for the lang_tag match */
saved_pos = strlen(cur_loc_range);
- while(saved_pos!=(-1) ){
- if( loc_range_to_cmp){
- efree(loc_range_to_cmp);
- }
- loc_range_to_cmp = estrndup(cur_loc_range,saved_pos+1);
- for( i=0; i< cur_arr_ind; i++ ){
- if( cur_arr[i] && (strcmp(loc_range_to_cmp,cur_arr[i])==0) ){
+ while(saved_pos > 0) {
+ for(i=0; i< cur_arr_len; i++){
+ if(cur_arr[i*2] != NULL && strlen(cur_arr[i*2]) == saved_pos && strncmp(cur_loc_range, cur_arr[i*2], saved_pos) == 0) {
/* Match found */
- return_value = estrdup( cur_arr[i] );
- if ( cur_loc_range ){
- efree( cur_loc_range );
- }
- if( loc_range_to_cmp){
- efree(loc_range_to_cmp);
- }
- if( can_loc_range ){
- efree( can_loc_range );
- }
- array_cleanup( cur_arr , cur_arr_len );
- return return_value;
+ return_value = estrdup(canonicalize?cur_arr[i*2]:cur_arr[i*2+1]);
+ efree(cur_loc_range);
+ LOOKUP_CLEAN_RETURN(return_value);
}
}
- saved_pos = getStrrtokenPos( cur_loc_range , saved_pos );
- }
-
- if( loc_range_to_cmp){
- efree(loc_range_to_cmp);
- }
- if ( cur_loc_range ){
- efree( cur_loc_range );
+ saved_pos = getStrrtokenPos(cur_loc_range, saved_pos);
}
- if( can_loc_range ){
- efree( can_loc_range );
- }
- array_cleanup( cur_arr , cur_arr_len );
/* Match not found */
- return empty_result;
-
+ efree(cur_loc_range);
+ LOOKUP_CLEAN_RETURN(NULL);
}
/* }}} */
-/* {{{ proto string Locale::lookup(array $langtag, $locale[, $default = null])
+/* {{{ proto string Locale::lookup(array $langtag, string $locale[, bool $canonicalize[, string $default = null]])
* Searchs the items in $langtag for the best match to the language
* range
*/
/* }}} */
-/* {{{ proto string locale_lookup(array $langtag, $locale[, $default = null])
+/* {{{ proto string locale_lookup(array $langtag, string $locale[, bool $canonicalize[, string $default = null]])
* Searchs the items in $langtag for the best match to the language
* range
*/
PHP_FUNCTION(locale_lookup)
{
- char* fallback_loc = NULL;
- int fallback_loc_len = 0;
- char* loc_range = NULL;
- int loc_range_len = 0;
+ char* fallback_loc = NULL;
+ int fallback_loc_len = 0;
+ char* loc_range = NULL;
+ int loc_range_len = 0;
- zval* arr = NULL;
+ zval* arr = NULL;
HashTable* hash_arr = NULL;
- zend_bool boolCanonical = 0;
-
+ zend_bool boolCanonical = 0;
char* result =NULL;
intl_error_reset( NULL TSRMLS_CC );
- if(zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "asb|s",
- &arr,&loc_range,&loc_range_len,&boolCanonical,
- &fallback_loc,&fallback_loc_len) == FAILURE)
- {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "locale_lookup: unable to parse input params", 0 TSRMLS_CC );
-
+ if(zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "as|bs", &arr, &loc_range, &loc_range_len,
+ &boolCanonical, &fallback_loc, &fallback_loc_len) == FAILURE) {
+ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "locale_lookup: unable to parse input params", 0 TSRMLS_CC );
RETURN_NULL();
}
@@ -1600,25 +1531,22 @@ PHP_FUNCTION(locale_lookup)
loc_range = INTL_G(default_locale);
}
- /* MAKE_STD_ZVAL(hash_arr); */
- hash_arr = HASH_OF( arr );
+ hash_arr = HASH_OF(arr);
- if( !hash_arr || zend_hash_num_elements( hash_arr ) == 0 ){
+ if( !hash_arr || zend_hash_num_elements( hash_arr ) == 0 ) {
RETURN_EMPTY_STRING();
- }
- else{
- result = lookup_loc_range( loc_range ,hash_arr ,(boolCanonical?1:0) TSRMLS_CC);
-
+ }
+
+ result = lookup_loc_range(loc_range, hash_arr, boolCanonical TSRMLS_CC);
if(result == NULL || result[0] == '\0') {
if( fallback_loc ) {
- result = estrndup( fallback_loc , fallback_loc_len);
+ result = estrndup(fallback_loc, fallback_loc_len);
} else {
RETURN_EMPTY_STRING();
}
}
-}
- RETVAL_STRINGL( result, strlen(result), 0);
+ RETVAL_STRINGL(result, strlen(result), 0);
}
/* }}} */
diff --git a/ext/intl/locale/locale_methods.h b/ext/intl/locale/locale_methods.h
index f7096a35f..9d1dcfde5 100755
--- a/ext/intl/locale/locale_methods.h
+++ b/ext/intl/locale/locale_methods.h
@@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: locale_methods.h,v 1.1.2.3 2008/08/03 11:33:45 jani Exp $ */
+/* $Id: locale_methods.h 264111 2008-08-03 11:33:45Z jani $ */
#ifndef LOCALE_METHODS_H
#define LOCALE_METHODS_H
diff --git a/ext/intl/php_intl.c b/ext/intl/php_intl.c
index 13f36fd03..831ace4d5 100755
--- a/ext/intl/php_intl.c
+++ b/ext/intl/php_intl.c
@@ -454,6 +454,7 @@ zend_function_entry intl_functions[] = {
/* {{{ INI Settings */
PHP_INI_BEGIN()
STD_PHP_INI_ENTRY(LOCALE_INI_NAME, NULL, PHP_INI_ALL, OnUpdateStringUnempty, default_locale, zend_intl_globals, intl_globals)
+ STD_PHP_INI_ENTRY("intl.error_level", "0", PHP_INI_ALL, OnUpdateLong, error_level, zend_intl_globals, intl_globals)
PHP_INI_END()
/* }}} */
diff --git a/ext/intl/php_intl.h b/ext/intl/php_intl.h
index 92663444e..61455b6fb 100755
--- a/ext/intl/php_intl.h
+++ b/ext/intl/php_intl.h
@@ -45,6 +45,7 @@ ZEND_BEGIN_MODULE_GLOBALS(intl)
collator_compare_func_t compare_func;
UBreakIterator* grapheme_iterator;
intl_error g_error;
+ long error_level;
ZEND_END_MODULE_GLOBALS(intl)
/* Macro to access request-wide global variables. */
diff --git a/ext/intl/tests/bug48227.phpt b/ext/intl/tests/bug48227.phpt
index 8f633c737..0ac0d5e55 100644
--- a/ext/intl/tests/bug48227.phpt
+++ b/ext/intl/tests/bug48227.phpt
@@ -1,5 +1,7 @@
--TEST--
Bug #48227 (NumberFormatter::format leaks memory)
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
--FILE--
<?php
diff --git a/ext/intl/tests/idn.phpt b/ext/intl/tests/idn.phpt
new file mode 100755
index 000000000..fde822a56
--- /dev/null
+++ b/ext/intl/tests/idn.phpt
@@ -0,0 +1,18 @@
+--TEST--
+IDN
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+/*
+ * Test IDN functions (procedural only)
+ */
+
+echo idn_to_ascii("t\xC3\xA4st.de")."\n";
+echo urlencode(idn_to_utf8('xn--tst-qla.de'))."\n";
+
+?>
+--EXPECT--
+xn--tst-qla.de
+t%C3%A4st.de \ No newline at end of file
diff --git a/ext/intl/tests/locale_lookup.phpt b/ext/intl/tests/locale_lookup.phpt
index 08f92ffc4..f0affafa6 100755
--- a/ext/intl/tests/locale_lookup.phpt
+++ b/ext/intl/tests/locale_lookup.phpt
@@ -71,19 +71,19 @@ ut_run();
loc_range:de-de
lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2
-lookup result:de_de
+lookup result:de-DE
Canonical lookup result:de_de
--------------
loc_range:sl_IT
lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2
-lookup result:sl_it
+lookup result:sl_IT
Canonical lookup result:sl_it
--------------
loc_range:sl_IT_Nedis
lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2
-lookup result:sl_it
+lookup result:sl_IT
Canonical lookup result:sl_it
--------------
loc_range:jbo
@@ -95,5 +95,5 @@ Canonical lookup result:jbo
loc_range:art-lojban
lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2
-lookup result:art_lojban
-Canonical lookup result:jbo \ No newline at end of file
+lookup result:art-lojban
+Canonical lookup result:jbo
diff --git a/ext/intl/tests/ut_common.inc b/ext/intl/tests/ut_common.inc
index 454bbaa53..4f2036123 100755
--- a/ext/intl/tests/ut_common.inc
+++ b/ext/intl/tests/ut_common.inc
@@ -1,388 +1,388 @@
-<?php
-/*
- * Run unit test in OO- and in procedural mode.
- * Then compare the outputs.
- * It they're equal then show one of them.
- * Otherwise indicate an error.
- */
-function ut_run()
-{
- // Run unit test in OO mode.
- $GLOBALS['oo-mode'] = true;
- $oo_result = ut_main();
-
- // Run unit test in procedural mode.
- $GLOBALS['oo-mode'] = false;
- $proc_result = ut_main();
-
- // Show error if the APIs produce different results.
- if( $proc_result !== $oo_result )
- {
- echo "ERROR: OO- and procedural APIs produce different results!\n";
- echo "OO API output:\n";
- echo str_repeat( '=', 78 ) . "\n";
- echo $oo_result;
- echo str_repeat( '=', 78 ) . "\n";
- echo "procedural API output:\n";
- echo str_repeat( '=', 78 ) . "\n";
- echo $proc_result;
- echo str_repeat( '=', 78 ) . "\n";
- return;
- }
-
- // Else, if the results are equal, show one of them.
- echo $proc_result;
-}
-
-function dump( $val )
-{
- return var_export( $val, true );
-}
-
-/*
- * Wrappers around Collator methods to run them in either OO- or procedural mode.
- */
-
-function ut_coll_create( $locale )
-{
- return $GLOBALS['oo-mode'] ? Collator::create( $locale ) : collator_create( $locale );
-}
-function ut_coll_compare( $coll, $str1, $str2 )
-{
- return $GLOBALS['oo-mode'] ? $coll->compare( $str1, $str2 ) : collator_compare( $coll, $str1, $str2 );
-}
-function ut_coll_sort( $coll, &$arr, $sort_flag = Collator::SORT_REGULAR )
-{
- return $GLOBALS['oo-mode'] ? $coll->sort( $arr, $sort_flag ) : collator_sort( $coll, $arr, $sort_flag );
-}
-function ut_coll_sort_with_sort_keys( $coll, &$arr )
-{
- return $GLOBALS['oo-mode'] ? $coll->sortWithSortKeys( $arr ) : collator_sort_with_sort_keys( $coll, $arr );
-}
-function ut_coll_asort( $coll, &$arr, $sort_flag = Collator::SORT_REGULAR )
-{
- return $GLOBALS['oo-mode'] ? $coll->asort( $arr, $sort_flag ) : collator_asort( $coll, $arr, $sort_flag );
-}
-function ut_coll_get_locale( $coll, $type )
-{
- return $GLOBALS['oo-mode'] ? $coll->getLocale( $type ) : collator_get_locale( $coll, $type );
-}
-function ut_coll_get_display_name( $obj_loc, $disp_loc )
-{
- return $GLOBALS['oo-mode'] ? Collator::getDisplayName( $obj_loc, $disp_loc ) : collator_get_display_name( $obj_loc, $disp_loc );
-}
-function ut_coll_get_available_locales()
-{
- return $GLOBALS['oo-mode'] ? Collator::getAvailableLocales() : collator_get_available_locales();
-}
-function ut_coll_get_attribute( $coll, $attr )
-{
- return $GLOBALS['oo-mode'] ? $coll->getAttribute( $attr ) : collator_get_attribute( $coll, $attr );
-}
-function ut_coll_get_strength( $coll )
-{
- return $GLOBALS['oo-mode'] ? $coll->getStrength() : collator_get_strength( $coll );
-}
-function ut_coll_set_strength( $coll, $strength )
-{
- return $GLOBALS['oo-mode'] ? $coll->setStrength( $strength ) : collator_set_strength( $coll, $strength );
-}
-function ut_coll_set_attribute( $coll, $attr, $val )
-{
- return $GLOBALS['oo-mode'] ? $coll->setAttribute( $attr, $val ) : collator_set_attribute( $coll, $attr, $val );
-}
-function ut_coll_get_variable_top( $coll )
-{
- return $GLOBALS['oo-mode'] ? $coll->getVariableTop() : collator_get_variable_top( $coll );
-}
-function ut_coll_set_variable_top( $coll, $var_top )
-{
- return $GLOBALS['oo-mode'] ? $coll->setVariableTop( $var_top ) : collator_set_variable_top( $coll, $var_top );
-}
-function ut_coll_restore_variable_top( $coll, $var_top )
-{
- return $GLOBALS['oo-mode'] ? $coll->restoreVariableTop( $var_top ) : collator_restore_variable_top( $coll, $var_top );
-}
-function ut_coll_get_error_code( $coll )
-{
- return $GLOBALS['oo-mode'] ? $coll->getErrorCode() : collator_get_error_code( $coll );
-}
-function ut_coll_get_error_message( $coll )
-{
- return $GLOBALS['oo-mode'] ? $coll->getErrorMessage() : collator_get_error_message( $coll );
-}
-function ut_coll_get_default()
-{
- return $GLOBALS['oo-mode'] ? Collator::getDefault() : collator_get_default();
-}
-function ut_coll_set_default( $coll )
-{
- return $GLOBALS['oo-mode'] ? Collator::setDefault( $coll ) : collator_set_default( $coll );
-}
-
-/*
- * Wrappers around NumberFormatter methods to run them in either OO- or procedural mode.
- */
-
-// FIXME: incomplete list
-
-function ut_nfmt_create( $locale, $style, $pattern = null )
-{
- return $GLOBALS['oo-mode'] ? new NumberFormatter( $locale, $style, $pattern ) : numfmt_create( $locale, $style, $pattern );
-}
-function ut_nfmt_format( $fmt, $number, $type = null )
-{
- return $GLOBALS['oo-mode'] ? $fmt->format( $number, $type ) : numfmt_format( $fmt, $number, $type );
-}
-function ut_nfmt_parse( $fmt, $string, $type = NumberFormatter::TYPE_DOUBLE, &$position = null )
-{
- if(is_null($position)) {
- return $GLOBALS['oo-mode'] ? $fmt->parse( $string, $type ) : numfmt_parse( $fmt, $string, $type );
- } else {
- return $GLOBALS['oo-mode'] ? $fmt->parse( $string, $type, $position ) : numfmt_parse( $fmt, $string, $type, $position );
- }
-}
-function ut_nfmt_format_currency( $fmt, $number, $currency )
-{
- return $GLOBALS['oo-mode'] ? $fmt->formatCurrency( $number, $currency ) : numfmt_format_currency( $fmt, $number, $currency );
-}
-function ut_nfmt_parse_currency( $fmt, $string, &$currency, &$position = null )
-{
- if(is_null($position)) {
- return $GLOBALS['oo-mode'] ? $fmt->parseCurrency( $string, $currency ) : numfmt_parse_currency( $fmt, $string, $currency );
- } else {
- return $GLOBALS['oo-mode'] ? $fmt->parseCurrency( $string, $currency, $position ) : numfmt_parse_currency( $fmt, $string, $currency, $position );
- }
-}
-function ut_nfmt_set_attribute( $fmt, $attribute, $value )
-{
- return $GLOBALS['oo-mode'] ? $fmt->setAttribute( $attribute, $value ) : numfmt_set_attribute( $fmt, $attribute, $value );
-}
-function ut_nfmt_set_text_attribute( $fmt, $attribute, $value )
-{
- return $GLOBALS['oo-mode'] ? $fmt->setTextAttribute( $attribute, $value ) : numfmt_set_text_attribute( $fmt, $attribute, $value );
-}
-function ut_nfmt_set_symbol( $fmt, $attribute, $value )
-{
- return $GLOBALS['oo-mode'] ? $fmt->setSymbol( $attribute, $value ) : numfmt_set_symbol( $fmt, $attribute, $value );
-}
-function ut_nfmt_set_pattern( $fmt, $pattern )
-{
- return $GLOBALS['oo-mode'] ? $fmt->setPattern( $pattern ) : numfmt_set_pattern( $fmt, $pattern );
-}
-function ut_nfmt_get_attribute( $fmt, $attribute )
-{
- return $GLOBALS['oo-mode'] ? $fmt->getAttribute( $attribute ) : numfmt_get_attribute( $fmt, $attribute );
-}
-function ut_nfmt_get_text_attribute( $fmt, $attribute )
-{
- return $GLOBALS['oo-mode'] ? $fmt->getTextAttribute( $attribute ) : numfmt_get_text_attribute( $fmt, $attribute );
-}
-function ut_nfmt_get_symbol( $fmt, $attribute )
-{
- return $GLOBALS['oo-mode'] ? $fmt->getSymbol( $attribute ) : numfmt_get_symbol( $fmt, $attribute );
-}
-function ut_nfmt_get_pattern( $fmt )
-{
- return $GLOBALS['oo-mode'] ? $fmt->getPattern() : numfmt_get_pattern( $fmt );
-}
-function ut_nfmt_get_locale( $fmt, $type = 0 )
-{
- return $GLOBALS['oo-mode'] ? $fmt->getLocale( $type ) : numfmt_get_locale( $fmt, $type );
-}
-function ut_nfmt_get_error_code( $fmt )
-{
- return $GLOBALS['oo-mode'] ? $fmt->getErrorCode() : numfmt_get_error_code( $fmt );
-}
-function ut_nfmt_get_error_message( $fmt )
-{
- return $GLOBALS['oo-mode'] ? $fmt->getErrorMessage() : numfmt_get_error_message( $fmt );
-}
-
-function ut_norm_normalize( $str, $form )
-{
- return $GLOBALS['oo-mode'] ? Normalizer::normalize( $str, $form ) : normalizer_normalize( $str, $form );
-}
-function ut_norm_is_normalized( $str, $form )
-{
- return $GLOBALS['oo-mode'] ? Normalizer::isNormalized( $str, $form ) : normalizer_is_normalized( $str, $form );
-}
-
-/*
- * Wrappers around Collator methods to run them in either OO- or procedural mode.
- */
-
-function ut_loc_get_default( )
-{
- return $GLOBALS['oo-mode'] ? Locale::getDefault( ) : locale_get_default();
-}
-function ut_loc_set_default( $locale )
-{
- return $GLOBALS['oo-mode'] ? Locale::setDefault( $locale ) : locale_set_default( $locale );
-}
-function ut_loc_get_primary_language( $locale )
-{
- return $GLOBALS['oo-mode'] ? Locale::getPrimaryLanguage( $locale ) : locale_get_primary_language( $locale );
-}
-function ut_loc_get_script( $locale )
-{
- return $GLOBALS['oo-mode'] ? Locale::getScript( $locale ) : locale_get_script( $locale );
-}
-function ut_loc_get_region( $locale )
-{
- return $GLOBALS['oo-mode'] ? Locale::getRegion( $locale ) : locale_get_region( $locale );
-}
-function ut_loc_get_keywords( $locale )
-{
- return $GLOBALS['oo-mode'] ? Locale::getKeywords( $locale ) : locale_get_keywords( $locale );
-}
-function ut_loc_get_display_name( $locale , $dispLocale )
-{
- return $GLOBALS['oo-mode'] ? Locale::getDisplayName( $locale , $dispLocale ) : locale_get_display_name( $locale , $dispLocale );
-}
-function ut_loc_get_display_language( $locale , $dispLocale )
-{
- return $GLOBALS['oo-mode'] ? Locale::getDisplayLanguage( $locale , $dispLocale ) : locale_get_display_language( $locale , $dispLocale );
-}
-function ut_loc_get_display_script( $locale , $dispLocale )
-{
- return $GLOBALS['oo-mode'] ? Locale::getDisplayScript( $locale , $dispLocale ) : locale_get_display_script( $locale , $dispLocale );
-}
-function ut_loc_get_display_region( $locale, $dispLocale )
-{
- return $GLOBALS['oo-mode'] ? Locale::getDisplayRegion( $locale, $dispLocale ) : locale_get_display_region( $locale, $dispLocale );
-}
-function ut_loc_get_display_variant( $locale , $dispLocale )
-{
- return $GLOBALS['oo-mode'] ? Locale::getDisplayVariant( $locale , $dispLocale ) : locale_get_display_variant( $locale, $dispLocale );
-}
-function ut_loc_locale_compose( $loc_parts_arr )
-{
- return $GLOBALS['oo-mode'] ? Locale::composeLocale( $loc_parts_arr ) : locale_compose( $loc_parts_arr );
-}
-function ut_loc_locale_parse( $locale )
-{
- return $GLOBALS['oo-mode'] ? Locale::parseLocale( $locale ) : locale_parse($locale );
-}
-function ut_loc_locale_get_all_variants( $locale )
-{
- return $GLOBALS['oo-mode'] ? Locale::getAllVariants( $locale ) : locale_get_all_variants( $locale );
-}
-function ut_loc_locale_filter_matches( $lang_tag,$loc_range ,$isCanonical)
-{
- return $GLOBALS['oo-mode'] ? Locale::filterMatches( $lang_tag,$loc_range ,$isCanonical) : locale_filter_matches( $lang_tag,$loc_range ,$isCanonical);
-}
-function ut_loc_canonicalize( $locale )
-{
- return $GLOBALS['oo-mode'] ? Locale::canonicalize( $locale ) : locale_canonicalize( $locale );
-}
-function ut_loc_locale_lookup( $lang_tag_arr,$loc_range,$isCanonical,$default_loc)
-{
- return $GLOBALS['oo-mode'] ? Locale::lookup( $lang_tag_arr,$loc_range,$isCanonical,$default_loc ) : locale_lookup( $lang_tag_arr,$loc_range,$isCanonical,$default_loc );
-}
-function ut_loc_accept_http($http) {
- return $GLOBALS['oo-mode'] ? Locale::acceptFromHttp($http):locale_accept_from_http($http);
-}
-/* MessageFormatter functions */
-function ut_msgfmt_create( $locale, $pattern)
-{
- return $GLOBALS['oo-mode'] ? MessageFormatter::create( $locale, $pattern ) : msgfmt_create( $locale, $pattern );
-}
-function ut_msgfmt_format( $fmt, $args )
-{
- return $GLOBALS['oo-mode'] ? $fmt->format( $args ) : msgfmt_format( $fmt, $args);
-}
-function ut_msgfmt_parse( $fmt, $string)
-{
- return $GLOBALS['oo-mode'] ? $fmt->parse( $string) : msgfmt_parse( $fmt, $string);
-}
-function ut_msgfmt_format_message( $locale, $pattern, $args )
-{
- return $GLOBALS['oo-mode'] ? MessageFormatter::formatMessage( $locale, $pattern, $args ) : msgfmt_format_message( $locale, $pattern, $args );
-}
-function ut_msgfmt_parse_message( $locale, $pattern, $string )
-{
- return $GLOBALS['oo-mode'] ? MessageFormatter::parseMessage( $locale, $pattern, $string ) : msgfmt_parse_message( $locale, $pattern, $string );
-}
-function ut_msgfmt_set_pattern( $fmt, $pattern )
-{
- return $GLOBALS['oo-mode'] ? $fmt->setPattern( $pattern ) : msgfmt_set_pattern( $fmt, $pattern );
-}
-function ut_msgfmt_get_pattern( $fmt )
-{
- return $GLOBALS['oo-mode'] ? $fmt->getPattern() : msgfmt_get_pattern( $fmt );
-}
-function ut_msgfmt_get_locale( $fmt )
-{
- return $GLOBALS['oo-mode'] ? $fmt->getLocale( ) : msgfmt_get_locale( $fmt );
-}
-function ut_msgfmt_get_error_code( $fmt )
-{
- return $GLOBALS['oo-mode'] ? $fmt->getErrorCode() : msgfmt_get_error_code( $fmt );
-}
-function ut_msgfmt_get_error_message( $fmt )
-{
- return $GLOBALS['oo-mode'] ? $fmt->getErrorMessage() : msgfmt_get_error_message( $fmt );
-}
-/* IntlDateFormatter functions */
-function ut_datefmt_create( $locale, $datetype, $timetype, $timezone = null, $calendar = null ,$pattern = null)
-{
- return $GLOBALS['oo-mode'] ? datefmt_create( $locale, $datetype, $timetype, $timezone, $calendar ,$pattern ) : datefmt_create( $locale, $datetype, $timetype, $timezone, $calendar ,$pattern);
-}
-function ut_datefmt_get_datetype( $fmt )
-{
- return $GLOBALS['oo-mode'] ? $fmt->getDateType( ) : datefmt_get_datetype( $fmt );
-}
-function ut_datefmt_get_timetype( $fmt )
-{
- return $GLOBALS['oo-mode'] ? $fmt->getTimeType( ) : datefmt_get_timetype( $fmt );
-}
-function ut_datefmt_get_calendar( $fmt )
-{
- return $GLOBALS['oo-mode'] ? $fmt->getCalendar( ) : datefmt_get_calendar( $fmt );
-}
-function ut_datefmt_set_calendar( $fmt ,$calendar )
-{
- return $GLOBALS['oo-mode'] ? $fmt->setCalendar( $calendar ) : datefmt_set_calendar( $fmt , $calendar );
-}
-function ut_datefmt_get_timezone_id( $fmt )
-{
- return $GLOBALS['oo-mode'] ? $fmt->getTimeZoneId( ) : datefmt_get_timezone_id( $fmt );
-}
-function ut_datefmt_set_timezone_id( $fmt ,$timezone_id )
-{
- return $GLOBALS['oo-mode'] ? $fmt->setTimeZoneId( $timezone_id ) : datefmt_set_timezone_id( $fmt ,$timezone_id);
-}
-function ut_datefmt_get_pattern( $fmt )
-{
- return $GLOBALS['oo-mode'] ? $fmt->getPattern() : datefmt_get_pattern( $fmt );
-}
-function ut_datefmt_set_pattern( $fmt , $pattern )
-{
- return $GLOBALS['oo-mode'] ? $fmt->setPattern( $pattern ) : datefmt_set_pattern( $fmt , $pattern);
-}
-function ut_datefmt_get_locale( $fmt ,$type=ULOC_ACTUAL_LOCALE)
-{
- return $GLOBALS['oo-mode'] ? $fmt->getLocale($type ) : datefmt_get_locale( $fmt ,$type);
-}
-function ut_datefmt_is_lenient( $fmt )
-{
- return $GLOBALS['oo-mode'] ? $fmt->isLenient() : datefmt_is_lenient( $fmt );
-}
-function ut_datefmt_set_lenient( $fmt , $lenient )
-{
- return $GLOBALS['oo-mode'] ? $fmt->setLenient( $lenient ) : datefmt_set_lenient( $fmt , $lenient);
-}
-function ut_datefmt_format( $fmt , $value )
-{
- return $GLOBALS['oo-mode'] ? $fmt->format( $value ) : datefmt_format( $fmt , $value);
-}
-function ut_datefmt_parse( $fmt , $value , &$parse_pos=0 )
-{
- return $GLOBALS['oo-mode'] ? $fmt->parse( $value ,$parse_pos ) : datefmt_parse( $fmt , $value,$parse_pos);
-}
-function ut_datefmt_localtime( $fmt , $value , &$parse_pos=0 )
-{
- return $GLOBALS['oo-mode'] ? $fmt->localtime( $value , $parse_pos ) : datefmt_localtime( $fmt , $value , $parse_pos );
-}
-?>
+<?php
+/*
+ * Run unit test in OO- and in procedural mode.
+ * Then compare the outputs.
+ * It they're equal then show one of them.
+ * Otherwise indicate an error.
+ */
+function ut_run()
+{
+ // Run unit test in OO mode.
+ $GLOBALS['oo-mode'] = true;
+ $oo_result = ut_main();
+
+ // Run unit test in procedural mode.
+ $GLOBALS['oo-mode'] = false;
+ $proc_result = ut_main();
+
+ // Show error if the APIs produce different results.
+ if( $proc_result !== $oo_result )
+ {
+ echo "ERROR: OO- and procedural APIs produce different results!\n";
+ echo "OO API output:\n";
+ echo str_repeat( '=', 78 ) . "\n";
+ echo $oo_result;
+ echo str_repeat( '=', 78 ) . "\n";
+ echo "procedural API output:\n";
+ echo str_repeat( '=', 78 ) . "\n";
+ echo $proc_result;
+ echo str_repeat( '=', 78 ) . "\n";
+ return;
+ }
+
+ // Else, if the results are equal, show one of them.
+ echo $proc_result;
+}
+
+function dump( $val )
+{
+ return var_export( $val, true );
+}
+
+/*
+ * Wrappers around Collator methods to run them in either OO- or procedural mode.
+ */
+
+function ut_coll_create( $locale )
+{
+ return $GLOBALS['oo-mode'] ? Collator::create( $locale ) : collator_create( $locale );
+}
+function ut_coll_compare( $coll, $str1, $str2 )
+{
+ return $GLOBALS['oo-mode'] ? $coll->compare( $str1, $str2 ) : collator_compare( $coll, $str1, $str2 );
+}
+function ut_coll_sort( $coll, &$arr, $sort_flag = Collator::SORT_REGULAR )
+{
+ return $GLOBALS['oo-mode'] ? $coll->sort( $arr, $sort_flag ) : collator_sort( $coll, $arr, $sort_flag );
+}
+function ut_coll_sort_with_sort_keys( $coll, &$arr )
+{
+ return $GLOBALS['oo-mode'] ? $coll->sortWithSortKeys( $arr ) : collator_sort_with_sort_keys( $coll, $arr );
+}
+function ut_coll_asort( $coll, &$arr, $sort_flag = Collator::SORT_REGULAR )
+{
+ return $GLOBALS['oo-mode'] ? $coll->asort( $arr, $sort_flag ) : collator_asort( $coll, $arr, $sort_flag );
+}
+function ut_coll_get_locale( $coll, $type )
+{
+ return $GLOBALS['oo-mode'] ? $coll->getLocale( $type ) : collator_get_locale( $coll, $type );
+}
+function ut_coll_get_display_name( $obj_loc, $disp_loc )
+{
+ return $GLOBALS['oo-mode'] ? Collator::getDisplayName( $obj_loc, $disp_loc ) : collator_get_display_name( $obj_loc, $disp_loc );
+}
+function ut_coll_get_available_locales()
+{
+ return $GLOBALS['oo-mode'] ? Collator::getAvailableLocales() : collator_get_available_locales();
+}
+function ut_coll_get_attribute( $coll, $attr )
+{
+ return $GLOBALS['oo-mode'] ? $coll->getAttribute( $attr ) : collator_get_attribute( $coll, $attr );
+}
+function ut_coll_get_strength( $coll )
+{
+ return $GLOBALS['oo-mode'] ? $coll->getStrength() : collator_get_strength( $coll );
+}
+function ut_coll_set_strength( $coll, $strength )
+{
+ return $GLOBALS['oo-mode'] ? $coll->setStrength( $strength ) : collator_set_strength( $coll, $strength );
+}
+function ut_coll_set_attribute( $coll, $attr, $val )
+{
+ return $GLOBALS['oo-mode'] ? $coll->setAttribute( $attr, $val ) : collator_set_attribute( $coll, $attr, $val );
+}
+function ut_coll_get_variable_top( $coll )
+{
+ return $GLOBALS['oo-mode'] ? $coll->getVariableTop() : collator_get_variable_top( $coll );
+}
+function ut_coll_set_variable_top( $coll, $var_top )
+{
+ return $GLOBALS['oo-mode'] ? $coll->setVariableTop( $var_top ) : collator_set_variable_top( $coll, $var_top );
+}
+function ut_coll_restore_variable_top( $coll, $var_top )
+{
+ return $GLOBALS['oo-mode'] ? $coll->restoreVariableTop( $var_top ) : collator_restore_variable_top( $coll, $var_top );
+}
+function ut_coll_get_error_code( $coll )
+{
+ return $GLOBALS['oo-mode'] ? $coll->getErrorCode() : collator_get_error_code( $coll );
+}
+function ut_coll_get_error_message( $coll )
+{
+ return $GLOBALS['oo-mode'] ? $coll->getErrorMessage() : collator_get_error_message( $coll );
+}
+function ut_coll_get_default()
+{
+ return $GLOBALS['oo-mode'] ? Collator::getDefault() : collator_get_default();
+}
+function ut_coll_set_default( $coll )
+{
+ return $GLOBALS['oo-mode'] ? Collator::setDefault( $coll ) : collator_set_default( $coll );
+}
+
+/*
+ * Wrappers around NumberFormatter methods to run them in either OO- or procedural mode.
+ */
+
+// FIXME: incomplete list
+
+function ut_nfmt_create( $locale, $style, $pattern = null )
+{
+ return $GLOBALS['oo-mode'] ? new NumberFormatter( $locale, $style, $pattern ) : numfmt_create( $locale, $style, $pattern );
+}
+function ut_nfmt_format( $fmt, $number, $type = null )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->format( $number, $type ) : numfmt_format( $fmt, $number, $type );
+}
+function ut_nfmt_parse( $fmt, $string, $type = NumberFormatter::TYPE_DOUBLE, &$position = null )
+{
+ if(is_null($position)) {
+ return $GLOBALS['oo-mode'] ? $fmt->parse( $string, $type ) : numfmt_parse( $fmt, $string, $type );
+ } else {
+ return $GLOBALS['oo-mode'] ? $fmt->parse( $string, $type, $position ) : numfmt_parse( $fmt, $string, $type, $position );
+ }
+}
+function ut_nfmt_format_currency( $fmt, $number, $currency )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->formatCurrency( $number, $currency ) : numfmt_format_currency( $fmt, $number, $currency );
+}
+function ut_nfmt_parse_currency( $fmt, $string, &$currency, &$position = null )
+{
+ if(is_null($position)) {
+ return $GLOBALS['oo-mode'] ? $fmt->parseCurrency( $string, $currency ) : numfmt_parse_currency( $fmt, $string, $currency );
+ } else {
+ return $GLOBALS['oo-mode'] ? $fmt->parseCurrency( $string, $currency, $position ) : numfmt_parse_currency( $fmt, $string, $currency, $position );
+ }
+}
+function ut_nfmt_set_attribute( $fmt, $attribute, $value )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->setAttribute( $attribute, $value ) : numfmt_set_attribute( $fmt, $attribute, $value );
+}
+function ut_nfmt_set_text_attribute( $fmt, $attribute, $value )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->setTextAttribute( $attribute, $value ) : numfmt_set_text_attribute( $fmt, $attribute, $value );
+}
+function ut_nfmt_set_symbol( $fmt, $attribute, $value )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->setSymbol( $attribute, $value ) : numfmt_set_symbol( $fmt, $attribute, $value );
+}
+function ut_nfmt_set_pattern( $fmt, $pattern )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->setPattern( $pattern ) : numfmt_set_pattern( $fmt, $pattern );
+}
+function ut_nfmt_get_attribute( $fmt, $attribute )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getAttribute( $attribute ) : numfmt_get_attribute( $fmt, $attribute );
+}
+function ut_nfmt_get_text_attribute( $fmt, $attribute )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getTextAttribute( $attribute ) : numfmt_get_text_attribute( $fmt, $attribute );
+}
+function ut_nfmt_get_symbol( $fmt, $attribute )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getSymbol( $attribute ) : numfmt_get_symbol( $fmt, $attribute );
+}
+function ut_nfmt_get_pattern( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getPattern() : numfmt_get_pattern( $fmt );
+}
+function ut_nfmt_get_locale( $fmt, $type = 0 )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getLocale( $type ) : numfmt_get_locale( $fmt, $type );
+}
+function ut_nfmt_get_error_code( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getErrorCode() : numfmt_get_error_code( $fmt );
+}
+function ut_nfmt_get_error_message( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getErrorMessage() : numfmt_get_error_message( $fmt );
+}
+
+function ut_norm_normalize( $str, $form )
+{
+ return $GLOBALS['oo-mode'] ? Normalizer::normalize( $str, $form ) : normalizer_normalize( $str, $form );
+}
+function ut_norm_is_normalized( $str, $form )
+{
+ return $GLOBALS['oo-mode'] ? Normalizer::isNormalized( $str, $form ) : normalizer_is_normalized( $str, $form );
+}
+
+/*
+ * Wrappers around Collator methods to run them in either OO- or procedural mode.
+ */
+
+function ut_loc_get_default( )
+{
+ return $GLOBALS['oo-mode'] ? Locale::getDefault( ) : locale_get_default();
+}
+function ut_loc_set_default( $locale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::setDefault( $locale ) : locale_set_default( $locale );
+}
+function ut_loc_get_primary_language( $locale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::getPrimaryLanguage( $locale ) : locale_get_primary_language( $locale );
+}
+function ut_loc_get_script( $locale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::getScript( $locale ) : locale_get_script( $locale );
+}
+function ut_loc_get_region( $locale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::getRegion( $locale ) : locale_get_region( $locale );
+}
+function ut_loc_get_keywords( $locale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::getKeywords( $locale ) : locale_get_keywords( $locale );
+}
+function ut_loc_get_display_name( $locale , $dispLocale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::getDisplayName( $locale , $dispLocale ) : locale_get_display_name( $locale , $dispLocale );
+}
+function ut_loc_get_display_language( $locale , $dispLocale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::getDisplayLanguage( $locale , $dispLocale ) : locale_get_display_language( $locale , $dispLocale );
+}
+function ut_loc_get_display_script( $locale , $dispLocale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::getDisplayScript( $locale , $dispLocale ) : locale_get_display_script( $locale , $dispLocale );
+}
+function ut_loc_get_display_region( $locale, $dispLocale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::getDisplayRegion( $locale, $dispLocale ) : locale_get_display_region( $locale, $dispLocale );
+}
+function ut_loc_get_display_variant( $locale , $dispLocale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::getDisplayVariant( $locale , $dispLocale ) : locale_get_display_variant( $locale, $dispLocale );
+}
+function ut_loc_locale_compose( $loc_parts_arr )
+{
+ return $GLOBALS['oo-mode'] ? Locale::composeLocale( $loc_parts_arr ) : locale_compose( $loc_parts_arr );
+}
+function ut_loc_locale_parse( $locale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::parseLocale( $locale ) : locale_parse($locale );
+}
+function ut_loc_locale_get_all_variants( $locale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::getAllVariants( $locale ) : locale_get_all_variants( $locale );
+}
+function ut_loc_locale_filter_matches( $lang_tag,$loc_range ,$isCanonical)
+{
+ return $GLOBALS['oo-mode'] ? Locale::filterMatches( $lang_tag,$loc_range ,$isCanonical) : locale_filter_matches( $lang_tag,$loc_range ,$isCanonical);
+}
+function ut_loc_canonicalize( $locale )
+{
+ return $GLOBALS['oo-mode'] ? Locale::canonicalize( $locale ) : locale_canonicalize( $locale );
+}
+function ut_loc_locale_lookup( $lang_tag_arr,$loc_range,$isCanonical,$default_loc)
+{
+ return $GLOBALS['oo-mode'] ? Locale::lookup( $lang_tag_arr,$loc_range,$isCanonical,$default_loc ) : locale_lookup( $lang_tag_arr,$loc_range,$isCanonical,$default_loc );
+}
+function ut_loc_accept_http($http) {
+ return $GLOBALS['oo-mode'] ? Locale::acceptFromHttp($http):locale_accept_from_http($http);
+}
+/* MessageFormatter functions */
+function ut_msgfmt_create( $locale, $pattern)
+{
+ return $GLOBALS['oo-mode'] ? MessageFormatter::create( $locale, $pattern ) : msgfmt_create( $locale, $pattern );
+}
+function ut_msgfmt_format( $fmt, $args )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->format( $args ) : msgfmt_format( $fmt, $args);
+}
+function ut_msgfmt_parse( $fmt, $string)
+{
+ return $GLOBALS['oo-mode'] ? $fmt->parse( $string) : msgfmt_parse( $fmt, $string);
+}
+function ut_msgfmt_format_message( $locale, $pattern, $args )
+{
+ return $GLOBALS['oo-mode'] ? MessageFormatter::formatMessage( $locale, $pattern, $args ) : msgfmt_format_message( $locale, $pattern, $args );
+}
+function ut_msgfmt_parse_message( $locale, $pattern, $string )
+{
+ return $GLOBALS['oo-mode'] ? MessageFormatter::parseMessage( $locale, $pattern, $string ) : msgfmt_parse_message( $locale, $pattern, $string );
+}
+function ut_msgfmt_set_pattern( $fmt, $pattern )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->setPattern( $pattern ) : msgfmt_set_pattern( $fmt, $pattern );
+}
+function ut_msgfmt_get_pattern( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getPattern() : msgfmt_get_pattern( $fmt );
+}
+function ut_msgfmt_get_locale( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getLocale( ) : msgfmt_get_locale( $fmt );
+}
+function ut_msgfmt_get_error_code( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getErrorCode() : msgfmt_get_error_code( $fmt );
+}
+function ut_msgfmt_get_error_message( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getErrorMessage() : msgfmt_get_error_message( $fmt );
+}
+/* IntlDateFormatter functions */
+function ut_datefmt_create( $locale, $datetype, $timetype, $timezone = null, $calendar = null ,$pattern = null)
+{
+ return $GLOBALS['oo-mode'] ? datefmt_create( $locale, $datetype, $timetype, $timezone, $calendar ,$pattern ) : datefmt_create( $locale, $datetype, $timetype, $timezone, $calendar ,$pattern);
+}
+function ut_datefmt_get_datetype( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getDateType( ) : datefmt_get_datetype( $fmt );
+}
+function ut_datefmt_get_timetype( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getTimeType( ) : datefmt_get_timetype( $fmt );
+}
+function ut_datefmt_get_calendar( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getCalendar( ) : datefmt_get_calendar( $fmt );
+}
+function ut_datefmt_set_calendar( $fmt ,$calendar )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->setCalendar( $calendar ) : datefmt_set_calendar( $fmt , $calendar );
+}
+function ut_datefmt_get_timezone_id( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getTimeZoneId( ) : datefmt_get_timezone_id( $fmt );
+}
+function ut_datefmt_set_timezone_id( $fmt ,$timezone_id )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->setTimeZoneId( $timezone_id ) : datefmt_set_timezone_id( $fmt ,$timezone_id);
+}
+function ut_datefmt_get_pattern( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getPattern() : datefmt_get_pattern( $fmt );
+}
+function ut_datefmt_set_pattern( $fmt , $pattern )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->setPattern( $pattern ) : datefmt_set_pattern( $fmt , $pattern);
+}
+function ut_datefmt_get_locale( $fmt ,$type=ULOC_ACTUAL_LOCALE)
+{
+ return $GLOBALS['oo-mode'] ? $fmt->getLocale($type ) : datefmt_get_locale( $fmt ,$type);
+}
+function ut_datefmt_is_lenient( $fmt )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->isLenient() : datefmt_is_lenient( $fmt );
+}
+function ut_datefmt_set_lenient( $fmt , $lenient )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->setLenient( $lenient ) : datefmt_set_lenient( $fmt , $lenient);
+}
+function ut_datefmt_format( $fmt , $value )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->format( $value ) : datefmt_format( $fmt , $value);
+}
+function ut_datefmt_parse( $fmt , $value , &$parse_pos=0 )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->parse( $value ,$parse_pos ) : datefmt_parse( $fmt , $value,$parse_pos);
+}
+function ut_datefmt_localtime( $fmt , $value , &$parse_pos=0 )
+{
+ return $GLOBALS['oo-mode'] ? $fmt->localtime( $value , $parse_pos ) : datefmt_localtime( $fmt , $value , $parse_pos );
+}
+?>