cvs: php-src /ext/spl php_spl.c spl_functions.c spl_functions.h spl_iterators.c /ext/spl/tests spl_003.phpt /ext/standard array.c

From: Date: Mon, 15 Aug 2005 17:29:09 +0000
Subject: cvs: php-src /ext/spl php_spl.c spl_functions.c spl_functions.h spl_iterators.c /ext/spl/tests spl_003.phpt /ext/standard array.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-33408@lists.php.net to get a copy of this message
dmitry Mon Aug 15 13:29:09 2005 EDT Modified files: /php-src/ext/spl php_spl.c spl_functions.c spl_functions.h spl_iterators.c /php-src/ext/spl/tests spl_003.phpt /php-src/ext/standard array.c Log: Unicode support

http://cvs.php.net/diff.php/php-src/ext/spl/php_spl.c?r1=1.57&r2=1.58&ty=u Index: php-src/ext/spl/php_spl.c diff -u php-src/ext/spl/php_spl.c:1.57 php-src/ext/spl/php_spl.c:1.58 --- php-src/ext/spl/php_spl.c:1.57 Fri Aug 12 07:29:32 2005 +++ php-src/ext/spl/php_spl.c Mon Aug 15 13:29:04 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_spl.c,v 1.57 2005/08/12 11:29:32 dmitry Exp $ */ +/* $Id: php_spl.c,v 1.58 2005/08/15 17:29:04 dmitry Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -59,23 +59,22 @@ } /* }}} */ -static zend_class_entry * spl_find_ce_by_name(char *name, int len, zend_bool autoload TSRMLS_DC) +static zend_class_entry * spl_find_ce_by_name(zend_uchar ztype, void *name, int len, zend_bool autoload TSRMLS_DC) { zend_class_entry **ce; int found; + if (!autoload) { char *lc_name; - lc_name = do_alloca(len + 1); - zend_str_tolower_copy(lc_name, name, len); - - found = zend_hash_find(EG(class_table), lc_name, len +1, (void **) &ce); - free_alloca(lc_name); + lc_name = zend_u_str_tolower_dup(ztype, name, len); + found = zend_u_hash_find(EG(class_table), ztype, lc_name, len +1, (void **) &ce); + efree(lc_name); } else { - found = zend_lookup_class(name, len, &ce TSRMLS_CC); + found = zend_u_lookup_class(ztype, name, len, &ce TSRMLS_CC); } if (found != SUCCESS) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Class %s does not exist%s", name, autoload ? " and could not be loaded" : ""); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Class %v does not exist%s", name, autoload ? " and could not be loaded" : ""); return NULL; } @@ -94,13 +93,13 @@ RETURN_FALSE; } - if (Z_TYPE_P(obj) != IS_OBJECT && Z_TYPE_P(obj) != IS_STRING) { + if (Z_TYPE_P(obj) != IS_OBJECT && Z_TYPE_P(obj) != IS_STRING && Z_TYPE_P(obj) != IS_UNICODE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "object or string expected"); RETURN_FALSE; } - if (Z_TYPE_P(obj) == IS_STRING) { - if (NULL == (ce = spl_find_ce_by_name(Z_STRVAL_P(obj), Z_STRLEN_P(obj), autoload TSRMLS_CC))) { + if (Z_TYPE_P(obj) == IS_STRING || Z_TYPE_P(obj) == IS_UNICODE) { + if (NULL == (ce = spl_find_ce_by_name(Z_TYPE_P(obj), Z_UNIVAL_P(obj), Z_UNILEN_P(obj), autoload TSRMLS_CC))) { RETURN_FALSE; } } else { @@ -127,13 +126,13 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|b", &obj, &autoload) == FAILURE) { RETURN_FALSE; } - if (Z_TYPE_P(obj) != IS_OBJECT && Z_TYPE_P(obj) != IS_STRING) { + if (Z_TYPE_P(obj) != IS_OBJECT && Z_TYPE_P(obj) != IS_STRING && Z_TYPE_P(obj) != IS_UNICODE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "object or string expected"); RETURN_FALSE; } - if (Z_TYPE_P(obj) == IS_STRING) { - if (NULL == (ce = spl_find_ce_by_name(Z_STRVAL_P(obj), Z_STRLEN_P(obj), autoload TSRMLS_CC))) { + if (Z_TYPE_P(obj) == IS_STRING || Z_TYPE_P(obj) == IS_UNICODE) { + if (NULL == (ce = spl_find_ce_by_name(Z_TYPE_P(obj), Z_UNIVAL_P(obj), Z_UNILEN_P(obj), autoload TSRMLS_CC))) { RETURN_FALSE; } } else { @@ -146,7 +145,7 @@ /* }}} */ #define SPL_ADD_CLASS(class_name, z_list, sub, allow, ce_flags) \ - spl_add_classes(&spl_ce_ ## class_name, z_list, sub, allow, ce_flags TSRMLS_CC) + spl_add_classes(U_CLASS_ENTRY(spl_ce_ ## class_name), z_list, sub, allow, ce_flags TSRMLS_CC) #define SPL_LIST_CLASSES(z_list, sub, allow, ce_flags) \ SPL_ADD_CLASS(AppendIterator, z_list, sub, allow, ce_flags); \ http://cvs.php.net/diff.php/php-src/ext/spl/spl_functions.c?r1=1.29&r2=1.30&ty=u Index: php-src/ext/spl/spl_functions.c diff -u php-src/ext/spl/spl_functions.c:1.29 php-src/ext/spl/spl_functions.c:1.30 --- php-src/ext/spl/spl_functions.c:1.29 Thu Aug 11 19:35:55 2005 +++ php-src/ext/spl/spl_functions.c Mon Aug 15 13:29:04 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_functions.c,v 1.29 2005/08/11 23:35:55 andrei Exp $ */ +/* $Id: spl_functions.c,v 1.30 2005/08/15 17:29:04 dmitry Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -115,11 +115,16 @@ if (!allow || (allow > 0 && pce->ce_flags & ce_flags) || (allow < 0 && !(pce->ce_flags & ce_flags))) { size_t len = pce->name_length; zval *tmp; + zend_uchar ztype = UG(unicode)?IS_UNICODE:IS_STRING; - if (zend_hash_find(Z_ARRVAL_P(list), pce->name, len+1, (void*)&tmp) == FAILURE) { + if (zend_u_hash_find(Z_ARRVAL_P(list), ztype, pce->name, len+1, (void*)&tmp) == FAILURE) { MAKE_STD_ZVAL(tmp); - ZVAL_STRING(tmp, pce->name, 1); - zend_hash_add(Z_ARRVAL_P(list), pce->name, len+1, &tmp, sizeof(zval *), NULL); + if (UG(unicode)) { + ZVAL_UNICODEL(tmp, pce->name, pce->name_length, 1); + } else { + ZVAL_STRINGL(tmp, pce->name, pce->name_length, 1); + } + zend_u_hash_add(Z_ARRVAL_P(list), ztype, pce->name, len+1, &tmp, sizeof(zval *), NULL); } } } @@ -137,10 +142,8 @@ /* }}} */ /* {{{ spl_add_classes */ -int spl_add_classes(zend_class_entry ** ppce, zval *list, int sub, int allow, int ce_flags TSRMLS_DC) +int spl_add_classes(zend_class_entry *pce, zval *list, int sub, int allow, int ce_flags TSRMLS_DC) { - zend_class_entry *pce = *ppce; - if (!pce) { return 0; } @@ -149,7 +152,7 @@ spl_add_interfaces(list, pce, allow, ce_flags TSRMLS_CC); while (pce->parent) { pce = pce->parent; - spl_add_classes(&pce, list, sub, allow, ce_flags TSRMLS_CC); + spl_add_classes(pce, list, sub, allow, ce_flags TSRMLS_CC); } } return 0; http://cvs.php.net/diff.php/php-src/ext/spl/spl_functions.h?r1=1.19&r2=1.20&ty=u Index: php-src/ext/spl/spl_functions.h diff -u php-src/ext/spl/spl_functions.h:1.19 php-src/ext/spl/spl_functions.h:1.20 --- php-src/ext/spl/spl_functions.h:1.19 Wed Aug 3 10:07:53 2005 +++ php-src/ext/spl/spl_functions.h Mon Aug 15 13:29:04 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_functions.h,v 1.19 2005/08/03 14:07:53 sniper Exp $ */ +/* $Id: spl_functions.h,v 1.20 2005/08/15 17:29:04 dmitry Exp $ */ #ifndef PHP_FUNCTIONS_H #define PHP_FUNCTIONS_H @@ -70,7 +70,7 @@ */ void spl_add_class_name(zval * list, zend_class_entry * pce, int allow, int ce_flags TSRMLS_DC); void spl_add_interfaces(zval * list, zend_class_entry * pce, int allow, int ce_flags TSRMLS_DC); -int spl_add_classes(zend_class_entry ** ppce, zval *list, int sub, int allow, int ce_flags TSRMLS_DC); +int spl_add_classes(zend_class_entry *pce, zval *list, int sub, int allow, int ce_flags TSRMLS_DC); #define SPL_ME(class_name, function_name, arg_info, flags) \ PHP_ME( spl_ ## class_name, function_name, arg_info, flags) http://cvs.php.net/diff.php/php-src/ext/spl/spl_iterators.c?r1=1.79&r2=1.80&ty=u Index: php-src/ext/spl/spl_iterators.c diff -u php-src/ext/spl/spl_iterators.c:1.79 php-src/ext/spl/spl_iterators.c:1.80 --- php-src/ext/spl/spl_iterators.c:1.79 Fri Aug 12 16:58:28 2005 +++ php-src/ext/spl/spl_iterators.c Mon Aug 15 13:29:04 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_iterators.c,v 1.79 2005/08/12 20:58:28 tony2001 Exp $ */ +/* $Id: spl_iterators.c,v 1.80 2005/08/15 17:29:04 dmitry Exp $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -1503,7 +1503,11 @@ zend_throw_exception_ex(U_CLASS_ENTRY(spl_ce_BadMethodCallException), 0 TSRMLS_CC, "%v does not fetch string value (see CachingIterator::__construct)", Z_OBJCE_P(getThis())->name); } if (intern->u.caching.zstr) { - RETURN_STRINGL(Z_STRVAL_P(intern->u.caching.zstr), Z_STRLEN_P(intern->u.caching.zstr), 1); + *return_value = *intern->u.caching.zstr; + zval_copy_ctor(return_value); + convert_to_text(return_value); + INIT_PZVAL(return_value); +// RETURN_STRINGL(Z_STRVAL_P(intern->u.caching.zstr), Z_STRLEN_P(intern->u.caching.zstr), 1); } else { RETURN_NULL(); } http://cvs.php.net/diff.php/php-src/ext/spl/tests/spl_003.phpt?r1=1.1&r2=1.2&ty=u Index: php-src/ext/spl/tests/spl_003.phpt diff -u php-src/ext/spl/tests/spl_003.phpt:1.1 php-src/ext/spl/tests/spl_003.phpt:1.2 --- php-src/ext/spl/tests/spl_003.phpt:1.1 Wed Apr 6 11:16:45 2005 +++ php-src/ext/spl/tests/spl_003.phpt Mon Aug 15 13:29:07 2005 @@ -73,4 +73,45 @@ } bool(false) bool(false) +===DONE=== +--UEXPECTF-- +Warning: class_parents(): Class foo does not exist in %sspl_003.php on line %d +unicode(3) "foo" + +Warning: class_parents(): Class foo does not exist and could not be loaded in %sspl_003.php on line %d +array(2) { + [u"b"]=> + unicode(1) "b" + [u"a"]=> + unicode(1) "a" +} +array(2) { + [u"b"]=> + unicode(1) "b" + [u"a"]=> + unicode(1) "a" +} +array(1) { + [u"a"]=> + unicode(1) "a" +} +array(1) { + [u"a"]=> + unicode(1) "a" +} +array(0) { +} +bool(false) +bool(false) +unicode(3) "aaa" + +Warning: class_implements(): Class aaa does not exist and could not be loaded in %sspl_003.php on line %d + +Warning: class_implements(): Class bbb does not exist in %sspl_003.php on line %d +array(0) { +} +array(0) { +} +bool(false) +bool(false) ===DONE=== \ No newline at end of file http://cvs.php.net/diff.php/php-src/ext/standard/array.c?r1=1.314&r2=1.315&ty=u Index: php-src/ext/standard/array.c diff -u php-src/ext/standard/array.c:1.314 php-src/ext/standard/array.c:1.315 --- php-src/ext/standard/array.c:1.314 Fri Aug 12 14:03:55 2005 +++ php-src/ext/standard/array.c Mon Aug 15 13:29:07 2005 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: array.c,v 1.314 2005/08/12 18:03:55 tony2001 Exp $ */ +/* $Id: array.c,v 1.315 2005/08/15 17:29:07 dmitry Exp $ */ #include "php.h" #include "php_ini.h" @@ -331,7 +331,7 @@ /* it the object implements Countable we call its count() method */ zval *retval; - if (Z_OBJ_HT_P(array)->get_class_entry && instanceof_function(Z_OBJCE_P(array), spl_ce_Countable TSRMLS_CC)) { + if (Z_OBJ_HT_P(array)->get_class_entry && instanceof_function(Z_OBJCE_P(array), U_CLASS_ENTRY(spl_ce_Countable) TSRMLS_CC)) { zend_call_method_with_0_params(&array, NULL, NULL, "count", &retval); RETVAL_LONG(Z_LVAL_P(retval)); zval_ptr_dtor(&retval);
« previous php.cvs (#33408) next »