From: Benjamin Sugars Date: Tue, 1 May 2001 14:58:24 +0000 (-0400) Subject: Multiple consecutive writes on PerlIO::Scalar X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=773aa8252ebd1aaabb7a2a381cdf80a51028c270;p=p5sagit%2Fp5-mst-13.2.git Multiple consecutive writes on PerlIO::Scalar Message-ID: p4raw-id: //depot/perl@9931 --- diff --git a/ext/PerlIO/Scalar/Scalar.xs b/ext/PerlIO/Scalar/Scalar.xs index 8674615..1d12adf 100644 --- a/ext/PerlIO/Scalar/Scalar.xs +++ b/ext/PerlIO/Scalar/Scalar.xs @@ -108,7 +108,7 @@ PerlIOScalar_unread(PerlIO *f, const void *vbuf, Size_t count) dTHX; PerlIOScalar *s = PerlIOSelf(f,PerlIOScalar); char *dst = SvGROW(s->var,s->posn+count); - Move(vbuf,dst,count,char); + Move(vbuf,dst+s->posn,count,char); s->posn += count; SvCUR_set(s->var,s->posn); SvPOK_on(s->var); diff --git a/t/lib/io_scalar.t b/t/lib/io_scalar.t index 3679550..83716c6 100644 --- a/t/lib/io_scalar.t +++ b/t/lib/io_scalar.t @@ -10,7 +10,7 @@ BEGIN { } $| = 1; -print "1..9\n"; +print "1..10\n"; my $fh; my $var = "ok 2\n"; @@ -32,4 +32,10 @@ print "not " if eof($fh); print "ok 8\n"; print "not " unless <$fh> eq "foo\n"; print "ok 9\n"; - +# Test multiple consecutive writes to $var +$var = ""; +seek($fh, 0, 0); +print $fh "Fred and Wilma "; +print $fh "Flintstone"; +print "not " unless $var eq "Fred and Wilma Flintstone"; +print "ok 10\n";