develooper Front page | perl.perl5.porters | Postings from March 2011

Re: serious PerlIO trouble :(

Thread Previous
From:
H.Merijn Brand
Date:
March 9, 2011 09:42
Subject:
Re: serious PerlIO trouble :(
Message ID:
20110309184129.1f4e0361@pc09.procura.nl
On Wed, 9 Mar 2011 16:53:59 +0000, Nicholas Clark <nick@ccl4.org> wrote:

> On Wed, Mar 09, 2011 at 05:49:47PM +0100, H.Merijn Brand wrote:
> > On Wed, 9 Mar 2011 09:50:00 +0100, "H.Merijn Brand"
> > <h.m.brand@xs4all.nl> wrote:
> > 
> > > See also RT#66474 - https://rt.cpan.org/Ticket/Display.html?id=66474
> > > 
> > > I'll just post the results here first. I'll have to start digging later
> > > Test script and data attached
> > 
> > Ignore the seriousness. There was a conflict in $PERL5LIB.
> 
> That would explain why I couldn't replicate it.
> 
> Florian Ragwitz and I hope to have that sort of thing detected (probably as a
> fatal error - I can't see how to recover from it) post 5.14.0

The problem still exists

OK:

open my $fh, "<:encoding(UTF-16) :crlf", $file;
my $r = $csv->getline ($fh);

NOT OK:

use open (IN => ":encoding(UTF-16) :crlf");
@ARGV = ($file);
my $r = $csv->getline (*ARGV);

EXECUTED XS CODE:

static int  io_handle_loaded = 0;
static SV  *m_getline, *m_print;

    {	STRLEN		result, rslen;
	const char	*rs = NULL;

	dSP;

	require_IO_Handle;

	csv->eol_pos = -1;
	if (csv->eolx || csv->eol_is_cr) {
	    rs = SvPOK (PL_rs) || SvPOKp (PL_rs) ? SvPV_const (PL_rs, rslen) : NULL;
	    sv_setpvn (PL_rs, (char *)csv->eol, csv->eol_len);
	    }
	PUSHMARK (sp);
	EXTEND (sp, 1);
	PUSHs (src);
	PUTBACK;
	result = call_sv (m_getline, G_SCALAR | G_METHOD);
	SPAGAIN;
	csv->tmp = result ? POPs : NULL;
	if (csv->eolx || csv->eol_is_cr) {
	    if (rs)
		sv_setpvn (PL_rs, rs, rslen);
	    else
		SvPOK_off (PL_rs);
	    }
	PUTBACK;
#if MAINT_DEBUG > 4
	fprintf (stderr, "getline () returned:\n");
	sv_dump (csv->tmp);
#endif
	}

BOOT:
    m_getline = newSVpvs ("getline");
    m_print   = newSVpvs ("print");

-- 
H.Merijn Brand  http://tux.nl      Perl Monger  http://amsterdam.pm.org/
using 5.00307 through 5.12 and porting perl5.13.x on HP-UX 10.20, 11.00,
11.11, 11.23 and 11.31, OpenSuSE 10.1, 11.0 .. 11.3 and AIX 5.2 and 5.3.
http://mirrors.develooper.com/hpux/           http://www.test-smoke.org/
http://qa.perl.org      http://www.goldmark.org/jeff/stupid-disclaimers/

Thread Previous


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