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