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

gEDA-cvs: gaf.git: branch: master updated (1.5.4-20090830-14-g4f40000)



The branch, master has been updated
       via  4f40000aff79919a3894de4e2e6e560e224220ce (commit)
       via  3e6e56f8840a5df6512e9305879d75afd9ece373 (commit)
      from  ff7738b406991a47bf77d2af4b20d0e59d148e1f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 gattrib/src/s_attrib.c              |    2 +-
 gschem/src/o_misc.c                 |    2 +-
 gschem/src/o_slot.c                 |    4 +-
 gschem/src/x_autonumber.c           |    5 +-
 libgeda/include/libgeda/prototype.h |    6 +-
 libgeda/include/prototype_priv.h    |    1 +
 libgeda/src/Makefile.am             |    1 +
 libgeda/src/a_basic.c               |    2 +-
 libgeda/src/o_attrib.c              |  185 +-----------------------------
 libgeda/src/o_complex_basic.c       |    2 +-
 libgeda/src/o_list.c                |    2 +-
 libgeda/src/s_slot.c                |  221 +++++++++++++++++++++++++++++++++++
 12 files changed, 237 insertions(+), 196 deletions(-)
 create mode 100644 libgeda/src/s_slot.c


=================
 Commit Messages
=================

commit 4f40000aff79919a3894de4e2e6e560e224220ce
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    libgeda: Move slot handling code to its own file, s_slot.c
    
    Separates special-case attribute handling from o_attrib.c
    
    Renamed functions:
      o_attrib_search_slot() -> s_slot_search_slot()
      o_attrib_slot_update() -> s_slot_update_object()
    
    libgeda private API:
      o_attrib_find_attrib_by_name() is no longer static to o_attrib.c

:100644 100644 615bde8... 8f10414... M	gattrib/src/s_attrib.c
:100644 100644 2e57ff1... 93275ff... M	gschem/src/o_misc.c
:100644 100644 4dd9fc2... d0bac60... M	gschem/src/o_slot.c
:100644 100644 9c07a49... ba123b9... M	gschem/src/x_autonumber.c
:100644 100644 a716da5... 1e47b5e... M	libgeda/include/libgeda/prototype.h
:100644 100644 44ccab0... fce2c75... M	libgeda/include/prototype_priv.h
:100644 100644 3a20a1c... 7b10439... M	libgeda/src/Makefile.am
:100644 100644 1dfcd38... 0c41d88... M	libgeda/src/a_basic.c
:100644 100644 fcabd25... f7edafb... M	libgeda/src/o_attrib.c
:100644 100644 35aa709... 3e2df60... M	libgeda/src/o_complex_basic.c
:100644 100644 f0385f4... 1bc8939... M	libgeda/src/o_list.c
:000000 100644 0000000... cd89fdf... A	libgeda/src/s_slot.c

commit 3e6e56f8840a5df6512e9305879d75afd9ece373
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    Use o_text_set_string() to adjust attribute values
    
    Avoids re-writing the text->string member directly.

:100644 100644 117ff91... fcabd25... M	libgeda/src/o_attrib.c

=========
 Changes
=========

commit 4f40000aff79919a3894de4e2e6e560e224220ce
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    libgeda: Move slot handling code to its own file, s_slot.c
    
    Separates special-case attribute handling from o_attrib.c
    
    Renamed functions:
      o_attrib_search_slot() -> s_slot_search_slot()
      o_attrib_slot_update() -> s_slot_update_object()
    
    libgeda private API:
      o_attrib_find_attrib_by_name() is no longer static to o_attrib.c

diff --git a/gattrib/src/s_attrib.c b/gattrib/src/s_attrib.c
index 615bde8..8f10414 100644
--- a/gattrib/src/s_attrib.c
+++ b/gattrib/src/s_attrib.c
@@ -121,7 +121,7 @@ char *s_attrib_get_refdes(OBJECT *object)
     o_attrib_search_object_attribs_by_name (object, "numslots", 0);
   if (numslots_value != NULL) {  /* this is a slotted component; 
 				    append slot number to refdes. */
-    slot_value = o_attrib_search_slot(object, &slot_text_object);
+    slot_value = s_slot_search_slot (object, &slot_text_object);
 #if DEBUG
     printf(". . .  , found slotted component with slot = %s\n", slot_value);
 #endif
diff --git a/gschem/src/o_misc.c b/gschem/src/o_misc.c
index 2e57ff1..93275ff 100644
--- a/gschem/src/o_misc.c
+++ b/gschem/src/o_misc.c
@@ -776,7 +776,7 @@ void o_update_component(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
   s_delete_object_glist (toplevel, temp_list);
 
   /* update the pinnumbers to the current slot */
-  o_attrib_slot_update(toplevel, o_current);
+  s_slot_update_object (toplevel, o_current);
 
   /* Recalculate the bounds of the object */
   o_recalc_single_object(toplevel, o_current);
diff --git a/gschem/src/o_slot.c b/gschem/src/o_slot.c
index 4dd9fc2..d0bac60 100644
--- a/gschem/src/o_slot.c
+++ b/gschem/src/o_slot.c
@@ -119,7 +119,7 @@ void o_slot_end(GSCHEM_TOPLEVEL *w_current, const char *string, int len)
 
     /* first see if slot attribute already exists outside
      * complex */
-    slot_value = o_attrib_search_slot(object, &slot_text_object);
+    slot_value = s_slot_search_slot (object, &slot_text_object);
 
     if (slot_value) {
       o_text_set_string (toplevel, slot_text_object, string);
@@ -158,7 +158,7 @@ void o_slot_end(GSCHEM_TOPLEVEL *w_current, const char *string, int len)
     }
 
     o_invalidate (w_current, object);
-    o_attrib_slot_update(toplevel, object);
+    s_slot_update_object (toplevel, object);
 
     o_invalidate (w_current,object);
 
diff --git a/gschem/src/x_autonumber.c b/gschem/src/x_autonumber.c
index 9c07a49..ba123b9 100644
--- a/gschem/src/x_autonumber.c
+++ b/gschem/src/x_autonumber.c
@@ -587,7 +587,7 @@ void autonumber_remove_number(AUTONUMBER_TEXT * autotext, OBJECT *o_current)
     /* get the slot attribute */
     o_parent = o_current->attached_to;
     if (o_parent != NULL) {
-      slot_str = o_attrib_search_slot(o_parent, &o_slot);
+      slot_str = s_slot_search_slot (o_parent, &o_slot);
       if (slot_str != NULL && o_slot != NULL) {
         g_free(slot_str);
         /* delete the slot attribute */
@@ -617,7 +617,7 @@ void autonumber_apply_new_text(AUTONUMBER_TEXT * autotext, OBJECT *o_current,
   /* add the slot as attribute to the object */
   o_parent = o_current->attached_to;
   if (slot != 0 && o_parent != NULL) {
-    slot_str = o_attrib_search_slot(o_parent, &o_slot);
+    slot_str = s_slot_search_slot (o_parent, &o_slot);
     if (slot_str != NULL) {
       /* update the slot attribute */
       g_free(slot_str);
@@ -635,7 +635,6 @@ void autonumber_apply_new_text(AUTONUMBER_TEXT * autotext, OBJECT *o_current,
 			  INVISIBLE, SHOW_NAME_VALUE,
 			  o_parent);
     }
-    o_attrib_slot_update(autotext->w_current->toplevel, o_parent);
   }
 
   /* replace old text */
diff --git a/libgeda/include/libgeda/prototype.h b/libgeda/include/libgeda/prototype.h
index a716da5..1e47b5e 100644
--- a/libgeda/include/libgeda/prototype.h
+++ b/libgeda/include/libgeda/prototype.h
@@ -107,8 +107,6 @@ char *o_attrib_search_floating_attribs_by_name (const GList *list, char *name, i
 char *o_attrib_search_attached_attribs_by_name (OBJECT *object, char *name, int counter);
 char *o_attrib_search_inherited_attribs_by_name (OBJECT *object, char *name, int counter);
 char *o_attrib_search_object_attribs_by_name (OBJECT *object, char *name, int counter);
-char *o_attrib_search_slot(OBJECT *object, OBJECT **return_found);
-void o_attrib_slot_update(TOPLEVEL *toplevel, OBJECT *object);
 GList *o_attrib_return_attribs(OBJECT *object);
 int o_attrib_is_inherited(OBJECT *attrib);
 
@@ -412,6 +410,10 @@ void s_slib_print(void);
 int s_slib_uniq(char *path);
 void s_slib_print_dirs(void);
 
+/* s_slot.c */
+char *s_slot_search_slot(OBJECT *object, OBJECT **return_found);
+void s_slot_update_object(TOPLEVEL *toplevel, OBJECT *object);
+
 /* s_stretch.c */
 GList *s_stretch_add(GList *list, OBJECT *object, CONN *connection, int whichone);
 GList *s_stretch_remove(GList *list, OBJECT *object);
diff --git a/libgeda/include/prototype_priv.h b/libgeda/include/prototype_priv.h
index 44ccab0..fce2c75 100644
--- a/libgeda/include/prototype_priv.h
+++ b/libgeda/include/prototype_priv.h
@@ -107,6 +107,7 @@ GList *o_read_attribs(TOPLEVEL *toplevel,
                       TextBuffer *tb,
                       unsigned int release_ver,
                       unsigned int fileformat_ver);
+OBJECT *o_attrib_find_attrib_by_name(const GList *list, char *name, int count);
 
 /* o_basic.c */
 void o_bounds_invalidate(TOPLEVEL *toplevel, OBJECT *object);
diff --git a/libgeda/src/Makefile.am b/libgeda/src/Makefile.am
index 3a20a1c..7b10439 100644
--- a/libgeda/src/Makefile.am
+++ b/libgeda/src/Makefile.am
@@ -52,6 +52,7 @@ libgeda_la_SOURCES = \
 	s_papersizes.c \
 	s_path.c \
 	s_slib.c \
+	s_slot.c \
 	s_stretch.c \
 	s_textbuffer.c \
 	s_tile.c \
diff --git a/libgeda/src/a_basic.c b/libgeda/src/a_basic.c
index 1dfcd38..0c41d88 100644
--- a/libgeda/src/a_basic.c
+++ b/libgeda/src/a_basic.c
@@ -415,7 +415,7 @@ GList *o_read_buffer (TOPLEVEL *toplevel, GList *object_list,
         if (new_obj != NULL &&
             (new_obj->type == OBJ_COMPLEX ||
              new_obj->type == OBJ_PLACEHOLDER)) {
-          o_attrib_slot_update (toplevel, new_obj);
+          s_slot_update_object (toplevel, new_obj);
         }
 
         new_obj = NULL;
diff --git a/libgeda/src/o_attrib.c b/libgeda/src/o_attrib.c
index fcabd25..f7edafb 100644
--- a/libgeda/src/o_attrib.c
+++ b/libgeda/src/o_attrib.c
@@ -54,9 +54,6 @@
 #include <dmalloc.h>
 #endif
 
-/*! Basic string splitting delimiters */
-#define DELIMITERS ",; "
-
 
 /*! \brief Add an attribute to an existing attribute list.
  *  \par Function Description
@@ -461,7 +458,7 @@ GList *o_attrib_find_floating_attribs (const GList *list)
  *  \param [in] counter  Which occurance to return.
  *  \return The n'th attribute object in the given list with the given name.
  */
-static OBJECT *o_attrib_find_attrib_by_name (const GList *list, char *name, int count)
+OBJECT *o_attrib_find_attrib_by_name (const GList *list, char *name, int count)
 {
   OBJECT *a_current;
   const GList *iter;
@@ -618,187 +615,6 @@ char *o_attrib_search_object_attribs_by_name (OBJECT *object, char *name, int co
 }
 
 
-/*! \brief Search for slot attribute.
- *  \par Function Description
- *  Search for slot attribute.
- *
- *  The returned value will only come from an attached attribute.
- *
- *  \param [in] object        OBJECT list to search.
- *  \param [in] return_found  attached slot attribute if found, NULL otherwise.
- *  \return Character string with attribute value, NULL otherwise.
- *
- *  \warning
- *  Caller must g_free returned character string
- */
-char *o_attrib_search_slot(OBJECT *object, OBJECT **return_found)
-{
-  GList *attributes;
-  OBJECT *attrib;
-  char *value = NULL;
-
-  attributes = o_attrib_return_attribs (object);
-  attrib = o_attrib_find_attrib_by_name (attributes, "slot", 0);
-  g_list_free (attributes);
-
-  if (attrib != NULL)
-    o_attrib_get_name_value (attrib, NULL, &value);
-
-  if (return_found)
-    *return_found = attrib;
-
-  return value;
-}
-
-
-/*! \brief Search for slotdef attribute.
- *  \par Function Description
- *  Search for slotdef attribute.
- *
- *  \param [in] object      The OBJECT list to search.
- *  \param [in] slotnumber  The slot number to search for.
- *  \return Character string with attribute value, NULL otherwise.
- *
- *  \warning
- *  Caller must g_free returned character string.
- */
-static char *o_attrib_search_slotdef (OBJECT *object, int slotnumber)
-{
-  int counter = 0;
-  char *slotdef;
-  char *search_for;
-
-  search_for = g_strdup_printf ("%d:", slotnumber);
-
-  while (1) {
-    slotdef = o_attrib_search_object_attribs_by_name (object, "slotdef",
-                                                      counter++);
-    if (slotdef == NULL ||
-        strncmp (slotdef, search_for, strlen (search_for)) == 0)
-      break;
-
-    g_free (slotdef);
-  }
-
-  g_free (search_for);
-  return slotdef;
-}
-
-
-/*! \brief Update all slot attributes in an object.
- *  \par Function Description
- *  Update pinnumber attributes in a graphic object.
- *  The interesting case is where the object is an
- *  instantiation of a slotted part.  This means that
- *  o_attrib_slot_update iterates through all pins
- *  found on object and sets the pinnumber= attrib
- *  on each.  This doesn't matter for non-slotted
- *  parts, but on slotted parts, this is what sets the
- *  pinnumber= attribute on slots 2, 3, 4....
- *
- *  \param [in]     toplevel  The TOPLEVEL object.
- *  \param [in,out] object     The OBJECT to update.
- */
-void o_attrib_slot_update (TOPLEVEL *toplevel, OBJECT *object)
-{
-  OBJECT *o_pin_object;
-  OBJECT *o_pinnum_attrib;
-  GList *attributes;
-  char *string;
-  char *slotdef;
-  char *pinseq;
-  int slot;
-  int slot_string;
-  int pin_counter;    /* Internal pin counter private to this fcn. */
-  char* current_pin;  /* text from slotdef= to be made into pinnumber= */
-  char* cptr;         /* char pointer pointing to pinnumbers in slotdef=#:#,#,# string */
-
-  /* For this particular graphic object (component instantiation) */
-  /* get the slot number as a string */
-  string = o_attrib_search_object_attribs_by_name (object, "slot", 0);
-
-  if (string == NULL) {
-    /* Did not find slot= attribute.
-     * This happens if there is no attached slot attribute, and
-     * there is no default slot= attribute inside the symbol.
-     * Assume slot=1.
-     */
-    slot = 1;
-    slot_string = 0;
-  } else {
-    slot_string = 1;
-    slot = atoi (string);
-    g_free (string);
-  }
-
-  /* OK, now that we have the slot number, use it to get the */
-  /* corresponding slotdef=#:#,#,# string.  */
-  slotdef = o_attrib_search_slotdef (object, slot);
-
-  if (slotdef == NULL) {
-    if (slot_string) /* only an error if there's a slot string */
-      s_log_message (_("Did not find slotdef=#:#,#,#... attribute\n"));
-    return;
-  }
-
-  if (!strstr (slotdef, ":")) {
-    /* Didn't find proper slotdef=#:... put warning into log */
-    s_log_message (_("Improper slotdef syntax: missing \":\".\n"));
-    g_free (slotdef);
-    return;
-  }
-
-  /* skip over slotdef number */
-  /* slotdef is in the form #:#,#,# */
-  /* this code skips first #: */
-  cptr = slotdef;
-  while (*cptr != '\0' && *cptr != ':') {
-    cptr++;
-  }
-  cptr++; /* skip colon */
-
-  if (*cptr == '\0') {
-    s_log_message (_("Did not find proper slotdef=#:#,#,#... attribute\n"));
-    g_free (slotdef);
-    return;
-  }
-
-  /* loop on all pins found in slotdef= attribute */
-  pin_counter = 1;  /* internal pin_counter */
-  /* get current pinnumber= from slotdef= attrib */
-  current_pin = strtok (cptr, DELIMITERS);
-  while (current_pin != NULL) {
-    /* get pin on this component with pinseq == pin_counter */
-    pinseq = g_strdup_printf ("%d", pin_counter);
-    o_pin_object = o_complex_find_pin_by_attribute (object, "pinseq", pinseq);
-    g_free (pinseq);
-
-    if (o_pin_object != NULL) {
-      /* Now rename pinnumber= attrib on this part with value found */
-      /* in slotdef attribute  */
-      attributes = o_attrib_return_attribs (o_pin_object);
-      o_pinnum_attrib = o_attrib_find_attrib_by_name (attributes, "pinnumber", 0);
-      g_list_free (attributes);
-
-      if (o_pinnum_attrib != NULL) {
-        o_text_set_string (toplevel,
-                           o_pinnum_attrib,
-                           g_strdup_printf ("pinnumber=%s", current_pin));
-        o_text_recreate (toplevel, o_pinnum_attrib);
-      }
-
-      pin_counter++;
-    } else {
-      s_log_message (_("component missing pinseq= attribute\n"));
-    }
-
-    current_pin = strtok (NULL, DELIMITERS);
-  }
-
-  g_free (slotdef);
-}
-
-
 /*! \brief Get all attached attributes of the specified OBJECT.
  *  \par Function Description
  *  This function returns all attributes of the specified object.
diff --git a/libgeda/src/o_complex_basic.c b/libgeda/src/o_complex_basic.c
index 35aa709..3e2df60 100644
--- a/libgeda/src/o_complex_basic.c
+++ b/libgeda/src/o_complex_basic.c
@@ -835,7 +835,7 @@ OBJECT *o_complex_copy(TOPLEVEL *toplevel, OBJECT *o_current)
   /* Delete or hide attributes eligible for promotion inside the complex */
   o_complex_remove_promotable_attribs (toplevel, o_new);
 
-  o_attrib_slot_update (toplevel, o_new);
+  s_slot_update_object (toplevel, o_new);
 
   /* deal with stuff that has changed */
 
diff --git a/libgeda/src/o_list.c b/libgeda/src/o_list.c
index f0385f4..1bc8939 100644
--- a/libgeda/src/o_list.c
+++ b/libgeda/src/o_list.c
@@ -206,7 +206,7 @@ GList *o_glist_copy_all (TOPLEVEL *toplevel,
                         src_object->attached_to->copied_to, FALSE);
         /* handle slot= attribute, it's a special case */
         if (g_ascii_strncasecmp (dst_object->text->string, "slot=", 5) == 0)
-          o_attrib_slot_update (toplevel, src_object->attached_to->copied_to);
+          s_slot_update_object (toplevel, src_object->attached_to->copied_to);
       }
     }
 
diff --git a/libgeda/src/s_slot.c b/libgeda/src/s_slot.c
new file mode 100644
index 0000000..cd89fdf
--- /dev/null
+++ b/libgeda/src/s_slot.c
@@ -0,0 +1,221 @@
+/* gEDA - GPL Electronic Design Automation
+ * libgeda - gEDA's library
+ * Copyright (C) 1998-2008 Ales Hvezda
+ * Copyright (C) 1998-2008 gEDA Contributors (see ChangeLog for details)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
+ */
+
+/*! \file s_slot.c
+ *  \brief utility functions for slotted components
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#include <math.h>
+
+#include "libgeda_priv.h"
+
+#ifdef HAVE_LIBDMALLOC
+#include <dmalloc.h>
+#endif
+
+/*! Basic string splitting delimiters */
+#define DELIMITERS ",; "
+
+
+/*! \brief Search for slot attribute.
+ *  \par Function Description
+ *  Search for slot attribute.
+ *
+ *  The returned value will only come from an attached attribute.
+ *
+ *  \param [in] object        OBJECT list to search.
+ *  \param [in] return_found  attached slot attribute if found, NULL otherwise.
+ *  \return Character string with attribute value, NULL otherwise.
+ *
+ *  \warning
+ *  Caller must g_free returned character string
+ */
+char *s_slot_search_slot (OBJECT *object, OBJECT **return_found)
+{
+  GList *attributes;
+  OBJECT *attrib;
+  char *value = NULL;
+
+  attributes = o_attrib_return_attribs (object);
+  attrib = o_attrib_find_attrib_by_name (attributes, "slot", 0);
+  g_list_free (attributes);
+
+  if (attrib != NULL)
+    o_attrib_get_name_value (attrib, NULL, &value);
+
+  if (return_found)
+    *return_found = attrib;
+
+  return value;
+}
+
+
+/*! \brief Search for slotdef attribute.
+ *  \par Function Description
+ *  Search for slotdef attribute.
+ *
+ *  \param [in] object      The OBJECT list to search.
+ *  \param [in] slotnumber  The slot number to search for.
+ *  \return Character string with attribute value, NULL otherwise.
+ *
+ *  \warning
+ *  Caller must g_free returned character string.
+ */
+static char *s_slot_search_slotdef (OBJECT *object, int slotnumber)
+{
+  int counter = 0;
+  char *slotdef;
+  char *search_for;
+
+  search_for = g_strdup_printf ("%d:", slotnumber);
+
+  while (1) {
+    slotdef = o_attrib_search_object_attribs_by_name (object, "slotdef",
+                                                      counter++);
+    if (slotdef == NULL ||
+        strncmp (slotdef, search_for, strlen (search_for)) == 0)
+      break;
+
+    g_free (slotdef);
+  }
+
+  g_free (search_for);
+  return slotdef;
+}
+
+
+/*! \brief Update all slot attributes in an object.
+ *  \par Function Description
+ *  Update pinnumber attributes in a graphic object.
+ *  The interesting case is where the object is an
+ *  instantiation of a slotted part.  This means that
+ *  s_slot_update_object iterates through all pins
+ *  found on object and sets the pinnumber= attrib
+ *  on each.  This doesn't matter for non-slotted
+ *  parts, but on slotted parts, this is what sets the
+ *  pinnumber= attribute on slots 2, 3, 4....
+ *
+ *  \param [in]     toplevel  The TOPLEVEL object.
+ *  \param [in,out] object     The OBJECT to update.
+ */
+void s_slot_update_object (TOPLEVEL *toplevel, OBJECT *object)
+{
+  OBJECT *o_pin_object;
+  OBJECT *o_pinnum_attrib;
+  GList *attributes;
+  char *string;
+  char *slotdef;
+  char *pinseq;
+  int slot;
+  int slot_string;
+  int pin_counter;    /* Internal pin counter private to this fcn. */
+  char* current_pin;  /* text from slotdef= to be made into pinnumber= */
+  char* cptr;         /* char pointer pointing to pinnumbers in slotdef=#:#,#,# string */
+
+  /* For this particular graphic object (component instantiation) */
+  /* get the slot number as a string */
+  string = o_attrib_search_object_attribs_by_name (object, "slot", 0);
+
+  if (string == NULL) {
+    /* Did not find slot= attribute.
+     * This happens if there is no attached slot attribute, and
+     * there is no default slot= attribute inside the symbol.
+     * Assume slot=1.
+     */
+    slot = 1;
+    slot_string = 0;
+  } else {
+    slot_string = 1;
+    slot = atoi (string);
+    g_free (string);
+  }
+
+  /* OK, now that we have the slot number, use it to get the */
+  /* corresponding slotdef=#:#,#,# string.  */
+  slotdef = s_slot_search_slotdef (object, slot);
+
+  if (slotdef == NULL) {
+    if (slot_string) /* only an error if there's a slot string */
+      s_log_message (_("Did not find slotdef=#:#,#,#... attribute\n"));
+    return;
+  }
+
+  if (!strstr (slotdef, ":")) {
+    /* Didn't find proper slotdef=#:... put warning into log */
+    s_log_message (_("Improper slotdef syntax: missing \":\".\n"));
+    g_free (slotdef);
+    return;
+  }
+
+  /* skip over slotdef number */
+  /* slotdef is in the form #:#,#,# */
+  /* this code skips first #: */
+  cptr = slotdef;
+  while (*cptr != '\0' && *cptr != ':') {
+    cptr++;
+  }
+  cptr++; /* skip colon */
+
+  if (*cptr == '\0') {
+    s_log_message (_("Did not find proper slotdef=#:#,#,#... attribute\n"));
+    g_free (slotdef);
+    return;
+  }
+
+  /* loop on all pins found in slotdef= attribute */
+  pin_counter = 1;  /* internal pin_counter */
+  /* get current pinnumber= from slotdef= attrib */
+  current_pin = strtok (cptr, DELIMITERS);
+  while (current_pin != NULL) {
+    /* get pin on this component with pinseq == pin_counter */
+    pinseq = g_strdup_printf ("%d", pin_counter);
+    o_pin_object = o_complex_find_pin_by_attribute (object, "pinseq", pinseq);
+    g_free (pinseq);
+
+    if (o_pin_object != NULL) {
+      /* Now rename pinnumber= attrib on this part with value found */
+      /* in slotdef attribute  */
+      attributes = o_attrib_return_attribs (o_pin_object);
+      o_pinnum_attrib = o_attrib_find_attrib_by_name (attributes, "pinnumber", 0);
+      g_list_free (attributes);
+
+      if (o_pinnum_attrib != NULL) {
+        o_text_set_string (toplevel,
+                           o_pinnum_attrib,
+                           g_strdup_printf ("pinnumber=%s", current_pin));
+        o_text_recreate (toplevel, o_pinnum_attrib);
+      }
+
+      pin_counter++;
+    } else {
+      s_log_message (_("component missing pinseq= attribute\n"));
+    }
+
+    current_pin = strtok (NULL, DELIMITERS);
+  }
+
+  g_free (slotdef);
+}

commit 3e6e56f8840a5df6512e9305879d75afd9ece373
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    Use o_text_set_string() to adjust attribute values
    
    Avoids re-writing the text->string member directly.

diff --git a/libgeda/src/o_attrib.c b/libgeda/src/o_attrib.c
index 117ff91..fcabd25 100644
--- a/libgeda/src/o_attrib.c
+++ b/libgeda/src/o_attrib.c
@@ -781,8 +781,9 @@ void o_attrib_slot_update (TOPLEVEL *toplevel, OBJECT *object)
       g_list_free (attributes);
 
       if (o_pinnum_attrib != NULL) {
-        g_free (o_pinnum_attrib->text->string);
-        o_pinnum_attrib->text->string = g_strdup_printf ("pinnumber=%s", current_pin);
+        o_text_set_string (toplevel,
+                           o_pinnum_attrib,
+                           g_strdup_printf ("pinnumber=%s", current_pin));
         o_text_recreate (toplevel, o_pinnum_attrib);
       }
 




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs