summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1999-02-12 05:39:29 +0000
committerGurusamy Sarathy <gsar@cpan.org>1999-02-12 05:39:29 +0000
commit35cd451c5a1303394968903750cc3b3a1a6bc892 (patch)
tree0dff9ce049b3cd7facf6fbfd54dcddddc8ac0990 /pp.c
parentcf34019797138569fd71cfc48bb60249b9df0ec3 (diff)
downloadperl-35cd451c5a1303394968903750cc3b3a1a6bc892.tar.gz
fix ops that are not filehandle constructors to not create GV if it
doesn't already exist (avoids leaks); extend semantics of defined() so that defined(*{$foo}) works (experimental) p4raw-id: //depot/perl@2879
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/pp.c b/pp.c
index 729d1e7ccc..83d881b58d 100644
--- a/pp.c
+++ b/pp.c
@@ -240,9 +240,18 @@ PP(pp_rv2gv)
RETSETUNDEF;
}
sym = SvPV(sv, n_a);
- if (PL_op->op_private & HINT_STRICT_REFS)
- DIE(PL_no_symref, sym, "a symbol");
- sv = (SV*)gv_fetchpv(sym, TRUE, SVt_PVGV);
+ if ((PL_op->op_flags & OPf_SPECIAL) &&
+ !(PL_op->op_flags & OPf_MOD))
+ {
+ sv = (SV*)gv_fetchpv(sym, FALSE, SVt_PVGV);
+ if (!sv)
+ RETSETUNDEF;
+ }
+ else {
+ if (PL_op->op_private & HINT_STRICT_REFS)
+ DIE(PL_no_symref, sym, "a symbol");
+ sv = (SV*)gv_fetchpv(sym, TRUE, SVt_PVGV);
+ }
}
}
if (PL_op->op_private & OPpLVAL_INTRO)
@@ -287,9 +296,18 @@ PP(pp_rv2sv)
RETSETUNDEF;
}
sym = SvPV(sv, n_a);
- if (PL_op->op_private & HINT_STRICT_REFS)
- DIE(PL_no_symref, sym, "a SCALAR");
- gv = (GV*)gv_fetchpv(sym, TRUE, SVt_PV);
+ if ((PL_op->op_flags & OPf_SPECIAL) &&
+ !(PL_op->op_flags & OPf_MOD))
+ {
+ gv = (GV*)gv_fetchpv(sym, FALSE, SVt_PV);
+ if (!gv)
+ RETSETUNDEF;
+ }
+ else {
+ if (PL_op->op_private & HINT_STRICT_REFS)
+ DIE(PL_no_symref, sym, "a SCALAR");
+ gv = (GV*)gv_fetchpv(sym, TRUE, SVt_PV);
+ }
}
sv = GvSV(gv);
}