From: ian Date: Sun, 22 Jan 2006 15:59:47 +0000 (+0000) Subject: slight improvements to scriptinv, including scriptinv_invoke_fg X-Git-Tag: debian/1.1.1~81 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-tcl.git;a=commitdiff_plain;h=1f4b96ff118c4666bb2674edb09c7dfcfa45f61d;hp=c48252ff1a8cfbd77e1be9717dbcb957bbcf57a8 slight improvements to scriptinv, including scriptinv_invoke_fg --- diff --git a/base/chiark-tcl.h b/base/chiark-tcl.h index 4c022cb..f3f0922 100644 --- a/base/chiark-tcl.h +++ b/base/chiark-tcl.h @@ -39,7 +39,7 @@ typedef struct { /* semi-opaque - read only, and then only where commented */ Tcl_Interp *ip; /* valid, non-0 and useable if set */ Tcl_Obj *obj; /* non-0 iff set (but only test for 0/non-0) */ Tcl_Obj *xargs; - int llength; + int llength; /* after set, is llength of script + xargs */ } ScriptToInvoke; void cht_scriptinv_init(ScriptToInvoke *si); @@ -48,7 +48,12 @@ int cht_scriptinv_set(ScriptToInvoke *si, Tcl_Interp *ip, void cht_scriptinv_cancel(ScriptToInvoke *si); /* then don't invoke */ /* no separate free function - just cancel */ +int cht_scriptinv_invoke_fg(ScriptToInvoke *si, int argc, + Tcl_Obj *const *argv); + /* if script fails, returns that error */ + void cht_scriptinv_invoke(ScriptToInvoke *si, int argc, Tcl_Obj *const *argv); + /* if script fails, reports it with Tcl_BackgroundError */ /* from idtable.c */ diff --git a/base/scriptinv.c b/base/scriptinv.c index 3bc383d..6dd5375 100644 --- a/base/scriptinv.c +++ b/base/scriptinv.c @@ -34,7 +34,8 @@ int cht_scriptinv_set(ScriptToInvoke *si, Tcl_Interp *ip, return 0; } -void cht_scriptinv_invoke(ScriptToInvoke *si, int argc, Tcl_Obj *const *argv) { +int cht_scriptinv_invoke_fg(ScriptToInvoke *si, int argc, + Tcl_Obj *const *argv) { Tcl_Obj *invoke=0; int i, rc; @@ -60,5 +61,10 @@ void cht_scriptinv_invoke(ScriptToInvoke *si, int argc, Tcl_Obj *const *argv) { x_rc: for (i=0; iip); + return rc; } + +void cht_scriptinv_invoke(ScriptToInvoke *si, int argc, Tcl_Obj *const *argv) { + rc= cht_scriptinv_invoke_fg(si, argc, argv); + if (rc) Tcl_BackgroundError(si->ip); +}