Add function check_for_nodes to
check if there are enough tokens in an instance line.
This commit is contained in:
parent
9774a64bf6
commit
059e2b2158
|
|
@ -24,6 +24,7 @@ static char* get_terminal_name(char* element, char* numberstr, NGHASHPTR instanc
|
||||||
static char* get_terminal_number(char* element, char* numberstr);
|
static char* get_terminal_number(char* element, char* numberstr);
|
||||||
static int setallvsources(struct card* tmpcard, NGHASHPTR instances, char* instname, int numnodes, bool haveall, bool power);
|
static int setallvsources(struct card* tmpcard, NGHASHPTR instances, char* instname, int numnodes, bool haveall, bool power);
|
||||||
|
|
||||||
|
static int check_for_nodes(char* instance, int numnodes);
|
||||||
|
|
||||||
/* Find any line starting with .probe: assemble all parameters like
|
/* Find any line starting with .probe: assemble all parameters like
|
||||||
<empty> add V(0) current measure sources to all device nodes in addition to .save all
|
<empty> add V(0) current measure sources to all device nodes in addition to .save all
|
||||||
|
|
@ -256,6 +257,12 @@ void inp_probe(struct card* deck)
|
||||||
else
|
else
|
||||||
numnodes = get_number_terminals(card->line);
|
numnodes = get_number_terminals(card->line);
|
||||||
|
|
||||||
|
if (check_for_nodes(card->line, numnodes)) {
|
||||||
|
fprintf(stderr, "Error: Not enough tokens in line %d\n%s\n", card->linenum_orig, card->line);
|
||||||
|
fprintf(stderr, " Please correct your input file\n");
|
||||||
|
controlled_exit(EXIT_BAD);
|
||||||
|
}
|
||||||
|
|
||||||
char* thisline = curr_line;
|
char* thisline = curr_line;
|
||||||
prevcard = card;
|
prevcard = card;
|
||||||
/* all elements with 2 nodes: add a voltage source to the second node in the elements line */
|
/* all elements with 2 nodes: add a voltage source to the second node in the elements line */
|
||||||
|
|
@ -744,6 +751,12 @@ void inp_probe(struct card* deck)
|
||||||
else
|
else
|
||||||
numnodes = get_number_terminals(thisline);
|
numnodes = get_number_terminals(thisline);
|
||||||
|
|
||||||
|
if (check_for_nodes(tmpcard->line, numnodes)) {
|
||||||
|
fprintf(stderr, "Error: Not enough tokens in line %d\n%s\n", tmpcard->linenum_orig, tmpcard->line);
|
||||||
|
fprintf(stderr, " Please correct your input file\n");
|
||||||
|
controlled_exit(EXIT_BAD);
|
||||||
|
}
|
||||||
|
|
||||||
/* skip ',' */
|
/* skip ',' */
|
||||||
if (*tmpstr == ',')
|
if (*tmpstr == ',')
|
||||||
tmpstr++;
|
tmpstr++;
|
||||||
|
|
@ -884,6 +897,12 @@ void inp_probe(struct card* deck)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (check_for_nodes(tmpcard->line, numnodes)) {
|
||||||
|
fprintf(stderr, "Error: Not enough tokens in line %d\n%s\n", tmpcard->linenum_orig, tmpcard->line);
|
||||||
|
fprintf(stderr, " Please correct your input file\n");
|
||||||
|
controlled_exit(EXIT_BAD);
|
||||||
|
}
|
||||||
|
|
||||||
int err = 0;
|
int err = 0;
|
||||||
/* call fcn with power requested */
|
/* call fcn with power requested */
|
||||||
err = setallvsources(tmpcard, instances, instname, numnodes, haveall, TRUE);
|
err = setallvsources(tmpcard, instances, instname, numnodes, haveall, TRUE);
|
||||||
|
|
@ -1435,3 +1454,17 @@ static int setallvsources(struct card *tmpcard, NGHASHPTR instances, char *instn
|
||||||
ds_free(&Bpowersave);
|
ds_free(&Bpowersave);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check if there are enough tokens in an instance line */
|
||||||
|
static int check_for_nodes(char* instance, int numnodes) {
|
||||||
|
int i;
|
||||||
|
char* tmpinst = instance;
|
||||||
|
tmpinst = nexttok(tmpinst); /* instance name */
|
||||||
|
for (i = 0; i < numnodes; i++) {
|
||||||
|
tmpinst = nexttok(tmpinst);
|
||||||
|
if (!tmpinst || *tmpinst == '\0') {
|
||||||
|
return 1;;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue