diff --git a/ChangeLog b/ChangeLog index 71b4b0605..8f97b92ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,11 @@ - +2010-06-29 Holger Vogt + * inpcom.c lines 743, 744 correct malloc for 64 bit LINUX + * inpcom.c, inpcom.h, nutinp.c, inp.c, fteext.h: + Command files spinit and .spiceinit (comfile==TRUE) will not be + treated by numparam processing. + Comment_out_unused_subckt() will no longer process lines inside + control section. + 2010-06-28 Holger Vogt * bsim3/b3set.c b3ld.c bsim3def.h: new preproc flag USE_OMP3 * bsim4/b4set.c b4ld.c bsim4def.h: OpenMP support for BSIM4 model diff --git a/src/frontend/inp.c b/src/frontend/inp.c index 953d4e3d7..e68a7858e 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -330,7 +330,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename) /* read in the deck from a file */ char *filename_dup = ( filename == NULL ) ? strdup(".") : strdup(filename); - inp_readall(fp, &deck, 0, dirname(filename_dup)); + inp_readall(fp, &deck, 0, dirname(filename_dup), comfile); tfree(filename_dup); /* if nothing came back from inp_readall, just close fp and return to caller */ diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index 452574315..97a86bcd2 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -735,12 +735,13 @@ comment_out_unused_subckt_models( struct line *start_card , int no_of_lines) char **used_subckt_names, **used_model_names, *line = NULL, *subckt_name, *model_name; int num_used_subckt_names = 0, num_used_model_names = 0, i = 0, num_terminals = 0, tmp_cnt = 0; bool processing_subckt = FALSE, found_subckt = FALSE, remove_subckt = FALSE, found_model = FALSE, has_models = FALSE; + int skip_control = 0; /* generate arrays of *char for subckt or model names. Start with 1000, but increase, if number of lines in deck is larger */ if (no_of_lines < 1000) no_of_lines = 1000; - used_subckt_names = (char**)tmalloc(no_of_lines); - used_model_names = (char**)tmalloc(no_of_lines); + used_subckt_names = (char**)tmalloc(no_of_lines*sizeof(char*)); + used_model_names = (char**)tmalloc(no_of_lines*sizeof(char*)); for ( card = start_card; card != NULL; card = card->li_next ) { if ( ciprefix( ".model", card->li_line ) ) has_models = TRUE; @@ -753,6 +754,17 @@ comment_out_unused_subckt_models( struct line *start_card , int no_of_lines) if ( *line == '*' ) continue; + /* there is no .subckt, .model or .param inside .control ... .endc */ + if ( ciprefix(".control", line) ) { + skip_control ++; + continue; + } else if( ciprefix(".endc", line) ) { + skip_control --; + continue; + } else if(skip_control > 0) { + continue; + } + if ( ciprefix( ".subckt", line ) || ciprefix( ".macro", line ) ) processing_subckt = TRUE; if ( ciprefix( ".ends", line ) || ciprefix( ".eom", line ) ) processing_subckt = FALSE; if ( !processing_subckt ) { @@ -1033,7 +1045,13 @@ inp_fix_ternary_operator( struct line *start_card ) * *data. *-------------------------------------------------------------------------*/ void -inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name) +inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool comfile) +/* fp: in, pointer to file to be read, + data: out, linked list of cards + call_depth: in, nested call to fcn + dir_name: in, name of directory of file to be read + comfile: in, TRUE if coammnd file (e.g. spinit, .spiceinit +*/ { struct line *end = NULL, *cc = NULL, *prev = NULL, *working, *newcard, *start_lib, *global_card, *tmp_ptr = NULL, *tmp_ptr2 = NULL; char *buffer = NULL, *s, *t, *y, *z, c; @@ -1200,11 +1218,11 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name) if ( dir_name_flag == FALSE ) { char *s_dup = strdup(s); - inp_readall(newfp, &libraries[num_libraries-1], call_depth+1, dirname(s_dup)); + inp_readall(newfp, &libraries[num_libraries-1], call_depth+1, dirname(s_dup), FALSE); tfree(s_dup); } else - inp_readall(newfp, &libraries[num_libraries-1], call_depth+1, dir_name); + inp_readall(newfp, &libraries[num_libraries-1], call_depth+1, dir_name, FALSE); fclose(newfp); } @@ -1253,7 +1271,6 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name) fprintf(cp_err, "Error: .include statement failed.\n"); tfree(buffer); /* allocated by readline() above */ controlled_exit(EXIT_FAILURE); -// continue; } } @@ -1263,11 +1280,11 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name) if ( dir_name_flag == FALSE ) { char *s_dup = strdup(s); - inp_readall(newfp, &newcard, call_depth+1, dirname(s_dup)); /* read stuff in include file into netlist */ + inp_readall(newfp, &newcard, call_depth+1, dirname(s_dup), FALSE); /* read stuff in include file into netlist */ tfree(s_dup); } else - inp_readall(newfp, &newcard, call_depth+1, dir_name); /* read stuff in include file into netlist */ + inp_readall(newfp, &newcard, call_depth+1, dir_name, FALSE); /* read stuff in include file into netlist */ (void) fclose(newfp); @@ -1542,6 +1559,14 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name) } } + /* The following processing of an input file is not required for command files + like spinit or .spiceinit, so return command files here. */ + if (comfile) { + /* save the return value (via **data) */ + *data = cc; + return; + } + working = cc->li_next; inp_fix_for_numparam(working); @@ -2675,7 +2700,7 @@ static void inp_fix_param_values( struct line *deck ) { struct line *c = deck; - char *line, *beg_of_str, *end_of_str, *old_str, *equal_ptr, *new_str, *tmp_str; + char *line, *beg_of_str, *end_of_str, *old_str, *equal_ptr, *new_str; char *vec_str, *natok, *buffer, *newvec, *whereisgt; bool control_section = FALSE, has_paren = FALSE; int n = 0; diff --git a/src/frontend/inpcom.h b/src/frontend/inpcom.h index e3f8360c0..fdfd923b5 100644 --- a/src/frontend/inpcom.h +++ b/src/frontend/inpcom.h @@ -7,7 +7,7 @@ #define INPCOM_H_INCLUDED FILE * inp_pathopen(char *name, char *mode); -void inp_readall(FILE *fp, struct line **data, int, char *dirname); +void inp_readall(FILE *fp, struct line **data, int, char *dirname, bool comfile); void inp_casefix(register char *string); #endif diff --git a/src/frontend/nutinp.c b/src/frontend/nutinp.c index 85bda9803..150c4aa36 100644 --- a/src/frontend/nutinp.c +++ b/src/frontend/nutinp.c @@ -33,7 +33,7 @@ inp_nutsource(FILE *fp, bool comfile, char *filename) wordlist *controls = NULL; FILE *lastin, *lastout, *lasterr; - inp_readall(fp, &deck, 0, NULL) /* still to check if . or filename instead of NULL */; + inp_readall(fp, &deck, 0, NULL, comfile) /* still to check if . or filename instead of NULL */; if (!deck) return; diff --git a/src/include/fteext.h b/src/include/fteext.h index 9942613b1..ab99b656a 100644 --- a/src/include/fteext.h +++ b/src/include/fteext.h @@ -287,7 +287,7 @@ extern void inp_source(char *file); void inp_spsource(FILE *fp, bool comfile, char *filename); extern void inp_casefix(char *string); extern void inp_list(FILE *file, struct line *deck, struct line *extras, int type); -extern void inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name); +extern void inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool comfile); extern FILE *inp_pathopen(char *name, char *mode); /* nutinp.c */