diff --git a/ChangeLog b/ChangeLog
index 29d29d1c1..fab129ca5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,42 @@
+2005-04-25 Paolo Nenzi
+
+ * src/frontend/numparam/{general.h, numparam.h, nupatest.c,
+ spicenum.c, washprog.c, xpressn.c}: Applied patch from Steven
+ Borley . The patch removed the numparam
+ support for end-of-line comments and moved it into frontend code.
+ Line buffer for numparam is increased from 250 to 1000 to accomodate
+ large model cards. Fixed compilation on Cygwin and MacOSX.
+
+ * src/frontend/subckt.c: numparams, once compiled in, must be
+ enabled, during interactive session, using "set numparams". Since
+ library is experimental and under continuos testing, it is not
+ yet intended for general use and support is provided for interactive
+ sessions only (patch from Steven Borley).
+
+ * src/frontend/{device.c, spiceif.c}: fixed case sensitivity problems
+ in key-word identification (patch from Steven Borley).
+
+ * src/frontend/inp.c: Fix a bug where the wrong argument to 'listing'
+ would error, but still produce a listing (patch fron Steven Borley).
+
+ * src/frontend/inpcom.c: From Steven Borley
+ patch:
+ End-of-line comments have been fixed and can be used on a line
+ that is followed by a continuation line. This functionality
+ has been moved from the numparams library and in to the front
+ end code. All the following can be used to start a comment:
+ ; for compatibility with PSpice
+ $ for compatibility with HSpice
+ // like C++, and as per numparams
+ -- as per numparams
+ This was a full re-write of this code, not a conversion of the
+ numparams code. It is not dependent on the numparams library.
+
+ * src/frontend/resource.c: Fixed a compile bug under window & cygwin
+ (patch from Steven Borley).
+
+ * src/frontend/plotting/x11.c: Applied patch from Steven Borley.
+
2005-04-16 Paolo Nenzi
* src/frontend/{subckt.c, inpcom.c}, src/frontend/numparam/{general.h,
diff --git a/src/frontend/device.c b/src/frontend/device.c
index f1b9701b8..328590239 100644
--- a/src/frontend/device.c
+++ b/src/frontend/device.c
@@ -663,7 +663,7 @@ devexpand(char *name)
wl = tw;
wl->wl_word = devices->wl_word;
}
- } else if (eq(name, "all")) {
+ } else if (cieq(name, "all")) {
wl = cp_cctowl(ft_curckt->ci_devices);
} else {
wl = alloc(struct wordlist);
diff --git a/src/frontend/inp.c b/src/frontend/inp.c
index f9bdf8ff4..51eea4096 100644
--- a/src/frontend/inp.c
+++ b/src/frontend/inp.c
@@ -37,7 +37,6 @@ Author: 1985 Wayne A. Christopher
static char * upper(register char *string);
static bool doedit(char *filename);
-
/* Do a listing. Use is listing [expanded] [logical] [physical] [deck] */
@@ -73,6 +72,7 @@ com_listing(wordlist *wl)
default:
fprintf(cp_err,
"Error: bad listing type %s\n", s);
+ return; /* SJB - don't go on after an error */
}
wl = wl->wl_next;
}
diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c
index 691d913eb..dd5838401 100644
--- a/src/frontend/inpcom.c
+++ b/src/frontend/inpcom.c
@@ -6,7 +6,21 @@ Author: 1985 Wayne A. Christopher
/*
* For dealing with spice input decks and command scripts
*/
-
+
+/*
+ * SJB 21 April 2005
+ * Added support for end-of-line comments that begin with any of the following:
+ * ';' (for PSpice compatability)
+ * '$' (for HSpice compatability)
+ * '//' (like in c++ and as per the numparam code)
+ * '--' (as per the numparam code)
+ * Any following text to the end of the line is ignored.
+ * Comments on a contunuation line (i.e. line begining with '+') are allowed
+ * and are removed before lines are stitched.
+ * Lines that contain only an end-of-line comment with or withou leading white
+ * space are also allowed.
+ */
+
/*
* SJB 22 May 2001
* Fixed memory leaks in inp_readall() when first(?) line of input begins with a '@'.
@@ -35,6 +49,11 @@ Author: 1985 Wayne A. Christopher
/* SJB - Uncomment this line for debug tracing */
/*#define TRACE */
+/* static declarations */
+static char * readline(FILE *fd);
+static void inp_stripcomments_deck(struct line *deck);
+static void inp_stripcomments_line(char * s);
+
/*-------------------------------------------------------------------------*
* This routine reads a line (of arbitrary length), up to a '\n' or 'EOF' *
* and returns a pointer to the resulting null terminated string. *
@@ -305,10 +324,17 @@ inp_readall(FILE *fp, struct line **data)
/* tfree(buffer); */
- /* Now clean up li: remove comments & stitch together continuation lines. */
+ /* Now clean up li: remove comments & stitch together continuation lines. */
working = cc->li_next; /* cc points to head of deck. Start with the
next card. */
+ /* sjb - strip or convert end-of-line comments.
+ This must be cone before stitching continuation lines.
+ If the line only contains an end-of-line comment then it is converted
+ into a normal comment with a '*' at the start. This will then get
+ stripped in the following code. */
+ inp_stripcomments_deck(working);
+
while (working) {
for (s = working->li_line; (c = *s) && c <= ' '; s++)
;
@@ -319,7 +345,7 @@ inp_readall(FILE *fp, struct line **data)
#endif
switch (c) {
- case '#':
+ case '#':
case '$':
case '*':
case '\0':
@@ -402,3 +428,73 @@ inp_casefix(char *string)
return;
#endif
}
+
+
+/* Strip all end-of-line comments from a deck */
+static void
+inp_stripcomments_deck(struct line *deck)
+{
+ struct line *c=deck;
+ while( c!=NULL) {
+ inp_stripcomments_line(c->li_line);
+ c= c->li_next;
+ }
+}
+
+/* Strip end of line comment from a string and remove trailing white space
+ supports comments that begin with single characters ';' or '$'
+ or double characters '//' or '--'
+ If there is only white space before the end-of-line comment the
+ the whole line is converted to a normal comment line (i.e. one that
+ begins with a '*').
+ BUG: comment characters in side of string literals are not ignored. */
+static void
+inp_stripcomments_line(char * s)
+{
+ char c = ' '; /* anything other than a comment character */
+ char * d = s;
+ if(*s=='\0') return; /* empty line */
+
+ /* look for comment */
+ while((c=*d)!='\0') {
+ d++;
+ if( (*d==';') || (*d=='$') ) {
+ break;
+ } else if( (*d==c) && ((c=='/') || (c=='-'))) {
+ *d--; /* move d back to first comment character */
+ break;
+ }
+ }
+ /* d now points to the first comment character of the null at the string end */
+
+ /* check for special case of comment at start of line */
+ if(d==s) {
+ *s = '*'; /* turn into normal comment */
+ return;
+ }
+
+ if(d>s) {
+ d--;
+ /* d now points to character just before comment */
+
+ /* eat white space at end of line */
+ while(d>=s) {
+ if( (*d!=' ') && (*d!='\t' ) )
+ break;
+ d--;
+ }
+ d++;
+ /* d now points to the first white space character before the
+ end-of-line or end-of-line comment, or it points to the first
+ end-of-line comment character, or to the begining of the line */
+ }
+
+ /* Check for special case of comment at start of line
+ with or without preceeding white space */
+ if(d<=s) {
+ *s = '*'; /* turn the whole line into normal comment */
+ return;
+ }
+
+ *d='\0'; /* terminate line in new location */
+}
diff --git a/src/frontend/numparam/general.h b/src/frontend/numparam/general.h
index 1ea052e77..b4785fc9f 100644
--- a/src/frontend/numparam/general.h
+++ b/src/frontend/numparam/general.h
@@ -85,7 +85,7 @@ Type(Pfile, FILE AT)
#ifdef __STDIO_H /* Turbo C */
Type(Pfile, FILE AT)
#else
- Type(Pfile, Pointer)
+ Type(Pfile, FILE*) /* sjb - was Pointer, now FILE* */
#endif
#endif
diff --git a/src/frontend/numparam/numparam.h b/src/frontend/numparam/numparam.h
index fef250bb9..3e72c109e 100644
--- a/src/frontend/numparam/numparam.h
+++ b/src/frontend/numparam/numparam.h
@@ -9,7 +9,8 @@
extern char * nupa_copy(char *s, int linenum);
extern int nupa_eval(char *s, int linenum);
-extern int nupa_signal(int sig, char *info);
+extern int nupa_signal(int sig, char *info);
+extern void nupa_scan(char * s, int linenum); // sjb
/***** numparam internals ********/
@@ -23,7 +24,12 @@ Cconst(Comment,'*') /*Spice Comment lines*/
Cconst(Pspice,'{') /*Pspice expression */
Cconst(Maxdico,200) /*size of symbol table*/
-Cconst(Llen,250) /* maximum composite input line length */
+/* Composite line length
+ This used to be 250 characters, but this is too easy to exceed with a
+ .model line, especially when spread over several continuation
+ lines with much white space. I hope 1000 will be enough. */
+Cconst(Llen,1000)
+
typedef char str20 [24];
typedef char str80 [84];
@@ -42,7 +48,7 @@ Record(entry)
Pchar sbbase; /* string buffer base address if any */
EndRec(entry)
-Record(fumas) /*funtion,macro,string*/
+Record(fumas) /*function,macro,string*/
Word start /*,stop*/ ; /*buffer index or location */
EndRec(fumas)
diff --git a/src/frontend/numparam/nupatest.c b/src/frontend/numparam/nupatest.c
index f4cab88a5..cfe5cd3dc 100644
--- a/src/frontend/numparam/nupatest.c
+++ b/src/frontend/numparam/nupatest.c
@@ -57,7 +57,7 @@ Func short runscript( tdico *dico, Pchar prefix,
/* return value: number of lines included */
Begin
short i,j, idef, nnest, nline, dn, myipx;
- Str(250, subpfx); /* subckt prefix */
+ Strbig(Llen, subpfx); /* subckt prefix */
Str(80, subname);
char c;
Bool done= False;
@@ -116,7 +116,7 @@ Proc gluepluslines( short imax)
/* general sweep to eliminate continuation lines */
Begin
short i,j,k, ls, p;
- Str(250,s);
+ Strbig(Llen,s);
i=1;
While i<= imax Do
If (buff[i][0]=='+') And (i>1) Then
@@ -141,7 +141,7 @@ Begin
Done
EndProc
-#if 0
+#if 0 // sjb - this is in mystring.c
Proc rs(Pchar s) /* 78 coumn limit */
Begin
short i;
@@ -185,7 +185,7 @@ EndProc
Proc wordinsert(Pchar s, Pchar w, short i)
/* insert w before s[i] */
Begin
- Str(250,t);
+ Strbig(Llen,t);
short ls=length(s);
pscopy(t,s,i+1,ls); pscopy(s,s,1,i);
sadd(s,w); sadd(s,t);
@@ -194,7 +194,7 @@ EndProc
Func short worddelete(Pchar s, short i)
/* delete word starting at s[i] */
Begin
- Str(250,t);
+ Strbig(Llen,t);
short ls= length(s);
short j=i;
While (j' ') Do Inc(j) Done
@@ -327,7 +327,7 @@ Proc getnodelist(Pchar form, Pchar act, Pchar s, tdico *dic, short k)
/* the line s contains the actual node parameters, between 1st & last word */
Begin
short j,ls, idef;
- Str(80,u); Str(250,t);
+ Str(80,u); Strbig(Llen,t);
ccopy(act,' '); ccopy(form,' ');
j=0; ls= length(s);
j= getnextword(s,u,j);
@@ -358,9 +358,9 @@ Proc nupa_test(Pchar fname, char mode)
Begin
Pfile tf, fout;
tdico * dic; /* dictionary data pointer */
- Str(250,s);
+ Strbig(Llen,s);
Str(80, prefix);
- /* Str(250, formals); Str(250,actuals); */
+ /* Strbig(Llen, formals); Strbig(Llen,actuals); */
Darray(formals, Pchar, 10)
Darray(actuals, Pchar, 10)
short i, j, k, nline, parstack;
diff --git a/src/frontend/numparam/spicenum.c b/src/frontend/numparam/spicenum.c
index 0acb94d97..03b468134 100644
--- a/src/frontend/numparam/spicenum.c
+++ b/src/frontend/numparam/spicenum.c
@@ -22,6 +22,7 @@ Todo:
*/
#include
+#include
#ifdef __TURBOC__
#include /* exit() */
#endif
@@ -30,7 +31,7 @@ Todo:
#include "numparam.h"
/* Uncomment this line to allow debug tracing */
-/*#define TRACE_NUMPARAMS */
+/* #define TRACE_NUMPARAMS */
/* the nupa_signal arguments sent from Spice:
@@ -55,6 +56,7 @@ Todo:
#define PlaceHold 1000000000L
Intern long placeholder= 0;
+#ifdef NOT_REQUIRED /* SJB - not required as front-end now does stripping */
Intern
Func short stripcomment( Pchar s)
/* allow end-of-line comments in Spice, like C++ */
@@ -82,6 +84,7 @@ Begin
EndIf
return i /* i>=0 if comment stripped at that position */
EndFunc
+#endif /* NOT_REQUIRED */
Intern
Proc stripsomespace(Pchar s, Bool incontrol)
@@ -106,7 +109,7 @@ Proc partition(Pchar t)
/* the Basic preprocessor doesnt understand multiple cmd/line */
/* bug: strip trailing spaces */
Begin
- Str(Llen,u);
+ Strbig(Llen,u);
short i,lt,state;
char c;
cadd(u,Intro);
@@ -140,7 +143,7 @@ Func short stripbraces( Pchar s)
/* puts the funny placeholders. returns the number of {...} substitutions */
Begin
short n,i,nest,ls,j;
- Str(Llen,t);
+ Strbig(Llen,t);
n=0; ls=length(s);
i=0;
While i=0) And (Not found) Do /* skip space, then non-space */
While (k>=0) And (s[k]<=' ') Do Dec(k) Done;
h=k+1; /* at h: space */
@@ -212,7 +215,7 @@ Begin
Done
found= (getidtype(dico, name) == 'U');
EndIf
- Done
+ Done
If found And (h new style with braces. */
Begin
- Str(250,t);
+ Strbig(Llen,t);
short i,state, ls;
char c,d;
i=0; state=0;
@@ -264,7 +267,7 @@ Func char transform(tdico * dico, Pchar s, Bool nostripping, Pchar u)
* any + line is copied as-is.
* any & or .param line is commented-out.
* any .subckt line has params section stripped off
- * any X line loses its arguments after circuit name
+ * any X line loses its arguments after sub-circuit name
* any &id or &() or {} inside line gets a 10-digit substitute.
*
* strip the new syntax off the codeline s, and
@@ -282,10 +285,10 @@ Func char transform(tdico * dico, Pchar s, Bool nostripping, Pchar u)
* 'B' netlist (or .model ?) line that had Braces killed
*/
Begin
- Str(Llen,t);
+ Strbig(Llen,t);
char category;
short i,k, a,n;
- i=stripcomment(s);
+/* i=stripcomment(s); sjb - not required now that front-end does stripping */
stripsomespace(s, nostripping);
modernizeex(s); /* required for stripbraces count */
scopy(u,"");
@@ -321,7 +324,7 @@ Begin
category='P';
ElsIf upcase(s[0])=='X' Then /* strip actual parameters */
i=findsubname(dico, s); /* i= index following last identifier in s */
- pscopy(s,s,1,i);
+/* pscopy(s,s,1,i); sjb - this is already done by findsubname() */
category='X'
ElsIf s[0]=='+' Then /* continuation line */
category='+'
@@ -367,7 +370,7 @@ Intern tdico * dico=Null;
Intern
Proc putlogfile(char c, int num, Pchar t)
Begin
- Str(Llen, u);
+ Strbig(Llen, u);
Str(20,fname);
If dologfile Then
If(logfile == Null) Then
@@ -437,6 +440,14 @@ Begin
placeholder= 0;
/* release symbol table data */
EndProc
+
+/* SJB - Scan the line for subcircuits */
+Proc nupa_scan(Pchar s, int linenum)
+Begin
+ If spos(".SUBCKT",s) ==1 Then
+ defsubckt( dico, s, linenum, 'U' );
+ EndIf
+EndProc
Func Pchar nupa_copy(Pchar s, int linenum)
/* returns a copy (not quite) of s in freshly allocated memory.
@@ -452,8 +463,8 @@ Func Pchar nupa_copy(Pchar s, int linenum)
- substitute placeholders for all {..} --> 10-digit numeric values.
*/
Begin
- Str(250,u);
- Str(250,keywd);
+ Strbig(Llen,u);
+ Strbig(Llen,keywd);
Pchar t;
short i,ls;
char c,d;
@@ -514,7 +525,7 @@ Begin
#ifdef TRACE_NUMPARAMS
printf("** SJB - in nupa_eval()\n");
printf("** SJB - processing line %3d: %s\n",linenum,s);
- printf("** SJB - category '%c'\n");
+ printf("** SJB - category '%c'\n",c);
#endif /* TRACE_NUMPARAMS */
If c=='P' Then /* evaluate parameters */
nupa_assignment( dico, dico->refptr[linenum] , 'N');
@@ -561,8 +572,10 @@ Begin
return 1
EndFunc
+#ifdef USING_NUPATEST
+/* This is use only by the nupatest program */
Func tdico * nupa_fetchinstance(void)
Begin
return dico
EndFunc
-
+#endif /* USING_NUPATEST */
diff --git a/src/frontend/numparam/washprog.c b/src/frontend/numparam/washprog.c
index 4a60279e1..a53f14d8d 100644
--- a/src/frontend/numparam/washprog.c
+++ b/src/frontend/numparam/washprog.c
@@ -118,7 +118,7 @@ EndProc
Proc saddn( Pchar s, Pchar t, short n)
Begin
- Str(250,u);
+ Strbig(Llen,u);
short lt= length(t);
If lt<= n Then
sadd(s,t)
@@ -367,7 +367,7 @@ Begin
Word j,k,dk,ls, lst, lmt, jmax, pj;
Bool ok;
char arg;
- Str(250,u);
+ Strbig(Llen,u);
Str(40,st);
/* returns >0 If comparison Ok == length of compared Pchar */
/*-StartProc-*/ k=0;
@@ -441,7 +441,7 @@ Begin
Word j,k,ps,ls;
Bool ok;
char endc;
- Str(250,u);
+ Strbig(Llen,u);
/* returns >0 if comparison Ok = length of compared string */
/* char comparison, s may have wildcard regions with "æ" BUT 1 valid End */
/*-StartProc-*/
@@ -578,7 +578,7 @@ EndFunc
Func Bool getSubList(Pchar slist)
/* read the search and substitution rule list */
Begin
- Str(250,s);
+ Strbig(Llen,s);
Pfile f;
Bool done, ok;
/*-StartProc-*/
@@ -629,7 +629,7 @@ EndFunc
*/
Bool washmore= True; /* flag that activates the postprocessor */
-Str(250,obf); /* output buffer */
+Strbig(Llen,obf); /* output buffer */
short iobf=0; /* its index */
short wstate=0; /* output state machine */
@@ -723,7 +723,7 @@ Proc translate(Pchar bf); /* recursion */
Proc echoOut(Pchar r, char isWild, string mac[] )
Begin
short u;
- Str(250,s);
+ Strbig(Llen,s);
/*-StartProc-*/
If isWild !=0 Then
u= cpos(isWild,r)
@@ -779,7 +779,7 @@ Begin
char c;
short i,j;
Bool escape;
- Str(250,s);
+ Strbig(Llen,s);
/*-StartProc-*/
escape=False;
For i=0; ierrcount);
If (dic->srcfile != Null) And NotZ(dic->srcfile[0]) Then
scopy(t, dic->srcfile); cadd(t,':')
@@ -166,7 +167,7 @@ Begin
ok=False;
i=d->nbd+1;
While (Not ok) And (i>1) Do
- Dec(i);
+ Dec(i);
ok= steq(d->dat[i].nom, s);
Done
If Not ok Then
@@ -194,7 +195,7 @@ Begin
Bool err= *perr;
Word k;
double u;
- Str(Llen, s);
+ Strbig(Llen, s);
k=entrynb(dico,t); /*no keyword*/
/*dbg -- If k<=0 Then ws("Dico num lookup fails. ") EndIf */
While (k>0) And (dico->dat[k].tp=='P') Do
@@ -269,7 +270,7 @@ Begin
short i;
char c;
Bool err, warn;
- Str(Llen,v);
+ Strbig(Llen,v);
i=attrib(dico,t,op);
err=False;
If i<=0 Then
@@ -369,7 +370,7 @@ Begin
if jumped, return index to existing function
*/
short i,j;
- Str(Llen, v);
+ Strbig(Llen, v);
i=attrib(dico,t,' '); j=0;
If i<=0 Then
err=message( dico," Symbol table overflow")
@@ -501,7 +502,7 @@ Begin
short ls;
char c;
Bool ok;
- Str(Llen, t);
+ Strbig(Llen, t);
ls=length(s);
x=0.0;
Repeat
@@ -546,7 +547,7 @@ Begin
short k,err;
char d;
Str(20, t);
- Str(Llen, v);
+ Strbig(Llen, v);
double u;
k=i;
Repeat
@@ -614,7 +615,7 @@ Begin
Byte level= *plevel;
Bool error= *perror;
char c,d;
- Str(Llen, v);
+ Strbig(Llen, v);
c=s[i-1];
If ioption) >0; /* we had -3 on the command line */
i=0; ls=length(s);
@@ -1190,8 +1191,8 @@ Func Bool nupa_substitute( tdico *dico, Pchar s, Pchar r, Bool err)
Begin
short i,k,ls,level, nnest, ir;
char c,d;
- Str(Llen, q);
- Str(Llen, t);
+ Strbig(Llen, q);
+ Strbig(Llen, t);
i=0;
ls=length(s);
err=False;
@@ -1367,8 +1368,8 @@ Func Bool nupa_assignment( tdico *dico, Pchar s, char mode)
*/
Begin
/* s has the format: ident = expression; ident= expression ... */
- Str(Llen, t);
- Str(Llen,u);
+ Strbig(Llen, t);
+ Strbig(Llen,u);
short i,j, ls;
Byte key;
Bool error, err;
@@ -1422,12 +1423,13 @@ Func Bool nupa_subcktcall( tdico *dico, Pchar s, Pchar x, Bool err)
x= a matching subckt call line, with actual params
*/
Begin
- short n,m,i,j,k,g,h, narg, ls, nest;
- Str(Llen,t);
- Str(Llen,u);
- Str(Llen,v);
- Str(Llen,idlist);
+ short n,m,i,j,k,g,h, narg=0, ls, nest;
+ Strbig(Llen,t);
+ Strbig(Llen,u);
+ Strbig(Llen,v);
+ Strbig(Llen,idlist);
Str(80,subname);
+
/***** first, analyze the subckt definition line */
n=0; /* number of parameters if any */
ls=length(s);
diff --git a/src/frontend/plotting/x11.c b/src/frontend/plotting/x11.c
index a4836fb69..76e5b11e6 100644
--- a/src/frontend/plotting/x11.c
+++ b/src/frontend/plotting/x11.c
@@ -709,8 +709,6 @@ zoomin(GRAPH *graph)
char buf[BSIZE_SP];
char buf2[128];
char *t;
- wordlist *wl;
- int dummy;
Window rootwindow, childwindow;
int rootx, rooty;
@@ -790,11 +788,16 @@ zoomin(GRAPH *graph)
/* don't use the following if using GNU Readline - AV */
#ifndef HAVE_GNUREADLINE
- /* hack for Gordon Jacobs */
- /* add to history list if plothistory is set */
- if (cp_getvar("plothistory", VT_BOOL, (char *) &dummy)) {
- wl = cp_parse(buf);
- (void) cp_addhistent(cp_event++, wl);
+ {
+ wordlist *wl;
+ int dummy;
+
+ /* hack for Gordon Jacobs */
+ /* add to history list if plothistory is set */
+ if (cp_getvar("plothistory", VT_BOOL, (char *) &dummy)) {
+ wl = cp_parse(buf);
+ (void) cp_addhistent(cp_event++, wl);
+ }
}
#endif /* HAVE_GNUREADLINE */
diff --git a/src/frontend/resource.c b/src/frontend/resource.c
index 11149c07e..72aa762ee 100644
--- a/src/frontend/resource.c
+++ b/src/frontend/resource.c
@@ -19,6 +19,14 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#ifdef HAVE__MEMAVL
#define WIN32_LEAN_AND_MEAN
+/*
+ * The ngspice.h file included above defines BOOLEAN (via bool.h) and this
+ * clashes with the definition obtained from windows.h (via winnt.h).
+ * However, BOOLEAN is not used by this file so we can work round this problem
+ * by undefining BOOLEAN before including windows.h
+ * SJB - April 2005
+ */
+#undef BOOLEAN
#include
#endif
@@ -199,7 +207,7 @@ printres(char *name)
# else
# ifdef HAVE_FTIME
struct timeb timenow;
- int sec, msec;
+// int sec, msec; sjb
ftime(&timenow);
timediff(&timenow, &timebegin, &total, &totalu);
// totalu /= 1000; hvogt
diff --git a/src/frontend/spiceif.c b/src/frontend/spiceif.c
index 0984ec41f..bbe5fdffa 100644
--- a/src/frontend/spiceif.c
+++ b/src/frontend/spiceif.c
@@ -702,8 +702,11 @@ parmtovar(IFvalue *pv, IFparm *opt)
return (vv);
}
-/* Extract the IFparm structure from the device. If isdev is TRUE, then get
- * the DEVmodQuest, otherwise get the DEVquest.
+/* Extract the parameter (IFparm structure) from the device or device's model.
+ * If do_mode is TRUE then look in the device's parameters
+ * If do_mode is FALSE then look in the device model's parameters
+ * If inout equals 1 then look only for parameters with the IF_SET type flag
+ * if inout equals 0 then look only for parameters with the IF_ASK type flag
*/
static IFparm *
@@ -711,9 +714,6 @@ parmlookup(IFdevice *dev, GENinstance **inptr, char *param, int do_model, int in
{
int i;
- /* fprintf(cp_err, "Called: parmlookup(%x, %c, %s)\n",
- dev, isdev, param); */
-
/* First try the device questions... */
if (!do_model && dev->numInstanceParms) {
for (i = 0; i < *(dev->numInstanceParms); i++) {
@@ -723,7 +723,7 @@ parmlookup(IFdevice *dev, GENinstance **inptr, char *param, int do_model, int in
continue;
else if ((((dev->instanceParms[i].dataType & IF_SET) && inout == 1)
|| ((dev->instanceParms[i].dataType & IF_ASK) && inout == 0))
- && eq(dev->instanceParms[i].keyword, param))
+ && cieq(dev->instanceParms[i].keyword, param))
{
if (dev->instanceParms[i].dataType & IF_REDUNDANT)
i -= 1;
diff --git a/src/frontend/subckt.c b/src/frontend/subckt.c
index db350f4ef..62adb85dd 100644
--- a/src/frontend/subckt.c
+++ b/src/frontend/subckt.c
@@ -61,7 +61,7 @@ Modified: 2000 AlansFixes
#include "variable.h"
/* Uncomment to turn on tracing for the Numparam */
-//#define TRACE_NUMPARAMS
+/*#define TRACE_NUMPARAMS*/
#ifdef NUMPARAMS
#define NUPADECKCOPY 0
@@ -71,6 +71,7 @@ Modified: 2000 AlansFixes
extern char * nupa_copy(char *s, int linenum);
extern int nupa_eval(char *s, int linenum);
extern int nupa_signal(int sig, char *info);
+extern void nupa_scan(char * s, int linenum); // sjb
#endif
/* ----- static declarations ----- */
@@ -117,13 +118,13 @@ struct subs {
static wordlist *modnames, *submod;
static struct subs *subs = NULL;
static bool nobjthack = FALSE;
+#ifdef NUMPARAMS
+/* flag indicating use of the experimental numparams library */
+static bool use_numparams = FALSE;
+#endif
static char start[32], sbend[32], invoke[32], model[32];
-#ifdef NUMPARAMS
-static char NumParams='y';
-#endif
-
/*-------------------------------------------------------------------*/
/* inp_subcktexpand is the top level function which translates */
/* .subckts into mainlined code. Note that there are two things */
@@ -147,7 +148,7 @@ inp_subcktexpand(struct line *deck)
char *s;
#ifdef NUMPARAMS
int ok;
-#endif
+#endif /* NUMPARAMS */
wordlist *wl;
modnames = NULL;
@@ -162,10 +163,12 @@ inp_subcktexpand(struct line *deck)
if(!cp_getvar("modelline", VT_STRING, model))
(void) strcpy(model, ".model");
(void) cp_getvar("nobjthack", VT_BOOL, (char *) &nobjthack);
-
+
#ifdef NUMPARAMS
+ (void) cp_getvar("numparams", VT_BOOL, (char *) &use_numparams);
+
/* deck has .control sections already removed, but not comments */
- if ( NumParams == 'y' ) {
+ if ( use_numparams ) {
#ifdef TRACE_NUMPARAMS
printf("Numparams is processing this deck:\n");
@@ -174,9 +177,14 @@ inp_subcktexpand(struct line *deck)
printf("%3d:%s\n",c->li_linenum, c->li_line);
c= c->li_next;
}
-#endif
+#endif /* TRACE_NUMPARAMS */
- ok = nupa_signal( NUPADECKCOPY, NULL);
+ ok = nupa_signal( NUPADECKCOPY, NULL);
+ c=deck;
+ while ( c != NULL) { /* first Numparam pass */
+ nupa_scan(c->li_line, c->li_linenum);
+ c= c->li_next;
+ }
c=deck;
while ( c != NULL) { /* first Numparam pass */
c->li_line = nupa_copy(c->li_line, c->li_linenum);
@@ -190,10 +198,10 @@ inp_subcktexpand(struct line *deck)
printf("%3d:%s\n",c->li_linenum, c->li_line);
c= c->li_next;
}
-#endif
+#endif /* TRACE_NUMPARAMS */
- }
-#endif
+ }
+#endif /* NUMPARAMS */
/* Get all the model names so we can deal with BJTs, etc.
* Stick all the model names into the doubly-linked wordlist modnames.
@@ -217,7 +225,7 @@ inp_subcktexpand(struct line *deck)
for(w = modnames; w; w = w->wl_next)
printf("%s\n",w->wl_word);
}
-#endif
+#endif /* TRACE */
/* Let's do a few cleanup things... Get rid of ( ) around node
@@ -228,7 +236,7 @@ inp_subcktexpand(struct line *deck)
#ifdef TRACE
/* SDB debug statement */
printf("In inp_subcktexpand, found a .subckt: %s\n", c->li_line);
-#endif
+#endif /* TRACE */
for (s = c->li_line; *s && (*s != '('); s++) /* Iterate charwise along line until ( is found */
;
if (*s) {
@@ -264,7 +272,7 @@ inp_subcktexpand(struct line *deck)
#ifdef TRACE
/* SDB debug statement */
printf("In inp_subcktexpand, about to call doit.\n");
-#endif
+#endif /* TRACE */
ll = doit(deck);
// SJB: free up the modnames linked list now we are done with it
@@ -276,13 +284,17 @@ inp_subcktexpand(struct line *deck)
/* Now check to see if there are still subckt instances undefined... */
if (ll!=NULL) for (c = ll; c; c = c->li_next)
if (ciprefix(invoke, c->li_line)) {
- fprintf(cp_err, "Error: unknown subckt: %s\n",
- c->li_line);
+ fprintf(cp_err, "Error: unknown subckt: %s\n", c->li_line);
+#ifdef NUMPARAMS
+ if ( use_numparams ) {
+ ok= ok && nupa_signal(NUPAEVALDONE, NULL);
+ }
+#endif /* NUMPARAMS */
return NULL;
}
#ifdef NUMPARAMS
- if ( NumParams == 'y' ) {
+ if ( use_numparams ) {
/* the NUMPARAM final line translation pass */
ok= ok && nupa_signal(NUPASUBDONE, NULL);
c= ll;
@@ -297,10 +309,10 @@ inp_subcktexpand(struct line *deck)
printf("%3d:%s\n",c->li_linenum, c->li_line);
c= c->li_next;
}
-#endif
+#endif /* TRACE_NUMPARAMS */
ok= ok && nupa_signal(NUPAEVALDONE, NULL);
}
-#endif
+#endif /* NUMPARAMS */
return (ll); /* return the spliced deck. */
}
@@ -322,7 +334,7 @@ doit(struct line *deck)
struct line *c, *last, *lc, *lcc;
#ifdef NUMPARAMS
struct line *savenext;
-#endif
+#endif /* NUMPARAMS */
struct subs *sss = (struct subs *) NULL, *ks; /* *sss and *ks temporarily hold decks to substitute */
char *s, *t, *scname, *subname;
int nest, numpasses = MAXNEST, i;
@@ -388,8 +400,8 @@ doit(struct line *deck)
if (!lcc) /* if lcc is null, then no .ends was found. */
lcc = last;
#ifdef NUMPARAMS
- if ( NumParams != 'y' )
-#endif
+ if ( use_numparams==FALSE )
+#endif /* NUMPARAMS */
lcc->li_next = NULL; /* shouldn't we free some memory here????? */
/* At this point, last points to the .subckt card, and lcc points to the .ends card */
@@ -424,7 +436,7 @@ doit(struct line *deck)
#ifdef NUMPARAMS
/*gp */ c->li_next = NULL; /* Numparam needs line c */
c->li_line[0] = '*'; /* comment it out */
-#endif
+#endif /* NUMPARAMS */
}
else { /* line is neither .ends nor .subckt. */
/* make lc point to this card, and advance last to next card. */
@@ -534,12 +546,12 @@ doit(struct line *deck)
/* Now splice the decks together. */
#ifdef NUMPARAMS
savenext = c->li_next;
- if ( NumParams != 'y') {
- /* old style: c will drop a dangling pointer: memory leak */
- if (lc)
- lc->li_next = lcc;
- else
- deck = lcc;
+ if ( use_numparams==FALSE ) {
+ /* old style: c will drop a dangling pointer: memory leak */
+ if (lc)
+ lc->li_next = lcc;
+ else
+ deck = lcc;
} else {
/* ifdef NUMPARAMS, keep the invoke line as a comment */
c->li_next = lcc;
@@ -550,13 +562,13 @@ doit(struct line *deck)
lc->li_next = lcc;
else
deck = lcc;
-#endif
+#endif /* NUMPARAMS */
while (lcc->li_next != NULL)
lcc = lcc->li_next;
lcc->li_next = c->li_next;
#ifdef NUMPARAMS
lcc->li_next = savenext;
-#endif
+#endif /* NUMPARAMS */
c = lcc->li_next;
lc = lcc;
tfree(tofree);