use strict;
use warnings;
-use Test::More tests => 35;
+use Test::More tests => 53;
use_ok('XS::APItest');
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);
+ }
+ }
+}
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;
/* 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;