From da06afb8954903c70a072b5236b41740c2ba9113 Mon Sep 17 00:00:00 2001 From: rlar Date: Sun, 25 Mar 2012 18:54:10 +0200 Subject: [PATCH] bug fix, numnodes() in response to the `ex-41.cir' test case distilled from a Dietmar Warning Bug report in "Subject: Re: subckt, param" translate() is called recursively and depends on `num of nodes' provided by numnodes(). numnodes() depends on availability of `su_numargs'. But the processing allows non-processing of subckt instantiations in inner recursions (which will be processed later) which means `su_numargs' is not always available. --- src/frontend/subckt.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/frontend/subckt.c b/src/frontend/subckt.c index b04e730e1..7c577b529 100644 --- a/src/frontend/subckt.c +++ b/src/frontend/subckt.c @@ -1502,12 +1502,24 @@ numnodes(char *name) s++; for (sss = subs; sss; sss = sss->su_next) if (eq(sss->su_name, s)) - break; - if (!sss) { - fprintf(cp_err, "Error: no such subcircuit: %s\n", s); - return (0); + return (sss->su_numargs); + /* + * number of nodes not known so far. + * lets count the nodes ourselves, + * assuming `buf' looks like this: + * xname n1 n2 ... nn subname + */ + { + int nodes = -2; + for(s = buf; *s; ) { + nodes++; + while(*s && !isspace(*s)) + s++; + while(isspace(*s)) + s++; + } + return (nodes); } - return (sss->su_numargs); } n = inp_numnodes(c);