The old (length) annotation actually wasn't being read. Changing
it to an array was telling g-i that it was an array of utf8, which
is clearly not true.
We *could* add (element-type guint8), but that would change it to a
byte array, as opposed to the original utf8 version.
Just removing the annotation should bring us back to where we
were, which was fine.
https://bugzilla.gnome.org/show_bug.cgi?id=680310
There is no need to store a has_trailing_blank_line boolean for
each group, we can just check this at the time we assemble the data.
This fixes a problem without roundtrips where we would sometimes
add an extra blank line between groups.
The testcase here is inspired by
https://bugzilla.gnome.org/show_bug.cgi?id=677817
(array) without (element-type) means "array of the same type as
the C type", so gchar* with (array) is interpreted as an array of
strings. Since GKeyFiles must be UTF-8 encoded anyway, just
annotate it as a string.
https://bugzilla.gnome.org/show_bug.cgi?id=658484
GKeyFile supports empty files and also supports loading from the string
"", but will fail with a critical if you try:
- explicit length == 0
- data == NULL
length == 0 should always be valid, and data == NULL should be valid in
the case that length == 0, so add some testcases for those and fix the
code up to allow them.
https://bugzilla.gnome.org/show_bug.cgi?id=668756
These were leaked. Valgrind was sad.
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=666113
Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
Adds g_key_file_ref and g_key_file_unref, to be used by a future
GKeyFile boxed type for language bindings.
Based on the patch by Christian Persch and Emmanuele Bassi.
Author: Christian Persch
Signed-off-by: Johan Dahlin
Signed-off-by: Giovanni Campagna
https://bugzilla.gnome.org/show_bug.cgi?id=590808
Per IRC discussion, we can just ask bindings to use
g_key_file_get_value() to test for the existence of a key.
I left the "fixed" code in the source tree as static because it makes
more sense to me.
When loading a keyfile the incoming bytes are fed
to a line buffer to get parsed each time a new line
is encountered.
The code that fills the line buffer does it inefficiently,
one byte at a time.
This commit changes that code to look ahead at the incoming
bytes for the next '\n' character and then fill the line buffer
all at once.
https://bugzilla.gnome.org/show_bug.cgi?id=650211
When loading a key file, the keys and values of individual lines
are allocated once when copied and trimmed from the parse buffer
and allocated/copied again when added to the lookup map.
This commit avoids the second pair of allocations by introducing
a new function g_key_file_add_key_value_pair that gives the
lookup map direct ownership of the key and value copied from the
parse buffer.
https://bugzilla.gnome.org/show_bug.cgi?id=650211
When g_key_file_parse_data() encountered \n, it was checking the previous
character in the current input buffer for a \r to erase, rather than the
previous character in the parse buffer. If g_key_file_load_from_file()
was given a file with a \r\n sequence straddling a 4 KB boundary, the \n
would be the first character in the input buffer, so the \r would not be
properly stripped.
Bug #640695.
Found-by: Jan Harkes <jaharkes@cs.cmu.edu>
* glib/gkeyfile.c (g_key_file_get_string): Explain the difference
to g_key_file_get_value(). Pointed out by Mart Raudsepp.
svn path=/trunk/; revision=7705