diff options
| -rw-r--r-- | generic/tclIO.c | 88 | ||||
| -rw-r--r-- | generic/tclIORChan.c | 18 |
2 files changed, 56 insertions, 50 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; diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c index fd338e4..42d1e8a 100644 --- a/generic/tclIORChan.c +++ b/generic/tclIORChan.c @@ -87,7 +87,7 @@ static const Tcl_ChannelType tclRChannelType = { #if TCL_THREADS ReflectThread, /* thread action, tracking owner */ #else - (void *)-1, /* thread action */ + NULL, /* thread action */ #endif NULL /* truncate */ }; @@ -1347,8 +1347,8 @@ ReflectInput( if (p.base.code != TCL_OK) { if (p.base.code < 0) { /* - * No error message, this is an errno signal. - */ + * No error message, this is an errno signal. + */ *errorCodePtr = -p.base.code; } else { @@ -1453,8 +1453,8 @@ ReflectOutput( if (p.base.code != TCL_OK) { if (p.base.code < 0) { /* - * No error message, this is an errno signal. - */ + * No error message, this is an errno signal. + */ *errorCodePtr = -p.base.code; } else { @@ -2645,8 +2645,8 @@ DeleteReflectedChannelMap( evPtr = resultPtr->evPtr; /* - * Basic crash safety until this routine can get revised [3411310] - */ + * Basic crash safety until this routine can get revised [3411310] + */ if (evPtr == NULL) { continue; @@ -2796,8 +2796,8 @@ DeleteThreadReflectedChannelMap( evPtr = resultPtr->evPtr; /* - * Basic crash safety until this routine can get revised [3411310] - */ + * Basic crash safety until this routine can get revised [3411310] + */ if (evPtr == NULL ) { continue; |
