/* doop.c
*
- * Copyright (c) 1991-2001, Larry Wall
+ * Copyright (c) 1991-2002, Larry Wall
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
char *pat = SvPV(*sarg, patlen);
bool do_taint = FALSE;
+ SvUTF8_off(sv);
+ if (DO_UTF8(*sarg))
+ SvUTF8_on(sv);
sv_vsetpvfn(sv, pat, patlen, Null(va_list*), sarg + 1, len - 1, &do_taint);
SvSETMAGIC(sv);
if (do_taint)
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);
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;