X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pp_sort.c;h=d2d4bdee0a00e5c81cf5ac61a32cb33c1f398a6c;hb=1fd8f4ce4f455e94926dba744af1f828c467ad44;hp=5d6ce8698e74dece4c16dbf8207f3194910b7df1;hpb=42165d2726b8a0b9ded4dc56d733154af8784b90;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pp_sort.c b/pp_sort.c index 5d6ce86..d2d4bde 100644 --- a/pp_sort.c +++ b/pp_sort.c @@ -34,10 +34,9 @@ static I32 amagic_cmp_locale(pTHX_ SV *a, SV *b); #define sv_cmp_static Perl_sv_cmp #define sv_cmp_locale_static Perl_sv_cmp_locale -#define SORTHINTS(hintsvp) \ - ((PL_hintgv && \ - (hintsvp = hv_fetch(GvHV(PL_hintgv), "SORT", 4, FALSE))) ? \ - (I32)SvIV(*hintsvp) : 0) +#define SORTHINTS(hintsv) \ + (((hintsv) = GvSV(gv_fetchpv("sort::hints", GV_ADDMULTI, SVt_IV))), \ + (SvIOK(hintsv) ? ((I32)SvIV(hintsv)) : 0)) #ifndef SMALLSORT #define SMALLSORT (200) @@ -1287,7 +1286,6 @@ S_qsortsvu(pTHX_ SV ** array, size_t num_elts, SVCOMPARE_t compare) * dictated by the indirect array. */ -static SVCOMPARE_t RealCmp; static I32 cmpindir(pTHX_ gptr a, gptr b) @@ -1296,7 +1294,7 @@ cmpindir(pTHX_ gptr a, gptr b) gptr *ap = (gptr *)a; gptr *bp = (gptr *)b; - if ((sense = RealCmp(aTHX_ *ap, *bp)) == 0) + if ((sense = PL_sort_RealCmp(aTHX_ *ap, *bp)) == 0) sense = (ap > bp) ? 1 : ((ap < bp) ? -1 : 0); return sense; } @@ -1304,9 +1302,9 @@ cmpindir(pTHX_ gptr a, gptr b) STATIC void S_qsortsv(pTHX_ gptr *list1, size_t nmemb, SVCOMPARE_t cmp) { - SV **hintsvp; + SV *hintsv; - if (SORTHINTS(hintsvp) & HINT_SORT_STABLE) { + if (SORTHINTS(hintsv) & HINT_SORT_STABLE) { register gptr **pp, *q; register size_t n, j, i; gptr *small[SMALLSORT], **indir, tmp; @@ -1320,8 +1318,8 @@ S_qsortsv(pTHX_ gptr *list1, size_t nmemb, SVCOMPARE_t cmp) /* Copy pointers to original array elements into indirect array */ for (n = nmemb, pp = indir, q = list1; n--; ) *pp++ = q++; - savecmp = RealCmp; /* Save current comparison routine, if any */ - RealCmp = cmp; /* Put comparison routine where cmpindir can find it */ + savecmp = PL_sort_RealCmp; /* Save current comparison routine, if any */ + PL_sort_RealCmp = cmp; /* Put comparison routine where cmpindir can find it */ /* sort, with indirection */ S_qsortsvu(aTHX_ (gptr *)indir, nmemb, cmpindir); @@ -1366,7 +1364,7 @@ S_qsortsv(pTHX_ gptr *list1, size_t nmemb, SVCOMPARE_t cmp) /* free iff allocated */ if (indir != small) { Safefree(indir); } /* restore prevailing comparison routine */ - RealCmp = savecmp; + PL_sort_RealCmp = savecmp; } else { S_qsortsvu(aTHX_ list1, nmemb, cmp); } @@ -1391,7 +1389,7 @@ Perl_sortsv(pTHX_ SV **array, size_t nmemb, SVCOMPARE_t cmp) { void (*sortsvp)(pTHX_ SV **array, size_t nmemb, SVCOMPARE_t cmp) = S_mergesortsv; - SV **hintsvp; + SV *hintsv; I32 hints; /* Sun's Compiler (cc: WorkShop Compilers 4.2 30 Oct 1996 C 4.2) used @@ -1399,7 +1397,7 @@ Perl_sortsv(pTHX_ SV **array, size_t nmemb, SVCOMPARE_t cmp) errors related to picking the correct sort() function, try recompiling this file without optimiziation. -- A.D. 4/2002. */ - hints = SORTHINTS(hintsvp); + hints = SORTHINTS(hintsv); if (hints & HINT_SORT_QUICKSORT) { sortsvp = S_qsortsv; }