From 22b7fa77b5ffb93e57df7a1cc6358282bc51fb00 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Mon, 28 May 2018 23:59:55 +0200 Subject: [PATCH] fix a bug with switches, when no subcircuit is involved --- src/frontend/inpcom.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index 2a3c573f6..503f201ed 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -6995,6 +6995,11 @@ pspice_compat(struct card *oldcard) tfree(modname); } } + + /* no need to continue if no vswitch is found */ + if (!modelsfound) + return newcard; + /* second scan: find the switch instances s calling a vswitch model and transform them */ for (card = newcard; card; card = card->nextcard) { static struct card *subcktline = NULL; @@ -7028,7 +7033,7 @@ pspice_compat(struct card *oldcard) for (i = 0; i < 6; i++) stoks[i] = gettok(&cut_line); /* rewrite s line and replace it if a model is found */ - if (find_a_model(modelsfound, stoks[5], subcktline->line)) { + if ((nesting > 0) && find_a_model(modelsfound, stoks[5], subcktline->line)) { tfree(card->line); card->line = tprintf("a%s %%vd(%s %s) %%gd(%s %s) a%s", stoks[0], stoks[3], stoks[4], stoks[1], stoks[2], stoks[5]);