+2004-10-27 Ray Strode <rstrode@redhat.com>
+
+ * glib/gkeyfile.c:
+ (g_key_file_load_from_fd),
+ (g_key_file_load_from_file):
+ Move file is regular check to load_from_file to use
+ fstat() instead of race prone g_file_test(). Don't
+ clear/init until needed. Change error messages to be
+ more consistent.
+ (g_key_file_load_from_data),
+ (g_key_file_load_from_data_dirs),
+ (g_key_file_parse_data),
+ (g_key_file_get_value),
+ (g_key_file_get_string),
+ (g_key_file_set_string),
+ (g_key_file_get_string_list),
+ (g_key_file_set_string_list),
+ (g_key_file_set_locale_string),
+ (g_key_file_get_locale_string),
+ (g_key_file_set_locale_string_list),
+ (g_key_file_get_boolean),
+ (g_key_file_set_boolean),
+ (g_key_file_get_boolean_list),
+ (g_key_file_set_boolean_list),
+ (g_key_file_get_integer),
+ (g_key_file_get_integer_list),
+ (g_key_file_set_integer_list),
+ (g_key_file_remove_key):
+ Add more g_return_*if_fail checks for public functions.
+
2004-10-27 Matthias Clasen <mclasen@redhat.com>
* configure.in: Bump version.
+2004-10-27 Ray Strode <rstrode@redhat.com>
+
+ * glib/gkeyfile.c:
+ (g_key_file_load_from_fd),
+ (g_key_file_load_from_file):
+ Move file is regular check to load_from_file to use
+ fstat() instead of race prone g_file_test(). Don't
+ clear/init until needed. Change error messages to be
+ more consistent.
+ (g_key_file_load_from_data),
+ (g_key_file_load_from_data_dirs),
+ (g_key_file_parse_data),
+ (g_key_file_get_value),
+ (g_key_file_get_string),
+ (g_key_file_set_string),
+ (g_key_file_get_string_list),
+ (g_key_file_set_string_list),
+ (g_key_file_set_locale_string),
+ (g_key_file_get_locale_string),
+ (g_key_file_set_locale_string_list),
+ (g_key_file_get_boolean),
+ (g_key_file_set_boolean),
+ (g_key_file_get_boolean_list),
+ (g_key_file_set_boolean_list),
+ (g_key_file_get_integer),
+ (g_key_file_get_integer_list),
+ (g_key_file_set_integer_list),
+ (g_key_file_remove_key):
+ Add more g_return_*if_fail checks for public functions.
+
2004-10-27 Matthias Clasen <mclasen@redhat.com>
* configure.in: Bump version.
+2004-10-27 Ray Strode <rstrode@redhat.com>
+
+ * glib/gkeyfile.c:
+ (g_key_file_load_from_fd),
+ (g_key_file_load_from_file):
+ Move file is regular check to load_from_file to use
+ fstat() instead of race prone g_file_test(). Don't
+ clear/init until needed. Change error messages to be
+ more consistent.
+ (g_key_file_load_from_data),
+ (g_key_file_load_from_data_dirs),
+ (g_key_file_parse_data),
+ (g_key_file_get_value),
+ (g_key_file_get_string),
+ (g_key_file_set_string),
+ (g_key_file_get_string_list),
+ (g_key_file_set_string_list),
+ (g_key_file_set_locale_string),
+ (g_key_file_get_locale_string),
+ (g_key_file_set_locale_string_list),
+ (g_key_file_get_boolean),
+ (g_key_file_set_boolean),
+ (g_key_file_get_boolean_list),
+ (g_key_file_set_boolean_list),
+ (g_key_file_get_integer),
+ (g_key_file_get_integer_list),
+ (g_key_file_set_integer_list),
+ (g_key_file_remove_key):
+ Add more g_return_*if_fail checks for public functions.
+
2004-10-27 Matthias Clasen <mclasen@redhat.com>
* configure.in: Bump version.
+2004-10-27 Ray Strode <rstrode@redhat.com>
+
+ * glib/gkeyfile.c:
+ (g_key_file_load_from_fd),
+ (g_key_file_load_from_file):
+ Move file is regular check to load_from_file to use
+ fstat() instead of race prone g_file_test(). Don't
+ clear/init until needed. Change error messages to be
+ more consistent.
+ (g_key_file_load_from_data),
+ (g_key_file_load_from_data_dirs),
+ (g_key_file_parse_data),
+ (g_key_file_get_value),
+ (g_key_file_get_string),
+ (g_key_file_set_string),
+ (g_key_file_get_string_list),
+ (g_key_file_set_string_list),
+ (g_key_file_set_locale_string),
+ (g_key_file_get_locale_string),
+ (g_key_file_set_locale_string_list),
+ (g_key_file_get_boolean),
+ (g_key_file_set_boolean),
+ (g_key_file_get_boolean_list),
+ (g_key_file_set_boolean_list),
+ (g_key_file_get_integer),
+ (g_key_file_get_integer_list),
+ (g_key_file_set_integer_list),
+ (g_key_file_remove_key):
+ Add more g_return_*if_fail checks for public functions.
+
2004-10-27 Matthias Clasen <mclasen@redhat.com>
* configure.in: Bump version.
+2004-10-27 Ray Strode <rstrode@redhat.com>
+
+ * glib/gkeyfile.c:
+ (g_key_file_load_from_fd),
+ (g_key_file_load_from_file):
+ Move file is regular check to load_from_file to use
+ fstat() instead of race prone g_file_test(). Don't
+ clear/init until needed. Change error messages to be
+ more consistent.
+ (g_key_file_load_from_data),
+ (g_key_file_load_from_data_dirs),
+ (g_key_file_parse_data),
+ (g_key_file_get_value),
+ (g_key_file_get_string),
+ (g_key_file_set_string),
+ (g_key_file_get_string_list),
+ (g_key_file_set_string_list),
+ (g_key_file_set_locale_string),
+ (g_key_file_get_locale_string),
+ (g_key_file_set_locale_string_list),
+ (g_key_file_get_boolean),
+ (g_key_file_set_boolean),
+ (g_key_file_get_boolean_list),
+ (g_key_file_set_boolean_list),
+ (g_key_file_get_integer),
+ (g_key_file_get_integer_list),
+ (g_key_file_set_integer_list),
+ (g_key_file_remove_key):
+ Add more g_return_*if_fail checks for public functions.
+
2004-10-27 Matthias Clasen <mclasen@redhat.com>
* configure.in: Bump version.
struct stat stat_buf;
gchar read_buf[4096];
- if (key_file->approximate_size > 0)
+ fstat (fd, &stat_buf);
+ if (!S_ISREG (stat_buf.st_mode))
{
- g_key_file_clear (key_file);
- g_key_file_init (key_file);
+ g_set_error (error, G_KEY_FILE_ERROR,
+ G_KEY_FILE_ERROR_PARSE,
+ _("Not a regular file"));
+ return FALSE;
}
- key_file->flags = flags;
- fstat (fd, &stat_buf);
if (stat_buf.st_size == 0)
{
g_set_error (error, G_KEY_FILE_ERROR,
return FALSE;
}
+ if (key_file->approximate_size > 0)
+ {
+ g_key_file_clear (key_file);
+ g_key_file_init (key_file);
+ }
+ key_file->flags = flags;
+
bytes_read = 0;
do
{
g_set_error (error, G_FILE_ERROR,
g_file_error_from_errno (errno),
- _("Failed to read from file: %s"),
- g_strerror (errno));
+ "%s", g_strerror (errno));
return FALSE;
}
g_return_val_if_fail (key_file != NULL, FALSE);
g_return_val_if_fail (file != NULL, FALSE);
- if (!g_file_test (file, G_FILE_TEST_IS_REGULAR))
- {
- g_set_error (error, G_FILE_ERROR,
- G_FILE_ERROR_ISDIR,
- _("Failed to open file '%s': Not a regular file"),
- file);
- return FALSE;
- }
-
fd = open (file, O_RDONLY);
if (fd < 0)
{
g_set_error (error, G_FILE_ERROR,
g_file_error_from_errno (errno),
- _("Failed to open file '%s': %s"),
- file, g_strerror (errno));
+ "%s", g_strerror (errno));
return FALSE;
}
{
GError *key_file_error = NULL;
+ g_return_val_if_fail (key_file != NULL, FALSE);
g_return_val_if_fail (data != NULL, FALSE);
g_return_val_if_fail (length != 0, FALSE);
gint fd;
gboolean found_file;
+ g_return_val_if_fail (key_file != NULL, FALSE);
g_return_val_if_fail (!g_path_is_absolute (file), FALSE);
user_data_dir = g_get_user_data_dir ();
gsize i;
g_return_if_fail (key_file != NULL);
+ g_return_if_fail (data != NULL);
parse_error = NULL;
g_return_val_if_fail (key_file != NULL, NULL);
g_return_val_if_fail (group_name != NULL, NULL);
+ g_return_val_if_fail (key != NULL, NULL);
group = g_key_file_lookup_group (key_file, group_name);
GError *key_file_error;
g_return_val_if_fail (key_file != NULL, NULL);
+ g_return_val_if_fail (group_name != NULL, NULL);
g_return_val_if_fail (key != NULL, NULL);
key_file_error = NULL;
gchar *value;
g_return_if_fail (key_file != NULL);
+ g_return_if_fail (group_name != NULL);
g_return_if_fail (key != NULL);
-
+ g_return_if_fail (string != NULL);
+
value = g_key_file_parse_string_as_value (key_file, string, FALSE);
g_key_file_set_value (key_file, group_name, key, value);
g_free (value);
gint i, len;
GSList *p, *pieces = NULL;
+ g_return_val_if_fail (key_file != NULL, NULL);
+ g_return_val_if_fail (group_name != NULL, NULL);
+ g_return_val_if_fail (key != NULL, NULL);
+
value = g_key_file_get_value (key_file, group_name, key, &key_file_error);
if (key_file_error)
gsize i;
g_return_if_fail (key_file != NULL);
+ g_return_if_fail (group_name != NULL);
g_return_if_fail (key != NULL);
+ g_return_if_fail (list != NULL);
value_list = g_string_sized_new (length * 128);
for (i = 0; list[i] != NULL && i < length; i++)
gchar *full_key, *value;
g_return_if_fail (key_file != NULL);
+ g_return_if_fail (group_name != NULL);
g_return_if_fail (key != NULL);
+ g_return_if_fail (locale != NULL);
+ g_return_if_fail (string != NULL);
value = g_key_file_parse_string_as_value (key_file, string, FALSE);
full_key = g_strdup_printf ("%s[%s]", key, locale);
gboolean free_languages = FALSE;
gint i;
+ g_return_val_if_fail (key_file != NULL, NULL);
+ g_return_val_if_fail (group_name != NULL, NULL);
+ g_return_val_if_fail (key != NULL, NULL);
+
candidate_key = NULL;
translated_value = NULL;
key_file_error = NULL;
GError *key_file_error;
gchar **values, *value;
+ g_return_val_if_fail (key_file != NULL, NULL);
+ g_return_val_if_fail (group_name != NULL, NULL);
+ g_return_val_if_fail (key != NULL, NULL);
+
key_file_error = NULL;
value = g_key_file_get_locale_string (key_file, group_name,
gsize i;
g_return_if_fail (key_file != NULL);
+ g_return_if_fail (group_name != NULL);
g_return_if_fail (key != NULL);
+ g_return_if_fail (locale != NULL);
+ g_return_if_fail (length != 0);
value_list = g_string_sized_new (length * 128);
for (i = 0; list[i] != NULL && i < length; i++)
gchar *value;
gboolean bool_value;
+ g_return_val_if_fail (key_file != NULL, FALSE);
+ g_return_val_if_fail (group_name != NULL, FALSE);
+ g_return_val_if_fail (key != NULL, FALSE);
+
value = g_key_file_get_value (key_file, group_name, key, &key_file_error);
if (!value)
gchar *result;
g_return_if_fail (key_file != NULL);
+ g_return_if_fail (group_name != NULL);
g_return_if_fail (key != NULL);
result = g_key_file_parse_boolean_as_value (key_file, value);
gboolean *bool_values;
gsize i, num_bools;
+ g_return_val_if_fail (key_file != NULL, NULL);
+ g_return_val_if_fail (group_name != NULL, NULL);
+ g_return_val_if_fail (key != NULL, NULL);
+
key_file_error = NULL;
values = g_key_file_get_string_list (key_file, group_name, key,
gsize i;
g_return_if_fail (key_file != NULL);
+ g_return_if_fail (group_name != NULL);
g_return_if_fail (key != NULL);
+ g_return_if_fail (list != NULL);
value_list = g_string_sized_new (length * 8);
for (i = 0; i < length; i++)
gchar *value;
gint int_value;
+ g_return_val_if_fail (key_file != NULL, -1);
+ g_return_val_if_fail (group_name != NULL, -1);
+ g_return_val_if_fail (key != NULL, -1);
+
key_file_error = NULL;
value = g_key_file_get_value (key_file, group_name, key, &key_file_error);
gchar *result;
g_return_if_fail (key_file != NULL);
+ g_return_if_fail (group_name != NULL);
g_return_if_fail (key != NULL);
result = g_key_file_parse_integer_as_value (key_file, value);
gint *int_values;
gsize i, num_ints;
+ g_return_val_if_fail (key_file != NULL, NULL);
+ g_return_val_if_fail (group_name != NULL, NULL);
+ g_return_val_if_fail (key != NULL, NULL);
+
values = g_key_file_get_string_list (key_file, group_name, key,
&num_ints, &key_file_error);
gsize i;
g_return_if_fail (key_file != NULL);
+ g_return_if_fail (group_name != NULL);
g_return_if_fail (key != NULL);
+ g_return_if_fail (list != NULL);
values = g_string_sized_new (length * 16);
for (i = 0; i < length; i++)
GList *key_node, *tmp;
GString *string;
gchar *comment;
-
+
group = g_key_file_lookup_group (key_file, group_name);
if (!group)
{
GKeyFileGroup *group;
GKeyFileKeyValuePair *pair;
+ g_return_if_fail (key_file != NULL);
+ g_return_if_fail (group_name != NULL);
+ g_return_if_fail (key != NULL);
+
pair = NULL;
if (group_name == NULL)