summaryrefslogtreecommitdiff
path: root/pp_hot.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1999-02-14 05:51:56 +0000
committerGurusamy Sarathy <gsar@cpan.org>1999-02-14 05:51:56 +0000
commitfbad3eb55c1f8c84d1dfd0e484ecddeffc891e79 (patch)
treef3886be033e03113de9177f18cdf413345741e1c /pp_hot.c
parent428f79ef10ad4e14667125f22397bceac3e2c65e (diff)
downloadperl-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.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/pp_hot.c b/pp_hot.c
index 27af29d071..b1bf270866 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -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);