parser/inpgmod.c, #6/6, cleanup, introduce find_model_parameter()

This commit is contained in:
rlar 2018-01-10 17:08:57 +01:00
parent 45e98db44c
commit bdf6091da7
1 changed files with 16 additions and 8 deletions

View File

@ -34,6 +34,20 @@ static int INPfindParm(char *name, IFparm *table, int numParms);
extern INPmodel *modtab;
static IFparm *
find_model_parameter(const char *name, IFdevice *device)
{
IFparm *p = device->modelParms;
IFparm *p_end = p + *(device->numModelParms);
for (; p < p_end; p++)
if (strcmp(name, p->keyword) == 0)
return p;
return NULL;
}
/*
* code moved from INPgetMod
*/
@ -86,15 +100,9 @@ create_model(CKTcircuit *ckt, INPmodel *modtmp, INPtables *tab)
continue;
}
IFparm *p = device->modelParms;
IFparm *p_end = p + *(device->numModelParms);
IFparm *p = find_model_parameter(parm, device);
for (; p < p_end; p++) {
if (strcmp(parm, p->keyword) == 0)
break;
}
if (p < p_end) {
if (p) {
IFvalue *val = INPgetValue(ckt, &line, p->dataType, tab);
error = ft_sim->setModelParm(ckt, modtmp->INPmodfast, p->id, val, NULL);
if (error)