summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--intrpvar.h2
-rw-r--r--pp_sort.c9
2 files changed, 6 insertions, 5 deletions
diff --git a/intrpvar.h b/intrpvar.h
index e940163651..f98e3484f7 100644
--- a/intrpvar.h
+++ b/intrpvar.h
@@ -520,6 +520,8 @@ PERLVAR(Iwantutf8, bool) /* want utf8 as the default discipline */
PERLVAR(Iutf8_idstart, SV *)
PERLVAR(Iutf8_idcont, SV *)
+PERLVAR(Isort_RealCmp, SVCOMPARE_t)
+
/* New variables must be added to the very end for binary compatibility.
* XSUB.h provides wrapper functions via perlapi.h that make this
* irrelevant, but not all code may be expected to #include XSUB.h. */
diff --git a/pp_sort.c b/pp_sort.c
index 0a50ed53bb..d2d4bdee0a 100644
--- a/pp_sort.c
+++ b/pp_sort.c
@@ -1286,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)
@@ -1295,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;
}
@@ -1319,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);
@@ -1365,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);
}