From bf119934a2bbf23dc728d9ee87c200d6fc76abc0 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 19 Apr 2024 08:12:21 +0000 Subject: (backport) Fix indenting --- generic/tclIO.c | 5 +- generic/tclIORChan.c | 226 +++++++++++++++++++++++++-------------------------- 2 files changed, 115 insertions(+), 116 deletions(-) diff --git a/generic/tclIO.c b/generic/tclIO.c index 0d8d4db..4c60171 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -3194,8 +3194,8 @@ CloseChannel( /* * Cancel any outstanding timer. */ - DeleteTimerHandler(statePtr); + DeleteTimerHandler(statePtr); /* * Mark the channel as deleted by clearing the type structure. @@ -7626,7 +7626,6 @@ Tcl_Eof( return GotFlag(statePtr, CHANNEL_EOF) ? 1 : 0; } - /* *---------------------------------------------------------------------- * @@ -7652,7 +7651,7 @@ TclChannelGetBlockingMode( return GotFlag(statePtr, CHANNEL_NONBLOCKING) ? 0 : 1; } - + /* *---------------------------------------------------------------------- * diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c index 4e938ae..ef731fc 100644 --- a/generic/tclIORChan.c +++ b/generic/tclIORChan.c @@ -86,7 +86,7 @@ static const Tcl_ChannelType tclRChannelType = { NULL, /* Handle events. NULL'able */ ReflectSeekWide, /* Move access point (64 bit). NULL'able */ #if TCL_THREADS - ReflectThread, /* thread action, tracking owner */ + ReflectThread, /* thread action, tracking owner */ #else NULL, /* thread action */ #endif @@ -108,7 +108,7 @@ typedef struct { */ #if TCL_THREADS Tcl_ThreadId thread; /* Thread the 'interp' belongs to. == Handler thread */ - Tcl_ThreadId owner; /* Thread owning the structure. == Channel thread */ + Tcl_ThreadId owner; /* Thread owning the structure. == Channel thread */ #endif Tcl_Obj *cmd; /* Callback command prefix */ Tcl_Obj *methods; /* Methods to append to command prefix */ @@ -125,12 +125,12 @@ typedef struct { A token for the timer that is scheduled in order to call Tcl_NotifyChannel when the channel is readable - */ + */ Tcl_TimerToken writeTimer; /* A token for the timer that is scheduled in order to call Tcl_NotifyChannel when the channel is writable - */ + */ /* * Note regarding the usage of timers. @@ -620,9 +620,9 @@ TclChanCreateObjCmd( */ if (TclListObjGetElements(NULL, resObj, &listc, &listv) != TCL_OK) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "chan handler \"%s initialize\" returned non-list: %s", - TclGetString(cmdObj), TclGetString(resObj))); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "chan handler \"%s initialize\" returned non-list: %s", + TclGetString(cmdObj), TclGetString(resObj))); Tcl_DecrRefCount(resObj); goto error; } @@ -646,37 +646,37 @@ TclChanCreateObjCmd( Tcl_DecrRefCount(resObj); if ((REQUIRED_METHODS & methods) != REQUIRED_METHODS) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "chan handler \"%s\" does not support all required methods", - TclGetString(cmdObj))); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "chan handler \"%s\" does not support all required methods", + TclGetString(cmdObj))); goto error; } if ((mode & TCL_READABLE) && !HAS(methods, METH_READ)) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "chan handler \"%s\" lacks a \"read\" method", - TclGetString(cmdObj))); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "chan handler \"%s\" lacks a \"read\" method", + TclGetString(cmdObj))); goto error; } if ((mode & TCL_WRITABLE) && !HAS(methods, METH_WRITE)) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "chan handler \"%s\" lacks a \"write\" method", - TclGetString(cmdObj))); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "chan handler \"%s\" lacks a \"write\" method", + TclGetString(cmdObj))); goto error; } if (!IMPLIES(HAS(methods, METH_CGET), HAS(methods, METH_CGETALL))) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "chan handler \"%s\" supports \"cget\" but not \"cgetall\"", - TclGetString(cmdObj))); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "chan handler \"%s\" supports \"cget\" but not \"cgetall\"", + TclGetString(cmdObj))); goto error; } if (!IMPLIES(HAS(methods, METH_CGETALL), HAS(methods, METH_CGET))) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "chan handler \"%s\" supports \"cgetall\" but not \"cget\"", - TclGetString(cmdObj))); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "chan handler \"%s\" supports \"cgetall\" but not \"cget\"", + TclGetString(cmdObj))); goto error; } @@ -752,7 +752,7 @@ TclChanCreateObjCmd( */ Tcl_SetObjResult(interp, - Tcl_NewStringObj(chanPtr->state->channelName, -1)); + Tcl_NewStringObj(chanPtr->state->channelName, -1)); return TCL_OK; error: @@ -824,7 +824,7 @@ ReflectEventDelete( ReflectEvent *e = (ReflectEvent *) ev; if ((ev->proc != ReflectEventRun) || ((cd != NULL) && (cd != e->rcPtr))) { - return 0; + return 0; } return 1; } @@ -883,7 +883,7 @@ TclChanPostEventObjCmd( if (hPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can not find reflected channel named \"%s\"", chanId)); + "can not find reflected channel named \"%s\"", chanId)); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "CHANNEL", chanId, (char *)NULL); return TCL_ERROR; } @@ -947,8 +947,8 @@ TclChanPostEventObjCmd( if (events & ~rcPtr->interest) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "tried to post events channel \"%s\" is not interested in", - chanId)); + "tried to post events channel \"%s\" is not interested in", + chanId)); return TCL_ERROR; } @@ -1217,11 +1217,11 @@ ReflectClose( ForwardOpToHandlerThread(rcPtr, ForwardedClose, &p); result = p.base.code; - /* - * Now squash the pending reflection events for this channel. - */ + /* + * Now squash the pending reflection events for this channel. + */ - Tcl_DeleteEvents(ReflectEventDelete, rcPtr); + Tcl_DeleteEvents(ReflectEventDelete, rcPtr); if (result != TCL_OK) { FreeReceivedError(&p); @@ -1255,11 +1255,11 @@ ReflectClose( ForwardOpToHandlerThread(rcPtr, ForwardedClose, &p); result = p.base.code; - /* - * Now squash the pending reflection events for this channel. - */ + /* + * Now squash the pending reflection events for this channel. + */ - Tcl_DeleteEvents(ReflectEventDelete, rcPtr); + Tcl_DeleteEvents(ReflectEventDelete, rcPtr); if (result != TCL_OK) { PassReceivedErrorInterp(interp, &p); @@ -1394,11 +1394,11 @@ ReflectInput( if (code < 0) { *errorCodePtr = -code; - goto error; + goto error; } Tcl_SetChannelError(rcPtr->chan, resObj); - goto invalid; + goto invalid; } bytev = Tcl_GetByteArrayFromObj(resObj, &bytec); @@ -1475,9 +1475,9 @@ ReflectOutput( *errorCodePtr = -p.base.code; } else { - PassReceivedError(rcPtr->chan, &p); - *errorCodePtr = EINVAL; - } + PassReceivedError(rcPtr->chan, &p); + *errorCodePtr = EINVAL; + } p.output.toWrite = -1; } else { *errorCodePtr = EOK; @@ -1501,11 +1501,11 @@ ReflectOutput( if (code < 0) { *errorCodePtr = -code; - goto error; + goto error; } Tcl_SetChannelError(rcPtr->chan, resObj); - goto invalid; + goto invalid; } if (Tcl_InterpDeleted(rcPtr->interp)) { @@ -1514,11 +1514,11 @@ ReflectOutput( */ SetChannelErrorStr(rcPtr->chan, msg_send_dstlost); - goto invalid; + goto invalid; } if (Tcl_GetIntFromObj(rcPtr->interp, resObj, &written) != TCL_OK) { Tcl_SetChannelError(rcPtr->chan, MarshallError(rcPtr->interp)); - goto invalid; + goto invalid; } if ((written == 0) && (toWrite > 0)) { @@ -1528,7 +1528,7 @@ ReflectOutput( */ SetChannelErrorStr(rcPtr->chan, msg_write_nothing); - goto invalid; + goto invalid; } if (toWrite < written) { /* @@ -1538,7 +1538,7 @@ ReflectOutput( */ SetChannelErrorStr(rcPtr->chan, msg_write_toomuch); - goto invalid; + goto invalid; } *errorCodePtr = EOK; @@ -1614,24 +1614,24 @@ ReflectSeekWide( TclNewIntObj(offObj, offset); baseObj = Tcl_NewStringObj( - (seekMode == SEEK_SET) ? "start" : - (seekMode == SEEK_CUR) ? "current" : "end", -1); + (seekMode == SEEK_SET) ? "start" : + (seekMode == SEEK_CUR) ? "current" : "end", -1); Tcl_IncrRefCount(offObj); Tcl_IncrRefCount(baseObj); if (InvokeTclMethod(rcPtr, METH_SEEK, offObj, baseObj, &resObj)!=TCL_OK) { Tcl_SetChannelError(rcPtr->chan, resObj); - goto invalid; + goto invalid; } if (Tcl_GetWideIntFromObj(rcPtr->interp, resObj, &newLoc) != TCL_OK) { Tcl_SetChannelError(rcPtr->chan, MarshallError(rcPtr->interp)); - goto invalid; + goto invalid; } if (newLoc < 0) { SetChannelErrorStr(rcPtr->chan, msg_seek_beforestart); - goto invalid; + goto invalid; } *errorCodePtr = EOK; @@ -1832,14 +1832,14 @@ ReflectThread( switch (action) { case TCL_CHANNEL_THREAD_INSERT: - rcPtr->owner = Tcl_GetCurrentThread(); - break; + rcPtr->owner = Tcl_GetCurrentThread(); + break; case TCL_CHANNEL_THREAD_REMOVE: - rcPtr->owner = NULL; - break; + rcPtr->owner = NULL; + break; default: - Tcl_Panic("Unknown thread action code."); - break; + Tcl_Panic("Unknown thread action code."); + break; } } @@ -1998,14 +1998,14 @@ ReflectGetOption( method = METH_CGET; optionObj = Tcl_NewStringObj(optionName, -1); - Tcl_IncrRefCount(optionObj); + Tcl_IncrRefCount(optionObj); } Tcl_Preserve(rcPtr); if (InvokeTclMethod(rcPtr, method, optionObj, NULL, &resObj)!=TCL_OK) { UnmarshallErrorResult(interp, resObj); - goto error; + goto error; } /* @@ -2015,7 +2015,7 @@ ReflectGetOption( if (optionObj != NULL) { TclDStringAppendObj(dsPtr, resObj); - goto ok; + goto ok; } /* @@ -2030,7 +2030,7 @@ ReflectGetOption( */ if (TclListObjGetElements(interp, resObj, &listc, &listv) != TCL_OK) { - goto error; + goto error; } if ((listc % 2) == 1) { @@ -2043,7 +2043,7 @@ ReflectGetOption( "Expected list with even number of " "elements, got %" TCL_SIZE_MODIFIER "d element%s instead", listc, (listc == 1 ? "" : "s"))); - goto error; + goto error; } else { Tcl_Size len; const char *str = TclGetStringFromObj(resObj, &len); @@ -2052,14 +2052,14 @@ ReflectGetOption( TclDStringAppendLiteral(dsPtr, " "); Tcl_DStringAppend(dsPtr, str, len); } - goto ok; + goto ok; } ok: result = TCL_OK; stop: if (optionObj) { - Tcl_DecrRefCount(optionObj); + Tcl_DecrRefCount(optionObj); } Tcl_DecrRefCount(resObj); /* Remove reference held from invoke */ Tcl_Release(rcPtr); @@ -2413,10 +2413,10 @@ InvokeTclMethod( Tcl_IncrRefCount(resObj); } - /* - * Not touching argOneObj, argTwoObj, they have not been used. - * See the contract as well. - */ + /* + * Not touching argOneObj, argTwoObj, they have not been used. + * See the contract as well. + */ return TCL_ERROR; } @@ -2712,11 +2712,11 @@ DeleteReflectedChannelMap( /* * The receiver for the event exited, before processing the event. We * detach the result now, wake the originator up and signal failure. - * - * Attention: Results may have been detached already, by either the - * receiver, or this thread, as part of other parts in the thread - * teardown. Such results are ignored. See ticket [b47b176adf] for the - * identical race condition in Tcl 8.6 IORTrans. + * + * Attention: Results may have been detached already, by either the + * receiver, or this thread, as part of other parts in the thread + * teardown. Such results are ignored. See ticket [b47b176adf] for the + * identical race condition in Tcl 8.6 IORTrans. */ evPtr = resultPtr->evPtr; @@ -2865,11 +2865,11 @@ DeleteThreadReflectedChannelMap( /* * The receiver for the event exited, before processing the event. We * detach the result now, wake the originator up and signal failure. - * - * Attention: Results may have been detached already, by either the - * receiver, or this thread, as part of other parts in the thread - * teardown. Such results are ignored. See ticket [b47b176adf] for the - * identical race condition in Tcl 8.6 IORTrans. + * + * Attention: Results may have been detached already, by either the + * receiver, or this thread, as part of other parts in the thread + * teardown. Such results are ignored. See ticket [b47b176adf] for the + * identical race condition in Tcl 8.6 IORTrans. */ evPtr = resultPtr->evPtr; @@ -3078,7 +3078,7 @@ ForwardProc( ForwardParam *paramPtr = evPtr->param; Tcl_Obj *resObj = NULL; /* Interp result of InvokeTclMethod */ ReflectedChannelMap *rcmPtr;/* Map of reflected channels with handlers in - * this interp. */ + * this interp. */ Tcl_HashEntry *hPtr; /* Entry in the above map */ /* @@ -3121,12 +3121,12 @@ ForwardProc( rcmPtr = GetReflectedChannelMap(interp); hPtr = Tcl_FindHashEntry(&rcmPtr->map, - Tcl_GetChannelName(rcPtr->chan)); + Tcl_GetChannelName(rcPtr->chan)); Tcl_DeleteHashEntry(hPtr); rcmPtr = GetThreadReflectedChannelMap(); hPtr = Tcl_FindHashEntry(&rcmPtr->map, - Tcl_GetChannelName(rcPtr->chan)); + Tcl_GetChannelName(rcPtr->chan)); Tcl_DeleteHashEntry(hPtr); MarkDead(rcPtr); break; @@ -3168,17 +3168,17 @@ ForwardProc( paramPtr->input.toRead = bytec; } } - Tcl_Release(rcPtr); - Tcl_DecrRefCount(toReadObj); + Tcl_Release(rcPtr); + Tcl_DecrRefCount(toReadObj); break; } case ForwardedOutput: { Tcl_Obj *bufObj = Tcl_NewByteArrayObj((unsigned char *) - paramPtr->output.buf, paramPtr->output.toWrite); - Tcl_IncrRefCount(bufObj); + paramPtr->output.buf, paramPtr->output.toWrite); + Tcl_IncrRefCount(bufObj); - Tcl_Preserve(rcPtr); + Tcl_Preserve(rcPtr); if (InvokeTclMethod(rcPtr, METH_WRITE, bufObj, NULL, &resObj) != TCL_OK) { int code = ErrnoReturn(rcPtr, resObj); @@ -3207,8 +3207,8 @@ ForwardProc( paramPtr->output.toWrite = written; } } - Tcl_Release(rcPtr); - Tcl_DecrRefCount(bufObj); + Tcl_Release(rcPtr); + Tcl_DecrRefCount(bufObj); break; } @@ -3250,35 +3250,35 @@ ForwardProc( paramPtr->seek.offset = -1; } } - Tcl_Release(rcPtr); - Tcl_DecrRefCount(offObj); - Tcl_DecrRefCount(baseObj); + Tcl_Release(rcPtr); + Tcl_DecrRefCount(offObj); + Tcl_DecrRefCount(baseObj); break; } case ForwardedWatch: { Tcl_Obj *maskObj = DecodeEventMask(paramPtr->watch.mask); - /* assert maskObj.refCount == 1 */ + /* assert maskObj.refCount == 1 */ - Tcl_Preserve(rcPtr); + Tcl_Preserve(rcPtr); rcPtr->interest = paramPtr->watch.mask; (void) InvokeTclMethod(rcPtr, METH_WATCH, maskObj, NULL, NULL); Tcl_DecrRefCount(maskObj); - Tcl_Release(rcPtr); + Tcl_Release(rcPtr); break; } case ForwardedBlock: { Tcl_Obj *blockObj = Tcl_NewBooleanObj(!paramPtr->block.nonblocking); - Tcl_IncrRefCount(blockObj); - Tcl_Preserve(rcPtr); + Tcl_IncrRefCount(blockObj); + Tcl_Preserve(rcPtr); if (InvokeTclMethod(rcPtr, METH_BLOCKING, blockObj, NULL, - &resObj) != TCL_OK) { + &resObj) != TCL_OK) { ForwardSetObjError(paramPtr, resObj); } - Tcl_Release(rcPtr); - Tcl_DecrRefCount(blockObj); + Tcl_Release(rcPtr); + Tcl_DecrRefCount(blockObj); break; } @@ -3286,16 +3286,16 @@ ForwardProc( Tcl_Obj *optionObj = Tcl_NewStringObj(paramPtr->setOpt.name, -1); Tcl_Obj *valueObj = Tcl_NewStringObj(paramPtr->setOpt.value, -1); - Tcl_IncrRefCount(optionObj); - Tcl_IncrRefCount(valueObj); - Tcl_Preserve(rcPtr); + Tcl_IncrRefCount(optionObj); + Tcl_IncrRefCount(valueObj); + Tcl_Preserve(rcPtr); if (InvokeTclMethod(rcPtr, METH_CONFIGURE, optionObj, valueObj, - &resObj) != TCL_OK) { + &resObj) != TCL_OK) { ForwardSetObjError(paramPtr, resObj); } - Tcl_Release(rcPtr); - Tcl_DecrRefCount(optionObj); - Tcl_DecrRefCount(valueObj); + Tcl_Release(rcPtr); + Tcl_DecrRefCount(optionObj); + Tcl_DecrRefCount(valueObj); break; } @@ -3306,15 +3306,15 @@ ForwardProc( Tcl_Obj *optionObj = Tcl_NewStringObj(paramPtr->getOpt.name, -1); - Tcl_IncrRefCount(optionObj); - Tcl_Preserve(rcPtr); + Tcl_IncrRefCount(optionObj); + Tcl_Preserve(rcPtr); if (InvokeTclMethod(rcPtr, METH_CGET, optionObj, NULL, &resObj)!=TCL_OK){ ForwardSetObjError(paramPtr, resObj); } else { TclDStringAppendObj(paramPtr->getOpt.value, resObj); } - Tcl_Release(rcPtr); - Tcl_DecrRefCount(optionObj); + Tcl_Release(rcPtr); + Tcl_DecrRefCount(optionObj); break; } @@ -3323,7 +3323,7 @@ ForwardProc( * Retrieve all options. */ - Tcl_Preserve(rcPtr); + Tcl_Preserve(rcPtr); if (InvokeTclMethod(rcPtr, METH_CGETALL, NULL, NULL, &resObj) != TCL_OK){ ForwardSetObjError(paramPtr, resObj); } else { @@ -3336,7 +3336,7 @@ ForwardProc( Tcl_Obj **listv; if (TclListObjGetElements(interp, resObj, &listc, - &listv) != TCL_OK) { + &listv) != TCL_OK) { Tcl_DecrRefCount(resObj); resObj = MarshallError(interp); ForwardSetObjError(paramPtr, resObj); @@ -3361,7 +3361,7 @@ ForwardProc( } } } - Tcl_Release(rcPtr); + Tcl_Release(rcPtr); break; case ForwardedTruncate: { -- cgit v0.12 From 072c5b11392289eeeb1813fa9deecd946db1e916 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 19 Apr 2024 08:15:29 +0000 Subject: More indenting --- generic/tclIO.c | 170 +++++++++++++++++++++++++-------------------------- generic/tclIORChan.c | 60 +++++++++--------- 2 files changed, 115 insertions(+), 115 deletions(-) diff --git a/generic/tclIO.c b/generic/tclIO.c index 4c60171..7ed6993 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -105,7 +105,7 @@ typedef struct CopyState { Tcl_Obj *cmdPtr; /* Command to be invoked at completion. */ Tcl_Size bufSize; /* Size of appended buffer. */ char buffer[TCLFLEXARRAY]; /* Copy buffer, this must be the last - * field. */ + * field. */ } CopyState; /* @@ -228,7 +228,7 @@ static Tcl_Size Write(Channel *chanPtr, const char *src, static Tcl_Obj * FixLevelCode(Tcl_Obj *msg); static void SpliceChannel(Tcl_Channel chan); static void CutChannel(Tcl_Channel chan); -static int WillRead(Channel *chanPtr); +static int WillRead(Channel *chanPtr); #define WriteChars(chanPtr, src, srcLen) \ Write(chanPtr, src, srcLen, chanPtr->state->encoding) @@ -430,12 +430,12 @@ ChanRead( */ if (GotFlag(chanPtr->state, CHANNEL_EOF)) { - chanPtr->state->inputEncodingFlags |= TCL_ENCODING_START; + chanPtr->state->inputEncodingFlags |= TCL_ENCODING_START; } ResetFlag(chanPtr->state, CHANNEL_BLOCKED | CHANNEL_EOF); chanPtr->state->inputEncodingFlags &= ~TCL_ENCODING_END; if (WillRead(chanPtr) < 0) { - return -1; + return -1; } bytesRead = chanPtr->typePtr->inputProc(chanPtr->instanceData, @@ -446,7 +446,7 @@ ChanRead( */ if (GotFlag(chanPtr->state, CHANNEL_EOF)) { - chanPtr->state->inputEncodingFlags |= TCL_ENCODING_START; + chanPtr->state->inputEncodingFlags |= TCL_ENCODING_START; } ResetFlag(chanPtr->state, CHANNEL_BLOCKED | CHANNEL_EOF); chanPtr->state->inputEncodingFlags &= ~TCL_ENCODING_END; @@ -597,14 +597,14 @@ TclFinalizeIOSubsystem(void) */ { - const char *s; - Tcl_DString ds; + const char *s; + Tcl_DString ds; - s = TclGetEnv("TCL_FLUSH_NONBLOCKING_ON_EXIT", &ds); - doflushnb = ((s != NULL) && strcmp(s, "0")); - if (s != NULL) { - Tcl_DStringFree(&ds); - } + s = TclGetEnv("TCL_FLUSH_NONBLOCKING_ON_EXIT", &ds); + doflushnb = ((s != NULL) && strcmp(s, "0")); + if (s != NULL) { + Tcl_DStringFree(&ds); + } } /* @@ -624,12 +624,12 @@ TclFinalizeIOSubsystem(void) statePtr != NULL; statePtr = statePtr->nextCSPtr) { chanPtr = statePtr->topChanPtr; - if (GotFlag(statePtr, CHANNEL_DEAD)) { - continue; - } + if (GotFlag(statePtr, CHANNEL_DEAD)) { + continue; + } if (!GotFlag(statePtr, CHANNEL_INCLOSE | CHANNEL_CLOSED ) || GotFlag(statePtr, BG_FLUSH_SCHEDULED)) { - ResetFlag(statePtr, BG_FLUSH_SCHEDULED); + ResetFlag(statePtr, BG_FLUSH_SCHEDULED); active = 1; break; } @@ -644,20 +644,20 @@ TclFinalizeIOSubsystem(void) /* * TIP #398: by default, we no longer set the channel back into - * blocking mode. To restore the old blocking behavior, the - * environment variable TCL_FLUSH_NONBLOCKING_ON_EXIT must be set - * and not be "0". + * blocking mode. To restore the old blocking behavior, the + * environment variable TCL_FLUSH_NONBLOCKING_ON_EXIT must be set + * and not be "0". */ - if (doflushnb) { - /* - * Set the channel back into blocking mode to ensure that we - * wait for all data to flush out. - */ + if (doflushnb) { + /* + * Set the channel back into blocking mode to ensure that we + * wait for all data to flush out. + */ - (void) Tcl_SetChannelOption(NULL, (Tcl_Channel) chanPtr, - "-blocking", "on"); - } + (void) Tcl_SetChannelOption(NULL, (Tcl_Channel) chanPtr, + "-blocking", "on"); + } if ((chanPtr == (Channel *) tsdPtr->stdinChannel) || (chanPtr == (Channel *) tsdPtr->stdoutChannel) || @@ -1240,8 +1240,8 @@ Tcl_UnregisterChannel( if (GotFlag(statePtr, CHANNEL_INCLOSE)) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( - "illegal recursive call to close through close-handler" - " of channel", -1)); + "illegal recursive call to close through close-handler" + " of channel", -1)); } return TCL_ERROR; } @@ -1468,7 +1468,7 @@ Tcl_GetChannel( hPtr = Tcl_FindHashEntry(hTblPtr, name); if (hPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can not find channel named \"%s\"", chanName)); + "can not find channel named \"%s\"", chanName)); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "CHANNEL", chanName, (char *)NULL); return NULL; } @@ -1671,9 +1671,9 @@ Tcl_CreateChannel( unsigned len = strlen(chanName) + 1; /* - * Make sure we allocate at least 7 bytes, so it fits for "stdout" - * later. - */ + * Make sure we allocate at least 7 bytes, so it fits for "stdout" + * later. + */ tmp = (char *)ckalloc((len < 7) ? 7 : len); strcpy(tmp, chanName); @@ -1865,7 +1865,7 @@ Tcl_StackChannel( if (statePtr == NULL) { if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "couldn't find state for channel \"%s\"", + "couldn't find state for channel \"%s\"", Tcl_GetChannelName(prevChan))); } return NULL; @@ -1916,7 +1916,7 @@ Tcl_StackChannel( statePtr->csPtrW = csPtrW; if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "could not flush channel \"%s\"", + "could not flush channel \"%s\"", Tcl_GetChannelName(prevChan))); } return NULL; @@ -2111,7 +2111,7 @@ Tcl_UnstackChannel( if (!TclChanCaughtErrorBypass(interp, chan) && interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "could not flush channel \"%s\"", + "could not flush channel \"%s\"", Tcl_GetChannelName((Tcl_Channel) chanPtr))); } return TCL_ERROR; @@ -2444,9 +2444,9 @@ Tcl_GetChannelHandle( chanPtr = ((Channel *) chan)->state->bottomChanPtr; if (!chanPtr->typePtr->getHandleProc) { - Tcl_SetChannelError(chan, Tcl_ObjPrintf( - "channel \"%s\" does not support OS handles", - Tcl_GetChannelName(chan))); + Tcl_SetChannelError(chan, Tcl_ObjPrintf( + "channel \"%s\" does not support OS handles", + Tcl_GetChannelName(chan))); return TCL_ERROR; } result = chanPtr->typePtr->getHandleProc(chanPtr->instanceData, direction, @@ -2476,7 +2476,7 @@ Tcl_GetChannelHandle( int Tcl_RemoveChannelMode( - Tcl_Interp *interp, /* The interp for an error message. Allowed to be NULL. */ + Tcl_Interp *interp, /* The interp for an error message. Allowed to be NULL. */ Tcl_Channel chan, /* The channel which is modified. */ int mode) /* The access mode to drop from the channel */ { @@ -2485,11 +2485,11 @@ Tcl_RemoveChannelMode( /* State of actual channel. */ if ((mode != TCL_READABLE) && (mode != TCL_WRITABLE)) { - emsg = "Illegal mode value."; + emsg = "Illegal mode value."; goto error; } if (0 == (GotFlag(statePtr, TCL_READABLE|TCL_WRITABLE) & ~mode)) { - emsg = "Bad mode, would make channel inacessible"; + emsg = "Bad mode, would make channel inacessible"; goto error; } @@ -2727,7 +2727,7 @@ CheckForDeadChannel( Tcl_SetErrno(EINVAL); if (interp) { Tcl_SetObjResult(interp, Tcl_NewStringObj( - "unable to access channel: invalid channel", -1)); + "unable to access channel: invalid channel", -1)); } return 1; } @@ -3038,7 +3038,7 @@ FlushChannel( ((statePtr->curOutPtr == NULL) || IsBufferEmpty(statePtr->curOutPtr))) { errorCode = CloseChannelPart(interp, chanPtr, errorCode, - TCL_CLOSE_WRITE); + TCL_CLOSE_WRITE); goto done; } @@ -3499,8 +3499,8 @@ Tcl_Close( if (GotFlag(statePtr, CHANNEL_INCLOSE)) { if (interp) { Tcl_SetObjResult(interp, Tcl_NewStringObj( - "illegal recursive call to close through close-handler" - " of channel", -1)); + "illegal recursive call to close through close-handler" + " of channel", -1)); } return TCL_ERROR; } @@ -3722,8 +3722,8 @@ Tcl_CloseEx( msg = "write"; } Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "Half-close of %s-side not possible, side not opened or" - " already closed", msg)); + "Half-close of %s-side not possible, side not opened or" + " already closed", msg)); return TCL_ERROR; } @@ -3735,8 +3735,8 @@ Tcl_CloseEx( if (GotFlag(statePtr, CHANNEL_INCLOSE)) { if (interp) { Tcl_SetObjResult(interp, Tcl_NewStringObj( - "illegal recursive call to close through close-handler" - " of channel", -1)); + "illegal recursive call to close through close-handler" + " of channel", -1)); } return TCL_ERROR; } @@ -3797,8 +3797,8 @@ static int CloseWrite( Tcl_Interp *interp, /* Interpreter for errors. */ Channel *chanPtr) /* The channel whose write side is being - * closed. May still be used by some - * interpreter */ + * closed. May still be used by some + * interpreter */ { /* * Notes: clear-channel-handlers - write side only ? or keep around, just @@ -3808,7 +3808,7 @@ CloseWrite( */ ChannelState *statePtr = chanPtr->state; - /* State of real IO channel. */ + /* State of real IO channel. */ int flushcode; int result = 0; @@ -4387,7 +4387,7 @@ static Tcl_Size Write( Channel *chanPtr, /* The channel to buffer output for. */ const char *src, /* UTF-8 string to write. */ - Tcl_Size srcLen, /* Length of UTF-8 string in bytes. */ + Tcl_Size srcLen, /* Length of UTF-8 string in bytes. */ Tcl_Encoding encoding) { ChannelState *statePtr = chanPtr->state; @@ -4399,7 +4399,7 @@ Write( int encodingError = 0; if (srcLen) { - WillWrite(chanPtr); + WillWrite(chanPtr); } /* @@ -5181,7 +5181,7 @@ TclGetsObjBinary( * coming back here. When we are not dealing with * CHANNEL_STICKY_EOF, a CHANNEL_EOF implies an empty buffer. * Here the buffer is non-empty so we know we're a non-EOF. - */ + */ assert(!GotFlag(statePtr, CHANNEL_STICKY_EOF)); assert(!GotFlag(statePtr, CHANNEL_EOF)); @@ -5478,7 +5478,7 @@ FilterInputBytes( * coming back here. When we are not dealing with CHANNEL_STICKY_EOF, * a CHANNEL_EOF implies an empty buffer. Here the buffer is * non-empty so we know we're a non-EOF. - */ + */ assert(!GotFlag(statePtr, CHANNEL_STICKY_EOF)); assert(!GotFlag(statePtr, CHANNEL_EOF)); @@ -5840,8 +5840,8 @@ Tcl_ReadRaw( bytesToRead -= toCopy; /* - * If the current buffer is empty recycle it. - */ + * If the current buffer is empty recycle it. + */ if (IsBufferEmpty(bufPtr)) { chanPtr->inQueueHead = bufPtr->nextPtr; @@ -6177,7 +6177,7 @@ finish: || GotFlag(statePtr, CHANNEL_ENCODING_ERROR) || Tcl_InputBuffered((Tcl_Channel)chanPtr) == 0); assert(!(GotFlag(statePtr, CHANNEL_EOF|CHANNEL_BLOCKED) - == (CHANNEL_EOF|CHANNEL_BLOCKED))); + == (CHANNEL_EOF|CHANNEL_BLOCKED))); UpdateInterest(chanPtr); /* This must comes after UpdateInterest(), which may set errno */ @@ -7128,7 +7128,7 @@ GetInput( * Check the actual buffersize against the requested buffersize. * Saved buffers of the wrong size are squashed. This is done to honor * dynamic changes of the buffersize made by the user. - * + * * TODO: Tests to cover this. */ @@ -7493,7 +7493,7 @@ Tcl_TruncateChannel( WillWrite(chanPtr); if (WillRead(chanPtr) < 0) { - return TCL_ERROR; + return TCL_ERROR; } /* @@ -7927,7 +7927,7 @@ Tcl_BadChannelOption( const char **argv; Tcl_Size argc, i; Tcl_DString ds; - Tcl_Obj *errObj; + Tcl_Obj *errObj; Tcl_DStringInit(&ds); Tcl_DStringAppend(&ds, genericopt, -1); @@ -7941,13 +7941,13 @@ Tcl_BadChannelOption( } Tcl_ResetResult(interp); errObj = Tcl_ObjPrintf("bad option \"%s\": should be one of ", - optionName ? optionName : ""); + optionName ? optionName : ""); argc--; for (i = 0; i < argc; i++) { Tcl_AppendPrintfToObj(errObj, "-%s, ", argv[i]); } Tcl_AppendPrintfToObj(errObj, "or -%s", argv[i]); - Tcl_SetObjResult(interp, errObj); + Tcl_SetObjResult(interp, errObj); Tcl_DStringFree(&ds); ckfree(argv); } @@ -8245,8 +8245,8 @@ Tcl_SetChannelOption( if (statePtr->csPtrR || statePtr->csPtrW) { if (interp) { Tcl_SetObjResult(interp, Tcl_NewStringObj( - "unable to set channel options: background copy in" - " progress", -1)); + "unable to set channel options: background copy in" + " progress", -1)); } return TCL_ERROR; } @@ -8295,10 +8295,10 @@ Tcl_SetChannelOption( ResetFlag(statePtr, CHANNEL_LINEBUFFERED); SetFlag(statePtr, CHANNEL_UNBUFFERED); } else if (interp) { - Tcl_SetObjResult(interp, Tcl_NewStringObj( - "bad value for -buffering: must be one of" - " full, line, or none", -1)); - return TCL_ERROR; + Tcl_SetObjResult(interp, Tcl_NewStringObj( + "bad value for -buffering: must be one of" + " full, line, or none", -1)); + return TCL_ERROR; } return TCL_OK; } else if (HaveOpt(7, "-buffersize")) { @@ -8363,8 +8363,8 @@ Tcl_SetChannelOption( if (inValue & 0x80 || outValue & 0x80) { if (interp) { Tcl_SetObjResult(interp, Tcl_NewStringObj( - "bad value for -eofchar: must be non-NUL ASCII" - " character", TCL_INDEX_NONE)); + "bad value for -eofchar: must be non-NUL ASCII" + " character", TCL_INDEX_NONE)); } ckfree(argv); return TCL_ERROR; @@ -8456,7 +8456,7 @@ Tcl_SetChannelOption( if (interp) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "bad value for -translation: must be one of " - "auto, binary, cr, lf, crlf, or platform", -1)); + "auto, binary, cr, lf, crlf, or platform", -1)); } ckfree(argv); return TCL_ERROR; @@ -8506,7 +8506,7 @@ Tcl_SetChannelOption( if (interp) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "bad value for -translation: must be one of " - "auto, binary, cr, lf, crlf, or platform", -1)); + "auto, binary, cr, lf, crlf, or platform", -1)); } ckfree(argv); return TCL_ERROR; @@ -9456,7 +9456,7 @@ TclCopyChannelOld( Tcl_Obj *cmdPtr) /* Pointer to script to execute or NULL. */ { return TclCopyChannel(interp, inChan, outChan, (Tcl_WideInt) toRead, - cmdPtr); + cmdPtr); } #endif @@ -9482,14 +9482,14 @@ TclCopyChannel( if (BUSY_STATE(inStatePtr, TCL_READABLE)) { if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "channel \"%s\" is busy", Tcl_GetChannelName(inChan))); + "channel \"%s\" is busy", Tcl_GetChannelName(inChan))); } return TCL_ERROR; } if (BUSY_STATE(outStatePtr, TCL_WRITABLE)) { if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "channel \"%s\" is busy", Tcl_GetChannelName(outChan))); + "channel \"%s\" is busy", Tcl_GetChannelName(outChan))); } return TCL_ERROR; } @@ -9571,8 +9571,8 @@ TclCopyChannel( */ if ((nonBlocking == CHANNEL_NONBLOCKING) && (toRead == 0)) { - Tcl_CreateTimerHandler(0, ZeroTransferTimerProc, csPtr); - return 0; + Tcl_CreateTimerHandler(0, ZeroTransferTimerProc, csPtr); + return 0; } /* @@ -9914,7 +9914,7 @@ CopyData( */ if ((csPtr->toRead == (Tcl_WideInt) -1) - || (csPtr->toRead > (Tcl_WideInt) csPtr->bufSize)) { + || (csPtr->toRead > (Tcl_WideInt) csPtr->bufSize)) { sizeb = csPtr->bufSize; } else { sizeb = (int) csPtr->toRead; @@ -9922,7 +9922,7 @@ CopyData( if (inBinary || sameEncoding) { size = DoRead(inStatePtr->topChanPtr, csPtr->buffer, sizeb, - !GotFlag(inStatePtr, CHANNEL_NONBLOCKING)); + !GotFlag(inStatePtr, CHANNEL_NONBLOCKING)); } else { size = DoReadChars(inStatePtr->topChanPtr, bufObj, sizeb, !GotFlag(inStatePtr, CHANNEL_NONBLOCKING) @@ -10605,7 +10605,7 @@ SetBlockMode( if (!TclChanCaughtErrorBypass(interp, (Tcl_Channel) chanPtr)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "error setting blocking mode: %s", + "error setting blocking mode: %s", Tcl_PosixError(interp))); } } else { @@ -11320,7 +11320,7 @@ Tcl_SetChannelErrorInterp( } if (disposePtr != NULL) { - TclDecrRefCount(disposePtr); + TclDecrRefCount(disposePtr); } return; } @@ -11358,7 +11358,7 @@ Tcl_SetChannelError( } if (disposePtr != NULL) { - TclDecrRefCount(disposePtr); + TclDecrRefCount(disposePtr); } return; } diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c index ef731fc..383d74a 100644 --- a/generic/tclIORChan.c +++ b/generic/tclIORChan.c @@ -973,36 +973,36 @@ TclChanPostEventObjCmd( } #if TCL_THREADS } else { - ReflectEvent *ev = (ReflectEvent *)ckalloc(sizeof(ReflectEvent)); - - ev->header.proc = ReflectEventRun; - ev->events = events; - ev->rcPtr = rcPtr; - - /* - * We are not preserving the structure here. When the channel is - * closed any pending events are deleted, see ReflectClose(), and - * ReflectEventDelete(). Trying to preserve and later release when the - * event is run may generate a situation where the channel structure - * is deleted but not our structure, crashing in - * FreeReflectedChannel(). - * - * Force creation of the RCM, for proper cleanup on thread teardown. - * The teardown of unprocessed events is currently coupled to the - * thread reflected channel map - */ - - (void) GetThreadReflectedChannelMap(); - - /* - * XXX Race condition !! - * XXX The destination thread may not exist anymore already. - * XXX (Delayed postevent executed after channel got removed). - * XXX Can we detect this ? (check the validity of the owner threadid ?) - * XXX Actually, in that case the channel should be dead also ! - */ - - Tcl_ThreadQueueEvent(rcPtr->owner, (Tcl_Event *) ev, + ReflectEvent *ev = (ReflectEvent *)ckalloc(sizeof(ReflectEvent)); + + ev->header.proc = ReflectEventRun; + ev->events = events; + ev->rcPtr = rcPtr; + + /* + * We are not preserving the structure here. When the channel is + * closed any pending events are deleted, see ReflectClose(), and + * ReflectEventDelete(). Trying to preserve and later release when the + * event is run may generate a situation where the channel structure + * is deleted but not our structure, crashing in + * FreeReflectedChannel(). + * + * Force creation of the RCM, for proper cleanup on thread teardown. + * The teardown of unprocessed events is currently coupled to the + * thread reflected channel map + */ + + (void) GetThreadReflectedChannelMap(); + + /* + * XXX Race condition !! + * XXX The destination thread may not exist anymore already. + * XXX (Delayed postevent executed after channel got removed). + * XXX Can we detect this ? (check the validity of the owner threadid ?) + * XXX Actually, in that case the channel should be dead also ! + */ + + Tcl_ThreadQueueEvent(rcPtr->owner, (Tcl_Event *) ev, TCL_QUEUE_TAIL|TCL_QUEUE_ALERT_IF_EMPTY); } #endif -- cgit v0.12