From 7aa38561f71d44dac3697324dd2d19cce74f9170 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sat, 4 May 2019 17:52:51 +0200 Subject: [PATCH] fixits: sort them before applying them An experimental commit introduced a fix-it hint that changes comments such as "/* empty */" into %empty. But in some case, because diagnostics are not necessarily emitted in order, the fixits also come in disorder, which must never happen, as the fixes are installed in one pass. * src/fixits.c (fixits_register): Insert them in order. --- src/fixits.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/fixits.c b/src/fixits.c index 3a8bf481..97c50569 100644 --- a/src/fixits.c +++ b/src/fixits.c @@ -52,6 +52,11 @@ fixit_new (location const *loc, char const* fix) return res; } +static int +fixit_cmp (const fixit *a, const fixit *b) +{ + return location_cmp (a->location, b->location); +} static void fixit_free (fixit *f) @@ -85,7 +90,7 @@ fixits_register (location const *loc, char const* fix) (gl_listelement_dispose_fn) fixit_free, true); fixit *f = fixit_new (loc, fix); - gl_list_add_last (fixits, f); + gl_sortedlist_add (fixits, (gl_listelement_compar_fn) fixit_cmp, f); if (feature_flag & feature_fixit_parsable) fixit_print (f, stderr); }