diff options
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 25 |
1 files changed, 19 insertions, 6 deletions
@@ -1388,8 +1388,7 @@ S_scan_const(pTHX_ char *start) "Unrecognized escape \\%c passed through", *s); /* default action is to copy the quoted character */ - *d++ = *s++; - continue; + goto default_action; } /* \132 indicates an octal constant */ @@ -1479,6 +1478,13 @@ S_scan_const(pTHX_ char *start) if (has_utf8 || uv > 255) { d = (char*)uv_to_utf8((U8*)d, uv); has_utf8 = TRUE; + if (PL_lex_inwhat == OP_TRANS && + PL_sublex_info.sub_op) { + PL_sublex_info.sub_op->op_private |= + (PL_lex_repl ? OPpTRANS_FROM_UTF + : OPpTRANS_TO_UTF); + utf = TRUE; + } } else { *d++ = (char)uv; @@ -1506,6 +1512,8 @@ S_scan_const(pTHX_ char *start) res = newSVpvn(s + 1, e - s - 1); res = new_constant( Nullch, 0, "charnames", res, Nullsv, "\\N{...}" ); + if (has_utf8) + sv_utf8_upgrade(res); str = SvPV(res,len); if (!has_utf8 && SvUTF8(res)) { char *ostart = SvPVX(sv); @@ -1588,8 +1596,7 @@ S_scan_const(pTHX_ char *start) continue; } /* end if (backslash) */ - /* (now in tr/// code again) */ - + default_action: if (UTF8_IS_CONTINUED(*s) && (this_utf8 || has_utf8)) { STRLEN len = (STRLEN) -1; UV uv; @@ -1608,10 +1615,15 @@ S_scan_const(pTHX_ char *start) *d++ = *s++; } has_utf8 = TRUE; + if (PL_lex_inwhat == OP_TRANS && PL_sublex_info.sub_op) { + PL_sublex_info.sub_op->op_private |= + (PL_lex_repl ? OPpTRANS_FROM_UTF : OPpTRANS_TO_UTF); + utf = TRUE; + } continue; } - *d++ = *s++; + *d++ = *s++; } /* while loop to process each character */ /* terminate the string and set up the sv */ @@ -4742,7 +4754,8 @@ Perl_yylex(pTHX) case KEY_qq: case KEY_qu: s = scan_str(s,FALSE,FALSE); - if (tmp == KEY_qu && is_utf8_string((U8*)s, SvCUR(PL_lex_stuff))) + if (tmp == KEY_qu && + is_utf8_string((U8*)SvPVX(PL_lex_stuff), SvCUR(PL_lex_stuff))) SvUTF8_on(PL_lex_stuff); if (!s) missingterm((char*)0); |