diff options
author | Brian Fraser <fraserbn@gmail.com> | 2011-07-06 04:31:08 -0300 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-10-06 13:01:06 -0700 |
commit | 499321d39221df050fd12158b300e0d5f2c83941 (patch) | |
tree | 0f6b5096e1e0e58b08e5184df9b060d10f8cc30b | |
parent | 772d5078e19623501bc9e2e30401b270f2b64bcc (diff) | |
download | perl-499321d39221df050fd12158b300e0d5f2c83941.tar.gz |
gv.c: gv_fetchmeth_pvn_autoload UTF8 cleanup.
As with the previous commit, no Perl-level visible changes.
-rw-r--r-- | ext/XS-APItest/t/gv_fetchmeth_autoload.t | 35 | ||||
-rw-r--r-- | gv.c | 4 |
2 files changed, 36 insertions, 3 deletions
diff --git a/ext/XS-APItest/t/gv_fetchmeth_autoload.t b/ext/XS-APItest/t/gv_fetchmeth_autoload.t index 2ceda8b18b..a24c00083c 100644 --- a/ext/XS-APItest/t/gv_fetchmeth_autoload.t +++ b/ext/XS-APItest/t/gv_fetchmeth_autoload.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 35; +use Test::More tests => 53; use_ok('XS::APItest'); @@ -47,3 +47,36 @@ ok !XS::APItest::gv_fetchmeth_autoload_type(\%::, "method\0not quite!", 1, $leve is XS::APItest::gv_fetchmeth_autoload_type(\%::, "method\0not quite!", 2, $level, 0), "*main::method", "gv_fetchmeth_autoload_pv() is not nul-clean"; ok !XS::APItest::gv_fetchmeth_autoload_type(\%::, "method\0not quite!", 3, $level, 0), "gv_fetchmeth_autoload_pvn() is nul-clean"; +{ + use utf8; + use open qw( :utf8 :std ); + + package main; + + sub method { 1 } + + my $meth_as_octets = + "\357\275\215\357\275\205\357\275\224\357\275\210\357\275\217\357\275\204"; + + $level = -1; + for my $type ( 1..3 ) { + ::is XS::APItest::gv_fetchmeth_autoload_type(\%main::, "method", $type, $level, 0), "*main::method", "$types[$type] is UTF-8 clean"; + ::ok !XS::APItest::gv_fetchmeth_autoload_type(\%main::, $meth_as_octets, $type, $level, 0); + ::ok !XS::APItest::gv_fetchmeth_autoload_type(\%main::, "method", $type, $level, 0); + + { + local *AUTOLOAD = sub { 1 }; + ::is XS::APItest::gv_fetchmeth_autoload_type(\%main::, "method$type", $type, $level, 0), "*main::method$type", "Autoloading UTF-8 subs works"; + } + + { + no strict 'refs'; + ::ok !XS::APItest::gv_fetchmeth_autoload_type( + \%{"\357\275\215\357\275\201\357\275\211\357\275\216::"}, + "method", $type, $level, 0); + ::ok !XS::APItest::gv_fetchmeth_autoload_type( + \%{"\357\275\215\357\275\201\357\275\211\357\275\216::"}, + "method", $type, $level, 0); + } + } +} @@ -840,7 +840,7 @@ Currently, the only significant value for C<flags> is SVf_UTF8. GV * Perl_gv_fetchmeth_pvn_autoload(pTHX_ HV *stash, const char *name, STRLEN len, I32 level, U32 flags) { - GV *gv = gv_fetchmeth_pvn(stash, name, len, level, 0); + GV *gv = gv_fetchmeth_pvn(stash, name, len, level, flags); PERL_ARGS_ASSERT_GV_FETCHMETH_PVN_AUTOLOAD; @@ -860,7 +860,7 @@ Perl_gv_fetchmeth_pvn_autoload(pTHX_ HV *stash, const char *name, STRLEN len, I3 /* Have an autoload */ if (level < 0) /* Cannot do without a stub */ gv_fetchmeth_pvn(stash, name, len, 0, flags); - gvp = (GV**)hv_fetch(stash, name, len, (level >= 0)); + gvp = (GV**)hv_fetch(stash, name, (flags & SVf_UTF8) ? -len : len, (level >= 0)); if (!gvp) return NULL; return *gvp; |