I32 base;
AV *oldstack = curstack;
I32 gimme = GIMME_V;
- I32 oldsave = savestack_ix;
+ I32 oldsave = savestack_ix;
+ I32 stacks_switched = 0;
#ifdef DEBUGGING
Copy(&LvTARGOFF(POPs), &pm, 1, PMOP*);
ary = Nullav;
if (ary && (gimme != G_ARRAY || (pm->op_pmflags & PMf_ONCE))) {
realarray = 1;
- if (!AvREAL(ary)) {
- AvREAL_on(ary);
- for (i = AvFILLp(ary); i >= 0; i--)
- AvARRAY(ary)[i] = &sv_undef; /* don't free mere refs */
- }
av_extend(ary,0);
- av_clear(ary);
- /* temporarily switch stacks */
- SWITCHSTACK(curstack, ary);
+ av_clear(ary);
+ if (!SvRMAGICAL(ary) || !mg_find((SV *) ary, 'P')) {
+ if (!AvREAL(ary)) {
+ AvREAL_on(ary);
+ for (i = AvFILLp(ary); i >= 0; i--)
+ AvARRAY(ary)[i] = &sv_undef; /* don't free mere refs */
+ }
+ /* temporarily switch stacks */
+ SWITCHSTACK(curstack, ary);
+ stacks_switched = 1;
+ }
}
base = SP - stack_base;
orig = s;
iters--, SP--;
}
if (realarray) {
- SWITCHSTACK(ary, oldstack);
- if (SvSMAGICAL(ary)) {
- PUTBACK;
- mg_set((SV*)ary);
- SPAGAIN;
- }
- if (gimme == G_ARRAY) {
- EXTEND(SP, iters);
- Copy(AvARRAY(ary), SP + 1, iters, SV*);
- SP += iters;
- RETURN;
+ if (stacks_switched) {
+ SWITCHSTACK(ary, oldstack);
+ if (SvSMAGICAL(ary)) {
+ PUTBACK;
+ mg_set((SV*)ary);
+ SPAGAIN;
+ }
+ if (gimme == G_ARRAY) {
+ EXTEND(SP, iters);
+ Copy(AvARRAY(ary), SP + 1, iters, SV*);
+ SP += iters;
+ RETURN;
+ }
+ }
+ else {
+ av_extend(ary, iters -1);
+ for (i= 0; i < iters; i++) {
+ dstr = SP[i+1-iters];
+ PUTBACK;
+ fprintf(stderr,"%d:%p %d '%s'\n",i,dstr,SvREFCNT(dstr), SvPV(dstr,na));
+ av_store(ary, i, dstr);
+ SPAGAIN;
+ }
+ if (SvSMAGICAL(ary)) {
+ PUTBACK;
+ mg_set((SV*)ary);
+ SPAGAIN;
+ }
+ for (i= 0; i < iters; i++) {
+ dstr = *av_fetch(ary,i,FALSE);
+ if (SvGMAGICAL(dstr))
+ mg_get(dstr);
+ fprintf(stderr,"%d:%p '%s'\n",i,dstr,SvPV(dstr,na));
+ }
+ if (gimme != G_ARRAY) {
+ SP -= iters;
+ RETURN;
+ }
}
}
else {
package main;
-print "1..29\n";
+print "1..30\n";
my $test = 1;
{my @ary;
print "not " unless $seen{'STORE'} >= 3;
print "ok ", $test++,"\n";
-
print "not " unless join(':',@ary) eq '1:2:3';
print "ok ", $test++,"\n";
+{my @thing = @ary;
+print "not " unless join(':',@thing) eq '1:2:3';
+print "ok ", $test++,"\n";
+
+tie @thing,'Implement';
+@thing = @ary;
+print "not " unless join(':',@thing) eq '1:2:3';
+print "ok ", $test++,"\n";
+}
+
print "not " unless pop(@ary) == 3;
print "ok ", $test++,"\n";
print "not " unless $seen{'POP'} == 1;
}
-print "not " unless $seen{'DESTROY'} == 1;
+print "not " unless $seen{'DESTROY'} == 2;
print "ok ", $test++,"\n";