better implementation of prevous commit

This commit is contained in:
Stefan Frederik 2021-10-10 00:44:01 +02:00
parent 86dcb4cafa
commit 04eee411f3
2 changed files with 17 additions and 18 deletions

View File

@ -1057,7 +1057,7 @@ void load_schematic(int load_symbols, const char *filename, int reset_undo) /* 2
if( (fd=fopen(name,fopen_read_mode))== NULL) {
fprintf(errfp, "load_schematic(): unable to open file: %s, filename=%s\n",
name, filename ? filename : "<NULL>");
my_snprintf(msg, S(msg), "alert_ {Unable to open file: %s}", filename ? filename: "(null)");
my_snprintf(msg, S(msg), "update; alert_ {Unable to open file: %s}", filename ? filename: "(null)");
tcleval(msg);
clear_drawing();
} else {

View File

@ -1581,25 +1581,24 @@ int Tcl_AppInit(Tcl_Interp *inter)
char f[PATH_MAX];
#ifdef __unix__
if(filename[0] == '~' && filename[1] == '/') {
my_snprintf(f, S(f), "%s%s", home_dir, filename + 1);
} else if(filename[0] == '.' && filename[1] == '/') {
my_snprintf(f, S(f), "%s%s", pwd_dir, filename + 1);
} else if(filename[0] !='/') {
my_snprintf(f, S(f), "%s/%s", pwd_dir, filename);
} else {
my_snprintf(f, S(f), "%s", filename);
}
if(filename[0] == '~' && filename[1] == '/') {
my_snprintf(f, S(f), "%s%s", home_dir, filename + 1);
} else if(filename[0] == '.' && filename[1] == '/') {
my_snprintf(f, S(f), "%s%s", pwd_dir, filename + 1);
} else if(filename[0] !='/') {
my_snprintf(f, S(f), "%s/%s", pwd_dir, filename);
} else {
my_snprintf(f, S(f), "%s", filename);
}
#else
my_strncpy(f, abs_sym_path(filename, ""), S(f));
my_strncpy(f, abs_sym_path(filename, ""), S(f));
#endif
dbg(1, "Tcl_AppInit(): filename %s given, removing symbols\n", filename);
remove_symbols();
/* if do_netlist=1 call load_schematic with 'reset_undo=0' avoiding call
to tcl is_xschem_file that could change netlist_type to symbol */
tcleval("update");
load_schematic(1, f, !do_netlist);
Tcl_VarEval(interp, "update_recent_file {", f, "}", NULL);
dbg(1, "Tcl_AppInit(): filename %s given, removing symbols\n", filename);
remove_symbols();
/* if do_netlist=1 call load_schematic with 'reset_undo=0' avoiding call
to tcl is_xschem_file that could change netlist_type to symbol */
load_schematic(1, f, !do_netlist);
Tcl_VarEval(interp, "update_recent_file {", f, "}", NULL);
} else if(!tcl_script[0]) {
char * tmp;
char filename[PATH_MAX];