From a716572233ad456a83d03fe54e506cea04a7dcf9 Mon Sep 17 00:00:00 2001 From: rlar Date: Mon, 6 Feb 2012 17:49:19 +0000 Subject: [PATCH] rewrite INPlookMod(), return INPmodel*/NULL instead of int 1/0 --- ChangeLog | 5 +++++ src/include/ngspice/inpdefs.h | 2 +- src/spicelib/parser/inplkmod.c | 31 +++++++++++++------------------ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index e1945d03f..d2c6ef020 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-02-06 Robert Larice + * src/include/ngspice/inpdefs.h , + * src/spicelib/parser/inplkmod.c : + rewrite INPlookMod(), return INPmodel*/NULL instead of int 1/0 + 2012-02-06 Robert Larice * src/frontend/com_compose.c , * src/frontend/define.c , diff --git a/src/include/ngspice/inpdefs.h b/src/include/ngspice/inpdefs.h index 6e294644e..443c43be4 100644 --- a/src/include/ngspice/inpdefs.h +++ b/src/include/ngspice/inpdefs.h @@ -110,7 +110,7 @@ int INPinsertNofree(char **token, INPtables *tab); int INPinsert(char **, INPtables *); int INPretrieve(char **, INPtables *); int INPremove(char *, INPtables *); -int INPlookMod(char *); +INPmodel *INPlookMod(const char *); int INPmakeMod(char *, int, card *); char *INPmkTemp(char *); void INPpas1(CKTcircuit *, card *, INPtables *); diff --git a/src/spicelib/parser/inplkmod.c b/src/spicelib/parser/inplkmod.c index 9cdb04ad5..7bec493d1 100644 --- a/src/spicelib/parser/inplkmod.c +++ b/src/spicelib/parser/inplkmod.c @@ -2,32 +2,27 @@ Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Thomas L. Quarles **********/ -/* - */ #include "ngspice/ngspice.h" -#include #include "ngspice/inpdefs.h" -#include "inp.h" - +#include extern INPmodel *modtab; + /*----------------------------------------------------------------- - * This fcn accepts a pointer to the model name, and returns 1 if - * the model exists in the model table, and returns 0 if hte model - * doesn't exist in the model table. + * This fcn accepts a pointer to the model name, and returns + * the INPmodel * if it exist in the model table. *----------------------------------------------------------------*/ -int INPlookMod(char *name) + +INPmodel * +INPlookMod(const char *name) { - register INPmodel **i; + INPmodel *i; + + for (i = modtab; i; i = i->INPnextModel) + if (strcmp(i->INPmodName, name) == 0) + return i; - for (i = &modtab; *i != NULL; i = &((*i)->INPnextModel)) { - if (strcmp((*i)->INPmodName, name) == 0) { - /* found the model in question - return TRUE */ - return (1); - } - } - /* didn't find model - return FALSE */ - return (0); + return NULL; }