I32 result;
PMOP * const pm = PL_curpm;
OP * const sortop = PL_op;
+ COP * const cop = PL_curcop;
SV **pad;
PERL_ARGS_ASSERT_SORTCV;
PL_stack_sp = PL_stack_base;
PL_op = PL_sortcop;
CALLRUNOPS(aTHX);
- if (PL_stack_sp != PL_stack_base + 1)
- Perl_croak(aTHX_ "Sort subroutine didn't return single value");
PL_op = sortop;
+ PL_curcop = cop;
pad = PL_curpad; PL_curpad = 0;
- result = SvIV(*PL_stack_sp);
+ if (PL_stack_sp != PL_stack_base + 1) {
+ assert(PL_stack_sp == PL_stack_base);
+ result = SvIV(&PL_sv_undef);
+ }
+ else result = SvIV(*PL_stack_sp);
PL_curpad = pad;
while (PL_scopestack_ix > oldscopeix) {
LEAVE;
AV * const av = GvAV(PL_defgv);
PMOP * const pm = PL_curpm;
OP * const sortop = PL_op;
+ COP * const cop = PL_curcop;
SV **pad;
PERL_ARGS_ASSERT_SORTCV_STACKED;
PL_stack_sp = PL_stack_base;
PL_op = PL_sortcop;
CALLRUNOPS(aTHX);
- if (PL_stack_sp != PL_stack_base + 1)
- Perl_croak(aTHX_ "Sort subroutine didn't return single value");
PL_op = sortop;
+ PL_curcop = cop;
pad = PL_curpad; PL_curpad = 0;
- result = SvIV(*PL_stack_sp);
+ if (PL_stack_sp != PL_stack_base + 1) {
+ assert(PL_stack_sp == PL_stack_base);
+ result = SvIV(&PL_sv_undef);
+ }
+ else result = SvIV(*PL_stack_sp);
PL_curpad = pad;
while (PL_scopestack_ix > oldscopeix) {
LEAVE;