transform doit() into a true recursive version,
drop usage of global variables
reduce scope of many variables
cleanup and readability
FIXME,
an opportunity to plug a memory leak is visible now.
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.
Simon Guan reported
Bug item #3509528, `Meas goes wrong when put in a while loop'
In a .control block a `let' variable was passed to the `measure' command.
The value of this variable would have been a plain integer,
yet it was converted internally to an internal ascii representation
with exponential representation (203 ==> 2.03e2)
and then processed by `ft_numparse()' where it was converted back to
double floating point.
Because the intermediate 2.03 has
no exact representation in the space of double floating point numbers
this conversion was lossy and resulted in a non-integer value.
This non-integer was then truncated towards minus infinity in com_measure
yielding an error of -1
This commit implements round to nearest in com_measure2
to avoid the problem.
FIXME,
the internal intermediate conversion of double floating point machine
values to ascii representations must be dropped,
or replaced with an exact/lossless ascii representation.
(for example GNU printf/scanf %a or 64bit hexadecimal representation)
this worked
.subckt psub a b p2 = {p1*2-1} p1 = 1
but this failed
.subckt psub a b p2 = { p1 * 2 - 1 } p1 = 1
thanks to Ivan Riis Nielsen for the report in Message
[Ngspice-devel] parsing problem (ngspice-24 tarball)