diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-03-04 13:59:36 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-03-04 13:59:36 (GMT) |
commit | f67e0871803fd2f7cd43ac5229188fe322550fa5 (patch) | |
tree | fe1fa7983f1e4125b964b5f0fa170c455eced1bf /generic/tclIO.c | |
parent | ac5f46d2701330d40d72814660be2efa4b69e39f (diff) | |
parent | 8defb7d10b69cdbe3219de6ae2dc169dc8df8bb9 (diff) | |
download | tcl-f67e0871803fd2f7cd43ac5229188fe322550fa5.zip tcl-f67e0871803fd2f7cd43ac5229188fe322550fa5.tar.gz tcl-f67e0871803fd2f7cd43ac5229188fe322550fa5.tar.bz2 |
Merge 8.6
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r-- | generic/tclIO.c | 88 |
1 files changed, 47 insertions, 41 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index 4bb3b00..d21c9f3 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -1546,8 +1546,8 @@ TclGetChannelFromObj( /* No epoch change in channel since lookup */ && (resPtr->epoch == statePtr->epoch)) { /* - * Have a valid saved lookup. Jump to end to return it. - */ + * Have a valid saved lookup. Jump to end to return it. + */ goto valid; } @@ -2895,9 +2895,9 @@ FlushChannel( break; } else { /* - * TODO: Consider detecting and reacting to short writes on + * TODO: Consider detecting and reacting to short writes on * blocking channels. Ought not happen. See iocmd-24.2. - */ + */ wroteSome = 1; } @@ -3502,11 +3502,17 @@ Tcl_Close( #ifndef TCL_NO_DEPRECATED if ((chanPtr->typePtr->closeProc == TCL_CLOSE2PROC) || (chanPtr->typePtr->closeProc == NULL)) { - /* If this half-close fails, just continue the full close */ - (void)chanPtr->typePtr->close2Proc(chanPtr->instanceData, interp, TCL_CLOSE_READ); + /* If this half-close gives a EINVAL, just continue the full close */ + result = chanPtr->typePtr->close2Proc(chanPtr->instanceData, interp, TCL_CLOSE_READ); + if (result == EINVAL) { + result = 0; + } } #else - (void)chanPtr->typePtr->close2Proc(chanPtr->instanceData, interp, TCL_CLOSE_READ); + result = chanPtr->typePtr->close2Proc(chanPtr->instanceData, interp, TCL_CLOSE_READ); + if (result == EINVAL) { + result = 0; + } #endif /* @@ -4256,8 +4262,8 @@ WillRead( { if (chanPtr->typePtr == NULL) { /* - * Prevent read attempts on a closed channel. - */ + * Prevent read attempts on a closed channel. + */ DiscardInputQueued(chanPtr->state, 0); Tcl_SetErrno(EINVAL); @@ -4368,15 +4374,15 @@ Write( dstLen + BUFFER_PADDING, &srcRead, &dstWrote, NULL); /* - * See chan-io-1.[89]. Tcl Bug 506297. - */ + * See chan-io-1.[89]. Tcl Bug 506297. + */ statePtr->outputEncodingFlags &= ~TCL_ENCODING_START; if ((result != TCL_OK) && (srcRead + dstWrote == 0)) { /* - * We're reading from invalid/incomplete UTF-8. - */ + * We're reading from invalid/incomplete UTF-8. + */ ReleaseChannelBuffer(bufPtr); if (total == 0) { @@ -5688,8 +5694,8 @@ Tcl_ReadRaw( : bytesToRead; /* - * Copy the current chunk into the read buffer. - */ + * Copy the current chunk into the read buffer. + */ memcpy(readBuf, RemovePoint(bufPtr), toCopy); bufPtr->nextRemoved += toCopy; @@ -5730,8 +5736,8 @@ Tcl_ReadRaw( if (nread > 0) { /* - * Successful read (short is OK) - add to bytes copied. - */ + * Successful read (short is OK) - add to bytes copied. + */ copied += nread; } else if (nread < 0) { @@ -6382,8 +6388,8 @@ ReadChars( ChannelBuffer *nextPtr; /* - * We were not able to read any chars. - */ + * We were not able to read any chars. + */ assert(numChars == 0); @@ -6403,7 +6409,7 @@ ReadChars( } /* - * Otherwise, reading zero characters indicates there's something + * Otherwise, reading zero characters indicates there's something * incomplete at the end of the src buffer. Maybe there were not * enough src bytes to decode into a char. Maybe a lone \r could * not be translated (crlf mode). Need to combine any unused src @@ -6512,17 +6518,17 @@ TranslateInputEOL( case TCL_TRANSLATE_LF: case TCL_TRANSLATE_CR: if (srcLen > dstLen) { - /* - * In these modes, each src byte become a dst byte. - */ + /* + * In these modes, each src byte become a dst byte. + */ srcLen = dstLen; } break; default: /* - * In other modes, at most 2 src bytes become a dst byte. - */ + * In other modes, at most 2 src bytes become a dst byte. + */ if (srcLen/2 > dstLen) { srcLen = 2 * dstLen; @@ -9625,8 +9631,8 @@ CopyData( if (size == 0) { if (!GotFlag(inStatePtr, CHANNEL_NONBLOCKING)) { /* - * We allowed a short read. Keep trying. - */ + * We allowed a short read. Keep trying. + */ continue; } @@ -9909,16 +9915,16 @@ DoRead( if (GotFlag(statePtr, CHANNEL_EOF|CHANNEL_BLOCKED)) { /* - * Further reads cannot do any more. - */ + * Further reads cannot do any more. + */ break; } if (code) { /* - * Read error - */ + * Read error + */ UpdateInterest(chanPtr); TclChannelRelease((Tcl_Channel)chanPtr); @@ -9970,28 +9976,28 @@ DoRead( if (bufPtr->nextPtr == NULL) { /* - * There's no more buffered data... - */ + * There's no more buffered data... + */ if (statePtr->flags & CHANNEL_EOF) { /* - * ...and there never will be. - */ + * ...and there never will be. + */ *p++ = '\r'; bytesToRead--; bufPtr->nextRemoved++; } else if (statePtr->flags & CHANNEL_BLOCKED) { /* - * ...and we cannot get more now. - */ + * ...and we cannot get more now. + */ SetFlag(statePtr, CHANNEL_NEED_MORE_DATA); break; } else { /* - * ...so we need to get some. - */ + * ...so we need to get some. + */ goto moreData; } @@ -9999,8 +10005,8 @@ DoRead( if (bufPtr->nextPtr) { /* - * There's a next buffer. Shift orphan \r to it. - */ + * There's a next buffer. Shift orphan \r to it. + */ ChannelBuffer *nextPtr = bufPtr->nextPtr; |