summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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";
+}