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.
This commit is contained in:
rlar 2012-03-25 18:54:10 +02:00
parent a1ea1b3193
commit da06afb895
1 changed files with 17 additions and 5 deletions

View File

@ -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);