Joanne fixes for potential crash in align_sch_pins_with_sym() if there is a sym/sch pin number mismatch. Moved box declaration to beginning of scope block for C89 compatibility
This commit is contained in:
parent
0d3ebf7da9
commit
500feade8d
25
src/save.c
25
src/save.c
|
|
@ -1262,7 +1262,7 @@ void pop_undo(int redo)
|
|||
* return symbol type in type pointer or "" if no type or no symbol found
|
||||
* if pintable given (!=NULL) hash all symbol pins
|
||||
* if embed_fd is not NULL read symbol from embedded '[...]' tags using embed_fd file pointer */
|
||||
void get_sym_type(const char *symname, char **type, struct int_hashentry **pintable, FILE *embed_fd)
|
||||
void get_sym_type(const char *symname, char **type, struct int_hashentry **pintable, FILE *embed_fd, int *sym_num_pins)
|
||||
{
|
||||
int i, c, n = 0;
|
||||
char name[PATH_MAX];
|
||||
|
|
@ -1284,8 +1284,11 @@ void get_sym_type(const char *symname, char **type, struct int_hashentry **pinta
|
|||
}
|
||||
}
|
||||
/* hash pins to get LCC schematic have same order as corresponding symbol */
|
||||
if(found && pintable) for(c = 0; c < xctx->sym[i].rects[PINLAYER]; c++) {
|
||||
int_hash_lookup(pintable, get_tok_value(xctx->sym[i].rect[PINLAYER][c].prop_ptr, "name", 0), c, XINSERT);
|
||||
if(found && pintable) {
|
||||
*sym_num_pins = xctx->sym[i].rects[PINLAYER];
|
||||
for (c = 0; c < xctx->sym[i].rects[PINLAYER]; c++) {
|
||||
int_hash_lookup(pintable, get_tok_value(xctx->sym[i].rect[PINLAYER][c].prop_ptr, "name", 0), c, XINSERT);
|
||||
}
|
||||
}
|
||||
if( !found ) {
|
||||
dbg(1, "get_sym_type(): open file %s, pintable %s\n",name, pintable ? "set" : "null");
|
||||
|
|
@ -1332,6 +1335,7 @@ void get_sym_type(const char *symname, char **type, struct int_hashentry **pinta
|
|||
/* hash pins to get LCC schematic have same order as corresponding symbol */
|
||||
int_hash_lookup(pintable, get_tok_value(box.prop_ptr, "name", 0), n++, XINSERT);
|
||||
dbg(1, "get_sym_type() : hashing %s\n", get_tok_value(box.prop_ptr, "name", 0));
|
||||
++(*sym_num_pins);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
@ -1358,17 +1362,22 @@ void align_sch_pins_with_sym(const char *name, int pos)
|
|||
char symname[PATH_MAX];
|
||||
char *symtype = NULL;
|
||||
const char *pinname;
|
||||
int i, fail = 0;
|
||||
int i, fail = 0, sym_num_pins=0;
|
||||
struct int_hashentry *pintable[HASHSIZE];
|
||||
|
||||
if ((ptr = strrchr(name, '.')) && !strcmp(ptr, ".sch")) {
|
||||
my_strncpy(symname, add_ext(name, ".sym"), S(symname));
|
||||
for(i = 0; i < HASHSIZE; i++) pintable[i] = NULL;
|
||||
/* hash all symbol pins with their position into pintable hash*/
|
||||
get_sym_type(symname, &symtype, pintable, NULL);
|
||||
get_sym_type(symname, &symtype, pintable, NULL, &sym_num_pins);
|
||||
if(symtype[0]) { /* found a .sym for current .sch LCC instance */
|
||||
xRect *box = NULL;
|
||||
box = (xRect *) my_malloc(1168, sizeof(xRect) * xctx->sym[pos].rects[PINLAYER]);
|
||||
if (sym_num_pins!=xctx->sym[pos].rects[PINLAYER]) {
|
||||
dbg(0, " align_sch_pins_with_sym(): warning: number of pins mismatch between %s and %s\n",
|
||||
name, symname);
|
||||
fail = 1;
|
||||
}
|
||||
box = (xRect *) my_malloc(1168, sizeof(xRect) * sym_num_pins);
|
||||
dbg(1, "align_sch_pins_with_sym(): symbol: %s\n", symname);
|
||||
for(i=0; i < xctx->sym[pos].rects[PINLAYER]; i++) {
|
||||
struct int_hashentry *entry;
|
||||
|
|
@ -1564,7 +1573,7 @@ int load_sym_def(const char *name, FILE *embed_fd)
|
|||
char *skip_line;
|
||||
const char *dash;
|
||||
xSymbol * symbol;
|
||||
int symbols;
|
||||
int symbols, sym_num_pins=0;
|
||||
|
||||
check_symbol_storage();
|
||||
symbol = xctx->sym;
|
||||
|
|
@ -1942,7 +1951,7 @@ int load_sym_def(const char *name, FILE *embed_fd)
|
|||
/* get symbol type by looking into list of loaded symbols or (if not found) by
|
||||
* opening/closing the symbol file and getting the 'type' attribute from global symbol attributes
|
||||
* if fd_tmp set read symbol from embedded tags '[...]' */
|
||||
get_sym_type(symname, &symtype, NULL, fd_tmp);
|
||||
get_sym_type(symname, &symtype, NULL, fd_tmp, &sym_num_pins);
|
||||
xfseek(lcc[level].fd, filepos, SEEK_SET); /* rewind file pointer */
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1128,7 +1128,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
|
|||
#else
|
||||
char install_dir[MAX_PATH]="";
|
||||
char *up_hier=NULL, *win_xschem_library_path=NULL;
|
||||
#define WIN_XSCHEM_LIBRARY_PATH_NUM 8
|
||||
#define WIN_XSCHEM_LIBRARY_PATH_NUM 9
|
||||
const char *WIN_XSCHEM_LIBRARY_PATH[WIN_XSCHEM_LIBRARY_PATH_NUM] = {
|
||||
/*1*/ "xschem_library",
|
||||
/*2*/ "xschem_library/devices",
|
||||
|
|
@ -1137,7 +1137,8 @@ int Tcl_AppInit(Tcl_Interp *inter)
|
|||
/*5*/ "xschem_library/logic",
|
||||
/*6*/ "xschem_library/binto7seg",
|
||||
/*7*/ "xschem_library/pcb",
|
||||
/*8*/ "xschem_library/rom8k"};
|
||||
/*8*/ "xschem_library/rom8k",
|
||||
/*9*/ "xschem_library/xschem_simulator"};
|
||||
GetModuleFileNameA(NULL, install_dir, MAX_PATH);
|
||||
change_to_unix_fn(install_dir);
|
||||
int dir_len=strlen(install_dir);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
v {xschem version=2.9.8 file_version=1.2}
|
||||
v {xschem version=2.9.9 file_version=1.2 }
|
||||
G {}
|
||||
K {}
|
||||
V {}
|
||||
|
|
@ -241,7 +241,7 @@ C {parax_cap.sym} 160 -1120 0 0 {name=c38 value=2p}
|
|||
C {passgate.sym} 860 -1260 0 1 {name=x1 m=1
|
||||
+ wn=0.4u ln=0.13u
|
||||
+ wp=0.4u lp=0.13u
|
||||
+ VCCBPIN=VCC VSSBPIN=VSS delvto="'agauss(0,ABSVAR,3)'"}
|
||||
+ VCCBPIN=VCC VSSBPIN=VSS extra="delvto='agauss(0,ABSVAR,3)'"}
|
||||
C {lab_pin.sym} 860 -1290 0 1 {name=l19 sig_type=std_logic lab=CALB}
|
||||
C {lab_pin.sym} 860 -1230 0 1 {name=l44 sig_type=std_logic lab=CALBB}
|
||||
C {nmos4-v.sym} 1100 -1100 0 0 {name=M3 verilog_gate=nmos del=50,50,50 model=nmos w=1.0u l=1.0u extra="delvto='agauss(0,ABSVAR,3)'"}
|
||||
|
|
@ -253,7 +253,7 @@ C {lab_pin.sym} 1090 -970 0 0 {name=p182 lab=VSSI}
|
|||
C {passgate.sym} 1350 -1260 0 1 {name=x2 m=1
|
||||
+ wn=0.4u ln=0.13u
|
||||
+ wp=0.4u lp=0.13u
|
||||
+ VCCBPIN=VCC VSSBPIN=VSS delvto="'agauss(0,ABSVAR,3)'"}
|
||||
+ VCCBPIN=VCC VSSBPIN=VSS extra="delvto='agauss(0,ABSVAR,3)'"}
|
||||
C {lab_pin.sym} 1350 -1290 0 1 {name=l45 sig_type=std_logic lab=CALB}
|
||||
C {lab_pin.sym} 1350 -1230 0 1 {name=l46 sig_type=std_logic lab=CALBB}
|
||||
C {nmos4-v.sym} 1590 -1100 0 0 {name=M7 verilog_gate=nmos del=50,50,50 model=nmos w=1.3u l=1.0u extra="delvto='agauss(0,ABSVAR,3)'"}
|
||||
|
|
@ -309,7 +309,7 @@ C {lab_pin.sym} 2290 -710 0 1 {name=l3 lab=SAOUT}
|
|||
C {passgate.sym} 1840 -1260 0 1 {name=x3 m=1
|
||||
+ wn=0.4u ln=0.13u
|
||||
+ wp=0.4u lp=0.13u
|
||||
+ VCCBPIN=VCC VSSBPIN=VSS delvto="'agauss(0,ABSVAR,3)'"}
|
||||
+ VCCBPIN=VCC VSSBPIN=VSS extra="delvto='agauss(0,ABSVAR,3)'"}
|
||||
C {lab_pin.sym} 1840 -1290 0 1 {name=l5 sig_type=std_logic lab=CALB}
|
||||
C {lab_pin.sym} 1840 -1230 0 1 {name=l6 sig_type=std_logic lab=CALBB}
|
||||
C {nmos4-v.sym} 2080 -1100 0 0 {name=M23 verilog_gate=nmos del=50,50,50 model=nmos w=1.5u l=1.0u extra="delvto='agauss(0,ABSVAR,3)'"}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
v {xschem version=2.9.5 file_version=1.1}
|
||||
G {type=passgate
|
||||
v {xschem version=2.9.9 file_version=1.2 }
|
||||
G {}
|
||||
K {type=passgate
|
||||
vhdl_stop=true
|
||||
format="#@spiceprefix\\\\MA#@name @#0 @#2 @#1 @VCCBPIN @modelp w=@wp l=@lp delvto=@delvto m=@m
|
||||
#@spiceprefix\\\\MB#@name @#0 @#3 @#1 @VSSBPIN @modeln w=@wn l=@ln delvto=@delvto m=@m"
|
||||
format="#@spiceprefix\\\\MA#@name @#0 @#2 @#1 @VCCBPIN @modelp w=@wp l=@lp @extra m=@m
|
||||
#@spiceprefix\\\\MB#@name @#0 @#3 @#1 @VSSBPIN @modeln w=@wn l=@ln m=@m"
|
||||
template="name=x1 m=1
|
||||
+ wn=1 ln=0.2 modeln=nmos
|
||||
+ wp=1 lp=0.2 modelp=pmos
|
||||
+ delvto=0
|
||||
+ VCCBPIN=VCC VSSBPIN=VSS nf=1"
|
||||
extra="VCCBPIN VSSBPIN"
|
||||
generic_type="m=integer
|
||||
|
|
|
|||
Loading…
Reference in New Issue