#define FROMTOUPTO(src, dst, lim) do *dst++ = *src++; while(src<lim)
-/* Runs are identified by a pointer in the auxilliary list.
+/* Runs are identified by a pointer in the auxiliary list.
** The pointer is at the start of the list,
** and it points to the start of the next list.
** NEXT is used as an lvalue, too.
}
if (nmemb <= SMALLSORT) aux = small; /* use stack for aux array */
- else { Newx(aux,nmemb,gptr); } /* allocate auxilliary array */
+ else { Newx(aux,nmemb,gptr); } /* allocate auxiliary array */
level = 0;
stackp = stack;
stackp->runs = dynprep(aTHX_ base, aux, nmemb, cmp);
t = NEXT(t); /* where second run will end */
t = PINDEX(base, PNELEM(aux, t)); /* where it now ends */
FROMTOUPTO(f1, f2, t); /* copy both runs */
- NEXT(b) = p; /* paralled pointer for 1st */
+ NEXT(b) = p; /* paralleled pointer for 1st */
NEXT(p) = t; /* ... and for second */
}
}
return;
}
- /* Innoculate large partitions against quadratic behavior */
+ /* Inoculate large partitions against quadratic behavior */
if (num_elts > QSORT_PLAY_SAFE) {
register size_t n;
register SV ** const q = array;
q = list1;
for (n = nmemb; n--; ) {
/* Assert A: all elements of q with index > n are already
- * in place. This is vacuosly true at the start, and we
+ * in place. This is vacuously true at the start, and we
* put element n where it belongs below (if it wasn't
* already where it belonged). Assert B: we only move
* elements that aren't where they belong,
}
else {
if (SvREADONLY(av))
- Perl_croak(aTHX_ "%s", PL_no_modify);
+ Perl_croak_no_modify(aTHX);
else
SvREADONLY_on(av);
p1 = p2 = AvARRAY(av);
if (!PL_sortcop) {
if (priv & OPpSORT_NUMERIC) {
if (priv & OPpSORT_INTEGER) {
- if (!SvIOK(*p1)) {
- if (SvAMAGIC(*p1))
- overloading = 1;
- else
- (void)sv_2iv(*p1);
- }
+ if (!SvIOK(*p1))
+ (void)sv_2iv_flags(*p1, SV_GMAGIC|SV_SKIP_OVERLOAD);
}
else {
- if (!SvNSIOK(*p1)) {
- if (SvAMAGIC(*p1))
- overloading = 1;
- else
- (void)sv_2nv(*p1);
- }
+ if (!SvNSIOK(*p1))
+ (void)sv_2nv_flags(*p1, SV_GMAGIC|SV_SKIP_OVERLOAD);
if (all_SIVs && !SvSIOK(*p1))
all_SIVs = 0;
}
}
else {
- if (!SvPOK(*p1)) {
- if (SvAMAGIC(*p1))
- overloading = 1;
- else
- (void)sv_2pv_flags(*p1, 0,
- SV_GMAGIC|SV_CONST_RETURN);
- }
+ if (!SvPOK(*p1))
+ (void)sv_2pv_flags(*p1, 0,
+ SV_GMAGIC|SV_CONST_RETURN|SV_SKIP_OVERLOAD);
}
+ if (SvAMAGIC(*p1))
+ overloading = 1;
}
p1++;
}
sort_flags);
if (!(flags & OPf_SPECIAL)) {
- LEAVESUB(cv);
- if (!is_xsub)
- CvDEPTH(cv)--;
+ SV *sv;
+ /* Reset cx, in case the context stack has been
+ reallocated. */
+ cx = &cxstack[cxstack_ix];
+ POPSUB(cx, sv);
+ LEAVESUB(sv);
}
POPBLOCK(cx,PL_curpm);
PL_stack_sp = newsp;
const I32 oldsaveix = PL_savestack_ix;
const I32 oldscopeix = PL_scopestack_ix;
I32 result;
+ PMOP * const pm = PL_curpm;
PERL_ARGS_ASSERT_SORTCV;
LEAVE;
}
leave_scope(oldsaveix);
+ PL_curpm = pm;
return result;
}
const I32 oldscopeix = PL_scopestack_ix;
I32 result;
AV * const av = GvAV(PL_defgv);
+ PMOP * const pm = PL_curpm;
PERL_ARGS_ASSERT_SORTCV_STACKED;
+ if (AvREAL(av)) {
+ av_clear(av);
+ AvREAL_off(av);
+ AvREIFY_on(av);
+ }
if (AvMAX(av) < 1) {
- SV** ary = AvALLOC(av);
+ SV **ary = AvALLOC(av);
if (AvARRAY(av) != ary) {
AvMAX(av) += AvARRAY(av) - AvALLOC(av);
AvARRAY(av) = ary;
AvMAX(av) = 1;
Renew(ary,2,SV*);
AvARRAY(av) = ary;
+ AvALLOC(av) = ary;
}
}
AvFILLp(av) = 1;
LEAVE;
}
leave_scope(oldsaveix);
+ PL_curpm = pm;
return result;
}
const I32 oldscopeix = PL_scopestack_ix;
CV * const cv=MUTABLE_CV(PL_sortcop);
I32 result;
+ PMOP * const pm = PL_curpm;
PERL_ARGS_ASSERT_SORTCV_XSUB;
LEAVE;
}
leave_scope(oldsaveix);
+ PL_curpm = pm;
return result;
}
}
#define tryCALL_AMAGICbin(left,right,meth) \
- (PL_amagic_generation && (SvAMAGIC(left)||SvAMAGIC(right))) \
- ? amagic_call(left, right, CAT2(meth,_amg), 0) \
+ (SvAMAGIC(left)||SvAMAGIC(right)) \
+ ? amagic_call(left, right, meth, 0) \
: NULL;
#define SORT_NORMAL_RETURN_VALUE(val) (((val) > 0) ? 1 : ((val) ? -1 : 0))
S_amagic_ncmp(pTHX_ register SV *const a, register SV *const b)
{
dVAR;
- SV * const tmpsv = tryCALL_AMAGICbin(a,b,ncmp);
+ SV * const tmpsv = tryCALL_AMAGICbin(a,b,ncmp_amg);
PERL_ARGS_ASSERT_AMAGIC_NCMP;
S_amagic_i_ncmp(pTHX_ register SV *const a, register SV *const b)
{
dVAR;
- SV * const tmpsv = tryCALL_AMAGICbin(a,b,ncmp);
+ SV * const tmpsv = tryCALL_AMAGICbin(a,b,ncmp_amg);
PERL_ARGS_ASSERT_AMAGIC_I_NCMP;
S_amagic_cmp(pTHX_ register SV *const str1, register SV *const str2)
{
dVAR;
- SV * const tmpsv = tryCALL_AMAGICbin(str1,str2,scmp);
+ SV * const tmpsv = tryCALL_AMAGICbin(str1,str2,scmp_amg);
PERL_ARGS_ASSERT_AMAGIC_CMP;
S_amagic_cmp_locale(pTHX_ register SV *const str1, register SV *const str2)
{
dVAR;
- SV * const tmpsv = tryCALL_AMAGICbin(str1,str2,scmp);
+ SV * const tmpsv = tryCALL_AMAGICbin(str1,str2,scmp_amg);
PERL_ARGS_ASSERT_AMAGIC_CMP_LOCALE;