[gnumeric] Compilation: clean up too many range sorting functions.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Compilation: clean up too many range sorting functions.
- Date: Thu, 6 May 2021 00:19:10 +0000 (UTC)
commit a21dd0a29dcd059fca9cb61e9b32c7740f805228
Author: Morten Welinder <terra gnome org>
Date: Wed May 5 20:18:24 2021 -0400
Compilation: clean up too many range sorting functions.
Just use goffice's.
plugins/fn-date/functions.c | 21 +++++----------------
plugins/fn-stat/functions.c | 6 +++---
src/rangefunc.c | 4 ++--
src/rangefunc.h | 2 ++
src/tools/analysis-tools.c | 26 --------------------------
src/tools/analysis-tools.h | 2 --
6 files changed, 12 insertions(+), 49 deletions(-)
---
diff --git a/plugins/fn-date/functions.c b/plugins/fn-date/functions.c
index 206ab1fa9..b207dcc0d 100644
--- a/plugins/fn-date/functions.c
+++ b/plugins/fn-date/functions.c
@@ -815,17 +815,6 @@ static GnmFuncHelp const help_workday[] = {
{ GNM_FUNC_HELP_END }
};
-static gint
-float_compare (gnm_float const *a, gnm_float const *b)
-{
- if (*a < *b)
- return -1;
- else if (*a == *b)
- return 0;
- else
- return 1;
-}
-
static GnmValue *
gnumeric_workday (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
@@ -838,7 +827,7 @@ gnumeric_workday (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float const default_weekends[] = {1.,0.,0.,0.,0.,0.,1.};
int nholidays, nweekends, n_non_weekend = 0;
GDateWeekday weekday;
- int serial;
+ int serial = 0;
int i;
datetime_value_to_g (&date, argv[0], conv);
@@ -886,14 +875,14 @@ gnumeric_workday (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
holidays = collect_floats_value (argv[2], ei->pos,
COLLECT_COERCE_STRINGS |
COLLECT_IGNORE_BOOLS |
- COLLECT_IGNORE_BLANKS,
+ COLLECT_IGNORE_BLANKS |
+ COLLECT_SORT,
&nholidays, &result);
if (result) {
if (weekends != default_weekends)
g_free (weekends);
return result;
}
- qsort (holidays, nholidays, sizeof (holidays[0]), (void *) &float_compare);
for (i = j = 0; i < nholidays; i++) {
gnm_float s = holidays[i];
@@ -1187,14 +1176,14 @@ gnumeric_networkdays (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
holidays = collect_floats_value (argv[2], ei->pos,
COLLECT_COERCE_STRINGS |
COLLECT_IGNORE_BOOLS |
- COLLECT_IGNORE_BLANKS,
+ COLLECT_IGNORE_BLANKS |
+ COLLECT_SORT,
&nholidays, &result);
if (result) {
if (weekends != default_weekends)
g_free (weekends);
return result;
}
- qsort (holidays, nholidays, sizeof (holidays[0]), (void *) &float_compare);
for (i = j = 0; i < nholidays; i++) {
gnm_float s = holidays[i];
diff --git a/plugins/fn-stat/functions.c b/plugins/fn-stat/functions.c
index 2672503e8..b0bc7db63 100644
--- a/plugins/fn-stat/functions.c
+++ b/plugins/fn-stat/functions.c
@@ -5027,7 +5027,7 @@ gnumeric_lkstest (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float val;
gnm_float stat;
- ys = range_sort (xs, n);
+ ys = gnm_range_sort (xs, n);
val = pnorm (ys[0], mu, sigma, TRUE, FALSE);
dplus = 1./(gnm_float)n - val;
@@ -5138,7 +5138,7 @@ gnumeric_sftest (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float *ys;
gnm_float *zs;
- ys = range_sort (xs, n);
+ ys = gnm_range_sort (xs, n);
zs = g_new (gnm_float, n);
for (i = 0; i < n; i++)
@@ -5226,7 +5226,7 @@ gnumeric_cvmtest (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float p;
gnm_float *ys;
- ys = range_sort (xs, n);
+ ys = gnm_range_sort (xs, n);
for (i = 0; i < n; i++) {
gnm_float val = pnorm (ys[i], mu, sigma, TRUE, FALSE);
diff --git a/src/rangefunc.c b/src/rangefunc.c
index 04db922a9..7583783b3 100644
--- a/src/rangefunc.c
+++ b/src/rangefunc.c
@@ -412,7 +412,7 @@ gnm_range_rsq_pop (gnm_float const *xs, const gnm_float *ys, int n, gnm_float *r
}
/* Most-common element. (The one whose first occurrence comes first in
- case of several equally common. */
+ case of several equally common.) */
int
gnm_range_mode (gnm_float const *xs, int n, gnm_float *res)
{
@@ -478,7 +478,7 @@ gnm_range_adtest (gnm_float const *xs, int n, gnm_float *pvalue,
gnm_float p;
gnm_float *ys;
- ys = range_sort (xs, n);
+ ys = gnm_range_sort (xs, n);
for (i = 0; i < n; i++) {
gnm_float val = (pnorm (ys[i], mu, sigma, TRUE, TRUE) +
diff --git a/src/rangefunc.h b/src/rangefunc.h
index 8359edf48..c4f616451 100644
--- a/src/rangefunc.h
+++ b/src/rangefunc.h
@@ -18,6 +18,7 @@ G_BEGIN_DECLS
# define gnm_range_median_inter go_range_median_interl
# define gnm_range_median_inter_sorted go_range_median_inter_sortedl
# define gnm_range_increasing go_range_increasingl
+# define gnm_range_sort go_range_sortl
#else
# define gnm_range_sum go_range_sum
# define gnm_range_sumsq go_range_sumsq
@@ -30,6 +31,7 @@ G_BEGIN_DECLS
# define gnm_range_median_inter go_range_median_inter
# define gnm_range_median_inter_sorted go_range_median_inter_sorted
# define gnm_range_increasing go_range_increasing
+# define gnm_range_sort go_range_sort
#endif
int gnm_range_count (gnm_float const *xs, int n, gnm_float *res);
diff --git a/src/tools/analysis-tools.c b/src/tools/analysis-tools.c
index 59ee76897..8e6500ad8 100644
--- a/src/tools/analysis-tools.c
+++ b/src/tools/analysis-tools.c
@@ -441,32 +441,6 @@ gnm_check_input_range_list_homogeneity (GSList *input_range)
/***** Some general routines ***********************************************/
-static gint
-float_compare (gnm_float const *a, gnm_float const *b)
-{
- if (*a < *b)
- return -1;
- else if (*a == *b)
- return 0;
- else
- return 1;
-}
-
-gnm_float *
-range_sort (gnm_float const *xs, int n)
-{
- if (n <= 0)
- return NULL;
- else {
- gnm_float *ys = g_new (gnm_float, n);
- memcpy (ys, xs, n * sizeof (gnm_float));
- qsort (ys, n, sizeof (ys[0]),
- (int (*) (const void *, const void *))&float_compare);
- return ys;
- }
-}
-
-
/*
* Set a column of text from a string like "/first/second/third" or "|foo|bar|baz".
*/
diff --git a/src/tools/analysis-tools.h b/src/tools/analysis-tools.h
index 615cb510b..d946f1ad1 100644
--- a/src/tools/analysis-tools.h
+++ b/src/tools/analysis-tools.h
@@ -252,8 +252,6 @@ void prepare_input_range (GSList **input_range, group_by_t group_by);
const GnmExpr *make_cellref (int dx, int dy);
const GnmExpr *make_rangeref (int dx0, int dy0, int dx1, int dy1);
-gnm_float *range_sort (gnm_float const *xs, int n);
-
void set_cell_text_row (data_analysis_output_t *dao,
int col, int row, const char *text);
void set_cell_text_col (data_analysis_output_t *dao,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]