X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pp_sort.c;h=edfdadfb0cd82e6e85ecb08576ad2f95d8bbd496;hb=c0ed5c75679d185e8c0f26e6f3efcd090e1e3f70;hp=1c120148c56a99bcf093d7f60f1d1672f5cdd5a5;hpb=7918f24d20384771923d344a382e1d16d9552018;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pp_sort.c b/pp_sort.c index 1c12014..edfdadf 100644 --- a/pp_sort.c +++ b/pp_sort.c @@ -340,7 +340,7 @@ typedef struct { static I32 -cmp_desc(pTHX_ gptr a, gptr b) +cmp_desc(pTHX_ gptr const a, gptr const b) { dVAR; return -PL_sort_RealCmp(aTHX_ a, b); @@ -1315,7 +1315,7 @@ S_qsortsvu(pTHX_ SV ** array, size_t num_elts, SVCOMPARE_t compare) static I32 -cmpindir(pTHX_ gptr a, gptr b) +cmpindir(pTHX_ gptr const a, gptr const b) { dVAR; gptr * const ap = (gptr *)a; @@ -1328,7 +1328,7 @@ cmpindir(pTHX_ gptr a, gptr b) } static I32 -cmpindir_desc(pTHX_ gptr a, gptr b) +cmpindir_desc(pTHX_ gptr const a, gptr const b) { dVAR; gptr * const ap = (gptr *)a; @@ -1557,11 +1557,12 @@ PP(pp_sort) max = AvFILL(av) + 1; if (SvMAGICAL(av)) { MEXTEND(SP, max); - p2 = SP; for (i=0; i < max; i++) { SV **svp = av_fetch(av, i, FALSE); *SP++ = (svp) ? *svp : NULL; } + SP--; + p1 = p2 = SP - (max-1); } else { if (SvREADONLY(av)) @@ -1717,7 +1718,7 @@ PP(pp_sort) SvREADONLY_off(av); else if (av && !sorting_av) { /* simulate pp_aassign of tied AV */ - SV** const base = ORIGMARK+1; + SV** const base = MARK+1; for (i=0; i < max; i++) { base[i] = newSVsv(base[i]); } @@ -1738,7 +1739,7 @@ PP(pp_sort) } static I32 -S_sortcv(pTHX_ SV *a, SV *b) +S_sortcv(pTHX_ SV *const a, SV *const b) { dVAR; const I32 oldsaveix = PL_savestack_ix; @@ -1765,7 +1766,7 @@ S_sortcv(pTHX_ SV *a, SV *b) } static I32 -S_sortcv_stacked(pTHX_ SV *a, SV *b) +S_sortcv_stacked(pTHX_ SV *const a, SV *const b) { dVAR; const I32 oldsaveix = PL_savestack_ix; @@ -1807,7 +1808,7 @@ S_sortcv_stacked(pTHX_ SV *a, SV *b) } static I32 -S_sortcv_xsub(pTHX_ SV *a, SV *b) +S_sortcv_xsub(pTHX_ SV *const a, SV *const b) { dVAR; dSP; const I32 oldsaveix = PL_savestack_ix; @@ -1838,7 +1839,7 @@ S_sortcv_xsub(pTHX_ SV *a, SV *b) static I32 -S_sv_ncmp(pTHX_ SV *a, SV *b) +S_sv_ncmp(pTHX_ SV *const a, SV *const b) { const NV nv1 = SvNSIV(a); const NV nv2 = SvNSIV(b); @@ -1849,7 +1850,7 @@ S_sv_ncmp(pTHX_ SV *a, SV *b) } static I32 -S_sv_i_ncmp(pTHX_ SV *a, SV *b) +S_sv_i_ncmp(pTHX_ SV *const a, SV *const b) { const IV iv1 = SvIV(a); const IV iv2 = SvIV(b); @@ -1867,7 +1868,7 @@ S_sv_i_ncmp(pTHX_ SV *a, SV *b) #define SORT_NORMAL_RETURN_VALUE(val) (((val) > 0) ? 1 : ((val) ? -1 : 0)) static I32 -S_amagic_ncmp(pTHX_ register SV *a, register SV *b) +S_amagic_ncmp(pTHX_ register SV *const a, register SV *const b) { dVAR; SV * const tmpsv = tryCALL_AMAGICbin(a,b,ncmp); @@ -1888,7 +1889,7 @@ S_amagic_ncmp(pTHX_ register SV *a, register SV *b) } static I32 -S_amagic_i_ncmp(pTHX_ register SV *a, register SV *b) +S_amagic_i_ncmp(pTHX_ register SV *const a, register SV *const b) { dVAR; SV * const tmpsv = tryCALL_AMAGICbin(a,b,ncmp); @@ -1909,7 +1910,7 @@ S_amagic_i_ncmp(pTHX_ register SV *a, register SV *b) } static I32 -S_amagic_cmp(pTHX_ register SV *str1, register SV *str2) +S_amagic_cmp(pTHX_ register SV *const str1, register SV *const str2) { dVAR; SV * const tmpsv = tryCALL_AMAGICbin(str1,str2,scmp); @@ -1930,7 +1931,7 @@ S_amagic_cmp(pTHX_ register SV *str1, register SV *str2) } static I32 -S_amagic_cmp_locale(pTHX_ register SV *str1, register SV *str2) +S_amagic_cmp_locale(pTHX_ register SV *const str1, register SV *const str2) { dVAR; SV * const tmpsv = tryCALL_AMAGICbin(str1,str2,scmp);