From: Rafael Garcia-Suarez Date: Mon, 23 May 2005 07:33:52 +0000 (+0000) Subject: Fix [perl #35929] : PerlIO::scalar didn't understand $/ = "" X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5735c168c62d0fa5cf526f0c7e7c97b069acef8f;p=p5sagit%2Fp5-mst-13.2.git Fix [perl #35929] : PerlIO::scalar didn't understand $/ = "" because PerlIOScalar_unread was broken. Bump version number of PerlIO::scalar to 0.04. p4raw-id: //depot/perl@24543 --- diff --git a/ext/PerlIO/scalar/scalar.pm b/ext/PerlIO/scalar/scalar.pm index 7eb936e..43685bf 100644 --- a/ext/PerlIO/scalar/scalar.pm +++ b/ext/PerlIO/scalar/scalar.pm @@ -1,5 +1,5 @@ package PerlIO::scalar; -our $VERSION = '0.03'; +our $VERSION = '0.04'; use XSLoader (); XSLoader::load 'PerlIO::scalar'; 1; diff --git a/ext/PerlIO/scalar/scalar.xs b/ext/PerlIO/scalar/scalar.xs index 55a5fd8..160deb2 100644 --- a/ext/PerlIO/scalar/scalar.xs +++ b/ext/PerlIO/scalar/scalar.xs @@ -106,9 +106,8 @@ PerlIOScalar_unread(pTHX_ PerlIO * f, const void *vbuf, Size_t count) { PerlIOScalar *s = PerlIOSelf(f, PerlIOScalar); char *dst = SvGROW(s->var, (STRLEN)s->posn + count); + s->posn -= count; Move(vbuf, dst + s->posn, count, char); - s->posn += count; - SvCUR_set(s->var, (STRLEN)s->posn); SvPOK_on(s->var); return count; } diff --git a/ext/PerlIO/t/scalar.t b/ext/PerlIO/t/scalar.t index 818aab5..8b43acb 100644 --- a/ext/PerlIO/t/scalar.t +++ b/ext/PerlIO/t/scalar.t @@ -15,7 +15,7 @@ BEGIN { } $| = 1; -print "1..26\n"; +print "1..27\n"; my $fh; my $var = "ok 2\n"; @@ -149,3 +149,17 @@ $data = undef; open(MEM, '<', \$data) or die "Fail: $!\n"; my $x = join '', ; print $x eq '' ? "ok 26\n" : "not ok 26\n"; + +{ + # [perl #35929] verify that works with $/ (i.e. test PerlIOScalar_unread) + my $s = <<'EOF'; +line A +line B +a third line +EOF + open(F, '<', \$s) or die "Could not open string as a file"; + local $/ = ""; + my $ln = ; + close F; + print $ln eq $s ? "ok 27\n" : "not ok 27\n"; +}