inpcom.c, cleanup deck loops #2/4

This commit is contained in:
rlar 2013-05-26 19:16:16 +02:00
parent 1905d23212
commit 1d26f71075
1 changed files with 14 additions and 32 deletions

View File

@ -927,11 +927,10 @@ inp_fix_gnd_name(struct line *deck)
struct line *c = deck;
char *gnd;
while (c) {
for (; c; c = c->li_next) {
gnd = c->li_line;
// if there is a comment or no gnd, go to next line
if ((*gnd == '*') || (strstr(gnd, "gnd") == NULL)) {
c = c->li_next;
continue;
}
// replace "?gnd?" by "? 0 ?", ? being a ' ' ',' '(' ')'.
@ -944,7 +943,6 @@ inp_fix_gnd_name(struct line *deck)
}
// now remove the extra white spaces around 0
c->li_line = inp_remove_ws(c->li_line);
c = c->li_next;
}
}
@ -1888,9 +1886,8 @@ static void
inp_stripcomments_deck(struct line *deck)
{
struct line *c = deck;
while (c) {
for (; c; c = c->li_next) {
inp_stripcomments_line(c->li_line);
c = c->li_next;
}
}
@ -2242,9 +2239,8 @@ inp_fix_for_numparam(struct line *deck)
struct line *c = deck;
char *str_ptr;
while (c) {
for (; c; c = c->li_next) {
if (ciprefix(".lib", c->li_line) || ciprefix("*lib", c->li_line) || ciprefix("*inc", c->li_line)) {
c = c->li_next;
continue;
}
@ -2254,7 +2250,6 @@ inp_fix_for_numparam(struct line *deck)
if (ciprefix(".endc", c->li_line))
found_control = FALSE;
if (found_control) {
c = c->li_next;
continue;
}
@ -2271,7 +2266,6 @@ inp_fix_for_numparam(struct line *deck)
if (ciprefix(".subckt", c->li_line))
c->li_line = inp_fix_subckt(c->li_line);
c = c->li_next;
}
}
@ -2281,9 +2275,8 @@ inp_remove_excess_ws(struct line *deck)
{
struct line *c = deck;
bool found_control = FALSE;
while (c) {
for (; c; c = c->li_next) {
if (*c->li_line == '*') {
c = c->li_next;
continue;
}
@ -2293,11 +2286,9 @@ inp_remove_excess_ws(struct line *deck)
if (ciprefix(".endc", c->li_line))
found_control = FALSE;
if ((found_control) && (ciprefix("echo", c->li_line))) {
c = c->li_next;
continue;
}
c->li_line = inp_remove_ws(c->li_line); /* freed in fcn */
c = c->li_next;
}
}
@ -2636,8 +2627,7 @@ inp_fix_inst_calls_for_numparam(struct line *deck)
if (found_mult_param(num_inst_params, inst_param_names)) {
flag = FALSE;
// iterate through the deck to find the subckt (last one defined wins)
d = deck;
while (d) {
for (d = deck; d; d = d->li_next) {
subckt_line = d->li_line;
if (ciprefix(".subckt", subckt_line)) {
subckt_line = skip_non_ws(subckt_line);
@ -2649,7 +2639,6 @@ inp_fix_inst_calls_for_numparam(struct line *deck)
flag = TRUE;
}
}
d = d->li_next;
}
if (flag) {
num_subckt_params = inp_get_params(p->li_line, subckt_param_names, subckt_param_values);
@ -3169,34 +3158,34 @@ inp_fix_param_values(struct line *deck)
wordlist *nwl;
int parens;
while (c) {
for (; c; c = c->li_next) {
line = c->li_line;
if (*line == '*' || (ciprefix(".param", line) && strchr(line, '{'))) {
c = c->li_next;
continue;
}
if (ciprefix(".control", line)) {
control_section = TRUE;
c = c->li_next;
continue;
}
if (ciprefix(".endc", line)) {
control_section = FALSE;
c = c->li_next;
continue;
}
/* no handling of params in "option" lines */
if (control_section || ciprefix(".option", line)) {
c = c->li_next; /* no handling of params in "option" lines */
continue;
}
/* no handling of params in "set" lines */
if (ciprefix("set", line)) {
c = c->li_next; /* no handling of params in "set" lines */
continue;
}
/* no handling of params in B source lines */
if (*line == 'b') {
c = c->li_next; /* no handling of params in B source lines */
continue;
}
@ -3208,7 +3197,6 @@ inp_fix_param_values(struct line *deck)
*(++line) = 'e';
*(++line) = 'l';
*(++line) = ' ';
c = c->li_next;
continue;
}
@ -3216,12 +3204,10 @@ inp_fix_param_values(struct line *deck)
if (ciprefix(".model", line) && (strstr(line, "numos") || strstr(line, "numd") ||
strstr(line, "nbjt") || strstr(line, "nbjt2") ||
strstr(line, "numd2"))) {
c = c->li_next;
continue;
}
/* exclude CIDER devices with ic.file parameter */
if (strstr(line, "ic.file")) {
c = c->li_next;
continue;
}
@ -3406,7 +3392,6 @@ inp_fix_param_values(struct line *deck)
tfree(old_str);
}
}
c = c->li_next;
}
}
@ -3622,11 +3607,9 @@ inp_sort_params(struct line *start_card, struct line *end_card, struct line *car
return;
/* determine the number of lines with .param */
ptr = start_card;
while (ptr) {
for (ptr = start_card; ptr; ptr = ptr->li_next) {
if (strchr(ptr->li_line, '='))
num_params++;
ptr = ptr->li_next;
}
arr_size = num_params;
@ -3649,7 +3632,7 @@ inp_sort_params(struct line *start_card, struct line *end_card, struct line *car
ptr_array_ordered = TMALLOC(struct line *, arr_size);
ptr = start_card;
while (ptr) {
for (ptr = start_card; ptr; ptr = ptr->li_next) {
// ignore .param lines without '='
if (strchr(ptr->li_line, '=')) {
depends_on[num_params][0] = NULL;
@ -3659,7 +3642,6 @@ inp_sort_params(struct line *start_card, struct line *end_card, struct line *car
ptr_array[num_params++] = ptr;
}
ptr = ptr->li_next;
}
// look for duplicately defined parameters and mark earlier one to skip
// param list is ordered as defined in netlist