[gnumeric] Lotus: fix loading of floating point constants in wk4 formulas.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Lotus: fix loading of floating point constants in wk4 formulas.
- Date: Thu, 1 Jan 2015 18:38:50 +0000 (UTC)
commit 27e3b6ea30ce292021d36f425036cc499dc42d94
Author: Morten Welinder <terra gnome org>
Date: Thu Jan 1 13:38:18 2015 -0500
Lotus: fix loading of floating point constants in wk4 formulas.
plugins/lotus-123/ChangeLog | 5 +++++
plugins/lotus-123/lotus-formula.c | 4 ++--
plugins/lotus-123/lotus.c | 12 +++++++++---
plugins/lotus-123/lotus.h | 2 +-
4 files changed, 17 insertions(+), 6 deletions(-)
---
diff --git a/plugins/lotus-123/ChangeLog b/plugins/lotus-123/ChangeLog
index 33aa712..853721c 100644
--- a/plugins/lotus-123/ChangeLog
+++ b/plugins/lotus-123/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-01 Morten Welinder <terra gnome org>
+
+ * lotus-formula.c (lotus_parse_formula_new): New formulas use
+ treal, not double.
+
2014-12-31 Morten Welinder <terra gnome org>
* lotus.c (lotus_treal): Base this on lotus_extfloat thus giving
diff --git a/plugins/lotus-123/lotus-formula.c b/plugins/lotus-123/lotus-formula.c
index ad5ee32..7b0fc35 100644
--- a/plugins/lotus-123/lotus-formula.c
+++ b/plugins/lotus-123/lotus-formula.c
@@ -715,8 +715,8 @@ lotus_parse_formula_new (LotusState *state, GnmParsePos *orig,
switch (data[i]) {
case LOTUS_FORMULA_CONSTANT:
parse_list_push_value (&stack,
- value_new_float (gsf_le_get_double (data + i + 1)));
- i += 9;
+ lotus_load_treal (data + i + 1));
+ i += 11;
break;
case LOTUS_FORMULA_VARIABLE: {
diff --git a/plugins/lotus-123/lotus.c b/plugins/lotus-123/lotus.c
index 5fc7f1b..3cfa982 100644
--- a/plugins/lotus-123/lotus.c
+++ b/plugins/lotus-123/lotus.c
@@ -925,7 +925,7 @@ lotus_smallnum (signed int d)
return value_new_int (d >> 1);
}
-GnmValue *
+static GnmValue *
lotus_extfloat (guint64 mant, guint16 signexp)
{
int exp = (signexp & 0x7fff) - 16383;
@@ -942,13 +942,19 @@ lotus_extfloat (guint64 mant, guint16 signexp)
return lotus_value (sign * gnm_ldexp (mant, exp - 63));
}
+GnmValue *
+lotus_load_treal (gconstpointer p)
+{
+ return lotus_extfloat (GSF_LE_GET_GUINT64 (p),
+ GSF_LE_GET_GUINT16 ((const char *)p + 8));
+}
+
static GnmValue *
lotus_treal (const record_t *r, int ofs)
{
g_return_val_if_fail (ofs + 10 <= r->len, NULL);
- return lotus_extfloat (GSF_LE_GET_GUINT64 (r->data + ofs),
- GSF_LE_GET_GUINT16 (r->data + ofs + 8));
+ return lotus_load_treal (r->data + ofs);
}
/* ------------------------------------------------------------------------- */
diff --git a/plugins/lotus-123/lotus.h b/plugins/lotus-123/lotus.h
index 3649ad0..612b05a 100644
--- a/plugins/lotus-123/lotus.h
+++ b/plugins/lotus-123/lotus.h
@@ -38,7 +38,7 @@ GnmValue *lotus_new_string (gchar const *data, int def_group);
gboolean lotus_read (LotusState *state);
GnmValue *lotus_unpack_number (guint32 u);
GnmValue *lotus_smallnum (signed int d);
-GnmValue *lotus_extfloat (guint64 mant, guint16 signexp);
+GnmValue *lotus_load_treal (gconstpointer p);
void lmbcs_init (void);
void lmbcs_shutdown (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]