summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>1998-01-24 12:02:34 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>1998-01-24 12:02:34 +0000
commit67a38de0970070c8aa928e300768e725698b3516 (patch)
tree397c37ef7b089378b20e2cd74f1dd039b17662df
parent31da6858e76569983828f43aec742159e881d627 (diff)
downloadperl-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.c25
-rw-r--r--hv.c8
-rw-r--r--pp_ctl.c11
-rw-r--r--scope.c7
4 files changed, 29 insertions, 22 deletions
diff --git a/av.c b/av.c
index 5925a17869..20c77d8444 100644
--- a/av.c
+++ b/av.c
@@ -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);
}
}
diff --git a/hv.c b/hv.c
index 5a0f9d2473..25f14220fb 100644
--- a/hv.c
+++ b/hv.c
@@ -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) {
diff --git a/pp_ctl.c b/pp_ctl.c
index 9590271e87..68bf5d2beb 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -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);
diff --git a/scope.c b/scope.c
index bca1c2b455..61bc731457 100644
--- a/scope.c
+++ b/scope.c
@@ -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*);