summaryrefslogtreecommitdiffstats
path: root/generic/tclIORChan.c
diff options
context:
space:
mode:
authormax <max@tclers.tk>2023-03-30 09:23:44 (GMT)
committermax <max@tclers.tk>2023-03-30 09:23:44 (GMT)
commit67ced520761d9c2dff0022dafbebdb996e20b551 (patch)
tree665b83f10083073eb9adafaa8cf6f0ce4fc9eb51 /generic/tclIORChan.c
parent5b6755494dd27d501b2fa753ecacceda849092ed (diff)
parentf8b9e919c954be237c906a708530111607f88081 (diff)
downloadtcl-67ced520761d9c2dff0022dafbebdb996e20b551.zip
tcl-67ced520761d9c2dff0022dafbebdb996e20b551.tar.gz
tcl-67ced520761d9c2dff0022dafbebdb996e20b551.tar.bz2
Merge 8.7: Allow empty mode list in [chan create].
Diffstat (limited to 'generic/tclIORChan.c')
-rw-r--r--generic/tclIORChan.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c
index ba2d2cb..2f4f91d 100644
--- a/generic/tclIORChan.c
+++ b/generic/tclIORChan.c
@@ -549,7 +549,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];
@@ -922,6 +922,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.
@@ -2111,10 +2116,10 @@ ReflectTruncate(
* 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
@@ -2144,12 +2149,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,