[gnumeric] xls: fix unintentional duplication of externnames.



commit 676055e286a19bac64ba862e8f75b72e3f20db55
Author: Morten Welinder <terra gnome org>
Date:   Wed Apr 10 11:38:23 2013 -0400

    xls: fix unintentional duplication of externnames.
    
    This happened with formulas like
    
      IFERROR(...,IFERROR(...,...))
    
    because we tried to lookup the function before the recursive call.

 NEWS                             |    1 +
 plugins/excel/ChangeLog          |    3 +++
 plugins/excel/ms-formula-write.c |    7 ++++++-
 3 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/NEWS b/NEWS
index 73e1724..1eb43a5 100644
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,7 @@ Morten:
        * Improve complex number parsing.
        * Fix error codes for complex number functions.
        * Fix import of non-Excel functions from LO's xls files.
+       * Fix problem with xls saving of externnames.
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.1
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 4b77619..18ee823 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,5 +1,8 @@
 2013-04-10  Morten Welinder  <terra gnome org>
 
+       * ms-formula-write.c (do_excel_write_prep_expr): Fix unintentional
+       duplication of externnames.
+
        * ms-excel-write.h (struct _XLSExporter): Change externnames
        member to a GPtrArray of char*.
 
diff --git a/plugins/excel/ms-formula-write.c b/plugins/excel/ms-formula-write.c
index 555b788..0c8b32d 100644
--- a/plugins/excel/ms-formula-write.c
+++ b/plugins/excel/ms-formula-write.c
@@ -98,12 +98,17 @@ do_excel_write_prep_expr (ExcelWriteState *ewb, GnmExpr const *expr)
 
        case GNM_EXPR_OP_FUNCALL: {
                GnmFunc *func = expr->func.func;
-               ExcelFunc *ef = g_hash_table_lookup (ewb->function_map, func);
+               ExcelFunc *ef;
                int i;
 
                for (i = 0; i < expr->func.argc; i++)
                        do_excel_write_prep_expr (ewb, expr->func.argv[i]);
 
+               /*
+                * Lookup here.  The loop above might have defined the
+                * name alreasy.
+                */
+               ef = g_hash_table_lookup (ewb->function_map, func);
                if (ef != NULL)
                        return;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]