This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
PerlIO-scalar: Fix fail to detect incomplete seqs at EOF
authorChristian Hansen <chansen@cpan.org>
Sun, 25 Mar 2012 23:23:39 +0000 (17:23 -0600)
committerKarl Williamson <khw@cpan.org>
Sun, 11 Dec 2016 14:44:21 +0000 (07:44 -0700)
ext/PerlIO-scalar/scalar.pm
ext/PerlIO-scalar/scalar.xs

index 4ed4e40..dcba127 100644 (file)
@@ -1,5 +1,5 @@
 package PerlIO::scalar;
 package PerlIO::scalar;
-our $VERSION = '0.24';
+our $VERSION = '0.25';
 require XSLoader;
 XSLoader::load();
 1;
 require XSLoader;
 XSLoader::load();
 1;
index f3dff49..dcb8283 100644 (file)
@@ -15,6 +15,19 @@ typedef struct {
     Off_t posn;
 } PerlIOScalar;
 
     Off_t posn;
 } PerlIOScalar;
 
+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;
+}
+
 static IV
 PerlIOScalar_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg,
                    PerlIO_funcs * tab)
 static IV
 PerlIOScalar_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg,
                    PerlIO_funcs * tab)
@@ -406,7 +419,7 @@ static PERLIO_FUNCS_DECL(PerlIO_scalar) = {
     PerlIOScalar_close,
     PerlIOScalar_flush,
     PerlIOScalar_fill,
     PerlIOScalar_close,
     PerlIOScalar_flush,
     PerlIOScalar_fill,
-    PerlIOBase_eof,
+    PerlIOScalar_eof,
     PerlIOBase_error,
     PerlIOBase_clearerr,
     PerlIOBase_setlinebuf,
     PerlIOBase_error,
     PerlIOBase_clearerr,
     PerlIOBase_setlinebuf,