summaryrefslogtreecommitdiffstats
path: root/generic/tclIO.c
diff options
context:
space:
mode:
authorpooryorick <com.digitalsmarties@pooryorick.com>2022-12-28 12:07:18 (GMT)
committerpooryorick <com.digitalsmarties@pooryorick.com>2022-12-28 12:07:18 (GMT)
commit4a8b2cf10f8ebcebaa9d3546f3399d3d9a8aa00e (patch)
treecc70e97f490ab84fa91b34aaa160f2e9d721d69b /generic/tclIO.c
parentecaf98ffad23b0a547d0cedb852e0186d5c0c0af (diff)
downloadtcl-4a8b2cf10f8ebcebaa9d3546f3399d3d9a8aa00e.zip
tcl-4a8b2cf10f8ebcebaa9d3546f3399d3d9a8aa00e.tar.gz
tcl-4a8b2cf10f8ebcebaa9d3546f3399d3d9a8aa00e.tar.bz2
A better fix for [b8f575aa23], as it maintains the expectation that synchronous
[read] results in an error when invalid data is encountered. someone other than pooryorick: Pushed this check-in back on to a review branch. It needs more baking/review. As is, it makes two tests fail, and it introduces a new element "-result" to the return options dictionary.
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r--generic/tclIO.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index e6e3560..63b9a7d 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -6041,7 +6041,7 @@ DoReadChars(
assert(statePtr->inputEncodingFlags & TCL_ENCODING_END);
assert(!GotFlag(statePtr, CHANNEL_BLOCKED|INPUT_SAW_CR));
- /* TODO: We don't need this call? */
+ /* TODO: UpdateInterest isn't needed here? */
UpdateInterest(chanPtr);
return 0;
}
@@ -6055,7 +6055,7 @@ DoReadChars(
}
ResetFlag(statePtr, CHANNEL_BLOCKED|CHANNEL_EOF);
statePtr->inputEncodingFlags &= ~TCL_ENCODING_END;
- /* TODO: We don't need this call? */
+ /* TODO: UpdateInterest isn't needed here? */
UpdateInterest(chanPtr);
return 0;
}
@@ -6084,6 +6084,15 @@ DoReadChars(
} else {
copiedNow = ReadChars(statePtr, objPtr, toRead, &factor);
}
+ if (GotFlag(statePtr, CHANNEL_ENCODING_ERROR) && !GotFlag(statePtr, CHANNEL_NONBLOCKING)) {
+ /* Channel is Synchronous. Return an error so that [read] and
+ * friends can return an error
+ */
+ TclChannelRelease((Tcl_Channel)chanPtr);
+ UpdateInterest(chanPtr);
+ Tcl_SetErrno(EILSEQ);
+ return -1;
+ }
/*
* If the current buffer is empty recycle it.