diff options
| author | kjnash <k.j.nash@usa.net> | 2022-09-15 14:58:59 (GMT) |
|---|---|---|
| committer | kjnash <k.j.nash@usa.net> | 2022-09-15 14:58:59 (GMT) |
| commit | 9e810a504500232f79a23de35a33127dc19bd34b (patch) | |
| tree | 075ab3f448d6e167ba88e6aa574cce3c881b44e2 /generic/tclIO.c | |
| parent | aca6eed0f36ee531e3e3c8eeb6c6c966ad80057f (diff) | |
| parent | 0371b9ed8d4bd0943122234faf1c03cfc14b3405 (diff) | |
| download | tcl-9e810a504500232f79a23de35a33127dc19bd34b.zip tcl-9e810a504500232f79a23de35a33127dc19bd34b.tar.gz tcl-9e810a504500232f79a23de35a33127dc19bd34b.tar.bz2 | |
Merge 8.7
Diffstat (limited to 'generic/tclIO.c')
| -rw-r--r-- | generic/tclIO.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index 5313eed..e00b99b 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -4335,6 +4335,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); @@ -4351,7 +4352,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; @@ -4390,16 +4391,26 @@ 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. */ - if (total == 0) { - Tcl_SetErrno(EILSEQ); - return -1; - } - break; + encodingError = 1; + result = TCL_OK; } bufPtr->nextAdded += dstWrote; @@ -4497,6 +4508,10 @@ Write( UpdateInterest(chanPtr); + if (encodingError) { + Tcl_SetErrno(EILSEQ); + return -1; + } return total; } |
