From e4e2ba37ccc053494d99a07508c396be5b2b6718 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sat, 25 Mar 2023 09:41:53 +0100 Subject: [PATCH] xschem load from script: no alert box warning if new file given --- src/actions.c | 6 +++--- src/callback.c | 2 +- src/font.c | 2 +- src/save.c | 19 +++++++++++-------- src/scheduler.c | 4 ++-- src/spice_netlist.c | 4 ++-- src/tedax_netlist.c | 3 ++- src/verilog_netlist.c | 2 +- src/vhdl_netlist.c | 2 +- src/xinit.c | 12 ++++++------ src/xschem.h | 2 +- 11 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/actions.c b/src/actions.c index ecb4c5ca..e151b92c 100644 --- a/src/actions.c +++ b/src/actions.c @@ -457,7 +457,7 @@ void ask_new_file(void) xctx->currsch = 0; unselect_all(1); remove_symbols(); - load_schematic(1, f,1); /* 20180925.1 */ + load_schematic(1, f, 1, 1); tclvareval("update_recent_file {", f, "}", NULL); my_strdup(_ALLOC_ID_, &xctx->sch_path[xctx->currsch],"."); xctx->sch_path_hash[xctx->currsch] = 0; @@ -1350,7 +1350,7 @@ int descend_schematic(int instnumber) dbg(1, "descend_schematic(): filename=%s\n", filename); /* we are descending from a parent schematic downloaded from the web */ remove_symbols(); - load_schematic(1, filename, 1); + load_schematic(1, filename, 1, 1); if(xctx->hilight_nets) { prepare_netlist_structs(0); propagate_hilights(1, 0, XINSERT_NOREPLACE); @@ -1401,7 +1401,7 @@ void go_back(int confirm) /* 20171006 add confirm */ /* by default) to parent schematic if going back from embedded symbol */ my_strncpy(filename, xctx->sch[xctx->currsch], S(filename)); - load_schematic(1, filename, 1); + load_schematic(1, filename, 1, 1); if(from_embedded_sym) xctx->modified=save_modified; /* to force ask save embedded sym in parent schematic */ if(xctx->hilight_nets) { diff --git a/src/callback.c b/src/callback.c index eb654d81..f17d0862 100644 --- a/src/callback.c +++ b/src/callback.c @@ -1894,7 +1894,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, unselect_all(1); remove_symbols(); my_strncpy(filename, abs_sym_path(xctx->sch[xctx->currsch], ""), S(filename)); - load_schematic(1, filename, 1); + load_schematic(1, filename, 1, 1); draw(); } break; diff --git a/src/font.c b/src/font.c index 7575a06a..27a99f5a 100644 --- a/src/font.c +++ b/src/font.c @@ -31,7 +31,7 @@ void compile_font(void) my_snprintf(name, S(name), "%s/systemlib/font.sch", tclgetvar("XSCHEM_SHAREDIR")); unselect_all(1); remove_symbols(); - load_schematic(1,name,0); + load_schematic(1, name, 0, 1); for(code=0;code<127;code++) { unselect_all(1); diff --git a/src/save.c b/src/save.c index 78142289..9a9ac009 100644 --- a/src/save.c +++ b/src/save.c @@ -2404,8 +2404,9 @@ void link_symbols_to_instances(int from) /* from >= 0 : linking symbols from pas } } -/* ALWAYS use absolute pathname for fname!!! */ -void load_schematic(int load_symbols, const char *fname, int reset_undo) /* 20150327 added reset_undo */ +/* ALWAYS use absolute pathname for fname!!! + * alert = 0 --> do not show alert if file not existing */ +void load_schematic(int load_symbols, const char *fname, int reset_undo, int alert) { FILE *fd; char name[PATH_MAX]; @@ -2474,9 +2475,11 @@ void load_schematic(int load_symbols, const char *fname, int reset_undo) /* 2015 } } if( (fd=fopen(name,fopen_read_mode))== NULL) { - fprintf(errfp, "load_schematic(): unable to open file: %s, fname=%s\n", name, fname ); - my_snprintf(msg, S(msg), "update; alert_ {Unable to open file: %s}", fname); - tcleval(msg); + if(alert) { + fprintf(errfp, "load_schematic(): unable to open file: %s, fname=%s\n", name, fname ); + my_snprintf(msg, S(msg), "update; alert_ {Unable to open file: %s}", fname); + tcleval(msg); + } clear_drawing(); if(reset_undo) set_modify(0); } else { @@ -3940,7 +3943,7 @@ void descend_symbol(void) unselect_all(1); remove_symbols(); /* must follow save (if) embedded */ /* load_symbol(name_embedded); */ - load_schematic(1, name_embedded, 1); + load_schematic(1, name_embedded, 1, 1); } else { char sympath[PATH_MAX]; my_strncpy(sympath, abs_sym_path(name, ""), S(sympath)); @@ -3954,9 +3957,9 @@ void descend_symbol(void) strstr(xctx->current_dirname, "https://") == xctx->current_dirname)) { /* symbols have already been downloaded while loading parent schematic: set local file path */ my_snprintf(sympath, S(sympath), "%s/xschem_web/%s", tclgetvar("XSCHEM_TMP_DIR"), get_cell_w_ext(name, 0)); - load_schematic(1, sympath, 1); + load_schematic(1, sympath, 1, 1); } else { - load_schematic(1, sympath, 1); + load_schematic(1, sympath, 1, 1); } } zoom_full(1, 0, 1, 0.97); diff --git a/src/scheduler.c b/src/scheduler.c index 84feca06..50325c5f 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -1845,7 +1845,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg xctx->currsch = 0; remove_symbols(); dbg(1, "scheduler: undo_reset=%d\n", undo_reset); - load_schematic(load_symbols, f, undo_reset); + load_schematic(load_symbols, f, undo_reset, 0); tclvareval("update_recent_file {", f, "}", NULL); my_strdup(_ALLOC_ID_, &xctx->sch_path[xctx->currsch], "."); xctx->sch_path_hash[xctx->currsch] = 0; @@ -2686,7 +2686,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg { unselect_all(1); remove_symbols(); - load_schematic(1, xctx->sch[xctx->currsch], 1); + load_schematic(1, xctx->sch[xctx->currsch], 1, 1); if(argc > 2 && !strcmp(argv[2], "zoom_full") ) { zoom_full(1, 0, 1, 0.97); } else { diff --git a/src/spice_netlist.c b/src/spice_netlist.c index fc4417f6..68895cea 100644 --- a/src/spice_netlist.c +++ b/src/spice_netlist.c @@ -88,7 +88,7 @@ void hier_psprint(char **res, int what) /* netlister driver */ str_hash_lookup(&subckt_table, subckt_name, "", XINSERT); get_sch_from_sym(filename, xctx->sym + i); /* for printing we go down to bottom regardless of spice_stop attribute */ - load_schematic(1,filename, 0); + load_schematic(1,filename, 0, 1); zoom_full(0, 0, 1, 0.97); if(what & 1) ps_draw(2); /* page */ if(what & 2) { /* print cellname */ @@ -564,7 +564,7 @@ int spice_block_netlist(FILE *fd, int i) my_free(_ALLOC_ID_, &extra); fprintf(fd, "\n"); - spice_stop ? load_schematic(0,filename, 0) : load_schematic(1,filename, 0); + spice_stop ? load_schematic(0,filename, 0, 1) : load_schematic(1,filename, 0, 1); err |= spice_netlist(fd, spice_stop); /* 20111113 added spice_stop */ if(xctx->schprop && xctx->schprop[0]) { diff --git a/src/tedax_netlist.c b/src/tedax_netlist.c index f37cead6..9bcfa499 100644 --- a/src/tedax_netlist.c +++ b/src/tedax_netlist.c @@ -106,7 +106,7 @@ static int tedax_block_netlist(FILE *fd, int i) fprintf(fd, "%s", get_sym_template(xctx->sym[i].templ, extra)); my_free(_ALLOC_ID_, &extra); fprintf(fd, "\n"); - load_schematic(1,filename, 0); + load_schematic(1,filename, 0, 1); err |= tedax_netlist(fd, tedax_stop); xctx->netlist_count++; @@ -244,5 +244,6 @@ int global_tedax_netlist(int global) /* netlister driver */ } if(!debug_var) xunlink(netl_filename); xctx->netlist_count = 0; + return err; } diff --git a/src/verilog_netlist.c b/src/verilog_netlist.c index 22e38911..9c22abe2 100644 --- a/src/verilog_netlist.c +++ b/src/verilog_netlist.c @@ -460,7 +460,7 @@ int verilog_block_netlist(FILE *fd, int i) my_strdup(_ALLOC_ID_, &extra, get_tok_value(xctx->sym[i].prop_ptr, "verilog_extra", 0)); my_strdup(_ALLOC_ID_, &extra2, get_tok_value(xctx->sym[i].prop_ptr, "verilog_extra", 0)); fprintf(fd, "// sch_path: %s\n", filename); - verilog_stop? load_schematic(0,filename, 0) : load_schematic(1,filename, 0); + verilog_stop? load_schematic(0,filename, 0, 1) : load_schematic(1,filename, 0, 1); /* print verilog timescale and preprocessor directives 10102004 */ fmt_attr = xctx->format ? xctx->format : "verilog_format"; for(j=0;jinstances; ++j) diff --git a/src/vhdl_netlist.c b/src/vhdl_netlist.c index 4bfd64e6..adb70d0c 100644 --- a/src/vhdl_netlist.c +++ b/src/vhdl_netlist.c @@ -550,7 +550,7 @@ int vhdl_block_netlist(FILE *fd, int i) } else { Int_hashtable table = {NULL, 0}; fprintf(fd, "-- sch_path: %s\n", filename); - load_schematic(1,filename, 0); + load_schematic(1,filename, 0, 1); dbg(1, "vhdl_block_netlist(): packages\n"); for(l=0;linstances; ++l) { diff --git a/src/xinit.c b/src/xinit.c index 7cc049fe..1ba32d58 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -755,7 +755,7 @@ int compare_schematics(const char *f) xctx->xorigin = save_xctx->xorigin; xctx->yorigin = save_xctx->yorigin; /* Load schematic 2 for comparing */ - load_schematic(1, xctx->sch_to_compare, 0); /* last param to 0, do not alter window title */ + load_schematic(1, xctx->sch_to_compare, 0, 1); /* last param to 0, do not alter window title */ /* HASH SCHEMATIC 2 , CHECK SCHEMATIC 2 WITH SCHEMATIC 1 */ for(i = 0; i < xctx->instances; ++i) { @@ -1154,7 +1154,7 @@ void preview_window(const char *what, const char *win_path, const char *fname) build_colors(0.0, 0.0); resetwin(1, 0, 1, 0, 0); /* create preview pixmap. resetwin(create_pixmap, clear_pixmap, force) */ dbg(1, "preview_window() draw, load schematic\n"); - load_schematic(1,fname, 0); + load_schematic(1,fname, 0, 1); } zoom_full(1, 0, 1, 0.97); /* draw */ xctx = save_xctx; @@ -1349,7 +1349,7 @@ static void create_new_window(int *window_count, const char *fname) resetwin(1, 0, 1, 0, 0); /* create preview pixmap. resetwin(create_pixmap, clear_pixmap, force, w, h) */ /* draw empty window so if following load fails due to missing file window appears correctly drawn */ zoom_full(1, 0, 1, 0.97); - load_schematic(1, fname, 1); + load_schematic(1, fname, 1, 1); zoom_full(1, 0, 1, 0.97); /* draw */ tclvareval("set_bindings ", window_path[n], NULL); tclvareval("save_ctx ", window_path[n], NULL); @@ -1449,7 +1449,7 @@ static void create_new_tab(int *window_count, const char *fname) /* draw empty window so if following load fails due to missing file window appears correctly drawn */ tclvareval("housekeeping_ctx", NULL); zoom_full(1, 0, 1, 0.97); - load_schematic(1,fname, 1); + load_schematic(1,fname, 1, 1); zoom_full(1, 0, 1, 0.97); /* draw */ } @@ -2469,7 +2469,7 @@ int Tcl_AppInit(Tcl_Interp *inter) remove_symbols(); /* if cli_opt_do_netlist=1 call load_schematic with 'reset_undo=0' avoiding call to tcl is_xschem_file that could change xctx->netlist_type to symbol */ - load_schematic(1, f, !cli_opt_do_netlist); + load_schematic(1, f, !cli_opt_do_netlist, 1); tclvareval("update_recent_file {", f, "}", NULL); } else if(!cli_opt_tcl_script[0]) { char * tmp; @@ -2482,7 +2482,7 @@ int Tcl_AppInit(Tcl_Interp *inter) my_strncpy(fname, abs_sym_path(tmp, ""), S(fname)); /* if cli_opt_do_netlist=1 call load_schematic with 'reset_undo=0' avoiding call to tcl is_xschem_file that could change xctx->netlist_type to symbol */ - load_schematic(1, fname, !cli_opt_do_netlist); + load_schematic(1, fname, !cli_opt_do_netlist, 1); } diff --git a/src/xschem.h b/src/xschem.h index aaa5657a..840968b6 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -1290,7 +1290,7 @@ extern void mem_push_undo(void); extern void mem_pop_undo(int redo, int set_modify_status); extern void mem_delete_undo(void); extern void mem_clear_undo(void); -extern void load_schematic(int load_symbol, const char *fname, int reset_undo); +extern void load_schematic(int load_symbol, const char *fname, int reset_undo, int alert); /* check if filename already in an open window/tab */ extern int check_loaded(const char *f, char *win_path); extern void link_symbols_to_instances(int from);