summaryrefslogtreecommitdiffstats
path: root/generic/tclIO.c
diff options
context:
space:
mode:
authormdejong <mdejong>2003-03-06 20:14:38 (GMT)
committermdejong <mdejong>2003-03-06 20:14:38 (GMT)
commit1767e49b26c0b5b2f14124ba0abab81f5ade4ec8 (patch)
tree4a5ddae0b2d93a863000f18d1ccbfbf06f9ec9b4 /generic/tclIO.c
parent532758ed47adda0642397dddb71185eb564a7432 (diff)
downloadtcl-1767e49b26c0b5b2f14124ba0abab81f5ade4ec8.zip
tcl-1767e49b26c0b5b2f14124ba0abab81f5ade4ec8.tar.gz
tcl-1767e49b26c0b5b2f14124ba0abab81f5ade4ec8.tar.bz2
* generic/tclIO.c (Tcl_Seek, Tcl_OutputBuffered):
If there is data buffered in the statePtr->curOutPtr member then set the BUFFER_READY flag in Tcl_Seek. This is needed so that the next call to FlushChannel will write any buffered bytes before doing the seek. The existing code would set the BUFFER_READY flag inside the Tcl_OutputBuffered function. This was a programming error made when Tcl_OutputBuffered was originally created in CVS revision 1.35. The setting of the BUFFER_READY flag should not have been included in the Tcl_OutputBuffered function. * generic/tclTest.c (TestChannelCmd): Use the Tcl_InputBuffered and Tcl_OutputBuffered util methods to query the amount of buffered input and output.
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r--generic/tclIO.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 9f992f0..accf020 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIO.c,v 1.65 2003/03/06 10:10:24 mdejong Exp $
+ * RCS: @(#) $Id: tclIO.c,v 1.66 2003/03/06 20:14:51 mdejong Exp $
*/
#include "tclInt.h"
@@ -5464,7 +5464,18 @@ Tcl_Seek(chan, offset, mode)
statePtr->flags &= (~(BG_FLUSH_SCHEDULED));
}
}
-
+
+ /*
+ * If there is data buffered in statePtr->curOutPtr then mark
+ * the channel as ready to flush before invoking FlushChannel.
+ */
+
+ if ((statePtr->curOutPtr != (ChannelBuffer *) NULL) &&
+ (statePtr->curOutPtr->nextAdded >
+ statePtr->curOutPtr->nextRemoved)) {
+ statePtr->flags |= BUFFER_READY;
+ }
+
/*
* If the flush fails we cannot recover the original position. In
* that case the seek is not attempted because we do not know where
@@ -5880,7 +5891,6 @@ Tcl_OutputBuffered(chan)
}
if ((statePtr->curOutPtr != (ChannelBuffer *) NULL) &&
(statePtr->curOutPtr->nextAdded > statePtr->curOutPtr->nextRemoved)) {
- statePtr->flags |= BUFFER_READY;
bytesBuffered +=
(statePtr->curOutPtr->nextAdded - statePtr->curOutPtr->nextRemoved);
}