summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2010-12-31 18:55:36 +0000
committerDavid Mitchell <davem@iabyn.com>2011-01-02 20:00:27 +0000
commitd1bea3d84afd8d32a236c8d800e5dfc0f837570e (patch)
tree7dab3aeb9baab81964b9a5e1de46c462327177e4 /op.c
parentbd31915d33b7eefea64e1a3f2416f804acf79df2 (diff)
downloadperl-d1bea3d84afd8d32a236c8d800e5dfc0f837570e.tar.gz
call pp_glob() even when its being skipped
Currently when an external Perl glob function is used (which is most of the time), the OP_GLOB op is removed and replaced with the pair: GV("CORE::GLOBAL::glob"), ENTERSUB. This commit re-adds the OP_GLOB to the op tree, but with OPf_SPECIAL set; and pp_glob() is updated to just return if OPf_SPECIAL is set. Thus there's no change in outward functionality with this commit. However, by always calling pp_glob(), it will allow us (in the next commit) to handle iterator overloading consistently, regardless of whether the internal globbing function is used or not.
Diffstat (limited to 'op.c')
-rw-r--r--op.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/op.c b/op.c
index ba9e2e2c57..a1b11a2d97 100644
--- a/op.c
+++ b/op.c
@@ -7663,20 +7663,30 @@ Perl_ck_glob(pTHX_ OP *o)
}
#endif /* PERL_EXTERNAL_GLOB */
+ assert(!(o->op_flags & OPf_SPECIAL));
if (gv && GvCVu(gv) && GvIMPORTED_CV(gv)) {
+ /* convert
+ * glob
+ * \ null - const(wildcard)
+ * into
+ * null
+ * \ enter
+ * \ list
+ * \ mark - glob - rv2cv
+ * | \ gv(CORE::GLOBAL::glob)
+ * |
+ * \ null - const(wildcard) - const(ix)
+ */
+ o->op_flags |= OPf_SPECIAL;
op_append_elem(OP_GLOB, o,
newSVOP(OP_CONST, 0, newSViv(PL_glob_index++)));
- o->op_type = OP_LIST;
- o->op_ppaddr = PL_ppaddr[OP_LIST];
- cLISTOPo->op_first->op_type = OP_PUSHMARK;
- cLISTOPo->op_first->op_ppaddr = PL_ppaddr[OP_PUSHMARK];
- cLISTOPo->op_first->op_targ = 0;
+ o = newLISTOP(OP_LIST, 0, o, NULL);
o = newUNOP(OP_ENTERSUB, OPf_STACKED,
op_append_elem(OP_LIST, o,
scalar(newUNOP(OP_RV2CV, 0,
newGVOP(OP_GV, 0, gv)))));
o = newUNOP(OP_NULL, 0, ck_subr(o));
- o->op_targ = OP_GLOB; /* hint at what it used to be */
+ o->op_targ = OP_GLOB; /* hint at what it used to be: eg in newWHILEOP */
return o;
}
gv = newGVgen("main");