develooper Front page | perl.perl5.porters | Postings from September 2010

XS question: local $/ = $eol;

Thread Next
From:
H.Merijn Brand
Date:
September 22, 2010 23:45
Subject:
XS question: local $/ = $eol;
Message ID:
20100923084458.0a169d89@pc09.procura.nl
To support "weird" eol sequences in Text::CSV_XS, I need the XS variant
of

  my $line = do { local $/ = $eol; scalar <$fh>; }

I know *when* I need it, but not (yet) how to do it:

    {   int     result;

        dSP;

        require_IO_Handle;

        if (csv->eolx) {
            /* local $/ = csv->eol */
            }
        csv->eol_pos = -1;
        PUSHMARK (sp);
        EXTEND (sp, 1);
        PUSHs (src);
        PUTBACK;
        result = call_sv (m_getline, G_SCALAR | G_METHOD);
        SPAGAIN;
        csv->tmp = result ? POPs : NULL;
        PUTBACK;
        }


with this support code:

#define require_IO_Handle                               \
    unless (io_handle_loaded) {                         \
        ENTER;                                          \
        load_module (PERL_LOADMOD_NOIMPORT,             \
            newSVpvs ("IO::Handle"), NULL, NULL, NULL); \
        LEAVE;                                          \
        io_handle_loaded = 1;                           \
        }

static SV  *m_getline, *m_print;

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


Can someone hint me towards the correct implementation?

-- 
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.3, 11.0, and 11.1, 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 Next


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