diff options
| author | oehhar <harald.oehlmann@elmicron.de> | 2023-11-20 13:55:31 (GMT) |
|---|---|---|
| committer | oehhar <harald.oehlmann@elmicron.de> | 2023-11-20 13:55:31 (GMT) |
| commit | 48dbc9e71e5a20cf64ee6f2df579c81efc3c6b51 (patch) | |
| tree | 3959b5414136587cc07db9f893bed1610a9adfcb /generic/tclIO.c | |
| parent | befd279ddd1ec6d3223626ed463a2570d6abfbb2 (diff) | |
| parent | ee5350e804935ff2c79ed4d6f85a0b205e7a7915 (diff) | |
| download | tcl-48dbc9e71e5a20cf64ee6f2df579c81efc3c6b51.zip tcl-48dbc9e71e5a20cf64ee6f2df579c81efc3c6b51.tar.gz tcl-48dbc9e71e5a20cf64ee6f2df579c81efc3c6b51.tar.bz2 | |
Fix bug [a173f922]: fcopy does not write leading correct chars on later encoding error.
Diffstat (limited to 'generic/tclIO.c')
| -rw-r--r-- | generic/tclIO.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index d7b9513..b480377 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -9687,6 +9687,7 @@ CopyData( ChannelState *inStatePtr, *outStatePtr; int result = TCL_OK; Tcl_Size sizeb; + Tcl_Size sizePart; Tcl_WideInt total; Tcl_WideInt size; const char *buffer; @@ -9768,6 +9769,23 @@ CopyData( size = DoReadChars(inStatePtr->topChanPtr, bufObj, sizeb, !GotFlag(inStatePtr, CHANNEL_NONBLOCKING) ,0 /* No append */); + /* + * In case of a recoverable encoding error, any data before + * the error should be written. This data is in the bufObj. + * Program flow for this case: + * - Check, if there are any remaining bytes to write + * - If yes, simulate a successful read to write them out + * - Come back here by the outer loop and read again + * - Do not enter in the if below, as there are no pending + * writes + * - Fail below with a read error + */ + if (size < 0 && Tcl_GetErrno() == EILSEQ) { + Tcl_GetStringFromObj(bufObj, &sizePart); + if (sizePart > 0) { + size = sizePart; + } + } } underflow = (size >= 0) && (size < sizeb); /* Input underflow */ } |
