[gimp/gimp-2-10] libgimpconfig: make gimp_scanner_parse_float() less strict
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] libgimpconfig: make gimp_scanner_parse_float() less strict
- Date: Tue, 30 Jul 2019 12:44:22 +0000 (UTC)
commit 77dd2982a579b4bbdef117b4ffa398f5509f06db
Author: Michael Natterer <mitch gimp org>
Date: Tue Jul 30 14:31:14 2019 +0200
libgimpconfig: make gimp_scanner_parse_float() less strict
A number without a decimal point can be put into a gdouble just fine,
no need to refuse them. Moreover, g_ascii_dtostr() serializes doubles
without fractional part without a decimal point, and we are soon going
to use it.
(cherry picked from commit 2c97bc83274345c40925268853714daee12555b1)
libgimpconfig/gimpscanner.c | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
---
diff --git a/libgimpconfig/gimpscanner.c b/libgimpconfig/gimpscanner.c
index b23ce357d9..08c15ecaab 100644
--- a/libgimpconfig/gimpscanner.c
+++ b/libgimpconfig/gimpscanner.c
@@ -568,17 +568,30 @@ gimp_scanner_parse_float (GScanner *scanner,
g_scanner_get_next_token (scanner);
}
- if (g_scanner_peek_next_token (scanner) != G_TOKEN_FLOAT)
- return FALSE;
+ if (g_scanner_peek_next_token (scanner) == G_TOKEN_FLOAT)
+ {
+ g_scanner_get_next_token (scanner);
- g_scanner_get_next_token (scanner);
+ if (negate)
+ *dest = -scanner->value.v_float;
+ else
+ *dest = scanner->value.v_float;
- if (negate)
- *dest = -scanner->value.v_float;
- else
- *dest = scanner->value.v_float;
+ return TRUE;
+ }
+ else if (g_scanner_peek_next_token (scanner) == G_TOKEN_INT)
+ {
+ g_scanner_get_next_token (scanner);
- return TRUE;
+ if (negate)
+ *dest = -scanner->value.v_int;
+ else
+ *dest = scanner->value.v_int;
+
+ return TRUE;
+ }
+
+ return FALSE;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]