summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-06-04 19:01:59 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-06-04 19:01:59 -0700
commit47d6f3d6640ee5a8c3c6670383171a78d34abbaa (patch)
treeaf85bc9aa5a1c154270774606d2487d76b2ac91e /ext
parent15367045db6522514a0a448ebd7e656888845a60 (diff)
downloadperl-47d6f3d6640ee5a8c3c6670383171a78d34abbaa.tar.gz
Get PerlIO::scalar to write to COWs
Diffstat (limited to 'ext')
-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..a5fab724b3 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.12';
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';
+}