helly Sat Feb 18 17:37:55 2006 UTC
Modified files:
/ZendEngine2 zend_vm_def.h zend_vm_execute.h
Log:
- Fix integrated iterator index
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_vm_def.h?r1=1.93&r2=1.94&diff_format=u
Index: ZendEngine2/zend_vm_def.h
diff -u ZendEngine2/zend_vm_def.h:1.93 ZendEngine2/zend_vm_def.h:1.94
--- ZendEngine2/zend_vm_def.h:1.93 Mon Feb 6 11:46:12 2006
+++ ZendEngine2/zend_vm_def.h Sat Feb 18 17:37:54 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_vm_def.h,v 1.93 2006/02/06 11:46:12 dmitry Exp $ */
+/* $Id: zend_vm_def.h,v 1.94 2006/02/18 17:37:54 helly Exp $ */
/* If you change this file, please regenerate the zend_vm_execute.h and
* zend_vm_opcodes.h files by running:
@@ -3118,6 +3118,7 @@
zval_ptr_dtor(&array_ptr);
ZEND_VM_NEXT_OPCODE();
}
+ iter->index = -1; /* will be set to 0 before using next handler
*/
} else if ((fe_ht = HASH_OF(array_ptr)) != NULL) {
zend_hash_internal_pointer_reset(fe_ht);
if (ce) {
@@ -3218,7 +3219,7 @@
case ZEND_ITER_OBJECT:
/* !iter happens from exception */
- if (iter && iter->index++) {
+ if (iter && ++iter->index > 0) {
/* This could cause an endless loop if index
becomes zero again.
* In case that ever happens we need an
additional flag. */
iter->funcs->move_forward(iter TSRMLS_CC);
@@ -3228,7 +3229,8 @@
ZEND_VM_NEXT_OPCODE();
}
}
- if (!iter || (iter->index > 1 &&
iter->funcs->valid(iter TSRMLS_CC) == FAILURE)) {
+ /* If index is zero we come from FE_RESET and checked
valid() already. */
+ if (!iter || (iter->index > 0 &&
iter->funcs->valid(iter TSRMLS_CC) == FAILURE)) {
/* reached end of iteration */
if (EG(exception)) {
array->refcount--;
@@ -3260,7 +3262,6 @@
int_key = iter->index;
}
}
-
break;
}
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_vm_execute.h?r1=1.97&r2=1.98&diff_format=u
Index: ZendEngine2/zend_vm_execute.h
diff -u ZendEngine2/zend_vm_execute.h:1.97 ZendEngine2/zend_vm_execute.h:1.98
--- ZendEngine2/zend_vm_execute.h:1.97 Mon Feb 6 11:46:12 2006
+++ ZendEngine2/zend_vm_execute.h Sat Feb 18 17:37:54 2006
@@ -2057,6 +2057,7 @@
zval_ptr_dtor(&array_ptr);
ZEND_VM_NEXT_OPCODE();
}
+ iter->index = -1; /* will be set to 0 before using next handler
*/
} else if ((fe_ht = HASH_OF(array_ptr)) != NULL) {
zend_hash_internal_pointer_reset(fe_ht);
if (ce) {
@@ -4557,6 +4558,7 @@
zval_ptr_dtor(&array_ptr);
ZEND_VM_NEXT_OPCODE();
}
+ iter->index = -1; /* will be set to 0 before using next handler
*/
} else if ((fe_ht = HASH_OF(array_ptr)) != NULL) {
zend_hash_internal_pointer_reset(fe_ht);
if (ce) {
@@ -7654,6 +7656,7 @@
zval_ptr_dtor(&array_ptr);
ZEND_VM_NEXT_OPCODE();
}
+ iter->index = -1; /* will be set to 0 before using next handler
*/
} else if ((fe_ht = HASH_OF(array_ptr)) != NULL) {
zend_hash_internal_pointer_reset(fe_ht);
if (ce) {
@@ -7754,7 +7757,7 @@
case ZEND_ITER_OBJECT:
/* !iter happens from exception */
- if (iter && iter->index++) {
+ if (iter && ++iter->index > 0) {
/* This could cause an endless loop if index
becomes zero again.
* In case that ever happens we need an
additional flag. */
iter->funcs->move_forward(iter TSRMLS_CC);
@@ -7764,7 +7767,8 @@
ZEND_VM_NEXT_OPCODE();
}
}
- if (!iter || (iter->index > 1 &&
iter->funcs->valid(iter TSRMLS_CC) == FAILURE)) {
+ /* If index is zero we come from FE_RESET and checked
valid() already. */
+ if (!iter || (iter->index > 0 &&
iter->funcs->valid(iter TSRMLS_CC) == FAILURE)) {
/* reached end of iteration */
if (EG(exception)) {
array->refcount--;
@@ -7796,7 +7800,6 @@
int_key = iter->index;
}
}
-
break;
}
@@ -20296,6 +20299,7 @@
zval_ptr_dtor(&array_ptr);
ZEND_VM_NEXT_OPCODE();
}
+ iter->index = -1; /* will be set to 0 before using next handler
*/
} else if ((fe_ht = HASH_OF(array_ptr)) != NULL) {
zend_hash_internal_pointer_reset(fe_ht);
if (ce) {
--
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
|