Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests breaking in GLib 2.59 (GHashTable order changed) #223

Merged
merged 2 commits into from Mar 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -3734,14 +3734,15 @@ static void
as_component_xml_keywords_to_node (AsComponent *cpt, xmlNode *root)
{
AsComponentPrivate *priv = GET_PRIVATE (cpt);
GHashTableIter iter;
gpointer key, value;
g_autoptr(GList) keys = NULL;
GList *link;

g_hash_table_iter_init (&iter, priv->keywords);
while (g_hash_table_iter_next (&iter, &key, &value)) {
keys = g_hash_table_get_keys (priv->keywords);
keys = g_list_sort (keys, (GCompareFunc) g_ascii_strcasecmp);
for (link = keys; link != NULL; link = link->next) {
xmlNode *node;
const gchar *locale = (const gchar*) key;
gchar **kws = (gchar**) value;
const gchar *locale = (const gchar*) link->data;
gchar **kws = (gchar**) g_hash_table_lookup (priv->keywords, locale);

/* skip cruft */
if (as_is_cruft_locale (locale))
@@ -3891,22 +3892,23 @@ as_component_xml_serialize_languages (AsComponent *cpt, xmlNode *cptnode)
{
AsComponentPrivate *priv = GET_PRIVATE (cpt);
xmlNode *node;
GHashTableIter iter;
gpointer key, value;
g_autoptr(GList) keys = NULL;
GList *link;

if (g_hash_table_size (priv->languages) == 0)
return;

node = xmlNewChild (cptnode, NULL, (xmlChar*) "languages", NULL);
g_hash_table_iter_init (&iter, priv->languages);
while (g_hash_table_iter_next (&iter, &key, &value)) {
keys = g_hash_table_get_keys (priv->languages);
keys = g_list_sort (keys, (GCompareFunc) g_ascii_strcasecmp);
for (link = keys; link != NULL; link = link->next) {
guint percentage;
const gchar *locale;
xmlNode *l_node;
g_autofree gchar *percentage_str = NULL;

locale = (const gchar*) key;
percentage = GPOINTER_TO_INT (value);
locale = (const gchar*) link->data;
percentage = GPOINTER_TO_INT (g_hash_table_lookup (priv->languages, locale));
percentage_str = g_strdup_printf("%i", percentage);

l_node = xmlNewTextChild (node,
@@ -3927,21 +3929,23 @@ as_component_xml_serialize_custom (AsComponent *cpt, xmlNode *cptnode)
{
AsComponentPrivate *priv = GET_PRIVATE (cpt);
xmlNode *node;
GHashTableIter iter;
gpointer key, value;
g_autoptr(GList) keys = NULL;
GList *link;

if (g_hash_table_size (priv->custom) == 0)
return;

node = xmlNewChild (cptnode, NULL, (xmlChar*) "custom", NULL);
g_hash_table_iter_init (&iter, priv->custom);
while (g_hash_table_iter_next (&iter, &key, &value)) {
keys = g_hash_table_get_keys (priv->custom);
keys = g_list_sort (keys, (GCompareFunc) g_ascii_strcasecmp);
for (link = keys; link != NULL; link = link->next) {
const gchar *key = (const gchar*) link->data;
xmlNode *snode;

snode = xmlNewTextChild (node,
NULL,
(xmlChar*) "value",
(xmlChar*) value);
(xmlChar*) g_hash_table_lookup (priv->custom, key));
xmlNewProp (snode,
(xmlChar*) "key",
(xmlChar*) key);
@@ -4861,22 +4865,23 @@ static void
as_component_yaml_emit_languages (AsComponent *cpt, yaml_emitter_t *emitter)
{
AsComponentPrivate *priv = GET_PRIVATE (cpt);
GHashTableIter iter;
gpointer key, value;
g_autoptr(GList) keys = NULL;
GList *link;

if (g_hash_table_size (priv->languages) == 0)
return;

as_yaml_emit_scalar (emitter, "Languages");
as_yaml_sequence_start (emitter);

g_hash_table_iter_init (&iter, priv->languages);
while (g_hash_table_iter_next (&iter, &key, &value)) {
keys = g_hash_table_get_keys (priv->languages);
keys = g_list_sort (keys, (GCompareFunc) g_ascii_strcasecmp);
for (link = keys; link != NULL; link = link->next) {
guint percentage;
const gchar *locale;

locale = (const gchar*) key;
percentage = GPOINTER_TO_INT (value);
locale = (const gchar*) link->data;
percentage = GPOINTER_TO_INT (g_hash_table_lookup (priv->languages, locale));

as_yaml_mapping_start (emitter);
as_yaml_emit_entry (emitter, "locale", locale);
@@ -4894,20 +4899,21 @@ static void
as_component_yaml_emit_custom (AsComponent *cpt, yaml_emitter_t *emitter)
{
AsComponentPrivate *priv = GET_PRIVATE (cpt);
GHashTableIter iter;
gpointer key, value;
g_autoptr(GList) keys = NULL;
GList *link;

if (g_hash_table_size (priv->custom) == 0)
return;

as_yaml_emit_scalar (emitter, "Custom");
as_yaml_mapping_start (emitter);

g_hash_table_iter_init (&iter, priv->custom);
while (g_hash_table_iter_next (&iter, &key, &value)) {
keys = g_hash_table_get_keys (priv->custom);
keys = g_list_sort (keys, (GCompareFunc) g_ascii_strcasecmp);
for (link = keys; link != NULL; link = link->next) {
as_yaml_emit_entry (emitter,
(const gchar*) key,
(const gchar*) value);
(const gchar*) link->data,
(const gchar*) g_hash_table_lookup (priv->custom, link->data));
}

as_yaml_mapping_end (emitter);
@@ -355,14 +355,15 @@ as_xml_add_description_node_helper (AsContext *ctx, xmlNode *root, xmlNode **des
void
as_xml_add_description_node (AsContext *ctx, xmlNode *root, GHashTable *desc_table)
{
GHashTableIter iter;
gpointer key, value;
g_autoptr(GList) keys = NULL;
GList *link;
xmlNode *desc_node = NULL;

g_hash_table_iter_init (&iter, desc_table);
while (g_hash_table_iter_next (&iter, &key, &value)) {
const gchar *locale = (const gchar*) key;
const gchar *desc_markup = (const gchar*) value;
keys = g_hash_table_get_keys (desc_table);
keys = g_list_sort (keys, (GCompareFunc) g_ascii_strcasecmp);
for (link = keys; link != NULL; link = link->next) {
const gchar *locale = (const gchar*) link->data;
const gchar *desc_markup = g_hash_table_lookup (desc_table, locale);

if (as_is_cruft_locale (locale))
continue;
@@ -379,14 +380,15 @@ as_xml_add_description_node (AsContext *ctx, xmlNode *root, GHashTable *desc_tab
void
as_xml_add_localized_text_node (xmlNode *root, const gchar *node_name, GHashTable *value_table)
{
GHashTableIter iter;
gpointer key, value;
g_autoptr(GList) keys = NULL;
GList *link;

g_hash_table_iter_init (&iter, value_table);
while (g_hash_table_iter_next (&iter, &key, &value)) {
keys = g_hash_table_get_keys (value_table);
keys = g_list_sort (keys, (GCompareFunc) g_ascii_strcasecmp);
for (link = keys; link != NULL; link = link->next) {
xmlNode *cnode;
const gchar *locale = (const gchar*) key;
const gchar *str = (const gchar*) value;
const gchar *locale = (const gchar*) link->data;
const gchar *str = (const gchar*) g_hash_table_lookup (value_table, locale);

if (as_str_empty (str))
continue;