summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorferrieux <ferrieux@users.sourceforge.net>2011-08-18 15:06:58 (GMT)
committerferrieux <ferrieux@users.sourceforge.net>2011-08-18 15:06:58 (GMT)
commit377e7c77456825d7dc9d44f44c937ff57e1bfce3 (patch)
tree9ef35d86a98dfa90f7db55a9e7430b8b3c4b960f
parentc507790763e7beac42adb3ac9a209603ff5a9582 (diff)
downloadtcl-377e7c77456825d7dc9d44f44c937ff57e1bfce3.zip
tcl-377e7c77456825d7dc9d44f44c937ff57e1bfce3.tar.gz
tcl-377e7c77456825d7dc9d44f44c937ff57e1bfce3.tar.bz2
[Bug 3096275] Sync fcopy buffers input.
-rw-r--r--ChangeLog4
-rw-r--r--generic/tclIO.c15
2 files changed, 14 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 64a25dd..e294229 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-08-18 Alexandre Ferrieux <ferrieux@users.sourceforge.net>
+
+ * generic/tclIO.c [Bug 3096275] Sync fcopy buffers input.
+
2011-08-18 Jan Nijtmans <nijtmans@users.sf.net>
* generic/tclUniData.c: [Bug 3393714] overflow in toupper delta
diff --git a/generic/tclIO.c b/generic/tclIO.c
index a19fde8..95afd63 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -79,7 +79,7 @@ static int DetachChannel(Tcl_Interp *interp, Tcl_Channel chan);
static void DiscardInputQueued(ChannelState *statePtr,
int discardSavedBuffers);
static void DiscardOutputQueued(ChannelState *chanPtr);
-static int DoRead(Channel *chanPtr, char *srcPtr, int slen);
+static int DoRead(Channel *chanPtr, char *srcPtr, int slen, int allowShortReads);
static int DoWrite(Channel *chanPtr, const char *src, int srcLen);
static int DoReadChars(Channel *chan, Tcl_Obj *objPtr, int toRead,
int appendFlag);
@@ -5444,7 +5444,7 @@ Tcl_Read(
return -1;
}
- return DoRead(chanPtr, dst, bytesToRead);
+ return DoRead(chanPtr, dst, bytesToRead, 0);
}
/*
@@ -9169,7 +9169,8 @@ CopyData(
}
if (inBinary || sameEncoding) {
- size = DoRead(inStatePtr->topChanPtr, csPtr->buffer, sizeb);
+ size = DoRead(inStatePtr->topChanPtr, csPtr->buffer, sizeb,
+ !GotFlag(inStatePtr, CHANNEL_NONBLOCKING));
} else {
size = DoReadChars(inStatePtr->topChanPtr, bufObj, sizeb,
0 /* No append */);
@@ -9408,7 +9409,8 @@ static int
DoRead(
Channel *chanPtr, /* The channel from which to read. */
char *bufPtr, /* Where to store input read. */
- int toRead) /* Maximum number of bytes to read. */
+ int toRead, /* Maximum number of bytes to read. */
+ int allowShortReads) /* Allow half-blocking (pipes,sockets) */
{
ChannelState *statePtr = chanPtr->state;
/* State info for channel */
@@ -9449,7 +9451,10 @@ DoRead(
}
goto done;
}
- }
+ } else if (allowShortReads) {
+ copied += copiedNow;
+ break;
+ }
}
ResetFlag(statePtr, CHANNEL_BLOCKED);