From 594a560e9cf0abd67f85e0fb6418d0f5e49374e3 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sat, 4 Jun 2011 19:01:59 -0700 Subject: Get PerlIO::scalar to write to COWs --- ext/PerlIO-scalar/scalar.pm | 2 +- ext/PerlIO-scalar/scalar.xs | 3 ++- ext/PerlIO-scalar/t/scalar.t | 10 +++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ext/PerlIO-scalar/scalar.pm b/ext/PerlIO-scalar/scalar.pm index 45f2119d56..a6da9631cf 100644 --- a/ext/PerlIO-scalar/scalar.pm +++ b/ext/PerlIO-scalar/scalar.pm @@ -1,5 +1,5 @@ package PerlIO::scalar; -our $VERSION = '0.11'; +our $VERSION = '0.11_01'; require XSLoader; XSLoader::load(); 1; diff --git a/ext/PerlIO-scalar/scalar.xs b/ext/PerlIO-scalar/scalar.xs index b6cc5c1bb7..de9873829c 100644 --- a/ext/PerlIO-scalar/scalar.xs +++ b/ext/PerlIO-scalar/scalar.xs @@ -24,7 +24,8 @@ PerlIOScalar_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg, */ if (arg && SvOK(arg)) { if (SvROK(arg)) { - if (SvREADONLY(SvRV(arg)) && mode && *mode != 'r') { + if (SvREADONLY(SvRV(arg)) && !SvIsCOW(SvRV(arg)) + && mode && *mode != 'r') { if (ckWARN(WARN_LAYER)) Perl_warner(aTHX_ packWARN(WARN_LAYER), "%s", PL_no_modify); SETERRNO(EINVAL, SS_IVCHAN); diff --git a/ext/PerlIO-scalar/t/scalar.t b/ext/PerlIO-scalar/t/scalar.t index 1aee4b0e67..ed1ae69dbb 100644 --- a/ext/PerlIO-scalar/t/scalar.t +++ b/ext/PerlIO-scalar/t/scalar.t @@ -16,7 +16,7 @@ use Fcntl qw(SEEK_SET SEEK_CUR SEEK_END); # Not 0, 1, 2 everywhere. $| = 1; -use Test::More tests => 70; +use Test::More tests => 71; my $fh; my $var = "aaa\n"; @@ -284,3 +284,11 @@ EOF is read($strIn, my $buffer, 5), 0, 'seek beyond end end of string followed by read'; } + +# Writing to COW scalars +{ + my $bovid = __PACKAGE__; + open my $handel, ">", \$bovid; + print $handel "the COW with the crumpled horn"; + is $bovid, "the COW with the crumpled horn", 'writing to COW scalars'; +} -- cgit v1.2.1