summaryrefslogtreecommitdiff
path: root/pp_sort.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-10-11 14:07:44 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-10-11 14:20:33 -0700
commitf7bc00eab34ee7a152e6156203f7f3ed0a777194 (patch)
tree440b32341fe35e0e2666bc4022db3ed9e6eecb19 /pp_sort.c
parent164df45ab853a1e9c2571d08edd3e27eae41a821 (diff)
downloadperl-f7bc00eab34ee7a152e6156203f7f3ed0a777194.tar.gz
[perl #30661] autoload sort subs
Diffstat (limited to 'pp_sort.c')
-rw-r--r--pp_sort.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/pp_sort.c b/pp_sort.c
index fd2f28a491..8dacd74a20 100644
--- a/pp_sort.c
+++ b/pp_sort.c
@@ -1516,7 +1516,9 @@ PP(pp_sort)
stash = CopSTASH(PL_curcop);
}
else {
- cv = sv_2cv(*++MARK, &stash, &gv, 0);
+ GV *autogv = NULL;
+ cv = sv_2cv(*++MARK, &stash, &gv, GV_ADD);
+ check_cv:
if (cv && SvPOK(cv)) {
const char * const proto = SvPV_nolen_const(MUTABLE_SV(cv));
if (proto && strEQ(proto, "$$")) {
@@ -1528,10 +1530,26 @@ PP(pp_sort)
is_xsub = 1;
}
else if (gv) {
+ goto autoload;
+ }
+ else if (!CvANON(cv) && (gv = CvGV(cv))) {
+ if (cv != GvCV(gv)) cv = GvCV(gv);
+ autoload:
+ if (!autogv && (
+ autogv = gv_autoload_pvn(
+ GvSTASH(gv), GvNAME(gv), GvNAMELEN(gv),
+ GvNAMEUTF8(gv) ? SVf_UTF8 : 0
+ )
+ )) {
+ cv = GvCVu(autogv);
+ goto check_cv;
+ }
+ else {
SV *tmpstr = sv_newmortal();
gv_efullname3(tmpstr, gv, NULL);
DIE(aTHX_ "Undefined sort subroutine \"%"SVf"\" called",
SVfARG(tmpstr));
+ }
}
else {
DIE(aTHX_ "Undefined subroutine in sort");