diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1999-02-14 05:51:56 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1999-02-14 05:51:56 +0000 |
commit | fbad3eb55c1f8c84d1dfd0e484ecddeffc891e79 (patch) | |
tree | f3886be033e03113de9177f18cdf413345741e1c /pp_hot.c | |
parent | 428f79ef10ad4e14667125f22397bceac3e2c65e (diff) | |
download | perl-fbad3eb55c1f8c84d1dfd0e484ecddeffc891e79.tar.gz |
slurping an empty file should return '' rather than undef, with
commensurate effects on ARGV processing
p4raw-id: //depot/perl@2910
Diffstat (limited to 'pp_hot.c')
-rw-r--r-- | pp_hot.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -1297,8 +1297,18 @@ do_readline(void) sv = sv_2mortal(NEWSV(57, 80)); offset = 0; } + +/* flip-flop EOF state for a snarfed empty file */ +#define SNARF_EOF(gimme,rs,io,sv) \ + ((gimme != G_SCALAR || SvCUR(sv) \ + || (IoFLAGS(io) & IOf_NOLINE) || IoLINES(io) || !RsSNARF(rs)) \ + ? ((IoFLAGS(io) &= ~IOf_NOLINE), TRUE) \ + : ((IoFLAGS(io) |= IOf_NOLINE), FALSE)) + for (;;) { - if (!sv_gets(sv, fp, offset)) { + if (!sv_gets(sv, fp, offset) + && (type == OP_GLOB || SNARF_EOF(gimme, PL_rs, io, sv))) + { PerlIO_clearerr(fp); if (IoFLAGS(io) & IOf_ARGV) { fp = nextargv(PL_last_in_gv); |