summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorGisle Aas <gisle@aas.no>2001-05-23 09:13:10 -0700
committerJarkko Hietaniemi <jhi@iki.fi>2001-05-24 12:36:35 +0000
commitec4ab249deaa88f5a071536b0473504f26c43486 (patch)
tree02fa2dd5e85b23366ae7c0f8f236a3f9ed01b63c /op.c
parent600d99fa249bb9ea83f068d4a70954217a9361a3 (diff)
downloadperl-ec4ab249deaa88f5a071536b0473504f26c43486.tar.gz
CORE::GLOBAL::require override happens too early
Message-ID: <lrofsjfym1.fsf@caliper.ActiveState.com> p4raw-id: //depot/perl@10192
Diffstat (limited to 'op.c')
-rw-r--r--op.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/op.c b/op.c
index 61f485073a..a252a0279d 100644
--- a/op.c
+++ b/op.c
@@ -3192,7 +3192,6 @@ void
Perl_utilize(pTHX_ int aver, I32 floor, OP *version, OP *id, OP *arg)
{
OP *pack;
- OP *rqop;
OP *imop;
OP *veop;
GV *gv;
@@ -3253,22 +3252,6 @@ Perl_utilize(pTHX_ int aver, I32 floor, OP *version, OP *id, OP *arg)
newSVOP(OP_METHOD_NAMED, 0, meth)));
}
- /* Fake up a require, handle override, if any */
- gv = gv_fetchpv("require", FALSE, SVt_PVCV);
- if (!(gv && GvIMPORTED_CV(gv)))
- gv = gv_fetchpv("CORE::GLOBAL::require", FALSE, SVt_PVCV);
-
- if (gv && GvIMPORTED_CV(gv)) {
- rqop = ck_subr(newUNOP(OP_ENTERSUB, OPf_STACKED,
- append_elem(OP_LIST, id,
- scalar(newUNOP(OP_RV2CV, 0,
- newGVOP(OP_GV, 0,
- gv))))));
- }
- else {
- rqop = newUNOP(OP_REQUIRE, 0, id);
- }
-
/* Fake up the BEGIN {}, which does its thing immediately. */
newATTRSUB(floor,
newSVOP(OP_CONST, 0, newSVpvn("BEGIN", 5)),
@@ -3276,7 +3259,7 @@ Perl_utilize(pTHX_ int aver, I32 floor, OP *version, OP *id, OP *arg)
Nullop,
append_elem(OP_LINESEQ,
append_elem(OP_LINESEQ,
- newSTATEOP(0, Nullch, rqop),
+ newSTATEOP(0, Nullch, newUNOP(OP_REQUIRE, 0, id)),
newSTATEOP(0, Nullch, veop)),
newSTATEOP(0, Nullch, imop) ));
@@ -6186,6 +6169,8 @@ Perl_ck_repeat(pTHX_ OP *o)
OP *
Perl_ck_require(pTHX_ OP *o)
{
+ GV* gv;
+
if (o->op_flags & OPf_KIDS) { /* Shall we supply missing .pm? */
SVOP *kid = (SVOP*)cUNOPo->op_first;
@@ -6207,6 +6192,23 @@ Perl_ck_require(pTHX_ OP *o)
sv_catpvn(kid->op_sv, ".pm", 3);
}
}
+
+ /* handle override, if any */
+ gv = gv_fetchpv("require", FALSE, SVt_PVCV);
+ if (!(gv && GvIMPORTED_CV(gv)))
+ gv = gv_fetchpv("CORE::GLOBAL::require", FALSE, SVt_PVCV);
+
+ if (gv && GvIMPORTED_CV(gv)) {
+ OP *kid = cUNOPo->op_first;
+ cUNOPo->op_first = 0;
+ op_free(o);
+ return ck_subr(newUNOP(OP_ENTERSUB, OPf_STACKED,
+ append_elem(OP_LIST, kid,
+ scalar(newUNOP(OP_RV2CV, 0,
+ newGVOP(OP_GV, 0,
+ gv))))));
+ }
+
return ck_fun(o);
}