Browse Source

Save path to .include file, add it to the search paths

for loading the next .include file.

If input directory dir_name is not set when loading .include files,
set it to the first .include found.

Both instruction add to the search paths for file to be inluded
and are valuable when the netlist is sent by circbyline without
input file involved.
pre-master-46
Holger Vogt 2 years ago
parent
commit
b660e75504
  1. 19
      src/frontend/inpcom.c

19
src/frontend/inpcom.c

@ -1433,11 +1433,15 @@ static struct inp_read_t inp_read(FILE* fp, int call_depth, const char* dir_name
char* y_resolved = inp_pathresolve_at(y, dir_name);
char* y_dir_name;
FILE* newfp;
static char oldpath[512];
if (!y_resolved) {
fprintf(cp_err, "Error: Could not find include file %s\n",
y);
controlled_exit(EXIT_FAILURE);
/* try again with most recent .include path */
y_resolved = inp_pathresolve_at(y, oldpath);
if (!y_resolved) {
fprintf(cp_err, "Error: Could not find include file %s\n", y);
controlled_exit(EXIT_FAILURE);
}
}
newfp = fopen(y_resolved, "r");
@ -1456,7 +1460,14 @@ static struct inp_read_t inp_read(FILE* fp, int call_depth, const char* dir_name
.cc; /* read stuff in include file into
netlist */
tfree(y_dir_name);
strncpy(oldpath, y_dir_name, 511);
/* if we don't have dir_name, e.g. when the netlist is loaded via
circbyline, then set dir_name to first .include path found. */
if (dir_name)
tfree(y_dir_name);
else
dir_name = y_dir_name;
tfree(y_resolved);
(void)fclose(newfp);

Loading…
Cancel
Save