From 63c626069695c7fc5546a97186b5225c3fd9deed Mon Sep 17 00:00:00 2001 From: h_vogt Date: Fri, 14 May 2010 22:39:56 +0000 Subject: [PATCH] update fcn inp_bsource_compat --- ChangeLog | 3 ++- src/frontend/inpcom.c | 34 ++++++++++++++++++++++++---------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index e068f8d0a..0643548a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,8 @@ 2010-05-14 Holger Vogt * dllitf.h, cplsetup.c, cmexport.c, int/udnfunc.c, real/udnfunc.c, xspice.c: tmalloc patch by R Larice - vngspice.sln, vngspice.proj: 64 bit support + vngspice.sln, vngspice.proj: 64 bit support + inpcom.c: exclude .control ... .endc lines from fcn inp_bsource_compat 2010-05-11 Holger Vogt * inpcom.c: new fcn inp_fix_gnd_name: 'gnd' replaced by ' 0 ', if delimiters diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index d442e683b..3ba589180 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -3878,16 +3878,29 @@ static void inp_compat(struct line *deck) static void inp_bsource_compat(struct line *deck) { - char *curr_line, *equal_ptr, *str_ptr, *tmp_char, *new_str, *final_str; + char *equal_ptr, *str_ptr, *tmp_char, *new_str, *final_str; char actchar, prevchar = ' '; - struct line *card = deck, *new_line, *tmp_ptr; + struct line *card, *new_line, *tmp_ptr; wordlist *wl = NULL, *wlist = NULL, *cwl; char buf[512]; size_t i, xlen, ustate = 0; + int skip_control = 0; + + for (card = deck; card; card = card->li_next) { + + char *curr_line = card->li_line; + + /* exclude any command inside .control ... .endc */ + if ( ciprefix(".control", curr_line) ) { + skip_control ++; + continue; + } else if( ciprefix(".endc", curr_line) ) { + skip_control --; + continue; + } else if(skip_control > 0) { + continue; + } - while ( card != NULL ) - { - curr_line = card->li_line; if ( *curr_line == 'b' ) { /* store starting point for later parsing, beginning of {expression} */ equal_ptr = strstr(curr_line, "="); @@ -3990,11 +4003,14 @@ static void inp_bsource_compat(struct line *deck) str_ptr++; } buf[i] = '\0'; + /* no parens {} around time, hertz, temper and the constants + pi and e which are defined in inpptree.c */ if ((*str_ptr == '(') || cieq(buf, "hertz") || cieq(buf, "temper") - || cieq(buf, "time")) + || cieq(buf, "time") || cieq(buf, "pi") || cieq(buf, "e")) { cwl->wl_word = copy(buf); } + /* {} around all other tokens */ else { xlen = strlen(buf); tmp_char = tmalloc(xlen + 3); @@ -4055,7 +4071,7 @@ static void inp_bsource_compat(struct line *deck) new_line->li_actual = NULL; new_line->li_line = final_str; new_line->li_linenum = 0; - // comment out current old R line + // comment out current old B line *(card->li_line) = '*'; // insert new B source line immediately after current line tmp_ptr = card->li_next; @@ -4067,7 +4083,5 @@ static void inp_bsource_compat(struct line *deck) tfree(new_str); tfree(tmp_char); } /* end of if 'b' */ - - card = card->li_next; - } + } /* end of for loop */ }