From cf0c9eac06ada6b9a52b71923a84e3c390891a4d Mon Sep 17 00:00:00 2001 From: rlar Date: Sat, 3 Feb 2018 17:47:55 +0100 Subject: [PATCH] parser/inpdpar.c, #5/6, cleanup, use a local `IFparm *' --- src/spicelib/parser/inpdpar.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/spicelib/parser/inpdpar.c b/src/spicelib/parser/inpdpar.c index 23ab85581..8c62cd681 100644 --- a/src/spicelib/parser/inpdpar.c +++ b/src/spicelib/parser/inpdpar.c @@ -35,7 +35,6 @@ INPdevParse(char **line, CKTcircuit *ckt, int dev, GENinstance *fast, int error; /* int to store evaluate error return codes in */ char *parm = NULL; char *errbuf; - int i; IFvalue *val; char *rtn = NULL; @@ -59,35 +58,34 @@ INPdevParse(char **line, CKTcircuit *ckt, int dev, GENinstance *fast, goto quit; } - for (i = 0; i < *(device->numInstanceParms); i++) { - if (strcmp(parm, device->instanceParms[i].keyword) == 0) { + IFparm *p = device->instanceParms; + IFparm *p_end = p + *(device->numInstanceParms); + + for (; p < p_end; p++) { + if (strcmp(parm, p->keyword) == 0) { break; } } - if (i >= *(device->numInstanceParms)) { + if (p >= p_end) { errbuf = tprintf(" unknown parameter (%s) \n", parm); rtn = errbuf; goto quit; } - val = INPgetValue(ckt, line, - device->instanceParms[i].dataType, - tab); + val = INPgetValue(ckt, line, p->dataType, tab); if (!val) { rtn = INPerror(E_PARMVAL); goto quit; } - error = ft_sim->setInstanceParm (ckt, fast, - device->instanceParms[i].id, - val, NULL); + error = ft_sim->setInstanceParm (ckt, fast, p->id, val, NULL); if (error) { rtn = INPerror(error); goto quit; } /* delete the union val */ - switch (device->instanceParms[i].dataType & IF_VARTYPES) { + switch (p->dataType & IF_VARTYPES) { case IF_REALVEC: tfree(val->v.vec.rVec); break;