[gnumeric] csv: guess decimal separator if only one of dot/comma was seen.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] csv: guess decimal separator if only one of dot/comma was seen.
- Date: Mon, 10 Jun 2019 00:43:51 +0000 (UTC)
commit 9ae83bc27028a90db2f9cbcdd91a4a7bd9fa1276
Author: Morten Welinder <terra gnome org>
Date: Sun Jun 9 20:41:50 2019 -0400
csv: guess decimal separator if only one of dot/comma was seen.
ChangeLog | 8 ++++++++
src/stf-parse.c | 15 +++++++++++----
2 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 70503c104..931e1cd15 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2019-06-09 Morten Welinder <terra gnome org>
+
+ * src/stf-parse.c (stf_parse_options_guess_formats): If we cannot
+ choose between decimal comma and decimal point, but have seen only
+ one then assume it is a decimal separator.
+ (do_check_date): Reject date unless guessed format has all three
+ of year, month, and day. [#401]
+
2019-05-22 Morten Welinder <terra gnome org>
* configure.ac: Post-release bump.
diff --git a/src/stf-parse.c b/src/stf-parse.c
index 3e0cfa109..215a14271 100644
--- a/src/stf-parse.c
+++ b/src/stf-parse.c
@@ -2025,10 +2025,17 @@ stf_parse_options_guess_formats (StfParseOptions_t *po, char const *data)
g_printerr ("col=%d; after [%s] possible=0x%x\n", col, data, possible);
}
- if ((possible & STF_GUESS_NUMBER_DEC_EITHER) == STF_GUESS_NUMBER_DEC_EITHER &&
- !seen_dot && !seen_comma) {
- // It doesn't matter what the separators are
- possible &= ~STF_GUESS_NUMBER_DEC_COMMA;
+ if ((possible & STF_GUESS_NUMBER_DEC_EITHER) == STF_GUESS_NUMBER_DEC_EITHER) {
+ if (!seen_dot && !seen_comma) {
+ // It doesn't matter what the separators are
+ possible &= ~STF_GUESS_NUMBER_DEC_COMMA;
+ } else if (seen_dot && !seen_comma) {
+ // Hope for the best
+ possible &= ~STF_GUESS_NUMBER_DEC_COMMA;
+ } else if (seen_comma && !seen_dot) {
+ // Hope for the best
+ possible &= ~STF_GUESS_NUMBER_DEC_EITHER;
+ }
}
switch (possible) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]