* src/buffer.c (compare_overlays): Avoid qsort's instability.

Fixes: debbugs:6830
This commit is contained in:
Stefan Monnier 2012-03-09 11:46:25 -05:00
parent 4f96ea3f4f
commit cae0700001
2 changed files with 17 additions and 9 deletions

View file

@ -1,3 +1,7 @@
2012-03-09 Stefan Monnier <monnier@iro.umontreal.ca>
* buffer.c (compare_overlays): Avoid qsort's instability (bug#6830).
2012-03-08 Jan Djärv <jan.h.d@swipnet.se>
* gtkutil.c (x_wm_set_size_hint): Use one row in call to
@ -201,8 +205,8 @@
2012-02-04 Eli Zaretskii <eliz@gnu.org>
* w32.c (get_emacs_configuration_options): Include
--enable-checking, if specified, in the return value.
* w32.c (get_emacs_configuration_options):
Include --enable-checking, if specified, in the return value.
2012-02-04 Martin Rudalics <rudalics@gmx.at>
@ -308,8 +312,8 @@
2012-01-19 Martin Rudalics <rudalics@gmx.at>
* window.c (save_window_save, Fcurrent_window_configuration)
(Vwindow_persistent_parameters): Do not use Qstate. Rewrite
doc-strings.
(Vwindow_persistent_parameters): Do not use Qstate.
Rewrite doc-strings.
2012-01-19 Kenichi Handa <handa@m17n.org>
@ -483,9 +487,9 @@
* nsselect.m (CUT_BUFFER_SUPPORT): Remove define.
(symbol_to_nsstring): Fix indentation.
(ns_symbol_to_pb): New function.
(Fns_get_selection_internal): Renamed from Fns_get_cut_buffer_internal.
(Fns_rotate_cut_buffers_internal): Removed.
(Fns_store_selection_internal): Renamed from
(Fns_get_selection_internal): Rename from Fns_get_cut_buffer_internal.
(Fns_rotate_cut_buffers_internal): Remove.
(Fns_store_selection_internal): Rename from
Fns_store_cut_buffer_internal.
(ns_get_foreign_selection, Fx_own_selection_internal)
(Fx_disown_selection_internal, Fx_selection_exists_p)
@ -626,7 +630,7 @@
(coding_set_destination): Return how many bytes
coding->destination was relocated.
(CODING_DECODE_CHAR, CODING_ENCODE_CHAR, CODING_CHAR_CHARSET)
(CODING_CHAR_CHARSET_P): Adjusted for the avove changes.
(CODING_CHAR_CHARSET_P): Adjust for the avove changes.
2011-12-05 Kazuhiro Ito <kzhr@d1.dion.ne.jp> (tiny change)

View file

@ -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.