From c86d3ebb602d98dcbec9d379ec06c450f1a810f7 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Wed, 7 Oct 2020 16:07:36 -0400 Subject: [PATCH] Another update that properly deals with the "port" command for limiting search to non-port labels or to port labels only, depending on the command option (which was previously not implemented properly). --- commands/CmdLQ.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/commands/CmdLQ.c b/commands/CmdLQ.c index 3f1b25ae..c0bf6ce9 100644 --- a/commands/CmdLQ.c +++ b/commands/CmdLQ.c @@ -1115,6 +1115,7 @@ cmdPortLabelFunc2(scx, label, tpath, cdata) /* Find a label in the cell editDef. */ /* */ /* If "port" is true, then search only for labels that are ports. */ +/* If false, then search only for labels that are not ports. */ /* If "unique" is true, then return a label only if exactly one label */ /* is found in the edit box. */ /*----------------------------------------------------------------------*/ @@ -1123,10 +1124,10 @@ Label * portFindLabel(editDef, port, unique, nonEdit) CellDef *editDef; bool unique; - bool port; + bool port; // If TRUE, only look for labels that are ports bool *nonEdit; // TRUE if label is not in the edit cell { - int found; + int found, wrongkind; Label *lab, *sl; Rect editBox; @@ -1138,10 +1139,19 @@ portFindLabel(editDef, port, unique, nonEdit) ToolGetEditBox(&editBox); found = 0; + wrongkind = FALSE; if (nonEdit) *nonEdit = FALSE; lab = NULL; for (sl = editDef->cd_labels; sl != NULL; sl = sl->lab_next) { + /* Ignore labels based on whether label is or is not a port */ + if (((port == TRUE) && !(sl->lab_flags & PORT_DIR_MASK)) || + ((port == FALSE) && (sl->lab_flags & PORT_DIR_MASK))) + { + wrongkind = TRUE; /* Found at least one label of the wrong kind */ + continue; + } + if (GEO_OVERLAP(&editBox, &sl->lab_rect) || GEO_SURROUND(&editBox, &sl->lab_rect)) { @@ -1167,11 +1177,13 @@ portFindLabel(editDef, port, unique, nonEdit) if (nonEdit) *nonEdit = FALSE; } } + if ((found == 0) && (wrongkind == TRUE)) return NULL; /* If no label was found, then search the hierarchy under the box. */ /* The calling routine may determine whether a label that is not in */ /* the edit cell may be valid for the command (e.g., if querying */ - /* but not changing values). */ + /* but not changing values). NOTE: Currently this does not apply */ + /* the "port" option. */ if (found == 0) {