documented to behave; still returns undef on error
p4raw-id: //depot/perl@1327
djSP; dTARGET;
GV *gv;
MAGIC *mg;
+ PerlIO *fp;
if (MAXARG <= 0)
gv = stdingv;
SvSetMagicSV_nosteal(TARG, TOPs);
RETURN;
}
- if (!gv || do_eof(gv)) /* make sure we have fp with something */
+ if (!gv || !GvIO(gv) || !(fp = IoIFP(GvIOp(gv)))) /* valid fp? */
RETPUSHUNDEF;
+
+ if (do_eof(gv)) { /* handle magic argv, if needed */
+ if (PerlIO_error(fp))
+ PUSHs(&sv_undef);
+ else
+ PUSHp("",0);
+ RETURN;
+ }
TAINT;
sv_setpv(TARG, " ");
- *SvPVX(TARG) = PerlIO_getc(IoIFP(GvIOp(gv))); /* should never be EOF */
+ *SvPVX(TARG) = PerlIO_getc(fp); /* should never be EOF */
PUSHTARG;
RETURN;
}