summaryrefslogtreecommitdiff
path: root/ext/PerlIO
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-05-23 07:33:52 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-05-23 07:33:52 +0000
commit5735c168c62d0fa5cf526f0c7e7c97b069acef8f (patch)
tree807b7f132eed16da55e044932192ceec77e4ab23 /ext/PerlIO
parent102d3b8a62934b6c124acd38fad140f94f743df1 (diff)
downloadperl-5735c168c62d0fa5cf526f0c7e7c97b069acef8f.tar.gz
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
Diffstat (limited to 'ext/PerlIO')
-rw-r--r--ext/PerlIO/scalar/scalar.pm2
-rw-r--r--ext/PerlIO/scalar/scalar.xs3
-rw-r--r--ext/PerlIO/t/scalar.t16
3 files changed, 17 insertions, 4 deletions
diff --git a/ext/PerlIO/scalar/scalar.pm b/ext/PerlIO/scalar/scalar.pm
index 7eb936eacb..43685bf31d 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 55a5fd8057..160deb2191 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 818aab575f..8b43acb17a 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 '', <MEM>;
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 = <F>;
+ close F;
+ print $ln eq $s ? "ok 27\n" : "not ok 27\n";
+}