summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorYitzchak Scott-Thoennes <sthoenna@efn.org>2002-03-04 08:24:32 -0800
committerJarkko Hietaniemi <jhi@iki.fi>2002-03-06 00:34:32 +0000
commit4e3399f9b267135d193509ba5240514af04e9fec (patch)
treee1cbf712891072ead87a2bc38d7f8dcdfc112774 /pp_ctl.c
parentfa09c185cf93a599dc0290b9ee4ba0149df70363 (diff)
downloadperl-4e3399f9b267135d193509ba5240514af04e9fec.tar.gz
Re: [PATCH] Re: [ID 20000922.001] Implicit comparison to $. not performed before filehandle read
Message-ID: <ABBh8gzkgezX092yn@efn.org> p4raw-id: //depot/perl@15054
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index eb1394950f..81a96de1c4 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -896,13 +896,16 @@ PP(pp_flip)
else {
dTOPss;
SV *targ = PAD_SV(PL_op->op_targ);
- int flip;
+ int flip = 0;
if (PL_op->op_private & OPpFLIP_LINENUM) {
- struct io *gp_io;
- flip = PL_last_in_gv
- && (gp_io = GvIO(PL_last_in_gv))
- && SvIV(sv) == (IV)IoLINES(gp_io);
+ if (GvIO(PL_last_in_gv)) {
+ flip = SvIV(sv) == (IV)IoLINES(GvIOp(PL_last_in_gv));
+ }
+ else {
+ GV *gv = gv_fetchpv(".", TRUE, SVt_PV);
+ if (gv && GvSV(gv)) flip = SvIV(sv) == SvIV(GvSV(gv));
+ }
} else {
flip = SvTRUE(sv);
}
@@ -980,11 +983,23 @@ PP(pp_flop)
else {
dTOPss;
SV *targ = PAD_SV(cUNOP->op_first->op_targ);
+ int flop = 0;
sv_inc(targ);
- if ((PL_op->op_private & OPpFLIP_LINENUM)
- ? (GvIO(PL_last_in_gv)
- && SvIV(sv) == (IV)IoLINES(GvIOp(PL_last_in_gv)))
- : SvTRUE(sv) ) {
+
+ if (PL_op->op_private & OPpFLIP_LINENUM) {
+ if (GvIO(PL_last_in_gv)) {
+ flop = SvIV(sv) == (IV)IoLINES(GvIOp(PL_last_in_gv));
+ }
+ else {
+ GV *gv = gv_fetchpv(".", TRUE, SVt_PV);
+ if (gv && GvSV(gv)) flop = SvIV(sv) == SvIV(GvSV(gv));
+ }
+ }
+ else {
+ flop = SvTRUE(sv);
+ }
+
+ if (flop) {
sv_setiv(PAD_SV(((UNOP*)cUNOP->op_first)->op_first->op_targ), 0);
sv_catpv(targ, "E0");
}