From 39316ea3c6f1f856ab2afbee8862a64836504feb Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Wed, 26 Oct 2022 16:23:00 +0200 Subject: [PATCH 1/3] Function ngSpice_Circ() may send empty lines to shared ngspice. Skip these lines while processing the netlist array. --- src/frontend/inp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/frontend/inp.c b/src/frontend/inp.c index ad7099ccd..e1735ac12 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -1878,8 +1878,12 @@ void create_circbyline(char *line, bool reset, bool lastline) circarray = TREALLOC(char *, circarray, n_elem_alloc); } - /* Remove any leading whitespace by shifting */ char *p_src = skip_ws(line); + /* return if line is empty */ + if (*p_src == '\0') + return; + + /* Remove any leading whitespace by shifting */ if (p_src != line) { char *p_dst = line; char ch_cur; From ce2e95f32d19865c670d8d6a40a7c35be4b30009 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Wed, 26 Oct 2022 16:23:36 +0200 Subject: [PATCH 2/3] Fix typo --- src/frontend/inp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/inp.c b/src/frontend/inp.c index e1735ac12..e6660442e 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -1903,7 +1903,7 @@ void create_circbyline(char *line, bool reset, bool lastline) * free the deck. The card allocations themselves will be freed * elsewhere */ if (ciprefix(".end", line) && (line[4] == '\0' || isspace_c(line[4]))) { - circarray[linec] = NULL; /* termiante the deck */ + circarray[linec] = NULL; /* terminate the deck */ inp_spsource((FILE *) NULL, FALSE, NULL, TRUE); /* process */ tfree(circarray); /* set to empty */ linec = 0; From 159e36d23b9dfb15d6bca2fb781b1cb2d6f561f5 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Wed, 26 Oct 2022 23:34:10 +0200 Subject: [PATCH 3/3] Add function char* ngCM_Input_Path(const char* path); to shared ngspice API to send file path for code model input files (e.g. dsource). Such path cannot be extracted automatically when netlist has been sent by ngSpice_Circ --- src/include/ngspice/sharedspice.h | 6 +++++- src/sharedspice.c | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/include/ngspice/sharedspice.h b/src/include/ngspice/sharedspice.h index e3a81d391..ee67ab30d 100644 --- a/src/include/ngspice/sharedspice.h +++ b/src/include/ngspice/sharedspice.h @@ -365,12 +365,16 @@ Commands are executed immediately */ IMPEXP int ngSpice_Command(char* command); - /* get info about a vector */ IMPEXP pvector_info ngGet_Vec_Info(char* vecname); #ifdef XSPICE +/* Set the input path for files loaded by code models. + If NULL is sent, return the current Infile_Path. */ +IMPEXP +char* ngCM_Input_Path(const char* path); + /* get info about the event node vector */ IMPEXP pevt_shared_data ngGet_Evt_NodeInfo(char* nodename); diff --git a/src/sharedspice.c b/src/sharedspice.c index 7edb2d2bc..4b5dbcec6 100644 --- a/src/sharedspice.c +++ b/src/sharedspice.c @@ -1085,6 +1085,22 @@ int ngSpice_Command(char* comexec) return 1; } +#ifdef XSPICE +/* Set the input path for files loaded by code models. + If NULL is sent, return the current Infile_Path. */ +IMPEXP +char *ngCM_Input_Path(const char* path) +{ + /* delete existing command memory */ + if (path) { + txfree(Infile_Path); + Infile_Path = copy(path); + } + fprintf(stdout, "Note: Codel model file loading path is %s\n", Infile_Path); + return Infile_Path; +} +#endif + /* Return information about a vector to the caller */ IMPEXP pvector_info ngGet_Vec_Info(char* vecname)