Submitted by Daniel Macks
Assigned to Dan Nicholson
Building pkg-config-0.28 on OS X 10.8 against an already-installed glib-2.22.4 succeeds with no errors or warnings. It fails a self-test:
../pkg-config --print-variables simple : 'prefix libdir exec_prefix includedir' != 'exec_prefix prefix libdir includedir' FAIL: check-print-options
It looks like the same set of variable-names, just in a different order. Neither order appears to have any significance. Neither the expected nor actual result is n the order they appear in the simple.pc test file (which doesn't seem a useful detail to retain anyway) nor sorted alphabetically (which would be a nicely deterministic effect). If I understand the code being tested, it's main.c around line 685:
g_hash_table_foreach(pkg->vars, &print_hashtable_key, NULL);
and it's failing because it's assuming that a hash will have a particular order. I can't find that documented as such in the glib docs, and it goes against the whole idea of a hash (vs a list) data structure.
One solution would be to sort the list of keys. Something like (untested):
GList *varnames = g_hash_table_get_values(pkg->vars); varnames = g_list_sort(varnames, (GCompareFunc)g_ascii_strcasecmp); g_list_foreach(sorted_varnames, &print_list_entry, NULL);
with print_list_entry being a printf() of its first argument (like print_hashtable_key).