summaryrefslogtreecommitdiffstats
path: root/generic/tclIO.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-09-11 21:47:06 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-09-11 21:47:06 (GMT)
commita6b22dc4b365ce9482463ae0a89410571fae6a75 (patch)
treef6c852281460b98270a6d6ab68803b9869c4635a /generic/tclIO.c
parent8f0f3b11657ba48eee382942394b7741af6b02cf (diff)
parent9fd4244e4f77dce5470abdc7d85c9c7d75186b09 (diff)
downloadtcl-a6b22dc4b365ce9482463ae0a89410571fae6a75.zip
tcl-a6b22dc4b365ce9482463ae0a89410571fae6a75.tar.gz
tcl-a6b22dc4b365ce9482463ae0a89410571fae6a75.tar.bz2
Merge 8.7
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r--generic/tclIO.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 732e103..7e9593c 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -4301,6 +4301,7 @@ Write(
char *nextNewLine = NULL;
int endEncoding, saved = 0, total = 0, flushed = 0, needNlFlush = 0;
char safe[BUFFER_PADDING];
+ int encodingError = 0;
if (srcLen) {
WillWrite(chanPtr);
@@ -4317,7 +4318,7 @@ Write(
nextNewLine = (char *)memchr(src, '\n', srcLen);
}
- while (srcLen + saved + endEncoding > 0) {
+ while (srcLen + saved + endEncoding > 0 && !encodingError) {
ChannelBuffer *bufPtr;
char *dst;
int result, srcRead, dstLen, dstWrote, srcLimit = srcLen;
@@ -4361,14 +4362,14 @@ Write(
* Check, if an encoding error occured and should be reported to the
* script level.
* This happens, if a written character may not be represented by the
- * current output encoding and strict encoding is active.hao_
+ * current output encoding and strict encoding is active.
*/
-
+
if (result == TCL_CONVERT_UNKNOWN) {
- Tcl_SetErrno(EILSEQ);
- return -1;
+ encodingError = 1;
+ result = TCL_OK;
}
-
+
if ((result != TCL_OK) && (srcRead + dstWrote == 0)) {
/*
* We're reading from invalid/incomplete UTF-8.
@@ -4476,6 +4477,10 @@ Write(
UpdateInterest(chanPtr);
+ if (encodingError) {
+ Tcl_SetErrno(EILSEQ);
+ return -1;
+ }
return total;
}