diff options
author | Brian Fraser <fraserbn@gmail.com> | 2011-07-06 10:41:10 -0300 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-10-06 13:01:10 -0700 |
commit | 204e6232679d0d412347fddd9e5bd0e529da73d5 (patch) | |
tree | f277f72f11f914e9b6c9874e5e48c22d56ba27a1 /ext/mro | |
parent | a00b390b6689672af8817e28321f92e70369c0d4 (diff) | |
download | perl-204e6232679d0d412347fddd9e5bd0e529da73d5.tar.gz |
mro UTF8 cleanup.
This patch also duplicates existing mro tests with copies that use
Unicode in identifiers, to test the mro code.
Since those tests trigger it, it also fixes a bug in the parsing
of *{...}: If the first character inside the braces is a non-ASCII
Unicode identifier character, the inside is now implicitly quoted
if it is just an identifier (just as it is with ASCII identifiers),
instead of being parsed as a bareword that would violate strict subs.
Diffstat (limited to 'ext/mro')
-rw-r--r-- | ext/mro/mro.xs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/ext/mro/mro.xs b/ext/mro/mro.xs index da67e732de..618260e965 100644 --- a/ext/mro/mro.xs +++ b/ext/mro/mro.xs @@ -475,6 +475,7 @@ mro__nextcan(...) SV *stashname; const char *fq_subname; const char *subname; + bool subname_utf8 = 0; STRLEN stashname_len; STRLEN subname_len; SV* sv; @@ -550,6 +551,7 @@ mro__nextcan(...) fq_subname = SvPVX(sv); fq_subname_len = SvCUR(sv); + subname_utf8 = SvUTF8(sv) ? 1 : 0; subname = strrchr(fq_subname, ':'); } else { subname = NULL; @@ -594,7 +596,8 @@ mro__nextcan(...) /* beyond here is just for cache misses, so perf isn't as critical */ stashname_len = subname - fq_subname - 2; - stashname = newSVpvn_flags(fq_subname, stashname_len, SVs_TEMP); + stashname = newSVpvn_flags(fq_subname, stashname_len, + SVs_TEMP | (subname_utf8 ? SVf_UTF8 : 0)); /* has ourselves at the top of the list */ linear_av = S_mro_get_linear_isa_c3(aTHX_ selfstash, 0); @@ -633,14 +636,16 @@ mro__nextcan(...) assert(curstash); - gvp = (GV**)hv_fetch(curstash, subname, subname_len, 0); + gvp = (GV**)hv_fetch(curstash, subname, + subname_utf8 ? -subname_len : subname_len, 0); if (!gvp) continue; candidate = *gvp; assert(candidate); if (SvTYPE(candidate) != SVt_PVGV) - gv_init(candidate, curstash, subname, subname_len, TRUE); + gv_init_pvn(candidate, curstash, subname, subname_len, + GV_ADDMULTI|(subname_utf8 ? SVf_UTF8 : 0)); /* Notably, we only look for real entries, not method cache entries, because in C3 the method cache of a parent is not |