[gnumeric] Don't duplicate range markers



commit c40cf7008b9d59026614e4199c920a7925b25bf2
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Fri Jun 11 12:44:03 2010 -0600

    Don't duplicate range markers
    
    2010-06-11 Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* src/expr.c (gnm_insert_unique_value_cmp): new
    	(gnm_insert_unique_value): new
    	(do_gnm_expr_get_ranges): use gnm_insert_unique_value rather than
    	  gnm_insert_unique which only compares pointers
    
    2010-06-11  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* gnumeric-expr-entry.c (gee_scan_for_range): remove warning

 ChangeLog                         |    9 ++++++++-
 src/expr.c                        |   20 +++++++++++++++++++-
 src/widgets/ChangeLog             |    4 ++++
 src/widgets/gnumeric-expr-entry.c |    1 -
 4 files changed, 31 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 074fe7d..b35a6a1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,16 @@
+2010-06-11 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* src/expr.c (gnm_insert_unique_value_cmp): new
+	(gnm_insert_unique_value): new
+	(do_gnm_expr_get_ranges): use gnm_insert_unique_value rather than
+	  gnm_insert_unique which only compares pointers
+
 2010-06-11  Jean Brefort  <jean brefort normalesup org>
 
 	* src/item-edit.c (item_edit_draw):	Fixed multi-line item edit
 	selection. [#621235]
 
-2010-06-10 Andreas J. Guelzow <aguelzow pyrshep ca>
+2010-06-11 Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* src/gnm-pane-impl.h: make cursor.expr_range into a GSList
 	* src/gnm-pane.h (gnm_pane_expr_cursor_bound_set): add main_colour arg 
diff --git a/src/expr.c b/src/expr.c
index 70225c9..08cb4de 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -2506,6 +2506,24 @@ gnm_expr_get_range (GnmExpr const *expr)
 	}
 }
 
+static gint
+gnm_insert_unique_value_cmp (gconstpointer a, gconstpointer b)
+{
+	return (value_equal (a,b) ? 0 : 1);
+}
+
+
+
+static GSList *
+gnm_insert_unique_value (GSList *list, GnmValue *data)
+{
+	if (g_slist_find_custom (list, data, 
+				 gnm_insert_unique_value_cmp) 
+	    == NULL)
+		return g_slist_prepend (list, data);
+	value_release (data);
+	return list;
+}
 
 static GSList *
 do_gnm_expr_get_ranges (GnmExpr const *expr, GSList *ranges)
@@ -2542,7 +2560,7 @@ do_gnm_expr_get_ranges (GnmExpr const *expr, GSList *ranges)
 	default: {
 		GnmValue *v = gnm_expr_get_range (expr);
 		if (v)
-			return gnm_insert_unique (ranges, v);
+			return gnm_insert_unique_value (ranges, v);
 		return ranges;
 	}
 	}
diff --git a/src/widgets/ChangeLog b/src/widgets/ChangeLog
index 2e4b88c..252332c 100644
--- a/src/widgets/ChangeLog
+++ b/src/widgets/ChangeLog
@@ -1,5 +1,9 @@
 2010-06-11  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* gnumeric-expr-entry.c (gee_scan_for_range): remove warning
+
+2010-06-11  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* gnumeric-expr-entry.c (gee_scan_for_range): create cursors for all
 	  ranges
 
diff --git a/src/widgets/gnumeric-expr-entry.c b/src/widgets/gnumeric-expr-entry.c
index 2bc7071..f57d4d9 100644
--- a/src/widgets/gnumeric-expr-entry.c
+++ b/src/widgets/gnumeric-expr-entry.c
@@ -513,7 +513,6 @@ gee_scan_for_range (GnmExprEntry *gee)
 			      sheet_get_conventions (sheet), NULL))!= NULL) {
 				GSList *ptr;
 				GSList *list = gnm_expr_top_get_ranges (texpr);
-#warning FIXME: gnm_expr_top_get_ranges does not delete duplicates!
 				for (ptr = list ; ptr != NULL ; ptr = ptr->next) {
 					GnmValue *v = ptr->data;
 					GnmRange  r;



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