Skip to content

Instantly share code, notes, and snippets.

@chansen
Created March 25, 2012 23:36
Show Gist options
  • Save chansen/2201633 to your computer and use it in GitHub Desktop.
Save chansen/2201633 to your computer and use it in GitHub Desktop.
PerlIO::scalar patch
diff --git a/ext/PerlIO-scalar/scalar.xs b/ext/PerlIO-scalar/scalar.xs
index eac682b..d324bdd 100644
--- a/ext/PerlIO-scalar/scalar.xs
+++ b/ext/PerlIO-scalar/scalar.xs
@@ -125,6 +125,18 @@ PerlIOScalar_tell(pTHX_ PerlIO * f)
return s->posn;
}
+IV
+PerlIOScalar_eof(pTHX_ PerlIO * f)
+{
+ if (PerlIOBase(f)->flags & PERLIO_F_CANREAD) {
+ PerlIOScalar *s = PerlIOSelf(f, PerlIOScalar);
+ char *p;
+ STRLEN len;
+ p = SvPV(s->var, len);
+ return len - (STRLEN)(s->posn) <= 0;
+ }
+ return 1;
+}
SSize_t
PerlIOScalar_read(pTHX_ PerlIO *f, void *vbuf, Size_t count)
@@ -343,7 +355,7 @@ PERLIO_FUNCS_DECL(PerlIO_scalar) = {
PerlIOScalar_close,
PerlIOScalar_flush,
PerlIOScalar_fill,
- PerlIOBase_eof,
+ PerlIOScalar_eof,
PerlIOBase_error,
PerlIOBase_clearerr,
PerlIOBase_setlinebuf,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment