diff options
Diffstat (limited to 'generic/tclIO.c')
| -rw-r--r-- | generic/tclIO.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index 85067f2..ca12d63 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -8009,7 +8009,8 @@ Tcl_GetChannelOption( if (len == 0) { Tcl_DStringAppendElement(dsPtr, "-nocomplainencoding"); } - Tcl_DStringAppendElement(dsPtr,"1"); + Tcl_DStringAppendElement(dsPtr, + (flags & CHANNEL_ENCODING_STRICT) ? "0" : "1"); if (len > 0) { return TCL_OK; } @@ -8283,7 +8284,17 @@ Tcl_SetChannelOption( if (Tcl_GetBoolean(interp, newValue, &newMode) == TCL_ERROR) { return TCL_ERROR; } - if (!newMode) { + if (newMode) { + if (statePtr->flags & CHANNEL_ENCODING_STRICT) { + if (interp) { + Tcl_SetObjResult(interp, Tcl_NewStringObj( + "-nocomplainencoding cannot be used with -strictencoding", + -1)); + } + return TCL_ERROR; + } + statePtr->flags |= CHANNEL_ENCODING_NOCOMPLAIN; + } else { if (interp) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "bad value for -nocomplainencoding: only true allowed", @@ -8299,6 +8310,14 @@ Tcl_SetChannelOption( return TCL_ERROR; } if (newMode) { + if (statePtr->flags & CHANNEL_ENCODING_NOCOMPLAIN) { + if (interp) { + Tcl_SetObjResult(interp, Tcl_NewStringObj( + "-strictencoding cannot be used with -nocomplainencoding", + -1)); + } + return TCL_ERROR; + } statePtr->flags |= CHANNEL_ENCODING_STRICT; } return TCL_OK; |
