subckt.c, inp_subcktexpand(), abstraction, new function `collect_global_nodes()'
This commit is contained in:
parent
833c8b972e
commit
d82b836136
|
|
@ -134,6 +134,43 @@ static char start[32], sbend[32], invoke[32], model[32];
|
|||
static char global_nodes[128][128];
|
||||
static int num_global_nodes;
|
||||
|
||||
|
||||
static void
|
||||
collect_global_nodes(struct line *c)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 128; i++)
|
||||
strcpy(global_nodes[i], ""); /* Clear global node holder */
|
||||
|
||||
num_global_nodes = 0;
|
||||
for (; c; c = c->li_next)
|
||||
if (ciprefix(".global", c->li_line)) {
|
||||
char *s = c->li_line;
|
||||
txfree(gettok(&s));
|
||||
while (*s) {
|
||||
char *t = s;
|
||||
i = 0;
|
||||
for (/*s*/; *s && !isspace(*s); s++)
|
||||
i++;
|
||||
strncpy(global_nodes[num_global_nodes], t, (size_t) i);
|
||||
if (i>0 && t[i-1] != '\0')
|
||||
global_nodes[num_global_nodes][i] = '\0';
|
||||
while (isspace(*s))
|
||||
s++;
|
||||
num_global_nodes++;
|
||||
} /* global_nodes[] holds name of global node */
|
||||
#ifdef TRACE
|
||||
printf("***Global node option has been found.***\n");
|
||||
for (i = 0; i<num_global_nodes; i++)
|
||||
printf("***Global node no.%d is %s.***\n", i, global_nodes[i]);
|
||||
printf("\n");
|
||||
#endif
|
||||
c->li_line[0] = '*'; /* comment it out */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------
|
||||
inp_subcktexpand is the top level function which translates
|
||||
.subckts into mainlined code. Note that there are several things
|
||||
|
|
@ -238,37 +275,7 @@ inp_subcktexpand(struct line *deck) {
|
|||
#endif
|
||||
|
||||
/* Added by H.Tanaka to find global nodes */
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 128; i++)
|
||||
strcpy(global_nodes[i], ""); /* Clear global node holder */
|
||||
|
||||
num_global_nodes = 0;
|
||||
for (c = deck; c; c = c->li_next)
|
||||
if (ciprefix(".global", c->li_line)) {
|
||||
char *s = c->li_line;
|
||||
txfree(gettok(&s));
|
||||
while (*s) {
|
||||
char *t = s;
|
||||
i = 0;
|
||||
for (/*s*/; *s && !isspace(*s); s++)
|
||||
i++;
|
||||
strncpy(global_nodes[num_global_nodes], t, (size_t) i);
|
||||
if (i>0 && t[i-1] != '\0')
|
||||
global_nodes[num_global_nodes][i] = '\0';
|
||||
while (isspace(*s))
|
||||
s++;
|
||||
num_global_nodes++;
|
||||
} /* global_nodes[] holds name of global node */
|
||||
#ifdef TRACE
|
||||
printf("***Global node option has been found.***\n");
|
||||
for (i = 0; i<num_global_nodes; i++)
|
||||
printf("***Global node no.%d is %s.***\n", i, global_nodes[i]);
|
||||
printf("\n");
|
||||
#endif
|
||||
c->li_line[0] = '*'; /* comment it out */
|
||||
}
|
||||
}
|
||||
collect_global_nodes(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 */
|
||||
|
|
|
|||
Loading…
Reference in New Issue