summaryrefslogtreecommitdiffstats
path: root/generic/tclTest.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/tclTest.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/tclTest.c')
-rw-r--r--generic/tclTest.c39
1 files changed, 6 insertions, 33 deletions
diff --git a/generic/tclTest.c b/generic/tclTest.c
index ed7e0ad..41d420e 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclTest.c,v 1.62 2003/02/18 10:13:25 vincentdarley Exp $
+ * RCS: @(#) $Id: tclTest.c,v 1.63 2003/03/06 20:14:58 mdejong Exp $
*/
#define TCL_TEST
@@ -5324,28 +5324,15 @@ TestChannelCmd(clientData, interp, argc, argv)
} else if (statePtr->outputTranslation == TCL_TRANSLATE_CRLF) {
Tcl_AppendElement(interp, "crlf");
}
- for (IOQueued = 0, bufPtr = statePtr->inQueueHead;
- bufPtr != (ChannelBuffer *) NULL;
- bufPtr = bufPtr->nextPtr) {
- IOQueued += bufPtr->nextAdded - bufPtr->nextRemoved;
- }
+ IOQueued = Tcl_InputBuffered(chan);
TclFormatInt(buf, IOQueued);
Tcl_AppendElement(interp, buf);
- IOQueued = 0;
- if (statePtr->curOutPtr != (ChannelBuffer *) NULL) {
- IOQueued = statePtr->curOutPtr->nextAdded -
- statePtr->curOutPtr->nextRemoved;
- }
- for (bufPtr = statePtr->outQueueHead;
- bufPtr != (ChannelBuffer *) NULL;
- bufPtr = bufPtr->nextPtr) {
- IOQueued += (bufPtr->nextAdded - bufPtr->nextRemoved);
- }
+ IOQueued = Tcl_OutputBuffered(chan);
TclFormatInt(buf, IOQueued);
Tcl_AppendElement(interp, buf);
- TclFormatInt(buf, (int)Tcl_Tell((Tcl_Channel) chanPtr));
+ TclFormatInt(buf, (int)Tcl_Tell(chan));
Tcl_AppendElement(interp, buf);
TclFormatInt(buf, statePtr->refCount);
@@ -5361,12 +5348,7 @@ TestChannelCmd(clientData, interp, argc, argv)
(char *) NULL);
return TCL_ERROR;
}
-
- for (IOQueued = 0, bufPtr = statePtr->inQueueHead;
- bufPtr != (ChannelBuffer *) NULL;
- bufPtr = bufPtr->nextPtr) {
- IOQueued += bufPtr->nextAdded - bufPtr->nextRemoved;
- }
+ IOQueued = Tcl_InputBuffered(chan);
TclFormatInt(buf, IOQueued);
Tcl_AppendResult(interp, buf, (char *) NULL);
return TCL_OK;
@@ -5457,16 +5439,7 @@ TestChannelCmd(clientData, interp, argc, argv)
return TCL_ERROR;
}
- IOQueued = 0;
- if (statePtr->curOutPtr != (ChannelBuffer *) NULL) {
- IOQueued = statePtr->curOutPtr->nextAdded -
- statePtr->curOutPtr->nextRemoved;
- }
- for (bufPtr = statePtr->outQueueHead;
- bufPtr != (ChannelBuffer *) NULL;
- bufPtr = bufPtr->nextPtr) {
- IOQueued += (bufPtr->nextAdded - bufPtr->nextRemoved);
- }
+ IOQueued = Tcl_OutputBuffered(chan);
TclFormatInt(buf, IOQueued);
Tcl_AppendResult(interp, buf, (char *) NULL);
return TCL_OK;