summaryrefslogtreecommitdiffstats
path: root/generic/tclIO.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2024-04-19 08:22:33 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2024-04-19 08:22:33 (GMT)
commitc0685465eeeaf12a1b44612577716d5ea346c2f2 (patch)
tree209371d207926e6b805d9d0c841e8b4acdd7d3f3 /generic/tclIO.c
parent161bda563f77454a183679508e6cbdb47d186862 (diff)
parent683beb38ad31acd9627c1718921c8cee387d77a6 (diff)
downloadtcl-c0685465eeeaf12a1b44612577716d5ea346c2f2.zip
tcl-c0685465eeeaf12a1b44612577716d5ea346c2f2.tar.gz
tcl-c0685465eeeaf12a1b44612577716d5ea346c2f2.tar.bz2
Merge 8.7 (more indenting)
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r--generic/tclIO.c164
1 files changed, 82 insertions, 82 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 44d4f7d..4e053e1 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;
/*
@@ -230,7 +230,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)
@@ -431,12 +431,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) == -1) {
- return -1;
+ return -1;
}
bytesRead = chanPtr->typePtr->inputProc(chanPtr->instanceData,
@@ -447,7 +447,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;
@@ -588,14 +588,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);
+ }
}
/*
@@ -615,12 +615,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;
}
@@ -635,20 +635,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) ||
@@ -1238,8 +1238,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;
}
@@ -1466,7 +1466,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;
}
@@ -1649,9 +1649,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 *)Tcl_Alloc((len < 7) ? 7 : len);
strcpy(tmp, chanName);
@@ -1835,7 +1835,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;
@@ -1886,7 +1886,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;
@@ -2081,7 +2081,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;
@@ -2414,9 +2414,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,
@@ -2446,7 +2446,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 */
{
@@ -2455,11 +2455,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;
}
@@ -2697,7 +2697,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;
}
@@ -3008,7 +3008,7 @@ FlushChannel(
((statePtr->curOutPtr == NULL) ||
IsBufferEmpty(statePtr->curOutPtr))) {
errorCode = CloseChannelPart(interp, chanPtr, errorCode,
- TCL_CLOSE_WRITE);
+ TCL_CLOSE_WRITE);
goto done;
}
@@ -3457,8 +3457,8 @@ TclClose(
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;
}
@@ -3671,8 +3671,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;
}
@@ -3684,8 +3684,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;
}
@@ -3746,8 +3746,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
@@ -3757,7 +3757,7 @@ CloseWrite(
*/
ChannelState *statePtr = chanPtr->state;
- /* State of real IO channel. */
+ /* State of real IO channel. */
int flushcode;
int result = 0;
@@ -4331,7 +4331,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;
@@ -4343,7 +4343,7 @@ Write(
int encodingError = 0;
if (srcLen) {
- WillWrite(chanPtr);
+ WillWrite(chanPtr);
}
/*
@@ -5116,7 +5116,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));
@@ -5411,7 +5411,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));
@@ -5773,8 +5773,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;
@@ -6102,7 +6102,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 */
@@ -7054,7 +7054,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.
*/
@@ -7411,7 +7411,7 @@ Tcl_TruncateChannel(
WillWrite(chanPtr);
if (WillRead(chanPtr) == -1) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
/*
@@ -7845,7 +7845,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);
@@ -7859,13 +7859,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);
Tcl_Free((void *)argv);
}
@@ -8128,8 +8128,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;
}
@@ -8178,10 +8178,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")) {
@@ -8328,7 +8328,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));
}
Tcl_Free((void *)argv);
return TCL_ERROR;
@@ -8377,7 +8377,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));
}
Tcl_Free((void *)argv);
return TCL_ERROR;
@@ -9339,14 +9339,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;
}
@@ -9417,8 +9417,8 @@ TclCopyChannel(
*/
if ((nonBlocking == CHANNEL_NONBLOCKING) && (toRead == 0)) {
- Tcl_CreateTimerHandler(0, ZeroTransferTimerProc, csPtr);
- return 0;
+ Tcl_CreateTimerHandler(0, ZeroTransferTimerProc, csPtr);
+ return 0;
}
/*
@@ -9755,7 +9755,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 = csPtr->toRead;
@@ -9763,7 +9763,7 @@ CopyData(
if (moveBytes) {
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)
@@ -10479,7 +10479,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 {
@@ -11104,7 +11104,7 @@ Tcl_SetChannelErrorInterp(
}
if (disposePtr != NULL) {
- TclDecrRefCount(disposePtr);
+ TclDecrRefCount(disposePtr);
}
return;
}
@@ -11142,7 +11142,7 @@ Tcl_SetChannelError(
}
if (disposePtr != NULL) {
- TclDecrRefCount(disposePtr);
+ TclDecrRefCount(disposePtr);
}
return;
}