php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch php-5.4.0-alpha1-foreach-list-diff.patch for Scripting Engine problem Bug #10203

Patch version 2011-07-06 05:34 UTC

Return to Bug #10203 | Download this patch
Patch Revisions:

Developer: laruence@php.net

diff php-5.4.0alpha1/Zend/zend_compile.c php-5.4.0alpha1.edited/Zend/zend_compile.c
5826c5826
< 	opline = &CG(active_op_array)->opcodes[as_token->u.op.	opline_num];
---
> 	opline = &CG(active_op_array)->opcodes[as_token->u.op.opline_num];
5839,5840c5839,5845
< 	if ((key->op_type != IS_UNUSED) && (key->EA & ZEND_PARSED_REFERENCE_VARIABLE)) {
< 		zend_error(E_COMPILE_ERROR, "Key element cannot be a reference");
---
> 	if ((key->op_type != IS_UNUSED)) {
>         if (key->EA & ZEND_PARSED_REFERENCE_VARIABLE) {
> 		    zend_error(E_COMPILE_ERROR, "Key element cannot be a reference");
>         }
>         if (key->EA & ZEND_PARSED_LIST) {
> 		    zend_error(E_COMPILE_ERROR, "Key element cannot be a list expression");
>         }
5875,5883c5880,5892
< 
< 	if (assign_by_ref) {
< 		zend_do_end_variable_parse(value, BP_VAR_W, 0 TSRMLS_CC);
< 		/* Mark FE_FETCH as IS_VAR as it holds the data directly as a value */
< 		zend_do_assign_ref(NULL, value, &value_node TSRMLS_CC);
< 	} else {
< 		zend_do_assign(&dummy, value, &value_node TSRMLS_CC);
< 		zend_do_free(&dummy TSRMLS_CC);
< 	}
---
>     if (value->EA & ZEND_PARSED_LIST) {
>         zend_do_list_end(&dummy, &value_node TSRMLS_CC);
>         zend_do_free(&dummy TSRMLS_CC);
>     } else {
>         if (assign_by_ref) {
>             zend_do_end_variable_parse(value, BP_VAR_W, 0 TSRMLS_CC);
>             /* Mark FE_FETCH as IS_VAR as it holds the data directly as a value */
>             zend_do_assign_ref(NULL, value, &value_node TSRMLS_CC);
>         } else {
>             zend_do_assign(&dummy, value, &value_node TSRMLS_CC);
>             zend_do_free(&dummy TSRMLS_CC);
>         }
>     }
diff php-5.4.0alpha1/Zend/zend_compile.h php-5.4.0alpha1.list/Zend/zend_compile.h
715a716
> #define ZEND_PARSED_LIST                (1<<7)
diff php-5.4.0alpha1/Zend/zend_language_parser.y php-5.4.0alpha1.list/Zend/zend_language_parser.y
255c255
< 		variable foreach_optional_arg ')' { zend_check_writable_variable(&$6); zend_do_foreach_cont(&$1, &$2, &$4, &$6, &$7 TSRMLS_CC); }
---
> 		foreach_variable foreach_optional_arg ')' { zend_check_writable_variable(&$6); zend_do_foreach_cont(&$1, &$2, &$4, &$6, &$7 TSRMLS_CC); }
363,364c363,364
< 		/* empty */						{ $$.op_type = IS_UNUSED; }
< 	|	T_DOUBLE_ARROW foreach_variable	{ $$ = $2; }
---
> 		/* empty */						        { $$.op_type = IS_UNUSED; }
> 	|	T_DOUBLE_ARROW foreach_variable	        { $$ = $2; }
367d366
< 
370a370
>     |   T_LIST '('          { zend_do_list_init(TSRMLS_C); } assignment_list ')' { $$ = $1;$$.EA |= ZEND_PARSED_LIST; }
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 22:01:28 2024 UTC