Initialize stack2[] to double 0.0

This commit is contained in:
stefan schippers 2023-03-01 18:34:07 +01:00
parent dbc123e8cc
commit ebf4fa1f44
6 changed files with 84 additions and 34 deletions

View File

@ -82,6 +82,7 @@ void redraw_w_a_l_r_p_rubbers(void)
}
}
/* resets UI state, unselect all and abort any pending operation */
void abort_operation(void)
{
xctx->no_draw = 0;

View File

@ -330,7 +330,7 @@ double atof_spice(const char *s)
int n;
double a = 0.0, mul=1.0;
char lower_s[100];
char suffix[100];
char suffix[100]={0};
const char *p;
if(!s) return 0.0;

View File

@ -986,7 +986,7 @@ int plot_raw_custom_data(int sweep_idx, int first, int last, const char *expr)
const char *n;
char *endptr, *ntok_copy = NULL, *ntok_save, *ntok_ptr;
Stack1 stack1[STACKMAX];
double stack2[STACKMAX], tmp, result, avg;
double stack2[STACKMAX]={0}, tmp, result, avg;
int stackptr1 = 0, stackptr2 = 0;
SPICE_DATA *y = xctx->graph_values[xctx->graph_nvars]; /* custom plot data column */
SPICE_DATA *x = xctx->graph_values[sweep_idx];
@ -3924,9 +3924,10 @@ void descend_symbol(void)
"%s/.xschem_embedded_%d_%s", tclgetvar("XSCHEM_TMP_DIR"), getpid(), get_cell_w_ext(name, 0));
if(!(fd = fopen(name_embedded, "w")) ) {
fprintf(errfp, "descend_symbol(): problems opening file %s \n", name_embedded);
} else {
save_embedded_symbol(xctx->inst[n].ptr+xctx->sym, fd);
fclose(fd);
}
save_embedded_symbol(xctx->inst[n].ptr+xctx->sym, fd);
fclose(fd);
unselect_all(1);
remove_symbols(); /* must follow save (if) embedded */
/* load_symbol(name_embedded); */

View File

@ -297,11 +297,13 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
*/
switch(argv[1][0]) {
case 'a': /*----------------------------------------------*/
/* resets UI state, unselect all and abort any pending operation */
if(!strcmp(argv[1], "abort_operation"))
{
abort_operation();
}
/* start a GUI placement of a symbol pin */
else if(!strcmp(argv[1], "add_symbol_pin"))
{
unselect_all(1);
@ -314,6 +316,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
Tcl_ResetResult(interp);
}
/* start a GUI placement of a graph object */
else if(!strcmp(argv[1], "add_graph"))
{
unselect_all(1);
@ -346,6 +349,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
Tcl_ResetResult(interp);
}
/* ask user to choose a png file and start a GUI placement of the image */
else if(!strcmp(argv[1], "add_png"))
{
char str[PATH_MAX+100];
@ -363,6 +367,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
Tcl_ResetResult(interp);
}
/* align currently selected objects to current snap setting */
else if(!strcmp(argv[1], "align"))
{
xctx->push_undo();
@ -376,6 +381,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
draw();
}
/* annotate operating point data into current schematic.
* use <schematic name>.raw or use supplied argument as raw file to open
* look for operating point data and annotate voltages/currents into schematic */
else if(!strcmp(argv[1], "annotate_op"))
{
int i;
@ -404,12 +412,15 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
}
}
/* Start a GUI placement of an arc.
* User should click 3 unaligned points to define the arc */
else if(!strcmp(argv[1], "arc"))
{
xctx->ui_state |= MENUSTARTARC;
}
else if(!strcmp(argv[1], "attach_labels")) /* attach pins to selected component 20171005 */
/* Attach net labels to selected component(s) instance(s) */
else if(!strcmp(argv[1], "attach_labels"))
{
attach_labels_to_inst(0);
Tcl_ResetResult(interp);
@ -417,6 +428,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else { cmd_found = 0;}
break;
case 'b': /*----------------------------------------------*/
/* start/end bounding box calculation: parameter is either 'begin' or 'end' */
if(!strcmp(argv[1], "bbox"))
{
if(argc > 2) {
@ -431,12 +443,14 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
Tcl_ResetResult(interp);
}
/* break wires at selected instance pins */
else if(!strcmp(argv[1], "break_wires"))
{
break_wires_at_pins();
Tcl_ResetResult(interp);
}
/* rebuild color palette using values of tcl vars dim_value and dim_bg */
else if(!strcmp(argv[1], "build_colors"))
{
build_colors(tclgetdoublevar("dim_value"), tclgetdoublevar("dim_bg"));
@ -445,6 +459,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else { cmd_found = 0;}
break;
case 'c': /*----------------------------------------------*/
/* invoke the callback event dispatcher */
if(!strcmp(argv[1], "callback") )
{
callback( argv[2], atoi(argv[3]), atoi(argv[4]), atoi(argv[5]), (KeySym)atol(argv[6]),
@ -454,6 +469,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
Tcl_ResetResult(interp);
}
/* set case insensitive symbol lookup. Use only on case insensitive filesystems */
else if(!strcmp(argv[1], "case_insensitive"))
{
if(argc > 2) {
@ -468,6 +484,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
}
}
/* list all used symbols in current schematic and warn if some symbol is newer */
else if(!strcmp(argv[1], "check_symbols"))
{
char sympath[PATH_MAX];
@ -492,9 +509,11 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
Tcl_ResetResult(interp);
}
/* check if all instances have a unique refdes (name attribute in xschem),
* highlight such instances. If second parameter is '1' rename duplicates */
else if(!strcmp(argv[1], "check_unique_names"))
{
if(!strcmp(argv[2], "1")) {
if(argc > 2 && !strcmp(argv[2], "1")) {
check_unique_names(1);
} else {
check_unique_names(0);
@ -502,15 +521,27 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
Tcl_ResetResult(interp);
}
/* Start a GUI placement of a circle.
* User should click 3 unaligned points to define the circle */
else if(!strcmp(argv[1], "circle"))
{
xctx->ui_state |= MENUSTARTCIRCLE;
}
/* clear current schematic window.
* xschem clear [force] [schematic|symbol]
* the 'force' parameter will not ask to save existing modified schematic.
* the 'schematic' or 'symbol' parameter specifies to default to a schematic
* or symbol window (default: schematic) */
else if(!strcmp(argv[1], "clear"))
{
int cancel = 0;
if(argc < 3 || strcmp(argv[2], "force") ) cancel=save(1);
int i, cancel = 1, symbol = 0;;
for(i = 2; i < argc; i++) {
if(!strcmp(argv[i], "force") ) cancel = 0;
if(!strcmp(argv[i], "symbol")) symbol = 1;
}
if(cancel == 1) cancel=save(1);
if(cancel != -1) { /* -1 means user cancel save request */
char name[PATH_MAX];
struct stat buf;
@ -519,7 +550,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
unselect_all(1);
remove_symbols();
clear_drawing();
if(argc > 2 && !strcmp(argv[2], "SYMBOL")) {
if(symbol == 1) {
xctx->netlist_type = CAD_SYMBOL_ATTRS;
set_tcl_netlist_type();
for(i=0;; ++i) { /* find a non-existent untitled[-n].sym */
@ -553,9 +584,13 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
Tcl_ResetResult(interp);
}
/* clears drawing but does not purge symbols */
else if(!strcmp(argv[1], "clear_drawing"))
{
if(argc==2) clear_drawing();
if(argc==2) {
unselect_all(1);
clear_drawing();
}
Tcl_ResetResult(interp);
}
@ -2426,8 +2461,8 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
if(argc == 4) {
const char *f;
f = !strcmp(argv[2], "") ? NULL : argv[2];
if(!strcmp(argv[3], "SCHEMATIC")) saveas(f, SCHEMATIC);
else if(!strcmp(argv[3], "SYMBOL")) saveas(f, SYMBOL);
if(!strcmp(argv[3], "schematic")) saveas(f, SCHEMATIC);
else if(!strcmp(argv[3], "symbol")) saveas(f, SYMBOL);
else saveas(f, SCHEMATIC);
}
else if(argc == 3) {

View File

@ -94,7 +94,7 @@ void check_unique_names(int rename)
char *tmp = NULL;
Int_hashentry *entry;
int big = xctx->wires> 2000 || xctx->instances > 2000;
char *upinst = NULL, *type = NULL;
char *upinst = NULL;
if(xctx->hilight_nets) {
xRect boundbox;
@ -111,15 +111,16 @@ void check_unique_names(int rename)
}
int_hash_free(&xctx->inst_table);
int_hash_init(&xctx->inst_table, HASHSIZE);
/* look for duplicates */
first = 1;
for(i=0;i<xctx->instances; ++i) {
if(xctx->inst[i].instname && xctx->inst[i].instname[0]) {
my_strdup(_ALLOC_ID_, &type,(xctx->inst[i].ptr+ xctx->sym)->type);
if(!type) continue;
if(!(xctx->inst[i].ptr+ xctx->sym)->type) continue;
my_strdup(_ALLOC_ID_, &upinst, xctx->inst[i].instname);
strtoupper(upinst);
if( (entry = int_hash_lookup(&xctx->inst_table, upinst, i, XINSERT_NOREPLACE) ) && entry->value != i) {
dbg(1, "check_unique_names(): found duplicate: i=%d name=%s\n", i, xctx->inst[i].instname);
dbg(0, "check_unique_names(): found duplicate: i=%d name=%s\n", i, xctx->inst[i].instname);
xctx->inst[i].color = -PINLAYER;
inst_hilight_hash_lookup(xctx->inst[i].instname, -PINLAYER, XINSERT_NOREPLACE);
if(rename == 1) {
@ -134,20 +135,23 @@ void check_unique_names(int rename)
bbox(ADD, xctx->inst[i].x1, xctx->inst[i].y1, xctx->inst[i].x2, xctx->inst[i].y2);
}
}
if( (xctx->inst[i].color != -10000) && rename) {
my_strdup(_ALLOC_ID_, &tmp, xctx->inst[i].prop_ptr);
new_prop_string(i, tmp, newpropcnt++, 0);
my_strdup(_ALLOC_ID_, &upinst, xctx->inst[i].instname);
strtoupper(upinst);
int_hash_lookup(&xctx->inst_table, upinst, i, XINSERT);
symbol_bbox(i, &xctx->inst[i].x1, &xctx->inst[i].y1, &xctx->inst[i].x2, &xctx->inst[i].y2);
bbox(ADD, xctx->inst[i].x1, xctx->inst[i].y1, xctx->inst[i].x2, xctx->inst[i].y2);
my_free(_ALLOC_ID_, &tmp);
}
}
} /* for(i...) */
/* rename duplicates */
for(i=0;i<xctx->instances; ++i) {
if( (xctx->inst[i].color != -10000) && rename) {
my_strdup(_ALLOC_ID_, &tmp, xctx->inst[i].prop_ptr);
new_prop_string(i, tmp, newpropcnt++, 0);
my_strdup(_ALLOC_ID_, &upinst, xctx->inst[i].instname);
strtoupper(upinst);
int_hash_lookup(&xctx->inst_table, upinst, i, XINSERT);
symbol_bbox(i, &xctx->inst[i].x1, &xctx->inst[i].y1, &xctx->inst[i].x2, &xctx->inst[i].y2);
bbox(ADD, xctx->inst[i].x1, xctx->inst[i].y1, xctx->inst[i].x2, xctx->inst[i].y2);
my_free(_ALLOC_ID_, &tmp);
}
} /* for(i...) */
my_free(_ALLOC_ID_, &upinst);
my_free(_ALLOC_ID_, &type);
if(rename == 1 && xctx->hilight_nets) {
bbox(SET,0.0,0.0,0.0,0.0);
draw();

View File

@ -5419,9 +5419,18 @@ proc simulate_button {button_path} {
if { ![info exists tctx::[xschem get current_win_path]_simulate] } {
set tctx::[xschem get current_win_path]_simulate 1
$button_path configure -bg red
simulate "clear_simulate_button $button_path tctx::[xschem get current_win_path]_simulate"
if {[catch {
simulate "clear_simulate_button $button_path tctx::[xschem get current_win_path]_simulate"
} err ]} {
puts {Error running simulation procedure}
alert_ {Error running simulation procedure}
clear_simulate_button $button_path tctx::[xschem get current_win_path]_simulate
}
if {$err == -1} {
puts {Error: simulate procedure returned error code -1}
alert_ {Error: simulate procedure returned error code -1}
}
}
}
proc clear_simulate_button {button_path simvar} {
@ -5610,14 +5619,14 @@ proc build_widgets { {topwin {} } } {
$topwin.menubar.file.menu add command -label "New Schematic" -accelerator Ctrl+N\
-command {
xschem clear SCHEMATIC
xschem clear schematic
}
# toolbar_add FileNew {xschem clear SCHEMATIC} "New Schematic" $topwin
# toolbar_add FileNew {xschem clear schematic} "New Schematic" $topwin
$topwin.menubar.file.menu add command -label "New Symbol" -accelerator Ctrl+Shift+N \
-command {
xschem clear SYMBOL
xschem clear symbol
}
# toolbar_add FileNewSym {xschem clear SYMBOL} "New Symbol" $topwin
# toolbar_add FileNewSym {xschem clear symbol} "New Symbol" $topwin
$topwin.menubar.file.menu add command -label "New empty Schematic window" -accelerator {Alt+N} \
-command {
xschem new_window
@ -5667,7 +5676,7 @@ proc build_widgets { {topwin {} } } {
} "Reload File" $topwin
$topwin.menubar.file.menu add command -label "Save as" -command "xschem saveas" -accelerator {Ctrl+Shift+S}
$topwin.menubar.file.menu add command -label "Save as symbol" \
-command "xschem saveas {} SYMBOL" -accelerator {Ctrl+Alt+S}
-command "xschem saveas {} symbol" -accelerator {Ctrl+Alt+S}
# added svg, png 20171022
$topwin.menubar.file.menu add command -label "PDF/PS Export" -command "xschem print pdf" -accelerator {*}
$topwin.menubar.file.menu add command -label "Hierarchical PDF/PS Export" -command "xschem hier_psprint"