During syntax check: v,i sources need two nodes,
and prevent crash upon buggy ac input.
This commit is contained in:
parent
29c51c0d30
commit
3420e66705
|
|
@ -8421,7 +8421,17 @@ static void inp_check_syntax(struct card *deck)
|
||||||
/* check for missing ac <val> in voltage or current source */
|
/* check for missing ac <val> in voltage or current source */
|
||||||
if (check_control == 0 && strchr("VvIi", *cut_line)) {
|
if (check_control == 0 && strchr("VvIi", *cut_line)) {
|
||||||
int err = 0;
|
int err = 0;
|
||||||
char* acline = search_plain_identifier(cut_line, "ac");
|
char* acline;
|
||||||
|
/* skip instance name and nodes */
|
||||||
|
acline = nexttok(cut_line);
|
||||||
|
acline = nexttok(acline);
|
||||||
|
acline = nexttok(acline);
|
||||||
|
if (!acline) {
|
||||||
|
fprintf(stderr, "Error in line %s\n", cut_line);
|
||||||
|
fprintf(stderr, " Not enough parameters\n");
|
||||||
|
controlled_exit(EXIT_BAD);
|
||||||
|
}
|
||||||
|
acline = search_plain_identifier(acline, "ac");
|
||||||
if (acline == NULL)
|
if (acline == NULL)
|
||||||
continue;
|
continue;
|
||||||
/* skip ac */
|
/* skip ac */
|
||||||
|
|
@ -8438,6 +8448,7 @@ static void inp_check_syntax(struct card *deck)
|
||||||
char* nnacline = nacline;
|
char* nnacline = nacline;
|
||||||
/* get first token after ac */
|
/* get first token after ac */
|
||||||
char* numtok = gettok_node(&nnacline);
|
char* numtok = gettok_node(&nnacline);
|
||||||
|
if (numtok) {
|
||||||
char* numtokfree = numtok;
|
char* numtokfree = numtok;
|
||||||
/* Check if token is a parameter, to be filled in later */
|
/* Check if token is a parameter, to be filled in later */
|
||||||
if (*numtok == '\'' || *numtok == '{') {
|
if (*numtok == '\'' || *numtok == '{') {
|
||||||
|
|
@ -8447,9 +8458,11 @@ static void inp_check_syntax(struct card *deck)
|
||||||
/* check if token is a valid number */
|
/* check if token is a valid number */
|
||||||
INPevaluate(&numtok, &err, 0);
|
INPevaluate(&numtok, &err, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
tfree(numtokfree);
|
tfree(numtokfree);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
err = 1;
|
||||||
|
}
|
||||||
/* if no number, replace 'ac' by 'ac 1 0' */
|
/* if no number, replace 'ac' by 'ac 1 0' */
|
||||||
if (err){
|
if (err){
|
||||||
char *begstr = copy_substring(cut_line, acline);
|
char *begstr = copy_substring(cut_line, acline);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue