From c9eeb0ceeadcf183a5ed67eda994d7d7606d096a Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sun, 17 Jan 2021 23:00:11 +0100 Subject: [PATCH] Modify get_number_terminals() and make it non-static. Use modified function to replace fixed node number. --- src/frontend/inpcom.c | 15 +++++++++++---- src/frontend/subckt.c | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index 454a0ae1a..f1b37406d 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -113,7 +113,7 @@ long dynsubst; /* spicenum.c 221 */ static bool has_if = FALSE; /* if we have an .if ... .endif pair */ static char *readline(FILE *fd); -static int get_number_terminals(char *c); +int get_number_terminals(char *c); static void inp_stripcomments_deck(struct card *deck, bool cs); static void inp_stripcomments_line(char *s, bool cs); static void inp_fix_for_numparam( @@ -4214,7 +4214,7 @@ static int inp_get_param_level( } -static int get_number_terminals(char *c) +int get_number_terminals(char *c) { int i, j, k; char *name[12]; @@ -4250,18 +4250,25 @@ static int get_number_terminals(char *c) break; case 'm': /* recognition of 4, 5, 6, or 7 nodes for SOI devices needed */ + { i = 0; + char* cc, * ccfree; + cc = copy(c); + /* required to make m= 1 a single token m=1 */ + ccfree = cc = inp_remove_ws(cc); /* find the first token with "off" or "=" in the line*/ - while ((i < 20) && (*c != '\0')) { - char *inst = gettok_instance(&c); + while ((i < 20) && (*cc != '\0')) { + char* inst = gettok_instance(&cc); strncpy(nam_buf, inst, sizeof(nam_buf) - 1); txfree(inst); if (strstr(nam_buf, "off") || strchr(nam_buf, '=') || strstr(nam_buf, "tnodeout") || strstr(nam_buf, "thermal")) break; i++; } + tfree(ccfree); return i - 2; break; + } case 'p': /* recognition of up to 100 cpl nodes */ i = j = 0; /* find the last token in the line*/ diff --git a/src/frontend/subckt.c b/src/frontend/subckt.c index 5c78edd2b..f3cf388c1 100644 --- a/src/frontend/subckt.c +++ b/src/frontend/subckt.c @@ -76,6 +76,7 @@ Modified: 2000 AlansFixes #include "numparam/numpaif.h" extern void line_free_x(struct card *deck, bool recurse); +extern int get_number_terminals(char* c); #define line_free(line, flag) \ do { \ @@ -1395,7 +1396,7 @@ translate(struct card *deck, char *formal, char *actual, char *scname, const cha /* FIXME anothet hack: if no models found for m devices, set number of nodes to 4 */ if (!modnames && *(c->line) == 'm') - nnodes = 4; + nnodes = get_number_terminals(c->line); else nnodes = numnodes(c->line, subs, modnames); while (--nnodes >= 0) {