summaryrefslogtreecommitdiffstats
path: root/generic/tclIO.c
diff options
context:
space:
mode:
authorpooryorick <com.digitalsmarties@pooryorick.com>2023-04-04 16:26:18 (GMT)
committerpooryorick <com.digitalsmarties@pooryorick.com>2023-04-04 16:26:18 (GMT)
commit8528cc532386d9ff80380afeb132f82c6a2cf25b (patch)
tree9b88208cc941494e7e095051bcc20bcea02e2559 /generic/tclIO.c
parent81999e05543a471cc0a666354120aa83c2bcc7f4 (diff)
downloadtcl-8528cc532386d9ff80380afeb132f82c6a2cf25b.zip
tcl-8528cc532386d9ff80380afeb132f82c6a2cf25b.tar.gz
tcl-8528cc532386d9ff80380afeb132f82c6a2cf25b.tar.bz2
Fix for [9ca87e6286262a62], sync fcopy buffers input in ReadChars().
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r--generic/tclIO.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index d4e562c..1c43360 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -196,7 +196,7 @@ static void DiscardOutputQueued(ChannelState *chanPtr);
static int DoRead(Channel *chanPtr, char *dst, int bytesToRead,
int allowShortReads);
static int DoReadChars(Channel *chan, Tcl_Obj *objPtr, int toRead,
- int appendFlag);
+ int allowShortReads, int appendFlag);
static int FilterInputBytes(Channel *chanPtr,
GetsState *statePtr);
static int FlushChannel(Tcl_Interp *interp, Channel *chanPtr,
@@ -5931,7 +5931,7 @@ Tcl_ReadChars(
return TCL_INDEX_NONE;
}
- return DoReadChars(chanPtr, objPtr, toRead, appendFlag);
+ return DoReadChars(chanPtr, objPtr, toRead, 0, appendFlag);
}
/*
*---------------------------------------------------------------------------
@@ -5962,6 +5962,7 @@ DoReadChars(
int 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
@@ -6101,8 +6102,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);
@@ -9853,7 +9854,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 < sizeb); /* Input underflow */
}