summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-06-04 19:01:59 -0700
committerFlorian Ragwitz <rafl@debian.org>2011-09-05 13:04:36 +0200
commit594a560e9cf0abd67f85e0fb6418d0f5e49374e3 (patch)
tree2861f9839e42da26f29ad7932e86ed00e04f2953
parent03648d386e8364854d010041c04112e82fd58d26 (diff)
downloadperl-594a560e9cf0abd67f85e0fb6418d0f5e49374e3.tar.gz
Get PerlIO::scalar to write to COWs
-rw-r--r--ext/PerlIO-scalar/scalar.pm2
-rw-r--r--ext/PerlIO-scalar/scalar.xs3
-rw-r--r--ext/PerlIO-scalar/t/scalar.t10
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';
+}