diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-04-13 06:16:05 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-04-13 06:16:05 (GMT) |
| commit | 023ceb178da1d545717b455ee96184c481f20f5c (patch) | |
| tree | de4077d39417d0029e43d9ac715fbf81304c415f | |
| parent | 4518ee9a6deea0f9709c67f91ef839c53567170f (diff) | |
| download | tcl-023ceb178da1d545717b455ee96184c481f20f5c.zip tcl-023ceb178da1d545717b455ee96184c481f20f5c.tar.gz tcl-023ceb178da1d545717b455ee96184c481f20f5c.tar.bz2 | |
cherry-pick from trunk: Remove one unnecesary call to Tcl_SetErrno() in DoReadChars().
| -rw-r--r-- | generic/tclIO.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index 6ec93f2..92ad97e 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -6091,11 +6091,7 @@ DoReadChars( if (GotFlag(statePtr, CHANNEL_ENCODING_ERROR) && !GotFlag(statePtr, CHANNEL_STICKY_EOF) - && !GotFlag(statePtr, CHANNEL_NONBLOCKING)) { - /* Channel is blocking. Return an error so that callers - * like [read] can return an error. - */ - Tcl_SetErrno(EILSEQ); + && (!GotFlag(statePtr, CHANNEL_NONBLOCKING))) { goto finish; } } @@ -6138,7 +6134,7 @@ finish: } /* - * Regenerate the top channel, in case it was changed due to + * Regenerate chanPtr in case it was changed due to * self-modifying reflected transforms. */ @@ -6160,8 +6156,14 @@ finish: assert(!(GotFlag(statePtr, CHANNEL_EOF|CHANNEL_BLOCKED) == (CHANNEL_EOF|CHANNEL_BLOCKED))); UpdateInterest(chanPtr); + + /* This must comes after UpdateInterest(), which may set errno */ if (GotFlag(statePtr, CHANNEL_ENCODING_ERROR) && (!copied || !GotFlag(statePtr, CHANNEL_NONBLOCKING))) { + /* Channel either is blocking or is nonblocking with no data + * succesfully red before the error. Return an error so that callers + * like [read] can also return an error. + */ Tcl_SetErrno(EILSEQ); copied = -1; } @@ -6200,7 +6202,7 @@ ReadBytes( * been allocated to hold data, not how many * bytes of data have been stored in the * object. */ - int bytesToRead) /* Maximum number of bytes to store, or < 0 to + int bytesToRead) /* Maximum number of bytes to store, or -1 to * get all available bytes. Bytes are obtained * from the first buffer in the queue - even * if this number is larger than the number of @@ -6597,7 +6599,7 @@ ReadChars( * precautions. */ - if (nextPtr->nextRemoved - srcLen < 0) { + if (nextPtr->nextRemoved < srcLen) { Tcl_Panic("Buffer Underflow, BUFFER_PADDING not enough"); } |
