diff --git a/src/spicelib/parser/inpdpar.c b/src/spicelib/parser/inpdpar.c index 9f0e52850..e7e546149 100644 --- a/src/spicelib/parser/inpdpar.c +++ b/src/spicelib/parser/inpdpar.c @@ -3,13 +3,13 @@ Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Thomas L. Quarles **********/ - /* - * INPdevParse() - * - * parse a given input according to the standard rules - look - * for the parameters given in the parmlists, In addition, - * an optional leading numeric parameter is handled. - */ +/* + * INPdevParse() + * + * parse a given input according to the standard rules - look + * for the parameters given in the parmlists, In addition, + * an optional leading numeric parameter is handled. + */ #include "ngspice/ngspice.h" #include @@ -20,79 +20,82 @@ Author: 1985 Thomas L. Quarles #include "ngspice/fteext.h" #include "inpxx.h" -char *INPdevParse(char **line, CKTcircuit *ckt, int dev, GENinstance *fast, - double *leading, int *waslead, INPtables * tab) - /* the line to parse */ - /* the circuit this device is a member of */ - /* the device type code to the device being parsed */ - /* direct pointer to device being parsed */ - /* the optional leading numeric parameter */ - /* flag - 1 if leading double given, 0 otherwise */ +char * +INPdevParse(char **line, CKTcircuit *ckt, int dev, GENinstance *fast, + double *leading, int *waslead, INPtables *tab) +/* the line to parse */ +/* the circuit this device is a member of */ +/* the device type code to the device being parsed */ +/* direct pointer to device being parsed */ +/* the optional leading numeric parameter */ +/* flag - 1 if leading double given, 0 otherwise */ { - int error; /* int to store evaluate error return codes in */ - char *parm=NULL; + int error; /* int to store evaluate error return codes in */ + char *parm = NULL; char *errbuf; int i; IFvalue *val; - char *rtn=NULL; + char *rtn = NULL; /* check for leading value */ *waslead = 0; *leading = INPevaluate(line, &error, 1); - if (error == 0) { /* found a good leading number */ - *waslead = 1; - } else - *leading = 0.0; + + if (error == 0) /* found a good leading number */ + *waslead = 1; + else + *leading = 0.0; + while (**line != '\0') { - error = INPgetTok(line, &parm, 1); - if (!*parm) { - FREE(parm); - continue; - } - if (error) { - rtn = INPerror(error); - goto quit; - } - for (i = 0; i < *(ft_sim->devices[dev]->numInstanceParms); i++) { - if (strcmp(parm, ft_sim->devices[dev]->instanceParms[i].keyword) == 0) { + error = INPgetTok(line, &parm, 1); + if (!*parm) { + FREE(parm); + continue; + } + if (error) { + rtn = INPerror(error); + goto quit; + } + for (i = 0; i < *(ft_sim->devices[dev]->numInstanceParms); i++) { + if (strcmp(parm, ft_sim->devices[dev]->instanceParms[i].keyword) == 0) { - int type; + int type; - val = - INPgetValue(ckt, line, - ft_sim->devices[dev]->instanceParms[i].dataType, - tab); - if (!val) { - rtn = INPerror(E_PARMVAL); - goto quit; - } - error = ft_sim->setInstanceParm (ckt, fast, - ft_sim->devices[dev]->instanceParms[i].id, - val, NULL); - if (error) { - rtn = INPerror(error); - goto quit; - } + val = INPgetValue(ckt, line, + ft_sim->devices[dev]->instanceParms[i].dataType, + tab); + if (!val) { + rtn = INPerror(E_PARMVAL); + goto quit; + } + error = ft_sim->setInstanceParm (ckt, fast, + ft_sim->devices[dev]->instanceParms[i].id, + val, NULL); + if (error) { + rtn = INPerror(error); + goto quit; + } - /* delete the union val */ - type = ft_sim->devices[dev]->instanceParms[i].dataType; - type &= IF_VARTYPES; - if (type == IF_REALVEC) - tfree(val->v.vec.rVec); - else if (type == IF_INTVEC) - tfree(val->v.vec.iVec); + /* delete the union val */ + type = ft_sim->devices[dev]->instanceParms[i].dataType; + type &= IF_VARTYPES; + if (type == IF_REALVEC) + tfree(val->v.vec.rVec); + else if (type == IF_INTVEC) + tfree(val->v.vec.iVec); - break; - } - } - if (i == *(ft_sim->devices[dev]->numInstanceParms)) { - errbuf = tprintf(" unknown parameter (%s) \n", parm); - rtn = errbuf; - goto quit; - } - FREE(parm); + break; + } + } + if (i == *(ft_sim->devices[dev]->numInstanceParms)) { + errbuf = tprintf(" unknown parameter (%s) \n", parm); + rtn = errbuf; + goto quit; + } + FREE(parm); } -quit: - FREE(parm); - return rtn; + + quit: + FREE(parm); + return rtn; } diff --git a/src/spicelib/parser/inpgval.c b/src/spicelib/parser/inpgval.c index 021dcd00f..1ec25bb77 100644 --- a/src/spicelib/parser/inpgval.c +++ b/src/spicelib/parser/inpgval.c @@ -10,7 +10,9 @@ Author: 1985 Thomas L. Quarles #include "ngspice/inpptree.h" #include "inpxx.h" -IFvalue *INPgetValue(CKTcircuit *ckt, char **line, int type, INPtables * tab) + +IFvalue * +INPgetValue(CKTcircuit *ckt, char **line, int type, INPtables *tab) { double *list; int *ilist; @@ -23,58 +25,58 @@ IFvalue *INPgetValue(CKTcircuit *ckt, char **line, int type, INPtables * tab) /* make sure we get rid of extra bits in type */ type &= IF_VARTYPES; if (type == IF_INTEGER) { - tmp = INPevaluate(line, &error, 1); - temp.iValue = (int) floor(0.5 + tmp); - /*printf(" returning integer value %d\n",temp.iValue); */ + tmp = INPevaluate(line, &error, 1); + temp.iValue = (int) floor(0.5 + tmp); + /* printf(" returning integer value %d\n",temp.iValue); */ } else if (type == IF_REAL) { - temp.rValue = INPevaluate(line, &error, 1); - /*printf(" returning real value %e\n",temp.rValue); */ + temp.rValue = INPevaluate(line, &error, 1); + /* printf(" returning real value %e\n",temp.rValue); */ } else if (type == IF_REALVEC) { - temp.v.numValue = 0; - list = TMALLOC(double, 1); - tmp = INPevaluate(line, &error, 1); - while (error == 0) { - /*printf(" returning vector value %g\n",tmp); */ - temp.v.numValue++; - list = - TREALLOC(double, list, temp.v.numValue); - list[temp.v.numValue - 1] = tmp; - tmp = INPevaluate(line, &error, 1); - } - temp.v.vec.rVec = list; + temp.v.numValue = 0; + list = TMALLOC(double, 1); + tmp = INPevaluate(line, &error, 1); + while (error == 0) { + /* printf(" returning vector value %g\n",tmp); */ + temp.v.numValue++; + list = TREALLOC(double, list, temp.v.numValue); + list[temp.v.numValue - 1] = tmp; + tmp = INPevaluate(line, &error, 1); + } + temp.v.vec.rVec = list; } else if (type == IF_INTVEC) { - temp.v.numValue = 0; - ilist = TMALLOC(int, 1); - tmp = INPevaluate(line, &error, 1); - while (error == 0) { - /*printf(" returning vector value %g\n",tmp); */ - temp.v.numValue++; - ilist = - TREALLOC(int, ilist, temp.v.numValue); - ilist[temp.v.numValue - 1] = (int) floor(0.5 + tmp); - tmp = INPevaluate(line, &error, 1); - } - temp.v.vec.iVec = ilist; + temp.v.numValue = 0; + ilist = TMALLOC(int, 1); + tmp = INPevaluate(line, &error, 1); + while (error == 0) { + /* printf(" returning vector value %g\n",tmp); */ + temp.v.numValue++; + ilist = TREALLOC(int, ilist, temp.v.numValue); + ilist[temp.v.numValue - 1] = (int) floor(0.5 + tmp); + tmp = INPevaluate(line, &error, 1); + } + temp.v.vec.iVec = ilist; } else if (type == IF_FLAG) { - temp.iValue = 1; + temp.iValue = 1; } else if (type == IF_NODE) { - INPgetNetTok(line, &word, 1); - INPtermInsert(ckt, &word, tab, &(temp.nValue)); + INPgetNetTok(line, &word, 1); + INPtermInsert(ckt, &word, tab, &(temp.nValue)); } else if (type == IF_INSTANCE) { - INPgetTok(line, &word, 1); - INPinsert(&word, tab); - temp.uValue = word; + INPgetTok(line, &word, 1); + INPinsert(&word, tab); + temp.uValue = word; } else if (type == IF_STRING) { - INPgetStr(line, &word, 1); - temp.sValue = word; + INPgetStr(line, &word, 1); + temp.sValue = word; } else if (type == IF_PARSETREE) { - INPgetTree(line, &pt, ckt, tab); - if (!pt) - return (NULL); - temp.tValue = (IFparseTree *) pt; - /*INPptPrint("Parse tree is: ", temp.tValue); */ - } else { /* don't know what type of parameter caller is talking about! */ - return (NULL); + INPgetTree(line, &pt, ckt, tab); + if (!pt) + return NULL; + temp.tValue = (IFparseTree *) pt; + /* INPptPrint("Parse tree is: ", temp.tValue); */ + } else { + /* don't know what type of parameter caller is talking about! */ + return NULL; } - return (&temp); + + return &temp; }