diff options
| author | Ondřej Surý <ondrej@sury.org> | 2011-03-18 11:28:21 +0100 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2011-03-18 11:28:21 +0100 |
| commit | 038ba12e8724d537040e88ec794354b0c063f0a6 (patch) | |
| tree | a7181b4f4d10e3a154522d4b96fdf42f4597bf2a /ext/intl | |
| parent | fd5a0b31640419ca63d1ddeaffd6d3cf2a741814 (diff) | |
| download | php-038ba12e8724d537040e88ec794354b0c063f0a6.tar.gz | |
Imported Upstream version 5.3.6upstream/5.3.6
Diffstat (limited to 'ext/intl')
28 files changed, 413 insertions, 187 deletions
diff --git a/ext/intl/collator/collator_class.c b/ext/intl/collator/collator_class.c index ee16ee03e..58a11fe46 100755 --- a/ext/intl/collator/collator_class.c +++ b/ext/intl/collator/collator_class.c @@ -29,6 +29,7 @@ #include <unicode/ucol.h> zend_class_entry *Collator_ce_ptr = NULL; +static zend_object_handlers Collator_handlers; /* * Auxiliary functions needed by objects of 'Collator' class @@ -73,7 +74,7 @@ zend_object_value Collator_object_create( (zend_objects_free_object_storage_t)Collator_objects_free, NULL TSRMLS_CC ); - retval.handlers = zend_get_std_object_handlers(); + retval.handlers = &Collator_handlers; return retval; } @@ -142,6 +143,12 @@ void collator_register_Collator_class( TSRMLS_D ) ce.create_object = Collator_object_create; Collator_ce_ptr = zend_register_internal_class( &ce TSRMLS_CC ); + memcpy(&Collator_handlers, zend_get_std_object_handlers(), + sizeof Collator_handlers); + /* Collator has no usable clone semantics - ucol_cloneBinary/ucol_openBinary require binary buffer + for which we don't have the place to keep */ + Collator_handlers.clone_obj = NULL; + /* Declare 'Collator' class properties. */ if( !Collator_ce_ptr ) { diff --git a/ext/intl/dateformat/dateformat_class.c b/ext/intl/dateformat/dateformat_class.c index 7df95816e..74c193bc0 100755 --- a/ext/intl/dateformat/dateformat_class.c +++ b/ext/intl/dateformat/dateformat_class.c @@ -24,6 +24,7 @@ #include "dateformat_attr.h" zend_class_entry *IntlDateFormatter_ce_ptr = NULL; +static zend_object_handlers IntlDateFormatter_handlers; /* * Auxiliary functions needed by objects of 'IntlDateFormatter' class @@ -73,12 +74,36 @@ zend_object_value IntlDateFormatter_object_create(zend_class_entry *ce TSRMLS_DC (zend_objects_free_object_storage_t)IntlDateFormatter_object_free, NULL TSRMLS_CC ); - retval.handlers = zend_get_std_object_handlers(); + retval.handlers = &IntlDateFormatter_handlers; return retval; } /* }}} */ +/* {{{ IntlDateFormatter_object_clone */ +zend_object_value IntlDateFormatter_object_clone(zval *object TSRMLS_DC) +{ + zend_object_value new_obj_val; + zend_object_handle handle = Z_OBJ_HANDLE_P(object); + IntlDateFormatter_object *dfo, *new_dfo; + + DATE_FORMAT_METHOD_FETCH_OBJECT; + new_obj_val = IntlDateFormatter_ce_ptr->create_object(IntlDateFormatter_ce_ptr TSRMLS_CC); + new_dfo = (IntlDateFormatter_object *)zend_object_store_get_object_by_handle(new_obj_val.handle TSRMLS_CC); + /* clone standard parts */ + zend_objects_clone_members(&new_dfo->zo, new_obj_val, &dfo->zo, handle TSRMLS_CC); + /* clone formatter object */ + DATE_FORMAT_OBJECT(new_dfo) = udat_clone(DATE_FORMAT_OBJECT(dfo), &INTL_DATA_ERROR_CODE(new_dfo)); + if(U_FAILURE(INTL_DATA_ERROR_CODE(new_dfo))) { + /* set up error in case error handler is interested */ + intl_error_set( NULL, INTL_DATA_ERROR_CODE(new_dfo), "Failed to clone IntlDateFormatter object", 0 TSRMLS_CC ); + IntlDateFormatter_object_dtor(new_dfo, new_obj_val.handle TSRMLS_CC); /* free new object */ + zend_error(E_ERROR, "Failed to clone IntlDateFormatter object"); + } + return new_obj_val; +} +/* }}} */ + /* * 'IntlDateFormatter' class registration structures & functions */ @@ -161,6 +186,10 @@ void dateformat_register_IntlDateFormatter_class( TSRMLS_D ) ce.create_object = IntlDateFormatter_object_create; IntlDateFormatter_ce_ptr = zend_register_internal_class( &ce TSRMLS_CC ); + memcpy(&IntlDateFormatter_handlers, zend_get_std_object_handlers(), + sizeof IntlDateFormatter_handlers); + IntlDateFormatter_handlers.clone_obj = IntlDateFormatter_object_clone; + /* Declare 'IntlDateFormatter' class properties. */ if( !IntlDateFormatter_ce_ptr ) { diff --git a/ext/intl/formatter/formatter_attr.c b/ext/intl/formatter/formatter_attr.c index 851b2b310..46d61fb1f 100755 --- a/ext/intl/formatter/formatter_attr.c +++ b/ext/intl/formatter/formatter_attr.c @@ -311,6 +311,11 @@ PHP_FUNCTION( numfmt_set_symbol ) RETURN_FALSE; } + + if (symbol >= UNUM_FORMAT_SYMBOL_COUNT || symbol < 0) { + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "numfmt_set_symbol: invalid symbol value", 0 TSRMLS_CC ); + RETURN_FALSE; + } /* Fetch the object. */ FORMATTER_METHOD_FETCH_OBJECT; diff --git a/ext/intl/formatter/formatter_class.c b/ext/intl/formatter/formatter_class.c index a6f45108e..07d07b64c 100755 --- a/ext/intl/formatter/formatter_class.c +++ b/ext/intl/formatter/formatter_class.c @@ -25,6 +25,7 @@ #include "formatter_attr.h" zend_class_entry *NumberFormatter_ce_ptr = NULL; +static zend_object_handlers NumberFormatter_handlers; /* * Auxiliary functions needed by objects of 'NumberFormatter' class @@ -53,8 +54,7 @@ void NumberFormatter_object_free( zend_object *object TSRMLS_DC ) /* }}} */ /* {{{ NumberFormatter_object_create */ -zend_object_value NumberFormatter_object_create( - zend_class_entry *ce TSRMLS_DC ) +zend_object_value NumberFormatter_object_create(zend_class_entry *ce TSRMLS_DC) { zend_object_value retval; NumberFormatter_object* intern; @@ -69,12 +69,36 @@ zend_object_value NumberFormatter_object_create( (zend_objects_free_object_storage_t)NumberFormatter_object_free, NULL TSRMLS_CC ); - retval.handlers = zend_get_std_object_handlers(); + retval.handlers = &NumberFormatter_handlers; return retval; } /* }}} */ +/* {{{ NumberFormatter_object_clone */ +zend_object_value NumberFormatter_object_clone(zval *object TSRMLS_DC) +{ + zend_object_value new_obj_val; + zend_object_handle handle = Z_OBJ_HANDLE_P(object); + NumberFormatter_object *nfo, *new_nfo; + + FORMATTER_METHOD_FETCH_OBJECT; + new_obj_val = NumberFormatter_ce_ptr->create_object(NumberFormatter_ce_ptr TSRMLS_CC); + new_nfo = (NumberFormatter_object *)zend_object_store_get_object_by_handle(new_obj_val.handle TSRMLS_CC); + /* clone standard parts */ + zend_objects_clone_members(&new_nfo->zo, new_obj_val, &nfo->zo, handle TSRMLS_CC); + /* clone formatter object */ + FORMATTER_OBJECT(new_nfo) = unum_clone(FORMATTER_OBJECT(nfo), &INTL_DATA_ERROR_CODE(new_nfo)); + if(U_FAILURE(INTL_DATA_ERROR_CODE(new_nfo))) { + /* set up error in case error handler is interested */ + intl_error_set( NULL, INTL_DATA_ERROR_CODE(new_nfo), "Failed to clone NumberFormatter object", 0 TSRMLS_CC ); + NumberFormatter_object_dtor(new_nfo, new_obj_val.handle TSRMLS_CC); /* free new object */ + zend_error(E_ERROR, "Failed to clone NumberFormatter object"); + } + return new_obj_val; +} +/* }}} */ + /* * 'NumberFormatter' class registration structures & functions */ @@ -171,6 +195,10 @@ void formatter_register_class( TSRMLS_D ) ce.create_object = NumberFormatter_object_create; NumberFormatter_ce_ptr = zend_register_internal_class( &ce TSRMLS_CC ); + memcpy(&NumberFormatter_handlers, zend_get_std_object_handlers(), + sizeof(NumberFormatter_handlers)); + NumberFormatter_handlers.clone_obj = NumberFormatter_object_clone; + /* Declare 'NumberFormatter' class properties. */ if( !NumberFormatter_ce_ptr ) { diff --git a/ext/intl/grapheme/grapheme_string.c b/ext/intl/grapheme/grapheme_string.c index ba883f34a..1784d028a 100755 --- a/ext/intl/grapheme/grapheme_string.c +++ b/ext/intl/grapheme/grapheme_string.c @@ -70,8 +70,8 @@ PHP_FUNCTION(grapheme_strlen) } ret_len = grapheme_ascii_check(string, string_len); - - if ( ret_len >= 0 ) + + if ( ret_len >= 0 ) RETURN_LONG(ret_len); /* convert the string to UTF-16. */ @@ -87,7 +87,7 @@ PHP_FUNCTION(grapheme_strlen) efree( ustring ); RETURN_NULL(); } - + ret_len = grapheme_split_string(ustring, ustring_len, NULL, 0 TSRMLS_CC ); efree( ustring ); @@ -110,37 +110,37 @@ PHP_FUNCTION(grapheme_strpos) long loffset = 0; int32_t offset = 0; int ret_pos, uchar_pos; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", (char **)&haystack, &haystack_len, (char **)&needle, &needle_len, &loffset) == FAILURE) { - + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_strpos: unable to parse input param", 0 TSRMLS_CC ); - + RETURN_FALSE; } if ( OUTSIDE_STRING(loffset, haystack_len) ) { - + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_strpos: Offset not contained in string", 1 TSRMLS_CC ); - + RETURN_FALSE; } - /* we checked that it will fit: */ + /* we checked that it will fit: */ offset = (int32_t) loffset; /* the offset is 'grapheme count offset' so it still might be invalid - we'll check it later */ if (needle_len == 0) { - + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_strpos: Empty delimiter", 1 TSRMLS_CC ); - + RETURN_FALSE; } /* quick check to see if the string might be there - * I realize that 'offset' is 'grapheme count offset' but will work in spite of that + * I realize that 'offset' is 'grapheme count offset' but will work in spite of that */ found = (unsigned char *)php_memnstr((char *)haystack + offset, (char *)needle, needle_len, (char *)haystack + haystack_len); @@ -178,31 +178,31 @@ PHP_FUNCTION(grapheme_stripos) int32_t offset = 0; int ret_pos, uchar_pos; int is_ascii; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", (char **)&haystack, &haystack_len, (char **)&needle, &needle_len, &loffset) == FAILURE) { - + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_stripos: unable to parse input param", 0 TSRMLS_CC ); - + RETURN_FALSE; } if ( OUTSIDE_STRING(loffset, haystack_len) ) { - + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_stripos: Offset not contained in string", 1 TSRMLS_CC ); - + RETURN_FALSE; } - + /* we checked that it will fit: */ offset = (int32_t) loffset; /* the offset is 'grapheme count offset' so it still might be invalid - we'll check it later */ if (needle_len == 0) { - + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_stripos: Empty delimiter", 1 TSRMLS_CC ); - + RETURN_FALSE; } @@ -252,40 +252,40 @@ PHP_FUNCTION(grapheme_strrpos) int32_t offset = 0; int32_t ret_pos; int is_ascii; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", (char **)&haystack, &haystack_len, (char **)&needle, &needle_len, &loffset) == FAILURE) { - + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_strrpos: unable to parse input param", 0 TSRMLS_CC ); - + RETURN_FALSE; } if ( OUTSIDE_STRING(loffset, haystack_len) ) { - + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_strpos: Offset not contained in string", 1 TSRMLS_CC ); - + RETURN_FALSE; } - + /* we checked that it will fit: */ offset = (int32_t) loffset; /* the offset is 'grapheme count offset' so it still might be invalid - we'll check it later */ if (needle_len == 0) { - + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_strpos: Empty delimiter", 1 TSRMLS_CC ); - + RETURN_FALSE; } is_ascii = grapheme_ascii_check(haystack, haystack_len) >= 0; if ( is_ascii ) { - + ret_pos = grapheme_strrpos_ascii(haystack, haystack_len, needle, needle_len, offset); - + if ( ret_pos >= 0 ) { RETURN_LONG(ret_pos); @@ -307,7 +307,7 @@ PHP_FUNCTION(grapheme_strrpos) } else { RETURN_FALSE; } - + } /* }}} */ @@ -322,31 +322,31 @@ PHP_FUNCTION(grapheme_strripos) int32_t offset = 0; int32_t ret_pos; int is_ascii; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", (char **)&haystack, &haystack_len, (char **)&needle, &needle_len, &loffset) == FAILURE) { - + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_strrpos: unable to parse input param", 0 TSRMLS_CC ); - + RETURN_FALSE; } if ( OUTSIDE_STRING(loffset, haystack_len) ) { - + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_strpos: Offset not contained in string", 1 TSRMLS_CC ); - + RETURN_FALSE; } /* we checked that it will fit: */ offset = (int32_t) loffset; - + /* the offset is 'grapheme count offset' so it still might be invalid - we'll check it later */ if (needle_len == 0) { - + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_strpos: Empty delimiter", 1 TSRMLS_CC ); - + RETURN_FALSE; } @@ -361,7 +361,7 @@ PHP_FUNCTION(grapheme_strripos) php_strtolower((char *)haystack_dup, haystack_len); ret_pos = grapheme_strrpos_ascii(haystack_dup, haystack_len, needle_dup, needle_len, offset); - + efree(haystack_dup); efree(needle_dup); @@ -385,7 +385,7 @@ PHP_FUNCTION(grapheme_strripos) } else { RETURN_FALSE; } - + } /* }}} */ @@ -407,17 +407,17 @@ PHP_FUNCTION(grapheme_substr) int32_t (*iter_func)(UBreakIterator *); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|l", (char **)&str, &str_len, &lstart, &length) == FAILURE) { - + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_substr: unable to parse input param", 0 TSRMLS_CC ); - + RETURN_FALSE; } if ( OUTSIDE_STRING(lstart, str_len) ) { - + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_substr: start not contained in string", 1 TSRMLS_CC ); - + RETURN_FALSE; } @@ -456,7 +456,7 @@ PHP_FUNCTION(grapheme_substr) if( U_FAILURE(status) ) { RETURN_FALSE; } - + ubrk_setText(bi, ustr, ustr_len, &status); if ( start < 0 ) { @@ -482,9 +482,9 @@ PHP_FUNCTION(grapheme_substr) } if ( 0 != start || sub_str_start_pos >= ustr_len ) { - + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_substr: start not contained in string", 1 TSRMLS_CC ); - + efree(ustr); ubrk_close(bi); RETURN_FALSE; @@ -541,11 +541,11 @@ PHP_FUNCTION(grapheme_substr) length += iter_val; } - + if ( UBRK_DONE == sub_str_end_pos && length < 0) { - + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_substr: length not contained in string", 1 TSRMLS_CC ); - + efree(ustr); ubrk_close(bi); RETURN_FALSE; @@ -586,17 +586,17 @@ static void strstr_common_handler(INTERNAL_FUNCTION_PARAMETERS, int f_ignore_cas zend_bool part = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|b", (char **)&haystack, &haystack_len, (char **)&needle, &needle_len, &part) == FAILURE) { - + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_strstr: unable to parse input param", 0 TSRMLS_CC ); - + RETURN_FALSE; } if (needle_len == 0) { - + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_strpos: Empty delimiter", 1 TSRMLS_CC ); - + RETURN_FALSE; } @@ -604,7 +604,7 @@ static void strstr_common_handler(INTERNAL_FUNCTION_PARAMETERS, int f_ignore_cas if ( !f_ignore_case ) { /* ASCII optimization: quick check to see if the string might be there - * I realize that 'offset' is 'grapheme count offset' but will work in spite of that + * I realize that 'offset' is 'grapheme count offset' but will work in spite of that */ found = (unsigned char *)php_memnstr((char *)haystack, (char *)needle, needle_len, (char *)haystack + haystack_len); @@ -640,7 +640,7 @@ static void strstr_common_handler(INTERNAL_FUNCTION_PARAMETERS, int f_ignore_cas if (part) { RETURN_STRINGL(((char *)haystack), ret_pos, 1); - } + } else { RETURN_STRINGL(((char *)haystack) + ret_pos, haystack_len - ret_pos, 1); } @@ -752,7 +752,7 @@ grapheme_extract_count_iter(UBreakIterator *bi, int32_t size, unsigned char *pst size--; } - /* pos is one past the last UChar - and represent the number of code units to + /* pos is one past the last UChar - and represent the number of code units to advance in the utf-8 buffer */ @@ -790,10 +790,10 @@ PHP_FUNCTION(grapheme_extract) zval *next = NULL; /* return offset of next part of the string */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|llz", (char **)&str, &str_len, &size, &extract_type, &lstart, &next) == FAILURE) { - + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_extract: unable to parse input param", 0 TSRMLS_CC ); - + RETURN_FALSE; } @@ -801,12 +801,12 @@ PHP_FUNCTION(grapheme_extract) if ( !PZVAL_IS_REF(next) ) { intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_extract: 'next' was not passed by reference", 0 TSRMLS_CC ); - + RETURN_FALSE; } else { /* initialize next */ - ZVAL_LONG(next, start); + ZVAL_LONG(next, lstart); } } @@ -814,16 +814,22 @@ PHP_FUNCTION(grapheme_extract) intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_extract: unknown extract type param", 0 TSRMLS_CC ); - + RETURN_FALSE; } if ( lstart > INT32_MAX || lstart < 0 || lstart >= str_len ) { + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_extract: start not contained in string", 0 TSRMLS_CC ); + RETURN_FALSE; + } - intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_extract: start not contained in string", 1 TSRMLS_CC ); - + if ( size > INT32_MAX || size < 0) { + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_extract: size is invalid", 0 TSRMLS_CC ); RETURN_FALSE; } + if (size == 0) { + RETURN_EMPTY_STRING(); + } /* we checked that it will fit: */ start = (int32_t) lstart; @@ -839,7 +845,7 @@ PHP_FUNCTION(grapheme_extract) if ( pstr >= str_end ) { intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_extract: invalid input string", 0 TSRMLS_CC ); - + RETURN_FALSE; } } @@ -850,9 +856,9 @@ PHP_FUNCTION(grapheme_extract) /* if the string is all ASCII up to size+1 - or str_len whichever is first - then we are done. (size + 1 because the size-th character might be the beginning of a grapheme cluster) */ - + if ( -1 != grapheme_ascii_check(pstr, size + 1 < str_len ? size + 1 : str_len ) ) { - long nsize = ( size < str_len ? size : str_len ); + long nsize = ( size < str_len ? size : str_len ); if ( NULL != next ) { ZVAL_LONG(next, start+nsize); } diff --git a/ext/intl/locale/locale_methods.c b/ext/intl/locale/locale_methods.c index 51c02923e..bbfb65bbd 100755 --- a/ext/intl/locale/locale_methods.c +++ b/ext/intl/locale/locale_methods.c @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: locale_methods.c 292566 2009-12-23 21:41:05Z stas $ */ +/* $Id: locale_methods.c 307392 2011-01-12 00:29:59Z felipe $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -264,7 +264,7 @@ static char* get_icu_value_internal( char* loc_name , char* tag_name, int* resul UErrorCode status = U_ZERO_ERROR; - if( tag_name != LOC_CANONICALIZE_TAG ){ + if( strcmp(tag_name, LOC_CANONICALIZE_TAG) != 0 ){ /* Handle grandfathered languages */ grOffset = findOffset( LOC_GRANDFATHERED , loc_name ); if( grOffset >= 0 ){ @@ -501,7 +501,7 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME loc_name = INTL_G(default_locale); } - if( tag_name != DISP_NAME ){ + if( strcmp(tag_name, DISP_NAME) != 0 ){ /* Handle grandfathered languages */ grOffset = findOffset( LOC_GRANDFATHERED , loc_name ); if( grOffset >= 0 ){ @@ -1042,9 +1042,10 @@ static int add_array_entry(char* loc_name, zval* hash_arr, char* key_name TSRMLS sprintf( cur_key_name , "%s%d", key_name , cnt++); add_assoc_string( hash_arr, cur_key_name , token , TRUE ); } - - if( key_name == LOC_PRIVATE_TAG ){ +/* + if( strcmp(key_name, LOC_PRIVATE_TAG) == 0 ){ } +*/ } } else { if( result == 1 ){ diff --git a/ext/intl/msgformat/msgformat_class.c b/ext/intl/msgformat/msgformat_class.c index b710ee708..bd291291e 100755 --- a/ext/intl/msgformat/msgformat_class.c +++ b/ext/intl/msgformat/msgformat_class.c @@ -25,6 +25,7 @@ #include "msgformat_attr.h" zend_class_entry *MessageFormatter_ce_ptr = NULL; +static zend_object_handlers MessageFormatter_handlers; /* * Auxiliary functions needed by objects of 'MessageFormatter' class @@ -66,12 +67,36 @@ zend_object_value MessageFormatter_object_create(zend_class_entry *ce TSRMLS_DC) (zend_objects_free_object_storage_t)MessageFormatter_object_free, NULL TSRMLS_CC ); - retval.handlers = zend_get_std_object_handlers(); + retval.handlers = &MessageFormatter_handlers; return retval; } /* }}} */ +/* {{{ MessageFormatter_object_clone */ +zend_object_value MessageFormatter_object_clone(zval *object TSRMLS_DC) +{ + zend_object_value new_obj_val; + zend_object_handle handle = Z_OBJ_HANDLE_P(object); + MessageFormatter_object *mfo, *new_mfo; + + MSG_FORMAT_METHOD_FETCH_OBJECT; + new_obj_val = MessageFormatter_ce_ptr->create_object(MessageFormatter_ce_ptr TSRMLS_CC); + new_mfo = (MessageFormatter_object *)zend_object_store_get_object_by_handle(new_obj_val.handle TSRMLS_CC); + /* clone standard parts */ + zend_objects_clone_members(&new_mfo->zo, new_obj_val, &mfo->zo, handle TSRMLS_CC); + /* clone formatter object */ + MSG_FORMAT_OBJECT(new_mfo) = umsg_clone(MSG_FORMAT_OBJECT(mfo), &INTL_DATA_ERROR_CODE(new_mfo)); + if(U_FAILURE(INTL_DATA_ERROR_CODE(new_mfo))) { + /* set up error in case error handler is interested */ + intl_error_set( NULL, INTL_DATA_ERROR_CODE(new_mfo), "Failed to clone MessageFormatter object", 0 TSRMLS_CC ); + MessageFormatter_object_dtor(new_mfo, new_obj_val.handle TSRMLS_CC); /* free new object */ + zend_error(E_ERROR, "Failed to clone MessageFormatter object"); + } + return new_obj_val; +} +/* }}} */ + /* * 'MessageFormatter' class registration structures & functions */ @@ -135,6 +160,10 @@ void msgformat_register_class( TSRMLS_D ) ce.create_object = MessageFormatter_object_create; MessageFormatter_ce_ptr = zend_register_internal_class( &ce TSRMLS_CC ); + memcpy(&MessageFormatter_handlers, zend_get_std_object_handlers(), + sizeof MessageFormatter_handlers); + MessageFormatter_handlers.clone_obj = MessageFormatter_object_clone; + /* Declare 'MessageFormatter' class properties. */ if( !MessageFormatter_ce_ptr ) { diff --git a/ext/intl/resourcebundle/resourcebundle.c b/ext/intl/resourcebundle/resourcebundle.c index b525ed1a3..237d6c8d1 100644 --- a/ext/intl/resourcebundle/resourcebundle.c +++ b/ext/intl/resourcebundle/resourcebundle.c @@ -29,7 +29,6 @@ void resourcebundle_extract_value( zval *return_value, ResourceBundle_object *so UResType restype; const UChar* ufield; const uint8_t* bfield; - char * cfield; const int32_t* vfield; int32_t ilen; int i; diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c index bebd0e828..a8a4bf1c8 100644 --- a/ext/intl/resourcebundle/resourcebundle_class.c +++ b/ext/intl/resourcebundle/resourcebundle_class.c @@ -109,7 +109,7 @@ static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS) if (!fallback && (INTL_DATA_ERROR_CODE(rb) == U_USING_FALLBACK_WARNING || INTL_DATA_ERROR_CODE(rb) == U_USING_DEFAULT_WARNING)) { intl_errors_set_code( NULL, INTL_DATA_ERROR_CODE(rb) TSRMLS_CC ); spprintf( &pbuf, 0, "resourcebundle_ctor: Cannot load libICU resource '%s' without fallback from %s to %s", - bundlename, locale, ures_getLocale( rb->me, &INTL_DATA_ERROR_CODE(rb)) ); + bundlename, locale, ures_getLocaleByType( rb->me, ULOC_ACTUAL_LOCALE, &INTL_DATA_ERROR_CODE(rb)) ); intl_errors_set_custom_msg( INTL_DATA_ERROR_P(rb), pbuf, 1 TSRMLS_CC ); efree(pbuf); zval_dtor( return_value ); @@ -187,7 +187,7 @@ static void resourcebundle_array_fetch(zval *object, zval *offset, zval *return_ if (!fallback && (INTL_DATA_ERROR_CODE(rb) == U_USING_FALLBACK_WARNING || INTL_DATA_ERROR_CODE(rb) == U_USING_DEFAULT_WARNING)) { UErrorCode icuerror; - const char * locale = ures_getLocale( rb->me, &icuerror ); + const char * locale = ures_getLocaleByType( rb->me, ULOC_ACTUAL_LOCALE, &icuerror ); if (is_numeric) { spprintf( &pbuf, 0, "Cannot load element %d without fallback from to %s", meindex, locale ); } else { @@ -420,6 +420,7 @@ void resourcebundle_register_class( TSRMLS_D ) } ResourceBundle_object_handlers = std_object_handlers; + ResourceBundle_object_handlers.clone_obj = NULL; /* ICU ResourceBundle has no clone implementation */ ResourceBundle_object_handlers.read_dimension = resourcebundle_array_get; ResourceBundle_object_handlers.count_elements = resourcebundle_array_count; } diff --git a/ext/intl/tests/bug53512.phpt b/ext/intl/tests/bug53512.phpt new file mode 100644 index 000000000..a1b1dcf37 --- /dev/null +++ b/ext/intl/tests/bug53512.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #53512 (NumberFormatter::setSymbol crash on bogus $attr values) +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + +$badvals = array(4294901761, 2147483648, -2147483648, -1); + +foreach ($badvals as $val) { + $x = numfmt_create("en", NumberFormatter::PATTERN_DECIMAL); + var_dump(numfmt_set_symbol($x, $val, "")); + var_dump(intl_get_error_message()); +} + +?> +--EXPECTF-- +bool(false) +string(65) "numfmt_set_symbol: invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR" +bool(false) +string(65) "numfmt_set_symbol: invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR" +bool(false) +string(65) "numfmt_set_symbol: invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR" +bool(false) +string(65) "numfmt_set_symbol: invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/collator_get_locale.phpt b/ext/intl/tests/collator_get_locale.phpt index 2fab35eb4..3f5dbaa0e 100755 --- a/ext/intl/tests/collator_get_locale.phpt +++ b/ext/intl/tests/collator_get_locale.phpt @@ -19,7 +19,6 @@ function ut_main() -9999999999999, 9999999999999, 1.2, - 9999999999999999999999999999999999999999999999 ); $coll = ut_coll_create( 'en_US' ); @@ -49,4 +48,3 @@ Locale of type -100 is false Locale of type -9999999999999 is false Locale of type 9999999999999 is false Locale of type 1.2 is 'en_US' -Locale of type 1.0E+46 is false diff --git a/ext/intl/tests/collator_get_sort_key.phpt b/ext/intl/tests/collator_get_sort_key.phpt index 0186c26f6..0fedde0ff 100755 --- a/ext/intl/tests/collator_get_sort_key.phpt +++ b/ext/intl/tests/collator_get_sort_key.phpt @@ -2,6 +2,8 @@ collator_get_sort_key() --SKIPIF-- <?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--XFAIL-- +Sort keys are not fixed, comparing them to fixed strings doesn't work. --FILE-- <?php @@ -30,7 +32,7 @@ function ut_main() // Regular strings keys $test_params = array( - 'abc', 'abd', 'aaa', + 'abc', 'abd', 'aaa', 'аа', 'а', 'z', '', null , '3', 'y' , 'i' , 'k' @@ -40,7 +42,7 @@ function ut_main() // Sort a non-ASCII array using ru_RU locale. $test_params = array( - 'абг', 'абв', 'жжж', 'эюя' + 'абг', 'абв', 'жжж', 'эюя' ); $res_str .= sort_arrays( 'ru_RU', $test_params ); @@ -67,9 +69,9 @@ source: %D0%B0 key: _+%01%05%01%05%00 source: z key: %5B%01%05%01%05%00 -source: +source: key: %01%01%00 -source: +source: key: %01%01%00 source: 3 key: %26%80%01%05%01%05%00 diff --git a/ext/intl/tests/dateformat_clone.phpt b/ext/intl/tests/dateformat_clone.phpt new file mode 100755 index 000000000..886a98f17 --- /dev/null +++ b/ext/intl/tests/dateformat_clone.phpt @@ -0,0 +1,36 @@ +--TEST-- +Cloning datefmt +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php +include_once( 'ut_common.inc' ); +$GLOBALS['oo-mode'] = true; +$res_str = ''; +/* + * Clone + */ +$start_pattern = 'dd-MM-YY'; +$fmt = ut_datefmt_create( "en-US", IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/New_York', IntlDateFormatter::GREGORIAN , $start_pattern ); + +$formatted = ut_datefmt_format($fmt,0); +$res_str .= "\nResult of formatting timestamp=0 is : \n$formatted"; + +$fmt_clone = clone $fmt; +ut_datefmt_set_pattern( $fmt , 'yyyy-DDD.hh:mm:ss z' ); + +$formatted = ut_datefmt_format($fmt,0); +$res_str .= "\nResult of formatting timestamp=0 is : \n$formatted"; +$formatted = ut_datefmt_format($fmt_clone,0); +$res_str .= "\nResult of clone formatting timestamp=0 is : \n$formatted"; + +echo $res_str; + +?> +--EXPECTF-- +Result of formatting timestamp=0 is : +31-12-69 +Result of formatting timestamp=0 is : +1969-365.07:00:00 EST +Result of clone formatting timestamp=0 is : +31-12-69 diff --git a/ext/intl/tests/dateformat_get_set_pattern.phpt b/ext/intl/tests/dateformat_get_set_pattern.phpt index b0d02dc0b..648923250 100755 --- a/ext/intl/tests/dateformat_get_set_pattern.phpt +++ b/ext/intl/tests/dateformat_get_set_pattern.phpt @@ -58,12 +58,12 @@ ut_run(); Creating IntlDateFormatter with pattern = dd-MM-YY After call to get_pattern : pattern= dd-MM-YY Result of formatting timestamp=0 is : -31-12-70 +31-12-69 ------------------- Setting IntlDateFormatter with pattern = DD-MM-YYYY hh:mm:ss After call to get_pattern : pattern= DD-MM-YYYY hh:mm:ss Result of formatting timestamp=0 with the new pattern is : -365-12-1970 07:00:00 +365-12-1969 07:00:00 ------------------- Setting IntlDateFormatter with pattern = yyyy-DDD.hh:mm:ss z diff --git a/ext/intl/tests/dateformat_set_timezone_id.phpt b/ext/intl/tests/dateformat_set_timezone_id.phpt index 76b4d474c..900d424fe 100755 --- a/ext/intl/tests/dateformat_set_timezone_id.phpt +++ b/ext/intl/tests/dateformat_set_timezone_id.phpt @@ -19,7 +19,7 @@ function ut_main() 'CN' ); $timestamp_entry = 0; - + $res_str = ''; $fmt = ut_datefmt_create( "en_US", IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/San_Francisco' , IntlDateFormatter::GREGORIAN ); @@ -56,18 +56,18 @@ After creation of the dateformatter : timezone_id= America/San_Francisco ----------- Trying to set timezone_id= America/New_York After call to set_timezone_id : timezone_id= America/New_York -Formatting timestamp=0 resulted in Wednesday, December 31, 1969 7:00:00 PM ET -Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 8:00:00 PM ET +Formatting timestamp=0 resulted in Wednesday, December 31, 1969 7:00:00 PM Eastern Standard Time +Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 8:00:00 PM Eastern Standard Time ----------- Trying to set timezone_id= America/Los_Angeles After call to set_timezone_id : timezone_id= America/Los_Angeles -Formatting timestamp=0 resulted in Wednesday, December 31, 1969 4:00:00 PM PT -Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 5:00:00 PM PT +Formatting timestamp=0 resulted in Wednesday, December 31, 1969 4:00:00 PM Pacific Standard Time +Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 5:00:00 PM Pacific Standard Time ----------- Trying to set timezone_id= America/Chicago After call to set_timezone_id : timezone_id= America/Chicago -Formatting timestamp=0 resulted in Wednesday, December 31, 1969 6:00:00 PM CT -Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 7:00:00 PM CT +Formatting timestamp=0 resulted in Wednesday, December 31, 1969 6:00:00 PM Central Standard Time +Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 7:00:00 PM Central Standard Time ----------- Trying to set timezone_id= CN After call to set_timezone_id : timezone_id= CN diff --git a/ext/intl/tests/formatter_clone.phpt b/ext/intl/tests/formatter_clone.phpt new file mode 100755 index 000000000..4e8d09624 --- /dev/null +++ b/ext/intl/tests/formatter_clone.phpt @@ -0,0 +1,30 @@ +--TEST-- +Cloning numfmt +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php +include_once( 'ut_common.inc' ); +$GLOBALS['oo-mode'] = true; +$res_str = ''; +/* + * Clone + */ +$test_value = 12345.123456; +$fmt = new NumberFormatter( "en_US", NumberFormatter::PATTERN_DECIMAL ); +$res_str .= "Formatted number: " . ut_nfmt_format( $fmt, $test_value ) . "\n"; +$fmt_clone = clone $fmt; + +$res = $fmt->setPattern("0.0" ); +if( $res === false ) + $res_str .= ut_nfmt_get_error_message( $fmt ) . " (" . ut_nfmt_get_error_code( $fmt ) . ")\n"; + +$res_str .= "Formatted number: " . ut_nfmt_format( $fmt, $test_value ) . "\n"; +$res_str .= "Formatted(clone) number: " . ut_nfmt_format( $fmt_clone, $test_value ) . "\n"; +echo $res_str; + +?> +--EXPECTF-- +Formatted number: 12345.123456 +Formatted number: 12345.1 +Formatted(clone) number: 12345.123456 diff --git a/ext/intl/tests/formatter_format.phpt b/ext/intl/tests/formatter_format.phpt index 413c71d7a..f47b123c8 100755 --- a/ext/intl/tests/formatter_format.phpt +++ b/ext/intl/tests/formatter_format.phpt @@ -9,7 +9,7 @@ numfmt_format() * Format a number using misc locales/patterns. */ -/* +/* * TODO: doesn't pass on ICU 3.6 because 'ru' and 'de' locales changed * currency and percent formatting. */ @@ -50,7 +50,7 @@ function ut_main() foreach( $styles as $style => $pattern ) { $fmt = ut_nfmt_create( $locale, $style, $pattern ); - + if(!$fmt) { $str_res .= "Bad formatter!\n"; continue; @@ -74,8 +74,8 @@ Locale is: en_US '\$1,234,567.89' '123,456,789%' '1.23456789123457E6' -'one million, two hundred and thirty-four thousand, five hundred and sixty-seven point eight nine one two three four five seven' -'1,234,567th' +'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five seven' +'1,234,567(th|ᵗʰ)' '342:56:07' '#####.###' Bad formatter! @@ -83,11 +83,11 @@ Bad formatter! Locale is: ru_UA '1234567,89123457' '1 234 567,891' -'1 234 567,89 грн.' -'123 456 789 ?%' +'1 234 567,89 ?(грн\.|₴)' +'123 456 789 ?%' '1,23456789123457E6' -'миллион два сто тридцать четыре тысяча пять сто шестьдесят восемь' -'1 234 567' +'один миллион двасти тридцать четыре тысяч пятьсот шестьдесят семь запятая восемь девять один два три четыре пять семь' +'1 234 567.?' '1 234 567' '#####.###' Bad formatter! @@ -95,11 +95,11 @@ Bad formatter! Locale is: de '1234567,89123457' '1.234.567,891' -'(¤ )?1.234.567,89( ¤)?' -'123.456.789 ?%' +'(¤ )?1.234.567,89( ¤)?' +'123\.456\.789 %' '1,23456789123457E6' -'eine Million zweihundertvierunddreißigtausendfünfhundertsiebenundsechzig komma acht neun eins zwei drei vier fünf sieben' -'1.234.567' +'eine Million zweihundertvierunddreißigtausendfünfhundertsiebenundsechzig Komma acht neun eins zwei drei vier fünf sieben' +'1.234.567.?' '1.234.567' '#####.###' Bad formatter! @@ -107,11 +107,11 @@ Bad formatter! Locale is: fr '1234567,89123457' '1 234 567,891' -'1 234 567,89 ¤' +'1 234 567,89 ¤' '123 456 789 ?%' '1,23456789123457E6' -'un million deux cents trente-quatre mille cinq cents soixante-sept virgule huit neuf un deux trois quatre cinq sept' -'1 234 567' +'un million deux-cent-trente-quatre-mille-cinq-cent-soixante-sept virgule huit neuf un deux trois quatre cinq sept' +'1 234 567ᵉ?' '1 234 567' '#####.###' Bad formatter! @@ -122,8 +122,8 @@ Locale is: en_UK '¤1,234,567.89' '123,456,789%' '1.23456789123457E6' -'one million, two hundred and thirty-four thousand, five hundred and sixty-seven point eight nine one two three four five seven' -'1,234,567th' +'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five seven' +'1,234,567(th|ᵗʰ)' '342:56:07' '#####.###' Bad formatter!
\ No newline at end of file diff --git a/ext/intl/tests/formatter_format_currency.phpt b/ext/intl/tests/formatter_format_currency.phpt index 715f12256..c53f831b7 100755 --- a/ext/intl/tests/formatter_format_currency.phpt +++ b/ext/intl/tests/formatter_format_currency.phpt @@ -8,7 +8,7 @@ numfmt_format_currency() /* * Format a number using misc currencies/locales. */ -/* +/* * TODO: doesn't pass on ICU 3.6 because 'ru' and 'uk' locales changed * currency formatting. */ @@ -41,9 +41,9 @@ include_once( 'ut_common.inc' ); ut_run(); ?> ---EXPECTREGEX-- +--EXPECT-- en_UK: '£1,234,567.89' -en_US: '\$1,234,567.89' -ru: '1 234 567,89 ?р.' -uk: '(грн. )?1 234 567,89( грн.)?' -en: 'UAH1,234,567.89'
\ No newline at end of file +en_US: '$1,234,567.89' +ru: '1 234 567,89 р.' +uk: '1 234 567,89 ₴' +en: '₴1,234,567.89'
\ No newline at end of file diff --git a/ext/intl/tests/formatter_get_set_attribute.phpt b/ext/intl/tests/formatter_get_set_attribute.phpt index c52334684..95a264343 100755 --- a/ext/intl/tests/formatter_get_set_attribute.phpt +++ b/ext/intl/tests/formatter_get_set_attribute.phpt @@ -25,7 +25,7 @@ function ut_main() 'FRACTION_DIGITS' => array( NumberFormatter::FRACTION_DIGITS, 5, 12345.123456 ), 'MULTIPLIER' => array( NumberFormatter::MULTIPLIER, 2, 12345.123456 ), 'GROUPING_SIZE' => array( NumberFormatter::GROUPING_SIZE, 2, 12345.123456 ), - 'ROUNDING_MODE' => array( NumberFormatter::ROUNDING_MODE, 7, 12345.123456 ), + 'ROUNDING_MODE' => array( NumberFormatter::ROUNDING_MODE, 1, 12345.123456 ), 'ROUNDING_INCREMENT' => array( NumberFormatter::ROUNDING_INCREMENT, (float)2, 12345.123456 ), 'FORMAT_WIDTH' => array( NumberFormatter::FORMAT_WIDTH, 27, 12345.123456 ), 'PADDING_POSITION' => array( NumberFormatter::PADDING_POSITION, 21, 12345.123456 ), @@ -155,10 +155,10 @@ New attribute value: 2 ; Format result: '0,01,23,45.12346' ; Parse result: 1234 Attribute ROUNDING_MODE Old attribute value: 4 ; Format result: '0,012,345.12346' ; Parse result: 12345.12346 Setting attribute: ok -New attribute value: 7 ; Format result: '0,012,345.12346' ; Parse result: 12345.12346 +New attribute value: 1 ; Format result: '0,012,345.12345' ; Parse result: 12345.12345 Attribute ROUNDING_INCREMENT -Old attribute value: 0 ; Format result: '0,012,345.12346' ; Parse result: 12345.12346 +Old attribute value: 1.0E-5 ; Format result: '0,012,345.12346' ; Parse result: 12345.12346 Setting attribute: ok New attribute value: 2 ; Format result: '0,012,346.00000' ; Parse result: 12346 diff --git a/ext/intl/tests/grapheme.phpt b/ext/intl/tests/grapheme.phpt index d65c90900..def9110d0 100755 --- a/ext/intl/tests/grapheme.phpt +++ b/ext/intl/tests/grapheme.phpt @@ -772,8 +772,8 @@ function check_result($result, $expected) { function grapheme_strlen($string) {} -"hindi" in devanagari strlen 5 -"ab" + "hindi" + "cde" strlen 10 +"hindi" in devanagari strlen 3 +"ab" + "hindi" + "cde" strlen 8 "" strlen 0 char_a_ring_nfd strlen 1 char_a_ring_nfd + "bc" strlen 3 diff --git a/ext/intl/tests/locale_get_display_name.phpt b/ext/intl/tests/locale_get_display_name.phpt index 1e84bc2b9..cf8949865 100755 --- a/ext/intl/tests/locale_get_display_name.phpt +++ b/ext/intl/tests/locale_get_display_name.phpt @@ -130,9 +130,9 @@ disp_locale=fr : display_name=i-enochian disp_locale=de : display_name=i-enochian ----------------- locale='zh-hakka' -disp_locale=en : display_name=Chinese #HAKKA# -disp_locale=fr : display_name=chinois #HAKKA# -disp_locale=de : display_name=Chinesisch #HAKKA# +disp_locale=en : display_name=Chinese( #HAKKA#)? +disp_locale=fr : display_name=chinois( #HAKKA#)? +disp_locale=de : display_name=Chinesisch( #HAKKA#)? ----------------- locale='zh-wuu' disp_locale=en : display_name=Chinese #WUU# @@ -201,12 +201,12 @@ disp_locale=de : display_name=i-enochian ----------------- locale='zh-Hant' disp_locale=en : display_name=Chinese #Traditional Han# -disp_locale=fr : display_name=chinois #idéogrammes han #variante traditionnelle## +disp_locale=fr : display_name=chinois #idéogrammes han (#variante traditionnelle#|traditionnels)# disp_locale=de : display_name=Chinesisch #Traditionelle Chinesische Schrift# ----------------- locale='zh-Hans' disp_locale=en : display_name=Chinese #Simplified Han# -disp_locale=fr : display_name=chinois #idéogrammes han #variante simplifiée## +disp_locale=fr : display_name=chinois #idéogrammes han (#variante simplifiée#|simplifiés)# disp_locale=de : display_name=Chinesisch #Vereinfachte Chinesische Schrift# ----------------- locale='sr-Cyrl' @@ -221,7 +221,7 @@ disp_locale=de : display_name=Serbisch #Lateinisch# ----------------- locale='zh-Hans-CN' disp_locale=en : display_name=Chinese #Simplified Han, China# -disp_locale=fr : display_name=chinois #idéogrammes han #variante simplifiée#, Chine# +disp_locale=fr : display_name=chinois #idéogrammes han (#variante simplifiée#|simplifiés), Chine# disp_locale=de : display_name=Chinesisch #Vereinfachte Chinesische Schrift, China# ----------------- locale='sr-Latn-CS' @@ -230,19 +230,19 @@ disp_locale=fr : display_name=serbe #latin, Serbie-et-Monténégro# disp_locale=de : display_name=Serbisch #Lateinisch, Serbien und Montenegro# ----------------- locale='sl-rozaj' -disp_locale=en : display_name=Slovenian #ROZAJ# -disp_locale=fr : display_name=slovène #ROZAJ# -disp_locale=de : display_name=Slowenisch #(ROZAJ|Resianisch)# +disp_locale=en : display_name=Slovenian( #ROZAJ#)? +disp_locale=fr : display_name=slovène( #ROZAJ#)? +disp_locale=de : display_name=Slowenisch( #(ROZAJ|Resianisch)#)? ----------------- locale='sl-nedis' -disp_locale=en : display_name=Slovenian #NEDIS# -disp_locale=fr : display_name=slovène #NEDIS# -disp_locale=de : display_name=Slowenisch #NEDIS# +disp_locale=en : display_name=Slovenian( #NEDIS#)? +disp_locale=fr : display_name=slovène( #NEDIS#)? +disp_locale=de : display_name=Slowenisch( #NEDIS#)? ----------------- locale='de-CH-1901' disp_locale=en : display_name=German #Switzerland, Traditional German orthography# disp_locale=fr : display_name=allemand #Suisse, orthographe allemande traditionnelle# -disp_locale=de : display_name=Deutsch #Schweiz, (1901|alte deutsche Rechtschreibung)# +disp_locale=de : display_name=Deutsch #Schweiz, (1901|[aA]lte deutsche Rechtschreibung)# ----------------- locale='sl-IT-nedis' disp_locale=en : display_name=Slovenian #Italy, Natisone dialect# @@ -275,9 +275,9 @@ disp_locale=fr : display_name=allemand #Suisse, X_PHONEBK# disp_locale=de : display_name=Deutsch #Schweiz, X_PHONEBK# ----------------- locale='az-Arab-x-AZE-derbend' -disp_locale=en : display_name=Azerbaijani #Arabic, X, AZE_DERBEND# -disp_locale=fr : display_name=azéri #arabe, X, AZE_DERBEND# -disp_locale=de : display_name=Aserbaidschanisch #Arabisch, X, AZE_DERBEND# +disp_locale=en : display_name=Azerbaijani #Arabic(, X, AZE_DERBEND)?# +disp_locale=fr : display_name=azéri #arabe(, X, AZE_DERBEND)?# +disp_locale=de : display_name=Aserbaidschanisch #Arabisch(, X, AZE_DERBEND)?# ----------------- locale='zh-min' disp_locale=en : display_name=Chinese #MIN# @@ -320,9 +320,9 @@ disp_locale=fr : display_name=chinois #Chine, A_MYEXT_X_PRIVATE# disp_locale=de : display_name=Chinesisch #China, A_MYEXT_X_PRIVATE# ----------------- locale='en-a-myExt-b-another' -disp_locale=en : display_name=English #A, MYEXT_B_ANOTHER# -disp_locale=fr : display_name=anglais #A, MYEXT_B_ANOTHER# -disp_locale=de : display_name=Englisch #A, MYEXT_B_ANOTHER# +disp_locale=en : display_name=English( #A, MYEXT_B_ANOTHER#)? +disp_locale=fr : display_name=anglais( #A, MYEXT_B_ANOTHER#)? +disp_locale=de : display_name=Englisch( #A, MYEXT_B_ANOTHER#)? ----------------- locale='de-419-DE' disp_locale=en : display_name=German #Latin America and the Caribbean, DE# @@ -335,7 +335,7 @@ disp_locale=fr : display_name=a #Allemagne# disp_locale=de : display_name=a #Deutschland# ----------------- locale='ar-a-aaa-b-bbb-a-ccc' -disp_locale=en : display_name=Arabic #A, AAA_B_BBB_A_CCC# -disp_locale=fr : display_name=arabe #A, AAA_B_BBB_A_CCC# -disp_locale=de : display_name=Arabisch #A, AAA_B_BBB_A_CCC# +disp_locale=en : display_name=Arabic( #A, AAA_B_BBB_A_CCC#)? +disp_locale=fr : display_name=arabe( #A, AAA_B_BBB_A_CCC#)? +disp_locale=de : display_name=Arabisch( #A, AAA_B_BBB_A_CCC#)? ----------------- diff --git a/ext/intl/tests/locale_get_display_region.phpt b/ext/intl/tests/locale_get_display_region.phpt index 47ebeb7af..354fc0623 100755 --- a/ext/intl/tests/locale_get_display_region.phpt +++ b/ext/intl/tests/locale_get_display_region.phpt @@ -163,14 +163,14 @@ disp_locale=fr : display_region=Serbie-et-Monténégro disp_locale=de : display_region=Serbien und Montenegro ----------------- locale='sl-rozaj' -disp_locale=en : display_region=ROZAJ -disp_locale=fr : display_region=ROZAJ -disp_locale=de : display_region=ROZAJ +disp_locale=en : display_region= +disp_locale=fr : display_region= +disp_locale=de : display_region= ----------------- locale='sl-nedis' -disp_locale=en : display_region=NEDIS -disp_locale=fr : display_region=NEDIS -disp_locale=de : display_region=NEDIS +disp_locale=en : display_region= +disp_locale=fr : display_region= +disp_locale=de : display_region= ----------------- locale='de-CH-1901' disp_locale=en : display_region=Switzerland @@ -208,9 +208,9 @@ disp_locale=fr : display_region=Suisse disp_locale=de : display_region=Schweiz ----------------- locale='az-Arab-x-AZE-derbend' -disp_locale=en : display_region=X -disp_locale=fr : display_region=X -disp_locale=de : display_region=X +disp_locale=en : display_region=X? +disp_locale=fr : display_region=X? +disp_locale=de : display_region=X? ----------------- locale='zh-min' disp_locale=en : display_region= @@ -253,9 +253,9 @@ disp_locale=fr : display_region=Chine disp_locale=de : display_region=China ----------------- locale='en-a-myExt-b-another' -disp_locale=en : display_region=A -disp_locale=fr : display_region=A -disp_locale=de : display_region=A +disp_locale=en : display_region=A? +disp_locale=fr : display_region=A? +disp_locale=de : display_region=A? ----------------- locale='de-419-DE' disp_locale=en : display_region=Latin America and the Caribbean @@ -268,7 +268,7 @@ disp_locale=fr : display_region=Allemagne disp_locale=de : display_region=Deutschland ----------------- locale='ar-a-aaa-b-bbb-a-ccc' -disp_locale=en : display_region=A -disp_locale=fr : display_region=A -disp_locale=de : display_region=A +disp_locale=en : display_region=A? +disp_locale=fr : display_region=A? +disp_locale=de : display_region=A? ----------------- diff --git a/ext/intl/tests/locale_get_display_script.phpt b/ext/intl/tests/locale_get_display_script.phpt index 1b74e90c9..916441b5f 100755 --- a/ext/intl/tests/locale_get_display_script.phpt +++ b/ext/intl/tests/locale_get_display_script.phpt @@ -91,7 +91,7 @@ include_once( 'ut_common.inc' ); ut_run(); ?> ---EXPECT-- +--EXPECTREGEX-- locale='uk-ua_CALIFORNIA@currency=;currency=GRN' disp_locale=en : display_script= disp_locale=fr : display_script= @@ -134,12 +134,12 @@ disp_locale=de : display_script= ----------------- locale='zh-Hant' disp_locale=en : display_script=Traditional Han -disp_locale=fr : display_script=idéogrammes han (variante traditionnelle) +disp_locale=fr : display_script=idéogrammes han (\(variante traditionnelle\)|traditionnels) disp_locale=de : display_script=Traditionelle Chinesische Schrift ----------------- locale='zh-Hans' disp_locale=en : display_script=Simplified Han -disp_locale=fr : display_script=idéogrammes han (variante simplifiée) +disp_locale=fr : display_script=idéogrammes han (\(variante simplifiée\)|simplifiés) disp_locale=de : display_script=Vereinfachte Chinesische Schrift ----------------- locale='sr-Cyrl' @@ -154,7 +154,7 @@ disp_locale=de : display_script=Lateinisch ----------------- locale='zh-Hans-CN' disp_locale=en : display_script=Simplified Han -disp_locale=fr : display_script=idéogrammes han (variante simplifiée) +disp_locale=fr : display_script=idéogrammes han (\(variante simplifiée\)|simplifiés) disp_locale=de : display_script=Vereinfachte Chinesische Schrift ----------------- locale='sr-Latn-CS' diff --git a/ext/intl/tests/locale_get_display_variant.phpt b/ext/intl/tests/locale_get_display_variant.phpt index 7a58ba34d..25bfef15d 100755 --- a/ext/intl/tests/locale_get_display_variant.phpt +++ b/ext/intl/tests/locale_get_display_variant.phpt @@ -175,7 +175,7 @@ disp_locale=de : display_variant= locale='de-CH-1901' disp_locale=en : display_variant=Traditional German orthography disp_locale=fr : display_variant=orthographe allemande traditionnelle -disp_locale=de : display_variant=(1901|alte deutsche Rechtschreibung) +disp_locale=de : display_variant=(1901|[Aa]lte deutsche Rechtschreibung) ----------------- locale='sl-IT-nedis' disp_locale=en : display_variant=Natisone dialect @@ -208,9 +208,9 @@ disp_locale=fr : display_variant=X_PHONEBK disp_locale=de : display_variant=X_PHONEBK ----------------- locale='az-Arab-x-AZE-derbend' -disp_locale=en : display_variant=AZE_DERBEND -disp_locale=fr : display_variant=AZE_DERBEND -disp_locale=de : display_variant=AZE_DERBEND +disp_locale=en : display_variant=(AZE_DERBEND)? +disp_locale=fr : display_variant=(AZE_DERBEND)? +disp_locale=de : display_variant=(AZE_DERBEND)? ----------------- locale='zh-min' disp_locale=en : display_variant= @@ -253,9 +253,9 @@ disp_locale=fr : display_variant=A_MYEXT_X_PRIVATE disp_locale=de : display_variant=A_MYEXT_X_PRIVATE ----------------- locale='en-a-myExt-b-another' -disp_locale=en : display_variant=MYEXT_B_ANOTHER -disp_locale=fr : display_variant=MYEXT_B_ANOTHER -disp_locale=de : display_variant=MYEXT_B_ANOTHER +disp_locale=en : display_variant=(MYEXT_B_ANOTHER)? +disp_locale=fr : display_variant=(MYEXT_B_ANOTHER)? +disp_locale=de : display_variant=(MYEXT_B_ANOTHER)? ----------------- locale='de-419-DE' disp_locale=en : display_variant=DE @@ -268,7 +268,7 @@ disp_locale=fr : display_variant= disp_locale=de : display_variant= ----------------- locale='ar-a-aaa-b-bbb-a-ccc' -disp_locale=en : display_variant=AAA_B_BBB_A_CCC -disp_locale=fr : display_variant=AAA_B_BBB_A_CCC -disp_locale=de : display_variant=AAA_B_BBB_A_CCC +disp_locale=en : display_variant=(AAA_B_BBB_A_CCC)? +disp_locale=fr : display_variant=(AAA_B_BBB_A_CCC)? +disp_locale=de : display_variant=(AAA_B_BBB_A_CCC)? ----------------- diff --git a/ext/intl/tests/locale_get_region.phpt b/ext/intl/tests/locale_get_region.phpt index e62855e56..0bebb331a 100755 --- a/ext/intl/tests/locale_get_region.phpt +++ b/ext/intl/tests/locale_get_region.phpt @@ -99,8 +99,8 @@ sr-Cyrl: region='' sr-Latn: region='' zh-Hans-CN: region='CN' sr-Latn-CS: region='CS' -sl-rozaj: region='ROZAJ' -sl-nedis: region='NEDIS' +sl-rozaj: region='' +sl-nedis: region='' de-CH-1901: region='CH' sl-IT-nedis: region='IT' sl-Latn-IT-nedis: region='IT' @@ -108,7 +108,7 @@ de-DE: region='DE' en-US: region='US' es-419: region='419' de-CH-x-phonebk: region='CH' -az-Arab-x-AZE-derbend: region='X' +az-Arab-x-AZE-derbend: region='' zh-min: region='' zh-min-nan-Hant-CN: region='MIN' x-whatever: region='' @@ -117,7 +117,7 @@ sr-Latn-QM: region='QM' sr-Qaaa-CS: region='CS' en-US-u-islamCal: region='US' zh-CN-a-myExt-x-private: region='CN' -en-a-myExt-b-another: region='A' +en-a-myExt-b-another: region='' de-419-DE: region='419' a-DE: region='DE' -ar-a-aaa-b-bbb-a-ccc: region='A' +ar-a-aaa-b-bbb-a-ccc: region='' diff --git a/ext/intl/tests/locale_parse_locale.phpt b/ext/intl/tests/locale_parse_locale.phpt index e670b31a1..e47f71830 100755 --- a/ext/intl/tests/locale_parse_locale.phpt +++ b/ext/intl/tests/locale_parse_locale.phpt @@ -138,10 +138,10 @@ sr-Latn-CS: language : 'sr' , script : 'Latn' , region : 'CS' , --------------------- sl-rozaj: -language : 'sl' , region : 'ROZAJ' , +language : 'sl' , --------------------- sl-nedis: -language : 'sl' , region : 'NEDIS' , +language : 'sl' , --------------------- de-CH-1901: language : 'de' , region : 'CH' , variant0 : '1901' , diff --git a/ext/intl/tests/msgfmt_clone.phpt b/ext/intl/tests/msgfmt_clone.phpt new file mode 100755 index 000000000..9d8ea6444 --- /dev/null +++ b/ext/intl/tests/msgfmt_clone.phpt @@ -0,0 +1,30 @@ +--TEST-- +Cloning msgfmt +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php +include_once( 'ut_common.inc' ); +$GLOBALS['oo-mode'] = true; +$res_str = ''; +/* + * Clone + */ +$fmt = ut_msgfmt_create( "en_US", "{0,number} monkeys on {1,number} trees" ); + +// Get default patten. +$res_str .= "Formatting result: " . ut_msgfmt_format( $fmt, array(123, 456) ) . "\n"; +$fmt_clone = clone $fmt; +// Set a new pattern. +$pattern = "{0,number} trees hosting {1,number} monkeys"; +$res = ut_msgfmt_set_pattern( $fmt, $pattern ); +$res_str .= "Formatting result: " . ut_msgfmt_format( $fmt, array(123, 456) ) . "\n"; +$res_str .= "Formatting clone result: " . ut_msgfmt_format( $fmt_clone, array(123, 456) ) . "\n"; + +echo $res_str; + +?> +--EXPECTF-- +Formatting result: 123 monkeys on 456 trees +Formatting result: 123 trees hosting 456 monkeys +Formatting clone result: 123 monkeys on 456 trees diff --git a/ext/intl/tests/msgfmt_get_set_pattern.phpt b/ext/intl/tests/msgfmt_get_set_pattern.phpt index dd6fb5fa2..67b1aca45 100755 --- a/ext/intl/tests/msgfmt_get_set_pattern.phpt +++ b/ext/intl/tests/msgfmt_get_set_pattern.phpt @@ -30,11 +30,11 @@ function ut_main() if( $res === false ) $res_str .= ut_msgfmt_get_error_message( $fmt ) . " (" . ut_msgfmt_get_error_code( $fmt ) . ")\n"; $res_str .= "New pattern: '" . ut_msgfmt_get_pattern( $fmt ) . "'\n"; - $res_str .= "Formatted number: " . ut_msgfmt_format( $fmt, array(123, 456) ) . "\n"; + $res_str .= "Formatted message: " . ut_msgfmt_format( $fmt, array(123, 456) ) . "\n"; ut_msgfmt_set_pattern($fmt, str_repeat($pattern, 10)); $res_str .= "New pattern: '" . ut_msgfmt_get_pattern( $fmt ) . "'\n"; - $res_str .= "Formatted number: " . ut_msgfmt_format( $fmt, array(123, 456) ) . "\n"; + $res_str .= "Formatted message: " . ut_msgfmt_format( $fmt, array(123, 456) ) . "\n"; return $res_str; @@ -48,6 +48,6 @@ ut_run(); Default pattern: '{0,number} monkeys on {1,number} trees' Formatting result: 123 monkeys on 456 trees New pattern: '{0,number} trees hosting {1,number} monkeys' -Formatted number: 123 trees hosting 456 monkeys +Formatted message: 123 trees hosting 456 monkeys New pattern: '{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys' -Formatted number: 123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys +Formatted message: 123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys |
