diff options
author | pooryorick <com.digitalsmarties@pooryorick.com> | 2023-04-03 17:12:11 (GMT) |
---|---|---|
committer | pooryorick <com.digitalsmarties@pooryorick.com> | 2023-04-03 17:12:11 (GMT) |
commit | 3e6eaa5776cbff53a13c50cbf5592e65307bd6bb (patch) | |
tree | b6fd219e73ebaa90137130ee9339d04b2f140b84 /generic/tclIO.c | |
parent | 465fa239eb8f73260379ed0e6c139bab39fd2f94 (diff) | |
download | tcl-3e6eaa5776cbff53a13c50cbf5592e65307bd6bb.zip tcl-3e6eaa5776cbff53a13c50cbf5592e65307bd6bb.tar.gz tcl-3e6eaa5776cbff53a13c50cbf5592e65307bd6bb.tar.bz2 |
Fix for [9ca87e6286262a62], sync fcopy buffers input in ReadChars().
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r-- | generic/tclIO.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index 287a2f2..73d787a 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -196,7 +196,7 @@ static void DiscardOutputQueued(ChannelState *chanPtr); static Tcl_Size DoRead(Channel *chanPtr, char *dst, Tcl_Size bytesToRead, int allowShortReads); static Tcl_Size DoReadChars(Channel *chan, Tcl_Obj *objPtr, Tcl_Size toRead, - int appendFlag); + int allowShortReads, int appendFlag); static int FilterInputBytes(Channel *chanPtr, GetsState *statePtr); static int FlushChannel(Tcl_Interp *interp, Channel *chanPtr, @@ -5899,7 +5899,7 @@ Tcl_ReadChars( return TCL_INDEX_NONE; } - return DoReadChars(chanPtr, objPtr, toRead, appendFlag); + return DoReadChars(chanPtr, objPtr, toRead, 0, appendFlag); } /* *--------------------------------------------------------------------------- @@ -5930,6 +5930,7 @@ DoReadChars( Tcl_Size toRead, /* Maximum number of characters to store, or * TCL_INDEX_NONE to read all available data (up to EOF or * when channel blocks). */ + int allowShortReads, /* Allow half-blocking (pipes,sockets) */ int appendFlag) /* If non-zero, data read from the channel * will be appended to the object. Otherwise, * the data will replace the existing contents @@ -6070,8 +6071,8 @@ DoReadChars( if (GotFlag(statePtr, CHANNEL_EOF)) { break; } - if (GotFlag(statePtr, CHANNEL_NONBLOCKING|CHANNEL_BLOCKED) - == (CHANNEL_NONBLOCKING|CHANNEL_BLOCKED)) { + if ((GotFlag(statePtr, CHANNEL_NONBLOCKING) || allowShortReads) + && GotFlag(statePtr, CHANNEL_BLOCKED)) { break; } result = GetInput(chanPtr); @@ -9762,7 +9763,8 @@ CopyData( !GotFlag(inStatePtr, CHANNEL_NONBLOCKING)); } else { size = DoReadChars(inStatePtr->topChanPtr, bufObj, sizeb, - 0 /* No append */); + !GotFlag(inStatePtr, CHANNEL_NONBLOCKING) + ,0 /* No append */); } underflow = (size >= 0) && ((size_t)size < sizeb); /* Input underflow */ } |