[gnumeric] GROWTH: Handle missing second argument as documented.



commit 3f0e2e8c9d1ea88731e391be64f308d0ab2b7f6b
Author: Morten Welinder <terra gnome org>
Date:   Mon Jun 29 13:28:06 2015 -0400

    GROWTH: Handle missing second argument as documented.

 NEWS                        |    1 +
 plugins/fn-stat/ChangeLog   |    5 +++++
 plugins/fn-stat/functions.c |   27 ++++++++++++++++++++-------
 3 files changed, 26 insertions(+), 7 deletions(-)
---
diff --git a/NEWS b/NEWS
index 2ab7189..506e58e 100644
--- a/NEWS
+++ b/NEWS
@@ -40,6 +40,7 @@ Morten:
        * Fix xlsx namespace problem.  [#751120]
        * Protect database functions against malformed database.  [#751392]
        * Fix csv problem with invalid UTF-8 data.  [#751577]
+       * Fix GROWTH.  [#751658]
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.22
diff --git a/plugins/fn-stat/ChangeLog b/plugins/fn-stat/ChangeLog
index f580448..b86f28c 100644
--- a/plugins/fn-stat/ChangeLog
+++ b/plugins/fn-stat/ChangeLog
@@ -1,3 +1,8 @@
+2015-06-29  Morten Welinder  <terra gnome org>
+
+       * functions.c (gnumeric_growth): Properly handle that the second
+       argument has a default.  Fixes #751658.
+
 2015-06-18  Morten Welinder  <terra gnome org>
 
        * functions.c (help_percentrank_exc): Fix function name.
diff --git a/plugins/fn-stat/functions.c b/plugins/fn-stat/functions.c
index 51da693..87c2df4 100644
--- a/plugins/fn-stat/functions.c
+++ b/plugins/fn-stat/functions.c
@@ -4296,13 +4296,26 @@ gnumeric_growth (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
        gnm_float expres[2];
        gboolean constp = FALSE;
 
-       res = collect_float_pairs (argv[0], argv[1], ei->pos,
-                                  COLLECT_IGNORE_BLANKS |
-                                  COLLECT_IGNORE_STRINGS |
-                                  COLLECT_IGNORE_BOOLS,
-                                  &ys, &xs, &n, &constp);
-       if (res)
-               return res;
+       if (argv[1]) {
+               res = collect_float_pairs (argv[0], argv[1], ei->pos,
+                                          COLLECT_IGNORE_BLANKS |
+                                          COLLECT_IGNORE_STRINGS |
+                                          COLLECT_IGNORE_BOOLS,
+                                          &ys, &xs, &n, &constp);
+               if (res)
+                       return res;
+       } else {
+               ys = collect_floats_value (argv[0], ei->pos,
+                                          COLLECT_IGNORE_BLANKS |
+                                          COLLECT_IGNORE_STRINGS |
+                                          COLLECT_IGNORE_BOOLS,
+                                          &n, &res);
+               if (res)
+                       return res;
+               xs = g_new (gnm_float, n);
+               for (i = 0; i < n; i++)
+                       xs[i] = i + 1;
+       }
 
        if (argv[2] != NULL) {
                nxs = collect_floats_value (argv[2], ei->pos,


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