[gnumeric] Complex: fix problem parsing complex numbers.



commit e1899135ce2fb41d221fdf4a392bdeeb9ae2a55c
Author: Morten Welinder <terra gnome org>
Date:   Sat May 1 13:44:51 2010 -0400

    Complex: fix problem parsing complex numbers.

 ChangeLog     |    5 +++++
 NEWS          |    1 +
 src/complex.c |    3 +++
 3 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 47bd064..fa6d52a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-05-01  Morten Welinder  <terra gnome org>
+
+	* src/complex.c (complex_from_string): Reject invalid strings like
+	"42.0.1i".
+
 2010-04-30 Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* src/cmd-edit.c (cmd_shift_rows): protect against data loss
diff --git a/NEWS b/NEWS
index e878db0..1b0d8eb 100644
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,7 @@ Morten:
 	* Fix xls-save problems with custom autofilters.
 	* Fix auto-filter problem.  [#383400]
 	* Fix advanced-filter problem with multiple criteria.  [#164169]
+	* Fix problem parsing comples numbers.
 
 --------------------------------------------------------------------------
 Gnumeric 1.10.2
diff --git a/src/complex.c b/src/complex.c
index b5740de..7642dc6 100644
--- a/src/complex.c
+++ b/src/complex.c
@@ -113,6 +113,9 @@ complex_from_string (complex_t *dst, char const *src, char *imunit)
 		return 0;
 	}
 
+	if (*src != '-' && *src != '+')
+		return -1;
+
 	/* Case: "42+i", "+42-i", "-42-i", ...  */
 	if (is_unit_imaginary (src, &dst->im, imunit)) {
 		dst->re = x;



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