From ba142b8747fa34c6106d81bd4dff34c45ac3673a Mon Sep 17 00:00:00 2001 From: Bernd Jendrissek Date: Wed, 3 Jun 2015 00:52:25 +0200 Subject: [PATCH] Support default return value in o_complex_get_refdes. --- gattrib/src/s_attrib.c | 13 ++++--------- gnetlist/src/s_traverse.c | 5 ----- gschem/src/x_dialog.c | 4 ++-- libgeda/include/libgeda/prototype.h | 2 +- libgeda/src/g_smob.c | 6 +++--- libgeda/src/o_complex_basic.c | 9 +++------ 6 files changed, 13 insertions(+), 26 deletions(-) diff --git a/gattrib/src/s_attrib.c b/gattrib/src/s_attrib.c index 44a4ebf36..37898cd13 100644 --- a/gattrib/src/s_attrib.c +++ b/gattrib/src/s_attrib.c @@ -84,18 +84,13 @@ char *s_attrib_get_refdes(OBJECT *object) OBJECT *slot_text_object; /*------ Try to get the refdes -----*/ - temp_uref = o_attrib_search_name_single(object, "refdes", NULL); + temp_uref = o_complex_get_refdes(object, NULL); if (!temp_uref) { - temp_uref = o_attrib_search_name_single(object, "uref", NULL); // deprecated - if (temp_uref) { - printf("WARNING: Found uref=%s, uref= is deprecated, please use refdes=\n", temp_uref); - } else { /* didn't find refdes. Report error to log. */ #ifdef DEBUG - printf("In s_attrib_get_refdes, found non-graphical component with no refdes.\n"); - printf(". . . . complex_basename = %s.\n", object->complex_basename); + printf("In s_attrib_get_refdes, found non-graphical component with no refdes.\n"); + printf(". . . . complex_basename = %s.\n", object->complex_basename); #endif - return NULL; - } + return NULL; } #ifdef DEBUG diff --git a/gnetlist/src/s_traverse.c b/gnetlist/src/s_traverse.c index a042c0334..eab447809 100644 --- a/gnetlist/src/s_traverse.c +++ b/gnetlist/src/s_traverse.c @@ -135,8 +135,6 @@ s_traverse_sheet(TOPLEVEL * pr_current, OBJECT *o_current, netlist = s_netlist_return_tail(graphical_netlist_head); is_graphical = TRUE; - - } netlist = s_netlist_add(netlist); netlist->nlid = o_current->sid; @@ -163,7 +161,6 @@ s_traverse_sheet(TOPLEVEL * pr_current, OBJECT *o_current, netlist->object_ptr = o_current; if (!netlist->component_uref) { - /* search of net attribute */ /* maybe symbol is not a component */ /* but a power / gnd symbol */ @@ -173,7 +170,6 @@ s_traverse_sheet(TOPLEVEL * pr_current, OBJECT *o_current, /* nope net attribute not found */ if ( (!temp) && (!is_graphical) ) { - fprintf(stderr, "Could not find refdes on component and could not find any special attributes!\n"); @@ -187,7 +183,6 @@ s_traverse_sheet(TOPLEVEL * pr_current, OBJECT *o_current, netlist->component_uref = NULL; g_free(temp); } - } netlist->cpins = diff --git a/gschem/src/x_dialog.c b/gschem/src/x_dialog.c index fab0d1010..60de72801 100644 --- a/gschem/src/x_dialog.c +++ b/gschem/src/x_dialog.c @@ -2459,7 +2459,7 @@ void slot_chooser_visitor(OBJECT *o_current, void *context) /* Save the treestore iterator. */ parent_row = tree_parent->row; - refdes = o_complex_get_refdes(o_current); + refdes = o_complex_get_refdes(o_current, _("(unknown part)")); /* Add a row for the part as a whole. */ treeview = tree_parent->treeview; @@ -2605,7 +2605,7 @@ void slot_chooser_dialog(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, return; } scwindow = GTK_WINDOW(widget); - refdes = o_complex_get_refdes(o_current); + refdes = o_complex_get_refdes(o_current, _("(unknown part)")); if (refdes) { char *title, *slotname; diff --git a/libgeda/include/libgeda/prototype.h b/libgeda/include/libgeda/prototype.h index b419c4d82..f3a531542 100644 --- a/libgeda/include/libgeda/prototype.h +++ b/libgeda/include/libgeda/prototype.h @@ -207,7 +207,7 @@ int world_get_object_glist_bounds(GList const *o_list, int *left, int *top, int *right, int *bottom); OBJECT *new_head(TOPLEVEL *toplevel); -char *o_complex_get_refdes(OBJECT const *o_current); +char *o_complex_get_refdes(OBJECT const *o_current, char const *default_value); int o_complex_is_embedded(OBJECT const *o_current); GList *o_complex_get_toplevel_attribs(OBJECT *o_head); GList *o_complex_get_promotable (TOPLEVEL *toplevel, OBJECT *object, int detach); diff --git a/libgeda/src/g_smob.c b/libgeda/src/g_smob.c index 4f3186964..04edba547 100644 --- a/libgeda/src/g_smob.c +++ b/libgeda/src/g_smob.c @@ -801,7 +801,7 @@ SCM g_swap_pins(SCM component, SCM n1, SCM n2) } if (shorted_pads) { - char *refdes = o_complex_get_refdes(owner); + char *refdes = o_complex_get_refdes(owner, _("(unknown part)")); g_warning(_("Component %s # has shorted pads\n"), refdes, owner->name); @@ -856,7 +856,7 @@ SCM g_swap_pins(SCM component, SCM n1, SCM n2) if (pad1_seen != 1 || pad2_seen != 1) { /* Component doesn't have exactly one of each of the named pads. */ - char *refdes = o_complex_get_refdes(owner); + char *refdes = o_complex_get_refdes(owner, _("(unknown part)")); scm_dynwind_unwind_handler(g_free, refdes, SCM_F_WIND_EXPLICITLY); g_warning(_("Component %s # has broken vpads attribute\n"), @@ -871,7 +871,7 @@ SCM g_swap_pins(SCM component, SCM n1, SCM n2) o_text_change(attrib, vpads, attrib->visibility, attrib->show_name_value); } else { /* Component doesn't support pin swapping at all. */ - char *refdes = o_complex_get_refdes(owner); + char *refdes = o_complex_get_refdes(owner, _("(unknown part)")); scm_dynwind_unwind_handler(g_free, refdes, SCM_F_WIND_EXPLICITLY); g_warning(_("Component %s # does not support pin swapping\n"), diff --git a/libgeda/src/o_complex_basic.c b/libgeda/src/o_complex_basic.c index ceabf19d0..83ecce4bd 100644 --- a/libgeda/src/o_complex_basic.c +++ b/libgeda/src/o_complex_basic.c @@ -245,7 +245,8 @@ OBJECT *new_head(TOPLEVEL *toplevel) return new_node; } -char *o_complex_get_refdes(OBJECT const *o_current) +char *o_complex_get_refdes(OBJECT const *o_current, + char const *default_value) { char *refdes; @@ -254,7 +255,7 @@ char *o_complex_get_refdes(OBJECT const *o_current) if (refdes == NULL) { refdes = o_attrib_search_name_single((OBJECT *) o_current, "uref", NULL); if (refdes == NULL) { - refdes = g_strdup("(unknown part)"); + refdes = default_value ? g_strdup(default_value) : NULL; } } @@ -556,7 +557,6 @@ OBJECT *o_complex_new(TOPLEVEL *toplevel, toplevel->ADDING_SEL = 1; /* name is hack, don't want to */ if (clib == NULL || buffer == NULL) { - OBJECT *save_prim_objs; char *not_found_text = NULL; int left, right, top, bottom; @@ -635,9 +635,7 @@ OBJECT *o_complex_new(TOPLEVEL *toplevel, VISIBLE, SHOW_NAME_VALUE); prim_objs = s_basic_link_object(new_prim_obj, prim_objs); prim_objs = save_prim_objs; - } else { - /* filename was found */ loaded_normally = TRUE; @@ -645,7 +643,6 @@ OBJECT *o_complex_new(TOPLEVEL *toplevel, o_read_buffer(toplevel, prim_objs, buffer, -1, new_node->complex_basename); g_free (buffer); - } toplevel->ADDING_SEL = save_adding_sel; -- 2.11.4.GIT