Make the interface of o_selection_add match the other o_selection_*()
functions.

o_selection_remove() in libgeda modifies a pointer to a selection list
passed as an argument, as do the other o_selection_*() functions.
However, o_selection_add() does not; it returns the new selection
list. This patch changes o_selection_add() to match the other
o_selection_*() functions.

 gschem/src/o_attrib.c       |   21 +++++++++------------
 gschem/src/o_buffer.c       |    2 +-
 gschem/src/o_complex.c      |    3 +--
 gschem/src/o_copy.c         |   20 ++++++++++----------
 gschem/src/o_misc.c         |    6 ------
 gschem/src/o_select.c       |   15 ++++++---------
 gschem/src/o_text.c         |    5 ++---
 libgeda/include/prototype.h |    2 +-
 libgeda/src/o_net_basic.c   |    6 ++----
 libgeda/src/o_selection.c   |    4 ++--
 10 files changed, 34 insertions(+), 50 deletions(-)

diff --git a/gschem/src/o_attrib.c b/gschem/src/o_attrib.c
index c53dce8..3ac0a5a 100644
--- a/gschem/src/o_attrib.c
+++ b/gschem/src/o_attrib.c
@@ -55,9 +55,8 @@ void o_attrib_add_selected(TOPLEVEL *w_current, GList** 
selection_list_ptr,
                           OBJECT *selected)
 {
   ATTRIB *a_current;
-  GList *selection_list = *selection_list_ptr;
 
-  if (!selection_list) return;
+  if (!(*selection_list_ptr)) return;
 
   /* deal with attributes here? */
   if (selected->attribs != NULL) {
@@ -70,10 +69,10 @@ void o_attrib_add_selected(TOPLEVEL *w_current, GList** 
selection_list_ptr,
 
                                /* make sure object isn't selected already */
         if (a_current->object->saved_color == -1) {
-          *selection_list_ptr = o_selection_add(selection_list,
-                                               /* w_current->page_current->
-                                                  selection2_head,*/
-                                               a_current->object);
+          o_selection_add(selection_list_ptr,
+                         /* w_current->page_current->
+                            selection2_head,*/
+                         a_current->object);
           o_redraw_single(w_current, a_current->object);
         }
 
@@ -345,9 +344,8 @@ void o_attrib_end(TOPLEVEL *w_current)
                     object);
   }
 
-  w_current->page_current->selection_list = 
-    o_selection_add(w_current->page_current->selection_list,
-                   w_current->page_current->object_tail);
+  o_selection_add(&(w_current->page_current->selection_list),
+                 w_current->page_current->object_tail);
   o_undo_savestate(w_current, UNDO_ALL);
 }
 
@@ -473,9 +471,8 @@ OBJECT *o_attrib_add_attrib(TOPLEVEL *w_current,
                     o_current);
   }
 
-  w_current->page_current->selection_list = 
-    o_selection_add(w_current->page_current->selection_list,
-                   w_current->page_current->object_tail);
+  o_selection_add(&(w_current->page_current->selection_list),
+                 w_current->page_current->object_tail);
 
   o_text_erase(w_current, w_current->page_current->object_tail); 
   o_text_draw(w_current, w_current->page_current->object_tail);
diff --git a/gschem/src/o_buffer.c b/gschem/src/o_buffer.c
index 496721f..d474f7a 100644
--- a/gschem/src/o_buffer.c
+++ b/gschem/src/o_buffer.c
@@ -209,7 +209,7 @@ void o_buffer_paste_end(TOPLEVEL *w_current, int screen_x, 
int screen_y,
 
   /* now add new objects to the selection list */
   while (o_current != NULL) {
-    temp_list = o_selection_add(temp_list, o_current);
+    o_selection_add(&temp_list, o_current);
     s_conn_update_object(w_current, o_current);
     if (o_current->type == OBJ_COMPLEX || o_current->type == OBJ_PLACEHOLDER) {
       connected_objects = s_conn_return_complex_others(
diff --git a/gschem/src/o_complex.c b/gschem/src/o_complex.c
index edd8f75..e87f5e6 100644
--- a/gschem/src/o_complex.c
+++ b/gschem/src/o_complex.c
@@ -436,8 +436,7 @@ void o_complex_end(TOPLEVEL *w_current, int screen_x, int 
screen_y)
 
   o_selection_unselect_list(w_current,
                            &(w_current->page_current->selection_list));
-  w_current->page_current->selection_list = 
-    o_selection_add(w_current->page_current->selection_list, 
+  o_selection_add(&(w_current->page_current->selection_list), 
                    w_current->page_current->object_tail);
   /* the o_redraw_selected is in x_events.c after this call
    * returns */
diff --git a/gschem/src/o_copy.c b/gschem/src/o_copy.c
index 345f863..2aaa7a4 100644
--- a/gschem/src/o_copy.c
+++ b/gschem/src/o_copy.c
@@ -144,7 +144,7 @@ void o_copy_end(TOPLEVEL *w_current)
                               diff_x, diff_y,
                               new_object);
 
-        temp_list = o_selection_add(temp_list, new_object);
+        o_selection_add(&temp_list, new_object);
         new_object->saved_color = object->saved_color;
         o_net_draw(w_current, new_object);
 
@@ -175,7 +175,7 @@ void o_copy_end(TOPLEVEL *w_current)
                               diff_x, diff_y,
                               new_object);
         
-        temp_list = o_selection_add(temp_list, new_object);
+       o_selection_add(&temp_list, new_object);
         new_object->saved_color = object->saved_color;
         o_pin_draw(w_current, new_object);
         
@@ -205,7 +205,7 @@ void o_copy_end(TOPLEVEL *w_current)
                               diff_x, diff_y,
                               new_object);
         
-        temp_list = o_selection_add(temp_list, new_object);
+       o_selection_add(&temp_list, new_object);
         new_object->saved_color = object->saved_color;
         o_bus_draw(w_current, new_object);
         
@@ -245,7 +245,7 @@ void o_copy_end(TOPLEVEL *w_current)
                                            diff_y,
                                            new_object);
 
-        temp_list = o_selection_add(temp_list, new_object);
+        o_selection_add(&temp_list, new_object);
 
        /* NEWSEL: this needs to be fixed too */
        /* this may not be needed anymore? */
@@ -276,7 +276,7 @@ void o_copy_end(TOPLEVEL *w_current)
                                new_object);
         w_current->ADDING_SEL=0; 
 
-        temp_list = o_selection_add(temp_list, new_object);
+        o_selection_add(&temp_list, new_object);
         new_object->saved_color = object->saved_color;
         o_line_draw(w_current, new_object);
         break;
@@ -298,7 +298,7 @@ void o_copy_end(TOPLEVEL *w_current)
                               new_object);
         w_current->ADDING_SEL=0; 
         
-        temp_list = o_selection_add(temp_list, new_object);
+        o_selection_add(&temp_list, new_object);
         new_object->saved_color = object->saved_color;
         o_box_draw(w_current, new_object);
         
@@ -321,7 +321,7 @@ void o_copy_end(TOPLEVEL *w_current)
                                  new_object);
         w_current->ADDING_SEL=0; 
         
-        temp_list = o_selection_add(temp_list, new_object);
+        o_selection_add(&temp_list, new_object);
         new_object->saved_color = object->saved_color;
         o_picture_draw(w_current, new_object);
         
@@ -345,7 +345,7 @@ void o_copy_end(TOPLEVEL *w_current)
                                  new_object);
         w_current->ADDING_SEL=0; 
 
-        temp_list = o_selection_add(temp_list, new_object);
+        o_selection_add(&temp_list, new_object);
         new_object->saved_color = object->saved_color;
         o_circle_draw(w_current, new_object);
         break;
@@ -368,7 +368,7 @@ void o_copy_end(TOPLEVEL *w_current)
                               new_object);
         w_current->ADDING_SEL=0; 
         
-        temp_list = o_selection_add(temp_list, new_object);
+        o_selection_add(&temp_list, new_object);
         new_object->saved_color = object->saved_color;
         o_arc_draw(w_current, new_object);
         break;
@@ -442,7 +442,7 @@ void o_copy_end(TOPLEVEL *w_current)
           color = object->saved_color;
         }
 
-        temp_list = o_selection_add(temp_list, new_object);
+        o_selection_add(&temp_list, new_object);
         new_object->saved_color = color;
         
        /* signify that object is no longer an attribute */
diff --git a/gschem/src/o_misc.c b/gschem/src/o_misc.c
index 753539f..c78ddf5 100644
--- a/gschem/src/o_misc.c
+++ b/gschem/src/o_misc.c
@@ -1048,12 +1048,6 @@ int o_edit_find_text(TOPLEVEL * w_current, OBJECT * 
o_list, char *stext,
     if (o_current->type == OBJ_TEXT) {
      /* replaced strcmp with strstr to simplify the search */
       if (strstr(o_current->text->string,stext)) {
-       /*            printf(_("Found %s\n"), stext);
-          if (!o_current->selected&&(!descend)) {
-          w_current->page_current->selection_list = 
-            o_selection_add(w_current->page_current->selection_list,
-                            o_current);
-          } */
        if (!skiplast) {
 
 #if 0 /* replaced by code below by avh, might not quite be right though */
diff --git a/gschem/src/o_select.c b/gschem/src/o_select.c
index c087660..24efe1d 100644
--- a/gschem/src/o_select.c
+++ b/gschem/src/o_select.c
@@ -171,9 +171,8 @@ void o_select_object(TOPLEVEL *w_current, OBJECT *o_current,
 
       /* object not select, add it to the selection list */
       o_select_run_hooks(w_current, o_current, 1);
-      w_current->page_current->selection_list = 
-       o_selection_add(w_current->page_current->selection_list,
-                       o_current);
+      o_selection_add(&(w_current->page_current->selection_list),
+                     o_current);
 
       break;
 
@@ -207,9 +206,8 @@ void o_select_object(TOPLEVEL *w_current, OBJECT *o_current,
                                       
&(w_current->page_current->selection_list));
            
            o_select_run_hooks(w_current, o_current, 1);
-            w_current->page_current->selection_list = 
-             o_selection_add(w_current->page_current->selection_list,
-                             o_current);
+           o_selection_add(&(w_current->page_current->selection_list),
+                           o_current);
           }    
 
           /* condition: doing single object add */
@@ -222,9 +220,8 @@ void o_select_object(TOPLEVEL *w_current, OBJECT *o_current,
                                       
&(w_current->page_current->selection_list));
 
             o_select_run_hooks (w_current, o_current, 1);
-            w_current->page_current->selection_list =
-             o_selection_add(w_current->page_current->selection_list,
-                             o_current);
+           o_selection_add(&(w_current->page_current->selection_list),
+                           o_current);
           }
 
           if (CONTROLKEY) {
diff --git a/gschem/src/o_text.c b/gschem/src/o_text.c
index 28d1250..23aa9d7 100644
--- a/gschem/src/o_text.c
+++ b/gschem/src/o_text.c
@@ -582,9 +582,8 @@ void o_text_end(TOPLEVEL *w_current)
   o_select_run_hooks(w_current, NULL, 2); 
   o_selection_unselect_list(w_current,
                            &(w_current->page_current->selection_list));
-  w_current->page_current->selection_list = 
-    o_selection_add(w_current->page_current->selection_list, 
-                   w_current->page_current->object_tail);
+  o_selection_add(&(w_current->page_current->selection_list), 
+                 w_current->page_current->object_tail);
        
 
   /* object_tail is the object that was just added */
diff --git a/libgeda/include/prototype.h b/libgeda/include/prototype.h
index 0064e63..02a6721 100644
--- a/libgeda/include/prototype.h
+++ b/libgeda/include/prototype.h
@@ -433,7 +433,7 @@ void o_pin_modify(TOPLEVEL *w_current, OBJECT *object, int 
x, int y, int whichon
 void o_pin_update_whichend(TOPLEVEL *w_current, OBJECT *object_list, int 
num_pins);
 
 /* o_selection.c */
-GList *o_selection_add(GList *head, OBJECT *o_selected);
+void o_selection_add(GList **head, OBJECT *o_selected);
 void o_selection_print_all( GList *head );
 void o_selection_select(OBJECT *object, int color);
 void o_selection_unselect(OBJECT *object);
diff --git a/libgeda/src/o_net_basic.c b/libgeda/src/o_net_basic.c
index 01a0bb6..59685a5 100644
--- a/libgeda/src/o_net_basic.c
+++ b/libgeda/src/o_net_basic.c
@@ -925,10 +925,8 @@ int o_net_consolidate_segments(TOPLEVEL *w_current, OBJECT 
*object)
           if (reselect_new == TRUE) {
             o_selection_remove(&(w_current->page_current->selection_list), 
                                object);
-
-            w_current->page_current->selection_list = 
-             o_selection_add(w_current->page_current->selection_list, 
-                             object);
+           o_selection_add(&(w_current->page_current->selection_list), 
+                           object);
           }
                                
           s_conn_remove(w_current, other_object);
diff --git a/libgeda/src/o_selection.c b/libgeda/src/o_selection.c
index 88a107e..20df860 100644
--- a/libgeda/src/o_selection.c
+++ b/libgeda/src/o_selection.c
@@ -53,10 +53,10 @@
  *  \param [in] o_selected Object to select.
  *  \returns a pointer to the selection list, with the object added.
  */
-GList *o_selection_add(GList *head, OBJECT *o_selected)
+void o_selection_add(GList **head, OBJECT *o_selected)
 {
   o_selection_select(o_selected, SELECT_COLOR);
-  return (g_list_append(head, o_selected));
+  *head = g_list_append(*head, o_selected);
 }
 
 /*! \brief Prints the given selection list.


_______________________________________________
geda-dev mailing list
[email protected]
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev

Reply via email to