[gnumeric] csv: improve handling of expressions.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] csv: improve handling of expressions.
- Date: Thu, 15 Oct 2020 23:50:42 +0000 (UTC)
commit 0c4430052fb88f6d52e54f4c9fbcfa890e5cab2e
Author: Morten Welinder <terra gnome org>
Date: Thu Oct 15 19:49:27 2020 -0400
csv: improve handling of expressions.
1. Ignore expression when guessing formats.
2. Accept expressions in columns with non-general, non-text formats.
ChangeLog | 6 ++++++
NEWS | 1 +
src/stf-parse.c | 5 +++--
3 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 33db170c3..7aa3d3f43 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-10-15 Morten Welinder <terra gnome org>
+
+ * src/stf-parse.c (stf_parse_sheet): Don't try to parse entries
+ with single quote or equal sign as numbers; use stf_cell_set_text.
+ (stf_parse_options_guess_formats): Skip entries with '=' also.
+
2020-10-12 Morten Welinder <terra gnome org>
* src/workbook-priv.h: Introspection doesn't like empty structs so
diff --git a/NEWS b/NEWS
index 75c26566e..87b3e7ff6 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ Morten:
* Fix critical when using fd://1.
* Don't trim spaces for csv files as per rfc 4180. [#528]
* Fix cvs separator guessing problem with quotes. [#537]
+ * Improve handling of expressions in csv files.
--------------------------------------------------------------------------
Gnumeric 1.12.48
diff --git a/src/stf-parse.c b/src/stf-parse.c
index 83493efd4..7a4332a05 100644
--- a/src/stf-parse.c
+++ b/src/stf-parse.c
@@ -1386,6 +1386,7 @@ stf_parse_sheet (StfParseOptions_t *parseoptions,
if (text && *text) {
GnmCell *cell = sheet_cell_fetch (sheet, col, row);
if (!go_format_is_text (fmt) &&
+ text[0] != '=' && text[0] != '\'' &&
lcol < parseoptions->formats_decimal->len &&
g_ptr_array_index (parseoptions->formats_decimal, lcol)) {
GOFormatFamily fam;
@@ -1398,7 +1399,6 @@ stf_parse_sheet (StfParseOptions_t *parseoptions,
v = value_new_string (text);
sheet_cell_set_value (cell, v);
} else {
-
stf_cell_set_text (cell, text);
}
}
@@ -2003,8 +2003,9 @@ stf_parse_options_guess_formats (StfParseOptions_t *po, char const *data)
GPtrArray *line = g_ptr_array_index (lines, lno);
const char *data = col < line->len ? g_ptr_array_index (line, col) : "";
unsigned prev_possible = possible;
+ gunichar c0 = g_utf8_get_char (data);
- if (*data == 0 || data[0] == '\'')
+ if (c0 == 0 || c0 == '\'' || c0 == '=')
continue;
do_check_date (data, STF_GUESS_DATE_DMY, FALSE, FALSE, &possible, date_conv);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]