From c350b88c1e6dfa56f828338a652bb26eb43c2de7 Mon Sep 17 00:00:00 2001 From: Benjamin Sugars Date: Tue, 1 May 2001 12:32:03 -0400 Subject: [PATCH] Allow appending on a PerlIO::Scalar Message-ID: p4raw-id: //depot/perl@9939 --- ext/PerlIO/Scalar/Scalar.xs | 5 ++++- t/lib/io_scalar.t | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) 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"; -- 2.7.4