summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorDan Kogai <dankogai@dan.co.jp>2002-10-22 02:36:02 +0900
committerhv <hv@crypt.org>2002-10-24 23:36:48 +0000
commitd0063567ae6829f18fa94be9ac4f0b3986e32f5a (patch)
tree63f390c01e731f401d0f2b5085864df3a6757bc4 /regcomp.c
parentab3374e4b7f0adca0bcf6e7b71aaacbfd7df7b07 (diff)
downloadperl-d0063567ae6829f18fa94be9ac4f0b3986e32f5a.tar.gz
The Inaba patch for tr/// vs. use encoding
Message-Id: <218B4434-E4D0-11D6-A668-0003939A104C@dan.co.jp> p4raw-id: //depot/perl@18058
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/regcomp.c b/regcomp.c
index c8b5d7634b..a4c2d43f6a 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -3304,25 +3304,27 @@ tryagain:
/* If the encoding pragma is in effect recode the text of
* any EXACT-kind nodes. */
if (PL_encoding && PL_regkind[(U8)OP(ret)] == EXACT) {
- STRLEN oldlen = STR_LEN(ret);
- SV *sv = sv_2mortal(newSVpvn(STRING(ret), oldlen));
-
- if (RExC_utf8)
- SvUTF8_on(sv);
- if (sv_utf8_downgrade(sv, TRUE)) {
- char *s = sv_recode_to_utf8(sv, PL_encoding);
- STRLEN newlen = SvCUR(sv);
-
- if (!SIZE_ONLY) {
- DEBUG_r(PerlIO_printf(Perl_debug_log, "recode %*s to %*s\n",
- (int)oldlen, STRING(ret),
- (int)newlen, s));
- Copy(s, STRING(ret), newlen, char);
- STR_LEN(ret) += newlen - oldlen;
- RExC_emit += STR_SZ(newlen) - STR_SZ(oldlen);
- } else
- RExC_size += STR_SZ(newlen) - STR_SZ(oldlen);
- }
+ STRLEN oldlen = STR_LEN(ret);
+ SV *sv = sv_2mortal(newSVpvn(STRING(ret), oldlen));
+
+ if (RExC_utf8)
+ SvUTF8_on(sv);
+ if (sv_utf8_downgrade(sv, TRUE)) {
+ char *s = sv_recode_to_utf8(sv, PL_encoding);
+ STRLEN newlen = SvCUR(sv);
+
+ if (SvUTF8(sv))
+ RExC_utf8 = 1;
+ if (!SIZE_ONLY) {
+ DEBUG_r(PerlIO_printf(Perl_debug_log, "recode %*s to %*s\n",
+ (int)oldlen, STRING(ret),
+ (int)newlen, s));
+ Copy(s, STRING(ret), newlen, char);
+ STR_LEN(ret) += newlen - oldlen;
+ RExC_emit += STR_SZ(newlen) - STR_SZ(oldlen);
+ } else
+ RExC_size += STR_SZ(newlen) - STR_SZ(oldlen);
+ }
}
return(ret);