[goffice] Ignore invalid values while checking data order. [#744200]
- From: Jean Bréfort <jbrefort src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Ignore invalid values while checking data order. [#744200]
- Date: Wed, 11 Feb 2015 17:21:31 +0000 (UTC)
commit 6107b0c4deae40c562f5d24d9f59feef28061262
Author: Jean Brefort <jean brefort normalesup org>
Date: Wed Feb 11 18:20:55 2015 +0100
Ignore invalid values while checking data order. [#744200]
ChangeLog | 5 +++++
NEWS | 3 +++
goffice/math/go-rangefunc.c | 32 ++++++++++++++++++++++++++------
3 files changed, 34 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2ac7b28..f9d8233 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-02-11 Jean Brefort <jean brefort normalesup org>
+
+ * goffice/math/go-rangefunc.c (go_range_increasing),
+ (go_range_decreasing): ignore nans. [#744200]
+
2015-02-11 Morten Welinder <terra gnome org>
* goffice/canvas/goc-arc.c (prepare_draw_arrow): Protect oval
diff --git a/NEWS b/NEWS
index 5c5cb6a..5ba245e 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
goffice 0.10.21:
+Jean:
+ * Ignore invalid values while checking data order. [#744200]
+
Morten:
* Fix problem with linear solver.
* Add arrow selector widget.
diff --git a/goffice/math/go-rangefunc.c b/goffice/math/go-rangefunc.c
index 2eb1567..63c61cb 100644
--- a/goffice/math/go-rangefunc.c
+++ b/goffice/math/go-rangefunc.c
@@ -307,22 +307,42 @@ SUFFIX(go_range_constant) (DOUBLE const *xs, int n)
int
SUFFIX(go_range_increasing) (DOUBLE const *xs, int n)
{
- int i;
+ int i = 0;
+ DOUBLE last;
g_return_val_if_fail (n == 0 || xs != NULL, 0);
- for (i = 1; i < n; i++)
- if (xs[i - 1] >= xs[i])
+ while ( i < n && isnan (xs[i]))
+ i++;
+ if (i == n)
+ return 0;
+ last = xs[i];
+ for (i = i + 1; i < n; i++) {
+ if (isnan (xs[i]))
+ continue;
+ if (last >= xs[i])
return 0;
+ last = xs[i];
+ }
return 1;
}
int
SUFFIX(go_range_decreasing) (DOUBLE const *xs, int n)
{
- int i;
+ int i = 0;
+ DOUBLE last;
g_return_val_if_fail (n == 0 || xs != NULL, 0);
- for (i = 1; i < n; i++)
- if (xs[i - 1] <= xs[i])
+ while ( i < n && isnan (xs[i]))
+ i++;
+ if (i == n)
+ return 0;
+ last = xs[i];
+ for (i = i + 1; i < n; i++) {
+ if (isnan (xs[i]))
+ continue;
+ if (last <= xs[i])
return 0;
+ last = xs[i];
+ }
return 1;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]