diff options
author | Nick Ing-Simmons <nik@tiuk.ti.com> | 1998-01-24 12:02:34 +0000 |
---|---|---|
committer | Nick Ing-Simmons <nik@tiuk.ti.com> | 1998-01-24 12:02:34 +0000 |
commit | 67a38de0970070c8aa928e300768e725698b3516 (patch) | |
tree | 397c37ef7b089378b20e2cd74f1dd039b17662df | |
parent | 31da6858e76569983828f43aec742159e881d627 (diff) | |
download | perl-67a38de0970070c8aa928e300768e725698b3516.tar.gz |
Gisle's av_unshift tweak, two small patches from chip
and check for NULL in hv_delete in case '~' and tie magic
are present
p4raw-id: //depot/ansiperl@438
-rw-r--r-- | av.c | 25 | ||||
-rw-r--r-- | hv.c | 8 | ||||
-rw-r--r-- | pp_ctl.c | 11 | ||||
-rw-r--r-- | scope.c | 7 |
4 files changed, 29 insertions, 22 deletions
@@ -436,7 +436,7 @@ void av_unshift(register AV *av, register I32 num) { register I32 i; - register SV **sstr,**dstr; + register SV **ary; MAGIC* mg; if (!av || num <= 0) @@ -471,22 +471,15 @@ av_unshift(register AV *av, register I32 num) AvFILLp(av) += i; SvPVX(av) = (char*)(AvARRAY(av) - i); } - if (num) { - av_extend(av,AvFILLp(av)+num); + if (num) { + i = AvFILLp(av); + av_extend(av, i + num); AvFILLp(av) += num; - dstr = AvARRAY(av) + AvFILLp(av); - sstr = dstr - num; -#ifdef BUGGY_MSC5 - # pragma loop_opt(off) /* don't loop-optimize the following code */ -#endif /* BUGGY_MSC5 */ - for (i = AvFILLp(av) - num; i >= 0; --i) { - *dstr-- = *sstr--; -#ifdef BUGGY_MSC5 - # pragma loop_opt() /* loop-optimization back to command-line setting */ -#endif /* BUGGY_MSC5 */ - } - while (num) - AvARRAY(av)[--num] = &sv_undef; + ary = AvARRAY(av); + Move(ary, ary + num, i + 1, SV*); + do { + ary[--num] = &sv_undef; + } while (num); } } @@ -423,6 +423,7 @@ hv_delete(HV *hv, char *key, U32 klen, I32 flags) register U32 hash; register HE *entry; register HE **oentry; + SV **svp; SV *sv; if (!hv) @@ -432,8 +433,8 @@ hv_delete(HV *hv, char *key, U32 klen, I32 flags) bool needs_store; hv_magic_check (hv, &needs_copy, &needs_store); - if (needs_copy) { - sv = *hv_fetch(hv, key, klen, TRUE); + if (needs_copy && (svp = hv_fetch(hv, key, klen, TRUE))) { + sv = *svp; mg_clear(sv); if (!needs_store) { if (mg_find(sv, 'p')) { @@ -501,8 +502,7 @@ hv_delete_ent(HV *hv, SV *keysv, I32 flags, U32 hash) bool needs_store; hv_magic_check (hv, &needs_copy, &needs_store); - if (needs_copy) { - entry = hv_fetch_ent(hv, keysv, TRUE, hash); + if (needs_copy && (entry = hv_fetch_ent(hv, keysv, TRUE, hash))) { sv = HeVAL(entry); mg_clear(sv); if (!needs_store) { @@ -2162,6 +2162,7 @@ doeval(int gimme, OP** startop) HV *newstash; CV *caller; AV* comppadlist; + I32 i; in_eval = 1; @@ -2178,6 +2179,16 @@ doeval(int gimme, OP** startop) SAVEI32(max_intro_pending); caller = compcv; + for (i = cxstack_ix - 1; i >= 0; i--) { + PERL_CONTEXT *cx = &cxstack[i]; + if (cx->cx_type == CXt_EVAL) + break; + else if (cx->cx_type == CXt_SUB) { + caller = cx->blk_sub.cv; + break; + } + } + SAVESPTR(compcv); compcv = (CV*)NEWSV(1104,0); sv_upgrade((SV *)compcv, SVt_PVCV); @@ -205,11 +205,14 @@ AV * save_ary(GV *gv) { dTHR; - AV *oav, *av; + AV *oav = GvAVn(gv); + AV *av; + if (!AvREAL(oav) && AvREIFY(oav)) + av_reify(oav); SSCHECK(3); SSPUSHPTR(gv); - SSPUSHPTR(oav = GvAVn(gv)); + SSPUSHPTR(oav); SSPUSHINT(SAVEt_AV); GvAV(gv) = Null(AV*); |