aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorStefan Monnier <[email protected]>2012-03-09 11:46:25 -0500
committerStefan Monnier <[email protected]>2012-03-09 11:46:25 -0500
commitcae070000107848cd082496e14cf5851cc1f2c25 (patch)
tree359bcc430193765f6012a6115e87e6552eb1208c /src/buffer.c
parent4f96ea3f4fbe8950c0d281da836897fb8394a812 (diff)
* src/buffer.c (compare_overlays): Avoid qsort's instability.
Fixes: debbugs:6830
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 1577254d92..efb9a80f35 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2864,7 +2864,11 @@ compare_overlays (const void *v1, const void *v2)
return s1->beg < s2->beg ? -1 : 1;
if (s1->end != s2->end)
return s2->end < s1->end ? -1 : 1;
- return 0;
+ /* Avoid the non-determinism of qsort by choosing an arbitrary ordering
+ between "equal" overlays. The result can still change between
+ invocations of Emacs, but it won't change in the middle of
+ `find_field' (bug#6830). */
+ return XHASH (s1->overlay) < XHASH (s2->overlay) ? -1 : 1;
}
/* Sort an array of overlays by priority. The array is modified in place.