diff options
author | Steve Bennett <steveb@workware.net.au> | 2013-12-09 07:28:30 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2013-12-09 08:20:05 +1000 |
commit | dd213d13411bce204850d48669632bc57b242c7c (patch) | |
tree | 8dc14dafde01afe73ca826dff438d40254c927d8 /jim-aio.c | |
parent | 2448a2047e587cae8a1b2f401607b7b4c3108429 (diff) | |
download | jimtcl-dd213d13411bce204850d48669632bc57b242c7c.zip jimtcl-dd213d13411bce204850d48669632bc57b242c7c.tar.gz jimtcl-dd213d13411bce204850d48669632bc57b242c7c.tar.bz2 |
Fix aio close from non-global namespace
aio [open], as well as similar commands return the name of the
created command. If this is done in the non-global namespace, the
returned name is implicitly scoped to the current namespace while
the actual command is created in the global namespace. Thus [close]
does not work when invoked in that namespace.
The solution is to return a fully qualified name, such as ::aio.handle3
Note that this may also be a problem for similar command such as
[proc] and [alias] that return command names.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim-aio.c')
-rw-r--r-- | jim-aio.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -667,8 +667,7 @@ static int aio_cmd_eof(Jim_Interp *interp, int argc, Jim_Obj *const *argv) static int aio_cmd_close(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { - Jim_DeleteCommand(interp, Jim_String(argv[0])); - return JIM_OK; + return Jim_DeleteCommand(interp, Jim_String(argv[0])); } static int aio_cmd_seek(Jim_Interp *interp, int argc, Jim_Obj *const *argv) @@ -1098,7 +1097,10 @@ static int JimMakeChannel(Jim_Interp *interp, FILE *fh, int fd, Jim_Obj *filenam snprintf(buf, sizeof(buf), hdlfmt, Jim_GetId(interp)); Jim_CreateCommand(interp, buf, JimAioSubCmdProc, af, JimAioDelProc); - Jim_SetResultString(interp, buf, -1); + /* Note that the command must use the global namespace, even if + * the current namespace is something different + */ + Jim_SetResult(interp, Jim_MakeGlobalNamespaceName(interp, Jim_NewStringObj(interp, buf, -1))); return JIM_OK; } |