diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2014-06-06 08:46:58 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2014-06-06 08:46:58 (GMT) |
commit | 0564f2716f8b04442e7d62edc49e651dcff09126 (patch) | |
tree | dfddf6c597119ff9ee8b53992ab0180b0adbb0fe /generic | |
parent | a6f4af7b107ac8381f33d4da361aef7825bd7d6b (diff) | |
parent | 852f44abf1e24dce23b456d6cfa857bb5649300e (diff) | |
download | tcl-0564f2716f8b04442e7d62edc49e651dcff09126.zip tcl-0564f2716f8b04442e7d62edc49e651dcff09126.tar.gz tcl-0564f2716f8b04442e7d62edc49e651dcff09126.tar.bz2 |
merge trunk
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclIO.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index 7d94037..9197b06 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -2503,6 +2503,11 @@ DiscardOutputQueued( } statePtr->outQueueHead = NULL; statePtr->outQueueTail = NULL; + bufPtr = statePtr->curOutPtr; + if (bufPtr && BytesLeft(bufPtr)) { + statePtr->curOutPtr = NULL; + RecycleBuffer(statePtr, bufPtr, 0); + } } /* @@ -3287,11 +3292,18 @@ Tcl_Close( stickyError = 0; - if ((statePtr->encoding != NULL) - && !(statePtr->outputEncodingFlags & TCL_ENCODING_START) - && (CheckChannelErrors(statePtr, TCL_WRITABLE) == 0)) { - statePtr->outputEncodingFlags |= TCL_ENCODING_END; - if (WriteChars(chanPtr, "", 0) < 0) { + if (GotFlag(statePtr, TCL_WRITABLE) && (statePtr->encoding != NULL) + && !(statePtr->outputEncodingFlags & TCL_ENCODING_START)) { + + int code = CheckChannelErrors(statePtr, TCL_WRITABLE); + + if (code == 0) { + statePtr->outputEncodingFlags |= TCL_ENCODING_END; + code = WriteChars(chanPtr, "", 0); + statePtr->outputEncodingFlags &= ~TCL_ENCODING_END; + statePtr->outputEncodingFlags |= TCL_ENCODING_START; + } + if (code < 0) { stickyError = Tcl_GetErrno(); } @@ -8034,8 +8046,9 @@ Tcl_NotifyChannel( */ if (GotFlag(statePtr, BG_FLUSH_SCHEDULED) && (mask & TCL_WRITABLE)) { - FlushChannel(NULL, chanPtr, 1); - mask &= ~TCL_WRITABLE; + if (0 == FlushChannel(NULL, chanPtr, 1)) { + mask &= ~TCL_WRITABLE; + } } /* |