diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1999-12-04 21:11:51 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1999-12-04 21:11:51 +0000 |
commit | db7ec62399075c965a182629c9ca8ed4044fc594 (patch) | |
tree | 485f3d81bac31069fc5c30b9994e3ab83c43bad0 /pp_sys.c | |
parent | b89fed5ff1fc43a68f98ebc06fd23230eb6697a8 (diff) | |
download | perl-db7ec62399075c965a182629c9ca8ed4044fc594.tar.gz |
make eof() open ARGV if it isn't open already; also fixes bug
where eof() would operate on any last-read filehandle, not
just ARGV
p4raw-id: //depot/perl@4642
Diffstat (limited to 'pp_sys.c')
-rw-r--r-- | pp_sys.c | 24 |
1 files changed, 21 insertions, 3 deletions
@@ -1703,10 +1703,28 @@ PP(pp_eof) GV *gv; MAGIC *mg; - if (MAXARG <= 0) - gv = PL_last_in_gv; + if (MAXARG <= 0) { + if (PL_op->op_flags & OPf_SPECIAL) { /* eof() */ + IO *io; + gv = PL_last_in_gv = PL_argvgv; + io = GvIO(gv); + if (io && !IoIFP(io)) { + if ((IoFLAGS(io) & IOf_START) && av_len(GvAVn(gv)) < 0) { + IoLINES(io) = 0; + IoFLAGS(io) &= ~IOf_START; + do_open(gv, "-", 1, FALSE, O_RDONLY, 0, Nullfp); + sv_setpvn(GvSV(gv), "-", 1); + SvSETMAGIC(GvSV(gv)); + } + else if (!nextargv(gv)) + RETPUSHYES; + } + } + else + gv = PL_last_in_gv; /* eof */ + } else - gv = PL_last_in_gv = (GV*)POPs; + gv = PL_last_in_gv = (GV*)POPs; /* eof(FH) */ if (gv && (mg = SvTIED_mg((SV*)gv, 'q'))) { PUSHMARK(SP); |