From: Benjamin Sugars Date: Tue, 1 May 2001 16:32:03 +0000 (-0400) Subject: Allow appending on a PerlIO::Scalar X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c350b88c1e6dfa56f828338a652bb26eb43c2de7;p=p5sagit%2Fp5-mst-13.2.git Allow appending on a PerlIO::Scalar Message-ID: p4raw-id: //depot/perl@9939 --- diff --git a/ext/PerlIO/Scalar/Scalar.xs b/ext/PerlIO/Scalar/Scalar.xs index 1d12adf..f22193e 100644 --- a/ext/PerlIO/Scalar/Scalar.xs +++ b/ext/PerlIO/Scalar/Scalar.xs @@ -38,7 +38,10 @@ PerlIOScalar_pushed(PerlIO *f, const char *mode, SV *arg) s->var = newSVpvn("",0); } sv_upgrade(s->var,SVt_PV); - s->posn = 0; + if (strnEQ(mode,"a",1)) + s->posn = SvCUR(SvRV(arg)); + else + s->posn = 0; return PerlIOBase_pushed(f,mode,Nullsv); } diff --git a/t/lib/io_scalar.t b/t/lib/io_scalar.t index 83716c6..928355e 100644 --- a/t/lib/io_scalar.t +++ b/t/lib/io_scalar.t @@ -10,7 +10,7 @@ BEGIN { } $| = 1; -print "1..10\n"; +print "1..11\n"; my $fh; my $var = "ok 2\n"; @@ -39,3 +39,10 @@ print $fh "Fred and Wilma "; print $fh "Flintstone"; print "not " unless $var eq "Fred and Wilma Flintstone"; print "ok 10\n"; +# Test appending +close $fh; +$var = "Fred and Wilma "; +open $fh, ">>", \$var; +print $fh "Flintstone"; +print "not " unless $var eq "Fred and Wilma Flintstone"; +print "ok 11\n";