summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2013-10-04 21:02:51 -0400
committerRyan Lortie <desrt@desrt.ca>2013-10-04 21:02:51 -0400
commit40b616d64847bba6de03eb6b8e7a3e311c5f58cd (patch)
tree6f67349a93d47f84f03aeb2a3f55d460859f1b3e
parentf0b7484e2d6829a1f4bb4603d85888fc81948b79 (diff)
Change how we add strings for keyfiles
This makes it match the way we write the keyfile to the index, which prevents a failed assert in the case that we have entries before the first group. That's technically invalid, but we should be able to deal with invalid input without aborting.
-rw-r--r--src/dfi-builder.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/dfi-builder.c b/src/dfi-builder.c
index f3f2591..1821e9e 100644
--- a/src/dfi-builder.c
+++ b/src/dfi-builder.c
@@ -436,38 +436,32 @@ dfi_builder_serialise (DfiBuilder *builder)
}
static void
-dfi_builder_add_strings_for_keyfile (DfiBuilder *builder,
+dfi_builder_add_strings_for_keyfile (DfiBuilder *builder,
DfiKeyfile *keyfile)
{
- guint n_groups;
- guint i;
+ gint n_groups, n_items;
+ gint i;
n_groups = dfi_keyfile_get_n_groups (keyfile);
+ n_items = dfi_keyfile_get_n_items (keyfile);
for (i = 0; i < n_groups; i++)
{
const gchar *group_name;
- guint start, end;
- guint j;
group_name = dfi_keyfile_get_group_name (keyfile, i);
- dfi_keyfile_get_group_range (keyfile, i, &start, &end);
-
dfi_string_list_ensure (builder->group_names, group_name);
+ }
- for (j = start; j < end; j++)
- {
- const gchar *key, *locale, *value;
-
- dfi_keyfile_get_item (keyfile, j, &key, &locale, &value);
-
- dfi_string_list_ensure (builder->key_names, key);
+ for (i = 0; i < n_items; i++)
+ {
+ const gchar *key, *locale, *value;
- if (locale)
- dfi_string_list_ensure (builder->locale_names, locale);
+ dfi_keyfile_get_item (keyfile, i, &key, &locale, &value);
- dfi_string_tables_add_string (builder->locale_string_tables, locale, value);
- }
+ dfi_string_list_ensure (builder->key_names, key);
+ dfi_string_list_ensure (builder->locale_names, locale); /* may be "" */
+ dfi_string_tables_add_string (builder->locale_string_tables, locale, value);
}
}