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
Nick Ing-Simmons
February 1, 2003 04:52
Re: Smoke [5.9.0] 18609 FAIL(F) MSWin32 5.1 (x86/1 cpu)
Message ID:
Enache Adrian <> writes:
>The test also fails on Linux when setting PERLIO=:crlf , and
>here I positively know that it isn't my patch fault ( When
>the file is a pipe - as at t/run/switches.t:60 , it just does
>things the old way ).
>However I don't have access to a Window system.
>Could try please try this (it completely disables my hack)
>and see if it makes any difference on Windows ?

I already said that the fstat() trick was flawed when PerlIO layers
are involved - it would have been cool for perl5.6 but now it is 
just going to get in the way - it at least needs changing so that 
in SNARF mode once you have read st_size octets you re-try and see if
there are anymore. Consider a layer which does something like 
MIME encode what is being read - you may be gets-ing far more than 
was on disk.

It is also not clear that the st.st_size != 0 test is sufficent - 
pipes, sockets, FIFOs might (on some systems) have finite size.
You need explcit test for a regular file.

As the SNARF (rslen == 0) case is already optimized to do Copy() 
of all available data that fits all you really need to do for that case 
is an SvGROW(sv) so there is room. 

So if you replace the goto read_record
      SvGROW(sv, (STRLEN) (recsize + append+1));

you should get best of both worlds. 

The only draw back to that scheme is if data read is a lot smaller
than what is on disk you have malloc-ed memory you are not using
- which I think we can live with.

The attached patch (which creates //depot/perlio/sv.c@18612) implements 
all the above suggestions, and also avoids the "short buffered" case 
when rslen == 0 (which should now be rare).

>--- /arc/perl-current/sv.c	2003-01-30 11:15:10.000000000 +0200
>+++ sv.c	2003-02-01 07:05:42.000000000 +0200
>@@ -6173,10 +6173,12 @@
> 	rslen = 1;
>     }
>     else if (RsSNARF(PL_rs)) {
>+	/*
> 	Stat_t st;
> 	if (!PerlLIO_fstat(PerlIO_fileno(fp), &st) && st.st_size
> 		&& (recsize = st.st_size - PerlIO_tell(fp)))
> 	    goto read_record;
>+	 */
> 	rsptr = NULL;
> 	rslen = 0;
>     }
>Thanks & Regards
Nick Ing-Simmons

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About