diff options
author | max <max@tclers.tk> | 2023-03-30 08:46:27 (GMT) |
---|---|---|
committer | max <max@tclers.tk> | 2023-03-30 08:46:27 (GMT) |
commit | 784535a35c779f46886fe9a880b706c979efdd77 (patch) | |
tree | 0f44abfb50b3fc8d28e5248ffeecc593b19eb516 /generic/tclIORChan.c | |
parent | 2616ef0ef16085f9c15283dfb56c9ccfd3f2da5d (diff) | |
download | tcl-784535a35c779f46886fe9a880b706c979efdd77.zip tcl-784535a35c779f46886fe9a880b706c979efdd77.tar.gz tcl-784535a35c779f46886fe9a880b706c979efdd77.tar.bz2 |
Allow empty mode list in [chan create], so that refchans are able to mimic the behavior of channels created by [socket -server].
Diffstat (limited to 'generic/tclIORChan.c')
-rw-r--r-- | generic/tclIORChan.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c index 8c6f25f..482b0d5 100644 --- a/generic/tclIORChan.c +++ b/generic/tclIORChan.c @@ -532,7 +532,7 @@ TclChanCreateObjCmd( /* * First argument is a list of modes. Allowed entries are "read", "write". - * Expect at least one list element. Abbreviations are ok. + * Empty list is uncommon, but allowed. Abbreviations are ok. */ modeObj = objv[MODE]; @@ -905,6 +905,11 @@ TclChanPostEventObjCmd( if (EncodeEventMask(interp, "event", objv[EVENT], &events) != TCL_OK) { return TCL_ERROR; } + if (events == 0) { + Tcl_SetObjResult(interp, + Tcl_NewStringObj("bad event list: is empty", -1)); + return TCL_ERROR; + } /* * Check that the channel is actually interested in the provided events. @@ -2007,10 +2012,10 @@ ReflectGetOption( * EncodeEventMask -- * * This function takes a list of event items and constructs the - * equivalent internal bitmask. The list must contain at least one - * element. Elements are "read", "write", or any unique abbreviation of - * them. Note that the bitmask is not changed if problems are - * encountered. + * equivalent internal bitmask. The list may be empty but will usually + * contain at least one element. Valid elements are "read", "write", or + * any unique abbreviation of them. Note that the bitmask is not changed + * if problems are encountered. * * Results: * A standard Tcl error code. A bitmask where TCL_READABLE and/or @@ -2040,12 +2045,6 @@ EncodeEventMask( return TCL_ERROR; } - if (listc < 1) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "bad %s list: is empty", objName)); - return TCL_ERROR; - } - events = 0; while (listc > 0) { if (Tcl_GetIndexFromObj(interp, listv[listc-1], eventOptions, |