diff options
author | dgp <dgp@users.sourceforge.net> | 2014-05-28 17:14:11 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2014-05-28 17:14:11 (GMT) |
commit | d6e3f0435451305fe0e8da53490b9c56517db94f (patch) | |
tree | 6060219edc43e39683dc66489a8f38f0f0cb68b2 /generic | |
parent | 1c2468956cac48003a15f5984176963d5135d340 (diff) | |
download | tcl-d6e3f0435451305fe0e8da53490b9c56517db94f.zip tcl-d6e3f0435451305fe0e8da53490b9c56517db94f.tar.gz tcl-d6e3f0435451305fe0e8da53490b9c56517db94f.tar.bz2 |
Expand the IsBufferFull() macro to check non-NULL bufPtr..
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclIO.c | 17 |
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: |