Blame SOURCES/0071-lib-use-user-friendly-order-in-make_description.patch

562801
From 15b4d3e8b516009bab878b7279f549fa61824c74 Mon Sep 17 00:00:00 2001
562801
From: Matej Habrnal <mhabrnal@redhat.com>
562801
Date: Tue, 16 Sep 2014 05:11:40 +0200
562801
Subject: [LIBREPORT PATCH 71/93] lib: use user-friendly order in
562801
 make_description()
562801
562801
The reason, time, cmd_line, package, uid, count are always sorted in this
562801
order. The other items are sorted alphabetically and added to the the end of
562801
the list.
562801
562801
Related to rhbz#1067440
562801
562801
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
562801
---
562801
 src/lib/make_descr.c | 28 +++++++++++++++++++++++++++-
562801
 1 file changed, 27 insertions(+), 1 deletion(-)
562801
562801
diff --git a/src/lib/make_descr.c b/src/lib/make_descr.c
562801
index 7f5c10b..dcf517e 100644
562801
--- a/src/lib/make_descr.c
562801
+++ b/src/lib/make_descr.c
562801
@@ -48,6 +48,32 @@ char *make_description_item_multiline(const char *name, const char *content)
562801
     return strbuf_free_nobuf(buf);
562801
 }
562801
 
562801
+static int list_cmp(const char *s1, const char *s2)
562801
+{
562801
+    static const char *const list_order[] = {
562801
+            FILENAME_REASON    ,
562801
+            FILENAME_TIME      ,
562801
+            FILENAME_CMDLINE   ,
562801
+            FILENAME_PACKAGE   ,
562801
+            FILENAME_UID       ,
562801
+            FILENAME_COUNT     ,
562801
+            NULL
562801
+    };
562801
+    int s1_index = index_of_string_in_list(s1, (char**) list_order);
562801
+    int s2_index = index_of_string_in_list(s2, (char**) list_order);
562801
+
562801
+    if(s1_index < 0 && s2_index < 0)
562801
+        return strcmp(s1, s2);
562801
+
562801
+    if(s1_index < 0)
562801
+        return 1;
562801
+
562801
+    if(s2_index < 0)
562801
+        return -1;
562801
+
562801
+    return s1_index - s2_index;
562801
+}
562801
+
562801
 char *make_description(problem_data_t *problem_data, char **names_to_skip,
562801
                        unsigned max_text_size, unsigned desc_flags)
562801
 {
562801
@@ -59,7 +85,7 @@ char *make_description(problem_data_t *problem_data, char **names_to_skip,
562801
                                                             FILENAME_ANALYZER);
562801
 
562801
     GList *list = g_hash_table_get_keys(problem_data);
562801
-    list = g_list_sort(list, (GCompareFunc)strcmp);
562801
+    list = g_list_sort(list, (GCompareFunc)list_cmp);
562801
     GList *l;
562801
 
562801
     /* Print one-liners. Format:
562801
-- 
562801
1.8.3.1
562801