diff options
author | oehhar <harald.oehlmann@elmicron.de> | 2022-09-12 10:16:59 (GMT) |
---|---|---|
committer | oehhar <harald.oehlmann@elmicron.de> | 2022-09-12 10:16:59 (GMT) |
commit | 74efc2944882b5bd6d2835d3759035ee13f4ea87 (patch) | |
tree | 500d5091878d948141b87ffd51308853b03afd40 /generic/tclIO.c | |
parent | 14086d3b4aca32f2aa71c2799862593f2db4e0fd (diff) | |
parent | a6b22dc4b365ce9482463ae0a89410571fae6a75 (diff) | |
download | tcl-74efc2944882b5bd6d2835d3759035ee13f4ea87.zip tcl-74efc2944882b5bd6d2835d3759035ee13f4ea87.tar.gz tcl-74efc2944882b5bd6d2835d3759035ee13f4ea87.tar.bz2 |
Merge main
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r-- | generic/tclIO.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index d8a9760..37bef84 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; @@ -4356,6 +4357,19 @@ Write( statePtr->outputEncodingFlags &= ~TCL_ENCODING_START; + /* + * See io-75.2, TCL bug 6978c01b65. + * 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. + */ + + if (result == TCL_CONVERT_UNKNOWN) { + encodingError = 1; + result = TCL_OK; + } + if ((result != TCL_OK) && (srcRead + dstWrote == 0)) { /* * We're reading from invalid/incomplete UTF-8. @@ -4463,6 +4477,10 @@ Write( UpdateInterest(chanPtr); + if (encodingError) { + Tcl_SetErrno(EILSEQ); + return -1; + } return total; } |