From 64e3a23bfdcfbe7b66872c58d095aa6e1868f95e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 31 Jan 2023 07:49:16 +0000 Subject: SetFlag -> GotFlag (since SetFlag always returns 1, this is nonsence in an if() statement). Also add test-case, showing that it was actually wrong, in behavior too. --- generic/tclIO.c | 2 +- tests/ioCmd.test | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/generic/tclIO.c b/generic/tclIO.c index 47040d5..fed469c 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -8354,7 +8354,7 @@ Tcl_SetChannelOption( #ifdef TCL_NO_DEPRECATED ResetFlag(statePtr, CHANNEL_ENCODING_NOCOMPLAIN); #else - if (SetFlag(statePtr, CHANNEL_ENCODING_STRICT)) { + if (GotFlag(statePtr, CHANNEL_ENCODING_STRICT) != CHANNEL_ENCODING_STRICT) { if (interp) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "bad value for -nocomplainencoding: only true allowed", diff --git a/tests/ioCmd.test b/tests/ioCmd.test index 73f0e1c..1a72f70 100644 --- a/tests/ioCmd.test +++ b/tests/ioCmd.test @@ -376,6 +376,16 @@ test iocmd-8.21 {fconfigure command / -nocomplainencoding 0 error} -constraints } -body { fconfigure $console -nocomplainencoding 0 } -returnCodes error -result "bad value for -nocomplainencoding: only true allowed" +test iocmd-8.22 {fconfigure command / -nocomplainencoding 0, no error if -strictencoding already defined} -setup { + set console stdin + set oldmode [fconfigure $console -strictencoding] +} -body { + fconfigure $console -strictencoding 1 + fconfigure $console -nocomplainencoding 0 + fconfigure $console -nocomplainencoding +} -cleanup { + fconfigure $console -strictencoding $oldmode +} -result 0 test iocmd-9.1 {eof command} { -- cgit v0.12