[recipes] Fix number parsing
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Fix number parsing
- Date: Tue, 16 May 2017 02:49:12 +0000 (UTC)
commit a675abdfbe9103ffe75a37bad139d4540cdfc978
Author: Matthias Clasen <mclasen redhat com>
Date: Mon May 15 22:45:19 2017 -0400
Fix number parsing
Our number parser was unintentionally eating
whitespace after integers, but not after other
kinds of numbers. This was causing the space
between amount and unit to grow every time the
field was parsed and re-saved.
src/gr-number.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/src/gr-number.c b/src/gr-number.c
index 663e75a..e108d9b 100644
--- a/src/gr-number.c
+++ b/src/gr-number.c
@@ -262,18 +262,21 @@ gr_number_parse (GrNumber *number,
if (parse_as_integer (number, &orig, FALSE, NULL)) {
gboolean valid;
+ char *endofint;
GrNumber n;
+ endofint = orig;
valid = skip_whitespace (&orig);
if (parse_as_vulgar_fraction (&n, &orig, NULL) ||
parse_as_fraction (&n, &orig, NULL)) {
gr_number_add (number, &n, number);
- valid = TRUE;
+ *input = orig;
+ return TRUE;
}
if (valid || *orig == '\0') {
- *input = orig;
+ *input = endofint;
return TRUE;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]