summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-03-18 05:15:06 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-03-18 05:15:06 +0000
commit60425c380d8403607be85706bb016ae8d577acf4 (patch)
tree08f8900d4049d68f909ca8aaeb45e172b06f495a /mg.c
parent05d340b81db0665672bf1917f71d6cb9459a3b2b (diff)
downloadperl-60425c380d8403607be85706bb016ae8d577acf4.tar.gz
NI-S' cunning idea of how to de-UTF8 the "\C-broken" submatches.
p4raw-id: //depot/perl@9193
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/mg.c b/mg.c
index eb79dc469a..931b1a1525 100644
--- a/mg.c
+++ b/mg.c
@@ -412,7 +412,9 @@ Perl_magic_len(pTHX_ SV *sv, MAGIC *mg)
char *s = rx->subbeg + s1;
char *send = rx->subbeg + t1;
- i = Perl_utf8_length(aTHX_ (U8*)s, (U8*)send);
+ i = t1 - s1;
+ if (is_utf8_string((U8*)s, i))
+ i = Perl_utf8_length(aTHX_ (U8*)s, (U8*)send);
}
if (i < 0)
Perl_croak(aTHX_ "panic: magic_len: %"IVdf, (IV)i);
@@ -630,7 +632,7 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
PL_tainted = FALSE;
}
sv_setpvn(sv, s, i);
- if (DO_UTF8(PL_reg_sv))
+ if (DO_UTF8(PL_reg_sv) && is_utf8_string((U8*)s, i))
SvUTF8_on(sv);
else
SvUTF8_off(sv);