summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-12-23 00:57:10 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-12-23 00:57:10 +0000
commit22c54be3d94cfb3f4b06aaa5a8a1910193e54a07 (patch)
tree611d086249eebc9551ef28434416bbcb46ccac59 /regcomp.c
parent02fc2eeebe0e138f51e361717ee5d2258b2c13d0 (diff)
downloadperl-22c54be3d94cfb3f4b06aaa5a8a1910193e54a07.tar.gz
Fix encoding pragma.
p4raw-id: //depot/perl@13859
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/regcomp.c b/regcomp.c
index 4cfd3dbbdb..2e0943ea6e 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -3131,7 +3131,7 @@ tryagain:
if (RExC_flags16 & PMf_EXTENDED)
p = regwhite(p, RExC_end);
if (UTF && FOLD) {
- toLOWER_uni(ender, tmpbuf, &ulen);
+ toFOLD_uni(ender, tmpbuf, &ulen);
ender = utf8_to_uvchr(tmpbuf, 0);
}
if (ISMULT2(p)) { /* Back off on ?+*. */
@@ -3180,20 +3180,26 @@ tryagain:
break;
}
- if (PL_encoding && PL_regkind[(U8)OP(ret)] == EXACT && !RExC_utf8) {
+ if (PL_encoding && PL_regkind[(U8)OP(ret)] == EXACT) {
STRLEN oldlen = STR_LEN(ret);
SV *sv = sv_2mortal(newSVpvn(STRING(ret), oldlen));
- char *s = Perl_sv_recode_to_utf8(aTHX_ 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);
- RExC_utf8 = 1;
+
+ if (RExC_utf8)
+ SvUTF8_on(sv);
+ if (sv_utf8_downgrade(sv, TRUE)) {
+ char *s = Perl_sv_recode_to_utf8(aTHX_ 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);
+ }
}
return(ret);