[gnumeric] xls: handle new xl2010 function names
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] xls: handle new xl2010 function names
- Date: Thu, 20 Jun 2013 19:05:40 +0000 (UTC)
commit d65f550a38e4670b170c6855f3be72ccf6308d2c
Author: Morten Welinder <terra gnome org>
Date: Thu Jun 20 15:04:58 2013 -0400
xls: handle new xl2010 function names
I.e., map them to the ones we use on import. We do not reverse the mapping
on output.
NEWS | 1 +
plugins/excel/ChangeLog | 5 ++++
plugins/excel/ms-formula-read.c | 45 +++++++++++++++++++++++++++++++++++---
3 files changed, 47 insertions(+), 4 deletions(-)
---
diff --git a/NEWS b/NEWS
index bec6767..f9b842f 100644
--- a/NEWS
+++ b/NEWS
@@ -66,6 +66,7 @@ Morten:
* Workaround problems with automake 1.13.
* Fix crashes on corrupted files. [#702101] [#702182] [#702218]
[#702267] [#702277] [#702379] [#702658]
+ * Improve xls import of new stat function names.
--------------------------------------------------------------------------
Gnumeric 1.12.2
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 18beeee..7b2701f 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,8 @@
+2013-06-20 Morten Welinder <terra gnome org>
+
+ * ms-formula-read.c (xl2010_synonyms): Map new function names to
+ the ones we used.
+
2013-06-20 Andreas J. Guelzow <aguelzow pyrshep ca>
* xlsx-read.c (xlsx_pattern): set a default pattern
diff --git a/plugins/excel/ms-formula-read.c b/plugins/excel/ms-formula-read.c
index b85da80..16456fe 100644
--- a/plugins/excel/ms-formula-read.c
+++ b/plugins/excel/ms-formula-read.c
@@ -470,6 +470,40 @@ ExcelFuncDesc const excel_func_desc [] = {
int excel_func_desc_size = G_N_ELEMENTS (excel_func_desc);
GHashTable *excel_func_by_name = NULL;
+static GnmFunc *
+xl2010_synonyms (const char *name)
+{
+ Workbook *wb = NULL;
+ static const struct {
+ const char *newname;
+ const char *oldname;
+ } names[] = {
+ { "chisq.test", "chitest" },
+ { "confidence.norm", "confidence" },
+ { "covariance.p", "covar" },
+ { "f.test", "ftest" },
+ { "mode.sngl", "mode" },
+ { "percentile.inc", "percentile" },
+ { "percentrank.inc", "percentrank" },
+ { "quartile.inc", "quartile" },
+ { "rank.eq", "rank" },
+ { "stdev.p", "stdevp" },
+ { "stdev.s", "stdev" },
+ { "t.test", "ttest" },
+ { "var.p", "varp" },
+ { "var.s", "var" },
+ { "z.test", "ztest" }
+ };
+ unsigned ui;
+
+ for (ui = 0; ui < G_N_ELEMENTS (names); ui++)
+ if (g_ascii_strcasecmp (name, names[ui].newname) == 0)
+ return gnm_func_lookup (names[ui].oldname, wb);
+
+ return NULL;
+}
+
+
static GnmExpr const *
xl_expr_err (ExcelReadSheet const *esheet, int col, int row,
char const *msg, char const *str)
@@ -658,10 +692,13 @@ make_function (GnmExprList **stack, int fn_idx, int numargs, Workbook *wb)
name = NULL;
- if (g_str_has_prefix (f_name, "_xlfn.") &&
- (name = gnm_func_lookup (f_name + 6, wb))) {
- /* This happens for IFERROR, for example. */
- f_name += 6;
+ if (g_str_has_prefix (f_name, "_xlfn.")) {
+ name = gnm_func_lookup (f_name + 6, wb);
+ if (name)
+ /* This happens for IFERROR, for example. */
+ f_name += 6;
+ else
+ name = xl2010_synonyms (f_name + 6);
} else if (g_str_has_prefix (f_name, "_xlfnodf.") &&
(name = gnm_func_lookup (f_name + 9, wb))) {
/* This happens for GAMMA, for example. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]