better range checking for commands "xschem get schname" and "xschem get sch_path"

This commit is contained in:
stefan schippers 2023-03-22 11:22:41 +01:00
parent a0fb4c5ee6
commit 757fd0a378
2 changed files with 6 additions and 8 deletions

View File

@ -632,7 +632,7 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
<li><kbd> temp_dir </kbd> get windows temporary dir </li>
<li><kbd> text_svg </kbd> return 1 if using &lt;text&gt; elements in svg export </li>
<li><kbd> textlayer </kbd> layer number for texts </li>
<li><kbd> top_path </kbd> get top hier path of current window (always "") for tabbed if </li>
<li><kbd> top_path </kbd> get top hier path of current window (always "" for tabbed if) </li>
<li><kbd> topwindow </kbd> same as top_path but main window returned as "." </li>
<li><kbd> version </kbd> return xschem version </li>
<li><kbd> wirelayer </kbd> layer used for wires </li>

View File

@ -942,9 +942,8 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
/* allows to retrieve name of n-th parent schematic */
if(argc > 3) x = atoi(argv[3]);
else x = xctx->currsch;
if(x<0 && xctx->currsch+x>=0) {
Tcl_SetResult(interp, xctx->sch[xctx->currsch+x], TCL_VOLATILE);
} else if(x<=xctx->currsch) {
if(x < 0 ) x = xctx->currsch + x;
if(x<=xctx->currsch && x >= 0) {
Tcl_SetResult(interp, xctx->sch[x], TCL_VOLATILE);
}
}
@ -953,9 +952,8 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
int x;
if(argc > 3) x = atoi(argv[3]);
else x = xctx->currsch;
if(x<0 && xctx->currsch+x>=0) {
Tcl_SetResult(interp, xctx->sch_path[xctx->currsch+x], TCL_VOLATILE);
} else if(x<=xctx->currsch) {
if(x < 0 ) x = xctx->currsch + x;
if(x<=xctx->currsch && x >= 0) {
Tcl_SetResult(interp, xctx->sch_path[x], TCL_VOLATILE);
}
}
@ -1009,7 +1007,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
}
/* top_path="" for main window, ".x1", ".x2", ... for additional windows.
* always "" in tabbed interface */
else if(!strcmp(argv[2], "top_path")) { /* get top hier path of current window (always "") for tabbed if */
else if(!strcmp(argv[2], "top_path")) { /* get top hier path of current window (always "" for tabbed if) */
Tcl_SetResult(interp, xctx->top_path, TCL_VOLATILE);
}
/* same as above but main window returned as "." */