in reply to Re: Configurable IO buffersize?
in thread Configurable IO buffersize?

Thank you kind Sir.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^3: Configurable IO buffersize?
by Anonymous Monk on Aug 02, 2011 at 11:15 UTC
    Ok, now I've tested it, it works, the concept is proved, but there are some issues, like using :raw causes PerlIO to croak -- probably something about XS I'm doing wrong :)

    I used ->getbufsiz to test if ->setbuf had effect, because Devel::Peek/Data::Peek was no help with handles, and trying to parse perliol.h with Convert::Binary::C wasn't happening

    This definitely needs official support

    Cheers

      Some more testing, none of these behave like :raw, they seem to "work"
      Fudge( __FILE__ , ':raw:perlio:encoding(UTF-16LE):crlf', 6 ); Fudge( __FILE__ , ':raw:perlio:encoding(UTF-16LE):utf8', 6 ); Fudge( __FILE__ , ':raw:perlio', 7666 ); Fudge( __FILE__ , ':raw:win32', 6 ); Fudge( __FILE__ , ':win32', 6 );

      Though now its obvious that the :raw issue is probably pointer arithmetic related (and/or related to Chicanery Needed to Handle Unicode Text on Microsoft Windows)

      It remains, that setting a lower length than previous buffer length, doesn't change the length, only setting a higher one changes it

      I reiterate, this definitely needs official support :)

      here are some issues, like using :raw causes PerlIO to croak

      Doesn't :raw disable buffering?


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
Re^3: Configurable IO buffersize?
by Anonymous Monk on Aug 02, 2011 at 02:50 UTC
    Bah, typo (f not handle), still untested :)
    void setbuf(handle, ...) OutputStream handle CODE: if (handle) #ifdef PERLIO_IS_STDIO { char *buf = items == 2 && SvPOK(ST(1)) ? sv_grow(ST(1), BUFSIZ) : 0; setbuf(handle, buf); } #else { /* not_here("IO::Handle::setbuf"); */ PerlIOBuf * const b = PerlIOSelf( handle, PerlIOBuf); PERL_UNUSED_CONTEXT; if(items == 2 && SvPOK(ST(1)) ) { b->bufsiz = SvLEN(ST(1)); Newxz(b->buf, b->bufsiz , STDCHAR); } } #endif