summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2015-02-21 10:55:00 -0800
committerDan Nicholson <dbn.lists@gmail.com>2015-02-21 10:55:00 -0800
commit818aeace3b08d731d104d5ef9b1d5e3c34dd4192 (patch)
tree2faa8b082e038eae4808694f0808077a22de502c /main.c
parenta6e8749ada5af1737b27f1eca1babe83e82af38c (diff)
downloadpkg-config-818aeace3b08d731d104d5ef9b1d5e3c34dd4192.tar.gz
Sort --print-variables output
Makes the output consistent regardless of how glib puts together the variables hash table. https://bugs.freedesktop.org/show_bug.cgi?id=66939
Diffstat (limited to 'main.c')
-rw-r--r--main.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/main.c b/main.c
index 8d37644..227ed35 100644
--- a/main.c
+++ b/main.c
@@ -281,11 +281,10 @@ pkg_uninstalled (Package *pkg)
}
void
-print_hashtable_key (gpointer key,
- gpointer value,
- gpointer user_data)
+print_list_data (gpointer data,
+ gpointer user_data)
{
- printf("%s\n", (gchar*)key);
+ g_print ("%s\n", (gchar *)data);
}
static void
@@ -700,9 +699,13 @@ main (int argc, char **argv)
{
Package *pkg = tmp->data;
if (pkg->vars != NULL)
- g_hash_table_foreach(pkg->vars,
- &print_hashtable_key,
- NULL);
+ {
+ /* Sort variables for consistent output */
+ GList *keys = g_hash_table_get_keys (pkg->vars);
+ keys = g_list_sort (keys, (GCompareFunc)g_strcmp0);
+ g_list_foreach (keys, print_list_data, NULL);
+ g_list_free (keys);
+ }
tmp = g_list_next (tmp);
if (tmp) printf ("\n");
}