15 #include <sys/types.h> 24 static char *
upper(
char*);
25 static void spsource(FILE*,
bool,
bool,
char*);
30 static void varsub(
char**);
79 "Error: bad listing type %s\n", s);
88 fprintf(
cp_err,
"Error: no circuit loaded.\n");
96 register
char *
string;
125 struct
line *deck, *extras;
130 struct line *tmp, *next;
132 bool useout = (file ==
cp_out);
160 for (here = deck; here; here = here->
li_next) {
174 fprintf(file,
"%6d : %s\n",
183 fprintf(file,
"%s\n",
197 fprintf(file,
"%6d : .end\n", i);
201 for (here = deck; here; here = here->
li_next) {
216 fprintf(file,
"%6d : %s\n",
225 fprintf(file,
"%s\n",
233 fprintf(file,
"%s\n",
251 fprintf(file,
"%6d : %s\n",
260 fprintf(file,
"%s\n",
269 fprintf(file,
"%s\n",
286 fprintf(file,
"%6d : .end\n", i);
292 fprintf(file,
".end\n");
296 fprintf(
cp_err,
"inp_list: Internal Error: bad type %d\n",type);
314 spsource(fp, comfile, comfile, filename);
322 bool nospice, nocmds;
331 if (
prefix(
"(Symbo",buf)) {
344 if (
prefix(
".check",buf)) {
353 if (
prefix(
".stim",buf)) {
356 MB_run(fp,1,filename);
388 bool nospice, nocmds;
392 FILE *lastin, *lastout, *lasterr;
398 if (!nospice &&
is_ckt(deck)) {
401 out_printf(
"\nCircuit: %s\n\n", deck->li_line);
412 if (!nocmds || nospice) {
422 for (wl = controls; wl; wl = wl->
wl_next)
452 if (!*s || *s ==
'*' || *s ==
'#') {
468 struct line *dd, *realdeck, *options;
471 bool nosubckts =
false;
475 tt =
copy(deck->li_line);
479 if (*dd->
li_line ==
'*')
continue;
501 "Error during subcircuit expansion, circuit not loaded.\n");
510 fprintf(
cp_err,
"Error: no lines in input\n");
527 struct line *dd, *ld;
538 while (isspace(*s)) s++;
571 struct line *dd, *ld;
581 if (commands && !allcmds)
583 "Warning: redundant .control card\n");
594 "Warning: misplaced .endc card\n");
623 while (isspace(*s)) s--;
676 #define VALIDCHARS "_<#?@.()[]&" 690 while (isspace(*c)) c++;
692 while ((d = strchr(c,
'$')) !=
NULL) {
706 while(isspace(*c)) *c-- =
'\0';
709 if (*++d ==
'\0')
break;
710 if (*++d ==
'\0')
break;
752 while (*d && isspace(*d)) d++;
781 for (ww = wl; ww; ww = ww->
wl_next)
782 len += strlen(ww->
wl_word) + 1;
785 for (ww = wl; ww; ww = ww->
wl_next) {
788 while (*s ==
'%') s++;
813 struct
line *options;
828 for (dd = deck; dd; dd = dd->
li_next) {
834 for (dd = options; dd; dd = dd->
li_next) {
858 for (dd = deck; dd; dd = dd->
li_next)
861 fprintf(
cp_err,
"Warning, line %d : %s\n%s\n",
903 for (; options; options = options->
li_next) {
906 for (s = options->
li_line; *s && !isspace(*s); s++)
947 bool permfile, nosource =
false, reuse =
false;
963 if (
eq(wl->wl_word,
"-n")) {
968 if (
eq(wl->wl_word,
"-r")) {
973 if (wl->wl_next &&
eq(wl->wl_next->wl_word,
"-n"))
975 if (wl->wl_next &&
eq(wl->wl_next->wl_word,
"-r"))
977 filename = wl->wl_word;
995 if (!(fp = fopen(filename,
"w"))) {
1002 "Warning: editing a temporary file -- circuit not saved\n");
1007 if (!(fp = fopen(filename,
"w"))) {
1011 fprintf(fp,
"SPICE 3 test deck\n");
1017 if ((!rval ||
cieq(ed,
"xeditor")) && !
xeditor(filename)) {
1029 struct stat st1, st2;
1032 i = stat(filename,&st1);
1035 j = stat(filename,&st2);
1038 if (!i && st1.st_mtime == st2.st_mtime) {
1060 bool permfile, reuse;
1103 FILE *fp,*errfp,*outfp,*errtmp,*outtmp;
1105 bool inter, nosource =
false, reuse =
false;
1106 char *errmsg =
"Error: no symbolic representation found.\n";
1107 char *filename,*errfile,*outfile;
1117 if (
eq(wl->wl_word,
"-n")) {
1122 if (
eq(wl->wl_word,
"-r")) {
1127 if (wl->wl_next &&
eq(wl->wl_next->wl_word,
"-n"))
1129 if (wl->wl_next &&
eq(wl->wl_next->wl_word,
"-r"))
1131 filename = wl->wl_word;
1144 filename =
"noname";
1151 errfp = fopen(errfile,
"w+");
1152 outfp = fopen(outfile,
"w");
1153 if (errfp ==
NULL || outfp ==
NULL) {
1154 fprintf(
cp_err,
"Error: redirection failed.\n");
1167 struct stat st1, st2;
1171 k = stat(filename,&st1);
1172 i =
sced(&filename);
1174 j = stat(filename,&st2);
1177 if (!k &&
eq(f1,filename) && st1.st_mtime == st2.st_mtime) {
1190 i =
sced(&filename);
1204 if (i == 2 || nosource)
1213 fprintf(
cp_err,
"Sourcing the spice text from %s\n",filename);
1215 "Warning: this text may not accurately reflect subcircuit changes\n\ 1216 made after %s was saved in sced\n",filename);
1244 char *tempfile =
NULL, *fname;
1247 bool nospice =
false, nocmds =
false, reuse =
false;
1252 for (; wl; wl = wn) {
1254 if (*wl->wl_word !=
'-')
1256 if (strchr(wl->wl_word,
'n'))
1258 else if (strchr(wl->wl_word,
'c'))
1260 else if (strchr(wl->wl_word,
'r'))
1277 if (wl && wl->wl_next) {
1290 while ((i = fread(buf, 1,
BSIZE_SP, tp)) > 0)
1291 (
void) fwrite(buf, 1, i, fp);
1295 (void) fseek(fp, (
long) 0, 0);
1307 if (reuse && !nospice)
1314 fname = wl->wl_word;
void com_edit(wordlist *wl)
static char buf[MAXPROMPT]
void inp_decksource(struct line *deck, bool comfile, char *filename)
bool cp_getvar(char *n, int t, char *r)
static wordlist * get_speccmds()
struct line * inp_deckcopy()
struct line * ci_origdeck
bool inp_spdeck(struct line *deck, char *filename)
void inp_srcedit(char *filename, bool permfile, bool reuse)
void inp_source(char *file)
void inp_spsource(FILE *fp, bool comfile, char *filename)
struct line * inp_getopts()
static wordlist * get_controls()
struct variable * cp_setparse()
void com_source(wordlist *wl)
struct circ * ft_circuits
struct wordlist * wl_prev
void inp_list(FILE *file, struct line *deck, struct line *extras, int type)
static wordlist * wl_separate()
void inp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse, struct line *options, char *filename)
void com_listing(wordlist *wl)
struct variable * ci_vars
struct line * inp_subcktexpand()
static struct ccom * commands
void com_sced(wordlist *wl)
struct wordlist * wl_next
struct variable * va_next
void ShowPrompt(char *str)