cvs: ZendEngine2 / zend_execute.c
| From: | Zeev Suraski | Date: | Wed, 11 Feb 2004 13:58:29 +0000 |
| Subject: | cvs: ZendEngine2 / zend_execute.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-2354@lists.php.net to get a copy of this message | ||
zeev Wed Feb 11 08:58:29 2004 EDT
Modified files:
/ZendEngine2 zend_execute.c
Log:
Improve the implementation of unset() on array dimensions to be more
consistent with that of regular variables and string offsets
http://cvs.php.net/diff.php/ZendEngine2/zend_execute.c?r1=1.604&r2=1.605&ty=u
Index: ZendEngine2/zend_execute.c
diff -u ZendEngine2/zend_execute.c:1.604 ZendEngine2/zend_execute.c:1.605
--- ZendEngine2/zend_execute.c:1.604 Tue Feb 10 12:01:55 2004
+++ ZendEngine2/zend_execute.c Wed Feb 11 08:58:29 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute.c,v 1.604 2004/02/10 17:01:55 zeev Exp $ */
+/* $Id: zend_execute.c,v 1.605 2004/02/11 13:58:29 zeev Exp $ */
#define ZEND_INTENSIVE_DEBUGGING 0
@@ -754,9 +754,10 @@
fetch_string_dim:
if (zend_symtable_find(ht, offset_key, offset_key_length+1, (void **) &retval) == FAILURE) {
switch (type) {
- case BP_VAR_R:
- zend_error(E_NOTICE,"Undefined index: %s", offset_key);
+ case BP_VAR_R:
+ zend_error(E_NOTICE, "Undefined index: %s", offset_key);
/* break missing intentionally */
+ case BP_VAR_UNSET:
case BP_VAR_IS:
retval = &EG(uninitialized_zval_ptr);
break;
@@ -786,9 +787,10 @@
}
if (zend_hash_index_find(ht, index, (void **) &retval) == FAILURE) {
switch (type) {
- case BP_VAR_R:
+ case BP_VAR_R:
zend_error(E_NOTICE,"Undefined offset: %ld", index);
/* break missing intentionally */
+ case BP_VAR_UNSET:
case BP_VAR_IS:
retval = &EG(uninitialized_zval_ptr);
break;
@@ -808,10 +810,15 @@
break;
default:
zend_error(E_WARNING, "Illegal offset type");
- if (type == BP_VAR_R || type == BP_VAR_IS) {
- retval = &EG(uninitialized_zval_ptr);
- } else {
- retval = &EG(error_zval_ptr);
+ switch (type) {
+ case BP_VAR_R:
+ case BP_VAR_IS:
+ case BP_VAR_UNSET:
+ retval = &EG(uninitialized_zval_ptr);
+ break;
+ default:
+ retval = &EG(error_zval_ptr);
+ break;
}
break;
}
@@ -898,8 +905,15 @@
convert_to_long(&tmp);
offset = &tmp;
}
- if (type!=BP_VAR_R && type!=BP_VAR_IS) {
- SEPARATE_ZVAL_IF_NOT_REF(container_ptr);
+ switch (type) {
+ case BP_VAR_R:
+ case BP_VAR_IS:
+ case BP_VAR_UNSET:
+ /* do nothing... */
+ break;
+ default:
+ SEPARATE_ZVAL_IF_NOT_REF(container_ptr);
+ break;
}
container = *container_ptr;
T(result->u.var).str_offset.str = container;
@@ -933,10 +947,18 @@
break;
default: {
get_zval_ptr(op2, Ts, &EG(free_op2), BP_VAR_R);
- if (type==BP_VAR_R || type==BP_VAR_IS) {
- *retval = &EG(uninitialized_zval_ptr);
- } else {
- *retval = &EG(error_zval_ptr);
+
+ switch (type) {
+ case BP_VAR_UNSET:
+ zend_error(E_WARNING, "Cannot unset offset in a non-array variable");
+ /* break missing intentionally */
+ case BP_VAR_R:
+ case BP_VAR_IS:
+ *retval = &EG(uninitialized_zval_ptr);
+ break;
+ default:
+ *retval = &EG(error_zval_ptr);
+ break;
}
FREE_OP(Ts, op2, EG(free_op2));
SELECTIVE_PZVAL_LOCK(**retval, result);
@@ -1970,7 +1992,7 @@
PZVAL_LOCK(*EX_T(opline->op1.u.var).var.ptr_ptr);
}
*/
- zend_fetch_dimension_address(&opline->result, &opline->op1, &opline->op2,
EX(Ts), BP_VAR_R TSRMLS_CC);
+ zend_fetch_dimension_address(&opline->result, &opline->op1, &opline->op2,
EX(Ts), BP_VAR_UNSET TSRMLS_CC);
if (EX_T(opline->result.u.var).var.ptr_ptr == NULL) {
zend_error(E_ERROR, "Cannot unset string offsets");
} else {