| 1 |
--- perl-5.10.0/op.c 2007-12-18 05:47:07.000000000 -0500
|
| 2 |
+++ perl-5.10.0/op.c 2007-12-31 11:15:57.000000000 -0500
|
| 3 |
@@ -3992,6 +3992,7 @@
|
| 4 |
static const char no_list_state[] = "Initialization of state variables"
|
| 5 |
" in list context currently forbidden";
|
| 6 |
OP *curop;
|
| 7 |
+ bool maybe_common_vars = TRUE;
|
| 8 |
|
| 9 |
PL_modcount = 0;
|
| 10 |
/* Grandfathering $[ assignment here. Bletch.*/
|
| 11 |
@@ -4009,6 +4010,65 @@
|
| 12 |
o = newBINOP(OP_AASSIGN, flags, list(force_list(right)), curop);
|
| 13 |
o->op_private = (U8)(0 | (flags >> 8));
|
| 14 |
|
| 15 |
+ if ((left->op_type == OP_LIST
|
| 16 |
+ || (left->op_type == OP_NULL && left->op_targ == OP_LIST)))
|
| 17 |
+ {
|
| 18 |
+ OP* lop = ((LISTOP*)left)->op_first;
|
| 19 |
+ maybe_common_vars = FALSE;
|
| 20 |
+ while (lop) {
|
| 21 |
+ if (lop->op_type == OP_PADSV ||
|
| 22 |
+ lop->op_type == OP_PADAV ||
|
| 23 |
+ lop->op_type == OP_PADHV ||
|
| 24 |
+ lop->op_type == OP_PADANY) {
|
| 25 |
+ if (!(lop->op_private & OPpLVAL_INTRO))
|
| 26 |
+ maybe_common_vars = TRUE;
|
| 27 |
+
|
| 28 |
+ if (lop->op_private & OPpPAD_STATE) {
|
| 29 |
+ if (left->op_private & OPpLVAL_INTRO) {
|
| 30 |
+ /* Each variable in state($a, $b, $c) = ... */
|
| 31 |
+ }
|
| 32 |
+ else {
|
| 33 |
+ /* Each state variable in
|
| 34 |
+ (state $a, my $b, our $c, $d, undef) = ... */
|
| 35 |
+ }
|
| 36 |
+ yyerror(no_list_state);
|
| 37 |
+ } else {
|
| 38 |
+ /* Each my variable in
|
| 39 |
+ (state $a, my $b, our $c, $d, undef) = ... */
|
| 40 |
+ }
|
| 41 |
+ } else if (lop->op_type == OP_UNDEF ||
|
| 42 |
+ lop->op_type == OP_PUSHMARK) {
|
| 43 |
+ /* undef may be interesting in
|
| 44 |
+ (state $a, undef, state $c) */
|
| 45 |
+ } else {
|
| 46 |
+ /* Other ops in the list. */
|
| 47 |
+ maybe_common_vars = TRUE;
|
| 48 |
+ }
|
| 49 |
+ lop = lop->op_sibling;
|
| 50 |
+ }
|
| 51 |
+ }
|
| 52 |
+ else if ((left->op_private & OPpLVAL_INTRO)
|
| 53 |
+ && ( left->op_type == OP_PADSV
|
| 54 |
+ || left->op_type == OP_PADAV
|
| 55 |
+ || left->op_type == OP_PADHV
|
| 56 |
+ || left->op_type == OP_PADANY))
|
| 57 |
+ {
|
| 58 |
+ maybe_common_vars = FALSE;
|
| 59 |
+ if (left->op_private & OPpPAD_STATE) {
|
| 60 |
+ /* All single variable list context state assignments, hence
|
| 61 |
+ state ($a) = ...
|
| 62 |
+ (state $a) = ...
|
| 63 |
+ state @a = ...
|
| 64 |
+ state (@a) = ...
|
| 65 |
+ (state @a) = ...
|
| 66 |
+ state %a = ...
|
| 67 |
+ state (%a) = ...
|
| 68 |
+ (state %a) = ...
|
| 69 |
+ */
|
| 70 |
+ yyerror(no_list_state);
|
| 71 |
+ }
|
| 72 |
+ }
|
| 73 |
+
|
| 74 |
/* PL_generation sorcery:
|
| 75 |
* an assignment like ($a,$b) = ($c,$d) is easier than
|
| 76 |
* ($a,$b) = ($c,$a), since there is no need for temporary vars.
|
| 77 |
@@ -4023,7 +4083,7 @@
|
| 78 |
* to store these values, evil chicanery is done with SvUVX().
|
| 79 |
*/
|
| 80 |
|
| 81 |
- {
|
| 82 |
+ if (maybe_common_vars) {
|
| 83 |
OP *lastop = o;
|
| 84 |
PL_generation++;
|
| 85 |
for (curop = LINKLIST(o); curop != o; curop = LINKLIST(curop)) {
|
| 86 |
@@ -4084,54 +4144,6 @@
|
| 87 |
o->op_private |= OPpASSIGN_COMMON;
|
| 88 |
}
|
| 89 |
|
| 90 |
- if ((left->op_type == OP_LIST
|
| 91 |
- || (left->op_type == OP_NULL && left->op_targ == OP_LIST))) {
|
| 92 |
- OP* lop = ((LISTOP*)left)->op_first;
|
| 93 |
- while (lop) {
|
| 94 |
- if (lop->op_type == OP_PADSV ||
|
| 95 |
- lop->op_type == OP_PADAV ||
|
| 96 |
- lop->op_type == OP_PADHV ||
|
| 97 |
- lop->op_type == OP_PADANY) {
|
| 98 |
- if (lop->op_private & OPpPAD_STATE) {
|
| 99 |
- if (left->op_private & OPpLVAL_INTRO) {
|
| 100 |
- /* Each variable in state($a, $b, $c) = ... */
|
| 101 |
- }
|
| 102 |
- else {
|
| 103 |
- /* Each state variable in
|
| 104 |
- (state $a, my $b, our $c, $d, undef) = ... */
|
| 105 |
- }
|
| 106 |
- yyerror(no_list_state);
|
| 107 |
- } else {
|
| 108 |
- /* Each my variable in
|
| 109 |
- (state $a, my $b, our $c, $d, undef) = ... */
|
| 110 |
- }
|
| 111 |
- } else {
|
| 112 |
- /* Other ops in the list. undef may be interesting in
|
| 113 |
- (state $a, undef, state $c) */
|
| 114 |
- }
|
| 115 |
- lop = lop->op_sibling;
|
| 116 |
- }
|
| 117 |
- }
|
| 118 |
- else if (((left->op_private & (OPpLVAL_INTRO | OPpPAD_STATE))
|
| 119 |
- == (OPpLVAL_INTRO | OPpPAD_STATE))
|
| 120 |
- && ( left->op_type == OP_PADSV
|
| 121 |
- || left->op_type == OP_PADAV
|
| 122 |
- || left->op_type == OP_PADHV
|
| 123 |
- || left->op_type == OP_PADANY))
|
| 124 |
- {
|
| 125 |
- /* All single variable list context state assignments, hence
|
| 126 |
- state ($a) = ...
|
| 127 |
- (state $a) = ...
|
| 128 |
- state @a = ...
|
| 129 |
- state (@a) = ...
|
| 130 |
- (state @a) = ...
|
| 131 |
- state %a = ...
|
| 132 |
- state (%a) = ...
|
| 133 |
- (state %a) = ...
|
| 134 |
- */
|
| 135 |
- yyerror(no_list_state);
|
| 136 |
- }
|
| 137 |
-
|
| 138 |
if (right && right->op_type == OP_SPLIT && !PL_madskills) {
|
| 139 |
OP* tmpop = ((LISTOP*)right)->op_first;
|
| 140 |
if (tmpop && (tmpop->op_type == OP_PUSHRE)) {
|