summaryrefslogtreecommitdiff
path: root/doop.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2001-12-07 17:06:56 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-12-07 17:27:02 +0000
commit991e6d419e6cb68835dda77416b60c341a13a26e (patch)
tree5e229781d7fcc38f738c30d7991860378bcb36cb /doop.c
parent962a6f0a381b8fd2149165ea73c61d00dc48fab9 (diff)
downloadperl-991e6d419e6cb68835dda77416b60c341a13a26e.tar.gz
Re: [PATCH] chom?p needs to remove read only fakery
Message-ID: <20011207170656.G21702@plum.flirble.org> p4raw-id: //depot/perl@13521
Diffstat (limited to 'doop.c')
-rw-r--r--doop.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/doop.c b/doop.c
index bc772018bb..9f0fa6466a 100644
--- a/doop.c
+++ b/doop.c
@@ -950,8 +950,14 @@ Perl_do_chop(pTHX_ register SV *astr, register SV *sv)
do_chop(astr,hv_iterval(hv,entry));
return;
}
- else if (SvREADONLY(sv))
- Perl_croak(aTHX_ PL_no_modify);
+ else if (SvREADONLY(sv)) {
+ if (SvFAKE(sv)) {
+ /* SV is copy-on-write */
+ sv_force_normal_flags(sv, 0);
+ }
+ if (SvREADONLY(sv))
+ Perl_croak(aTHX_ PL_no_modify);
+ }
s = SvPV(sv, len);
if (len && !SvPOK(sv))
s = SvPV_force(sv, len);
@@ -1020,8 +1026,14 @@ Perl_do_chomp(pTHX_ register SV *sv)
count += do_chomp(hv_iterval(hv,entry));
return count;
}
- else if (SvREADONLY(sv))
- Perl_croak(aTHX_ PL_no_modify);
+ else if (SvREADONLY(sv)) {
+ if (SvFAKE(sv)) {
+ /* SV is copy-on-write */
+ sv_force_normal_flags(sv, 0);
+ }
+ if (SvREADONLY(sv))
+ Perl_croak(aTHX_ PL_no_modify);
+ }
s = SvPV(sv, len);
if (s && len) {
s += --len;