From: Stefan Monnier Date: Fri, 9 Mar 2012 16:46:25 +0000 (-0500) Subject: * src/buffer.c (compare_overlays): Avoid qsort's instability. X-Git-Tag: emacs-pretest-24.0.05~132 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=cae070000107848cd082496e14cf5851cc1f2c25;p=emacs.git * src/buffer.c (compare_overlays): Avoid qsort's instability. Fixes: debbugs:6830 --- diff --git a/src/ChangeLog b/src/ChangeLog index f623e9d46e7..b984064e26c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2012-03-09 Stefan Monnier + + * buffer.c (compare_overlays): Avoid qsort's instability (bug#6830). + 2012-03-08 Jan Djärv * gtkutil.c (x_wm_set_size_hint): Use one row in call to @@ -201,8 +205,8 @@ 2012-02-04 Eli Zaretskii - * 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 @@ -308,8 +312,8 @@ 2012-01-19 Martin Rudalics * 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 @@ -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 (tiny change) diff --git a/src/buffer.c b/src/buffer.c index 1577254d92a..efb9a80f35d 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.