• Home
  • Raw
  • Download

Lines Matching full:comment

74    /* Now we can add our new comment
79 pair->value = g_key_file_parse_comment_as_value (key_file, comment);
83 /* Now we can add our new comment
85 - group->comment = g_slice_new (GKeyFileKeyValuePair);
86 + group->comment = g_new (GKeyFileKeyValuePair, 1);
87 group->comment->key = NULL;
88 group->comment->value = g_key_file_parse_comment_as_value (key_file, comment);
91 if (comment == NULL)
97 pair->value = g_key_file_parse_comment_as_value (key_file, comment);
142 Subject: [PATCH 2/2] gkeyfile: Fix group comment management
144 This removes the `comment` member of the GKeyFileGroup structure, which
150 comment above the first group and the comment at the beginning of the
153 between comment above a group and comment at the end of the preceding
156 Instead, the same logic is used for groups as for keys: the comment
162 * It is now added as a comment as soon as the group is added (since a
163 blank line is considered a comment), so that
188 - GKeyFileKeyValuePair *comment; /* Special comment that is stuck to the top of a group */
221 - if (group->comment != NULL)
222 - g_string_append_printf (data_string, "%s\n", group->comment->value);
242 + const gchar *comment,
263 + if (comment == NULL)
268 + pair->value = g_key_file_parse_comment_as_value (key_file, comment);
293 + return g_key_file_set_top_comment (key_file, comment, error);
295 /* First remove any existing comment
297 - if (group->comment)
302 - g_key_file_key_value_pair_free (group->comment);
303 - group->comment = NULL;
313 if (comment == NULL)
316 /* Now we can add our new comment
318 - group->comment = g_new (GKeyFileKeyValuePair, 1);
319 - group->comment->key = NULL;
320 - group->comment->value = g_key_file_parse_comment_as_value (key_file, comment);
327 - const gchar *comment,
348 - if (comment == NULL)
353 pair->value = g_key_file_parse_comment_as_value (key_file, comment);
365 - if (group->comment)
366 - return g_strdup (group->comment->value);
409 - if (group->comment)
411 - g_key_file_key_value_pair_free (group->comment);
412 - group->comment = NULL;
424 "# group comment\n"
425 "# group comment, continued\n"
431 const gchar *top_comment = " top comment\n top comment, continued";
432 const gchar *group_comment = " group comment\n group comment, continued";
434 check_name ("top comment", comment, top_comment, 0);
435 g_free (comment);
439 + comment = g_key_file_get_comment (keyfile, NULL, NULL, &error);
441 + g_assert_null (comment);
443 comment = g_key_file_get_comment (keyfile, "group1", "key2", &error);
445 check_name ("key comment", comment, key_comment, 0);
447 check_name ("group comment", comment, group_comment, 0);
448 g_free (comment);
455 + comment = g_key_file_get_comment (keyfile, "group2", NULL, &error);
457 + g_assert_null (comment);
459 comment = g_key_file_get_comment (keyfile, "group3", NULL, &error);
461 + check_name ("group comment", comment, "", 0);
462 + g_free (comment);
464 + comment = g_key_file_get_comment (keyfile, "group4", NULL, &error);
466 + g_assert_null (comment);
468 + comment = g_key_file_get_comment (keyfile, "group5", NULL, &error);
477 + gchar *data1, *data2, *comment;
480 + const gchar *key_comment = " A random comment in the first group";
481 + const gchar *top_comment = " Top comment\n\n First comment";
483 + const gchar *group_comment_2 = " Second comment - one line";
484 + const gchar *group_comment_3 = " Third comment - two lines\n Third comment - two lines";
498 + comment = g_key_file_get_comment (keyfile, "first", "anotherkey", &error);
500 + g_assert_cmpstr (comment, ==, key_comment);
501 + g_free (comment);
503 + comment = g_key_file_get_comment (keyfile, NULL, NULL, &error);
505 + g_assert_cmpstr (comment, ==, top_comment);
506 + g_free (comment);
508 + comment = g_key_file_get_comment (keyfile, "first", NULL, &error);
510 + g_assert_cmpstr (comment, ==, group_comment_1);
511 + g_free (comment);
513 + comment = g_key_file_get_comment (keyfile, "second", NULL, &error);
515 + g_assert_cmpstr (comment, ==, group_comment_2);
516 + g_free (comment);
518 + comment = g_key_file_get_comment (keyfile, "third", NULL, &error);
520 + g_assert_cmpstr (comment, ==, group_comment_3);
521 + g_free (comment);
523 + comment = g_key_file_get_comment (keyfile, "fourth", NULL, &error);
525 + g_assert_cmpstr (comment, ==, group_comment_4);
526 + g_free (comment);
528 + comment = g_key_file_get_comment (keyfile, "fifth", NULL, &error);
530 + g_assert_null (comment);