summaryrefslogtreecommitdiffstats
path: root/generic/tclIO.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2014-05-28 17:14:11 (GMT)
committerdgp <dgp@users.sourceforge.net>2014-05-28 17:14:11 (GMT)
commitc08a9df4d6f77032655cfedda1c62c5c3d171758 (patch)
tree6060219edc43e39683dc66489a8f38f0f0cb68b2 /generic/tclIO.c
parenta60da763ba80a364d4f77d4c04b40dbf02f557e7 (diff)
downloadtcl-c08a9df4d6f77032655cfedda1c62c5c3d171758.zip
tcl-c08a9df4d6f77032655cfedda1c62c5c3d171758.tar.gz
tcl-c08a9df4d6f77032655cfedda1c62c5c3d171758.tar.bz2
Expand the IsBufferFull() macro to check non-NULL bufPtr..
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r--generic/tclIO.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 9e0d7f1..17efa1e 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -12,6 +12,7 @@
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
+#undef NDEBUG
#include "tclInt.h"
#include "tclIO.h"
#include <assert.h>
@@ -284,7 +285,7 @@ static int WillRead(Channel *chanPtr);
#define IsBufferEmpty(bufPtr) ((bufPtr)->nextAdded == (bufPtr)->nextRemoved)
-#define IsBufferFull(bufPtr) ((bufPtr)->nextAdded >= (bufPtr)->bufLength)
+#define IsBufferFull(bufPtr) ((bufPtr) && (bufPtr)->nextAdded >= (bufPtr)->bufLength)
#define IsBufferOverflowing(bufPtr) ((bufPtr)->nextAdded > (bufPtr)->bufLength)
@@ -2516,8 +2517,7 @@ FlushChannel(
* queue.
*/
- if (((statePtr->curOutPtr != NULL) &&
- IsBufferFull(statePtr->curOutPtr))
+ if (IsBufferFull(statePtr->curOutPtr)
|| (GotFlag(statePtr, BUFFER_READY) &&
(statePtr->outQueueHead == NULL))) {
ResetFlag(statePtr, BUFFER_READY);
@@ -2531,6 +2531,8 @@ FlushChannel(
statePtr->curOutPtr = NULL;
}
+ assert(!IsBufferFull(statePtr->curOutPtr));
+
/*
* If we are not being called from an async flush and an async flush
* is active, we just return without producing any output.
@@ -6122,9 +6124,8 @@ GetInput(
*/
bufPtr = statePtr->inQueueTail;
- if ((bufPtr != NULL) && !IsBufferFull(bufPtr)) {
- toRead = SpaceLeft(bufPtr);
- } else {
+
+ if ((bufPtr == NULL) || IsBufferFull(bufPtr)) {
bufPtr = statePtr->saveInBufPtr;
statePtr->saveInBufPtr = NULL;
@@ -6154,6 +6155,8 @@ GetInput(
statePtr->inQueueTail->nextPtr = bufPtr;
}
statePtr->inQueueTail = bufPtr;
+ } else {
+ toRead = SpaceLeft(bufPtr);
}
PreserveChannelBuffer(bufPtr);
@@ -8827,7 +8830,7 @@ DoRead(
/* If there is no full buffer, attempt to create and/or fill one. */
- while (bufPtr == NULL || !IsBufferFull(bufPtr)) {
+ while (!IsBufferFull(bufPtr)) {
int code;
moreData: