helly           Wed Jan 26 19:22:08 2005 EDT

  Modified files:              
    /php-src/ext/spl    spl_array.c 
  Log:
  - Know whether ew refer to an external array (is_ref) or not
  
http://cvs.php.net/diff.php/php-src/ext/spl/spl_array.c?r1=1.57&r2=1.58&ty=u
Index: php-src/ext/spl/spl_array.c
diff -u php-src/ext/spl/spl_array.c:1.57 php-src/ext/spl/spl_array.c:1.58
--- php-src/ext/spl/spl_array.c:1.57    Thu Nov 11 15:06:23 2004
+++ php-src/ext/spl/spl_array.c Wed Jan 26 19:22:06 2005
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_array.c,v 1.57 2004/11/11 20:06:23 helly Exp $ */
+/* $Id: spl_array.c,v 1.58 2005/01/27 00:22:06 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -127,6 +127,7 @@
        zend_object       std;
        zval              *array;
        HashPosition      pos;
+       int               is_ref;
 } spl_array_object;
 
 /* {{{ spl_array_object_free_storage */
@@ -162,9 +163,11 @@
        if (orig) {
                intern->array = orig->array;
                ZVAL_ADDREF(intern->array);
+               intern->is_ref = 1;
        } else {
                MAKE_STD_ZVAL(intern->array);
                array_init(intern->array);
+               intern->is_ref = 0;
        }
        zend_hash_internal_pointer_reset_ex(HASH_OF(intern->array), 
&intern->pos);
 
@@ -497,11 +500,16 @@
 {
        HashTable *aht = HASH_OF(intern->array);
 
-       zend_hash_move_forward_ex(aht, &intern->pos);
-       if (Z_TYPE_P(intern->array) == IS_OBJECT) {
-               return spl_array_skip_protected(intern TSRMLS_CC);
+       if (intern->is_ref && spl_hash_verify_pos(intern TSRMLS_CC) == FAILURE) 
{
+               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified 
outside object and internal position is no longer valid");
+               return FAILURE;
        } else {
-               return zend_hash_has_more_elements_ex(aht, &intern->pos);
+               zend_hash_move_forward_ex(aht, &intern->pos);
+               if (Z_TYPE_P(intern->array) == IS_OBJECT) {
+                       return spl_array_skip_protected(intern TSRMLS_CC);
+               } else {
+                       return zend_hash_has_more_elements_ex(aht, 
&intern->pos);
+               }
        }
 } /* }}} */
 
@@ -532,7 +540,7 @@
                return FAILURE;
        }
 
-       if (object->pos && object->array->is_ref && spl_hash_verify_pos(object 
TSRMLS_CC) == FAILURE) {
+       if (object->pos && object->is_ref && spl_hash_verify_pos(object 
TSRMLS_CC) == FAILURE) {
                php_error_docref(NULL TSRMLS_CC, E_NOTICE, 
"ArrayIterator::valid(): Array was modified outside object and internal 
position is no longer valid");
                return FAILURE;
        } else {
@@ -564,7 +572,7 @@
                return HASH_KEY_NON_EXISTANT;
        }
 
-       if (object->array->is_ref && spl_hash_verify_pos(object TSRMLS_CC) == 
FAILURE) {
+       if (object->is_ref && spl_hash_verify_pos(object TSRMLS_CC) == FAILURE) 
{
                php_error_docref(NULL TSRMLS_CC, E_NOTICE, 
"ArrayIterator::current(): Array was modified outside object and internal 
position is no longer valid");
                return HASH_KEY_NON_EXISTANT;
        }
@@ -585,7 +593,7 @@
                return;
        }
 
-       if (object->array->is_ref && spl_hash_verify_pos(object TSRMLS_CC) == 
FAILURE) {
+       if (object->is_ref && spl_hash_verify_pos(object TSRMLS_CC) == FAILURE) 
{
                php_error_docref(NULL TSRMLS_CC, E_NOTICE, 
"ArrayIterator::next(): Array was modified outside object and internal position 
is no longer valid");
        } else {
                spl_array_next(object TSRMLS_CC);
@@ -791,7 +799,7 @@
                return;
        }
 
-       if (intern->array->is_ref && spl_hash_verify_pos(intern TSRMLS_CC) == 
FAILURE) {
+       if (intern->is_ref && spl_hash_verify_pos(intern TSRMLS_CC) == FAILURE) 
{
                php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified 
outside object and internal position is no longer valid");
                return;
        }
@@ -820,7 +828,7 @@
                return;
        }
 
-       if (intern->array->is_ref && spl_hash_verify_pos(intern TSRMLS_CC) == 
FAILURE) {
+       if (intern->is_ref && spl_hash_verify_pos(intern TSRMLS_CC) == FAILURE) 
{
                php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified 
outside object and internal position is no longer valid");
                return;
        }
@@ -851,11 +859,7 @@
                return;
        }
 
-       if (intern->array->is_ref && spl_hash_verify_pos(intern TSRMLS_CC) == 
FAILURE) {
-               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified 
outside object and internal position is no longer valid");
-       } else {
-               spl_array_next(intern TSRMLS_CC);
-       }
+       spl_array_next(intern TSRMLS_CC);
 }
 /* }}} */
 
@@ -872,7 +876,7 @@
                return;
        }
 
-       if (intern->pos && intern->array->is_ref && spl_hash_verify_pos(intern 
TSRMLS_CC) == FAILURE) {
+       if (intern->pos && intern->is_ref && spl_hash_verify_pos(intern 
TSRMLS_CC) == FAILURE) {
                php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified 
outside object and internal position is no longer valid");
                RETURN_FALSE;
        } else {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to