From d8f926865dd24ac78558e939f5c816cdc2cb4eb8 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Mon, 20 Mar 2023 21:00:35 -0400 Subject: [PATCH] Modified the behavior of cell reading, mainly with respect to dereferencing, and making the behavior of "load" on the command line (i.e., loading a cell from a file) the same as the behavior of loading a cell as a result of expanding an unloaded instance. In both cases, if "load -dereference" is used, and a cell does not exist in any search path but does exist in the original location, without dereferencing, then the cell will be loaded from the original location. Also: Corrected an error that has existed since adding the capability to read compressed files, which causes magic to crash when attempting to run the "crash recover" command (because that routine was mixing compressed and regular file stream calls). --- VERSION | 2 +- calma/CalmaWrite.c | 2 +- calma/CalmaWriteZ.c | 2 +- cif/CIFwrite.c | 2 +- commands/CmdCD.c | 2 +- commands/CmdE.c | 2 +- commands/CmdSubrs.c | 2 +- database/DBcellsrch.c | 18 ++++----- database/DBcellsubr.c | 2 +- database/DBexpand.c | 8 ++-- database/DBio.c | 60 ++++++++++++----------------- database/DBlabel2.c | 4 +- database/DBtimestmp.c | 2 +- dbwind/DBWprocs.c | 87 ++++++++++++++++++++++++++++++++----------- drc/DRCmain.c | 2 +- extract/ExtInter.c | 4 +- graphics/W3Dmain.c | 2 +- lef/defRead.c | 2 +- sim/SimDBstuff.c | 2 +- 19 files changed, 119 insertions(+), 88 deletions(-) diff --git a/VERSION b/VERSION index 6036b47e..0fcb5ebb 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.3.382 +8.3.383 diff --git a/calma/CalmaWrite.c b/calma/CalmaWrite.c index 82349992..ee76aed3 100644 --- a/calma/CalmaWrite.c +++ b/calma/CalmaWrite.c @@ -892,7 +892,7 @@ calmaProcessDef(def, outf, do_library) if ((def->cd_flags & CDAVAILABLE) == 0) { bool dereference = (def->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - if (!DBCellRead(def, (char *) NULL, TRUE, dereference, NULL)) + if (!DBCellRead(def, TRUE, dereference, NULL)) return (0); } diff --git a/calma/CalmaWriteZ.c b/calma/CalmaWriteZ.c index 2877fce5..200290af 100644 --- a/calma/CalmaWriteZ.c +++ b/calma/CalmaWriteZ.c @@ -843,7 +843,7 @@ calmaProcessDefZ(def, outf, do_library) if ((def->cd_flags & CDAVAILABLE) == 0) { bool dereference = (def->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - if (!DBCellRead(def, (char *) NULL, TRUE, dereference, NULL)) + if (!DBCellRead(def, TRUE, dereference, NULL)) return (0); } diff --git a/cif/CIFwrite.c b/cif/CIFwrite.c index 22265db8..d5313a63 100644 --- a/cif/CIFwrite.c +++ b/cif/CIFwrite.c @@ -319,7 +319,7 @@ cifOut(outf) if ((def->cd_flags & CDAVAILABLE) == 0) { bool dereference = (def->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - if (!DBCellRead(def, (char *) NULL, TRUE, dereference, NULL)) continue; + if (!DBCellRead(def, TRUE, dereference, NULL)) continue; } /* Add any subcells to the stack. This must be done before diff --git a/commands/CmdCD.c b/commands/CmdCD.c index 822e8de8..4ca3caeb 100644 --- a/commands/CmdCD.c +++ b/commands/CmdCD.c @@ -4741,7 +4741,7 @@ cmdDumpParseArgs(cmdName, w, cmd, dummy, scx) */ def->cd_flags &= ~CDNOTFOUND; dereference = (def->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - if (!DBCellRead(def, (char *) NULL, TRUE, dereference, NULL)) + if (!DBCellRead(def, TRUE, dereference, NULL)) return (FALSE); DBReComputeBbox(def); dummy->cu_def = def; diff --git a/commands/CmdE.c b/commands/CmdE.c index 0054fdf7..1197f09b 100644 --- a/commands/CmdE.c +++ b/commands/CmdE.c @@ -137,7 +137,7 @@ CmdEdit(w, cmd) { bool dereference = (EditCellUse->cu_def->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - DBCellRead(EditCellUse->cu_def, (char *)NULL, TRUE, dereference, NULL); + DBCellRead(EditCellUse->cu_def, TRUE, dereference, NULL); } if (EditCellUse->cu_def->cd_flags & CDNOEDIT) diff --git a/commands/CmdSubrs.c b/commands/CmdSubrs.c index 53feb07f..692afce0 100644 --- a/commands/CmdSubrs.c +++ b/commands/CmdSubrs.c @@ -325,7 +325,7 @@ cmdFlushCell(def, force_deref) DBCellClearDef(def); DBCellClearAvail(def); dereference = (def->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - (void) DBCellRead(def, (char *) NULL, TRUE, dereference, NULL); + (void) DBCellRead(def, TRUE, dereference, NULL); DBCellSetAvail(def); DBReComputeBbox(def); DBCellSetModified(def, FALSE); diff --git a/database/DBcellsrch.c b/database/DBcellsrch.c index 69c5e074..cceee44a 100644 --- a/database/DBcellsrch.c +++ b/database/DBcellsrch.c @@ -244,7 +244,7 @@ dbCellPlaneSrFunc(scx, fp) if ((def->cd_flags & CDAVAILABLE) == 0) { bool dereference = (def->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - if (!DBCellRead(def, (char *) NULL, TRUE, dereference, NULL)) return 0; + if (!DBCellRead(def, TRUE, dereference, NULL)) return 0; } context.tc_scx = scx; @@ -366,7 +366,7 @@ dbCellUniqueTileSrFunc(scx, fp) if ((def->cd_flags & CDAVAILABLE) == 0) { bool dereference = (def->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - if (!DBCellRead(def, (char *) NULL, TRUE, dereference, NULL)) return 0; + if (!DBCellRead(def, TRUE, dereference, NULL)) return 0; } context.tc_scx = scx; @@ -478,7 +478,7 @@ DBNoTreeSrTiles(scx, mask, xMask, func, cdarg) if ((def->cd_flags & CDAVAILABLE) == 0) { bool dereference = (def->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - if (!DBCellRead(def, (char *) NULL, TRUE, dereference, NULL)) return 0; + if (!DBCellRead(def, TRUE, dereference, NULL)) return 0; } filter.tf_func = func; @@ -589,7 +589,7 @@ DBTreeSrLabels(scx, mask, xMask, tpath, flags, func, cdarg) if ((def->cd_flags & CDAVAILABLE) == 0) { bool dereference = (def->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - if (!DBCellRead(def, (char *) NULL, TRUE, dereference, NULL)) return 0; + if (!DBCellRead(def, TRUE, dereference, NULL)) return 0; } for (lab = def->cd_labels; lab; lab = lab->lab_next) @@ -696,7 +696,7 @@ dbCellLabelSrFunc(scx, fp) if ((def->cd_flags & CDAVAILABLE) == 0) { bool dereference = (def->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - if (!DBCellRead(def, (char *) NULL, TRUE, dereference, NULL)) return 0; + if (!DBCellRead(def, TRUE, dereference, NULL)) return 0; } /* Do not add a path name of a top level window */ @@ -820,7 +820,7 @@ DBTreeSrCells(scx, xMask, func, cdarg) if ((cellUse->cu_def->cd_flags & CDAVAILABLE) == 0) { bool dereference = (cellUse->cu_def->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - if (!DBCellRead(cellUse->cu_def, (char *) NULL, TRUE, dereference, NULL)) + if (!DBCellRead(cellUse->cu_def, TRUE, dereference, NULL)) return 0; } @@ -868,7 +868,7 @@ dbTreeCellSrFunc(scx, fp) if ((use->cu_def->cd_flags & CDAVAILABLE) == 0) { bool dereference = (use->cu_def->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - if (!DBCellRead(use->cu_def, (char *) NULL, TRUE, dereference, NULL)) + if (!DBCellRead(use->cu_def, TRUE, dereference, NULL)) return 0; } } @@ -1129,7 +1129,7 @@ DBCellSrArea(scx, func, cdarg) { bool dereference = (scx->scx_use->cu_def->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - if (!DBCellRead(scx->scx_use->cu_def, (char *) NULL, TRUE, dereference, NULL)) + if (!DBCellRead(scx->scx_use->cu_def, TRUE, dereference, NULL)) return 0; } @@ -1255,7 +1255,7 @@ DBCellEnum(cellDef, func, cdarg) if ((cellDef->cd_flags & CDAVAILABLE) == 0) { bool dereference = (cellDef->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - if (!DBCellRead(cellDef, (char *) NULL, TRUE, dereference, NULL)) return 0; + if (!DBCellRead(cellDef, TRUE, dereference, NULL)) return 0; } if (DBSrCellPlaneArea(cellDef->cd_cellPlane, &TiPlaneRect, dbEnumFunc, (ClientData) &filter)) diff --git a/database/DBcellsubr.c b/database/DBcellsubr.c index b9c60b47..52eacb24 100644 --- a/database/DBcellsubr.c +++ b/database/DBcellsubr.c @@ -79,7 +79,7 @@ DBDescendSubcell(use, xMask) { bool dereference = (use->cu_def->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - if (!DBCellRead(use->cu_def, (char *) NULL, TRUE, dereference, NULL)) + if (!DBCellRead(use->cu_def, TRUE, dereference, NULL)) return FALSE; } return (DBIsSubcircuit(use->cu_def)) ? FALSE : TRUE; diff --git a/database/DBexpand.c b/database/DBexpand.c index 71cb6b79..2f076791 100644 --- a/database/DBexpand.c +++ b/database/DBexpand.c @@ -83,7 +83,7 @@ DBExpand(cellUse, expandMask, expandFlag) if ((def->cd_flags & CDAVAILABLE) == 0) { bool dereference = (def->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - if (!DBCellRead(def, (char *) NULL, TRUE, dereference, NULL)) + if (!DBCellRead(def, TRUE, dereference, NULL)) return; /* Note: we don't have to recompute the bbox here, because * if it changed, then a timestamp violation must have occurred @@ -149,7 +149,7 @@ DBExpandAll(rootUse, rootRect, expandMask, expandFlag, func, cdarg) if ((rootUse->cu_def->cd_flags & CDAVAILABLE) == 0) { - (void) DBCellRead(rootUse->cu_def, (char *) NULL, TRUE, dereference, NULL); + (void) DBCellRead(rootUse->cu_def, TRUE, dereference, NULL); } /* @@ -200,7 +200,7 @@ dbExpandFunc(scx, arg) /* If the cell is unavailable, then don't expand it. */ if ((childUse->cu_def->cd_flags & CDAVAILABLE) == 0) - if(!DBCellRead(childUse->cu_def, (char *) NULL, TRUE, arg->ea_deref, NULL)) + if(!DBCellRead(childUse->cu_def, TRUE, arg->ea_deref, NULL)) { TxError("Cell %s is unavailable. It could not be expanded.\n", childUse->cu_def->cd_name); @@ -317,7 +317,7 @@ dbReadAreaFunc(scx, halt_on_error) if ((def->cd_flags & CDAVAILABLE) == 0) { bool dereference = (def->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - if (DBCellRead(def, (char *)NULL, TRUE, dereference, NULL) == FALSE) + if (DBCellRead(def, TRUE, dereference, NULL) == FALSE) if (halt_on_error) return 1; diff --git a/database/DBio.c b/database/DBio.c index 28871a85..bd407034 100644 --- a/database/DBio.c +++ b/database/DBio.c @@ -414,13 +414,9 @@ DBAddStandardCellPaths(pathptr, level) */ bool -dbCellReadDef(f, cellDef, name, ignoreTech, dereference) +dbCellReadDef(f, cellDef, ignoreTech, dereference) FILETYPE f; /* The file, already opened by the caller */ CellDef *cellDef; /* Pointer to definition of cell to be read in */ - char *name; /* Name of file from which to read definition. - * If NULL, then use cellDef->cd_file; if that - * is NULL try the name of the cell. - */ bool ignoreTech; /* If FALSE then the technology of the file MUST * match the current technology, or else the * subroutine will return an error condition @@ -1088,13 +1084,13 @@ bool DBReadBackup(name) char *name; /* Name of the backup file */ { - FILE *f; + FILETYPE f; char *filename, *rootname, *chrptr; char line[256]; CellDef *cellDef; bool result = TRUE; - if ((f = PaOpen(name, "r", NULL, "", NULL, NULL)) == NULL) + if ((f = PaZOpen(name, "r", NULL, "", NULL, NULL)) == NULL) { TxError("Cannot open backup file \"%s\"\n", name); return FALSE; @@ -1136,7 +1132,7 @@ DBReadBackup(name) cellDef->cd_flags &= ~CDNOTFOUND; cellDef->cd_flags |= CDAVAILABLE; - if (dbCellReadDef(f, cellDef, filename, TRUE, FALSE) == FALSE) + if (dbCellReadDef(f, cellDef, TRUE, FALSE) == FALSE) return FALSE; if (dbFgets(line, sizeof(line), f) == NULL) @@ -1192,12 +1188,8 @@ DBReadBackup(name) */ bool -DBCellRead(cellDef, name, ignoreTech, dereference, errptr) +DBCellRead(cellDef, ignoreTech, dereference, errptr) CellDef *cellDef; /* Pointer to definition of cell to be read in */ - char *name; /* Name of file from which to read definition. - * If NULL, then use cellDef->cd_file; if that - * is NULL try the name of the cell. - */ bool ignoreTech; /* If FALSE then the technology of the file MUST * match the current technology, or else the * subroutine will return an error condition @@ -1219,12 +1211,12 @@ DBCellRead(cellDef, name, ignoreTech, dereference, errptr) if (cellDef->cd_flags & CDAVAILABLE) result = TRUE; - else if ((f = dbReadOpen(cellDef, name, TRUE, dereference, errptr)) == NULL) + else if ((f = dbReadOpen(cellDef, TRUE, dereference, errptr)) == NULL) result = FALSE; else { - result = (dbCellReadDef(f, cellDef, name, ignoreTech, dereference)); + result = (dbCellReadDef(f, cellDef, ignoreTech, dereference)); #ifdef FILE_LOCKS /* Close files that were locked by another user */ @@ -1244,7 +1236,7 @@ DBCellRead(cellDef, name, ignoreTech, dereference, errptr) * dbReadOpen -- * * Open the file containing the cell we are going to read. - * If a filename for the cell is specified ('name' is non-NULL), + * If a filename for the cell is being dereferenced, * we try to open it somewhere in the search path. Otherwise, * we try the filename already associated with the cell, or the * name of the cell itself as the name of the file containing @@ -1270,9 +1262,8 @@ DBCellRead(cellDef, name, ignoreTech, dereference, errptr) */ FILETYPE -dbReadOpen(cellDef, name, setFileName, dereference, errptr) +dbReadOpen(cellDef, setFileName, dereference, errptr) CellDef *cellDef; /* Def being read */ - char *name; /* Name if specified, or NULL */ bool setFileName; /* If TRUE then cellDef->cd_file should be updated * to point to the name of the file from which the * cell was loaded. @@ -1297,13 +1288,7 @@ dbReadOpen(cellDef, name, setFileName, dereference, errptr) if (errptr != NULL) *errptr = 0; // No error, by default - if (name != (char *) NULL) - { - f = PaLockZOpen(name, "r", DBSuffix, Path, - CellLibPath, &filename, &is_locked, &fd); - if (errptr != NULL) *errptr = errno; - } - else if (cellDef->cd_file != (char *) NULL) + if (cellDef->cd_file != (char *) NULL) { /* Do not send a name with a file extension to PaLockZOpen(), * otherwise that routine must handle it and then cannot @@ -1392,17 +1377,13 @@ dbReadOpen(cellDef, name, setFileName, dereference, errptr) if (cellDef->cd_flags & CDNOTFOUND) return ((FILETYPE) NULL); - if (name != (char *) NULL) - { - if (DBVerbose >= DB_VERBOSE_ERR) - TxError("File %s%s couldn't be read\n", name, DBSuffix); - } - else if (cellDef->cd_file != (char *) NULL) + if (cellDef->cd_file != (char *) NULL) { if (DBVerbose >= DB_VERBOSE_ERR) TxError("File %s couldn't be read\n", cellDef->cd_file); } - else { + else + { if (DBVerbose >= DB_VERBOSE_ERR) TxError("Cell %s couldn't be read\n", cellDef->cd_name); realname = (char *) mallocMagic((unsigned) (strlen(cellDef->cd_name) @@ -1582,7 +1563,13 @@ dbReadUse(cellDef, line, len, f, scalen, scaled, dereference, dbUseTable) pathptr = &path[0]; while (*pathptr == ' ' || *pathptr == '\t') pathptr++; - if ((dereference == TRUE) || (*pathptr == '\n')) *pathptr = '\0'; + + /* NOTE: Removed the truncating of the path when dereferencing, */ + /* 3/20/2023. This allows the original location to be recovered if */ + /* dereferencing is used, but the cell does not exist in the search */ + /* paths and only exists in the original location. */ + + if (*pathptr == '\n') *pathptr = '\0'; locked = (useid[0] == CULOCKCHAR) ? TRUE : FALSE; @@ -1772,10 +1759,11 @@ badTransform: /* or "~" and cellDef->cd_file has path components, then the path */ /* should be interpreted relative to the path of the parent cell. */ - /* If there is no pathptr, then the situation is one of these two: */ + /* If there is no pathptr, then one of these three things are true: */ /* (1) The instance is not the first time the cell was encountered */ - /* in the file, or (2) The cell is in the same path as the parent. */ - /* Only case (2) needs to be handled. */ + /* in the file, (2) "-dereference" has been selected on the current */ + /* file, but the subcell was already loaded, or (3) the cell is in */ + /* the same path as the parent. Only case (3) needs to be handled. */ if ((firstUse == TRUE) && ((*pathptr == '\0') || ((*pathptr != '/') && (*pathptr != '~')))) diff --git a/database/DBlabel2.c b/database/DBlabel2.c index 6a54de91..6113dbec 100644 --- a/database/DBlabel2.c +++ b/database/DBlabel2.c @@ -296,7 +296,7 @@ DBTreeFindUse(name, use, scx) if ((def->cd_flags & CDAVAILABLE) == 0) { bool dereference = (def->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - (void) DBCellRead(def, (char *) NULL, TRUE, dereference, NULL); + (void) DBCellRead(def, TRUE, dereference, NULL); } cp = name; @@ -348,7 +348,7 @@ DBTreeFindUse(name, use, scx) if ((def->cd_flags & CDAVAILABLE) == 0) { bool dereference = (def->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - (void) DBCellRead(def, (char *) NULL, TRUE, dereference, NULL); + (void) DBCellRead(def, TRUE, dereference, NULL); } scx->scx_use = use; diff --git a/database/DBtimestmp.c b/database/DBtimestmp.c index 121e074d..3ad6d7cb 100644 --- a/database/DBtimestmp.c +++ b/database/DBtimestmp.c @@ -140,7 +140,7 @@ DBFixMismatch() if (cellDef->cd_flags & CDPROCESSED) continue; dereference = (cellDef->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - (void) DBCellRead(cellDef, (char *) NULL, TRUE, dereference, NULL); + (void) DBCellRead(cellDef, TRUE, dereference, NULL); /* Jimmy up the cell's current bounding box, so the following * procedure call will absolutely and positively know that diff --git a/dbwind/DBWprocs.c b/dbwind/DBWprocs.c index 675a967c..c22d35dd 100644 --- a/dbwind/DBWprocs.c +++ b/dbwind/DBWprocs.c @@ -354,6 +354,9 @@ DBWloadWindow(window, name, flags) char *dotptr; + /* Strip any leading "./" from the name */ + if (!strncmp(name, "./", 2)) name += 2; + rootname = strrchr(name, '/'); if (rootname == NULL) rootname = name; @@ -376,14 +379,20 @@ DBWloadWindow(window, name, flags) newEditDef = DBCellLookDef(rootname); - if ((newEditDef != (CellDef *)NULL) && (newEditDef->cd_file != NULL)) + /* If "rootname" is the same as "name", then a cell was requested + * by name and was found in memory, and all is good. If not, then + * "name" implies some specific location and needs to be checked + * against the existing cell's file path. + */ + if ((newEditDef != (CellDef *)NULL) && (newEditDef->cd_file != NULL) && + strcmp(name, rootname)) { /* If the cellname exists already, check if we are really */ /* looking at the same file. If not, and two files in two */ - /* different paths have the same root cellname, then keep */ - /* the full pathname for the new cellname. */ + /* different paths have the same root cellname, then fail. */ char *fullpath; + bool badFile = FALSE; struct stat statbuf; ino_t inode; @@ -392,40 +401,68 @@ DBWloadWindow(window, name, flags) if (stat(fullpath, &statbuf) == 0) { inode = statbuf.st_ino; - if (stat(newEditDef->cd_file, &statbuf) == 0) + char *full_cdfile; + + full_cdfile = (char *)mallocMagic(strlen(newEditDef->cd_file) + + strlen(DBSuffix) + 1); + + /* cd_file is not supposed to have the file extension, */ + /* but check just in case. */ + + if (strstr(newEditDef->cd_file, DBSuffix) != NULL) + sprintf(full_cdfile, "%s", newEditDef->cd_file); + else + sprintf(full_cdfile, "%s%s", newEditDef->cd_file, DBSuffix); + + if (stat(full_cdfile, &statbuf) == 0) { if (inode != statbuf.st_ino) - newEditDef = (CellDef *)NULL; + badFile = TRUE; + } + else if ((dofail == FALSE) && + (!(newEditDef->cd_flags & CDAVAILABLE))) + { + /* Exception: If the cell can be found and the */ + /* existing file has not been loaded yet, then keep */ + /* the same behavior of "expand" and rename the cell */ + /* and flag a warning. */ + + TxError("Warning: Existing cell %s points to invalid path " + "\"%s\". Cell was found at location \"%s\" and " + "this location will be used.\n", + rootname, newEditDef->cd_file, fullpath); + freeMagic(newEditDef->cd_file); + newEditDef->cd_file = NULL; } else - newEditDef = (CellDef *)NULL; + badFile = TRUE; + + freeMagic(full_cdfile); } else - newEditDef = (CellDef *)NULL; + badFile = TRUE; + } else - newEditDef = (CellDef *)NULL; + badFile = TRUE; /* If the cells have the same name but different */ - /* paths, then give the new cell the full path name */ + /* paths, then fail. */ - if (newEditDef == NULL) + if (badFile == TRUE) { - if (dofail) - { - if (!beQuiet) - TxError("No file \"%s\" found or readable.\n", name); - return; - } - rootname = name; - newEditDef = DBCellLookDef(rootname); + TxError("File \"%s\": The cell was already read and points " + "to conflicting location \"%s\".\n", name, + newEditDef->cd_file); + return; } } if (newEditDef == (CellDef *) NULL) { /* "-fail" option: If no file is readable, then do not */ /* create a new cell. */ - if (dofail) + + if (dofail && !DBTestOpen(name, NULL)) { if (!beQuiet) TxError("No file \"%s\" found or readable.\n", name); @@ -434,9 +471,15 @@ DBWloadWindow(window, name, flags) newEditDef = DBCellNewDef(rootname); } - if (dereference) newEditDef->cd_flags |= CDDEREFERENCE; + /* If the name differs from the root name, then set the file */ + /* path to be the same as "name". */ - if (!DBCellRead(newEditDef, name, ignoreTech, dereference, &error_val)) + if (dereference) + newEditDef->cd_flags |= CDDEREFERENCE; + else if ((newEditDef->cd_file == NULL) && strcmp(name, rootname)) + newEditDef->cd_file = StrDup((char **)NULL, name); + + if (!DBCellRead(newEditDef, ignoreTech, dereference, &error_val)) { if (error_val == ENOENT) { @@ -448,7 +491,7 @@ DBWloadWindow(window, name, flags) { /* File exists but some error has occurred like * file is unreadable or max file descriptors - * was reached, in which csae we don't want to + * was reached, in which case we don't want to * create a new cell, so delete the new celldef * and return. */ diff --git a/drc/DRCmain.c b/drc/DRCmain.c index 6fa55e7c..7e0f0dc0 100644 --- a/drc/DRCmain.c +++ b/drc/DRCmain.c @@ -974,7 +974,7 @@ drcFindFunc(scx, finddata) HashSetValue(h, 1); dereference = (def->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - (void) DBCellRead(def, (char *) NULL, TRUE, dereference, NULL); + (void) DBCellRead(def, TRUE, dereference, NULL); if (DBSrPaintArea((Tile *) NULL, def->cd_planes[PL_DRC_ERROR], &def->cd_bbox, &DBAllButSpaceBits, drcFindFunc2, diff --git a/extract/ExtInter.c b/extract/ExtInter.c index f8be82fe..c5783490 100644 --- a/extract/ExtInter.c +++ b/extract/ExtInter.c @@ -426,7 +426,7 @@ extTreeSrPaintArea(scx, func, cdarg) if ((def->cd_flags & CDAVAILABLE) == 0) { bool dereference = (def->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - if (!DBCellRead(def, (char *) NULL, TRUE, dereference, NULL)) return 0; + if (!DBCellRead(def, TRUE, dereference, NULL)) return 0; } filter.tf_func = func; @@ -466,7 +466,7 @@ extTreeSrFunc(scx, fp) if ((def->cd_flags & CDAVAILABLE) == 0) { bool dereference = (def->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - if (!DBCellRead(def, (char *) NULL, TRUE, dereference, NULL)) return (0); + if (!DBCellRead(def, TRUE, dereference, NULL)) return (0); } context.tc_scx = scx; diff --git a/graphics/W3Dmain.c b/graphics/W3Dmain.c index f451e84f..964003db 100644 --- a/graphics/W3Dmain.c +++ b/graphics/W3Dmain.c @@ -1399,7 +1399,7 @@ W3DloadWindow(window, name) return FALSE; dereference = (newEditDef->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - if (!DBCellRead(newEditDef, (char *)NULL, TRUE, dereference, NULL)) + if (!DBCellRead(newEditDef, TRUE, dereference, NULL)) return FALSE; DBReComputeBbox(newEditDef); diff --git a/lef/defRead.c b/lef/defRead.c index 977ac809..7cf50622 100644 --- a/lef/defRead.c +++ b/lef/defRead.c @@ -2222,7 +2222,7 @@ DefReadComponents(f, rootDef, sname, oscale, total) defMacro->cd_flags &= ~CDNOTFOUND; dereference = (defMacro->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - if (!DBCellRead(defMacro, (char *)NULL, TRUE, dereference, NULL)) + if (!DBCellRead(defMacro, TRUE, dereference, NULL)) { LefError(DEF_ERROR, "Cell %s is not defined. Maybe you " "have not read the corresponding LEF file?\n", diff --git a/sim/SimDBstuff.c b/sim/SimDBstuff.c index 640519ef..2ae46c1d 100644 --- a/sim/SimDBstuff.c +++ b/sim/SimDBstuff.c @@ -762,7 +762,7 @@ SimCellTileSrFunc(scx, fp) if ((def->cd_flags & CDAVAILABLE) == 0) { bool dereference = (def->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; - if (!DBCellRead(def, (char *) NULL, TRUE, dereference, NULL)) return 0; + if (!DBCellRead(def, TRUE, dereference, NULL)) return 0; } context.tc_scx = scx;