helly Thu Feb 12 15:52:49 2004 EDT
Modified files:
/php-src/ext/spl/tests array_object.phpt
/php-src/ext/spl spl_array.c
Log:
Fix ArrayObject
http://cvs.php.net/diff.php/php-src/ext/spl/tests/array_object.phpt?r1=1.1&r2=1.2&ty=u
Index: php-src/ext/spl/tests/array_object.phpt
diff -u php-src/ext/spl/tests/array_object.phpt:1.1
php-src/ext/spl/tests/array_object.phpt:1.2
--- php-src/ext/spl/tests/array_object.phpt:1.1 Wed Nov 26 18:28:35 2003
+++ php-src/ext/spl/tests/array_object.phpt Thu Feb 12 15:52:46 2004
@@ -30,8 +30,9 @@
unset($ar["c"]);
var_dump($ar);
-echo "Done\n";
?>
+===DONE===
+<?php exit(0); ?>
--EXPECTF--
object(ArrayObject)#1 (2) {
[0]=>
@@ -47,9 +48,9 @@
[1]=>
int(1)
[2]=>
- &int(2)
+ int(2)
[3]=>
- &int(3)
+ int(3)
[4]=>
int(4)
[5]=>
@@ -62,11 +63,11 @@
[1]=>
int(1)
[2]=>
- &int(2)
+ int(2)
[3]=>
- &int(3)
+ int(3)
["a"]=>
- &string(1) "a"
+ string(1) "a"
}
int(0)
@@ -83,6 +84,6 @@
[0]=>
int(0)
[2]=>
- &int(2)
+ int(2)
}
-Done
+===DONE===
http://cvs.php.net/diff.php/php-src/ext/spl/spl_array.c?r1=1.31&r2=1.32&ty=u
Index: php-src/ext/spl/spl_array.c
diff -u php-src/ext/spl/spl_array.c:1.31 php-src/ext/spl/spl_array.c:1.32
--- php-src/ext/spl/spl_array.c:1.31 Wed Feb 4 07:45:47 2004
+++ php-src/ext/spl/spl_array.c Thu Feb 12 15:52:48 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_array.c,v 1.31 2004/02/04 12:45:47 zeev Exp $ */
+/* $Id: spl_array.c,v 1.32 2004/02/12 20:52:48 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -152,7 +152,7 @@
/* }}} */
/* {{{ spl_array_read_dimension */
-static zval *spl_array_read_dimension(zval *object, zval *offset TSRMLS_DC)
+static zval *spl_array_read_dimension(zval *object, zval *offset, int type TSRMLS_DC)
{
spl_array_object *intern =
(spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
zval **retval;
@@ -161,9 +161,10 @@
switch(Z_TYPE_P(offset)) {
case IS_STRING:
if (zend_symtable_find(HASH_OF(intern->array), Z_STRVAL_P(offset),
Z_STRLEN_P(offset)+1, (void **) &retval) == FAILURE) {
- zend_error(E_NOTICE,"Undefined index: %s",
Z_STRVAL_P(offset));
+ zend_error(E_NOTICE, "Undefined index: %s",
Z_STRVAL_P(offset));
return EG(uninitialized_zval_ptr);
} else {
+ (*retval)->refcount++;
return *retval;
}
case IS_DOUBLE:
@@ -176,7 +177,7 @@
index = Z_LVAL_P(offset);
}
if (zend_hash_index_find(HASH_OF(intern->array), index, (void **)
&retval) == FAILURE) {
- zend_error(E_NOTICE,"Undefined offset: %ld",
Z_LVAL_P(offset));
+ zend_error(E_NOTICE, "Undefined offset: %ld",
Z_LVAL_P(offset));
return EG(uninitialized_zval_ptr);
} else {
return *retval;
@@ -197,6 +198,11 @@
switch(Z_TYPE_P(offset)) {
case IS_STRING:
+ if (!value->is_ref) {
+ value->refcount++;
+ } else {
+ SEPARATE_ZVAL_IF_NOT_REF(&value);
+ }
zend_symtable_update(HASH_OF(intern->array), Z_STRVAL_P(offset),
Z_STRLEN_P(offset)+1, (void**)&value, sizeof(void*), NULL);
return;
case IS_DOUBLE:
@@ -208,6 +214,11 @@
} else {
index = Z_LVAL_P(offset);
}
+ if (!value->is_ref) {
+ value->refcount++;
+ } else {
+ SEPARATE_ZVAL_IF_NOT_REF(&value);
+ }
add_index_zval(intern->array, index, value);
return;
default:
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php