From db224105a7117b41d033739d1e73308c4dbd784a Mon Sep 17 00:00:00 2001 From: "R. Timothy Edwards" Date: Wed, 13 May 2026 09:46:21 -0400 Subject: [PATCH] Found another couple of places where the environment variable HOME was checked but no check was made on whether or not the result was NULL. This resolves issue #490 in the github issue tracker. Also: Modified the way that "select visible" works to check if labels and/or cells are rendered visible in the window. If not, then they are not selected. Previously, cell instances and labels would be selected whether or not they were visible. This resolves issue #503 in the github issue tracker. --- commands/CmdRS.c | 12 ++++++++++-- database/DBio.c | 15 ++++++++------- select/selCreate.c | 5 ++--- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/commands/CmdRS.c b/commands/CmdRS.c index fb01bd68..4ed1f16b 100644 --- a/commands/CmdRS.c +++ b/commands/CmdRS.c @@ -635,9 +635,17 @@ cmdSelectArea( int i; for (i = 0; i < DBNumUserLayers; i++) { - if((TTMaskHasType(&mask, i)) && !(TTMaskHasType(&crec->dbw_visibleLayers, i))) + if ((TTMaskHasType(&mask, i)) && + !(TTMaskHasType(&crec->dbw_visibleLayers, i))) TTMaskClearType(&mask, i); } + + /* Remove L_CELL and L_LABEL if crec->dbw_flags indicates that + * they are not visible in the layout window. + */ + + if (!(crec->dbw_flags & DBW_SEELABELS)) TTMaskClearType(&mask, L_LABEL); + if (!(crec->dbw_flags & DBW_SEECELLS)) TTMaskClearType(&mask, L_CELL); } SelectArea(&scx, &mask, crec->dbw_bitmask, globmatch); } @@ -1027,7 +1035,7 @@ CmdSelect( /*-------------------------------------------------------------------- * Select everything under the box, perhaps looking only at - * particular layers, but only if its visible. + * particular layers, but only if it's visible. *-------------------------------------------------------------------- */ diff --git a/database/DBio.c b/database/DBio.c index c8173d9f..82828907 100644 --- a/database/DBio.c +++ b/database/DBio.c @@ -2016,8 +2016,8 @@ badTransform: if ((cellDef->cd_file != NULL) && (cellDef->cd_file[0] == '/')) { char *homedir = getenv("HOME"); - if (strncmp(cellDef->cd_file, homedir, strlen(homedir)) || - *(cellDef->cd_file + strlen(homedir)) != '/') + if (homedir && (strncmp(cellDef->cd_file, homedir, strlen(homedir)) || + *(cellDef->cd_file + strlen(homedir)) != '/')) { char *homeroot = strrchr(homedir, '/'); int rootlen = (int)(homeroot - homedir) + 1; @@ -2060,9 +2060,10 @@ badTransform: if (*pathptr == '~') { char *homedir = getenv("HOME"); - if (!strncmp(subCellDef->cd_file, homedir, strlen(homedir)) - && (!strcmp(subCellDef->cd_file + strlen(homedir), - pathptr + 1))) + if (homedir && (!strncmp(subCellDef->cd_file, homedir, + strlen(homedir)) && + (!strcmp(subCellDef->cd_file + strlen(homedir), + pathptr + 1)))) pathOK = TRUE; } else if (!strcmp(cwddir, pathptr)) pathOK = TRUE; @@ -2254,9 +2255,9 @@ badTransform: /* Check if the path is the same as the current directory */ char *homedir = getenv("HOME"); - if (!strncmp(cwddir, homedir, strlen(homedir)) + if (homedir && (!strncmp(cwddir, homedir, strlen(homedir)) && (!strcmp(cwddir + strlen(homedir), - pathptr + 1))) + pathptr + 1)))) pathOK = TRUE; } else if (!strcmp(cwddir, pathptr)) pathOK = TRUE; diff --git a/select/selCreate.c b/select/selCreate.c index dfa6c433..571714af 100644 --- a/select/selCreate.c +++ b/select/selCreate.c @@ -471,12 +471,11 @@ SelectArea(scx, types, xMask, globmatch) if (TTMaskHasType(types, L_LABEL)) { if (globmatch != NULL) - DBCellCopyGlobLabels(scx, &DBAllTypeBits, xMask, SelectUse, &labelArea, + DBCellCopyGlobLabels(scx, types, xMask, SelectUse, &labelArea, globmatch); else - DBCellCopyAllLabels(scx, &DBAllTypeBits, xMask, SelectUse, &labelArea); + DBCellCopyAllLabels(scx, types, xMask, SelectUse, &labelArea); } - else (void) DBCellCopyAllLabels(scx, types, xMask, SelectUse, &labelArea); /* Select cell uses. */