chiark
/
gitweb
/
~ian
/
chiark-tcl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fixes for cdb; it now works at least a bit
[chiark-tcl.git]
/
base
/
scriptinv.c
diff --git
a/base/scriptinv.c
b/base/scriptinv.c
index 29651b254769d61680f542a4671d156847acea74..a066572c2873ecc3edff403574c8f6cc2a89f350 100644
(file)
--- a/
base/scriptinv.c
+++ b/
base/scriptinv.c
@@
-1,16
+1,18
@@
/*
*/
/*
*/
-#include "chiark-tcl.h"
+#include "chiark-tcl
-base
.h"
void cht_scriptinv_init(ScriptToInvoke *si) {
void cht_scriptinv_init(ScriptToInvoke *si) {
- si->obj= 0;
+ si->ipq= 0;
+ si->script= 0;
si->xargs= 0;
}
void cht_scriptinv_cancel(ScriptToInvoke *si) {
si->xargs= 0;
}
void cht_scriptinv_cancel(ScriptToInvoke *si) {
- if (si->
obj) { Tcl_DecrRefCount(si->obj); si->obj
= 0; }
+ if (si->
script) { Tcl_DecrRefCount(si->script); si->script
= 0; }
if (si->xargs) { Tcl_DecrRefCount(si->xargs); si->xargs= 0; }
if (si->xargs) { Tcl_DecrRefCount(si->xargs); si->xargs= 0; }
+ si->ipq= 0;
}
int cht_scriptinv_set(ScriptToInvoke *si, Tcl_Interp *ip,
}
int cht_scriptinv_set(ScriptToInvoke *si, Tcl_Interp *ip,
@@
-18,41
+20,44
@@
int cht_scriptinv_set(ScriptToInvoke *si, Tcl_Interp *ip,
int rc, xlength;
cht_scriptinv_cancel(si);
int rc, xlength;
cht_scriptinv_cancel(si);
+ if (!newscript) return 0;
- rc= Tcl_ListObjLength(ip, newscript, &si->llen
gth
); if (rc) return rc;
+ rc= Tcl_ListObjLength(ip, newscript, &si->llen); if (rc) return rc;
Tcl_IncrRefCount(newscript);
if (xargs) {
rc= Tcl_ListObjLength(ip, xargs, &xlength); if (rc) return rc;
Tcl_IncrRefCount(xargs);
Tcl_IncrRefCount(newscript);
if (xargs) {
rc= Tcl_ListObjLength(ip, xargs, &xlength); if (rc) return rc;
Tcl_IncrRefCount(xargs);
- si->llen
gth
+= xlength;
+ si->llen += xlength;
}
}
- si->
obj
= newscript;
+ si->
script
= newscript;
si->xargs= xargs;
si->xargs= xargs;
- si->ip= ip;
+ si->ip
q
= ip;
return 0;
}
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;
Tcl_Obj *invoke=0;
int i, rc;
- assert(si->obj);
+ if (!si->ipq) return TCL_OK;
+
for (i=0; i<argc; i++) Tcl_IncrRefCount(argv[i]);
for (i=0; i<argc; i++) Tcl_IncrRefCount(argv[i]);
- invoke= Tcl_DuplicateObj(si->
obj
);
+ invoke= Tcl_DuplicateObj(si->
script
);
Tcl_IncrRefCount(invoke);
if (si->xargs) {
Tcl_IncrRefCount(invoke);
if (si->xargs) {
- rc= Tcl_ListObjAppendList(si->ip, invoke, si->xargs);
+ rc= Tcl_ListObjAppendList(si->ip
q
, invoke, si->xargs);
if (rc) goto x_rc;
}
if (rc) goto x_rc;
}
- rc= Tcl_ListObjReplace(si->ip
, invoke,si->llength
,0, argc,argv);
+ rc= Tcl_ListObjReplace(si->ip
q, invoke,si->llen
,0, argc,argv);
if (rc) goto x_rc;
if (rc) goto x_rc;
- rc= Tcl_EvalObjEx(si->ip
,invoke,
TCL_EVAL_GLOBAL|TCL_EVAL_DIRECT);
+ rc= Tcl_EvalObjEx(si->ip
q, invoke,
TCL_EVAL_GLOBAL|TCL_EVAL_DIRECT);
if (rc) goto x_rc;
rc= 0;
if (rc) goto x_rc;
rc= 0;
@@
-60,5
+65,11
@@
void cht_scriptinv_invoke(ScriptToInvoke *si, int argc, Tcl_Obj *const *argv) {
x_rc:
for (i=0; i<argc; i++) Tcl_DecrRefCount(argv[i]);
if (invoke) Tcl_DecrRefCount(invoke);
x_rc:
for (i=0; i<argc; i++) Tcl_DecrRefCount(argv[i]);
if (invoke) Tcl_DecrRefCount(invoke);
-
if (rc) Tcl_BackgroundError(si->ip)
;
+
return rc
;
}
}
+
+void cht_scriptinv_invoke(ScriptToInvoke *si, int argc, Tcl_Obj *const *argv) {
+ int rc;
+ rc= cht_scriptinv_invoke_fg(si, argc, argv);
+ if (rc) Tcl_BackgroundError(si->ipq);
+}