From 0dfbc9ded90245ab5ef449f9bfbfc29303edaaf5 Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Sun, 21 Aug 2022 12:24:26 +0200 Subject: [PATCH] added return status from descend_schematic() --- src/actions.c | 15 ++++++++------- src/scheduler.c | 7 ++++--- src/xschem.h | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/actions.c b/src/actions.c index ff79411c..831528ac 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1212,7 +1212,7 @@ void get_sch_from_sym(char *filename, xSymbol *sym) } } -void descend_schematic(int instnumber) +int descend_schematic(int instnumber) { const char *str; char filename[PATH_MAX]; @@ -1224,7 +1224,7 @@ void descend_schematic(int instnumber) if(xctx->lastsel !=1 || xctx->sel_array[0].type!=ELEMENT) { dbg(1, "descend_schematic(): wrong selection\n"); - return; + return 0; } else { @@ -1240,10 +1240,10 @@ void descend_schematic(int instnumber) my_snprintf(cmd, S(cmd), "save_file_dialog {Save file} .sch.sym INITIALLOADDIR {%s}", filename); tcleval(cmd); my_strncpy(res, tclresult(), S(res)); - if(!res[0]) return; + if(!res[0]) return 0; dbg(1, "descend_schematic(): saving: %s\n",res); save_ok = save_schematic(res); - if(save_ok==0) return; + if(save_ok==0) return 0; } dbg(1, "descend_schematic(): inst type: %s\n", (xctx->inst[xctx->sel_array[0].n].ptr+ xctx->sym)->type); @@ -1252,7 +1252,7 @@ void descend_schematic(int instnumber) (xctx->inst[xctx->sel_array[0].n].ptr+ xctx->sym)->type && strcmp( (xctx->inst[xctx->sel_array[0].n].ptr+ xctx->sym)->type, "subcircuit") && strcmp( (xctx->inst[xctx->sel_array[0].n].ptr+ xctx->sym)->type, "primitive") - ) return; + ) return 0; if(xctx->modified) { @@ -1267,7 +1267,7 @@ void descend_schematic(int instnumber) * 0 : file not saved due to errors or per user request */ if(ret == 0) clear_all_hilights(); - if(ret == -1) return; /* user cancel */ + if(ret == -1) return 0; /* user cancel */ } /* build up current hierarchy path */ @@ -1298,7 +1298,7 @@ void descend_schematic(int instnumber) if(!inum[0]) { my_free(710, &xctx->sch_path[xctx->currsch+1]); xctx->sch_path_hash[xctx->currsch+1] =0; - return; + return 0; } inst_number=atoi(inum); } else { @@ -1336,6 +1336,7 @@ void descend_schematic(int instnumber) dbg(1, "descend_schematic(): before zoom(): prep_hash_inst=%d\n", xctx->prep_hash_inst); zoom_full(1, 0, 1, 0.97); } + return 1; } void go_back(int confirm) /* 20171006 add confirm */ diff --git a/src/scheduler.c b/src/scheduler.c index f0e06f33..92718299 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -618,14 +618,15 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg else if(!strcmp(argv[1],"descend")) { + int ret=0; cmd_found = 1; if(argc >=3) { int n = atoi(argv[2]); - descend_schematic(n); + ret = descend_schematic(n); } else { - descend_schematic(0); + ret = descend_schematic(0); } - Tcl_ResetResult(interp); + Tcl_SetResult(interp, dtoa(ret), TCL_VOLATILE); } else if(!strcmp(argv[1],"descend_symbol")) diff --git a/src/xschem.h b/src/xschem.h index 3a150104..7a730113 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -1214,7 +1214,7 @@ extern char *read_line(FILE *fp, int dbg_level); extern void read_record(int firstchar, FILE *fp, int dbg_level); extern void create_sch_from_sym(void); extern void get_sch_from_sym(char *filename, xSymbol *sym); -extern void descend_schematic(int instnumber); +extern int descend_schematic(int instnumber); extern void go_back(int confirm); extern void view_unzoom(double z); extern void view_zoom(double z);