Browse Source

abort if .inc fails

pre-master-46
h_vogt 16 years ago
parent
commit
dd66fc7220
  1. 5
      ChangeLog
  2. 7
      src/frontend/inpcom.c
  3. 86
      src/frontend/subckt.c

5
ChangeLog

@ -1,6 +1,7 @@
2010-05-15 Holger Vogt
* inpcom.c exclude comment lines from stripping EOL comments
subckt.c: exclude *, . and .control ... .endc lines from processing to
* inpcom.c: exclude comment lines from stripping EOL comments,
make ngspice abort if .inc <file> fails.
subckt.c: exclude *, and . lines from processing to
getting rid of ( ) around node lists
2010-05-14 Holger Vogt

7
src/frontend/inpcom.c

@ -1242,7 +1242,8 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name)
if (!*s) { /* if at end of line, error */
fprintf(cp_err, "Error: .include filename missing\n");
tfree(buffer); /* was allocated by readline() */
continue;
controlled_exit(EXIT_FAILURE);
// continue;
} /* Now s points to first char after .include */
for (t = s; *t && !isspace(*t) && !isquote(*t); t++) /* now advance past non-space chars */
;
@ -1266,8 +1267,10 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name)
if(copys) {
tfree(copys); /* allocated by the cp_tildexpand() above */
}
fprintf(cp_err, "Error: .include statement failed.\n");
tfree(buffer); /* allocated by readline() above */
continue;
controlled_exit(EXIT_FAILURE);
// continue;
}
}

86
src/frontend/subckt.c

@ -271,58 +271,58 @@ inp_subcktexpand(struct line *deck)
/* Let's do a few cleanup things... Get rid of ( ) around node lists... */
for (c = deck; c; c = c->li_next) { /* iterate on lines in deck */
/* exclude any line inside .control ... .endc */
if ( ciprefix(".control", c->li_line) ) {
skip_control ++;
continue;
} else if( ciprefix(".endc", c->li_line) ) {
skip_control --;
continue;
} else if(skip_control > 0) {
char *s = c->li_line;
if(*s == '*') /* skip comment */
continue;
}
if (ciprefix(start, c->li_line)) { /* if we find .subckt . . . */
if (ciprefix(start, s)) { /* if we find .subckt . . . */
#ifdef TRACE
/* SDB debug statement */
printf("In inp_subcktexpand, found a .subckt: %s\n", c->li_line);
#endif /* TRACE */
for (s = c->li_line; *s && (*s != '('); s++) /* Iterate charwise along line until ( is found */
;
if (*s) {
while (s[0] && (s[1] != ')')) {
s[0] = s[1];
s++;
}
while (s[1]) {
s[0] = s[2];
s++;
}
} /* if (*s) . . . */
}
else if ((*(c->li_line)=='*') || (*(c->li_line)=='.')) {
continue;
/* SDB debug statement */
printf("In inp_subcktexpand, found a .subckt: %s\n", s);
#endif
while (*s && *s != '(') /* search opening paren */
s++;
if (*s == '(') {
int level = 0;
do {
/* strip outer parens '(' ')', just the first pair */
if(*s == '(' && level++ == 0) {
*s = ' ';
}
if(*s == ')' && --level == 0) {
*s = ' ';
break;
}
} while(*s++);
}
}
else if (*s=='.') {
continue; /* skip .commands */
}
else { /* any other line . . . */
/* Iterate charwise along line until first space is found */
for (s = c->li_line; *s && !isspace(*s); s++)
;
while (isspace(*s))
else { /* any other line . . . */
while (*s && !isspace(*s)) /* skip first token */
s++;
/* continure here only if '(' follows after the first space */
while (*s && isspace(*s)) /* skip whitespace */
s++;
if (*s == '(') {
while (s[0] && (s[1] != ')')) {
s[0] = s[1];
s++;
}
while (s[1]) {
s[0] = s[2];
s++;
} /* while */
int level = 0;
do {
/* strip outer parens '(' ')', just the first pair, why ? */
if(*s == '(' && level++ == 0) {
*s = ' ';
}
if(*s == ')' && --level == 0) {
*s = ' ';
break;
}
} while(*s++);
} /* if (*s == '(' . . . */
} /* any other line */
} /* for (c = deck . . . */
/* doit does the actual splicing in of the .subckt . . . */
#ifdef TRACE

Loading…
Cancel
Save