start cleanup numparam
This commit is contained in:
parent
30d4b95931
commit
bb5ea06be4
|
|
@ -1,5 +1,6 @@
|
||||||
2011-02-13 Holger Vogt
|
2011-02-13 Holger Vogt
|
||||||
* spicelib/analysis/acan.c: explicit type cast
|
* spicelib/analysis/acan.c: explicit type cast
|
||||||
|
* spicenum.c, mystring.c, xpressn.c: start cleanup, fix bug no. 3175568
|
||||||
|
|
||||||
2011-02-12 Holger Vogt
|
2011-02-12 Holger Vogt
|
||||||
* src/makefile.am: enable tclspice again
|
* src/makefile.am: enable tclspice again
|
||||||
|
|
|
||||||
|
|
@ -74,10 +74,10 @@ wi (long i)
|
||||||
|
|
||||||
void
|
void
|
||||||
rs ( SPICE_DSTRINGPTR dstr_p)
|
rs ( SPICE_DSTRINGPTR dstr_p)
|
||||||
{ /* basic line input, limit= 80 chars */
|
{
|
||||||
|
/* basic line input, limit= 80 chars */
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
|
|
||||||
spice_dstring_reinit(dstr_p) ;
|
spice_dstring_reinit(dstr_p) ;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
|
@ -99,15 +99,17 @@ rc (void)
|
||||||
spice_dstring_init(&dstr) ;
|
spice_dstring_init(&dstr) ;
|
||||||
rs (&dstr);
|
rs (&dstr);
|
||||||
ls = spice_dstring_length (&dstr);
|
ls = spice_dstring_length (&dstr);
|
||||||
if (ls > 0){
|
if (ls > 0)
|
||||||
|
{
|
||||||
s_p = spice_dstring_value(&dstr) ;
|
s_p = spice_dstring_value(&dstr) ;
|
||||||
val = s_p[ls - 1] ;
|
val = s_p[ls - 1] ;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
val = 0 ;
|
val = 0 ;
|
||||||
}
|
}
|
||||||
spice_dstring_free(&dstr) ;
|
spice_dstring_free(&dstr) ;
|
||||||
return val ;
|
return val ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******* Strings ************
|
/******* Strings ************
|
||||||
|
|
@ -286,7 +288,8 @@ scopy_up (SPICE_DSTRINGPTR dstr_p, char *str) /* returns success flag */
|
||||||
|
|
||||||
spice_dstring_reinit( dstr_p ) ;
|
spice_dstring_reinit( dstr_p ) ;
|
||||||
up[1] = 0 ;
|
up[1] = 0 ;
|
||||||
for( ptr = str ; ptr && *ptr ; ptr++ ){
|
for( ptr = str ; ptr && *ptr ; ptr++ )
|
||||||
|
{
|
||||||
up[0] = upcase ( *ptr );
|
up[0] = upcase ( *ptr );
|
||||||
spice_dstring_append( dstr_p, up, 1 ) ;
|
spice_dstring_append( dstr_p, up, 1 ) ;
|
||||||
}
|
}
|
||||||
|
|
@ -305,7 +308,8 @@ scopy_lower (SPICE_DSTRINGPTR dstr_p, char *str) /* returns success flag */
|
||||||
|
|
||||||
spice_dstring_reinit( dstr_p ) ;
|
spice_dstring_reinit( dstr_p ) ;
|
||||||
low[1] = 0 ;
|
low[1] = 0 ;
|
||||||
for( ptr = str ; ptr && *ptr ; ptr++ ){
|
for( ptr = str ; ptr && *ptr ; ptr++ )
|
||||||
|
{
|
||||||
low[0] = lowcase ( *ptr );
|
low[0] = lowcase ( *ptr );
|
||||||
spice_dstring_append( dstr_p, low, 1 ) ;
|
spice_dstring_append( dstr_p, low, 1 ) ;
|
||||||
}
|
}
|
||||||
|
|
@ -336,8 +340,10 @@ pscopy (SPICE_DSTRINGPTR dstr_p, char *t, int start, int leng)
|
||||||
|
|
||||||
stop = length(t) ;
|
stop = length(t) ;
|
||||||
|
|
||||||
if (start < stop) { /* nothing! */
|
if (start < stop) /* nothing! */
|
||||||
if ((start + leng - 1) > stop) {
|
{
|
||||||
|
if ((start + leng - 1) > stop)
|
||||||
|
{
|
||||||
// leng = stop - start + 1;
|
// leng = stop - start + 1;
|
||||||
leng = stop - start ;
|
leng = stop - start ;
|
||||||
}
|
}
|
||||||
|
|
@ -346,7 +352,9 @@ pscopy (SPICE_DSTRINGPTR dstr_p, char *t, int start, int leng)
|
||||||
for (i = 0; i < leng; i++)
|
for (i = 0; i < leng; i++)
|
||||||
s_p[i] = t[start + i];
|
s_p[i] = t[start + i];
|
||||||
s_p[leng] = '\0' ;
|
s_p[leng] = '\0' ;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
s_p = spice_dstring_reinit(dstr_p) ;
|
s_p = spice_dstring_reinit(dstr_p) ;
|
||||||
}
|
}
|
||||||
return s_p ;
|
return s_p ;
|
||||||
|
|
@ -362,8 +370,10 @@ pscopy_up (SPICE_DSTRINGPTR dstr_p, char *t, int start, int leng)
|
||||||
|
|
||||||
stop = length(t) ;
|
stop = length(t) ;
|
||||||
|
|
||||||
if (start < stop) { /* nothing! */
|
if (start < stop) /* nothing! */
|
||||||
if ((start + leng - 1) > stop) {
|
{
|
||||||
|
if ((start + leng - 1) > stop)
|
||||||
|
{
|
||||||
// leng = stop - start + 1;
|
// leng = stop - start + 1;
|
||||||
leng = stop - start ;
|
leng = stop - start ;
|
||||||
}
|
}
|
||||||
|
|
@ -372,7 +382,9 @@ pscopy_up (SPICE_DSTRINGPTR dstr_p, char *t, int start, int leng)
|
||||||
for (i = 0; i < leng; i++)
|
for (i = 0; i < leng; i++)
|
||||||
s_p[i] = upcase ( t[start + i] ) ;
|
s_p[i] = upcase ( t[start + i] ) ;
|
||||||
s_p[leng] = '\0' ;
|
s_p[leng] = '\0' ;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
s_p = spice_dstring_reinit(dstr_p) ;
|
s_p = spice_dstring_reinit(dstr_p) ;
|
||||||
}
|
}
|
||||||
return s_p ;
|
return s_p ;
|
||||||
|
|
@ -423,14 +435,16 @@ nadd ( SPICE_DSTRINGPTR dstr_p, long n)
|
||||||
|
|
||||||
if (k == 0)
|
if (k == 0)
|
||||||
cadd (dstr_p, '0');
|
cadd (dstr_p, '0');
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
load_str[1] = 0 ;
|
load_str[1] = 0 ;
|
||||||
if (sg == '-')
|
if (sg == '-')
|
||||||
{
|
{
|
||||||
load_str[0] = sg ;
|
load_str[0] = sg ;
|
||||||
spice_dstring_append( dstr_p, load_str, 1 ) ;
|
spice_dstring_append( dstr_p, load_str, 1 ) ;
|
||||||
}
|
}
|
||||||
for (j = k - 1; j >= 0; j--) {
|
for (j = k - 1; j >= 0; j--)
|
||||||
|
{
|
||||||
load_str[0] = d[j] + '0';
|
load_str[0] = d[j] + '0';
|
||||||
spice_dstring_append( dstr_p, load_str, 1 ) ;
|
spice_dstring_append( dstr_p, load_str, 1 ) ;
|
||||||
}
|
}
|
||||||
|
|
@ -466,14 +480,16 @@ naddll (SPICE_DSTRINGPTR dstr_p, long long n)
|
||||||
|
|
||||||
if (k == 0)
|
if (k == 0)
|
||||||
cadd (dstr_p, '0');
|
cadd (dstr_p, '0');
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
load_str[1] = 0 ;
|
load_str[1] = 0 ;
|
||||||
if (sg == '-')
|
if (sg == '-')
|
||||||
{
|
{
|
||||||
load_str[0] = sg ;
|
load_str[0] = sg ;
|
||||||
spice_dstring_append( dstr_p, load_str, 1 ) ;
|
spice_dstring_append( dstr_p, load_str, 1 ) ;
|
||||||
}
|
}
|
||||||
for (j = k - 1; j >= 0; j--) {
|
for (j = k - 1; j >= 0; j--)
|
||||||
|
{
|
||||||
load_str[0] = d[j] + '0';
|
load_str[0] = d[j] + '0';
|
||||||
spice_dstring_append( dstr_p, load_str, 1 ) ;
|
spice_dstring_append( dstr_p, load_str, 1 ) ;
|
||||||
}
|
}
|
||||||
|
|
@ -678,7 +694,8 @@ new (long sz)
|
||||||
{
|
{
|
||||||
p = tmalloc (sz);
|
p = tmalloc (sz);
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
{ /* fatal error */
|
{
|
||||||
|
/* fatal error */
|
||||||
ws (" new() failure. Program halted.\n");
|
ws (" new() failure. Program halted.\n");
|
||||||
controlled_exit(EXIT_FAILURE);
|
controlled_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
@ -760,7 +777,8 @@ strif (long i, int f, SPICE_DSTRINGPTR dstr_p)
|
||||||
spice_dstring_reinit(dstr_p) ;
|
spice_dstring_reinit(dstr_p) ;
|
||||||
|
|
||||||
if ((f > k) && (f < 40))
|
if ((f > k) && (f < 40))
|
||||||
{ /* reasonable format */
|
{
|
||||||
|
/* reasonable format */
|
||||||
for (j = k + 2; j <= f; j++)
|
for (j = k + 2; j <= f; j++)
|
||||||
{
|
{
|
||||||
load_str[0] = ' ';
|
load_str[0] = ' ';
|
||||||
|
|
@ -768,7 +786,8 @@ strif (long i, int f, SPICE_DSTRINGPTR dstr_p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j <= k + 1; j++){
|
for (j = 0; j <= k + 1; j++)
|
||||||
|
{
|
||||||
load_str[0] = t[k + j]; /* shift t down */
|
load_str[0] = t[k + j]; /* shift t down */
|
||||||
spice_dstring_append( dstr_p, load_str, 1 ) ;
|
spice_dstring_append( dstr_p, load_str, 1 ) ;
|
||||||
}
|
}
|
||||||
|
|
@ -876,7 +895,8 @@ void
|
||||||
strf (double x, int f1, int f2, SPICE_DSTRINGPTR dstr_p)
|
strf (double x, int f1, int f2, SPICE_DSTRINGPTR dstr_p)
|
||||||
/* e-format if f2<0, else f2 digits after the point, total width=f1 */
|
/* e-format if f2<0, else f2 digits after the point, total width=f1 */
|
||||||
/* if f1=0, also e-format with f2 digits */
|
/* if f1=0, also e-format with f2 digits */
|
||||||
{ /* default f1=17, f2=-1 */
|
{
|
||||||
|
/* ngspice default f1=17, f2=10 */
|
||||||
int dlen ; /* length of digits */
|
int dlen ; /* length of digits */
|
||||||
char *dbuf_p ; /* beginning of sprintf buffer */
|
char *dbuf_p ; /* beginning of sprintf buffer */
|
||||||
SPICE_DSTRING fmt ; /* format string */
|
SPICE_DSTRING fmt ; /* format string */
|
||||||
|
|
@ -894,7 +914,7 @@ strf (double x, int f1, int f2, SPICE_DSTRINGPTR dstr_p)
|
||||||
{
|
{
|
||||||
cadd (&fmt, '.');
|
cadd (&fmt, '.');
|
||||||
nadd (&fmt, f2);
|
nadd (&fmt, f2);
|
||||||
sadd (&fmt, "lg");
|
sadd (&fmt, "g");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -60,12 +60,12 @@ extern int dynmaxline; /* inpcom.c:1529 */
|
||||||
overwrite any line pointers, or we start a new set after each sig=0 ?
|
overwrite any line pointers, or we start a new set after each sig=0 ?
|
||||||
Anyway, we neutralize all & and .param lines (category[] array!)
|
Anyway, we neutralize all & and .param lines (category[] array!)
|
||||||
and we substitute all {} &() and &id placeholders by dummy numbers.
|
and we substitute all {} &() and &id placeholders by dummy numbers.
|
||||||
The placeholders are long long integers 100000000000000+n (15 digits, n small).
|
The placeholders are long long integers 100000000000000+n (17 digits, n small).
|
||||||
|
|
||||||
*/
|
*/
|
||||||
/********** string handling ***********/
|
/********** string handling ***********/
|
||||||
|
|
||||||
#define PlaceHold 100000000000000LL
|
#define PlaceHold 10000000000000000LL
|
||||||
static long placeholder = 0;
|
static long placeholder = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -112,7 +112,8 @@ stripbraces (SPICE_DSTRINGPTR dstr_p)
|
||||||
while (i < ls)
|
while (i < ls)
|
||||||
{
|
{
|
||||||
if (s[i] == '{')
|
if (s[i] == '{')
|
||||||
{ /* something to strip */
|
{
|
||||||
|
/* something to strip */
|
||||||
j = i + 1;
|
j = i + 1;
|
||||||
nest = 1;
|
nest = 1;
|
||||||
n++;
|
n++;
|
||||||
|
|
@ -134,7 +135,7 @@ stripbraces (SPICE_DSTRINGPTR dstr_p)
|
||||||
cadd (&tstr, ' ');
|
cadd (&tstr, ' ');
|
||||||
|
|
||||||
cadd ( &tstr, ' ');
|
cadd ( &tstr, ' ');
|
||||||
naddll( &tstr, PlaceHold + placeholder); /* placeholder has 15 digits */
|
naddll( &tstr, PlaceHold + placeholder); /* placeholder has 17 digits */
|
||||||
cadd ( &tstr, ' ');
|
cadd ( &tstr, ' ');
|
||||||
|
|
||||||
if (s[j] >= ' ')
|
if (s[j] >= ' ')
|
||||||
|
|
@ -175,7 +176,8 @@ findsubname (tdico * dico, SPICE_DSTRINGPTR dstr_p)
|
||||||
spice_dstring_init( &name ) ;
|
spice_dstring_init( &name ) ;
|
||||||
|
|
||||||
while ((k >= 0) && (!found))
|
while ((k >= 0) && (!found))
|
||||||
{ /* skip space, then non-space */
|
{
|
||||||
|
/* skip space, then non-space */
|
||||||
while ((k >= 0) && (s[k] <= ' '))
|
while ((k >= 0) && (s[k] <= ' '))
|
||||||
k--;
|
k--;
|
||||||
|
|
||||||
|
|
@ -205,7 +207,8 @@ findsubname (tdico * dico, SPICE_DSTRINGPTR dstr_p)
|
||||||
|
|
||||||
found = (k >= 0) && alfanum (s[k + 1]); /* suppose an identifier */
|
found = (k >= 0) && alfanum (s[k + 1]); /* suppose an identifier */
|
||||||
if (found)
|
if (found)
|
||||||
{ /* check for known subckt name */
|
{
|
||||||
|
/* check for known subckt name */
|
||||||
spice_dstring_reinit( &name ) ;
|
spice_dstring_reinit( &name ) ;
|
||||||
j = k + 1;
|
j = k + 1;
|
||||||
while (alfanum (s[j]))
|
while (alfanum (s[j]))
|
||||||
|
|
@ -322,7 +325,8 @@ transform (tdico * dico, SPICE_DSTRINGPTR dstr_p, unsigned char nostripping,
|
||||||
|
|
||||||
s = spice_dstring_value(dstr_p) ;
|
s = spice_dstring_value(dstr_p) ;
|
||||||
if (s[0] == '.')
|
if (s[0] == '.')
|
||||||
{ /* check Pspice parameter format */
|
{
|
||||||
|
/* check Pspice parameter format */
|
||||||
scopy_up (&tstr, spice_dstring_value(dstr_p) ) ;
|
scopy_up (&tstr, spice_dstring_value(dstr_p) ) ;
|
||||||
k = 1;
|
k = 1;
|
||||||
|
|
||||||
|
|
@ -334,12 +338,14 @@ transform (tdico * dico, SPICE_DSTRINGPTR dstr_p, unsigned char nostripping,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ci_prefix (".PARAM", t) == 1)
|
if (ci_prefix (".PARAM", t) == 1)
|
||||||
{ /* comment it out */
|
{
|
||||||
|
/* comment it out */
|
||||||
/*s[0]='*'; */
|
/*s[0]='*'; */
|
||||||
category = 'P';
|
category = 'P';
|
||||||
}
|
}
|
||||||
else if (ci_prefix (".SUBCKT", t) == 1)
|
else if (ci_prefix (".SUBCKT", t) == 1)
|
||||||
{ /* split off any "params" tail */
|
{
|
||||||
|
/* split off any "params" tail */
|
||||||
a = spos_ ("PARAMS:", t);
|
a = spos_ ("PARAMS:", t);
|
||||||
if (a >= 0)
|
if (a >= 0)
|
||||||
pscopy (dstr_p, s, 0, a );
|
pscopy (dstr_p, s, 0, a );
|
||||||
|
|
@ -360,19 +366,22 @@ transform (tdico * dico, SPICE_DSTRINGPTR dstr_p, unsigned char nostripping,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (s[0] == Intro)
|
else if (s[0] == Intro)
|
||||||
{ /* private style preprocessor line */
|
{
|
||||||
|
/* private style preprocessor line */
|
||||||
s[0] = '*';
|
s[0] = '*';
|
||||||
category = 'P';
|
category = 'P';
|
||||||
}
|
}
|
||||||
else if (upcase (s[0]) == 'X')
|
else if (upcase (s[0]) == 'X')
|
||||||
{ /* strip actual parameters */
|
{
|
||||||
|
/* strip actual parameters */
|
||||||
findsubname (dico, dstr_p) ;/* i= index following last identifier in s */
|
findsubname (dico, dstr_p) ;/* i= index following last identifier in s */
|
||||||
category = 'X';
|
category = 'X';
|
||||||
}
|
}
|
||||||
else if (s[0] == '+') /* continuation line */
|
else if (s[0] == '+') /* continuation line */
|
||||||
category = '+';
|
category = '+';
|
||||||
else if (cpos (s[0], "*$#") < 0)
|
else if (cpos (s[0], "*$#") < 0)
|
||||||
{ /* not a comment line! */
|
{
|
||||||
|
/* not a comment line! */
|
||||||
n = stripbraces (dstr_p);
|
n = stripbraces (dstr_p);
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
category = 'B'; /* line that uses braces */
|
category = 'B'; /* line that uses braces */
|
||||||
|
|
@ -586,9 +595,11 @@ nupa_list_params (FILE * cp_out)
|
||||||
* If there are no parameters, the hash table will not be allocated as
|
* If there are no parameters, the hash table will not be allocated as
|
||||||
* we use lazy allocation to save memory.
|
* we use lazy allocation to save memory.
|
||||||
* ----------------------------------------------------------------- */
|
* ----------------------------------------------------------------- */
|
||||||
for( depth = dico_p->stack_depth ; depth > 0 ; depth-- ){
|
for( depth = dico_p->stack_depth ; depth > 0 ; depth-- )
|
||||||
|
{
|
||||||
htable_p = dico_p->local_symbols[depth] ;
|
htable_p = dico_p->local_symbols[depth] ;
|
||||||
if( htable_p ){
|
if( htable_p )
|
||||||
|
{
|
||||||
fprintf (cp_out, " local symbol definitions for:%s\n", dico_p->inst_name[depth]) ;
|
fprintf (cp_out, " local symbol definitions for:%s\n", dico_p->inst_name[depth]) ;
|
||||||
dump_symbol_table( dico_p, htable_p, cp_out ) ;
|
dump_symbol_table( dico_p, htable_p, cp_out ) ;
|
||||||
}
|
}
|
||||||
|
|
@ -625,11 +636,14 @@ nupa_get_param (char *param_name, int *found)
|
||||||
up_name = spice_dstring_value( & dico_p->lookup_buf ) ;
|
up_name = spice_dstring_value( & dico_p->lookup_buf ) ;
|
||||||
|
|
||||||
*found = 0;
|
*found = 0;
|
||||||
for( depth = dico_p->stack_depth ; depth > 0 ; depth-- ){
|
for( depth = dico_p->stack_depth ; depth > 0 ; depth-- )
|
||||||
|
{
|
||||||
htable_p = dico_p->local_symbols[depth] ;
|
htable_p = dico_p->local_symbols[depth] ;
|
||||||
if( htable_p ){
|
if( htable_p )
|
||||||
|
{
|
||||||
entry_p = (entry *) nghash_find( htable_p, up_name ) ;
|
entry_p = (entry *) nghash_find( htable_p, up_name ) ;
|
||||||
if( entry_p ){
|
if( entry_p )
|
||||||
|
{
|
||||||
result = entry_p->vl ;
|
result = entry_p->vl ;
|
||||||
*found = 1;
|
*found = 1;
|
||||||
break ;
|
break ;
|
||||||
|
|
@ -637,10 +651,12 @@ nupa_get_param (char *param_name, int *found)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(*found)){
|
if(!(*found))
|
||||||
|
{
|
||||||
/* No luck. Try the global table. */
|
/* No luck. Try the global table. */
|
||||||
entry_p = (entry *) nghash_find( dico_p->global_symbols, up_name ) ;
|
entry_p = (entry *) nghash_find( dico_p->global_symbols, up_name ) ;
|
||||||
if( entry_p ){
|
if( entry_p )
|
||||||
|
{
|
||||||
result = entry_p->vl ;
|
result = entry_p->vl ;
|
||||||
*found = 1;
|
*found = 1;
|
||||||
}
|
}
|
||||||
|
|
@ -667,19 +683,24 @@ nupa_add_param (char *param_name, double value)
|
||||||
scopy_up( & dico_p->lookup_buf, param_name ) ;
|
scopy_up( & dico_p->lookup_buf, param_name ) ;
|
||||||
up_name = spice_dstring_value( & dico_p->lookup_buf ) ;
|
up_name = spice_dstring_value( & dico_p->lookup_buf ) ;
|
||||||
|
|
||||||
if( dico_p->stack_depth > 0 ){
|
if( dico_p->stack_depth > 0 )
|
||||||
|
{
|
||||||
/* can't be lazy anymore */
|
/* can't be lazy anymore */
|
||||||
if(!(dico_p->local_symbols[dico_p->stack_depth])){
|
if(!(dico_p->local_symbols[dico_p->stack_depth]))
|
||||||
|
{
|
||||||
dico_p->local_symbols[dico_p->stack_depth] = nghash_init( NGHASH_MIN_SIZE ) ;
|
dico_p->local_symbols[dico_p->stack_depth] = nghash_init( NGHASH_MIN_SIZE ) ;
|
||||||
}
|
}
|
||||||
htable_p = dico_p->local_symbols[dico_p->stack_depth] ;
|
htable_p = dico_p->local_symbols[dico_p->stack_depth] ;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/* global symbol */
|
/* global symbol */
|
||||||
htable_p = dico_p->global_symbols ;
|
htable_p = dico_p->global_symbols ;
|
||||||
}
|
}
|
||||||
|
|
||||||
entry_p = attrib ( dico_p, htable_p, up_name, 'N');
|
entry_p = attrib ( dico_p, htable_p, up_name, 'N');
|
||||||
if( entry_p ){
|
if( entry_p )
|
||||||
|
{
|
||||||
entry_p->vl = value;
|
entry_p->vl = value;
|
||||||
entry_p->tp = 'R';
|
entry_p->tp = 'R';
|
||||||
entry_p->ivl = 0;
|
entry_p->ivl = 0;
|
||||||
|
|
@ -700,12 +721,14 @@ nupa_add_inst_param (char *param_name, double value)
|
||||||
scopy_up( & dico_p->lookup_buf, param_name ) ;
|
scopy_up( & dico_p->lookup_buf, param_name ) ;
|
||||||
up_name = spice_dstring_value( & dico_p->lookup_buf ) ;
|
up_name = spice_dstring_value( & dico_p->lookup_buf ) ;
|
||||||
|
|
||||||
if(!(dico_p->inst_symbols)){
|
if(!(dico_p->inst_symbols))
|
||||||
|
{
|
||||||
dico_p->inst_symbols = nghash_init( NGHASH_MIN_SIZE ) ;
|
dico_p->inst_symbols = nghash_init( NGHASH_MIN_SIZE ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
entry_p = attrib ( dico_p, dico_p->inst_symbols, up_name, 'N');
|
entry_p = attrib ( dico_p, dico_p->inst_symbols, up_name, 'N');
|
||||||
if( entry_p ){
|
if( entry_p )
|
||||||
|
{
|
||||||
entry_p->vl = value;
|
entry_p->vl = value;
|
||||||
entry_p->tp = 'R';
|
entry_p->tp = 'R';
|
||||||
entry_p->ivl = 0;
|
entry_p->ivl = 0;
|
||||||
|
|
@ -727,15 +750,18 @@ nupa_copy_inst_dico (void)
|
||||||
NGHASHITER iter ; /* hash iterator - thread safe */
|
NGHASHITER iter ; /* hash iterator - thread safe */
|
||||||
|
|
||||||
dico_p = dicoS ;
|
dico_p = dicoS ;
|
||||||
if( dico_p->inst_symbols ){
|
if( dico_p->inst_symbols )
|
||||||
|
{
|
||||||
/* We we perform this operation we should be in global scope */
|
/* We we perform this operation we should be in global scope */
|
||||||
if( dico_p->stack_depth > 0 ){
|
if( dico_p->stack_depth > 0 )
|
||||||
|
{
|
||||||
fprintf( stderr, "stack depth should be zero.\n" ) ;
|
fprintf( stderr, "stack depth should be zero.\n" ) ;
|
||||||
}
|
}
|
||||||
NGHASH_FIRST(&iter) ;
|
NGHASH_FIRST(&iter) ;
|
||||||
for (entry_p = (entry *) nghash_enumerateRE(dico_p->inst_symbols,&iter ) ;
|
for (entry_p = (entry *) nghash_enumerateRE(dico_p->inst_symbols,&iter ) ;
|
||||||
entry_p ;
|
entry_p ;
|
||||||
entry_p = (entry *) nghash_enumerateRE(dico_p->inst_symbols,&iter)){
|
entry_p = (entry *) nghash_enumerateRE(dico_p->inst_symbols,&iter))
|
||||||
|
{
|
||||||
nupa_add_param ( entry_p->symbol, entry_p->vl) ;
|
nupa_add_param ( entry_p->symbol, entry_p->vl) ;
|
||||||
dico_free_entry( entry_p ) ;
|
dico_free_entry( entry_p ) ;
|
||||||
}
|
}
|
||||||
|
|
@ -840,14 +866,16 @@ nupa_eval (char *s, int linenum, int orig_linenum)
|
||||||
fprintf (stderr, "** SJB - processing line %3d: %s\n", linenum, s);
|
fprintf (stderr, "** SJB - processing line %3d: %s\n", linenum, s);
|
||||||
fprintf (stderr, "** SJB - category '%c'\n", c);
|
fprintf (stderr, "** SJB - category '%c'\n", c);
|
||||||
#endif /* TRACE_NUMPARAMS */
|
#endif /* TRACE_NUMPARAMS */
|
||||||
if (c == 'P') { /* evaluate parameters */
|
if (c == 'P') /* evaluate parameters */
|
||||||
|
{
|
||||||
// err = nupa_substitute (dico, dico->dynrefptr[linenum], s, 0);
|
// err = nupa_substitute (dico, dico->dynrefptr[linenum], s, 0);
|
||||||
nupa_assignment (dicoS, dicoS->dynrefptr[linenum], 'N');
|
nupa_assignment (dicoS, dicoS->dynrefptr[linenum], 'N');
|
||||||
}
|
}
|
||||||
else if (c == 'B') /* substitute braces line */
|
else if (c == 'B') /* substitute braces line */
|
||||||
err = nupa_substitute (dicoS, dicoS->dynrefptr[linenum], s, 0);
|
err = nupa_substitute (dicoS, dicoS->dynrefptr[linenum], s, 0);
|
||||||
else if (c == 'X')
|
else if (c == 'X')
|
||||||
{ /* compute args of subcircuit, if required */
|
{
|
||||||
|
/* compute args of subcircuit, if required */
|
||||||
ptr = s;
|
ptr = s;
|
||||||
while (!isspace (*ptr))
|
while (!isspace (*ptr))
|
||||||
ptr++;
|
ptr++;
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,8 @@ extern long dynsubst; /* see inpcom.c */
|
||||||
extern unsigned int dynLlen;
|
extern unsigned int dynLlen;
|
||||||
|
|
||||||
#define MAX_STRING_INSERT 17 /* max. string length to be inserted and replaced */
|
#define MAX_STRING_INSERT 17 /* max. string length to be inserted and replaced */
|
||||||
#define ACT_CHARACTS 15 /* actual string length to be inserted and replaced */
|
#define ACT_CHARACTS 17 /* actual string length to be inserted and replaced */
|
||||||
/* was 10, needs to be less or equal to MAX_STRING_INSERT - 2 */
|
#define EXP_LENGTH 5
|
||||||
|
|
||||||
static double
|
static double
|
||||||
ternary_fcn (int conditional, double if_value, double else_value)
|
ternary_fcn (int conditional, double if_value, double else_value)
|
||||||
|
|
@ -98,7 +98,8 @@ mathfunction (int f, double z, double x)
|
||||||
/* the list of built-in functions. Patch 'fmath', here and near line 888 to get more ...*/
|
/* the list of built-in functions. Patch 'fmath', here and near line 888 to get more ...*/
|
||||||
{
|
{
|
||||||
double y;
|
double y;
|
||||||
switch (f) {
|
switch (f)
|
||||||
|
{
|
||||||
case 1:
|
case 1:
|
||||||
y = x * x;
|
y = x * x;
|
||||||
break;
|
break;
|
||||||
|
|
@ -238,7 +239,8 @@ initdico (tdico * dico)
|
||||||
|
|
||||||
void dico_free_entry( entry *entry_p )
|
void dico_free_entry( entry *entry_p )
|
||||||
{
|
{
|
||||||
if( entry_p->symbol ){
|
if( entry_p->symbol )
|
||||||
|
{
|
||||||
txfree(entry_p->symbol ) ;
|
txfree(entry_p->symbol ) ;
|
||||||
}
|
}
|
||||||
txfree(entry_p) ;
|
txfree(entry_p) ;
|
||||||
|
|
@ -269,7 +271,8 @@ dicostack (tdico * dico, char op)
|
||||||
if (op == Push)
|
if (op == Push)
|
||||||
{
|
{
|
||||||
dico->stack_depth++;
|
dico->stack_depth++;
|
||||||
if ( dico->stack_depth > dico->symbol_stack_alloc ){
|
if ( dico->stack_depth > dico->symbol_stack_alloc )
|
||||||
|
{
|
||||||
/* Just double the stack alloc */
|
/* Just double the stack alloc */
|
||||||
dico->symbol_stack_alloc *= 2 ;
|
dico->symbol_stack_alloc *= 2 ;
|
||||||
asize = dico->symbol_stack_alloc + 1 ; /* account for zero */
|
asize = dico->symbol_stack_alloc + 1 ; /* account for zero */
|
||||||
|
|
@ -290,7 +293,8 @@ dicostack (tdico * dico, char op)
|
||||||
* ----------------------------------------------------------------- */
|
* ----------------------------------------------------------------- */
|
||||||
inst_name = dico->inst_name[dico->stack_depth] ;
|
inst_name = dico->inst_name[dico->stack_depth] ;
|
||||||
htable_p = dico->local_symbols[dico->stack_depth] ;
|
htable_p = dico->local_symbols[dico->stack_depth] ;
|
||||||
if( htable_p ){
|
if( htable_p )
|
||||||
|
{
|
||||||
SPICE_DSTRING param_name ; /* build a qualified name */
|
SPICE_DSTRING param_name ; /* build a qualified name */
|
||||||
spice_dstring_init(¶m_name) ;
|
spice_dstring_init(¶m_name) ;
|
||||||
|
|
||||||
|
|
@ -342,11 +346,14 @@ entrynb ( tdico *d, char *s)
|
||||||
NGHASHPTR htable_p ; /* hash table */
|
NGHASHPTR htable_p ; /* hash table */
|
||||||
|
|
||||||
/* look at the current scope and then backup the stack */
|
/* look at the current scope and then backup the stack */
|
||||||
for( depth = d->stack_depth ; depth > 0 ; depth-- ){
|
for( depth = d->stack_depth ; depth > 0 ; depth-- )
|
||||||
|
{
|
||||||
htable_p = d->local_symbols[depth] ;
|
htable_p = d->local_symbols[depth] ;
|
||||||
if( htable_p ){
|
if( htable_p )
|
||||||
|
{
|
||||||
entry_p = (entry *) nghash_find( htable_p, s ) ;
|
entry_p = (entry *) nghash_find( htable_p, s ) ;
|
||||||
if( entry_p ){
|
if( entry_p )
|
||||||
|
{
|
||||||
return( entry_p ) ;
|
return( entry_p ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -383,7 +390,8 @@ fetchnumentry (tdico * dico, char *t, bool *perr)
|
||||||
entry_p = entrynb (dico, t); /* no keyword */
|
entry_p = entrynb (dico, t); /* no keyword */
|
||||||
/*dbg -- if ( k<=0 ) { ws("Dico num lookup fails. ") ;} */
|
/*dbg -- if ( k<=0 ) { ws("Dico num lookup fails. ") ;} */
|
||||||
|
|
||||||
while ( entry_p && (entry_p->tp == 'P') ){
|
while ( entry_p && (entry_p->tp == 'P') )
|
||||||
|
{
|
||||||
entry_p = entry_p->pointer ;
|
entry_p = entry_p->pointer ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -465,13 +473,17 @@ define (tdico * dico,
|
||||||
|
|
||||||
spice_dstring_init(&vartemp) ;
|
spice_dstring_init(&vartemp) ;
|
||||||
|
|
||||||
if( dico->stack_depth > 0 ){
|
if( dico->stack_depth > 0 )
|
||||||
|
{
|
||||||
/* can't be lazy anymore */
|
/* can't be lazy anymore */
|
||||||
if(!(dico->local_symbols[dico->stack_depth])){
|
if(!(dico->local_symbols[dico->stack_depth]))
|
||||||
|
{
|
||||||
dico->local_symbols[dico->stack_depth] = nghash_init( NGHASH_MIN_SIZE ) ;
|
dico->local_symbols[dico->stack_depth] = nghash_init( NGHASH_MIN_SIZE ) ;
|
||||||
}
|
}
|
||||||
htable_p = dico->local_symbols[dico->stack_depth] ;
|
htable_p = dico->local_symbols[dico->stack_depth] ;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/* global symbol */
|
/* global symbol */
|
||||||
htable_p = dico->global_symbols ;
|
htable_p = dico->global_symbols ;
|
||||||
}
|
}
|
||||||
|
|
@ -625,7 +637,8 @@ deffuma ( /* define function or macro entry. */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (dico->dat[i].tp != '?')
|
if (dico->dat[i].tp != '?')
|
||||||
{ /* old item! */
|
{
|
||||||
|
/* old item! */
|
||||||
if (jumped)
|
if (jumped)
|
||||||
{
|
{
|
||||||
j = dico->dat[i].ivl;
|
j = dico->dat[i].ivl;
|
||||||
|
|
@ -671,16 +684,19 @@ keyword ( SPICE_DSTRINGPTR keys_p, SPICE_DSTRINGPTR tstr_p)
|
||||||
k = 0;
|
k = 0;
|
||||||
j = 0;
|
j = 0;
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
j++;
|
j++;
|
||||||
i = 0;
|
i = 0;
|
||||||
ok = 1;
|
ok = 1;
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
i++;
|
i++;
|
||||||
k++;
|
k++;
|
||||||
ok = (k <= lk) && (t[i - 1] == keys[k - 1]);
|
ok = (k <= lk) && (t[i - 1] == keys[k - 1]);
|
||||||
} while (!((!ok) || (i >= lt)));
|
}
|
||||||
|
while (!((!ok) || (i >= lt)));
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
ok = (k == lk) || (keys[k] <= ' ');
|
ok = (k == lk) || (keys[k] <= ' ');
|
||||||
|
|
@ -688,7 +704,8 @@ keyword ( SPICE_DSTRINGPTR keys_p, SPICE_DSTRINGPTR tstr_p)
|
||||||
if (!ok && (k < lk)) /* skip to next item */
|
if (!ok && (k < lk)) /* skip to next item */
|
||||||
while ((k <= lk) && (keys[k - 1] > ' '))
|
while ((k <= lk) && (keys[k - 1] > ' '))
|
||||||
k++;
|
k++;
|
||||||
} while (!(ok || (k >= lk)));
|
}
|
||||||
|
while (!(ok || (k >= lk)));
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
return j;
|
return j;
|
||||||
|
|
@ -752,7 +769,8 @@ fetchid (char *s, SPICE_DSTRINGPTR t, int ls, int i)
|
||||||
spice_dstring_reinit(t) ;
|
spice_dstring_reinit(t) ;
|
||||||
cadd (t, upcase (c));
|
cadd (t, upcase (c));
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
i++;
|
i++;
|
||||||
if (i <= ls)
|
if (i <= ls)
|
||||||
c = s[i - 1];
|
c = s[i - 1];
|
||||||
|
|
@ -765,7 +783,8 @@ fetchid (char *s, SPICE_DSTRINGPTR t, int ls, int i)
|
||||||
if (ok)
|
if (ok)
|
||||||
cadd (t, c);
|
cadd (t, c);
|
||||||
|
|
||||||
} while (ok);
|
}
|
||||||
|
while (ok);
|
||||||
return i /* return updated i */ ;
|
return i /* return updated i */ ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -785,7 +804,8 @@ exists (tdico * d, char *s, int *pi, bool *perror)
|
||||||
spice_dstring_init(&t) ;
|
spice_dstring_init(&t) ;
|
||||||
x = 0.0;
|
x = 0.0;
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
i++;
|
i++;
|
||||||
if (i > ls)
|
if (i > ls)
|
||||||
c = Nul;
|
c = Nul;
|
||||||
|
|
@ -793,7 +813,8 @@ exists (tdico * d, char *s, int *pi, bool *perror)
|
||||||
c = s[i - 1];
|
c = s[i - 1];
|
||||||
|
|
||||||
ok = (c == '(');
|
ok = (c == '(');
|
||||||
} while (!(ok || (c == Nul)));
|
}
|
||||||
|
while (!(ok || (c == Nul)));
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
|
|
@ -802,7 +823,8 @@ exists (tdico * d, char *s, int *pi, bool *perror)
|
||||||
if (entrynb(d, spice_dstring_value(&t)))
|
if (entrynb(d, spice_dstring_value(&t)))
|
||||||
x = 1.0;
|
x = 1.0;
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (i > ls)
|
if (i > ls)
|
||||||
|
|
@ -811,7 +833,8 @@ exists (tdico * d, char *s, int *pi, bool *perror)
|
||||||
c = s[i - 1];
|
c = s[i - 1];
|
||||||
|
|
||||||
ok = (c == ')');
|
ok = (c == ')');
|
||||||
} while (!(ok || (c == Nul)));
|
}
|
||||||
|
while (!(ok || (c == Nul)));
|
||||||
}
|
}
|
||||||
if (!ok)
|
if (!ok)
|
||||||
error = message (d, " Defined() syntax");
|
error = message (d, " Defined() syntax");
|
||||||
|
|
@ -840,29 +863,34 @@ fetchnumber (tdico * dico, char *s, int ls, int *pi, bool *perror)
|
||||||
spice_dstring_init(&vstr) ;
|
spice_dstring_init(&vstr) ;
|
||||||
k = i;
|
k = i;
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
k++;
|
k++;
|
||||||
if (k > ls)
|
if (k > ls)
|
||||||
d = (char)(0);
|
d = (char)(0);
|
||||||
else
|
else
|
||||||
d = s[k - 1];
|
d = s[k - 1];
|
||||||
} while (!(!((d == '.') || ((d >= '0') && (d <= '9')))));
|
}
|
||||||
|
while (!(!((d == '.') || ((d >= '0') && (d <= '9')))));
|
||||||
|
|
||||||
if ((d == 'e') || (d == 'E'))
|
if ((d == 'e') || (d == 'E'))
|
||||||
{ /* exponent follows */
|
{
|
||||||
|
/* exponent follows */
|
||||||
k++;
|
k++;
|
||||||
d = s[k - 1];
|
d = s[k - 1];
|
||||||
|
|
||||||
if ((d == '+') || (d == '-'))
|
if ((d == '+') || (d == '-'))
|
||||||
k++;
|
k++;
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
k++;
|
k++;
|
||||||
if (k > ls)
|
if (k > ls)
|
||||||
d = (char)(0);
|
d = (char)(0);
|
||||||
else
|
else
|
||||||
d = s[k - 1];
|
d = s[k - 1];
|
||||||
} while (!(!((d >= '0') && (d <= '9'))));
|
}
|
||||||
|
while (!(!((d >= '0') && (d <= '9'))));
|
||||||
}
|
}
|
||||||
|
|
||||||
pscopy (&tstr, s, i-1, k - i) ;
|
pscopy (&tstr, s, i-1, k - i) ;
|
||||||
|
|
@ -1034,7 +1062,8 @@ opfunctkey (tdico * dico,
|
||||||
bool error = *perror;
|
bool error = *perror;
|
||||||
/*if kw operator keyword, c=token*/
|
/*if kw operator keyword, c=token*/
|
||||||
switch (kw)
|
switch (kw)
|
||||||
{ /* & | ~ DIV MOD Defined */
|
{
|
||||||
|
/* & | ~ DIV MOD Defined */
|
||||||
case 1:
|
case 1:
|
||||||
c = '&';
|
c = '&';
|
||||||
state = 2;
|
state = 2;
|
||||||
|
|
@ -1101,7 +1130,7 @@ operate (char op, double x, double y)
|
||||||
x = x * y;
|
x = x * y;
|
||||||
break;
|
break;
|
||||||
case '/':
|
case '/':
|
||||||
if (absf (y) > epsi)
|
// if (absf (y) > epsi)
|
||||||
x = x / y;
|
x = x / y;
|
||||||
break;
|
break;
|
||||||
case '^': /* power */
|
case '^': /* power */
|
||||||
|
|
@ -1223,7 +1252,8 @@ formula (tdico * dico, char *s, bool *perror)
|
||||||
i++;
|
i++;
|
||||||
c = s[i - 1];
|
c = s[i - 1];
|
||||||
if (c == '(')
|
if (c == '(')
|
||||||
{ /* sub-formula or math function */
|
{
|
||||||
|
/* sub-formula or math function */
|
||||||
level = 1;
|
level = 1;
|
||||||
/* new: must support multi-arg functions */
|
/* new: must support multi-arg functions */
|
||||||
k = i;
|
k = i;
|
||||||
|
|
@ -1231,7 +1261,8 @@ formula (tdico * dico, char *s, bool *perror)
|
||||||
v = 1.0;
|
v = 1.0;
|
||||||
arg3 = 0;
|
arg3 = 0;
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
k++;
|
k++;
|
||||||
if (k > ls)
|
if (k > ls)
|
||||||
d = (char)(0);
|
d = (char)(0);
|
||||||
|
|
@ -1345,12 +1376,14 @@ formula (tdico * dico, char *s, bool *perror)
|
||||||
error = message (dico, " Misplaced operator");
|
error = message (dico, " Misplaced operator");
|
||||||
|
|
||||||
if (state == 3)
|
if (state == 3)
|
||||||
{ /* push unary operator */
|
{
|
||||||
|
/* push unary operator */
|
||||||
ustack++;
|
ustack++;
|
||||||
uop[ustack] = c;
|
uop[ustack] = c;
|
||||||
}
|
}
|
||||||
else if (state == 1)
|
else if (state == 1)
|
||||||
{ /* atom pending */
|
{
|
||||||
|
/* atom pending */
|
||||||
natom++;
|
natom++;
|
||||||
if (i >= ls)
|
if (i >= ls)
|
||||||
{
|
{
|
||||||
|
|
@ -1368,7 +1401,8 @@ formula (tdico * dico, char *s, bool *perror)
|
||||||
{
|
{
|
||||||
/* do pending binaries of priority Upto "level" */
|
/* do pending binaries of priority Upto "level" */
|
||||||
for (k = 1; k <= level; k++)
|
for (k = 1; k <= level; k++)
|
||||||
{ /* not yet speed optimized! */
|
{
|
||||||
|
/* not yet speed optimized! */
|
||||||
accu[k] = operate (oper[k], accu[k], accu[k - 1]);
|
accu[k] = operate (oper[k], accu[k], accu[k - 1]);
|
||||||
accu[k - 1] = 0.0;
|
accu[k - 1] = 0.0;
|
||||||
oper[k] = ' '; /* reset intermediates */ ;
|
oper[k] = ' '; /* reset intermediates */ ;
|
||||||
|
|
@ -1423,7 +1457,8 @@ fmttype (double x)
|
||||||
if (ax < 1e-39) /* smaller then 1e-39 is 0 */
|
if (ax < 1e-39) /* smaller then 1e-39 is 0 */
|
||||||
isint = 1; /* and seen as an integer */
|
isint = 1; /* and seen as an integer */
|
||||||
else if (ax < 64000)
|
else if (ax < 64000)
|
||||||
{ /* detect integers */
|
{
|
||||||
|
/* detect integers */
|
||||||
rx = np_round (x);
|
rx = np_round (x);
|
||||||
dx = (x - rx) / ax;
|
dx = (x - rx) / ax;
|
||||||
isint = (absf (dx) < 1e-06);
|
isint = (absf (dx) < 1e-06);
|
||||||
|
|
@ -1446,7 +1481,7 @@ evaluate (tdico * dico, SPICE_DSTRINGPTR qstr_p, char *t, unsigned char mode)
|
||||||
/* transform t to result q. mode 0: expression, mode 1: simple variable */
|
/* transform t to result q. mode 0: expression, mode 1: simple variable */
|
||||||
double u = 0.0;
|
double u = 0.0;
|
||||||
int j, lq;
|
int j, lq;
|
||||||
char dt, fmt;
|
char dt/*, fmt*/;
|
||||||
entry *entry_p ;
|
entry *entry_p ;
|
||||||
bool numeric, done, nolookup;
|
bool numeric, done, nolookup;
|
||||||
bool err;
|
bool err;
|
||||||
|
|
@ -1458,11 +1493,13 @@ evaluate (tdico * dico, SPICE_DSTRINGPTR qstr_p, char *t, unsigned char mode)
|
||||||
err = 0;
|
err = 0;
|
||||||
|
|
||||||
if (mode == 1)
|
if (mode == 1)
|
||||||
{ /* string? */
|
{
|
||||||
|
/* string? */
|
||||||
stupcase (t);
|
stupcase (t);
|
||||||
entry_p = entrynb (dico, t);
|
entry_p = entrynb (dico, t);
|
||||||
nolookup = (!(entry_p));
|
nolookup = (!(entry_p));
|
||||||
while ((entry_p) && (entry_p->tp == 'P')){
|
while ((entry_p) && (entry_p->tp == 'P'))
|
||||||
|
{
|
||||||
entry_p = entry_p->pointer ; /* follow pointer chain */
|
entry_p = entry_p->pointer ; /* follow pointer chain */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1479,10 +1516,12 @@ evaluate (tdico * dico, SPICE_DSTRINGPTR qstr_p, char *t, unsigned char mode)
|
||||||
numeric = 1;
|
numeric = 1;
|
||||||
}
|
}
|
||||||
else if (dt == 'S')
|
else if (dt == 'S')
|
||||||
{ /* suppose source text "..." at */
|
{
|
||||||
|
/* suppose source text "..." at */
|
||||||
j = entry_p->ivl;
|
j = entry_p->ivl;
|
||||||
lq = 0;
|
lq = 0;
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
j++;
|
j++;
|
||||||
lq++;
|
lq++;
|
||||||
dt = /* ibf->bf[j]; */ entry_p->sbbase[j];
|
dt = /* ibf->bf[j]; */ entry_p->sbbase[j];
|
||||||
|
|
@ -1494,7 +1533,8 @@ evaluate (tdico * dico, SPICE_DSTRINGPTR qstr_p, char *t, unsigned char mode)
|
||||||
|
|
||||||
if (!done)
|
if (!done)
|
||||||
cadd (qstr_p, dt);
|
cadd (qstr_p, dt);
|
||||||
} while (!(done));
|
}
|
||||||
|
while (!(done));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(entry_p))
|
if (!(entry_p))
|
||||||
|
|
@ -1515,16 +1555,9 @@ evaluate (tdico * dico, SPICE_DSTRINGPTR qstr_p, char *t, unsigned char mode)
|
||||||
u = formula (dico, t, &err);
|
u = formula (dico, t, &err);
|
||||||
numeric = 1;
|
numeric = 1;
|
||||||
}
|
}
|
||||||
if (numeric)
|
/* set string to total length 17, mantissa after . is of length 9
|
||||||
{
|
use sprintf with format string %17.10g */
|
||||||
fmt = fmttype (u);
|
|
||||||
if (fmt == 'I')
|
|
||||||
stri (np_round (u), qstr_p);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strf (u, 17, 10, qstr_p);
|
strf (u, 17, 10, qstr_p);
|
||||||
}
|
|
||||||
}
|
|
||||||
spice_dstring_free(&vstr) ;
|
spice_dstring_free(&vstr) ;
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
@ -1547,7 +1580,8 @@ scanline (tdico * dico, char *s, char *r, bool err)
|
||||||
err = 0;
|
err = 0;
|
||||||
pscopy (u, s, 1, 3);
|
pscopy (u, s, 1, 3);
|
||||||
if ((ls > 7) && steq (u, "**&"))
|
if ((ls > 7) && steq (u, "**&"))
|
||||||
{ /* special Comment **&AC #... */
|
{
|
||||||
|
/* special Comment **&AC #... */
|
||||||
pscopy (r, s, 1, 7);
|
pscopy (r, s, 1, 7);
|
||||||
i = 7;
|
i = 7;
|
||||||
}
|
}
|
||||||
|
|
@ -1556,7 +1590,8 @@ scanline (tdico * dico, char *s, char *r, bool err)
|
||||||
i++;
|
i++;
|
||||||
c = s[i - 1];
|
c = s[i - 1];
|
||||||
if (c == Pspice)
|
if (c == Pspice)
|
||||||
{ /* try pspice expression syntax */
|
{
|
||||||
|
/* try pspice expression syntax */
|
||||||
k = i;
|
k = i;
|
||||||
nnest = 1;
|
nnest = 1;
|
||||||
do
|
do
|
||||||
|
|
@ -1580,15 +1615,18 @@ scanline (tdico * dico, char *s, char *r, bool err)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pscopy (t, s, i + 1, k - i - 1);
|
pscopy (t, s, i + 1, k - i - 1);
|
||||||
if( dico->hspice_compatibility && (strcasecmp(t,"LAST")==0) ) {
|
if( dico->hspice_compatibility && (strcasecmp(t,"LAST")==0) )
|
||||||
|
{
|
||||||
strcpy(q,"last") ;
|
strcpy(q,"last") ;
|
||||||
err=0;
|
err=0;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
err = evaluate (dico, q, t, 0);
|
err = evaluate (dico, q, t, 0);
|
||||||
}
|
}
|
||||||
i = k;
|
i = k;
|
||||||
if (!err)
|
if (!err)
|
||||||
{ /* insert number */
|
{
|
||||||
|
/* insert number */
|
||||||
sadd (r, q);
|
sadd (r, q);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -1603,7 +1641,8 @@ scanline (tdico * dico, char *s, char *r, bool err)
|
||||||
i++;
|
i++;
|
||||||
k = i;
|
k = i;
|
||||||
if (s[k - 1] == '(')
|
if (s[k - 1] == '(')
|
||||||
{ /* sub-formula */
|
{
|
||||||
|
/* sub-formula */
|
||||||
level = 1;
|
level = 1;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
|
@ -1638,7 +1677,8 @@ scanline (tdico * dico, char *s, char *r, bool err)
|
||||||
i = k;
|
i = k;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* simple identifier may also be string */
|
{
|
||||||
|
/* simple identifier may also be string */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
k++;
|
k++;
|
||||||
|
|
@ -1657,7 +1697,8 @@ scanline (tdico * dico, char *s, char *r, bool err)
|
||||||
i = k - 1;
|
i = k - 1;
|
||||||
}
|
}
|
||||||
if (!err)
|
if (!err)
|
||||||
{ /* insert the number */
|
{
|
||||||
|
/* insert the number */
|
||||||
sadd (r, q);
|
sadd (r, q);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -1666,7 +1707,8 @@ scanline (tdico * dico, char *s, char *r, bool err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (c == Nodekey)
|
else if (c == Nodekey)
|
||||||
{ /* follows: a node keyword */
|
{
|
||||||
|
/* follows: a node keyword */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
|
|
@ -1707,10 +1749,11 @@ compactfloatnb (SPICE_DSTRINGPTR vstr_p)
|
||||||
/* try to squeeze a floating pt format to ACT_CHARACTS characters */
|
/* try to squeeze a floating pt format to ACT_CHARACTS characters */
|
||||||
/* erase superfluous 000 digit streams before E */
|
/* erase superfluous 000 digit streams before E */
|
||||||
/* bug: truncating, no rounding */
|
/* bug: truncating, no rounding */
|
||||||
|
/* Not used anymore !!*/
|
||||||
{
|
{
|
||||||
int n, k, m, lex, lem;
|
int n, k, m, lex, lem;
|
||||||
char *expov ;
|
// char *expov ;
|
||||||
char *expnv ;
|
// char *expnv ;
|
||||||
char *v_p ;
|
char *v_p ;
|
||||||
SPICE_DSTRING expo_str ;
|
SPICE_DSTRING expo_str ;
|
||||||
SPICE_DSTRING expn_str ;
|
SPICE_DSTRING expn_str ;
|
||||||
|
|
@ -1720,37 +1763,23 @@ compactfloatnb (SPICE_DSTRINGPTR vstr_p)
|
||||||
n = cpos ('E', spice_dstring_value(vstr_p)) ; /* if too long, try to delete digits */
|
n = cpos ('E', spice_dstring_value(vstr_p)) ; /* if too long, try to delete digits */
|
||||||
if (n<0) n = cpos ('e', spice_dstring_value(vstr_p));
|
if (n<0) n = cpos ('e', spice_dstring_value(vstr_p));
|
||||||
|
|
||||||
if (n >= 0) {
|
if (n >= 0)
|
||||||
|
{
|
||||||
pscopy (&expo_str, spice_dstring_value(vstr_p), n,
|
pscopy (&expo_str, spice_dstring_value(vstr_p), n,
|
||||||
spice_dstring_length(vstr_p));
|
spice_dstring_length(vstr_p));
|
||||||
lex = spice_dstring_length (&expo_str) ;
|
lex = spice_dstring_length (&expo_str) ;
|
||||||
if (lex > 4) { /* exponent only 2 digits */
|
|
||||||
pscopy (&expn_str, spice_dstring_value(&expo_str), 1, 4);
|
|
||||||
expnv = spice_dstring_value(&expn_str) ;
|
|
||||||
if (atoi(expnv) < -99){
|
|
||||||
spice_dstring_reinit(&expo_str) ;
|
|
||||||
sadd(&expo_str, "e-099"); /* brutal */
|
|
||||||
}
|
|
||||||
if (atoi(expnv) > +99){
|
|
||||||
spice_dstring_reinit(&expo_str) ;
|
|
||||||
sadd(&expo_str, "e+099");
|
|
||||||
}
|
|
||||||
expov = spice_dstring_value(&expo_str) ;
|
|
||||||
expov[2] = expov[3];
|
|
||||||
expov[3] = expov[4];
|
|
||||||
expov[4] = '\0';
|
|
||||||
spice_dstring_setlength(&expo_str,4) ;
|
|
||||||
lex = 4;
|
|
||||||
}
|
|
||||||
k = n ; /* mantissa is 0...k */
|
|
||||||
|
|
||||||
m = MAX_STRING_INSERT;
|
k = n ; /* mantissa is [0..k[ */
|
||||||
|
|
||||||
v_p = spice_dstring_value(vstr_p) ;
|
v_p = spice_dstring_value(vstr_p) ;
|
||||||
while (v_p[m] != ' ')
|
|
||||||
m--;
|
for(m=k; m>0; --m)
|
||||||
m++;
|
if(v_p[m-1] == ' ')
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* FIXME, v_p[k] === 'e' thus this is never executed
|
||||||
while ((v_p[k] == '0') && (v_p[k - 1] == '0'))
|
while ((v_p[k] == '0') && (v_p[k - 1] == '0'))
|
||||||
k--;
|
k--;*/
|
||||||
|
|
||||||
lem = k - m;
|
lem = k - m;
|
||||||
|
|
||||||
|
|
@ -1758,21 +1787,28 @@ compactfloatnb (SPICE_DSTRINGPTR vstr_p)
|
||||||
lem = ACT_CHARACTS - lex;
|
lem = ACT_CHARACTS - lex;
|
||||||
|
|
||||||
pscopy (vstr_p, spice_dstring_value(vstr_p), m, lem);
|
pscopy (vstr_p, spice_dstring_value(vstr_p), m, lem);
|
||||||
if (cpos('.', spice_dstring_value(vstr_p)) >= 0) {
|
if (cpos('.', spice_dstring_value(vstr_p)) >= 0)
|
||||||
while (lem < ACT_CHARACTS - 4) {
|
{
|
||||||
|
while (lem < ACT_CHARACTS - EXP_LENGTH)
|
||||||
|
{
|
||||||
cadd(vstr_p, '0');
|
cadd(vstr_p, '0');
|
||||||
lem++;
|
lem++;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
cadd(vstr_p, '.');
|
cadd(vstr_p, '.');
|
||||||
lem++;
|
lem++;
|
||||||
while (lem < ACT_CHARACTS - 4) {
|
while (lem < ACT_CHARACTS - EXP_LENGTH)
|
||||||
|
{
|
||||||
cadd(vstr_p, '0');
|
cadd(vstr_p, '0');
|
||||||
lem++;
|
lem++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sadd (vstr_p, spice_dstring_value(&expo_str) );
|
sadd (vstr_p, spice_dstring_value(&expo_str) );
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m = 0;
|
m = 0;
|
||||||
v_p = spice_dstring_value(vstr_p) ;
|
v_p = spice_dstring_value(vstr_p) ;
|
||||||
while (v_p[m] == ' ')
|
while (v_p[m] == ' ')
|
||||||
|
|
@ -1799,7 +1835,7 @@ insertnumber (tdico * dico, int i, char *s, SPICE_DSTRINGPTR ustr_p)
|
||||||
spice_dstring_init(&vstr) ;
|
spice_dstring_init(&vstr) ;
|
||||||
spice_dstring_init(&mstr) ;
|
spice_dstring_init(&mstr) ;
|
||||||
scopyd (&vstr, ustr_p) ;
|
scopyd (&vstr, ustr_p) ;
|
||||||
compactfloatnb (&vstr) ;
|
// compactfloatnb (&vstr) ;
|
||||||
|
|
||||||
while ( spice_dstring_length (&vstr) < MAX_STRING_INSERT)
|
while ( spice_dstring_length (&vstr) < MAX_STRING_INSERT)
|
||||||
cadd (&vstr, ' ');
|
cadd (&vstr, ' ');
|
||||||
|
|
@ -1819,8 +1855,9 @@ insertnumber (tdico * dico, int i, char *s, SPICE_DSTRINGPTR ustr_p)
|
||||||
k = 0;
|
k = 0;
|
||||||
accu = 0;
|
accu = 0;
|
||||||
|
|
||||||
while (found && (k < 15))
|
while (found && (k < 17))
|
||||||
{ /* parse a 15-digit number */
|
{
|
||||||
|
/* parse a 15-digit number */
|
||||||
found = num (s[i + k]);
|
found = num (s[i + k]);
|
||||||
|
|
||||||
if (found)
|
if (found)
|
||||||
|
|
@ -1831,7 +1868,7 @@ insertnumber (tdico * dico, int i, char *s, SPICE_DSTRINGPTR ustr_p)
|
||||||
|
|
||||||
if (found)
|
if (found)
|
||||||
{
|
{
|
||||||
accu = accu - 100000000000000LL; /* plausibility test */
|
accu = accu - 10000000000000000LL; /* plausibility test */
|
||||||
|
|
||||||
found = (accu > 0) && (accu < dynsubst + 1); /* dynsubst numbers have been allocated */
|
found = (accu > 0) && (accu < dynsubst + 1); /* dynsubst numbers have been allocated */
|
||||||
}
|
}
|
||||||
|
|
@ -1839,7 +1876,8 @@ insertnumber (tdico * dico, int i, char *s, SPICE_DSTRINGPTR ustr_p)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found)
|
if (found)
|
||||||
{ /* substitute at i-1 ongoing */
|
{
|
||||||
|
/* substitute at i-1 ongoing */
|
||||||
i--;
|
i--;
|
||||||
v_p = spice_dstring_value(&vstr) ;
|
v_p = spice_dstring_value(&vstr) ;
|
||||||
for (k = 0; k < ACT_CHARACTS; k++)
|
for (k = 0; k < ACT_CHARACTS; k++)
|
||||||
|
|
@ -1884,17 +1922,20 @@ nupa_substitute (tdico * dico, char *s, char *r, bool err)
|
||||||
c = s[i - 1];
|
c = s[i - 1];
|
||||||
|
|
||||||
if (c == Pspice)
|
if (c == Pspice)
|
||||||
{ /* try pspice expression syntax */
|
{
|
||||||
|
/* try pspice expression syntax */
|
||||||
k = i;
|
k = i;
|
||||||
nnest = 1;
|
nnest = 1;
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
k++;
|
k++;
|
||||||
d = s[k - 1];
|
d = s[k - 1];
|
||||||
if (d == '{')
|
if (d == '{')
|
||||||
nnest++;
|
nnest++;
|
||||||
else if (d == '}')
|
else if (d == '}')
|
||||||
nnest--;
|
nnest--;
|
||||||
} while (!((nnest == 0) || (d == 0)));
|
}
|
||||||
|
while (!((nnest == 0) || (d == 0)));
|
||||||
|
|
||||||
if (d == 0)
|
if (d == 0)
|
||||||
err = message (dico, "Closing \"}\" not found.");
|
err = message (dico, "Closing \"}\" not found.");
|
||||||
|
|
@ -1902,11 +1943,13 @@ nupa_substitute (tdico * dico, char *s, char *r, bool err)
|
||||||
{
|
{
|
||||||
pscopy (&tstr, s, i , k - i - 1);
|
pscopy (&tstr, s, i , k - i - 1);
|
||||||
/* exeption made for .meas */
|
/* exeption made for .meas */
|
||||||
if( strcasecmp( spice_dstring_value(&tstr),"LAST")==0) {
|
if( strcasecmp( spice_dstring_value(&tstr),"LAST")==0)
|
||||||
|
{
|
||||||
spice_dstring_reinit(&qstr) ;
|
spice_dstring_reinit(&qstr) ;
|
||||||
sadd(&qstr,"last") ;
|
sadd(&qstr,"last") ;
|
||||||
err=0;
|
err=0;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
err = evaluate (dico, &qstr, spice_dstring_value(&tstr), 0);
|
err = evaluate (dico, &qstr, spice_dstring_value(&tstr), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1919,7 +1962,8 @@ nupa_substitute (tdico * dico, char *s, char *r, bool err)
|
||||||
else if (c == Intro)
|
else if (c == Intro)
|
||||||
{
|
{
|
||||||
/* skip "&&" which may occur in B source */
|
/* skip "&&" which may occur in B source */
|
||||||
if ((i + 1 < ls) && (s[i] == Intro)) {
|
if ((i + 1 < ls) && (s[i] == Intro))
|
||||||
|
{
|
||||||
i++;
|
i++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -1931,9 +1975,11 @@ nupa_substitute (tdico * dico, char *s, char *r, bool err)
|
||||||
k = i;
|
k = i;
|
||||||
|
|
||||||
if (s[k - 1] == '(')
|
if (s[k - 1] == '(')
|
||||||
{ /* sub-formula */
|
{
|
||||||
|
/* sub-formula */
|
||||||
level = 1;
|
level = 1;
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
k++;
|
k++;
|
||||||
if (k > ls)
|
if (k > ls)
|
||||||
d = (char)(0);
|
d = (char)(0);
|
||||||
|
|
@ -1944,7 +1990,8 @@ nupa_substitute (tdico * dico, char *s, char *r, bool err)
|
||||||
level++;
|
level++;
|
||||||
else if (d == ')')
|
else if (d == ')')
|
||||||
level--;
|
level--;
|
||||||
} while (!((k > ls) || ((d == ')') && (level <= 0))));
|
}
|
||||||
|
while (!((k > ls) || ((d == ')') && (level <= 0))));
|
||||||
|
|
||||||
if (k > ls)
|
if (k > ls)
|
||||||
err = message (dico, "Closing \")\" not found.");
|
err = message (dico, "Closing \")\" not found.");
|
||||||
|
|
@ -1956,14 +2003,17 @@ nupa_substitute (tdico * dico, char *s, char *r, bool err)
|
||||||
i = k;
|
i = k;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* simple identifier may also be string? */
|
{
|
||||||
do {
|
/* simple identifier may also be string? */
|
||||||
|
do
|
||||||
|
{
|
||||||
k++;
|
k++;
|
||||||
if (k > ls)
|
if (k > ls)
|
||||||
d = (char)(0);
|
d = (char)(0);
|
||||||
else
|
else
|
||||||
d = s[k - 1];
|
d = s[k - 1];
|
||||||
} while (!((k > ls) || (d <= ' ')));
|
}
|
||||||
|
while (!((k > ls) || (d <= ' ')));
|
||||||
|
|
||||||
pscopy (&tstr, s, i-1, k - i);
|
pscopy (&tstr, s, i-1, k - i);
|
||||||
err = evaluate (dico, &qstr, spice_dstring_value(&tstr), 1);
|
err = evaluate (dico, &qstr, spice_dstring_value(&tstr), 1);
|
||||||
|
|
@ -1996,7 +2046,8 @@ getword (char *s, SPICE_DSTRINGPTR tstr_p, int after, int *pi)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
} while (!((i >= ls) || alfa (s[i - 1])));
|
}
|
||||||
|
while (!((i >= ls) || alfa (s[i - 1])));
|
||||||
|
|
||||||
spice_dstring_reinit(tstr_p) ;
|
spice_dstring_reinit(tstr_p) ;
|
||||||
|
|
||||||
|
|
@ -2034,7 +2085,8 @@ getexpress (char *s, SPICE_DSTRINGPTR tstr_p, int *pi)
|
||||||
ia++; /*white space ? */
|
ia++; /*white space ? */
|
||||||
|
|
||||||
if (s[ia - 1] == '"')
|
if (s[ia - 1] == '"')
|
||||||
{ /* string constant */
|
{
|
||||||
|
/* string constant */
|
||||||
ia++;
|
ia++;
|
||||||
i = ia;
|
i = ia;
|
||||||
|
|
||||||
|
|
@ -2043,9 +2095,11 @@ getexpress (char *s, SPICE_DSTRINGPTR tstr_p, int *pi)
|
||||||
|
|
||||||
tpe = 'S';
|
tpe = 'S';
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
i++;
|
i++;
|
||||||
} while (!((i > ls) || (s[i - 1] > ' ')));
|
}
|
||||||
|
while (!((i > ls) || (s[i - 1] > ' ')));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -2055,7 +2109,8 @@ getexpress (char *s, SPICE_DSTRINGPTR tstr_p, int *pi)
|
||||||
|
|
||||||
i = ia - 1;
|
i = ia - 1;
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (i > ls)
|
if (i > ls)
|
||||||
|
|
@ -2064,9 +2119,11 @@ getexpress (char *s, SPICE_DSTRINGPTR tstr_p, int *pi)
|
||||||
c = s[i - 1];
|
c = s[i - 1];
|
||||||
|
|
||||||
if (c == '(')
|
if (c == '(')
|
||||||
{ /* sub-formula */
|
{
|
||||||
|
/* sub-formula */
|
||||||
level = 1;
|
level = 1;
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (i > ls)
|
if (i > ls)
|
||||||
|
|
@ -2078,11 +2135,13 @@ getexpress (char *s, SPICE_DSTRINGPTR tstr_p, int *pi)
|
||||||
level++;
|
level++;
|
||||||
else if (d == ')')
|
else if (d == ')')
|
||||||
level--;
|
level--;
|
||||||
} while (!((i > ls) || ((d == ')') && (level <= 0))));
|
}
|
||||||
|
while (!((i > ls) || ((d == ')') && (level <= 0))));
|
||||||
}
|
}
|
||||||
/* buggy? */ if ((c == '/') || (c == '-'))
|
/* buggy? */ if ((c == '/') || (c == '-'))
|
||||||
comment = (s[i] == c);
|
comment = (s[i] == c);
|
||||||
} while (!((cpos (c, ",;)}") >= 0) || comment)); /* legal separators */
|
}
|
||||||
|
while (!((cpos (c, ",;)}") >= 0) || comment)); /* legal separators */
|
||||||
|
|
||||||
tpe = 'R';
|
tpe = 'R';
|
||||||
|
|
||||||
|
|
@ -2137,7 +2196,8 @@ nupa_assignment (tdico * dico, char *s, char mode)
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (s[i] == '.')
|
if (s[i] == '.')
|
||||||
{ /* skip any dot keyword */
|
{
|
||||||
|
/* skip any dot keyword */
|
||||||
while (s[i] > ' ')
|
while (s[i] > ' ')
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
@ -2150,7 +2210,8 @@ nupa_assignment (tdico * dico, char *s, char mode)
|
||||||
error = message (dico, " Identifier expected");
|
error = message (dico, " Identifier expected");
|
||||||
|
|
||||||
if (!error)
|
if (!error)
|
||||||
{ /* assignment expressions */
|
{
|
||||||
|
/* assignment expressions */
|
||||||
while ((i <= ls) && (s[i - 1] != '='))
|
while ((i <= ls) && (s[i - 1] != '='))
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
|
|
@ -2249,7 +2310,8 @@ nupa_subcktcall (tdico * dico, char *s, char *x, bool err)
|
||||||
{
|
{
|
||||||
pscopy (&tstr, spice_dstring_value(&tstr), i + 7, spice_dstring_length (&tstr));
|
pscopy (&tstr, spice_dstring_value(&tstr), i + 7, spice_dstring_length (&tstr));
|
||||||
while (j = cpos ('=', spice_dstring_value(&tstr)), j >= 0)
|
while (j = cpos ('=', spice_dstring_value(&tstr)), j >= 0)
|
||||||
{ /* isolate idents to the left of =-signs */
|
{
|
||||||
|
/* isolate idents to the left of =-signs */
|
||||||
k = j - 1;
|
k = j - 1;
|
||||||
t_p = spice_dstring_value(&tstr) ;
|
t_p = spice_dstring_value(&tstr) ;
|
||||||
while ((k >= 0) && (t_p[k] <= ' '))
|
while ((k >= 0) && (t_p[k] <= ' '))
|
||||||
|
|
@ -2261,7 +2323,8 @@ nupa_subcktcall (tdico * dico, char *s, char *x, bool err)
|
||||||
h--;
|
h--;
|
||||||
|
|
||||||
if (alfa (t_p[h + 1]) && (k > h))
|
if (alfa (t_p[h + 1]) && (k > h))
|
||||||
{ /* we have some id */
|
{
|
||||||
|
/* we have some id */
|
||||||
for (m = (h + 1); m <= k; m++)
|
for (m = (h + 1); m <= k; m++)
|
||||||
cadd (&idlist, t_p[m]);
|
cadd (&idlist, t_p[m]);
|
||||||
|
|
||||||
|
|
@ -2283,7 +2346,8 @@ nupa_subcktcall (tdico * dico, char *s, char *x, bool err)
|
||||||
|
|
||||||
if (j >= 0)
|
if (j >= 0)
|
||||||
pscopy_up ( &tstr, x, 0, j );
|
pscopy_up ( &tstr, x, 0, j );
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
scopy_up (&tstr, x);
|
scopy_up (&tstr, x);
|
||||||
j = 0 ;
|
j = 0 ;
|
||||||
}
|
}
|
||||||
|
|
@ -2297,9 +2361,12 @@ nupa_subcktcall (tdico * dico, char *s, char *x, bool err)
|
||||||
found = 0;
|
found = 0;
|
||||||
token = strtok(buf, " "); /* a bit more exact - but not sufficient everytime */
|
token = strtok(buf, " "); /* a bit more exact - but not sufficient everytime */
|
||||||
j = j + (int) strlen(token) + 1;
|
j = j + (int) strlen(token) + 1;
|
||||||
if (strcmp(token, spice_dstring_value(&subname))) {
|
if (strcmp(token, spice_dstring_value(&subname)))
|
||||||
while ((token = strtok(NULL, " ")) != NULL) {
|
{
|
||||||
if (!strcmp(token, spice_dstring_value(&subname))) {
|
while ((token = strtok(NULL, " ")) != NULL)
|
||||||
|
{
|
||||||
|
if (!strcmp(token, spice_dstring_value(&subname)))
|
||||||
|
{
|
||||||
found = 1;
|
found = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -2318,15 +2385,18 @@ nupa_subcktcall (tdico * dico, char *s, char *x, bool err)
|
||||||
j++;
|
j++;
|
||||||
|
|
||||||
while (j < ls)
|
while (j < ls)
|
||||||
{ /* try to fetch valid arguments */
|
{
|
||||||
|
/* try to fetch valid arguments */
|
||||||
k = j;
|
k = j;
|
||||||
spice_dstring_reinit(&ustr) ;
|
spice_dstring_reinit(&ustr) ;
|
||||||
if ((t_p[k] == Intro))
|
if ((t_p[k] == Intro))
|
||||||
{ /* handle historical syntax... */
|
{
|
||||||
|
/* handle historical syntax... */
|
||||||
if (alfa (t_p[k + 1]))
|
if (alfa (t_p[k + 1]))
|
||||||
k++;
|
k++;
|
||||||
else if (t_p[k + 1] == '(')
|
else if (t_p[k + 1] == '(')
|
||||||
{ /* transform to braces... */
|
{
|
||||||
|
/* transform to braces... */
|
||||||
k++;
|
k++;
|
||||||
t_p[k] = '{';
|
t_p[k] = '{';
|
||||||
g = k;
|
g = k;
|
||||||
|
|
@ -2346,7 +2416,8 @@ nupa_subcktcall (tdico * dico, char *s, char *x, bool err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alfanum (t_p[k]) || t_p[k] == '.')
|
if (alfanum (t_p[k]) || t_p[k] == '.')
|
||||||
{ /* number, identifier */
|
{
|
||||||
|
/* number, identifier */
|
||||||
h = k;
|
h = k;
|
||||||
while (t_p[k] > ' ')
|
while (t_p[k] > ' ')
|
||||||
k++;
|
k++;
|
||||||
|
|
@ -2378,7 +2449,8 @@ nupa_subcktcall (tdico * dico, char *s, char *x, bool err)
|
||||||
k = cpos ('$', spice_dstring_value(&idlist)) ;
|
k = cpos ('$', spice_dstring_value(&idlist)) ;
|
||||||
|
|
||||||
if (k >= 0)
|
if (k >= 0)
|
||||||
{ /* replace dollar with expression string u */
|
{
|
||||||
|
/* replace dollar with expression string u */
|
||||||
pscopy (&vstr, spice_dstring_value(&idlist), 0, k);
|
pscopy (&vstr, spice_dstring_value(&idlist), 0, k);
|
||||||
sadd ( &vstr, spice_dstring_value(&ustr)) ;
|
sadd ( &vstr, spice_dstring_value(&ustr)) ;
|
||||||
pscopy (&ustr, spice_dstring_value(&idlist), k+1, spice_dstring_length (&idlist));
|
pscopy (&ustr, spice_dstring_value(&idlist), k+1, spice_dstring_length (&idlist));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue