[glib] g_key_file_parse_value_as_integer: Integers can have trailing whitespaces or tabs
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] g_key_file_parse_value_as_integer: Integers can have trailing whitespaces or tabs
- Date: Fri, 9 Sep 2011 00:21:17 +0000 (UTC)
commit 7a45dde4fe64b4f6c6d3ebc54dfb54d106290e9d
Author: Kushal Das <kdas redhat com>
Date: Fri Sep 2 12:15:21 2011 +0530
g_key_file_parse_value_as_integer: Integers can have trailing whitespaces or tabs
Now it can parse integer values with trailing whitespaces or tabs before CR.
Using g_ascii_isspace() as suggested.
https://bugzilla.gnome.org/show_bug.cgi?id=653987
glib/gkeyfile.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/glib/gkeyfile.c b/glib/gkeyfile.c
index 3463488..9c5ed9b 100644
--- a/glib/gkeyfile.c
+++ b/glib/gkeyfile.c
@@ -3857,14 +3857,14 @@ g_key_file_parse_value_as_integer (GKeyFile *key_file,
const gchar *value,
GError **error)
{
- gchar *end_of_valid_int;
- glong long_value;
+ gchar *eof_int;
+ glong long_value;
gint int_value;
errno = 0;
- long_value = strtol (value, &end_of_valid_int, 10);
+ long_value = strtol (value, &eof_int, 10);
- if (*value == '\0' || *end_of_valid_int != '\0')
+ if (*value == '\0' || (*eof_int != '\0' && !g_ascii_isspace(*eof_int)))
{
gchar *value_utf8 = _g_utf8_make_valid (value);
g_set_error (error, G_KEY_FILE_ERROR,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]