Browse Source

subckt.c, translate(), #8/8 whitespace and comments

pre-master-46
rlar 9 years ago
parent
commit
0fb21eaf4a
  1. 85
      src/frontend/subckt.c

85
src/frontend/subckt.c

@ -934,39 +934,38 @@ translate(struct line *deck, char *formal, char *actual, char *scname, const cha
goto quit; goto quit;
} }
/* now iterate through the .subckt deck and translate the cards. */
for (c = deck; c; c = c->li_next) { for (c = deck; c; c = c->li_next) {
char *s = c->li_line; char *s = c->li_line;
char dev_type = tolower_c(s[0]); char dev_type = tolower_c(s[0]);
bxx_rewind(&buffer); bxx_rewind(&buffer);
#ifdef TRACE #ifdef TRACE
/* SDB debug statement */
printf("\nIn translate, examining line (dev_type: %c, subname: %s, instance: %s) %s \n", dev_type, subname, scname, s); printf("\nIn translate, examining line (dev_type: %c, subname: %s, instance: %s) %s \n", dev_type, subname, scname, s);
#endif #endif
switch (dev_type) { switch (dev_type) {
case '.': case '.':
if (ciprefix(".ic", s) || ciprefix(".nodeset", s)) {
while ((paren_ptr = strchr(s, '(')) != NULL) {
name = paren_ptr + 1;
if (ciprefix(".ic", s) || ciprefix(".nodeset", s)) {
while ((paren_ptr = strchr(s, '(')) != NULL) {
name = paren_ptr + 1;
if ((paren_ptr = strchr(name, ')')) == NULL) {
fprintf(cp_err, "Error: missing closing ')' for .ic|.nodeset statement %s\n", c->li_line);
goto quit;
}
if ((paren_ptr = strchr(name, ')')) == NULL) {
fprintf(cp_err, "Error: missing closing ')' for .ic|.nodeset statement %s\n", c->li_line);
goto quit;
}
bxx_put_substring(&buffer, s, name);
translate_node_name(&buffer, scname, name, paren_ptr);
bxx_put_substring(&buffer, s, name);
translate_node_name(&buffer, scname, name, paren_ptr);
s = paren_ptr;
s = paren_ptr;
}
bxx_put_cstring(&buffer, s); /* rest of line */
break;
} else {
continue;
} }
bxx_put_cstring(&buffer, s); /* rest of line */
break;
} else {
continue;
}
case '\0': case '\0':
case '*': case '*':
@ -986,7 +985,6 @@ translate(struct line *deck, char *formal, char *actual, char *scname, const cha
translate_inst_name(&buffer, scname, name, NULL); translate_inst_name(&buffer, scname, name, NULL);
bxx_putc(&buffer, ' '); bxx_putc(&buffer, ' ');
/* Now translate the nodes, looking ahead one token to recognize */ /* Now translate the nodes, looking ahead one token to recognize */
/* when we reach the model name which should not be translated */ /* when we reach the model name which should not be translated */
/* here. */ /* here. */
@ -1024,21 +1022,20 @@ translate(struct line *deck, char *formal, char *actual, char *scname, const cha
break; break;
default: default:
/* must be a node name at this point, so translate it */ /* must be a node name at this point, so translate it */
translate_node_name(&buffer, scname, name, NULL); translate_node_name(&buffer, scname, name, NULL);
break; break;
} /* switch */
}
bxx_putc(&buffer, ' '); bxx_putc(&buffer, ' ');
} /* while */
}
/* copy in the last token, which is the model name */ /* copy in the last token, which is the model name */
if (name) { if (name) {
bxx_put_cstring(&buffer, name); bxx_put_cstring(&buffer, name);
tfree(name); tfree(name);
} }
break; /* case 'a' */ break; /* case 'a' */
/* gtri - end - wbk - 10/23/90 */ /* gtri - end - wbk - 10/23/90 */
@ -1084,22 +1081,20 @@ translate(struct line *deck, char *formal, char *actual, char *scname, const cha
translate_node_name(&buffer, scname, name, NULL); translate_node_name(&buffer, scname, name, NULL);
tfree(name); tfree(name);
bxx_putc(&buffer, ' '); bxx_putc(&buffer, ' ');
} /* while (nnodes-- . . . . */
}
/* Next we handle the POLY (if any) */
/* Next we handle the POLY (if any) */
/* get next token */ /* get next token */
t = s; t = s;
next_name = gettok_noparens(&t); next_name = gettok_noparens(&t);
if ((strcmp(next_name, "POLY") == 0) || if ((strcmp(next_name, "POLY") == 0) ||
(strcmp(next_name, "poly") == 0)) { /* found POLY . . . . */
(strcmp(next_name, "poly") == 0)) {
#ifdef TRACE #ifdef TRACE
/* SDB debug statement */
printf("In translate, looking at e, f, g, h found poly\n"); printf("In translate, looking at e, f, g, h found poly\n");
#endif #endif
/* move pointer ahead of ( */
/* move pointer ahead of '(' */
if (get_l_paren(&s) == 1) { if (get_l_paren(&s) == 1) {
fprintf(cp_err, "Error: no left paren after POLY %s\n", fprintf(cp_err, "Error: no left paren after POLY %s\n",
c->li_line); c->li_line);
@ -1111,7 +1106,7 @@ translate(struct line *deck, char *formal, char *actual, char *scname, const cha
dim = atoi(nametofree); /* convert returned string to int */ dim = atoi(nametofree); /* convert returned string to int */
tfree(nametofree); tfree(nametofree);
/* move pointer ahead of ) */
/* move pointer ahead of ')' */
if (get_r_paren(&s) == 1) { if (get_r_paren(&s) == 1) {
fprintf(cp_err, "Error: no right paren after POLY %s\n", fprintf(cp_err, "Error: no right paren after POLY %s\n",
c->li_line); c->li_line);
@ -1121,8 +1116,7 @@ translate(struct line *deck, char *formal, char *actual, char *scname, const cha
/* Write POLY(dim) into buffer */ /* Write POLY(dim) into buffer */
bxx_printf(&buffer, "POLY( %d ) ", dim); bxx_printf(&buffer, "POLY( %d ) ", dim);
} /* if ((strcmp(next_name, "POLY") == 0) . . . */
}
else else
dim = 1; /* only one controlling source . . . */ dim = 1; /* only one controlling source . . . */
tfree(next_name); tfree(next_name);
@ -1130,7 +1124,7 @@ translate(struct line *deck, char *formal, char *actual, char *scname, const cha
/* Now translate the controlling source/nodes */ /* Now translate the controlling source/nodes */
nnodes = dim * numdevs(c->li_line); nnodes = dim * numdevs(c->li_line);
while (--nnodes >= 0) { while (--nnodes >= 0) {
name = gettok_node(&s); /* name points to the returned token */
name = gettok_node(&s); /* name points to the returned token */
if (name == NULL) { if (name == NULL) {
fprintf(cp_err, "Error: too few devs: %s\n", c->li_line); fprintf(cp_err, "Error: too few devs: %s\n", c->li_line);
goto quit; goto quit;
@ -1142,14 +1136,12 @@ translate(struct line *deck, char *formal, char *actual, char *scname, const cha
translate_node_name(&buffer, scname, name, NULL); translate_node_name(&buffer, scname, name, NULL);
tfree(name); tfree(name);
bxx_putc(&buffer, ' '); bxx_putc(&buffer, ' ');
} /* while (nnodes--. . . . */
}
/* Now write out remainder of line (polynomial coeffs) */ /* Now write out remainder of line (polynomial coeffs) */
finishLine(&buffer, s, scname); finishLine(&buffer, s, scname);
break; break;
/*================= Default case ===================*/
default: /* this section handles ordinary components */ default: /* this section handles ordinary components */
name = gettok_node(&s); /* changed to gettok_node to handle netlists with ( , ) */ name = gettok_node(&s); /* changed to gettok_node to handle netlists with ( , ) */
if (!name) if (!name)
@ -1159,16 +1151,10 @@ translate(struct line *deck, char *formal, char *actual, char *scname, const cha
continue; continue;
} }
/* Here's where we translate the refdes to e.g. R:subcircuitname:57
* and stick the translated name into buffer.
*/
translate_inst_name(&buffer, scname, name, NULL); translate_inst_name(&buffer, scname, name, NULL);
tfree(name); tfree(name);
bxx_putc(&buffer, ' '); bxx_putc(&buffer, ' ');
/* Next iterate over all nodes (netnames) found and translate them. */
nnodes = numnodes(c->li_line, subs, modnames); nnodes = numnodes(c->li_line, subs, modnames);
while (--nnodes >= 0) { while (--nnodes >= 0) {
name = gettok_node(&s); name = gettok_node(&s);
@ -1180,7 +1166,7 @@ translate(struct line *deck, char *formal, char *actual, char *scname, const cha
translate_node_name(&buffer, scname, name, NULL); translate_node_name(&buffer, scname, name, NULL);
tfree(name); tfree(name);
bxx_putc(&buffer, ' '); bxx_putc(&buffer, ' ');
} /* while (nnodes-- . . . . */
}
/* Now translate any devices (i.e. controlling sources). /* Now translate any devices (i.e. controlling sources).
* This may be superfluous because we handle dependent * This may be superfluous because we handle dependent
@ -1197,7 +1183,7 @@ translate(struct line *deck, char *formal, char *actual, char *scname, const cha
translate_inst_name(&buffer, scname, name, NULL); translate_inst_name(&buffer, scname, name, NULL);
tfree(name); tfree(name);
bxx_putc(&buffer, ' '); bxx_putc(&buffer, ' ');
} /* while (nnodes--. . . . */
}
/* Now we finish off the line. For most components (R, C, etc), /* Now we finish off the line. For most components (R, C, etc),
* this involves adding the component value to the buffer. * this involves adding the component value to the buffer.
@ -1206,20 +1192,17 @@ translate(struct line *deck, char *formal, char *actual, char *scname, const cha
*/ */
finishLine(&buffer, s, scname); finishLine(&buffer, s, scname);
break; break;
} /* switch (c->li_line . . . . */
}
tfree(c->li_line); tfree(c->li_line);
c->li_line = copy(bxx_buffer(&buffer)); c->li_line = copy(bxx_buffer(&buffer));
#ifdef TRACE #ifdef TRACE
/* SDB debug statement */
printf("In translate, translated line = %s \n", c->li_line); printf("In translate, translated line = %s \n", c->li_line);
#endif #endif
} /* for (c = deck . . . . */
}
rtn = 1; rtn = 1;
quit:
quit:
for (i = 0; ; i++) { for (i = 0; ; i++) {
if (!table[i].t_old && !table[i].t_new) if (!table[i].t_old && !table[i].t_new)
break; break;
@ -1779,7 +1762,7 @@ devmodtranslate(struct line *s, char *subname, wordlist * const orig_modnames)
tfree(name); tfree(name);
break; break;
/* 4-7 terminal mos devices */
/* 4-7 terminal mos devices */
case 'm': case 'm':
name = gettok(&t); /* get refdes */ name = gettok(&t); /* get refdes */
bxx_printf(&buffer, "%s ", name); bxx_printf(&buffer, "%s ", name);

Loading…
Cancel
Save