2006-05-08 Matthias Clasen <mclasen@redhat.com>
+ * tests/keyfile-test.c (test_number): Add some tests for
+ invalid floating point numbers.
+
+ * glib/gkeyfile.c (g_key_file_parse_value_as_double): Return
+ an error for the empty string. (#339105, Morten Welinder)
+
* glib/gscanner.c (g_scanner_config_template): Make const,
noticed by Kjartan Maraas.
2006-05-08 Matthias Clasen <mclasen@redhat.com>
+ * tests/keyfile-test.c (test_number): Add some tests for
+ invalid floating point numbers.
+
+ * glib/gkeyfile.c (g_key_file_parse_value_as_double): Return
+ an error for the empty string. (#339105, Morten Welinder)
+
* glib/gscanner.c (g_scanner_config_template): Make const,
noticed by Kjartan Maraas.
double_value = g_ascii_strtod (value, &end_of_valid_d);
- if (*end_of_valid_d != '\0')
+ if (*end_of_valid_d != '\0' || end_of_valid_d == value)
g_set_error (error, G_KEY_FILE_ERROR,
G_KEY_FILE_ERROR_INVALID_VALUE,
_("Value '%s' cannot be interpreted as a float number."), value);
"key1=0xffff\n"
"key2=0.5\n"
"key3=1e37\n"
- "key4=ten\n";
+ "key4=ten\n"
+ "key5=\n"
+ "key6=1.0.0\n"
+ "key7=2x2\n"
+ "key8=abc\n";
keyfile = load_data (data, 0);
g_key_file_get_integer (keyfile, "invalid", "key4", &error);
check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE);
+ g_key_file_get_double (keyfile, "invalid", "key5", &error);
+ check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE);
+
+ g_key_file_get_double (keyfile, "invalid", "key6", &error);
+ check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE);
+
+ g_key_file_get_double (keyfile, "invalid", "key7", &error);
+ check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE);
+
+ g_key_file_get_double (keyfile, "invalid", "key8", &error);
+ check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE);
+
g_key_file_free (keyfile);
}