After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 349825 - GKeyFile always inserts a newline before a group
GKeyFile always inserts a newline before a group
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.12.x
Other All
: Normal major
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2006-08-03 18:48 UTC by Chris Wilson
Modified: 2011-02-18 15:49 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Chris Wilson 2006-08-03 18:48:59 UTC
Back in 2006-06-14, g_key_file_to_data beautified its output by inserting a newline before each group (bug #344868).

Since then my key files have been quietly growing....

Perhaps:

Index: glib/gkeyfile.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gkeyfile.c,v
retrieving revision 1.44
diff -u -p -r1.44 gkeyfile.c
--- glib/gkeyfile.c     14 Jun 2006 13:48:27 -0000      1.44
+++ glib/gkeyfile.c     3 Aug 2006 18:46:12 -0000
@@ -943,12 +943,11 @@ g_key_file_to_data (GKeyFile  *key_file,
 
       group = (GKeyFileGroup *) group_node->data;
 
-      /* separate groups by an empty line */
-      if (group_node->next)
-
       if (group->comment != NULL)
         g_string_append_printf (data_string, "%s\n", group->comment->value);
+      else if (group_node->next) /* separate groups by at least an empty line */
+        g_string_append_c (data_string, '\n');
+
       if (group->name != NULL)
         g_string_append_printf (data_string, "[%s]\n", group->name);
Comment 1 Matthias Clasen 2006-08-05 21:57:46 UTC
2006-08-05  Matthias Clasen  <mclasen@redhat.com>

	* glib/gkeyfile.c (g_key_file_to_data): Don't insert unnecessary
	newlines in keyfiles.  (#349825, Chris Wilson)