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
This commit is contained in:
Dan Nicholson 2015-02-21 10:55:00 -08:00
parent a6e8749ada
commit 818aeace3b
2 changed files with 13 additions and 10 deletions

View file

@ -16,10 +16,10 @@ RESULT="pcfiledir"
run_test --print-variables no-variables
RESULT="exec_prefix
prefix
libdir
includedir
pcfiledir"
libdir
pcfiledir
prefix"
run_test --print-variables simple
# --print-provides

17
main.c
View file

@ -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");
}