summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xext/spl/php_spl.c29
-rwxr-xr-xext/spl/spl_functions.c17
-rwxr-xr-xext/spl/spl_functions.h2
-rwxr-xr-xext/spl/spl_iterators.c6
-rwxr-xr-xext/spl/tests/spl_003.phpt41
-rw-r--r--ext/standard/array.c2
6 files changed, 72 insertions, 25 deletions
diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c
index ea8c1f4ea2..1b0fdcc9bb 100755
--- a/ext/spl/php_spl.c
+++ b/ext/spl/php_spl.c
@@ -59,23 +59,22 @@ static void spl_init_globals(zend_spl_globals *spl_globals)
}
/* }}} */
-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 @@ PHP_FUNCTION(class_parents)
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 @@ PHP_FUNCTION(class_implements)
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 @@ PHP_FUNCTION(class_implements)
/* }}} */
#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); \
diff --git a/ext/spl/spl_functions.c b/ext/spl/spl_functions.c
index 82a6bfb8b9..e86d723234 100755
--- a/ext/spl/spl_functions.c
+++ b/ext/spl/spl_functions.c
@@ -115,11 +115,16 @@ void spl_add_class_name(zval *list, zend_class_entry * pce, int allow, int ce_fl
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 @@ void spl_add_interfaces(zval *list, zend_class_entry * pce, int allow, int ce_fl
/* }}} */
/* {{{ 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 @@ int spl_add_classes(zend_class_entry ** ppce, zval *list, int sub, int allow, in
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;
diff --git a/ext/spl/spl_functions.h b/ext/spl/spl_functions.h
index 61dae21e68..ac39a60528 100755
--- a/ext/spl/spl_functions.h
+++ b/ext/spl/spl_functions.h
@@ -70,7 +70,7 @@ void spl_register_property( zend_class_entry * class_entry, char *prop_name, zva
*/
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)
diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c
index c70573d5c2..3a85e1855c 100755
--- a/ext/spl/spl_iterators.c
+++ b/ext/spl/spl_iterators.c
@@ -1503,7 +1503,11 @@ SPL_METHOD(CachingIterator, __toString)
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();
}
diff --git a/ext/spl/tests/spl_003.phpt b/ext/spl/tests/spl_003.phpt
index cadf3b5a6c..1411388612 100755
--- a/ext/spl/tests/spl_003.phpt
+++ b/ext/spl/tests/spl_003.phpt
@@ -73,4 +73,45 @@ array(0) {
}
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
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 320625da01..b51a070890 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -331,7 +331,7 @@ PHP_FUNCTION(count)
/* 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);