develooper Front page | perl.perl5.porters | Postings from February 2003

Re: Smoke [5.9.0] 18609 FAIL(F) MSWin32 5.1 (x86/1 cpu)

Thread Previous | Thread Next
From:
Enache Adrian
Date:
February 1, 2003 06:14
Subject:
Re: Smoke [5.9.0] 18609 FAIL(F) MSWin32 5.1 (x86/1 cpu)
Message ID:
20030201130902.GA8251@ratsnest.hole
On Sat, Feb 01, 2003 at 07:24:09AM +0200, Enache Adrian wrote:
> On Sat, Feb 01, 2003 at 03:38:26AM +0100, Abe Timmerman wrote:
> > Op een sneeuwerige winterdag (Friday 31 January 2003 23:44), schreef XPFikkie:
> > 
> > Could the failing of "run/switches.t":6 have to do with:
> > 
> > 	* Change 18580: patch to speed up Perl's slurp mode
> > (It fails for all builds)
> 
> I don't think so.
> 

It is caused by my patch. This shows up the bug:

# perl -e 'print "a\nb\nc\n" | perl -0777 -pe 1
a
b
c
# export PERLIO=:crlf
# perl -e 'print "a\nb\nc\n" | perl -0777 -pe 1
a
--ate up b and c

This gets it right for me:
---------------------------------------------------------
--- /arc/perl-current/sv.c	2003-01-30 11:15:10.000000000 +0200
+++ perl-current/sv.c	2003-02-01 14:40:09.000000000 +0200
@@ -6174,7 +6174,7 @@
     }
     else if (RsSNARF(PL_rs)) {
 	Stat_t st;
-	if (!PerlLIO_fstat(PerlIO_fileno(fp), &st) && st.st_size
+	if (!PerlLIO_fstat(PerlIO_fileno(fp), &st) && S_ISREG(st.st_mode)
 		&& (recsize = st.st_size - PerlIO_tell(fp)))
 	    goto read_record;
 	rsptr = NULL;
---------------------------------------------------------

I stupidly assumed that fstat(2) always sets .st_size to zero on
pipes, terminals, etc. This isn't at all the case.

This isn't deterministic either.
The above test may even work when the machine is under load
and/or the "a\n .." string is a longer :-(

As for regular files, the only harm when doing cr/lf translations
is wasting bytes (~140 / 4096 ) at the end of the buffer.
The current length (SvCUR) of the variable is set from the return
value of PerlIO_read().

Regards
Adi

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About