From c89e7c8818a17a704158dd52a05c03d4c56e3b12 Mon Sep 17 00:00:00 2001 From: rlar Date: Sun, 5 Mar 2017 16:55:01 +0100 Subject: [PATCH] inp2m.c, #15/15b, collapse remaining code into a for loop --- src/spicelib/parser/inp2m.c | 52 +++++++++---------------------------- 1 file changed, 12 insertions(+), 40 deletions(-) diff --git a/src/spicelib/parser/inp2m.c b/src/spicelib/parser/inp2m.c index b06c9993f..d6cc962fe 100644 --- a/src/spicelib/parser/inp2m.c +++ b/src/spicelib/parser/inp2m.c @@ -112,22 +112,14 @@ INP2M(CKTcircuit *ckt, INPtables *tab, card *current) node[5] = NULL; node[6] = NULL; - /* nodeflag == 4 */ - INPgetNetTok(&line, &nname[nodeflag], 1); - save = line; /* saj - save the posn for later if - the default mosfet model is used */ + for (nodeflag = 4; nodeflag < 8; nodeflag++) { - err_msg = INPgetMod(ckt, nname[nodeflag], &thismodel, tab); - tfree(err_msg); - - /* check if using model binning -- pass in line since need 'l' and 'w' */ - if (!thismodel && nodeflag < 5) - INPgetModBin(ckt, nname[nodeflag], &thismodel, tab, line); - - if (!thismodel) { - nodeflag = 5; INPgetNetTok(&line, &nname[nodeflag], 1); + if (nodeflag == 4) + save = line; /* saj - save the posn for later if + the default mosfet model is used */ + err_msg = INPgetMod(ckt, nname[nodeflag], &thismodel, tab); tfree(err_msg); @@ -135,34 +127,14 @@ INP2M(CKTcircuit *ckt, INPtables *tab, card *current) if (!thismodel && nodeflag < 5) INPgetModBin(ckt, nname[nodeflag], &thismodel, tab, line); - if (!thismodel) { - nodeflag = 6; - INPgetNetTok(&line, &nname[nodeflag], 1); + if (thismodel) + break; + } - err_msg = INPgetMod(ckt, nname[nodeflag], &thismodel, tab); - tfree(err_msg); - - /* check if using model binning -- pass in line since need 'l' and 'w' */ - if (!thismodel && nodeflag < 5) - INPgetModBin(ckt, nname[nodeflag], &thismodel, tab, line); - - if (!thismodel) { - nodeflag = 7; - INPgetTok(&line, &nname[nodeflag], 1); - - err_msg = INPgetMod(ckt, nname[nodeflag], &thismodel, tab); - tfree(err_msg); - - /* check if using model binning -- pass in line since need 'l' and 'w' */ - if (!thismodel && nodeflag < 5) - INPgetModBin(ckt, nname[nodeflag], &thismodel, tab, line); - - if (!thismodel) { - nodeflag = 4; /* now reset to a 4 node device */ - line = save; /* reset the posn to what it sould be */ - } - } - } + /* nothing found, reset and process as if it were a 4 node device */ + if (nodeflag >= 8) { + nodeflag = 4; + line = save; } if (!valid_numnodes(nodeflag, thismodel, current))