summaryrefslogtreecommitdiff
path: root/ext/spl/spl_array.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/spl/spl_array.c')
-rwxr-xr-xext/spl/spl_array.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index d025f3ffd..8079088d8 100755
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_array.c,v 1.71.2.17.2.4 2006/10/20 02:11:19 pollita Exp $ */
+/* $Id: spl_array.c,v 1.71.2.17.2.11 2007/04/06 17:57:10 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -42,8 +42,6 @@ zend_object_handlers spl_handler_ArrayIterator;
PHPAPI zend_class_entry *spl_ce_ArrayIterator;
PHPAPI zend_class_entry *spl_ce_RecursiveArrayIterator;
-PHPAPI zend_class_entry *spl_ce_Countable;
-
#define SPL_ARRAY_STD_PROP_LIST 0x00000001
#define SPL_ARRAY_ARRAY_AS_PROPS 0x00000002
#define SPL_ARRAY_OVERLOADED_REWIND 0x00010000
@@ -458,7 +456,7 @@ static int spl_array_has_dimension_ex(int check_inherited, zval *object, zval *o
{
spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
long index;
- zval *rv;
+ zval *rv, **tmp;
if (check_inherited && intern->fptr_offset_has) {
SEPARATE_ARG_IF_REF(offset);
@@ -476,7 +474,14 @@ static int spl_array_has_dimension_ex(int check_inherited, zval *object, zval *o
switch(Z_TYPE_P(offset)) {
case IS_STRING:
- return zend_symtable_exists(spl_array_get_hash_table(intern, 0 TSRMLS_CC), Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1);
+ if (check_empty) {
+ if (zend_symtable_find(spl_array_get_hash_table(intern, 0 TSRMLS_CC), Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **) &tmp) != FAILURE && zend_is_true(*tmp)) {
+ return 1;
+ }
+ return 0;
+ } else {
+ return zend_symtable_exists(spl_array_get_hash_table(intern, 0 TSRMLS_CC), Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1);
+ }
case IS_DOUBLE:
case IS_RESOURCE:
case IS_BOOL:
@@ -486,7 +491,15 @@ static int spl_array_has_dimension_ex(int check_inherited, zval *object, zval *o
} else {
index = Z_LVAL_P(offset);
}
- return zend_hash_index_exists(spl_array_get_hash_table(intern, 0 TSRMLS_CC), index);
+ if (check_empty) {
+ HashTable *ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
+ if (zend_hash_index_find(ht, index, (void **)&tmp) != FAILURE && zend_is_true(*tmp)) {
+ return 1;
+ }
+ return 0;
+ } else {
+ return zend_hash_index_exists(spl_array_get_hash_table(intern, 0 TSRMLS_CC), index);
+ }
default:
zend_error(E_WARNING, "Illegal offset type");
}
@@ -507,7 +520,7 @@ SPL_METHOD(Array, offsetExists)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &index) == FAILURE) {
return;
}
- RETURN_BOOL(spl_array_has_dimension_ex(0, getThis(), index, 1 TSRMLS_CC));
+ RETURN_BOOL(spl_array_has_dimension_ex(0, getThis(), index, 0 TSRMLS_CC));
} /* }}} */
/* {{{ proto mixed ArrayObject::offsetGet(mixed $index)
@@ -1022,7 +1035,7 @@ SPL_METHOD(Array, exchangeArray)
zend_hash_copy(HASH_OF(return_value), spl_array_get_hash_table(intern, 0 TSRMLS_CC), (copy_ctor_func_t) zval_add_ref, &tmp, sizeof(zval*));
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &array) == FAILURE) {
- WRONG_PARAM_COUNT;
+ return;
}
if (Z_TYPE_PP(array) == IS_OBJECT && intern == (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC)) {
zval_ptr_dtor(&intern->array);
@@ -1477,11 +1490,6 @@ static zend_function_entry spl_funcs_RecursiveArrayIterator[] = {
{NULL, NULL, NULL}
};
-static zend_function_entry spl_funcs_Countable[] = {
- SPL_ABSTRACT_ME(Countable, count, NULL)
- {NULL, NULL, NULL}
-};
-
/* {{{ PHP_MINIT_FUNCTION(spl_array) */
PHP_MINIT_FUNCTION(spl_array)
{
@@ -1515,8 +1523,6 @@ PHP_MINIT_FUNCTION(spl_array)
REGISTER_SPL_IMPLEMENTS(RecursiveArrayIterator, RecursiveIterator);
spl_ce_RecursiveArrayIterator->get_iterator = spl_array_get_iterator;
- REGISTER_SPL_INTERFACE(Countable);
-
REGISTER_SPL_IMPLEMENTS(ArrayObject, Countable);
REGISTER_SPL_IMPLEMENTS(ArrayIterator, Countable);