From ca67c8aedf44e752889164bd87dd025c65cc785e Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Tue, 25 Sep 2018 14:19:30 -0400 Subject: [PATCH] Added code to EFread to make sure that reading .ext files is symmetric with writing them. Since the writing of .ext files was changed to preferably use the location of the cell being read, and since the extflat database does not save this path information, it was necessary to check the main database entry for each cell to determine if there is a non-default path where the .ext file may have been saved (with the current working directory used as a fall-back if the directory is not writeable). --- extflat/EFread.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/extflat/EFread.c b/extflat/EFread.c index 57176648..056ae03b 100644 --- a/extflat/EFread.c +++ b/extflat/EFread.c @@ -172,12 +172,13 @@ efReadDef(def, dosubckt, resist, noscale, toplevel) bool dosubckt, resist, noscale, toplevel; { int argc, ac, n; + CellDef *dbdef; EFCapValue cap; char line[1024], *argv[64], *name, *attrs; int rscale = 1; /* Multiply resistances by this */ int cscale = 1; /* Multiply capacitances by this */ float lscale = 1.0; /* Multiply lambda by this */ - FILE *inf; + FILE *inf = NULL; Use *use; Rect r; bool rc = TRUE; @@ -187,7 +188,27 @@ efReadDef(def, dosubckt, resist, noscale, toplevel) /* Mark def as available */ def->def_flags |= DEF_AVAILABLE; name = def->def_name; - inf = PaOpen(name, "r", ".ext", EFSearchPath, EFLibPath, &efReadFileName); + + /* If cell is in main database, check if there is a file path set. */ + + if ((dbdef = DBCellLookDef(name)) != NULL) + { + if (dbdef->cd_file != NULL) + { + char *filepath, *sptr; + + filepath = StrDup((char **)NULL, dbdef->cd_file); + sptr = strrchr(filepath, '/'); + if (sptr) { + *sptr = '\0'; + inf = PaOpen(name, "r", ".ext", filepath, EFLibPath, &efReadFileName); + } + freeMagic(filepath); + } + } + if (inf == NULL) + inf = PaOpen(name, "r", ".ext", EFSearchPath, EFLibPath, &efReadFileName); + if (inf == NULL) { /* Complementary to .ext file write: If file is in a read-only */