Front page | perl.perl5.porters |
Postings from November 2003
Re: bug or a feature?
Thread Previous
|
Thread Next
From:
Torsten Foertsch
Date:
November 21, 2003 03:24
Subject:
Re: bug or a feature?
Message ID:
200311211221.33255.torsten.foertsch@gmx.net
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I have tracked it down in 5.8.2 to the following lines in pp_hot.c
(Perl_do_readline()). Maybe it rings some bells:
1569 /* delay EOF state for a snarfed empty file */
1570 #define SNARF_EOF(gimme,rs,io,sv) \
1571 (gimme != G_SCALAR || SvCUR(sv)
\
1572 || (IoFLAGS(io) & IOf_NOLINE) || !RsSNARF(rs))
1573
1574 for (;;) {
1575 PUTBACK;
1576 if (!sv_gets(sv, fp, offset)
1577 && (type == OP_GLOB || SNARF_EOF(gimme, PL_rs, io, sv)))
1578 {
1579 PerlIO_clearerr(fp);
1580 if (IoFLAGS(io) & IOf_ARGV) {
1581 fp = nextargv(PL_last_in_gv);
1582 if (fp)
1583 continue;
1584 (void)do_close(PL_last_in_gv, FALSE);
1585 }
1586 else if (type == OP_GLOB) {
1587 if (!do_close(PL_last_in_gv, FALSE) &&
ckWARN(WARN_GLOB) ) {
1588 Perl_warner(aTHX_ packWARN(WARN_GLOB),
1589 "glob failed (child exited with status
%d%s)" ,
1590 (int)(STATUS_CURRENT >> 8),
1591 (STATUS_CURRENT & 0x80) ? ", core dumped" :
" ");
1592 }
1593 }
1594 if (gimme == G_SCALAR) {
1595 if (type != OP_RCATLINE) {
1596 SV_CHECK_THINKFIRST(TARG);
1597 (void)SvOK_off(TARG);
1598 }
1599 SPAGAIN;
1600 PUSHTARG;
1601 }
1602 MAYBE_TAINT_LINE(io, sv);
1603 RETURN;
In both cases sv_gets() at line 1576 returns false (EOF). But with $/="\n" it
enters the if-block at line 1579 goes through lines 1596 and 1597 and returns
in line 1603. With $/=undef the if-block at line 1579 is not entered.
BTW, what does RsSNARF (or simply snarf) mean? I have looked it up at
http://dict.leo.org with no result.
Torsten
On Wednesday 19 November 2003 07:27, Andreas J Koenig wrote:
> >>>>> On Sat, 8 Nov 2003 14:44:34 +0000, Nicholas Clark <nick@ccl4.org>
> >>>>> said:
> >
> > So something changed as far back as 5.005
>
> ----Program----
> undef $/;open F, "/" and defined(scalar <F>) and print "ok\n"; print "$!\n"
>
> ----Output of ...hTONuT/perl-5.005_54@2909/bin/perl----
> Is a directory
>
> ----EOF ($?='0')----
> ----Output of ...GvDsG0/perl-5.005_54@2910/bin/perl----
> ok
> Is a directory
>
> ----EOF ($?='0')----
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE/vfU9wicyCTir8T4RAuS4AJ9KJ/RsEGZwGJX0TbD26SiVczmFPwCgoCcw
mHo/4Ytch7m1xehIDAST5x4=
=dojR
-----END PGP SIGNATURE-----
Thread Previous
|
Thread Next