From 96ce548316798492b7a034f6aac7686711cd5461 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Wed, 27 Apr 2016 21:58:08 +0200 Subject: [PATCH] inpcom.c, add fcn inp_check_scope_sub() --- src/frontend/inpcom.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index de2d170c9..f692f74d2 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -151,6 +151,7 @@ static char *search_plain_identifier(char *str, const char *identifier); void tprint(struct line *deck, int numb); static void inp_add_levels(struct line *deck); bool inp_check_scope_mod(unsigned short elem_level[], unsigned short mod_level[]); +bool inp_check_scope_sub(unsigned short x_level[], unsigned short subckt_level[]); struct inp_read_t { struct line *cc; @@ -2839,7 +2840,7 @@ inp_fix_inst_calls_for_numparam(struct names *subckt_w_params, struct line *deck break; } - if (!found_param_match) { + if (!found_param_match && inp_check_scope_sub(c->level, d->level)) { // comment out .subckt and continue while (d != NULL && !ciprefix(".ends", d->li_line)) { *(d->li_line) = '*'; @@ -6794,3 +6795,19 @@ inp_check_scope_mod(unsigned short elem_level[], unsigned short mod_level[]) return TRUE; return FALSE; } + + +/* not yet checked. + * Question: how to express overloading a sub at a lower level ? */ +bool +inp_check_scope_sub(unsigned short x_level[], unsigned short subckt_level[]) +{ + int i; + /* subcircuit at top level, accessible from all x lines */ + if ((subckt_level[0] > 0) && (subckt_level[1] == 0)) + return TRUE; + for (i = 1; i < NESTINGDEPTH - 1; i++) + if ((x_level[i] == subckt_level[i]) && (x_level[i + 1] == 0)) + return TRUE; + return FALSE; +}