File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -4616,7 +4616,7 @@ Tcl_GetsObj(
4616
4616
4617
4617
if (GotFlag (statePtr , CHANNEL_ENCODING_ERROR )) {
4618
4618
UpdateInterest (chanPtr );
4619
- ResetFlag (statePtr , CHANNEL_ENCODING_ERROR );
4619
+ ResetFlag (statePtr , CHANNEL_EOF | CHANNEL_BLOCKED );
4620
4620
Tcl_SetErrno (EILSEQ );
4621
4621
return TCL_INDEX_NONE ;
4622
4622
}
@@ -5941,6 +5941,7 @@ DoReadChars(
5941
5941
int factor = UTF_EXPANSION_FACTOR ;
5942
5942
5943
5943
if (GotFlag (statePtr , CHANNEL_ENCODING_ERROR )) {
5944
+ ResetFlag (statePtr , CHANNEL_EOF |CHANNEL_STICKY_EOF |CHANNEL_BLOCKED );
5944
5945
/* TODO: We don't need this call? */
5945
5946
UpdateInterest (chanPtr );
5946
5947
Tcl_SetErrno (EILSEQ );
@@ -6117,6 +6118,7 @@ DoReadChars(
6117
6118
* succesfully red before the error. Return an error so that callers
6118
6119
* like [read] can also return an error.
6119
6120
*/
6121
+ ResetFlag (statePtr , CHANNEL_EOF |CHANNEL_ENCODING_ERROR );
6120
6122
Tcl_SetErrno (EILSEQ );
6121
6123
copied = -1 ;
6122
6124
}
Original file line number Diff line number Diff line change @@ -9322,6 +9322,30 @@ test io-75.8 {invalid utf-8 encoding eof handling (-profile strict)} -setup {
9322
9322
removeFile io-75.8
9323
9323
} -result {41 1 {}}
9324
9324
9325
+ test io-75.8.eoflater {invalid utf-8 encoding eof handling (-profile strict)} -setup {
9326
+ set res {}
9327
+ set fn [makeFile {} io-75.8]
9328
+ set f [open $fn w+]
9329
+ fconfigure $f -encoding binary
9330
+ # \x81 is invalid in utf-8. -eofchar is not detected, because it comes later.
9331
+ puts -nonewline $f A\x81\x1A
9332
+ flush $f
9333
+ seek $f 0
9334
+ fconfigure $f -encoding utf-8 -buffering none -eofchar \x1A \
9335
+ -translation lf -profile strict
9336
+ } -body {
9337
+ after 1
9338
+ set status [catch {read $f } cres copts]
9339
+ lappend res $status
9340
+ lappend res [eof $f ]
9341
+ chan configure $f -encoding iso8859-1
9342
+ lappend res [read $f ]
9343
+ close $f
9344
+ set res
9345
+ } -cleanup {
9346
+ removeFile io-75.8
9347
+ } -result " 1 0 \x81 "
9348
+
9325
9349
test io-75.9 {unrepresentable character write passes and is replaced by ?} -setup {
9326
9350
set fn [makeFile {} io-75.9]
9327
9351
set f [open $fn w+]
You can’t perform that action at this time.
0 commit comments