Accept duplicate groups. (#157877, Sebastien Bacher)

2006-04-18  Matthias Clasen  <mclasen@redhat.com>

	* glib/gkeyfile.c (g_key_file_add_group): Accept duplicate
	groups.  (#157877, Sebastien Bacher)

	* tests/keyfile-test.c: Add tests for duplicate key and
	duplicate group handling.
This commit is contained in:
Matthias Clasen 2006-04-19 02:39:37 +00:00 committed by Matthias Clasen
parent 442ef9d902
commit 64434acfe1
4 changed files with 52 additions and 1 deletions

View File

@ -1,3 +1,11 @@
2006-04-18 Matthias Clasen <mclasen@redhat.com>
* glib/gkeyfile.c (g_key_file_add_group): Accept duplicate
groups. (#157877, Sebastien Bacher)
* tests/keyfile-test.c: Add tests for duplicate key and
duplicate group handling.
2006-04-17 Matthias Clasen <mclasen@redhat.com> 2006-04-17 Matthias Clasen <mclasen@redhat.com>
* glib/gcompletion.c (g_completion_complete_utf8): Make passing * glib/gcompletion.c (g_completion_complete_utf8): Make passing

View File

@ -1,3 +1,11 @@
2006-04-18 Matthias Clasen <mclasen@redhat.com>
* glib/gkeyfile.c (g_key_file_add_group): Accept duplicate
groups. (#157877, Sebastien Bacher)
* tests/keyfile-test.c: Add tests for duplicate key and
duplicate group handling.
2006-04-17 Matthias Clasen <mclasen@redhat.com> 2006-04-17 Matthias Clasen <mclasen@redhat.com>
* glib/gcompletion.c (g_completion_complete_utf8): Make passing * glib/gcompletion.c (g_completion_complete_utf8): Make passing

View File

@ -2660,7 +2660,9 @@ g_key_file_add_group (GKeyFile *key_file,
g_return_if_fail (key_file != NULL); g_return_if_fail (key_file != NULL);
g_return_if_fail (group_name != NULL); g_return_if_fail (group_name != NULL);
g_return_if_fail (g_key_file_lookup_group_node (key_file, group_name) == NULL);
if (g_key_file_lookup_group_node (key_file, group_name) != NULL)
return;
group = g_new0 (GKeyFileGroup, 1); group = g_new0 (GKeyFileGroup, 1);
group->name = g_strdup (group_name); group->name = g_strdup (group_name);

View File

@ -880,6 +880,37 @@ test_groups (void)
g_key_file_free (keyfile); g_key_file_free (keyfile);
} }
static void
test_duplicate_keys (void)
{
GKeyFile *keyfile;
const gchar *data =
"[1]\n"
"key1=123\n"
"key1=345\n";
keyfile = load_data (data, 0);
check_string_value (keyfile, "1", "key1", "345");
g_key_file_free (keyfile);
}
/* http://bugzilla.gnome.org/show_bug.cgi?id=157877 */
static void
test_duplicate_groups (void)
{
GKeyFile *keyfile;
const gchar *data =
"[Desktop Entry]\n"
"key1=123\n"
"[Desktop Entry]\n"
"key2=123\n";
keyfile = load_data (data, 0);
g_key_file_free (keyfile);
}
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
@ -896,6 +927,8 @@ main (int argc, char *argv[])
test_group_remove (); test_group_remove ();
test_key_remove (); test_key_remove ();
test_groups (); test_groups ();
test_duplicate_keys ();
test_duplicate_groups ();
return 0; return 0;
} }