From 56f5c7751c0f9e4da9c1a40ee533ce392a43e4a2 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Thu, 9 Mar 2023 10:47:12 +0000 Subject: Fix SetChannelOption parsing of -encoding* to match GetChannelOption --- generic/tclIO.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/generic/tclIO.c b/generic/tclIO.c index 97ca8d0..4a6dbf4 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -8194,7 +8194,7 @@ Tcl_SetChannelOption( } Tcl_SetChannelBufferSize(chan, newBufferSize); return TCL_OK; - } else if (HaveOpt(2, "-encoding")) { + } else if (HaveOpt(8, "-encoding")) { Tcl_Encoding encoding; int profile; @@ -8230,6 +8230,15 @@ Tcl_SetChannelOption( ResetFlag(statePtr, CHANNEL_NEED_MORE_DATA|CHANNEL_ENCODING_ERROR); UpdateInterest(chanPtr); return TCL_OK; + } else if (HaveOpt(9, "-encodingprofile")) { + int profile; + if (TclEncodingProfileNameToId(interp, newValue, &profile) != TCL_OK) { + return TCL_ERROR; + } + TCL_ENCODING_PROFILE_SET(statePtr->inputEncodingFlags, profile); + TCL_ENCODING_PROFILE_SET(statePtr->outputEncodingFlags, profile); + ResetFlag(statePtr, CHANNEL_NEED_MORE_DATA|CHANNEL_ENCODING_ERROR); + return TCL_OK; } else if (HaveOpt(2, "-eofchar")) { if (!newValue[0] || (!(newValue[0] & 0x80) && !newValue[1])) { if (GotFlag(statePtr, TCL_READABLE)) { @@ -8285,15 +8294,6 @@ Tcl_SetChannelOption( ResetFlag(statePtr, CHANNEL_EOF|CHANNEL_STICKY_EOF|CHANNEL_BLOCKED); statePtr->inputEncodingFlags &= ~TCL_ENCODING_END; return TCL_OK; - } else if (HaveOpt(1, "-encodingprofile")) { - int profile; - if (TclEncodingProfileNameToId(interp, newValue, &profile) != TCL_OK) { - return TCL_ERROR; - } - TCL_ENCODING_PROFILE_SET(statePtr->inputEncodingFlags, profile); - TCL_ENCODING_PROFILE_SET(statePtr->outputEncodingFlags, profile); - ResetFlag(statePtr, CHANNEL_NEED_MORE_DATA|CHANNEL_ENCODING_ERROR); - return TCL_OK; } else if (HaveOpt(1, "-translation")) { const char *readMode, *writeMode; -- cgit v0.12