summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-10-10 11:08:38 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-10-10 11:08:38 (GMT)
commit3f7f7c5584f701f2fee77dc372b824b15b1a7739 (patch)
tree4493ccaae5ea9a393929ed5c20460572d0c46a59
parenta2b119cac88f2853439b6781404687c40acae4d2 (diff)
downloadtcl-3f7f7c5584f701f2fee77dc372b824b15b1a7739.zip
tcl-3f7f7c5584f701f2fee77dc372b824b15b1a7739.tar.gz
tcl-3f7f7c5584f701f2fee77dc372b824b15b1a7739.tar.bz2
Slight improvement to TIP #346/#633 combination: Now -strictencoding 1 automatically sets -nocomplainencoding to 0, while -nocomplainencoding 1 automatically sets strictencoding to 0. This way, they can never both be set.
-rw-r--r--generic/tclIO.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 407b586..6a9c306 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -8320,25 +8320,20 @@ Tcl_SetChannelOption(
return TCL_ERROR;
}
if (newMode) {
- if (GotFlag(statePtr, CHANNEL_ENCODING_STRICT)) {
- if (interp) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "-nocomplainencoding cannot be used with -strictencoding",
- -1));
- }
- return TCL_ERROR;
- }
+ ResetFlag(statePtr, CHANNEL_ENCODING_STRICT);
SetFlag(statePtr, CHANNEL_ENCODING_NOCOMPLAIN);
} else {
#ifdef TCL_NO_DEPRECATED
ResetFlag(statePtr, CHANNEL_ENCODING_NOCOMPLAIN);
#else
- if (interp) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "bad value for -nocomplainencoding: only true allowed",
- -1));
+ if (SetFlag(statePtr, CHANNEL_ENCODING_STRICT)) {
+ if (interp) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "bad value for -nocomplainencoding: only true allowed",
+ TCL_INDEX_NONE));
+ }
+ return TCL_ERROR;
}
- return TCL_ERROR;
#endif
}
return TCL_OK;
@@ -8349,14 +8344,7 @@ Tcl_SetChannelOption(
return TCL_ERROR;
}
if (newMode) {
- if (GotFlag(statePtr, CHANNEL_ENCODING_NOCOMPLAIN)) {
- if (interp) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "-strictencoding cannot be used with -nocomplainencoding",
- -1));
- }
- return TCL_ERROR;
- }
+ ResetFlag(statePtr, CHANNEL_ENCODING_NOCOMPLAIN);
SetFlag(statePtr, CHANNEL_ENCODING_STRICT);
} else {
ResetFlag(statePtr, CHANNEL_ENCODING_STRICT);