From 4a25523bd51f705a6a6aad227de13267caef05dc Mon Sep 17 00:00:00 2001 From: dkf Date: Sat, 1 Jun 2024 16:13:39 +0000 Subject: Some tidying up, mostly of indentation --- generic/tclParse.c | 4 ++-- generic/tclParse.h | 25 ++++++++++++++----------- generic/tclPathObj.c | 28 ++++++++++++++-------------- generic/tclPipe.c | 2 +- generic/tclPkgConfig.c | 2 +- generic/tclPreserve.c | 13 +++++++------ generic/tclProc.c | 2 +- generic/tclRegexp.c | 10 +++++----- generic/tclResult.c | 4 ++-- generic/tclScan.c | 17 +++++++++-------- generic/tclStrToD.c | 15 ++++++++------- generic/tclStringObj.c | 42 ++++++++++++++++++++---------------------- 12 files changed, 84 insertions(+), 80 deletions(-) diff --git a/generic/tclParse.c b/generic/tclParse.c index e88de0b..dca351c 100644 --- a/generic/tclParse.c +++ b/generic/tclParse.c @@ -1039,7 +1039,7 @@ ParseComment( static int ParseTokens( - const char *src, /* First character to parse. */ + const char *src, /* First character to parse. */ Tcl_Size numBytes, /* Max number of bytes to scan. */ int mask, /* Specifies when to stop parsing. The parse * stops at the first unquoted character whose @@ -1531,7 +1531,7 @@ Tcl_ParseVarName( const char * Tcl_ParseVar( Tcl_Interp *interp, /* Context for looking up variable. */ - const char *start, /* Start of variable substitution. First + const char *start, /* Start of variable substitution. First * character must be "$". */ const char **termPtr) /* If non-NULL, points to word to fill in with * character just after last one in the diff --git a/generic/tclParse.h b/generic/tclParse.h index b28ac8c..1381b30 100644 --- a/generic/tclParse.h +++ b/generic/tclParse.h @@ -1,18 +1,21 @@ /* - * Minimal set of shared macro definitions and declarations so that multiple + * Minimal set of shared flag definitions and declarations so that multiple * source files can make use of the parsing table in tclParse.c */ -#define TYPE_NORMAL 0 -#define TYPE_SPACE 0x1 -#define TYPE_COMMAND_END 0x2 -#define TYPE_SUBS 0x4 -#define TYPE_QUOTE 0x8 -#define TYPE_CLOSE_PAREN 0x10 -#define TYPE_CLOSE_BRACK 0x20 -#define TYPE_BRACE 0x40 -#define TYPE_OPEN_PAREN 0x80 -#define TYPE_BAD_ARRAY_INDEX (TYPE_OPEN_PAREN|TYPE_CLOSE_PAREN|TYPE_QUOTE|TYPE_BRACE) +enum ParseTypeFlags { + TYPE_NORMAL = 0, + TYPE_SPACE = 0x1, + TYPE_COMMAND_END = 0x2, + TYPE_SUBS = 0x4, + TYPE_QUOTE = 0x8, + TYPE_CLOSE_PAREN = 0x10, + TYPE_CLOSE_BRACK = 0x20, + TYPE_BRACE = 0x40, + TYPE_OPEN_PAREN = 0x80, + TYPE_BAD_ARRAY_INDEX = ( + TYPE_OPEN_PAREN | TYPE_CLOSE_PAREN | TYPE_QUOTE | TYPE_BRACE) +}; #define CHAR_TYPE(c) tclCharTypeTable[(unsigned char)(c)] diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c index 9a44863..7664827 100644 --- a/generic/tclPathObj.c +++ b/generic/tclPathObj.c @@ -40,11 +40,11 @@ static int MakeTildeRelativePath(Tcl_Interp *interp, */ static const Tcl_ObjType fsPathType = { - "path", /* name */ - FreeFsPathInternalRep, /* freeIntRepProc */ - DupFsPathInternalRep, /* dupIntRepProc */ - UpdateStringOfFsPath, /* updateStringProc */ - SetFsPathFromAny, /* setFromAnyProc */ + "path", /* name */ + FreeFsPathInternalRep, /* freeIntRepProc */ + DupFsPathInternalRep, /* dupIntRepProc */ + UpdateStringOfFsPath, /* updateStringProc */ + SetFsPathFromAny, /* setFromAnyProc */ TCL_OBJTYPE_V0 }; @@ -2347,7 +2347,7 @@ DupFsPathInternalRep( static void UpdateStringOfFsPath( - Tcl_Obj *pathPtr) /* path obj with string rep to update. */ + Tcl_Obj *pathPtr) /* path obj with string rep to update. */ { FsPath *fsPathPtr = PATHOBJ(pathPtr); Tcl_Size cwdLen; @@ -2469,11 +2469,11 @@ TclNativePathInFilesystem( */ int MakeTildeRelativePath( - Tcl_Interp *interp, /* May be NULL. Only used for error messages */ - const char *user, /* User name. NULL -> current user */ - const char *subPath, /* Rest of path. May be NULL */ - Tcl_DString *dsPtr) /* Output. Is initialized by the function. Must be - * freed on success */ + Tcl_Interp *interp, /* May be NULL. Only used for error messages */ + const char *user, /* User name. NULL -> current user */ + const char *subPath, /* Rest of path. May be NULL */ + Tcl_DString *dsPtr) /* Output. Is initialized by the function. Must + * be freed on success */ { const char *dir; Tcl_DString dirString; @@ -2537,8 +2537,8 @@ MakeTildeRelativePath( */ Tcl_Obj * TclGetHomeDirObj( - Tcl_Interp *interp, /* May be NULL. Only used for error messages */ - const char *user) /* User name. NULL -> current user */ + Tcl_Interp *interp, /* May be NULL. Only used for error messages */ + const char *user) /* User name. NULL -> current user */ { Tcl_DString dirString; @@ -2569,7 +2569,7 @@ TclGetHomeDirObj( */ Tcl_Obj * TclResolveTildePath( - Tcl_Interp *interp, /* May be NULL. Only used for error messages */ + Tcl_Interp *interp, /* May be NULL. Only used for error messages */ Tcl_Obj *pathObj) { const char *path; diff --git a/generic/tclPipe.c b/generic/tclPipe.c index 73f291a..1efe1ba 100644 --- a/generic/tclPipe.c +++ b/generic/tclPipe.c @@ -1021,7 +1021,7 @@ Tcl_Channel Tcl_OpenCommandChannel( Tcl_Interp *interp, /* Interpreter for error reporting. Can NOT be * NULL. */ - Tcl_Size argc, /* How many arguments. */ + Tcl_Size argc, /* How many arguments. */ const char **argv, /* Array of arguments for command pipe. */ int flags) /* Or'ed combination of TCL_STDIN, TCL_STDOUT, * TCL_STDERR, and TCL_ENFORCE_MODE. */ diff --git a/generic/tclPkgConfig.c b/generic/tclPkgConfig.c index d84472c..40ec9d0 100644 --- a/generic/tclPkgConfig.c +++ b/generic/tclPkgConfig.c @@ -22,7 +22,7 @@ * - TCL_COMPILE_STATS OSCMa bytecode compiler statistics. * * - TCL_CFG_DO64BIT NSCMdt tcl is compiled for a 64bit system. - * - NDEBUG NSCMdt tcl is compiled with symbol info off. + * - NDEBUG NSCMdt tcl is compiled with symbol info off. * - TCL_CFG_OPTIMIZED NSCMdt tcl is compiled with cc optimizations on * - TCL_CFG_PROFILED NSCMdt tcl is compiled with profiling info. * diff --git a/generic/tclPreserve.c b/generic/tclPreserve.c index 36a9537..58bc82d 100644 --- a/generic/tclPreserve.c +++ b/generic/tclPreserve.c @@ -21,7 +21,7 @@ */ typedef struct { - void *clientData; /* Address of preserved block. */ + void *clientData; /* Address of preserved block. */ size_t refCount; /* Number of Tcl_Preserve calls in effect for * block. */ int mustFree; /* Non-zero means Tcl_EventuallyFree was @@ -36,10 +36,11 @@ typedef struct { * These variables are protected by "preserveMutex". */ -static Reference *refArray = NULL; /* First in array of references. */ +static Reference *refArray = NULL; + /* First in array of references. */ static size_t spaceAvl = 0; /* Total number of structures available at * *firstRefPtr. */ -static size_t inUse = 0; /* Count of structures currently in use in +static size_t inUse = 0; /* Count of structures currently in use in * refArray. */ TCL_DECLARE_MUTEX(preserveMutex)/* To protect the above statics */ @@ -117,7 +118,7 @@ TclFinalizePreserve(void) void Tcl_Preserve( - void *clientData) /* Pointer to malloc'ed block of memory. */ + void *clientData) /* Pointer to malloc'ed block of memory. */ { Reference *refPtr; size_t i; @@ -180,7 +181,7 @@ Tcl_Preserve( void Tcl_Release( - void *clientData) /* Pointer to malloc'ed block of memory. */ + void *clientData) /* Pointer to malloc'ed block of memory. */ { Reference *refPtr; size_t i; @@ -259,7 +260,7 @@ Tcl_Release( void Tcl_EventuallyFree( - void *clientData, /* Pointer to malloc'ed block of memory. */ + void *clientData, /* Pointer to malloc'ed block of memory. */ Tcl_FreeProc *freeProc) /* Function to actually do free. */ { Reference *refPtr; diff --git a/generic/tclProc.c b/generic/tclProc.c index 2f87048..8e752ed 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -2108,7 +2108,7 @@ MakeProcError( void TclProcDeleteProc( - void *clientData) /* Procedure to be deleted. */ + void *clientData) /* Procedure to be deleted. */ { Proc *procPtr = (Proc *)clientData; diff --git a/generic/tclRegexp.c b/generic/tclRegexp.c index 04f060b..caf6461 100644 --- a/generic/tclRegexp.c +++ b/generic/tclRegexp.c @@ -103,11 +103,11 @@ static int SetRegexpFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr); */ const Tcl_ObjType tclRegexpType = { - "regexp", /* name */ - FreeRegexpInternalRep, /* freeIntRepProc */ - DupRegexpInternalRep, /* dupIntRepProc */ - NULL, /* updateStringProc */ - SetRegexpFromAny, /* setFromAnyProc */ + "regexp", /* name */ + FreeRegexpInternalRep, /* freeIntRepProc */ + DupRegexpInternalRep, /* dupIntRepProc */ + NULL, /* updateStringProc */ + SetRegexpFromAny, /* setFromAnyProc */ TCL_OBJTYPE_V0 }; diff --git a/generic/tclResult.c b/generic/tclResult.c index 7151fc4..f205b47 100644 --- a/generic/tclResult.c +++ b/generic/tclResult.c @@ -388,7 +388,7 @@ Tcl_AppendElement( void Tcl_ResetResult( - Tcl_Interp *interp)/* Interpreter for which to clear result. */ + Tcl_Interp *interp) /* Interpreter for which to clear result. */ { Interp *iPtr = (Interp *) interp; @@ -441,7 +441,7 @@ Tcl_ResetResult( static void ResetObjResult( - Interp *iPtr) /* Points to the interpreter whose result + Interp *iPtr) /* Points to the interpreter whose result * object should be reset. */ { Tcl_Obj *objResultPtr = iPtr->objResultPtr; diff --git a/generic/tclScan.c b/generic/tclScan.c index cccdd7a..9a9e773 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -16,14 +16,15 @@ /* * Flag values used by Tcl_ScanObjCmd. */ - -#define SCAN_NOSKIP 0x1 /* Don't skip blanks. */ -#define SCAN_SUPPRESS 0x2 /* Suppress assignment. */ -#define SCAN_UNSIGNED 0x4 /* Read an unsigned value. */ -#define SCAN_WIDTH 0x8 /* A width value was supplied. */ - -#define SCAN_LONGER 0x400 /* Asked for a wide value. */ -#define SCAN_BIG 0x800 /* Asked for a bignum value. */ +enum ScanFlags { + SCAN_NOSKIP = 0x1, /* Don't skip blanks. */ + SCAN_SUPPRESS = 0x2, /* Suppress assignment. */ + SCAN_UNSIGNED = 0x4, /* Read an unsigned value. */ + SCAN_WIDTH = 0x8, /* A width value was supplied. */ + + SCAN_LONGER = 0x400, /* Asked for a wide value. */ + SCAN_BIG = 0x800 /* Asked for a bignum value. */ +}; /* * The following structure contains the information associated with a diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c index ee21cf8..59decd9 100644 --- a/generic/tclStrToD.c +++ b/generic/tclStrToD.c @@ -1696,7 +1696,7 @@ MakeLowPrecisionDouble( * ulp, so we need to change rounding mode to 53-bits. We also make * 'retval' volatile, so that it doesn't get promoted to a register. */ - volatile double retval; /* Value of the number. */ + volatile double retval; /* Value of the number. */ /* * Test for zero significand, which requires explicit construction @@ -2652,7 +2652,7 @@ ComputeScale( static inline void SetPrecisionLimits( - int flags, /* Type of conversion: TCL_DD_SHORTEST, + int flags, /* Type of conversion: TCL_DD_SHORTEST, * TCL_DD_E_FMT, TCL_DD_F_FMT. */ int k, /* Floor(log10(number to convert)) */ int *ndigitsPtr, /* IN/OUT: Number of digits requested (will be @@ -3433,7 +3433,8 @@ ShouldBankerRoundUpToNextPowD( * 2**(MP_DIGIT_BIT*sd) */ - if ((mp_add(b, m, temp) != MP_OKAY) || (temp->used <= sd)) { /* Too few digits to be > s */ + if ((mp_add(b, m, temp) != MP_OKAY) || (temp->used <= sd)) { + /* Too few digits to be > s */ return 0; } if (temp->used > sd+1 || temp->dp[sd] > 1) { @@ -4808,7 +4809,7 @@ Tcl_InitBignumFromDouble( err = mp_init_i64(b, w); if (err != MP_OKAY) { - /* just skip */ + /* just skip */ } else if (shift < 0) { err = mp_div_2d(b, -shift, b, NULL); } else if (shift > 0) { @@ -4838,7 +4839,7 @@ Tcl_InitBignumFromDouble( double TclBignumToDouble( - const void *big) /* Integer to convert. */ + const void *big) /* Integer to convert. */ { mp_int b; int bits, shift, i, lsb; @@ -4959,7 +4960,7 @@ TclBignumToDouble( double TclCeil( - const void *big) /* Integer to convert. */ + const void *big) /* Integer to convert. */ { double r = 0.0; mp_int b; @@ -5025,7 +5026,7 @@ TclCeil( double TclFloor( - const void *big) /* Integer to convert. */ + const void *big) /* Integer to convert. */ { double r = 0.0; mp_int b; diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 827c227..5793f65 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -124,8 +124,8 @@ const Tcl_ObjType tclStringType = { static void GrowStringBuffer( Tcl_Obj *objPtr, - Tcl_Size needed, /* Not including terminating nul */ - int flag) /* If 0, try to overallocate */ + Tcl_Size needed, /* Not including terminating nul */ + int flag) /* If 0, try to overallocate */ { /* * Preconditions: @@ -718,8 +718,8 @@ Tcl_GetUnicodeFromObj( Tcl_Obj * Tcl_GetRange( Tcl_Obj *objPtr, /* The Tcl object to find the range of. */ - Tcl_Size first, /* First index of the range. */ - Tcl_Size last) /* Last index of the range. */ + Tcl_Size first, /* First index of the range. */ + Tcl_Size last) /* Last index of the range. */ { Tcl_Obj *newObjPtr; /* The Tcl object to find the range of. */ String *stringPtr; @@ -3051,11 +3051,9 @@ TclStringRepeat( /* maxCount includes space for null */ if (count > (maxCount-1)) { if (interp) { - Tcl_SetObjResult( - interp, - Tcl_ObjPrintf("max size for a Tcl value (%" TCL_SIZE_MODIFIER - "d bytes) exceeded", - TCL_SIZE_MAX)); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "max size for a Tcl value (%" TCL_SIZE_MODIFIER + "d bytes) exceeded", TCL_SIZE_MAX)); Tcl_SetErrorCode(interp, "TCL", "MEMORY", (char *)NULL); } return NULL; @@ -3510,7 +3508,8 @@ TclStringCat( overflow: if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "max size for a Tcl value (%" TCL_SIZE_MODIFIER "d bytes) exceeded", TCL_SIZE_MAX)); + "max size for a Tcl value (%" TCL_SIZE_MODIFIER + "d bytes) exceeded", TCL_SIZE_MAX)); Tcl_SetErrorCode(interp, "TCL", "MEMORY", (char *)NULL); } return NULL; @@ -3534,9 +3533,9 @@ TclStringCat( static int UniCharNcasememcmp( - const void *ucsPtr, /* Unicode string to compare to uct. */ - const void *uctPtr, /* Unicode string ucs is compared to. */ - size_t numChars) /* Number of Unichars to compare. */ + const void *ucsPtr, /* Unicode string to compare to uct. */ + const void *uctPtr, /* Unicode string ucs is compared to. */ + size_t numChars) /* Number of Unichars to compare. */ { const Tcl_UniChar *ucs = (const Tcl_UniChar *)ucsPtr; const Tcl_UniChar *uct = (const Tcl_UniChar *)uctPtr; @@ -3557,7 +3556,7 @@ static int UtfNmemcmp( const void *csPtr, /* UTF string to compare to ct. */ const void *ctPtr, /* UTF string cs is compared to. */ - size_t numChars) /* Number of UTF chars to compare. */ + size_t numChars) /* Number of UTF chars to compare. */ { Tcl_UniChar ch1 = 0, ch2 = 0; const char *cs = (const char *)csPtr; @@ -3589,7 +3588,7 @@ static int UtfNcasememcmp( const void *csPtr, /* UTF string to compare to ct. */ const void *ctPtr, /* UTF string cs is compared to. */ - size_t numChars) /* Number of UTF chars to compare. */ + size_t numChars) /* Number of UTF chars to compare. */ { Tcl_UniChar ch1 = 0, ch2 = 0; const char *cs = (const char *)csPtr; @@ -3616,9 +3615,9 @@ UtfNcasememcmp( static int UniCharNmemcmp( - const void *ucsPtr, /* Unicode string to compare to uct. */ - const void *uctPtr, /* Unicode string ucs is compared to. */ - size_t numChars) /* Number of unichars to compare. */ + const void *ucsPtr, /* Unicode string to compare to uct. */ + const void *uctPtr, /* Unicode string ucs is compared to. */ + size_t numChars) /* Number of unichars to compare. */ { const Tcl_UniChar *ucs = (const Tcl_UniChar *)ucsPtr; const Tcl_UniChar *uct = (const Tcl_UniChar *)uctPtr; @@ -3650,7 +3649,7 @@ TclStringCmp( int checkEq, /* comparison is only for equality */ int nocase, /* comparison is not case sensitive */ Tcl_Size reqlength) /* requested length in characters; - * TCL_INDEX_NONE to compare whole strings */ + * TCL_INDEX_NONE to compare whole strings */ { const char *s1, *s2; int empty, match; @@ -3696,9 +3695,8 @@ TclStringCmp( && (value1Ptr->bytes != NULL) && (s2len == value2Ptr->length) && (value2Ptr->bytes != NULL)) { - /* each byte represents one character so s1l3n, s2l3n, and - * reqlength are in both bytes and characters - */ + /* each byte represents one character so s1l3n, s2l3n, + * and reqlength are in both bytes and characters */ s1 = value1Ptr->bytes; s2 = value2Ptr->bytes; memCmpFn = memcmp; -- cgit v0.12 From 8b39f58d80a03b6462b6fa8e2cc070c4e099eae7 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 3 Jun 2024 12:02:15 +0000 Subject: Let's review the SetResult.3 changes in trunk (which were never backported to 8.6/8.7) --- doc/SetResult.3 | 239 ++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 172 insertions(+), 67 deletions(-) diff --git a/doc/SetResult.3 b/doc/SetResult.3 index 954906a..9e009fa 100644 --- a/doc/SetResult.3 +++ b/doc/SetResult.3 @@ -35,105 +35,210 @@ const char * .SH ARGUMENTS .AS Tcl_FreeProc sourceInterp out .AP Tcl_Interp *interp out -The interpreter get or set the result for. +Interpreter whose result is to be modified or read. .AP Tcl_Obj *objPtr in -A value to set the result to. +Tcl value to become result for \fIinterp\fR. .AP char *result in -The string value set the result to, or to append to the existing result. +String value to become result for \fIinterp\fR or to be +appended to the existing result. .AP "const char" *element in -The string value to append as a list element +String value to append as a list element to the existing result of \fIinterp\fR. .AP Tcl_FreeProc *freeProc in -Pointer to a procedure to call to release storage at -\fIresult\fR. +Address of procedure to call to release storage at +\fIresult\fR, or \fBTCL_STATIC\fR, \fBTCL_DYNAMIC\fR, or +\fBTCL_VOLATILE\fR. .AP Tcl_Interp *sourceInterp in -The interpreter to transfer the result and return options from. +Interpreter that the result and return options should be transferred from. .AP Tcl_Interp *targetInterp in -The interpreter to transfer the result and return options to. +Interpreter that the result and return options should be transferred to. .AP int code in Return code value that controls transfer of return options. .BE .SH DESCRIPTION .PP -These procedures manipulate the result of an interpreter. Some procedures -provide a Tcl_Obj interface while others provide a string interface. For -example, \fBTcl_SetObjResult\fR accepts a Tcl_Obj and \fBTcl_SetResult\fR -accepts a char *. Similarly, \fBTcl_GetObjResult\fR produces a Tcl_Obj * and -\fBTcl_GetStringResult\fR produces a char *. The procedures can be mixed and -matched. For example, if \fBTcl_SetObjResult\fR is called to set the result to -a Tcl_Obj value, and then \fBTcl_GetStringResult\fR is called, it returns a -char * (but see caveats below). +The procedures described here are utilities for manipulating the +result value in a Tcl interpreter. +The interpreter result may be either a Tcl value or a string. +For example, \fBTcl_SetObjResult\fR and \fBTcl_SetResult\fR +set the interpreter result to, respectively, a value and a string. +Similarly, \fBTcl_GetObjResult\fR and \fBTcl_GetStringResult\fR +return the interpreter result as a value and as a string. +The procedures always keep the string and value forms +of the interpreter result consistent. +For example, if \fBTcl_SetObjResult\fR is called to set +the result to a value, +then \fBTcl_GetStringResult\fR is called, +it will return the value's string representation. .PP -\fBTcl_SetObjResult\fR sets \fIobjPtr\fR as the result for \fIinterp\fR, +\fBTcl_SetObjResult\fR +arranges for \fIobjPtr\fR to be the result for \fIinterp\fR, replacing any existing result. +The result is left pointing to the value +referenced by \fIobjPtr\fR. +\fIobjPtr\fR's reference count is incremented +since there is now a new reference to it from \fIinterp\fR. +The reference count for any old result value +is decremented and the old result value is freed if no +references to it remain. .PP -\fBTcl_GetObjResult\fR returns the result for \fIinterp\fR, without -incrementing its reference count. -.PP -\fBTcl_SetResult\fR sets \fIresult\fR as the result for \fIinterp\fR, replacing -any existing result, and calls \fIfreeProc\fR to free \fIresult\fR. See \fBTHE -TCL_FREEPROC ARGUMENT TO TCL_SETRESULT\fR below. If \fIresult\fR is -\fBNULL\fR, ignores \fIfreeProc\fR and sets the result for \fIinterp\fR to -point to the empty string. -.PP -\fBTcl_GetStringResult\fR returns the result for \fIinterp\fR as a string, i.e. -the bytes of the Tcl_Obj for the result, which can be decoded using -\fBTcl_UtfToExternal\fR. This value is freed when its corresponding Tcl_Obj is -freed.Programmers are encouraged to use the newer Tcl_Obj API procedures, e.g. -to call \fBTcl_GetObjResult\fR instead. -.PP -\fBTcl_ResetResult\fR sets the empty string as the result for \fIinterp\fR and -clears the error state managed by \fBTcl_AddErrorInfo\fR, -\fBTcl_AddObjErrorInfo\fR, and \fBTcl_SetErrorCode\fR. -.PP -\fBTcl_AppendResult\fR builds up a result from smaller pieces, appending each -\fIresult\fR in order to the current result for \fIinterp\fR. It may be called -repeatedly as additional pieces of the result are produced, and manages the -storage for the \fIinterp\fR's result, allocating a larger result area if -necessary. It also manages conversion to and from the \fIresult\fR field of -the \fIinterp\fR to handle backward-compatibility with old-style extensions. -Any number of \fIresult\fR arguments may be passed in a single call; the last -argument in the list must be (char *)NULL. -.PP -\fBTcl_TransferResult\fR transfers interpreter state from \fIsourceInterp\fR to -\fItargetInterp\fR, both of which must have been created in the same thread, -resets the result in \fIsourceInterp\fR, and moves the return options -dictionary as controlled by the return code value \fIcode\fR in the same manner -as \fBTcl_GetReturnOptions\fR. +\fBTcl_GetObjResult\fR returns the result for \fIinterp\fR as a value. +The value's reference count is not incremented; +if the caller needs to retain a long-term pointer to the value +they should use \fBTcl_IncrRefCount\fR to increment its reference count +in order to keep it from being freed too early or accidentally changed. +.PP +\fBTcl_SetResult\fR +arranges for \fIresult\fR to be the result for the current Tcl +command in \fIinterp\fR, replacing any existing result. +The \fIfreeProc\fR argument specifies how to manage the storage +for the \fIresult\fR argument; +it is discussed in the section +\fBTHE TCL_FREEPROC ARGUMENT TO TCL_SETRESULT\fR below. +If \fIresult\fR is \fBNULL\fR, then \fIfreeProc\fR is ignored +and \fBTcl_SetResult\fR +re-initializes \fIinterp\fR's result to point to an empty string. +.PP +\fBTcl_GetStringResult\fR returns the result for \fIinterp\fR as a string. +If the result was set to a value by a \fBTcl_SetObjResult\fR call, +the value form will be converted to a string and returned. +If the value's string representation contains null bytes, +this conversion will lose information. +For this reason, programmers are encouraged to +write their code to use the new value API procedures +and to call \fBTcl_GetObjResult\fR instead. +.PP +\fBTcl_ResetResult\fR clears the result for \fIinterp\fR +and leaves the result in its normal empty initialized state. +If the result is a value, +its reference count is decremented and the result is left +pointing to an unshared value representing an empty string. +If the result is a dynamically allocated string, its memory is free*d +and the result is left as a empty string. +\fBTcl_ResetResult\fR also clears the error state managed by +\fBTcl_AddErrorInfo\fR, \fBTcl_AddObjErrorInfo\fR, +and \fBTcl_SetErrorCode\fR. .PP -If \fIsourceInterp\fR and \fItargetInterp\fR are the same, nothing is done. +\fBTcl_AppendResult\fR makes it easy to build up Tcl results in pieces. +It takes each of its \fIresult\fR arguments and appends them in order +to the current result associated with \fIinterp\fR. +If the result is in its initialized empty state (e.g. a command procedure +was just invoked or \fBTcl_ResetResult\fR was just called), +then \fBTcl_AppendResult\fR sets the result to the concatenation of +its \fIresult\fR arguments. +\fBTcl_AppendResult\fR may be called repeatedly as additional pieces +of the result are produced. +\fBTcl_AppendResult\fR takes care of all the +storage management issues associated with managing \fIinterp\fR's +result, such as allocating a larger result area if necessary. +It also manages conversion to and from the \fIresult\fR field of the +\fIinterp\fR so as to handle backward-compatibility with old-style +extensions. +Any number of \fIresult\fR arguments may be passed in a single +call; the last argument in the list must be (char *)NULL. +.PP +\fBTcl_TransferResult\fR transfers interpreter state from \fIsourceInterp\fR +to \fItargetInterp\fR. The two interpreters must have been created in the +same thread. If \fIsourceInterp\fR and \fItargetInterp\fR are the same, +nothing is done. Otherwise, \fBTcl_TransferResult\fR moves the result +from \fIsourceInterp\fR to \fItargetInterp\fR, and resets the result +in \fIsourceInterp\fR. It also moves the return options dictionary as +controlled by the return code value \fIcode\fR in the same manner +as \fBTcl_GetReturnOptions\fR. .SH "DEPRECATED INTERFACES" .SS "OLD STRING PROCEDURES" .PP -The following procedures are deprecated since they manipulate the Tcl result as -a string. Procedures such as \fBTcl_SetObjResult\fR can be significantly more -efficient. -.PP -\fBTcl_AppendElement\fR is like \fBTcl_AppendResult\fR, but it appends only one -piece, and also appends that piece as a list item. -\fBTcl_AppendElement\fR adds backslashes or braces as necessary to ensure that -\fIelement\fR is properly formatted as a list item. Under normal conditions, -\fBTcl_AppendElement\fR adds a space character to \fIinterp\fR's result just -before adding the new list element, so that the list elements in the result are -properly separated. However if the new list element is the first item in the -list or sublist (i.e. \fIinterp\fR's current result is empty, or consists of -the single character +Use of the following procedures is deprecated +since they manipulate the Tcl result as a string. +Procedures such as \fBTcl_SetObjResult\fR +that manipulate the result as a value +can be significantly more efficient. +.PP +\fBTcl_AppendElement\fR is similar to \fBTcl_AppendResult\fR in +that it allows results to be built up in pieces. +However, \fBTcl_AppendElement\fR takes only a single \fIelement\fR +argument and it appends that argument to the current result +as a proper Tcl list element. +\fBTcl_AppendElement\fR adds backslashes or braces if necessary +to ensure that \fIinterp\fR's result can be parsed as a list and that +\fIelement\fR will be extracted as a single element. +Under normal conditions, \fBTcl_AppendElement\fR will add a space +character to \fIinterp\fR's result just before adding the new +list element, so that the list elements in the result are properly +separated. +However if the new list element is the first in a list or sub-list +(i.e. \fIinterp\fR's current result is empty, or consists of the +single character .QW { , or ends in the characters .QW " {" ) then no space is added. .SH "THE TCL_FREEPROC ARGUMENT TO TCL_SETRESULT" .PP -\fIFreeProc\fR has the following type: +\fBTcl_SetResult\fR's \fIfreeProc\fR argument specifies how +the Tcl system is to manage the storage for the \fIresult\fR argument. +If \fBTcl_SetResult\fR or \fBTcl_SetObjResult\fR are called +at a time when \fIinterp\fR holds a string result, +they do whatever is necessary to dispose of the old string result +(see the \fBTcl_Interp\fR manual entry for details on this). +.PP +If \fIfreeProc\fR is \fBTCL_STATIC\fR it means that \fIresult\fR +refers to an area of static storage that is guaranteed not to be +modified until at least the next call to \fBTcl_Eval\fR. +If \fIfreeProc\fR +is \fBTCL_DYNAMIC\fR it means that \fIresult\fR was allocated with a call +to \fBTcl_Alloc\fR and is now the property of the Tcl system. +\fBTcl_SetResult\fR will arrange for the string's storage to be +released by calling \fBTcl_Free\fR when it is no longer needed. +If \fIfreeProc\fR is \fBTCL_VOLATILE\fR it means that \fIresult\fR +points to an area of memory that is likely to be overwritten when +\fBTcl_SetResult\fR returns (e.g. it points to something in a stack frame). +In this case \fBTcl_SetResult\fR will make a copy of the string in +dynamically allocated storage and arrange for the copy to be the +result for the current Tcl command. +.PP +If \fIfreeProc\fR is not one of the values \fBTCL_STATIC\fR, +\fBTCL_DYNAMIC\fR, and \fBTCL_VOLATILE\fR, then it is the address +of a procedure that Tcl should call to free the string. +This allows applications to use non-standard storage allocators. +When Tcl no longer needs the storage for the string, it will +call \fIfreeProc\fR. \fIFreeProc\fR should have arguments and +result that match the type \fBTcl_FreeProc\fR: .PP .CS typedef void \fBTcl_FreeProc\fR( char *\fIblockPtr\fR); .CE .PP -When \fIfreeProc\fR is called, \fIblockPtr\fR is the \fIresult\fR value passed -to \fBTcl_SetResult\fR. +When \fIfreeProc\fR is called, its \fIblockPtr\fR will be set to +the value of \fIresult\fR passed to \fBTcl_SetResult\fR. +.SH "REFERENCE COUNT MANAGEMENT" +.PP +The interpreter result is one of the main places that owns references to +values, along with the bytecode execution stack, argument lists, variables, +and the list and dictionary collection values. +.PP +\fBTcl_SetObjResult\fR takes a value with an arbitrary reference count +\fI(specifically including zero)\fR and guarantees to increment the reference +count. If code wishes to continue using the value after setting it as the +result, it should add its own reference to it with \fBTcl_IncrRefCount\fR. +.PP +\fBTcl_GetObjResult\fR returns the current interpreter result value. This will +have a reference count of at least 1. If the caller wishes to keep the +interpreter result value, it should increment its reference count. +.PP +\fBTcl_GetStringResult\fR does not manipulate reference counts, but the string +it returns is owned by (and has a lifetime controlled by) the current +interpreter result value; it should be copied instead of being relied upon to +persist after the next Tcl API call, as most Tcl operations can modify the +interpreter result. +.PP +\fBTcl_SetResult\fR, \fBTcl_AppendResult\fR, \fBTcl_AppendResultVA\fR, +\fBTcl_AppendElement\fR, and \fBTcl_ResetResult\fR all modify the interpreter +result. They may cause the old interpreter result to have its reference count +decremented and a new interpreter result to be allocated. After they have been +called, the reference count of the interpreter result is guaranteed to be 1. .SH "SEE ALSO" Tcl_AddErrorInfo, Tcl_CreateObjCommand, Tcl_SetErrorCode, Tcl_Interp, Tcl_GetReturnOptions -- cgit v0.12 From 85fb2fa3c153705c4e2702f759d1263a50d536c1 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 4 Jun 2024 11:03:36 +0000 Subject: Let's review the encoding.n changes in 8.7/trunk (which were never backported to 8.6) --- doc/encoding.n | 183 +++++++++++++++++++++++++++++++++------------------------ 1 file changed, 105 insertions(+), 78 deletions(-) diff --git a/doc/encoding.n b/doc/encoding.n index 793348f..285f0f4 100644 --- a/doc/encoding.n +++ b/doc/encoding.n @@ -9,81 +9,78 @@ .so man.macros .BS .SH NAME -encoding \- Work with encodings +encoding \- Manipulate encodings .SH SYNOPSIS -\fBencoding \fIoperation\fR ?\fIarg arg ...\fR? +\fBencoding \fIoption\fR ?\fIarg arg ...\fR? .BE .SH INTRODUCTION .PP -In Tcl every string is composed of Unicode values. Text may be encoded into an -encoding such as cp1252, iso8859-1, Shitf\-JIS, utf-8, utf-16, etc. Not every -Unicode vealue is encodable in every encoding, and some encodings can encode -values that are not available in Unicode. -.PP -Even though Unicode is for encoding the written texts of human languages, any -sequence of bytes can be encoded as the first 255 Unicode values. iso8859-1 an -encoding for a subset of Unicode in which each byte is a Unicode value of 255 -or less. Thus, any sequence of bytes can be considered to be a Unicode string -encoded in iso8859-1. To work with binary data in Tcl, decode it from -iso8859-1 when reading it in, and encode it into iso8859-1 when writing it out, -ensuring that each character in the string has a value of 255 or less. -Decoding such a string does nothing, and encoding encoding such a string also -does nothing. -.PP -For example, the following is true: -.CS -set text {In Tcl binary data is treated as Unicode text and it just works.} -set encoded [encoding convertto iso8859-1 $text] -expr {$text eq $encoded}; #-> 1 -.CE -The following is also true: -.CS -set decoded [encoding convertfrom iso8859-1 $text] -expr {$text eq $decoded}; #-> 1 -.CE +Strings in Tcl are logically a sequence of Unicode characters. +These strings are represented in memory as a sequence of bytes that +may be in one of several encodings: modified UTF\-8 (which uses 1 to 4 +bytes per character), or a custom encoding start as 8 bit binary data. +.PP +Different operating system interfaces or applications may generate +strings in other encodings such as Shift\-JIS. The \fBencoding\fR +command helps to bridge the gap between Unicode and these other +formats. .SH DESCRIPTION .PP -Performs one of the following encoding \fIoperations\fR: +Performs one of several encoding related operations, depending on +\fIoption\fR. The legal \fIoption\fRs are: .TP \fBencoding convertfrom\fR ?\fIencoding\fR? \fIdata\fR .TP \fBencoding convertfrom\fR ?\fB-profile \fIprofile\fR? ?\fB-failindex var\fR? \fIencoding\fR \fIdata\fR . -Decodes \fIdata\fR encoded in \fIencoding\fR. If \fIencoding\fR is not -specified the current system encoding is used. +Converts \fIdata\fR, which should be in binary string encoded as per +\fIencoding\fR, to a Tcl string. If \fIencoding\fR is not specified, the current +system encoding is used. .VS "TCL8.7 TIP607, TIP656" -\fB-profile\fR determines how invalid data for the encoding are handled. See -the \fBPROFILES\fR section below for details. Returns an error if decoding -fails. However, if \fB-failindex\fR given, returns the result of the -conversion up to the point of termination, and stores in \fBvar\fR the index of -the character that could not be converted. If no errors are encountered the -entire result of the conversion is returned and the value \fB-1\fR is stored in -\fBvar\fR. +The \fB-profile\fR option determines the command behavior in the presence +of conversion errors. See the \fBPROFILES\fR section below for details. Any premature +termination of processing due to errors is reported through an exception if +the \fB-failindex\fR option is not specified. + +If the \fB-failindex\fR is specified, instead of an exception being raised +on premature termination, the result of the conversion up to the point of the +error is returned as the result of the command. In addition, the index +of the source byte triggering the error is stored in \fBvar\fR. If no +errors are encountered, the entire result of the conversion is returned and +the value \fB-1\fR is stored in \fBvar\fR. .VE "TCL8.7 TIP607, TIP656" .TP \fBencoding convertto\fR ?\fIencoding\fR? \fIdata\fR .TP \fBencoding convertto\fR ?\fB-profile \fIprofile\fR? ?\fB-failindex var\fR? \fIencoding\fR \fIdata\fR . -Converts \fIstring\fR to \fIencoding\fR. If \fIencoding\fR is not given, the -current system encoding is used. +Convert \fIstring\fR to the specified \fIencoding\fR. The result is a Tcl binary +string that contains the sequence of bytes representing the converted string in +the specified encoding. If \fIencoding\fR is not specified, the current system +encoding is used. .VS "TCL8.7 TIP607, TIP656" -See \fBencoding convertfrom\fR for the meaning of \fB-profile\fR and \fB-failindex\fR. +The \fB-profile\fR and \fB-failindex\fR options have the same effect as +described for the \fBencoding convertfrom\fR command. .VE "TCL8.7 TIP607, TIP656" .TP \fBencoding dirs\fR ?\fIdirectoryList\fR? . -Sets the search path for \fB*.enc\fR encoding data files to the list of -directories given by \fIdirectoryList\fR. If \fIdirectoryList\fR is not given, -returns the current list of directories that make up the search path. It is -not an error for an item in \fIdirectoryList\fR to not refer to a readable, -searchable directory. +Tcl can load encoding data files from the file system that describe +additional encodings for it to work with. This command sets the search +path for \fB*.enc\fR encoding data files to the list of directories +\fIdirectoryList\fR. If \fIdirectoryList\fR is omitted then the +command returns the current list of directories that make up the +search path. It is an error for \fIdirectoryList\fR to not be a valid +list. If, when a search for an encoding data file is happening, an +element in \fIdirectoryList\fR does not refer to a readable, +searchable directory, that element is ignored. .TP \fBencoding names\fR . -Returns a list of the names of available encodings. +Returns a list containing the names of all of the encodings that are +currently available. The encodings .QW utf-8 and @@ -92,58 +89,88 @@ are guaranteed to be present in the list. .VS "TCL8.7 TIP656" .TP \fBencoding profiles\fR -Returns a list of names of available encoding profiles. See \fBPROFILES\fR -below. +Returns a list of the names of encoding profiles. See \fBPROFILES\fR below. .VE "TCL8.7 TIP656" .TP \fBencoding system\fR ?\fIencoding\fR? . -Sets the system encoding to \fIencoding\fR. If \fIencoding\fR is not given, -returns the current system encoding. The system encoding is used to pass -strings to system calls. +Set the system encoding to \fIencoding\fR. If \fIencoding\fR is +omitted then the command returns the current system encoding. The +system encoding is used whenever Tcl passes strings to system calls. .\" Do not put .VS on whole section as that messes up the bullet list alignment .SH PROFILES .PP .VS "TCL8.7 TIP656" -Each \fIprofile\fR is a distinct strategy for dealing with invalid data for an -encoding. +Operations involving encoding transforms may encounter several types of +errors such as invalid sequences in the source data, characters that +cannot be encoded in the target encoding and so on. +A \fIprofile\fR prescribes the strategy for dealing with such errors +in one of two ways: +.VE "TCL8.7 TIP656" +. +.IP \(bu +.VS "TCL8.7 TIP656" +Terminating further processing of the source data. The profile does not +determine how this premature termination is conveyed to the caller. By default, +this is signalled by raising an exception. If the \fB-failindex\fR option +is specified, errors are reported through that mechanism. +.VE "TCL8.7 TIP656" +.IP \(bu +.VS "TCL8.7 TIP656" +Continue further processing of the source data using a fallback strategy such +as replacing or discarding the offending bytes in a profile-defined manner. +.VE "TCL8.7 TIP656" .PP -The following profiles are currently implemented. +The following profiles are currently implemented with \fBtcl8\fR being +the default if the \fB-profile\fR is not specified. .VS "TCL8.7 TIP656" .TP \fBtcl8\fR . -The default profile. Provides for behaviour identical to that of Tcl 8.6: When -decoding, for encodings \fBother than utf-8\fR, each invalid byte is interpreted -as the Unicode value given by that one byte. For example, the byte 0x80, which -is invalid in the ASCII encoding would be mapped to the Unicode value U+0080. -For \fButf-8\fR, each invalid byte that is a valid CP1252 character is -interpreted as the Unicode value for that character, while each byte that is -not is treated as the Unicode value given by that one byte. For example, byte -0x80 is defined by CP1252 and is therefore mapped to its Unicode equivalent -U+20AC while byte 0x81 which is not defined by CP1252 is mapped to U+0081. As -an additional special case, the sequence 0xC0 0x80 is mapped to U+0000. +The \fBtcl8\fR profile always follows the first strategy above and corresponds +to the behavior of encoding transforms in Tcl 8.6. When converting from an +external encoding \fBother than utf-8\fR to Tcl strings with the \fBencoding +convertfrom\fR command, invalid bytes are mapped to their numerically equivalent +code points. For example, the byte 0x80 which is invalid in ASCII would be +mapped to code point U+0080. When converting from \fButf-8\fR, invalid bytes +that are defined in CP1252 are mapped to their Unicode equivalents while those +that are not fall back to the numerical equivalents. For example, byte 0x80 is +defined by CP1252 and is therefore mapped to its Unicode equivalent U+20AC while +byte 0x81 which is not defined by CP1252 is mapped to U+0081. As an additional +special case, the sequence 0xC0 0x80 is mapped to U+0000. -When encoding, each character that cannot be represented in the encoding is -replaced by an encoding-dependent character, usually the question mark \fB?\fR. +When converting from Tcl strings to an external encoding format using +\fBencoding convertto\fR, characters that cannot be represented in the +target encoding are replaced by an encoding-dependent character, usually +the question mark \fB?\fR. .TP \fBstrict\fR . -The operation fails when invalid data for the encoding are encountered. +The \fBstrict\fR profile always stops processing when an conversion error is +encountered. The error is signalled via an exception or the \fB-failindex\fR +option mechanism. The \fBstrict\fR profile implements a Unicode standard +conformant behavior. .TP \fBreplace\fR . -When decoding, invalid bytes are replaced by U+FFFD, the Unicode REPLACEMENT -CHARACTER. +Like the \fBtcl8\fR profile, the \fBreplace\fR profile always continues +processing on conversion errors but follows a Unicode standard conformant +method for substitution of invalid source data. + +When converting an encoded byte sequence to a Tcl string using +\fBencoding convertfrom\fR, invalid bytes +are replaced by the U+FFFD REPLACEMENT CHARACTER code point. -When encoding, Unicode values that cannot be represented in the target encoding -are transformed to an encoding-specific fallback character, U+FFFD REPLACEMENT -CHARACTER for UTF targets, and generally `?` for other encodings. +When encoding a Tcl string with \fBencoding convertto\fR, +code points that cannot be represented in the +target encoding are transformed to an encoding-specific fallback character, +U+FFFD REPLACEMENT CHARACTER for UTF targets and generally `?` for other +encodings. .VE "TCL8.7 TIP656" .SH EXAMPLES .PP -These examples use the utility proc below that prints the Unicode value for -each character in a string. +These examples use the utility proc below that prints the Unicode code points +comprising a Tcl string. .PP .CS proc codepoints s {join [lmap c [split $s {}] { @@ -151,14 +178,14 @@ proc codepoints s {join [lmap c [split $s {}] { } .CE .PP -Example 1: Convert from euc-jp: +Example 1: convert a byte sequence in Japanese euc-jp encoding to a TCL string: .PP .CS -% codepoints [\fBencoding convertfrom\fR euc-jp \exA4\exCF] +% codepoints [\fBencoding convertfrom\fR euc-jp "\exA4\exCF"] U+00306F .CE .PP -The result is the Unicode value +The result is the unicode codepoint .QW "\eu306F" , which is the Hiragana letter HA. .VS "TCL8.7 TIP607, TIP656" -- cgit v0.12 From 14e9a4e0bda3c86ac11baf3c11f900a5837ea70a Mon Sep 17 00:00:00 2001 From: dkf Date: Tue, 4 Jun 2024 15:35:14 +0000 Subject: Space before tab is an extremely unlikely to be correct indentation pattern --- generic/tcl.h | 6 +-- generic/tclArithSeries.c | 102 +++++++++++++++++++---------------------------- generic/tclAssembly.c | 4 +- generic/tclBasic.c | 8 ++-- generic/tclClock.c | 18 ++++----- generic/tclClockFmt.c | 14 +++---- generic/tclCmdAH.c | 2 +- generic/tclCmdMZ.c | 4 +- generic/tclCompCmds.c | 14 +++---- generic/tclCompile.h | 10 ++--- generic/tclDictObj.c | 4 +- generic/tclEncoding.c | 2 +- generic/tclExecute.c | 2 +- generic/tclIO.c | 30 +++++++------- generic/tclIO.h | 6 +-- generic/tclIOCmd.c | 2 +- generic/tclIORTrans.c | 4 +- generic/tclIOUtil.c | 2 +- generic/tclInt.h | 26 ++++++------ generic/tclListObj.c | 28 ++++++------- generic/tclProc.c | 2 +- generic/tclResult.c | 2 +- generic/tclStrToD.c | 10 ++--- generic/tclStringObj.c | 78 ++++++++++++++++++------------------ generic/tclUtf.c | 22 +++++----- generic/tclUtil.c | 22 +++++----- generic/tclVar.c | 4 +- generic/tclZipfs.c | 6 +-- generic/tclZlib.c | 2 +- macosx/tclMacOSXNotify.c | 4 +- unix/tclEpollNotfy.c | 2 +- unix/tclKqueueNotfy.c | 2 +- unix/tclLoadDl.c | 8 ++-- unix/tclLoadDyld.c | 8 ++-- unix/tclUnixFCmd.c | 14 +++---- unix/tclUnixNotfy.c | 6 +-- unix/tclUnixSock.c | 10 ++--- unix/tclUnixTime.c | 2 +- win/tclWinConsole.c | 2 +- win/tclWinPipe.c | 14 +++---- win/tclWinPort.h | 2 +- win/tclWinSerial.c | 2 +- win/tclWinSock.c | 4 +- win/tclWinTime.c | 22 +++++----- 44 files changed, 256 insertions(+), 282 deletions(-) diff --git a/generic/tcl.h b/generic/tcl.h index 41e68a8..b5630cc 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -1105,7 +1105,7 @@ struct Tcl_HashEntry { * allocated for the hash table that is not for an * entry will use the system heap. * TCL_HASH_KEY_DIRECT_COMPARE - - * Allows fast comparison for hash keys directly + * Allows fast comparison for hash keys directly * by compare of their key.oneWordValue values, * before call of compareKeysProc (much slower * than a direct compare, so it is speed-up only @@ -1250,7 +1250,7 @@ typedef struct Tcl_HashSearch { typedef struct { void *next; /* Search position for underlying hash * table. */ - TCL_HASH_TYPE epoch; /* Epoch marker for dictionary being searched, + TCL_HASH_TYPE epoch; /* Epoch marker for dictionary being searched, * or 0 if search has terminated. */ Tcl_Dict dictionaryPtr; /* Reference to dictionary being searched. */ } Tcl_DictSearch; @@ -1998,7 +1998,7 @@ typedef struct Tcl_EncodingType { * buffer contains the entire input stream to be * converted, this flag should be set. * TCL_ENCODING_STOPONERROR - Not used any more. - * TCL_ENCODING_NO_TERMINATE - If set, Tcl_ExternalToUtf does not append a + * TCL_ENCODING_NO_TERMINATE - If set, Tcl_ExternalToUtf does not append a * terminating NUL byte. Since it does not need * an extra byte for a terminating NUL, it fills * all dstLen bytes with encoded UTF-8 content if diff --git a/generic/tclArithSeries.c b/generic/tclArithSeries.c index fd1014c..4b4b892 100755 --- a/generic/tclArithSeries.c +++ b/generic/tclArithSeries.c @@ -231,21 +231,19 @@ maxPrecision( * * ArithSeriesLen -- * - * Compute the length of the equivalent list where - * every element is generated starting from *start*, - * and adding *step* to generate every successive element - * that's < *end* for positive steps, or > *end* for negative - * steps. + * Compute the length of the equivalent list where + * every element is generated starting from *start*, + * and adding *step* to generate every successive element + * that's < *end* for positive steps, or > *end* for negative + * steps. * * Results: - * - * The length of the list generated by the given range, - * that may be zero. - * The function returns -1 if the list is of length infinite. + * The length of the list generated by the given range, + * that may be zero. + * The function returns -1 if the list is of length infinite. * * Side effects: - * - * None. + * None. * *---------------------------------------------------------------------- */ @@ -383,12 +381,11 @@ FreeArithSeriesInternalRep( * refcount = 0. * * Results: - * - * A Tcl_Obj pointer to the created ArithSeries object. - * A NULL pointer of the range is invalid. + * A Tcl_Obj pointer to the created ArithSeries object. + * A NULL pointer of the range is invalid. * * Side Effects: - * None. + * None. * *---------------------------------------------------------------------- */ @@ -425,7 +422,7 @@ NewArithSeriesInt( arithSeriesObj->internalRep.twoPtrValue.ptr2 = NULL; arithSeriesObj->typePtr = &arithSeriesType; if (length > 0) { - Tcl_InvalidateStringRep(arithSeriesObj); + Tcl_InvalidateStringRep(arithSeriesObj); } return arithSeriesObj; @@ -440,16 +437,13 @@ NewArithSeriesInt( * refcount = 0. * * Results: - * - * A Tcl_Obj pointer to the created ArithSeries object. - * A NULL pointer of the range is invalid. + * A Tcl_Obj pointer to the created ArithSeries object. + * A NULL pointer of the range is invalid. * * Side Effects: - * - * None. + * None. *---------------------------------------------------------------------- */ - static Tcl_Obj * NewArithSeriesDbl( double start, @@ -485,7 +479,7 @@ NewArithSeriesDbl( arithSeriesObj->typePtr = &arithSeriesType; if (length > 0) { - Tcl_InvalidateStringRep(arithSeriesObj); + Tcl_InvalidateStringRep(arithSeriesObj); } return arithSeriesObj; @@ -501,13 +495,10 @@ NewArithSeriesDbl( * refcount = 0. * * Results: - * - * A Tcl_Obj pointer. - * No assignment on error. + * A Tcl_Obj pointer. No assignment on error. * * Side Effects: - * - * None. + * None. *---------------------------------------------------------------------- */ static void @@ -549,16 +540,13 @@ assignNumber( * refcount = 0. * * Results: - * - * A Tcl_Obj pointer to the created ArithSeries object. - * An empty Tcl_Obj if the range is invalid. + * A Tcl_Obj pointer to the created ArithSeries object. + * An empty Tcl_Obj if the range is invalid. * * Side Effects: - * - * None. + * None. *---------------------------------------------------------------------- */ - int TclNewArithSeriesObj( Tcl_Interp *interp, /* For error reporting */ @@ -664,13 +652,11 @@ TclNewArithSeriesObj( * element is stored in *element. * * Results: - * - * TCL_OK on success. + * TCL_OK on success. * * Side Effects: - * - * On success, the integer pointed by *element is modified. - * An empty string ("") is assigned if index is out-of-bounds. + * On success, the integer pointed by *element is modified. + * An empty string ("") is assigned if index is out-of-bounds. * *---------------------------------------------------------------------- */ @@ -705,12 +691,10 @@ TclArithSeriesObjIndex( * Returns the length of the arithmetic series. * * Results: - * - * The length of the series as Tcl_WideInt. + * The length of the series as Tcl_WideInt. * * Side Effects: - * - * None. + * None. * *---------------------------------------------------------------------- */ @@ -732,13 +716,11 @@ ArithSeriesObjLength( * refcount = 0. * * Results: - * - * A Tcl_Obj pointer to the created ArithSeries object. - * A NULL pointer of the range is invalid. + * A Tcl_Obj pointer to the created ArithSeries object. + * A NULL pointer of the range is invalid. * * Side Effects: - * - * None. + * None. *---------------------------------------------------------------------- */ @@ -762,19 +744,17 @@ TclArithSeriesObjStep( * * SetArithSeriesFromAny -- * - * The Arithmetic Series object is just an way to optimize - * Lists space complexity, so no one should try to convert - * a string to an Arithmetic Series object. + * The Arithmetic Series object is just an way to optimize + * Lists space complexity, so no one should try to convert + * a string to an Arithmetic Series object. * - * This function is here just to populate the Type structure. + * This function is here just to populate the Type structure. * * Results: - * - * The result is always TCL_ERROR. But see Side Effects. + * The result is always TCL_ERROR. But see Side Effects. * * Side effects: - * - * Tcl Panic if called. + * Tcl Panic if called. * *---------------------------------------------------------------------- */ @@ -1119,11 +1099,11 @@ TclArithSeriesObjReverse( * should not be NULL and we assume it is not NULL. * * Notes: - * At the cost of overallocation it's possible to estimate - * the length of the string representation and make this procedure - * much faster. Because the programmer shouldn't expect the - * string conversion of a big arithmetic sequence to be fast - * this version takes more care of space than time. + * At the cost of overallocation it's possible to estimate + * the length of the string representation and make this procedure + * much faster. Because the programmer shouldn't expect the + * string conversion of a big arithmetic sequence to be fast + * this version takes more care of space than time. * *---------------------------------------------------------------------- */ diff --git a/generic/tclAssembly.c b/generic/tclAssembly.c index 1d09317..7283b0a 100644 --- a/generic/tclAssembly.c +++ b/generic/tclAssembly.c @@ -51,7 +51,7 @@ typedef enum BasicBlockCatchState { BBCS_UNKNOWN = 0, /* Catch context has not yet been identified */ BBCS_NONE, /* Block is outside of any catch */ BBCS_INCATCH, /* Block is within a catch context */ - BBCS_CAUGHT /* Block is within a catch context and + BBCS_CAUGHT /* Block is within a catch context and * may be executed after an exception fires */ } BasicBlockCatchState; @@ -1930,7 +1930,7 @@ MoveExceptionRangesToBasicBlock( curr_bb->foreignExceptionBase = savedExceptArrayNext; curr_bb->foreignExceptionCount = exceptionCount; curr_bb->foreignExceptions = - (ExceptionRange*)Tcl_Alloc(exceptionCount * sizeof(ExceptionRange)); + (ExceptionRange*)Tcl_Alloc(exceptionCount * sizeof(ExceptionRange)); memcpy(curr_bb->foreignExceptions, envPtr->exceptArrayPtr + savedExceptArrayNext, exceptionCount * sizeof(ExceptionRange)); diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 16721b1..9b6708d 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -319,7 +319,7 @@ static const CmdInfo builtInCmds[] = { {"break", Tcl_BreakObjCmd, TclCompileBreakCmd, NULL, CMD_IS_SAFE}, {"catch", Tcl_CatchObjCmd, TclCompileCatchCmd, TclNRCatchObjCmd, CMD_IS_SAFE}, {"concat", Tcl_ConcatObjCmd, TclCompileConcatCmd, NULL, CMD_IS_SAFE}, - {"const", Tcl_ConstObjCmd, TclCompileConstCmd, NULL, CMD_IS_SAFE}, + {"const", Tcl_ConstObjCmd, TclCompileConstCmd, NULL, CMD_IS_SAFE}, {"continue", Tcl_ContinueObjCmd, TclCompileContinueCmd, NULL, CMD_IS_SAFE}, {"coroinject", NULL, NULL, TclNRCoroInjectObjCmd, CMD_IS_SAFE}, {"coroprobe", NULL, NULL, TclNRCoroProbeObjCmd, CMD_IS_SAFE}, @@ -345,7 +345,7 @@ static const CmdInfo builtInCmds[] = { {"lmap", Tcl_LmapObjCmd, TclCompileLmapCmd, TclNRLmapCmd, CMD_IS_SAFE}, {"lpop", Tcl_LpopObjCmd, NULL, NULL, CMD_IS_SAFE}, {"lrange", Tcl_LrangeObjCmd, TclCompileLrangeCmd, NULL, CMD_IS_SAFE}, - {"lremove", Tcl_LremoveObjCmd, NULL, NULL, CMD_IS_SAFE}, + {"lremove", Tcl_LremoveObjCmd, NULL, NULL, CMD_IS_SAFE}, {"lrepeat", Tcl_LrepeatObjCmd, NULL, NULL, CMD_IS_SAFE}, {"lreplace", Tcl_LreplaceObjCmd, TclCompileLreplaceCmd, NULL, CMD_IS_SAFE}, {"lreverse", Tcl_LreverseObjCmd, NULL, NULL, CMD_IS_SAFE}, @@ -749,7 +749,7 @@ buildInfoObjCmd2( p += len; q = strchr(++p, '.'); if (!q) { - q = p + strlen(p); + q = p + strlen(p); } memcpy(buf, p, q - p); buf[q - p] = '\0'; @@ -8868,7 +8868,7 @@ TclNRTailcallObjCmd( nsObjPtr = Tcl_NewStringObj(nsPtr->fullName, TCL_INDEX_NONE); listPtr = Tcl_NewListObj(objc, objv); - TclListObjSetElement(interp, listPtr, 0, nsObjPtr); + TclListObjSetElement(interp, listPtr, 0, nsObjPtr); iPtr->varFramePtr->tailcallPtr = listPtr; } diff --git a/generic/tclClock.c b/generic/tclClock.c index 3b07b51..2496243 100644 --- a/generic/tclClock.c +++ b/generic/tclClock.c @@ -128,7 +128,7 @@ struct ClockCommand { * to it, but may well ignore this data. */ CompileProc *compileProc; /* The compiler for the command. */ void *clientData; /* Any clientData to give the command (if NULL - * a reference to ClockClientData will be sent) */ + * a reference to ClockClientData will be sent) */ }; static const struct ClockCommand clockCommands[] = { @@ -257,7 +257,7 @@ TclClockInit( #define TCL_CLOCK_PREFIX_LEN 14 /* == strlen("::tcl::clock::") */ memcpy(cmdName, "::tcl::clock::", TCL_CLOCK_PREFIX_LEN); for (clockCmdPtr=clockCommands ; clockCmdPtr->name!=NULL ; clockCmdPtr++) { - void *clientData; + void *clientData; strcpy(cmdName + TCL_CLOCK_PREFIX_LEN, clockCmdPtr->name); if (!(clientData = clockCmdPtr->clientData)) { @@ -438,7 +438,7 @@ NormTimezoneObj( } if (timezoneObj == dataPtr->prevSetupTimeZoneUnnorm && dataPtr->prevSetupTimeZone != NULL) { - return dataPtr->prevSetupTimeZone; + return dataPtr->prevSetupTimeZone; } if (timezoneObj == dataPtr->gmtSetupTimeZoneUnnorm && dataPtr->gmtSetupTimeZone != NULL) { @@ -648,7 +648,7 @@ NormLocaleObj( if ((localeObj->length == 1 /* C */ && strcasecmp(loc, Literals[LIT_C]) == 0) || (dataPtr->defaultLocale && (loc2 = TclGetString(dataPtr->defaultLocale)) - && localeObj->length == dataPtr->defaultLocale->length + && localeObj->length == dataPtr->defaultLocale->length && strcasecmp(loc, loc2) == 0)) { *mcDictObj = dataPtr->defaultLocaleDict; return dataPtr->defaultLocale ? @@ -1323,8 +1323,8 @@ ClockSetupTimeZone( /* before setup just take a look in TZData variable */ if (Tcl_ObjGetVar2(interp, dataPtr->literals[LIT_TZDATA], timezoneObj, 0)) { - /* put it to last slot and return normalized */ - TimezoneLoaded(dataPtr, callargs[1], timezoneObj); + /* put it to last slot and return normalized */ + TimezoneLoaded(dataPtr, callargs[1], timezoneObj); return callargs[1]; } /* setup now */ @@ -3305,10 +3305,10 @@ ClockParseFmtScnArgs( Tcl_WideInt baseVal; /* Base time, expressed in seconds from the Epoch */ if (operation == CLC_OP_SCN) { - /* default flags (from configure) */ - opts->flags |= dataPtr->defFlags & CLF_VALIDATE; + /* default flags (from configure) */ + opts->flags |= dataPtr->defFlags & CLF_VALIDATE; } else { - /* clock value (as current base) */ + /* clock value (as current base) */ opts->baseObj = objv[(baseIdx = 1)]; saw |= 1 << CLC_ARGS_BASE; } diff --git a/generic/tclClockFmt.c b/generic/tclClockFmt.c index b3401a0..ea5f0a5 100644 --- a/generic/tclClockFmt.c +++ b/generic/tclClockFmt.c @@ -758,7 +758,7 @@ ClockFmtObj_UpdateString( * Returns tcl object with key or format object if not localizable. * * Side effects: - * Converts given format object to ClockFmtObjType on demand for caching + * Converts given format object to ClockFmtObjType on demand for caching * the key inside its internal representation. * *---------------------------------------------------------------------- @@ -804,7 +804,7 @@ ClockFrmObjGetLocFmtKey( * Returns scan/format storage pointer to ClockFmtScnStorage. * * Side effects: - * Converts given format object to ClockFmtObjType on demand for caching + * Converts given format object to ClockFmtObjType on demand for caching * the format storage reference inside its internal representation. * Increments objRefCount of the ClockFmtScnStorage reference. * @@ -1416,7 +1416,7 @@ ClockMCGetMultiListIdxTree( * Results: * TCL_OK - match found and the index stored in *val, * TCL_RETURN - not matched or ambigous, - * TCL_ERROR - in error case. + * TCL_ERROR - in error case. * * Side effects: * Input points to end of the found token in string. @@ -1770,7 +1770,7 @@ ClockScnToken_JDN_Proc( } s = p; while (p < end && isdigit(UCHAR(*p))) { - fractJDDiv *= 10; + fractJDDiv *= 10; p++; } if (Clock_str2int(&fractJD, s, p, 1) != TCL_OK) { @@ -2649,7 +2649,7 @@ ClockScan( } if (flags & (CLF_ISO8601WEEK | CLF_ISO8601YEAR)) { if ((flags & (CLF_ISO8601YEAR | CLF_YEAR)) == CLF_YEAR) { - /* for calculations expected iso year */ + /* for calculations expected iso year */ info->date.iso8601Year = yyYear; } else if (info->date.iso8601Year < 100) { if (!(flags & CLF_ISO8601CENTURY)) { @@ -2662,7 +2662,7 @@ ClockScan( } } if ((flags & (CLF_ISO8601YEAR | CLF_YEAR)) == CLF_ISO8601YEAR) { - /* for calculations expected year (e. g. CLF_ISO8601WEEK not set) */ + /* for calculations expected year (e. g. CLF_ISO8601WEEK not set) */ yyYear = info->date.iso8601Year; } } @@ -2862,7 +2862,7 @@ ClockFmtToken_JDN_Proc( fractJD = dateFmt->date.secondOfDay - (int)tok->map->offs; /* 0 for calendar or 43200 for astro JD */ if (fractJD < 0) { - intJD--; + intJD--; fractJD += SECONDS_PER_DAY; } if (fractJD && intJD < 0) { /* avoid jump over 0, by negative JD's */ diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index d2f30dd..cab20b8 100644 --- a/generic/tclCmdAH.c +++ b/generic/tclCmdAH.c @@ -30,7 +30,7 @@ struct ForeachState { Tcl_Size j, maxj; /* Number of loop iterations. */ Tcl_Size numLists; /* Count of value lists. */ Tcl_Size *index; /* Array of value list indices. */ - Tcl_Size *varcList; /* # loop variables per list. */ + Tcl_Size *varcList; /* # loop variables per list. */ Tcl_Obj ***varvList; /* Array of var name lists. */ Tcl_Obj **vCopyList; /* Copies of var name list arguments. */ Tcl_Size *argcList; /* Array of value list sizes. */ diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 2a9d316..a36e349 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -2765,9 +2765,9 @@ StringCmpOpts( return TCL_ERROR; } if ((Tcl_WideUInt)wreqlength > TCL_SIZE_MAX) { - *reqlength = -1; + *reqlength = -1; } else { - *reqlength = wreqlength; + *reqlength = wreqlength; } } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c index 6d3eabd..001310b 100644 --- a/generic/tclCompCmds.c +++ b/generic/tclCompCmds.c @@ -379,9 +379,9 @@ TclCompileArraySetCmd( localIndex = TclFindCompiledLocal(varTokenPtr->start, varTokenPtr->size, 1, envPtr); PushStringLiteral(envPtr, "0"); - TclEmitInstInt4(INST_REVERSE, 2, envPtr); - TclEmitInstInt4(INST_UPVAR, localIndex, envPtr); - TclEmitOpcode(INST_POP, envPtr); + TclEmitInstInt4(INST_REVERSE, 2, envPtr); + TclEmitInstInt4(INST_UPVAR, localIndex, envPtr); + TclEmitOpcode(INST_POP, envPtr); } /* @@ -3415,10 +3415,10 @@ TclCompileFormatCmd( * to a local scalar variable name. * * Results: - * Returns the non-negative integer index value into the table of - * compiled locals corresponding to a local scalar variable name. - * If the arguments passed in do not identify a local scalar variable - * then return TCL_INDEX_NONE. + * Returns the non-negative integer index value into the table of + * compiled locals corresponding to a local scalar variable name. + * If the arguments passed in do not identify a local scalar variable + * then return TCL_INDEX_NONE. * * Side effects: * May add an entry into the table of compiled locals. diff --git a/generic/tclCompile.h b/generic/tclCompile.h index a20f81e..0a9f2a3 100644 --- a/generic/tclCompile.h +++ b/generic/tclCompile.h @@ -34,7 +34,7 @@ struct ByteCode; /* Forward declaration. */ * This variable is linked to the Tcl variable "tcl_traceCompile". */ -MODULE_SCOPE int tclTraceCompile; +MODULE_SCOPE int tclTraceCompile; /* * Variable that controls whether execution tracing is enabled and, if so, @@ -46,7 +46,7 @@ MODULE_SCOPE int tclTraceCompile; * This variable is linked to the Tcl variable "tcl_traceExec". */ -MODULE_SCOPE int tclTraceExec; +MODULE_SCOPE int tclTraceExec; #endif /* @@ -325,13 +325,13 @@ typedef struct CompileEnv { * exceptArrayPtr points in heap, else 0. */ #endif LiteralEntry *literalArrayPtr; - /* Points to start of LiteralEntry array. */ + /* Points to start of LiteralEntry array. */ Tcl_Size literalArrayNext; /* Index of next free object array entry. */ Tcl_Size literalArrayEnd; /* Index just after last obj array entry. */ int mallocedLiteralArray; /* 1 if object array was expanded and objArray * points into the heap, else 0. */ ExceptionRange *exceptArrayPtr; - /* Points to start of the ExceptionRange + /* Points to start of the ExceptionRange * array. */ Tcl_Size exceptArrayNext; /* Next free ExceptionRange array index. * exceptArrayNext is the number of ranges and @@ -482,7 +482,7 @@ typedef struct ByteCode { * array. This is just after the last code * byte. */ ExceptionRange *exceptArrayPtr; - /* Points to the start of the ExceptionRange + /* Points to the start of the ExceptionRange * array. This is just after the last object * in the object array. */ AuxData *auxDataArrayPtr; /* Points to the start of the auxiliary data diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c index a0016df..428a3a6 100644 --- a/generic/tclDictObj.c +++ b/generic/tclDictObj.c @@ -80,7 +80,7 @@ static const EnsembleImplMap implementationMap[] = { {"info", DictInfoCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0 }, {"keys", DictKeysCmd, TclCompileBasic1Or2ArgCmd, NULL, NULL, 0 }, {"lappend", DictLappendCmd, TclCompileDictLappendCmd, NULL, NULL, 0 }, - {"map", NULL, TclCompileDictMapCmd, DictMapNRCmd, NULL, 0 }, + {"map", NULL, TclCompileDictMapCmd, DictMapNRCmd, NULL, 0 }, {"merge", DictMergeCmd, TclCompileDictMergeCmd, NULL, NULL, 0 }, {"remove", DictRemoveCmd, TclCompileBasicMin1ArgCmd, NULL, NULL, 0 }, {"replace", DictReplaceCmd, NULL, NULL, NULL, 0 }, @@ -129,7 +129,7 @@ typedef struct Dict { * the dictionary. Used for doing traversal of * the entries in the order that they are * created. */ - size_t epoch; /* Epoch counter */ + size_t epoch; /* Epoch counter */ size_t refCount; /* Reference counter (see above) */ Tcl_Obj *chain; /* Linked list used for invalidating the * string representations of updated nested diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 176838d..f48bf63 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -4291,7 +4291,7 @@ int TclEncodingProfileNameToId( Tcl_Interp *interp, /* For error messages. May be NULL */ const char *profileName, /* Name of profile */ - int *profilePtr) /* Output */ + int *profilePtr) /* Output */ { size_t i; size_t numProfiles = sizeof(encodingProfiles) / sizeof(encodingProfiles[0]); diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 4b0284f..a0d04e8 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -3951,7 +3951,7 @@ TEBCresume( varPtr = TclObjLookupVarEx(interp, part1Ptr, NULL, 0, NULL, /*createPart1*/1, /*createPart2*/0, &arrayPtr); doConst: - if (TclIsVarConstant(varPtr)) { + if (TclIsVarConstant(varPtr)) { TRACE_APPEND(("\n")); NEXT_INST_V(pcAdjustment, cleanup, 0); } diff --git a/generic/tclIO.c b/generic/tclIO.c index 96a6d33..2000573 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -1530,8 +1530,8 @@ TclGetChannelFromObj( ChanGetInternalRep(objPtr, resPtr); if (resPtr) { /* - * Confirm validity of saved lookup results. - */ + * Confirm validity of saved lookup results. + */ statePtr = resPtr->statePtr; if ((resPtr->interp == interp) /* Same interp context */ @@ -4514,15 +4514,15 @@ Write( flushed += statePtr->bufSize; /* - * We just flushed. So if we have needNlFlush set to record that - * we need to flush because there is a (translated) newline in the - * buffer, that's likely not true any more. But there is a tricky - * exception. If we have saved bytes that did not really get - * flushed and those bytes came from a translation of a newline as - * the last thing taken from the src array, then needNlFlush needs - * to remain set to flag that the next buffer still needs a - * newline flush. - */ + * We just flushed. So if we have needNlFlush set to record that + * we need to flush because there is a (translated) newline in the + * buffer, that's likely not true any more. But there is a tricky + * exception. If we have saved bytes that did not really get + * flushed and those bytes came from a translation of a newline as + * the last thing taken from the src array, then needNlFlush needs + * to remain set to flag that the next buffer still needs a + * newline flush. + */ if (needNlFlush && (saved == 0 || src[-1] != '\n')) { needNlFlush = 0; @@ -10006,12 +10006,12 @@ CopyData( * * Results: * The number of bytes actually stored (<= bytesToRead), - * or TCL_INDEX_NONE if there is an error in reading the channel. Use - * Tcl_GetErrno() to retrieve the error code for the error + * or TCL_INDEX_NONE if there is an error in reading the channel. Use + * Tcl_GetErrno() to retrieve the error code for the error * that occurred. * * The number of bytes stored can be less than the number - * requested when + * requested when * - EOF is reached on the channel; or * - the channel is non-blocking, and we've read all we can * without blocking. @@ -10090,7 +10090,7 @@ DoRead( */ while (!bufPtr || /* We got no buffer! OR */ - (!IsBufferFull(bufPtr) && /* Our buffer has room AND */ + (!IsBufferFull(bufPtr) && /* Our buffer has room AND */ ((Tcl_Size) BytesLeft(bufPtr) < bytesToRead))) { /* Not enough bytes in it yet * to fill the dst */ diff --git a/generic/tclIO.h b/generic/tclIO.h index 8823e06..d1f4a0a 100644 --- a/generic/tclIO.h +++ b/generic/tclIO.h @@ -39,12 +39,12 @@ typedef struct ChannelBuffer { Tcl_Size refCount; /* Current uses count */ Tcl_Size nextAdded; /* The next position into which a character * will be put in the buffer. */ - Tcl_Size nextRemoved; /* Position of next byte to be removed from + Tcl_Size nextRemoved; /* Position of next byte to be removed from * the buffer. */ Tcl_Size bufLength; /* How big is the buffer? */ struct ChannelBuffer *nextPtr; - /* Next buffer in chain. */ - char buf[TCLFLEXARRAY]; /* Placeholder for real buffer. The real + /* Next buffer in chain. */ + char buf[TCLFLEXARRAY]; /* Placeholder for real buffer. The real * buffer occupies this space + bufSize-1 * bytes. This must be the last field in the * structure. */ diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c index 2f3f48e..c7ecb76 100644 --- a/generic/tclIOCmd.c +++ b/generic/tclIOCmd.c @@ -39,7 +39,7 @@ static Tcl_ThreadDataKey dataKey; */ static Tcl_ExitProc FinalizeIOCmdTSD; -static Tcl_TcpAcceptProc AcceptCallbackProc; +static Tcl_TcpAcceptProc AcceptCallbackProc; static Tcl_ObjCmdProc ChanPendingObjCmd; static Tcl_ObjCmdProc ChanTruncateObjCmd; static void RegisterTcpServerInterpCleanup( diff --git a/generic/tclIORTrans.c b/generic/tclIORTrans.c index 2ad6ecf0..0fe9d97 100644 --- a/generic/tclIORTrans.c +++ b/generic/tclIORTrans.c @@ -1374,8 +1374,8 @@ ReflectSeekWide( *errorCodePtr = EINVAL; curPos = -1; } else { - curPos = Tcl_ChannelWideSeekProc(parent->typePtr)(parent->instanceData, offset, - seekMode, errorCodePtr); + curPos = Tcl_ChannelWideSeekProc(parent->typePtr)(parent->instanceData, offset, + seekMode, errorCodePtr); } if (curPos == -1) { Tcl_SetErrno(*errorCodePtr); diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index c3131cd..3ead628 100644 --- a/generic/tclIOUtil.c +++ b/generic/tclIOUtil.c @@ -3464,7 +3464,7 @@ Tcl_LoadFile( static void * DivertFindSymbol( - Tcl_Interp *interp, /* The relevant interpreter. */ + Tcl_Interp *interp, /* The relevant interpreter. */ Tcl_LoadHandle loadHandle, /* A handle to the diverted module. */ const char *symbol) /* The name of symbol to resolve. */ { diff --git a/generic/tclInt.h b/generic/tclInt.h index bb6c4d0..c9ff923 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -1091,10 +1091,10 @@ typedef struct ActiveInterpTrace { * related flag values. * * TCL_TRACE_ENTER_EXEC - triggers enter/enterstep traces. - * - passed to Tcl_CreateObjTrace to set up + * - passed to Tcl_CreateObjTrace to set up * "enterstep" traces. * TCL_TRACE_LEAVE_EXEC - triggers leave/leavestep traces. - * - passed to Tcl_CreateObjTrace to set up + * - passed to Tcl_CreateObjTrace to set up * "leavestep" traces. */ @@ -1546,15 +1546,15 @@ struct CompileEnv; * be one of the following: * * TCL_OK Compilation completed normally. - * TCL_ERROR Compilation could not be completed. This can be just a - * judgment by the CompileProc that the command is too - * complex to compile effectively, or it can indicate - * that in the current state of the interp, the command - * would raise an error. The bytecode compiler will not - * do any error reporting at compiler time. Error - * reporting is deferred until the actual runtime, - * because by then changes in the interp state may allow - * the command to be successfully evaluated. + * TCL_ERROR Compilation could not be completed. This can be just a + * judgment by the CompileProc that the command is too + * complex to compile effectively, or it can indicate + * that in the current state of the interp, the command + * would raise an error. The bytecode compiler will not + * do any error reporting at compiler time. Error + * reporting is deferred until the actual runtime, + * because by then changes in the interp state may allow + * the command to be successfully evaluated. */ typedef int (CompileProc)(Tcl_Interp *interp, Tcl_Parse *parsePtr, @@ -2924,7 +2924,7 @@ typedef struct ProcessGlobalValue { Tcl_Encoding encoding; /* system encoding when global string was * initialized. */ TclInitProcessGlobalValueProc *proc; - /* A procedure to initialize the global string + /* A procedure to initialize the global string * copy when a "get" request comes in before * any "set" request has been received. */ Tcl_Mutex mutex; /* Enforce orderly access from multiple @@ -3486,7 +3486,7 @@ MODULE_SCOPE void TclParseInit(Tcl_Interp *interp, const char *string, MODULE_SCOPE Tcl_Size TclParseAllWhiteSpace(const char *src, Tcl_Size numBytes); MODULE_SCOPE int TclProcessReturn(Tcl_Interp *interp, int code, int level, Tcl_Obj *returnOpts); -MODULE_SCOPE void TclUndoRefCount(Tcl_Obj *objPtr); +MODULE_SCOPE void TclUndoRefCount(Tcl_Obj *objPtr); MODULE_SCOPE int TclpObjLstat(Tcl_Obj *pathPtr, Tcl_StatBuf *buf); MODULE_SCOPE Tcl_Obj * TclpTempFileName(void); MODULE_SCOPE Tcl_Obj * TclpTempFileNameForLibrary(Tcl_Interp *interp, diff --git a/generic/tclListObj.c b/generic/tclListObj.c index 20e85dd..2ffaf87 100644 --- a/generic/tclListObj.c +++ b/generic/tclListObj.c @@ -1668,7 +1668,7 @@ Tcl_ListObjGetElements( return TclObjTypeGetElements(interp, objPtr, objcPtr, objvPtr); } if (TclListObjGetRep(interp, objPtr, &listRep) != TCL_OK) { - return TCL_ERROR; + return TCL_ERROR; } ListRepElements(&listRep, *objcPtr, *objvPtr); return TCL_OK; @@ -1730,8 +1730,8 @@ Tcl_ListObjAppendList( * the passed Tcl_Obj is not a list object, it will be converted to one * and an error raised if the conversion fails. * - * The Tcl_Obj must not be shared though the internal representation - * may be. + * The Tcl_Obj must not be shared though the internal representation + * may be. * * Results: * On success, TCL_OK is returned with the specified elements appended. @@ -1918,27 +1918,23 @@ Tcl_ListObjAppendElement( * * Tcl_ListObjIndex -- * - * Retrieve a pointer to the element of 'listPtr' at 'index'. The index - * of the first element is 0. - * - * Value - * - * TCL_OK + * Retrieve a pointer to the element of 'listPtr' at 'index'. The index + * of the first element is 0. * + * Returns: + * TCL_OK * A pointer to the element at 'index' is stored in 'objPtrPtr'. If * 'index' is out of range, NULL is stored in 'objPtrPtr'. This * object should be treated as readonly and its 'refCount' is _not_ * incremented. The caller must do that if it holds on to the * reference. * - * TCL_ERROR - * - * 'listPtr' is not a valid list. An error message is left in the - * interpreter's result if 'interp' is not NULL. - * - * Effect + * TCL_ERROR + * 'listPtr' is not a valid list. An error message is left in the + * interpreter's result if 'interp' is not NULL. * - * If 'listPtr' is not already of type 'tclListType', it is converted. + * Effect: + * If 'listPtr' is not already of type 'tclListType', it is converted. * *---------------------------------------------------------------------- */ diff --git a/generic/tclProc.c b/generic/tclProc.c index 8e752ed..17f3c06 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -1635,7 +1635,7 @@ static int NRInterpProc( void *clientData, /* Record describing procedure to be * interpreted. */ - Tcl_Interp *interp, /* Interpreter in which procedure was + Tcl_Interp *interp, /* Interpreter in which procedure was * invoked. */ int objc, /* Count of number of arguments to this * procedure. */ diff --git a/generic/tclResult.c b/generic/tclResult.c index f205b47..2baa32c 100644 --- a/generic/tclResult.c +++ b/generic/tclResult.c @@ -760,7 +760,7 @@ TclProcessReturn( Tcl_ListObjReplace(interp, iPtr->errorStack, 0, len, valueObjc, valueObjv); - } + } Tcl_DictObjGet(NULL, iPtr->returnOpts, keys[KEY_ERRORCODE], &valuePtr); if (valuePtr != NULL) { diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c index 59decd9..f6e0e3c 100644 --- a/generic/tclStrToD.c +++ b/generic/tclStrToD.c @@ -124,7 +124,7 @@ typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__))); * Definitions of the parts of an IEEE754-format floating point number. */ -#define SIGN_BIT 0x80000000 +#define SIGN_BIT 0x80000000 /* Mask for the sign bit in the first word of * a double. */ #define EXP_MASK 0x7FF00000 @@ -308,7 +308,7 @@ static double MakeNaN(int signum, Tcl_WideUInt tag); static double RefineApproximation(double approx, mp_int *exactSignificand, int exponent); static mp_err MulPow5(mp_int *, unsigned, mp_int *) MP_WUR; -static int NormalizeRightward(Tcl_WideUInt *); +static int NormalizeRightward(Tcl_WideUInt *); static int RequiredPrecision(Tcl_WideUInt); static void DoubleToExpAndSig(double, Tcl_WideUInt *, int *, int *); @@ -2209,7 +2209,7 @@ RefineApproximation( static inline mp_err MulPow5( - mp_int *base, /* Number to multiply. */ + mp_int *base, /* Number to multiply. */ unsigned n, /* Power of 5 to multiply by. */ mp_int *result) /* Place to store the result. */ { @@ -2706,7 +2706,7 @@ SetPrecisionLimits( static inline char * BumpUp( - char *s, /* Cursor pointing one past the end of the + char *s, /* Cursor pointing one past the end of the * string. */ char *retval, /* Start of the string of digits. */ int *kPtr) /* Position of the decimal point. */ @@ -4154,7 +4154,7 @@ StrictBignumConversion( } err = mp_mul_2d(&b, b2, &b); if (err == MP_OKAY) { - err = mp_init_set(&S, 1); + err = mp_init_set(&S, 1); } if (err == MP_OKAY) { err = MulPow5(&S, s5, &S); diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 5793f65..8b6b719 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -1,24 +1,24 @@ /* * tclStringObj.c -- * - * This file contains functions that implement string operations on Tcl - * objects. Some string operations work with UTF-8 encoding forms. - * Functions that require knowledge of the width of each character, - * such as indexing, operate on fixed width encoding forms such as UTF-32. + * This file contains functions that implement string operations on Tcl + * objects. Some string operations work with UTF-8 encoding forms. + * Functions that require knowledge of the width of each character, + * such as indexing, operate on fixed width encoding forms such as UTF-32. * - * Conceptually, a string is a sequence of Unicode code points. Internally - * it may be stored in an encoding form such as a modified version of - * UTF-8 or UTF-32. + * Conceptually, a string is a sequence of Unicode code points. Internally + * it may be stored in an encoding form such as a modified version of + * UTF-8 or UTF-32. * * The String object is optimized for the case where each UTF char * in a string is only one byte. In this case, we store the value of * numChars, but we don't store the fixed form encoding (unless - * Tcl_GetUnicode is explicitly called). + * Tcl_GetUnicode is explicitly called). * - * The String object type stores one or both formats. The default - * behavior is to store UTF-8. Once UTF-16/UTF32 is calculated, it is - * stored in the internal rep for future access (without an additional - * O(n) cost). + * The String object type stores one or both formats. The default + * behavior is to store UTF-8. Once UTF-16/UTF32 is calculated, it is + * stored in the internal rep for future access (without an additional + * O(n) cost). * * To allow many appends to be done to an object without constantly * reallocating space, we allocate double the space and use the @@ -1322,7 +1322,7 @@ Tcl_AppendUnicodeToObj( const Tcl_UniChar *unicode, /* The Unicode string to append to the * object. */ Tcl_Size length) /* Number of chars in Unicode. Negative - * lengths means nul terminated */ + * lengths means nul terminated */ { String *stringPtr; @@ -2161,7 +2161,7 @@ Tcl_AppendFormatToObj( goto error; } if ((unsigned)code > 0x10FFFF) { - code = 0xFFFD; + code = 0xFFFD; } length = Tcl_UniCharToUtf(code, buf); segment = Tcl_NewStringObj(buf, length); @@ -2989,11 +2989,11 @@ TclGetStringStorage( * Performs the [string repeat] function. * * Results: - * A (Tcl_Obj *) pointing to the result value, or NULL in case of an - * error. + * A (Tcl_Obj *) pointing to the result value, or NULL in case of an + * error. * * Side effects: - * On error, when interp is not NULL, error information is left in it. + * On error, when interp is not NULL, error information is left in it. * *--------------------------------------------------------------------------- */ @@ -3016,8 +3016,8 @@ TclStringRepeat( /* * Analyze to determine what representation result should be. * GOALS: Avoid shimmering & string rep generation. - * Produce pure bytearray when possible. - * Error on overflow. + * Produce pure bytearray when possible. + * Error on overflow. */ if (!binary) { @@ -3144,11 +3144,11 @@ TclStringRepeat( * Performs the [string cat] function. * * Results: - * A (Tcl_Obj *) pointing to the result value, or NULL in case of an - * error. + * A (Tcl_Obj *) pointing to the result value, or NULL in case of an + * error. * * Side effects: - * On error, when interp is not NULL, error information is left in it. + * On error, when interp is not NULL, error information is left in it. * *--------------------------------------------------------------------------- */ @@ -3182,8 +3182,8 @@ TclStringCat( /* * Analyze to determine what representation result should be. * GOALS: Avoid shimmering & string rep generation. - * Produce pure bytearray when possible. - * Error on overflow. + * Produce pure bytearray when possible. + * Error on overflow. */ ov = objv, oc = objc; @@ -3200,10 +3200,10 @@ TclStringCat( * create a pure bytearray. */ - binary = 0; - if (ov > objv+1 && ISCONTINUATION(TclGetString(objPtr))) { - forceUniChar = 1; - } else if ((objPtr->typePtr) && TclHasInternalRep(objPtr, &tclStringType)) { + binary = 0; + if (ov > objv+1 && ISCONTINUATION(TclGetString(objPtr))) { + forceUniChar = 1; + } else if ((objPtr->typePtr) && TclHasInternalRep(objPtr, &tclStringType)) { /* Prevent shimmer of non-string types. */ allowUniChar = 0; } @@ -3302,11 +3302,11 @@ TclStringCat( } while (--oc && (length == 0) && (pendingPtr == NULL)); /* - * Either we found a possibly non-empty value, and we remember - * this index as the first and last such value so far seen, + * Either we found a possibly non-empty value, and we remember + * this index as the first and last such value so far seen, * or (oc == 0) and all values are known empty, - * so first = last = objc - 1 signals the right quick return. - */ + * so first = last = objc - 1 signals the right quick return. + */ first = last = objc - oc - 1; @@ -3417,7 +3417,7 @@ TclStringCat( if (0 == Tcl_AttemptSetObjLength(objResultPtr, length)) { if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "concatenation failed: unable to alloc %" + "concatenation failed: unable to alloc %" TCL_Z_MODIFIER "u bytes", STRING_SIZE(length))); Tcl_SetErrorCode(interp, "TCL", "MEMORY", (char *)NULL); @@ -3434,7 +3434,7 @@ TclStringCat( Tcl_DecrRefCount(objResultPtr); if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "concatenation failed: unable to alloc %" + "concatenation failed: unable to alloc %" TCL_Z_MODIFIER "u bytes", STRING_SIZE(length))); Tcl_SetErrorCode(interp, "TCL", "MEMORY", (char *)NULL); @@ -3466,7 +3466,7 @@ TclStringCat( if (0 == Tcl_AttemptSetObjLength(objResultPtr, length)) { if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "concatenation failed: unable to alloc %" TCL_SIZE_MODIFIER "d bytes", + "concatenation failed: unable to alloc %" TCL_SIZE_MODIFIER "d bytes", length)); Tcl_SetErrorCode(interp, "TCL", "MEMORY", (char *)NULL); } @@ -3481,7 +3481,7 @@ TclStringCat( Tcl_DecrRefCount(objResultPtr); if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "concatenation failed: unable to alloc %" TCL_SIZE_MODIFIER "d bytes", + "concatenation failed: unable to alloc %" TCL_SIZE_MODIFIER "d bytes", length)); Tcl_SetErrorCode(interp, "TCL", "MEMORY", (char *)NULL); } @@ -3957,10 +3957,10 @@ TclStringLast( if (ln == 0) { /* - * We don't find empty substrings. Bizarre! + * We don't find empty substrings. Bizarre! * - * TODO: When we one day make this a true substring - * finder, change this to "return last", after limitation. + * TODO: When we one day make this a true substring + * finder, change this to "return last", after limitation. */ goto lastEnd; } diff --git a/generic/tclUtf.c b/generic/tclUtf.c index 03ea8b6..a0cb936 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -206,13 +206,11 @@ Invalid( Tcl_Size Tcl_UniCharToUtf( - int ch, /* The Tcl_UniChar to be stored in the - * buffer. Can be or'ed with flag TCL_COMBINE. - */ - char *buf) /* Buffer in which the UTF-8 representation of - * ch is stored. Must be large enough to hold the UTF-8 - * character (at most 4 bytes). - */ + int ch, /* The Tcl_UniChar to be stored in the buffer. + * Can be or'ed with flag TCL_COMBINE. */ + char *buf) /* Buffer in which the UTF-8 representation of + * ch is stored. Must be large enough to hold + * the UTF-8 character (at most 4 bytes). */ { int flags = ch; @@ -309,9 +307,9 @@ three: char * Tcl_UniCharToUtfDString( - const int *uniStr, /* Unicode string to convert to UTF-8. */ + const int *uniStr, /* Unicode string to convert to UTF-8. */ Tcl_Size uniLength, /* Length of Unicode string. Negative for nul - * terminated string */ + * terminated string */ Tcl_DString *dsPtr) /* UTF-8 representation of string is appended * to this previously initialized DString. */ { @@ -440,9 +438,9 @@ static const unsigned short cp1252[32] = { Tcl_Size Tcl_UtfToUniChar( - const char *src, /* The UTF-8 string. */ - int *chPtr)/* Filled with the Unicode character represented by - * the UTF-8 string. */ + const char *src, /* The UTF-8 string. */ + int *chPtr) /* Filled with the Unicode character + * represented by the UTF-8 string. */ { int byte; diff --git a/generic/tclUtil.c b/generic/tclUtil.c index c2fa64f..e82eea2 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -158,7 +158,7 @@ TclLengthOne( * \u000A \n NEWLINE * \u000B \v VERTICAL TAB * \u000C \f FORM FEED - * \u000D \r CARRIAGE RETURN + * \u000D \r CARRIAGE RETURN * \u0020 SPACE * * NOTE: differences between this and other places where Tcl defines a role @@ -276,7 +276,7 @@ TclLengthOne( * * The command terminating character, * \u003b ; SEMICOLON * must be BRACEd, QUOTEd, or escaped so that it does not terminate the - * command prematurely. + * command prematurely. * * Any of the characters that begin substitutions in scripts, * \u0024 $ DOLLAR * \u005b [ OPEN BRACKET @@ -1672,7 +1672,7 @@ TclTrimRight( pp = Tcl_UtfPrev(p, bytes); do { pp += pInc; - pInc = TclUtfToUniChar(pp, &ch1); + pInc = TclUtfToUniChar(pp, &ch1); } while (pp + pInc < p); /* @@ -1881,7 +1881,7 @@ Tcl_Concat( for (i = 0; i < argc; i++) { bytesNeeded += strlen(argv[i]); - if (bytesNeeded < 0) { + if (bytesNeeded < 0) { Tcl_Panic("Tcl_Concat: max size of Tcl value exceeded"); } } @@ -3413,19 +3413,19 @@ GetWideForIndex( * list. * * Results: - * TCL_OK + * TCL_OK * - * The index is stored at the address given by by 'indexPtr'. + * The index is stored at the address given by by 'indexPtr'. * - * TCL_ERROR + * TCL_ERROR * - * The value of 'objPtr' does not have one of the expected formats. If - * 'interp' is non-NULL, an error message is left in the interpreter's - * result object. + * The value of 'objPtr' does not have one of the expected formats. If + * 'interp' is non-NULL, an error message is left in the interpreter's + * result object. * * Side effects: * - * The internal representation contained within objPtr may shimmer. + * The internal representation contained within objPtr may shimmer. * *---------------------------------------------------------------------- */ diff --git a/generic/tclVar.c b/generic/tclVar.c index 41bfa39..68d467a 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -6572,7 +6572,7 @@ AppendLocals( && (includeLinks || !TclIsVarLink(varPtr))) { varName = TclGetString(*varNamePtr); if ((pattern == NULL) || Tcl_StringMatch(varName, pattern)) { - if (!justConstants || TclIsVarConstant(varPtr)) { + if (!justConstants || TclIsVarConstant(varPtr)) { Tcl_ListObjAppendElement(interp, listPtr, *varNamePtr); } if (includeLinks) { @@ -6626,7 +6626,7 @@ AppendLocals( objNamePtr = VarHashGetKey(varPtr); varName = TclGetString(objNamePtr); if ((pattern == NULL) || Tcl_StringMatch(varName, pattern)) { - if (!justConstants || TclIsVarConstant(varPtr)) { + if (!justConstants || TclIsVarConstant(varPtr)) { Tcl_ListObjAppendElement(interp, listPtr, objNamePtr); } if (includeLinks) { diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index f09030a..b41126e 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -217,9 +217,9 @@ typedef struct ZipEntry { ZipFile *zipFilePtr; /* The ZIP file holding this virtual file */ size_t offset; /* Data offset into memory mapped ZIP file */ int numBytes; /* Uncompressed size of the virtual file. - * -1 for zip64 */ + * -1 for zip64 */ int numCompressedBytes; /* Compressed size of the virtual file. - * -1 for zip64 */ + * -1 for zip64 */ int compressMethod; /* Compress method */ int isDirectory; /* 0 if file, 1 if directory, -1 if root */ int depth; /* Number of slashes in path. */ @@ -258,7 +258,7 @@ typedef struct ZipChannel { Tcl_Size cursor; /* Seek position for next read or write*/ unsigned char *ubuf; /* Pointer to the uncompressed data */ unsigned char *ubufToFree; /* NULL if ubuf points to memory that does not - need freeing. Else memory to free (ubuf + need freeing. Else memory to free (ubuf may point *inside* the block) */ Tcl_Size ubufSize; /* Size of allocated ubufToFree */ int iscompr; /* True if data is compressed */ diff --git a/generic/tclZlib.c b/generic/tclZlib.c index 0c11bb4..f3a2623 100644 --- a/generic/tclZlib.c +++ b/generic/tclZlib.c @@ -3111,7 +3111,7 @@ ZlibTransformInput( gotBytes = 0; readBytes = chanDataPtr->inStream.avail_in; /* how many bytes in buffer now */ while (!HaveFlag(chanDataPtr, STREAM_DONE) && toRead > 0) { - unsigned int n; + unsigned int n; int decBytes; /* if starting from scratch or continuation after full decompression */ diff --git a/macosx/tclMacOSXNotify.c b/macosx/tclMacOSXNotify.c index d8af241..f7a2324 100644 --- a/macosx/tclMacOSXNotify.c +++ b/macosx/tclMacOSXNotify.c @@ -1683,7 +1683,7 @@ Tcl_Sleep( SInt32 runLoopStatus; waitTime = vdelay.sec + 1.0e-6 * vdelay.usec; - now = CFAbsoluteTimeGetCurrent(); + now = CFAbsoluteTimeGetCurrent(); waitEnd = now + waitTime; if (runLoopTimer) { @@ -1713,7 +1713,7 @@ Tcl_Sleep( } } while (waitTime > 0); tsdPtr->sleeping = 0; - if (runLoopTimer) { + if (runLoopTimer) { CFRunLoopTimerSetNextFireDate(runLoopTimer, nextTimerFire); } } else { diff --git a/unix/tclEpollNotfy.c b/unix/tclEpollNotfy.c index 2a1733a..8cb9166 100644 --- a/unix/tclEpollNotfy.c +++ b/unix/tclEpollNotfy.c @@ -263,7 +263,7 @@ PlatformEventsControl( * None. * * Side effects: - * While tsdPtr->notifierMutex is held: + * While tsdPtr->notifierMutex is held: * - The per-thread eventfd(2) is closed, if non-zero, and set to -1. * - The per-thread epoll(7) fd is closed, if non-zero, and set to 0. * - The per-thread epoll_event structs are freed, if any, and set to 0. diff --git a/unix/tclKqueueNotfy.c b/unix/tclKqueueNotfy.c index ba49842..a99f7bd 100644 --- a/unix/tclKqueueNotfy.c +++ b/unix/tclKqueueNotfy.c @@ -261,7 +261,7 @@ PlatformEventsControl( * None. * * Side effects: - * While tsdPtr->notifierMutex is held: + * While tsdPtr->notifierMutex is held: * The per-thread pipe(2) fds are closed, if non-zero, and set to -1. * The per-thread kqueue(2) fd is closed, if non-zero, and set to 0. * The per-thread kevent structs are freed, if any, and set to 0. diff --git a/unix/tclLoadDl.c b/unix/tclLoadDl.c index 23565c5..07bbc16 100644 --- a/unix/tclLoadDl.c +++ b/unix/tclLoadDl.c @@ -88,14 +88,14 @@ TclpDlopen( * Use (RTLD_NOW|RTLD_LOCAL) as default, see [Bug #3216070] */ if (flags & TCL_LOAD_GLOBAL) { - dlopenflags |= RTLD_GLOBAL; + dlopenflags |= RTLD_GLOBAL; } else { - dlopenflags |= RTLD_LOCAL; + dlopenflags |= RTLD_LOCAL; } if (flags & TCL_LOAD_LAZY) { - dlopenflags |= RTLD_LAZY; + dlopenflags |= RTLD_LAZY; } else { - dlopenflags |= RTLD_NOW; + dlopenflags |= RTLD_NOW; } handle = dlopen(native, dlopenflags); if (handle == NULL) { diff --git a/unix/tclLoadDyld.c b/unix/tclLoadDyld.c index 54290ec..5b1062e 100644 --- a/unix/tclLoadDyld.c +++ b/unix/tclLoadDyld.c @@ -197,14 +197,14 @@ TclpDlopen( */ if (flags & TCL_LOAD_GLOBAL) { - dlopenflags |= RTLD_GLOBAL; + dlopenflags |= RTLD_GLOBAL; } else { - dlopenflags |= RTLD_LOCAL; + dlopenflags |= RTLD_LOCAL; } if (flags & TCL_LOAD_LAZY) { - dlopenflags |= RTLD_LAZY; + dlopenflags |= RTLD_LAZY; } else { - dlopenflags |= RTLD_NOW; + dlopenflags |= RTLD_NOW; } dlHandle = dlopen(nativePath, dlopenflags); if (!dlHandle) { diff --git a/unix/tclUnixFCmd.c b/unix/tclUnixFCmd.c index b65cdb1..fab9c32 100644 --- a/unix/tclUnixFCmd.c +++ b/unix/tclUnixFCmd.c @@ -809,7 +809,7 @@ TclpObjCopyDirectory( * EEXIST: path is a non-empty directory. * EINVAL: path is a root directory. * ENOENT: path doesn't exist or is "". - * ENOTDIR: path is not a directory. + * ENOTDIR: path is not a directory. * * Side effects: * Directory removed. If an error occurs, the error will be returned @@ -953,12 +953,12 @@ TraverseUnixTree( * filled with UTF-8 name of file causing * error. */ int doRewind) /* Flag indicating that to ensure complete - * traversal of source hierarchy, the readdir - * loop should be rewound whenever - * traverseProc has returned TCL_OK; this is - * required when traverseProc modifies the - * source hierarchy, e.g. by deleting - * files. */ + * traversal of source hierarchy, the readdir + * loop should be rewound whenever + * traverseProc has returned TCL_OK; this is + * required when traverseProc modifies the + * source hierarchy, e.g. by deleting + * files. */ { Tcl_StatBuf statBuf; const char *source, *errfile; diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c index 984ee2f..8ffea58 100644 --- a/unix/tclUnixNotfy.c +++ b/unix/tclUnixNotfy.c @@ -360,12 +360,12 @@ AlertSingleThread( */ if (tsdPtr->prevPtr) { - tsdPtr->prevPtr->nextPtr = tsdPtr->nextPtr; + tsdPtr->prevPtr->nextPtr = tsdPtr->nextPtr; } else { - waitingListPtr = tsdPtr->nextPtr; + waitingListPtr = tsdPtr->nextPtr; } if (tsdPtr->nextPtr) { - tsdPtr->nextPtr->prevPtr = tsdPtr->prevPtr; + tsdPtr->nextPtr->prevPtr = tsdPtr->prevPtr; } tsdPtr->nextPtr = tsdPtr->prevPtr = NULL; tsdPtr->onList = 0; diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c index 78ed008..11193b7 100644 --- a/unix/tclUnixSock.c +++ b/unix/tclUnixSock.c @@ -204,8 +204,8 @@ printaddrinfo( * * InitializeHostName -- * - * This routine sets the process global value of the name of the local - * host on which the process is running. + * This routine sets the process global value of the name of the local + * host on which the process is running. * * Results: * None. @@ -400,8 +400,8 @@ TcpBlockModeProc( * return any error code. * * Results: - * 0 if the connection has completed, -1 if still in progress or there is - * an error. + * 0 if the connection has completed, -1 if still in progress or there is + * an error. * * Side effects: * Processes socket events off the system queue. May process @@ -1183,7 +1183,7 @@ TcpWatchProc( * from interfering with the -accept behavior (bug #3394732). */ - return; + return; } if (GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING)) { diff --git a/unix/tclUnixTime.c b/unix/tclUnixTime.c index 20b9a67..29146aa 100644 --- a/unix/tclUnixTime.c +++ b/unix/tclUnixTime.c @@ -246,7 +246,7 @@ TclpWideClicksToNanoseconds( * and back. * * Results: - * 1 click in microseconds as double. + * 1 click in microseconds as double. * * Side effects: * None. diff --git a/win/tclWinConsole.c b/win/tclWinConsole.c index 8b289b1..d7be807 100644 --- a/win/tclWinConsole.c +++ b/win/tclWinConsole.c @@ -176,7 +176,7 @@ typedef struct ConsoleHandleInfo { * is queued and dropped on receipt. */ typedef struct ConsoleChannelInfo { - HANDLE handle; /* Console handle */ + HANDLE handle; /* Console handle */ Tcl_ThreadId threadId; /* Id of owning thread */ struct ConsoleChannelInfo *nextWatchingChannelPtr; /* Pointer to next channel watching events. */ diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index dbf3324..c4b60b9 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -1462,7 +1462,7 @@ QuoteCmdLineBackslash( Tcl_DStringAppend(dsPtr, start, (int) (current - start)); } } else { - if (bspos > start) { /* part before first backslash */ + if (bspos > start) { /* part before first backslash */ Tcl_DStringAppend(dsPtr, start, (int) (bspos - start)); } while (bspos++ < current) { /* each backslash twice */ @@ -1505,7 +1505,7 @@ QuoteCmdLinePart( TclDStringAppendLiteral(dsPtr, "\""); /* opening escape quote-char */ do { - *bspos = NULL; + *bspos = NULL; special++; if (*special == '\\') { /* @@ -1810,7 +1810,7 @@ TclpCreateCommandChannel( SetThreadPriority(infoPtr->readThread, THREAD_PRIORITY_HIGHEST); infoPtr->validMask |= TCL_READABLE; } else { - infoPtr->readTI = NULL; + infoPtr->readTI = NULL; infoPtr->readThread = 0; } if (writeFile != NULL) { @@ -1825,8 +1825,8 @@ TclpCreateCommandChannel( SetThreadPriority(infoPtr->writeThread, THREAD_PRIORITY_HIGHEST); infoPtr->validMask |= TCL_WRITABLE; } else { - infoPtr->writeTI = NULL; - infoPtr->writeThread = 0; + infoPtr->writeTI = NULL; + infoPtr->writeThread = 0; } /* @@ -3397,10 +3397,10 @@ TclPipeThreadWaitForSignal( if (state != PTI_STATE_STOP) { *pipeTIPtr = NULL; } else { - pipeTI->evWakeUp = NULL; + pipeTI->evWakeUp = NULL; } if (wakeEvent) { - SetEvent(wakeEvent); + SetEvent(wakeEvent); } return 0; } diff --git a/win/tclWinPort.h b/win/tclWinPort.h index 8ab4548..0f22138 100644 --- a/win/tclWinPort.h +++ b/win/tclWinPort.h @@ -114,7 +114,7 @@ typedef DWORD_PTR * PDWORD_PTR; */ #ifndef ENOTEMPTY -# define ENOTEMPTY 41 /* Directory not empty */ +# define ENOTEMPTY 41 /* Directory not empty */ #endif #ifndef EREMOTE # define EREMOTE 66 /* The object is remote */ diff --git a/win/tclWinSerial.c b/win/tclWinSerial.c index e27937e..2ce432c 100644 --- a/win/tclWinSerial.c +++ b/win/tclWinSerial.c @@ -620,7 +620,7 @@ SerialCloseProc( serialPtr->validMask &= ~TCL_READABLE; if (serialPtr->writeThread) { - TclPipeThreadStop(&serialPtr->writeTI, serialPtr->writeThread); + TclPipeThreadStop(&serialPtr->writeTI, serialPtr->writeThread); CloseHandle(serialPtr->osWrite.hEvent); CloseHandle(serialPtr->evWritable); diff --git a/win/tclWinSock.c b/win/tclWinSock.c index c05f550..5239cd3 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -618,8 +618,8 @@ TcpBlockModeProc( * return any error code. * * Results: - * 0 if the connection has completed, -1 if still in progress or there is - * an error. + * 0 if the connection has completed, -1 if still in progress or there is + * an error. * * Side effects: * Processes socket events off the system queue. May process diff --git a/win/tclWinTime.c b/win/tclWinTime.c index 5636dc0..8cc4489 100644 --- a/win/tclWinTime.c +++ b/win/tclWinTime.c @@ -35,7 +35,7 @@ typedef struct { HANDLE readyEvent; /* System event used to trigger the requesting * thread when the clock calibration procedure * is initialized for the first time. */ - HANDLE exitEvent; /* Event to signal out of an exit handler to + HANDLE exitEvent; /* Event to signal out of an exit handler to * tell the calibration loop to terminate. */ LARGE_INTEGER nominalFreq; /* Nominal frequency of the system performance * counter, that is, the value returned from @@ -109,7 +109,7 @@ static struct { static void StopCalibration(void *clientData); static DWORD WINAPI CalibrationThread(LPVOID arg); -static void UpdateTimeEachSecond(void); +static void UpdateTimeEachSecond(void); static void ResetCounterSamples(unsigned long long fileTime, long long perfCounter, long long perfFreq); static long long AccumulateSample(long long perfCounter, @@ -278,7 +278,7 @@ TclpGetWideClicks(void) wideClick.microsecsScale = 1; return TclpGetMicroseconds(); } else { - return TclpGetMicroseconds(); + return TclpGetMicroseconds(); } } @@ -292,7 +292,7 @@ TclpGetWideClicks(void) * and back. * * Results: - * 1 click in microseconds as double. + * 1 click in microseconds as double. * * Side effects: * None. @@ -304,7 +304,7 @@ double TclpWideClickInMicrosec(void) { if (!wideClick.initialized) { - (void) TclpGetWideClicks(); /* initialize */ + (void) TclpGetWideClicks(); /* initialize */ } return wideClick.microsecsScale; } @@ -870,7 +870,7 @@ UpdateTimeEachSecond(void) if (curFileTime.QuadPart > lastFileTime.QuadPart && curFileTime.QuadPart < lastFileTime.QuadPart + (timeInfo.calibrationInterv * 10000000)) { - /* + /* * Look again in next one second. */ @@ -940,13 +940,13 @@ UpdateTimeEachSecond(void) tdiff = vt0 - curFileTime.QuadPart; if (tdiff > 10000000 || tdiff < -10000000) { - /* + /* * Jump to current system time, use curent estimated frequency. */ - vt0 = curFileTime.QuadPart; + vt0 = curFileTime.QuadPart; } else { - /* + /* * Calculate new frequency and estimate drift to the next second. */ @@ -1015,11 +1015,11 @@ UpdateTimeEachSecond(void) vt1 = vt0 - curFileTime.QuadPart; if (vt1 > 10000000 || vt1 < -10000000) { - /* + /* * Larger jump resp. shift relative new file-time. */ - vt0 = curFileTime.QuadPart; + vt0 = curFileTime.QuadPart; } } } -- cgit v0.12 From 514638fd758486513ea7eb842bb8972fd854ca06 Mon Sep 17 00:00:00 2001 From: dkf Date: Tue, 4 Jun 2024 15:54:35 +0000 Subject: Make function definitions have right argument style --- generic/tclClockFmt.c | 10 +++++++--- generic/tclDictObj.c | 3 ++- generic/tclEncoding.c | 3 ++- generic/tclExecute.c | 6 ++++-- generic/tclListObj.c | 26 +++++++++++++++++++------- generic/tclZipfs.c | 12 +++++++----- unix/tclUnixFile.c | 5 +++-- win/tclWinConsole.c | 3 ++- 8 files changed, 46 insertions(+), 22 deletions(-) diff --git a/generic/tclClockFmt.c b/generic/tclClockFmt.c index ea5f0a5..fead7fd 100644 --- a/generic/tclClockFmt.c +++ b/generic/tclClockFmt.c @@ -1241,9 +1241,13 @@ ObjListSearch( /* currently unused */ static int -LocaleListSearch(ClockFmtScnCmdArgs *opts, - DateInfo *info, int mcKey, int *val, - int minLen, int maxLen) +LocaleListSearch( + ClockFmtScnCmdArgs *opts, + DateInfo *info, + int mcKey, + int *val, + int minLen, + int maxLen) { Tcl_Obj **lstv; Tcl_Size lstc; diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c index 428a3a6..ea989be 100644 --- a/generic/tclDictObj.c +++ b/generic/tclDictObj.c @@ -1058,7 +1058,8 @@ Tcl_DictObjRemove( */ Tcl_Size -TclDictGetSize(Tcl_Obj *dictPtr) +TclDictGetSize( + Tcl_Obj *dictPtr) { Dict *dict; DictGetInternalRep(dictPtr, dict); diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index f48bf63..129ca51 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -4373,7 +4373,8 @@ TclEncodingProfileIdToName( *------------------------------------------------------------------------ */ void -TclGetEncodingProfiles(Tcl_Interp *interp) +TclGetEncodingProfiles( + Tcl_Interp *interp) { size_t i, n; Tcl_Obj *objPtr; diff --git a/generic/tclExecute.c b/generic/tclExecute.c index a0d04e8..5d4bff3 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -7865,8 +7865,10 @@ FinalizeOONextFilter( * Helper to calculate small powers of integers whose result is wide. */ static inline Tcl_WideInt -WidePwrSmallExpon(Tcl_WideInt w1, long exponent) { - +WidePwrSmallExpon( + Tcl_WideInt w1, + long exponent) +{ Tcl_WideInt wResult; wResult = w1 * w1; /* b**2 */ diff --git a/generic/tclListObj.c b/generic/tclListObj.c index 2ffaf87..683a0e7 100644 --- a/generic/tclListObj.c +++ b/generic/tclListObj.c @@ -266,7 +266,8 @@ ListSpanNew( *------------------------------------------------------------------------ */ static inline void -ListSpanDecrRefs(ListSpan *spanPtr) +ListSpanDecrRefs( + ListSpan *spanPtr) { if (spanPtr->refCount <= 1) { Tcl_Free(spanPtr); @@ -343,7 +344,8 @@ ListSpanMerited( *------------------------------------------------------------------------ */ static inline void -ListRepFreeUnreferenced(const ListRep *repPtr) +ListRepFreeUnreferenced( + const ListRep *repPtr) { if (! ListRepIsShared(repPtr) && repPtr->spanPtr) { /* T:listrep-1.5.1 */ @@ -492,7 +494,8 @@ MemoryAllocationError( *------------------------------------------------------------------------ */ static int -ListLimitExceededError(Tcl_Interp *interp) +ListLimitExceededError( + Tcl_Interp *interp) { if (interp != NULL) { Tcl_SetObjResult( @@ -523,7 +526,9 @@ ListLimitExceededError(Tcl_Interp *interp) *------------------------------------------------------------------------ */ static inline void -ListRepUnsharedShiftDown(ListRep *repPtr, Tcl_Size shiftCount) +ListRepUnsharedShiftDown( + ListRep *repPtr, + Tcl_Size shiftCount) { ListStore *storePtr; @@ -578,7 +583,9 @@ ListRepUnsharedShiftDown(ListRep *repPtr, Tcl_Size shiftCount) */ #if 0 static inline void -ListRepUnsharedShiftUp(ListRep *repPtr, Tcl_Size shiftCount) +ListRepUnsharedShiftUp( + ListRep *repPtr, + Tcl_Size shiftCount) { ListStore *storePtr; @@ -624,7 +631,10 @@ ListRepUnsharedShiftUp(ListRep *repPtr, Tcl_Size shiftCount) *------------------------------------------------------------------------ */ static void -ListRepValidate(const ListRep *repPtr, const char *file, int lineNum) +ListRepValidate( + const ListRep *repPtr, + const char *file, + int lineNum) { ListStore *storePtr = repPtr->storePtr; const char *condition; @@ -689,7 +699,9 @@ failure: *------------------------------------------------------------------------ */ void -TclListObjValidate(Tcl_Interp *interp, Tcl_Obj *listObj) +TclListObjValidate( + Tcl_Interp *interp, + Tcl_Obj *listObj) { ListRep listRep; if (TclListObjGetRep(interp, listObj, &listRep) != TCL_OK) { diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index b41126e..4fef38c 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -875,7 +875,7 @@ static char * DecodeZipEntryText( const unsigned char *inputBytes, unsigned int inputLength, - Tcl_DString *dstPtr) /* Must have been initialized by caller! */ + Tcl_DString *dstPtr) /* Must have been initialized by caller! */ { Tcl_Encoding encoding; const char *src; @@ -980,9 +980,10 @@ DecodeZipEntryText( *------------------------------------------------------------------------ */ static int -NormalizeMountPoint(Tcl_Interp *interp, - const char *mountPath, - Tcl_DString *dsPtr) /* Must be initialized by caller! */ +NormalizeMountPoint( + Tcl_Interp *interp, + const char *mountPath, + Tcl_DString *dsPtr) /* Must be initialized by caller! */ { const char *joiner[2]; char *joinedPath; @@ -2230,7 +2231,8 @@ ListMountPoints( *------------------------------------------------------------------------ */ static void -CleanupMount(ZipFile *zf) /* Mount point */ +CleanupMount( + ZipFile *zf) /* Mount point */ { ZipEntry *z, *znext; Tcl_HashEntry *hPtr; diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c index 93f6aa8..e91ed41 100644 --- a/unix/tclUnixFile.c +++ b/unix/tclUnixFile.c @@ -13,8 +13,9 @@ #include "tclInt.h" #include "tclFileSystem.h" -static int NativeMatchType(Tcl_Interp *interp, const char* nativeEntry, - const char* nativeName, Tcl_GlobTypeData *types); +static int NativeMatchType(Tcl_Interp *interp, + const char* nativeEntry, const char* nativeName, + Tcl_GlobTypeData *types); /* *--------------------------------------------------------------------------- diff --git a/win/tclWinConsole.c b/win/tclWinConsole.c index d7be807..a498200 100644 --- a/win/tclWinConsole.c +++ b/win/tclWinConsole.c @@ -2067,7 +2067,8 @@ AllocateConsoleHandleInfo( *------------------------------------------------------------------------ */ static ConsoleHandleInfo * -FindConsoleInfo(const ConsoleChannelInfo *chanInfoPtr) +FindConsoleInfo( + const ConsoleChannelInfo *chanInfoPtr) { ConsoleHandleInfo *handleInfoPtr; for (handleInfoPtr = gConsoleHandleInfoList; handleInfoPtr; handleInfoPtr = handleInfoPtr->nextPtr) { -- cgit v0.12 From 9d4f0b95ebcb92f94f3e4895af5014c458d68519 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 5 Jun 2024 13:10:11 +0000 Subject: More of the same: Space before tab is extremely unlikely to be correct indentation pattern. --- compat/fake-rfc2553.c | 38 +++++++++++++++---------------- generic/regc_color.c | 6 ++--- generic/regc_locale.c | 36 +++++++++++++++--------------- generic/regc_nfa.c | 54 ++++++++++++++++++++++----------------------- generic/regcomp.c | 8 +++---- generic/rege_dfa.c | 6 ++--- generic/tclDate.c | 2 +- generic/tclGetDate.y | 2 +- generic/tclScan.c | 2 +- generic/tclTest.c | 27 +++++++++++------------ generic/tclThreadTest.c | 2 +- library/auto.tcl | 12 +++++----- library/clock.tcl | 20 ++++++++--------- library/history.tcl | 2 +- library/http/http.tcl | 8 +++---- library/opt/optparse.tcl | 2 +- library/package.tcl | 4 ++-- library/platform/shell.tcl | 44 ++++++++++++++++++------------------ library/tcltest/tcltest.tcl | 6 ++--- tools/index.tcl | 6 ++--- tools/makeTestCases.tcl | 4 ++-- tools/tclOOScript.tcl | 6 ++--- tools/tcltk-man2html.tcl | 4 ++-- unix/Makefile.in | 2 +- unix/configure | 4 ++-- unix/configure.ac | 2 +- unix/dltest/embtest.c | 2 +- unix/tcl.m4 | 2 +- unix/tclUnixTest.c | 4 ++-- win/Makefile.in | 10 ++++----- win/makefile.vc | 2 +- win/rules.vc | 2 +- win/tcl.rc | 14 ++++++------ win/tclsh.rc | 14 ++++++------ win/tcltest.rc | 14 ++++++------ 35 files changed, 186 insertions(+), 187 deletions(-) diff --git a/compat/fake-rfc2553.c b/compat/fake-rfc2553.c index cfe4c39..066f83f 100644 --- a/compat/fake-rfc2553.c +++ b/compat/fake-rfc2553.c @@ -43,32 +43,32 @@ TCL_DECLARE_MUTEX(netdbMutex) static size_t strlcpy(char *dst, const char *src, size_t siz) { - char *d = dst; - const char *s = src; - size_t n = siz; + char *d = dst; + const char *s = src; + size_t n = siz; - /* Copy as many bytes as will fit */ - if (n != 0 && --n != 0) { - do { - if ((*d++ = *s++) == 0) - break; - } while (--n != 0); - } + /* Copy as many bytes as will fit */ + if (n != 0 && --n != 0) { + do { + if ((*d++ = *s++) == 0) + break; + } while (--n != 0); + } - /* Not enough room in dst, add NUL and traverse rest of src */ - if (n == 0) { - if (siz != 0) - *d = '\0'; /* NUL-terminate dst */ - while (*s++) - ; - } + /* Not enough room in dst, add NUL and traverse rest of src */ + if (n == 0) { + if (siz != 0) + *d = '\0'; /* NUL-terminate dst */ + while (*s++) + ; + } - return(s - src - 1); /* count does not include NUL */ + return(s - src - 1); /* count does not include NUL */ } #endif int fake_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, - size_t hostlen, char *serv, size_t servlen, int flags) + size_t hostlen, char *serv, size_t servlen, int flags) { struct sockaddr_in *sin = (struct sockaddr_in *)sa; struct hostent *hp; diff --git a/generic/regc_color.c b/generic/regc_color.c index f1e25d2..ccb1826 100644 --- a/generic/regc_color.c +++ b/generic/regc_color.c @@ -430,7 +430,7 @@ newsub( /* - subrange - allocate new subcolors to this range of chrs, fill in arcs ^ static void subrange(struct vars *, pchr, pchr, struct state *, - ^ struct state *); + ^ struct state *); */ static void subrange( @@ -689,7 +689,7 @@ uncolorchain( /* - rainbow - add arcs of all full colors (but one) between specified states ^ static void rainbow(struct nfa *, struct colormap *, int, pcolor, - ^ struct state *, struct state *); + ^ struct state *, struct state *); */ static void rainbow( @@ -716,7 +716,7 @@ rainbow( - colorcomplement - add arcs of complementary colors * The calling sequence ought to be reconciled with cloneouts(). ^ static void colorcomplement(struct nfa *, struct colormap *, int, - ^ struct state *, struct state *, struct state *); + ^ struct state *, struct state *, struct state *); */ static void colorcomplement( diff --git a/generic/regc_locale.c b/generic/regc_locale.c index b6687f3..6613e69 100644 --- a/generic/regc_locale.c +++ b/generic/regc_locale.c @@ -1187,24 +1187,24 @@ cclass( } break; case CC_PRINT: - cv = getcvec(v, NUM_SPACE_CHAR + NUM_GRAPH_CHAR, NUM_SPACE_RANGE + NUM_GRAPH_RANGE - 1); - if (cv) { - for (i=1 ; ifrom->no > bb->from->no) { - return 1; + return 1; } if (aa->co < bb->co) { - return -1; + return -1; } if (aa->co > bb->co) { - return 1; + return 1; } if (aa->type < bb->type) { - return -1; + return -1; } if (aa->type > bb->type) { - return 1; + return 1; } return 0; } @@ -1118,7 +1118,7 @@ copyouts( cparc(nfa, a, newState, a->to); } } else { - /* + /* * With many arcs, use a sort-merge approach. Note that createarc() * will put new arcs onto the front of newState's chain, so it does * not break our walk through the sorted part of the chain. @@ -1177,7 +1177,7 @@ copyouts( /* - cloneouts - copy out arcs of a state to another state pair, modifying type ^ static void cloneouts(struct nfa *, struct state *, struct state *, - ^ struct state *, int); + ^ struct state *, int); */ static void cloneouts( @@ -1267,7 +1267,7 @@ deltraverse( * well as mark already-seen states. (You knew there was a reason why it's a * state pointer, didn't you? :-)) ^ static void dupnfa(struct nfa *, struct state *, struct state *, - ^ struct state *, struct state *); + ^ struct state *, struct state *); */ static void dupnfa( @@ -1599,10 +1599,10 @@ pull( s->tmp = *intermediates; *intermediates = s; } - cparc(nfa, con, a->from, s); + cparc(nfa, con, a->from, s); cparc(nfa, a, s, to); - freearc(nfa, a); - break; + freearc(nfa, a); + break; default: assert(NOTREACHED); break; @@ -1779,9 +1779,9 @@ push( *intermediates = s; } cparc(nfa, con, s, a->to); - cparc(nfa, a, from, s); - freearc(nfa, a); - break; + cparc(nfa, a, from, s); + freearc(nfa, a); + break; default: assert(NOTREACHED); break; @@ -2021,11 +2021,11 @@ fixempties( } } - /* Reset the tmp fields as we walk back */ - nexts = s2->tmp; - s2->tmp = NULL; - } - s->tmp = NULL; + /* Reset the tmp fields as we walk back */ + nexts = s2->tmp; + s2->tmp = NULL; + } + s->tmp = NULL; assert(arccount <= totalinarcs); /* Remember how many original inarcs this state has */ @@ -2185,12 +2185,12 @@ fixconstraintloops( freearc(nfa, a); } else { hasconstraints = 1; - } + } } } - /* If we removed all the outarcs, the state is useless. */ - if (s->nouts == 0 && !s->flag) { - dropstate(nfa, s); + /* If we removed all the outarcs, the state is useless. */ + if (s->nouts == 0 && !s->flag) { + dropstate(nfa, s); } } @@ -2235,7 +2235,7 @@ fixconstraintloops( } if (f != NULL) { - dumpnfa(nfa, f); + dumpnfa(nfa, f); } } @@ -2725,7 +2725,7 @@ cleanup( /* - markreachable - recursive marking of reachable states ^ static void markreachable(struct nfa *, struct state *, struct state *, - ^ struct state *); + ^ struct state *); */ static void markreachable( @@ -2749,7 +2749,7 @@ markreachable( /* - markcanreach - recursive marking of states which can reach here ^ static void markcanreach(struct nfa *, struct state *, struct state *, - ^ struct state *); + ^ struct state *); */ static void markcanreach( diff --git a/generic/regcomp.c b/generic/regcomp.c index 012e37c..949f397 100644 --- a/generic/regcomp.c +++ b/generic/regcomp.c @@ -644,7 +644,7 @@ makesearch( * together with '|'. They appear in the tree as the left children of a chain * of '|' subres. ^ static struct subre *parse(struct vars *, int, int, struct state *, - ^ struct state *); + ^ struct state *); */ static struct subre * parse( @@ -726,7 +726,7 @@ parse( * Concatenated things are bundled up as much as possible, with separate * ',' nodes introduced only when necessary due to substructure. ^ static struct subre *parsebranch(struct vars *, int, int, struct state *, - ^ struct state *, int); + ^ struct state *, int); */ static struct subre * parsebranch( @@ -775,7 +775,7 @@ parsebranch( * particular, it contains a recursion that can involve parsing the rest of * the branch, making this function's name somewhat inaccurate. ^ static void parseqatom(struct vars *, int, int, struct state *, - ^ struct state *, struct subre *); + ^ struct state *, struct subre *); */ static void parseqatom( @@ -1649,7 +1649,7 @@ onechr( /* - dovec - fill in arcs for each element of a cvec ^ static void dovec(struct vars *, struct cvec *, struct state *, - ^ struct state *); + ^ struct state *); */ static void dovec( diff --git a/generic/rege_dfa.c b/generic/rege_dfa.c index 5d49aa5..c8c74f0 100644 --- a/generic/rege_dfa.c +++ b/generic/rege_dfa.c @@ -159,7 +159,7 @@ longest( /* - shortest - shortest-preferred matching engine ^ static chr *shortest(struct vars *, struct dfa *, chr *, chr *, chr *, - ^ chr **, int *); + ^ chr **, int *); */ static chr * /* endpoint, or NULL */ shortest( @@ -308,7 +308,7 @@ lastCold( /* - newDFA - set up a fresh DFA ^ static struct dfa *newDFA(struct vars *, struct cnfa *, - ^ struct colormap *, struct smalldfa *); + ^ struct colormap *, struct smalldfa *); */ static struct dfa * newDFA( @@ -477,7 +477,7 @@ initialize( /* - miss - handle a cache miss ^ static struct sset *miss(struct vars *, struct dfa *, struct sset *, - ^ pcolor, chr *, chr *); + ^ pcolor, chr *, chr *); */ static struct sset * /* NULL if goes to empty set */ miss( diff --git a/generic/tclDate.c b/generic/tclDate.c index a22168f..312a000 100644 --- a/generic/tclDate.c +++ b/generic/tclDate.c @@ -2649,7 +2649,7 @@ TclClockFreeScan( /* parse */ status = yyparse(info); if (status == 1) { - const char *msg = NULL; + const char *msg = NULL; if (info->errFlags & CLF_HAVEDATE) { msg = "more than one date in string"; } else if (info->errFlags & CLF_TIME) { diff --git a/generic/tclGetDate.y b/generic/tclGetDate.y index 3b04de4..301bf9d 100644 --- a/generic/tclGetDate.y +++ b/generic/tclGetDate.y @@ -1025,7 +1025,7 @@ TclClockFreeScan( /* parse */ status = yyparse(info); if (status == 1) { - const char *msg = NULL; + const char *msg = NULL; if (info->errFlags & CLF_HAVEDATE) { msg = "more than one date in string"; } else if (info->errFlags & CLF_TIME) { diff --git a/generic/tclScan.c b/generic/tclScan.c index 9a9e773..4ffe177 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -368,7 +368,7 @@ ValidateFormat( ull, (Tcl_Size)TCL_SIZE_MAX-1)); Tcl_SetErrorCode( - interp, "TCL", "FORMAT", "WIDTHLIMIT", (void *)NULL); + interp, "TCL", "FORMAT", "WIDTHLIMIT", (char *)NULL); goto error; } flags |= SCAN_WIDTH; diff --git a/generic/tclTest.c b/generic/tclTest.c index 795310d..0bb09f6 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -2070,7 +2070,7 @@ static void SpecialFree( * these functions (i/o command cannot test all combinations) * The arguments at the script level are roughly those of the above * functions: - * encodingname srcbytes flags state dstlen ?srcreadvar? ?dstwrotevar? ?dstcharsvar? + * encodingname srcbytes flags state dstlen ?srcreadvar? ?dstwrotevar? ?dstcharsvar? * * Results: * TCL_OK or TCL_ERROR. This any errors running the test, NOT the @@ -3754,7 +3754,7 @@ TestlinkarrayCmd( i++; } if (Tcl_GetIndexFromObj(interp, objv[i++], LinkType, "type", 0, - &typeIndex) != TCL_OK) { + &typeIndex) != TCL_OK) { return TCL_ERROR; } if (Tcl_GetIntFromObj(interp, objv[i++], &size) == TCL_ERROR) { @@ -3769,7 +3769,7 @@ TestlinkarrayCmd( if (i < objc) { if (Tcl_GetWideIntFromObj(interp, objv[i], &addr) == TCL_ERROR) { - Tcl_SetObjResult(interp, Tcl_NewStringObj( + Tcl_SetObjResult(interp, Tcl_NewStringObj( "wrong address value", -1)); return TCL_ERROR; } @@ -8531,15 +8531,15 @@ InterpCompiledVarResolver( Tcl_ResolvedVarInfo **rPtr) { if (*name == 'T') { - MyResolvedVarInfo *resVarInfo = (MyResolvedVarInfo *)Tcl_Alloc(sizeof(MyResolvedVarInfo)); - - resVarInfo->vInfo.fetchProc = MyCompiledVarFetch; - resVarInfo->vInfo.deleteProc = MyCompiledVarFree; - resVarInfo->var = NULL; - resVarInfo->nameObj = Tcl_NewStringObj(name, -1); - Tcl_IncrRefCount(resVarInfo->nameObj); - *rPtr = &resVarInfo->vInfo; - return TCL_OK; + MyResolvedVarInfo *resVarInfo = (MyResolvedVarInfo *)Tcl_Alloc(sizeof(MyResolvedVarInfo)); + + resVarInfo->vInfo.fetchProc = MyCompiledVarFetch; + resVarInfo->vInfo.deleteProc = MyCompiledVarFree; + resVarInfo->var = NULL; + resVarInfo->nameObj = Tcl_NewStringObj(name, -1); + Tcl_IncrRefCount(resVarInfo->nameObj); + *rPtr = &resVarInfo->vInfo; + return TCL_OK; } return TCL_CONTINUE; } @@ -8656,8 +8656,7 @@ int TestApplyLambdaObjCmd ( * - The body of the lambda (lambdaObjs[1]) ALREADY has internal * representation of ByteCode and thus will not be compiled again */ - evalObjs[1] = lambdaObj; /* lambdaObj already has a ref count so - no need for IncrRef */ + evalObjs[1] = lambdaObj; /* lambdaObj already has a ref count so no need for IncrRef */ result = Tcl_EvalObjv(interp, 2, evalObjs, TCL_EVAL_GLOBAL); Tcl_DecrRefCount(evalObjs[0]); Tcl_DecrRefCount(lambdaObj); diff --git a/generic/tclThreadTest.c b/generic/tclThreadTest.c index e4a9312..49d9cf2 100644 --- a/generic/tclThreadTest.c +++ b/generic/tclThreadTest.c @@ -985,7 +985,7 @@ ThreadCancel( Tcl_MutexUnlock(&threadMutex); Tcl_ResetResult(interp); return Tcl_CancelEval(tsdPtr->interp, - (result != NULL) ? Tcl_NewStringObj(result, -1) : NULL, 0, flags); + (result != NULL) ? Tcl_NewStringObj(result, -1) : NULL, 0, flags); } /* diff --git a/library/auto.tcl b/library/auto.tcl index 824cdac..cc779cf 100644 --- a/library/auto.tcl +++ b/library/auto.tcl @@ -45,7 +45,7 @@ proc auto_reset {} { # initialization script and set a global library variable. # # Arguments: -# basename Prefix of the directory name, (e.g., "tk") +# basename Prefix of the directory name, (e.g., "tk") # version Version number of the package, (e.g., "8.0") # patch Patchlevel of the package, (e.g., "8.0.3") # initScript Initialization script to source (e.g., tk.tcl) @@ -130,7 +130,7 @@ proc tcl_findLibrary {basename version patch initScript enVarName varName} { } else { catch {zipfs unmount $mountpoint} } - } + } } } } @@ -480,9 +480,9 @@ proc auto_mkindex_parser::childhook {cmd} { # "tclIndex" file for auto-loading. # # Arguments: -# name Name of command recognized in Tcl files. +# name Name of command recognized in Tcl files. # arglist Argument list for command. -# body Implementation of command to handle indexing. +# body Implementation of command to handle indexing. proc auto_mkindex_parser::command {name arglist body} { hook [list auto_mkindex_parser::commandInit $name $arglist $body] @@ -494,9 +494,9 @@ proc auto_mkindex_parser::command {name arglist body} { # called when the interpreter used by the parser is created. # # Arguments: -# name Name of command recognized in Tcl files. +# name Name of command recognized in Tcl files. # arglist Argument list for command. -# body Implementation of command to handle indexing. +# body Implementation of command to handle indexing. proc auto_mkindex_parser::commandInit {name arglist body} { variable parser diff --git a/library/clock.tcl b/library/clock.tcl index ef82372..83c6e61 100644 --- a/library/clock.tcl +++ b/library/clock.tcl @@ -140,9 +140,9 @@ proc ::tcl::clock::Initialize {} { Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec } MONTHS_FULL { - January February March - April May June - July August September + January February March + April May June + July August September October November December } PM {pm} @@ -292,7 +292,7 @@ proc ::tcl::clock::Initialize {} { # The keys are long lists of values obtained from the time zone # information in the Registry. In order, the list elements are: - # Bias StandardBias DaylightBias + # Bias StandardBias DaylightBias # StandardDate.wYear StandardDate.wMonth StandardDate.wDayOfWeek # StandardDate.wDay StandardDate.wHour StandardDate.wMinute # StandardDate.wSecond StandardDate.wMilliseconds @@ -339,7 +339,7 @@ proc ::tcl::clock::Initialize {} { {3600 0 3600 0 10 0 5 3 0 0 0 0 3 0 5 2 0 0 0} :CET {7200 0 3600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0} :Africa/Harare {7200 0 3600 0 9 4 5 23 59 59 0 0 4 4 5 23 59 59 0} - :Africa/Cairo + :Africa/Cairo {7200 0 3600 0 10 0 5 4 0 0 0 0 3 0 5 3 0 0 0} :Europe/Helsinki {7200 0 3600 0 9 0 3 2 0 0 0 0 3 5 5 2 0 0 0} :Asia/Jerusalem {7200 0 3600 0 9 0 5 1 0 0 0 0 3 0 5 0 0 0 0} :Europe/Bucharest @@ -480,9 +480,9 @@ proc ::tcl::clock::Initialize {} { variable LocFmtMap [dict create]; # Dictionary with localized format maps variable TimeZoneBad [dict create]; # Dictionary whose keys are time zone - # names and whose values are 1 if + # names and whose values are 1 if # the time zone is unknown and 0 - # if it is known. + # if it is known. variable TZData; # Array whose keys are time zone names # and whose values are lists of quads # comprising start time, UTC offset, @@ -518,7 +518,7 @@ proc ::tcl::clock::mcget {loc} { set loc [mclocale] } if {$loc ne {}} { - set loc [string tolower $loc] + set loc [string tolower $loc] } # try to retrieve now if already available: @@ -651,7 +651,7 @@ proc ::tcl::clock::GetSystemLocale {} { proc ::tcl::clock::EnterLocale { locale } { switch -- $locale system { - set locale [GetSystemLocale] + set locale [GetSystemLocale] } current { set locale [mclocale] } @@ -1001,7 +1001,7 @@ proc ::tcl::clock::SetupTimeZone { timezone {alias {}} } { LoadZoneinfoFile [string range $timezone 1 end] }] } then { - dict set TimeZoneBad $timezone 1 + dict set TimeZoneBad $timezone 1 return -code error \ -errorcode [list CLOCK badTimeZone $timezone] \ "time zone \"$timezone\" not found" diff --git a/library/history.tcl b/library/history.tcl index e3d3fe4..ec59ac7 100644 --- a/library/history.tcl +++ b/library/history.tcl @@ -89,7 +89,7 @@ trace add command ::history delete [list apply {{oldName newName op} { # exec (optional) a substring of "exec" causes the command to # be evaled. # Results: -# If executing, then the results of the command are returned +# If executing, then the results of the command are returned # # Side Effects: # Adds to the history list diff --git a/library/http/http.tcl b/library/http/http.tcl index d53ecef..63c2403 100644 --- a/library/http/http.tcl +++ b/library/http/http.tcl @@ -2449,7 +2449,7 @@ proc http::Connected {token proto phost srvurl} { if {[info exists state(reusing)] && $state(reusing)} { # The socket was closed at the server end, and closed at # this end by http::CheckEof. - if {[TestForReplay $token write $err a]} { + if {[TestForReplay $token write $err a]} { return } else { Finish $token {failed to re-use socket} @@ -3396,7 +3396,7 @@ proc http::cleanup {token} { # # Side Effects # Sets the status of the connection, which unblocks -# the waiting geturl call +# the waiting geturl call proc http::Connect {token proto phost srvurl} { variable $token @@ -4925,7 +4925,7 @@ proc http::ReceiveChunked {chan command} { } # http::SplitCommaSeparatedFieldValue -- -# Return the individual values of a comma-separated field value. +# Return the individual values of a comma-separated field value. # # Arguments: # fieldValue Comma-separated header field value. @@ -4942,7 +4942,7 @@ proc http::SplitCommaSeparatedFieldValue {fieldValue} { # http::GetFieldValue -- -# Return the value of a header field. +# Return the value of a header field. # # Arguments: # headers Headers key-value list diff --git a/library/opt/optparse.tcl b/library/opt/optparse.tcl index 0a6cdfa..d8883fe 100644 --- a/library/opt/optparse.tcl +++ b/library/opt/optparse.tcl @@ -811,7 +811,7 @@ proc ::tcl::OptCheckType {arg type {typeArgs ""}} { # Auto magic lazy type determination proc OptGuessType {arg} { - if { $arg == "true" || $arg == "false" } { + if { $arg == "true" || $arg == "false" } { return boolean } if {[string is integer -strict $arg]} { diff --git a/library/package.tcl b/library/package.tcl index 17ace66..118beef 100644 --- a/library/package.tcl +++ b/library/package.tcl @@ -504,7 +504,7 @@ proc tclPkgUnknown {name args} { # In case of version conflict, silently ignore continue } - tclLog "error reading package index file $file: $msg" + tclLog "error reading package index file $file: $msg" } on ok {} { set procdDirs($dir) 1 } @@ -612,7 +612,7 @@ proc tcl::MacOSXPkgUnknown {original name args} { continue } on error msg { if {[regexp {version conflict for package} $msg]} { - # In case of version conflict, silently ignore + # In case of version conflict, silently ignore continue } tclLog "error reading package index file $file: $msg" diff --git a/library/platform/shell.tcl b/library/platform/shell.tcl index 60d5b37..a91849c 100644 --- a/library/platform/shell.tcl +++ b/library/platform/shell.tcl @@ -163,34 +163,34 @@ proc ::platform::shell::TEMP {} { set checked_dir_writable 0 set mypid [pid] for {set i 0} {$i < $maxtries} {incr i} { - set newname $prefix - for {set j 0} {$j < $nrand_chars} {incr j} { - append newname [string index $chars \ + set newname $prefix + for {set j 0} {$j < $nrand_chars} {incr j} { + append newname [string index $chars \ [expr {int(rand()*62)}]] - } + } set newname [file join $tmpdir $newname] - if {[file exists $newname]} { - after 1 - } else { - if {[catch {open $newname $access $permission} channel]} { - if {!$checked_dir_writable} { - set dirname [file dirname $newname] - if {![file writable $dirname]} { - return -code error "Directory $dirname is not writable" - } - set checked_dir_writable 1 - } - } else { - # Success + if {[file exists $newname]} { + after 1 + } else { + if {[catch {open $newname $access $permission} channel]} { + if {!$checked_dir_writable} { + set dirname [file dirname $newname] + if {![file writable $dirname]} { + return -code error "Directory $dirname is not writable" + } + set checked_dir_writable 1 + } + } else { + # Success close $channel - return [file normalize $newname] - } - } + return [file normalize $newname] + } + } } if {$channel ne ""} { - return -code error "Failed to open a temporary file: $channel" + return -code error "Failed to open a temporary file: $channel" } else { - return -code error "Failed to find an unused temporary file name" + return -code error "Failed to find an unused temporary file name" } } diff --git a/library/tcltest/tcltest.tcl b/library/tcltest/tcltest.tcl index 2fc5838..3cb5e2d 100644 --- a/library/tcltest/tcltest.tcl +++ b/library/tcltest/tcltest.tcl @@ -515,7 +515,7 @@ namespace eval tcltest { unset $varName } namespace eval [namespace current] \ - [list upvar 0 Option($option) $varName] + [list upvar 0 Option($option) $varName] # Workaround for Bug (now Feature Request) 572889. Grrrr.... # Track all the variables tied to options lappend OptionControlledVariables $varName @@ -1914,7 +1914,7 @@ proc tcltest::SubstArguments {argList} { # Arguments: # name - Name of test, in the form foo-1.2. # description - Short textual description of the test, to -# help humans understand what it does. +# help humans understand what it does. # # Results: # None. @@ -2128,7 +2128,7 @@ proc tcltest::test {name description args} { # check if the answer matched the expected answer # Only check if we ran the body of the test (no setup failure) if {!$processTest} { - set scriptFailure 0 + set scriptFailure 0 } elseif {$setupFailure || $codeFailure} { set scriptFailure 0 } elseif {[set scriptCompare [catch { diff --git a/tools/index.tcl b/tools/index.tcl index 07f5868..5426ee6 100644 --- a/tools/index.tcl +++ b/tools/index.tcl @@ -14,12 +14,12 @@ # state - state variable that controls action of text proc. # # topics - array indexed by (package,section,topic) with value -# of topic ID. +# of topic ID. # # keywords - array indexed by keyword string with value of topic ID. # -# curID - current topic ID, starts at 0 and is incremented for -# each new topic file. +# curID - current topic ID, starts at 0 and is incremented for +# each new topic file. # # curPkg - current package name (e.g. Tcl). # diff --git a/tools/makeTestCases.tcl b/tools/makeTestCases.tcl index 1eae645..d1221b8 100755 --- a/tools/makeTestCases.tcl +++ b/tools/makeTestCases.tcl @@ -215,7 +215,7 @@ proc testcases2 { f2 } { # Define the roman numerals set roman { - ? i ii iii iv v vi vii viii ix + ? i ii iii iv v vi vii viii ix x xi xii xiii xiv xv xvi xvii xviii xix xx xxi xxii xxiii xxiv xxv xxvi xxvii xxviii xxix xxx xxxi xxxii xxxiii xxxiv xxxv xxxvi xxxvii xxxviii xxxix @@ -228,7 +228,7 @@ proc testcases2 { f2 } { c } set romanc { - ? c cc ccc cd d dc dcc dccc cm + ? c cc ccc cd d dc dcc dccc cm m mc mcc mccc mcd md mdc mdcc mdccc mcm mm mmc mmcc mmccc mmcd mmd mmdc mmdcc mmdccc mmcm mmm mmmc mmmcc mmmccc mmmcd mmmd mmmdc mmmdcc mmmdccc mmmcm diff --git a/tools/tclOOScript.tcl b/tools/tclOOScript.tcl index 0b75882..0cbe5b7 100644 --- a/tools/tclOOScript.tcl +++ b/tools/tclOOScript.tcl @@ -1,8 +1,8 @@ # tclOOScript.h -- # -# This file contains support scripts for TclOO. They are defined here so -# that the code can be definitely run even in safe interpreters; TclOO's -# core setup is safe. +# This file contains support scripts for TclOO. They are defined here so +# that the code can be definitely run even in safe interpreters; TclOO's +# core setup is safe. # # Copyright © 2012-2019 Donal K. Fellows # Copyright © 2013 Andreas Kupries diff --git a/tools/tcltk-man2html.tcl b/tools/tcltk-man2html.tcl index 7b3558d..01478aa 100755 --- a/tools/tcltk-man2html.tcl +++ b/tools/tcltk-man2html.tcl @@ -610,8 +610,8 @@ array set remap_link_target { Tcl_Obj Tcl_NewObj Tcl_ObjType Tcl_RegisterObjType Tcl_OpenFileChannelProc Tcl_FSOpenFileChannel - errorinfo env - errorcode env + errorinfo env + errorcode env tcl_pkgpath env Tcl_Command Tcl_CreateObjCommand Tcl_CmdProc Tcl_CreateObjCommand diff --git a/unix/Makefile.in b/unix/Makefile.in index 093edf8..29d3228 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -4,7 +4,7 @@ # "./configure", which is a configuration script generated by the "autoconf" # program (constructs like "@foo@" will get replaced in the actual Makefile. -VERSION = @TCL_VERSION@ +VERSION = @TCL_VERSION@ MAJOR_VERSION = @TCL_MAJOR_VERSION@ MINOR_VERSION = @TCL_MINOR_VERSION@ PATCH_LEVEL = @TCL_PATCH_LEVEL@ diff --git a/unix/configure b/unix/configure index b470e3c..2ef18ad 100755 --- a/unix/configure +++ b/unix/configure @@ -5796,7 +5796,7 @@ then : ;; *) # Make sure only first arg gets _r - CC=`echo "$CC" | sed -e 's/^\([^ ]*\)/\1_r/'` + CC=`echo "$CC" | sed -e 's/^\([^ ]*\)/\1_r/'` ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Using $CC for compiling with threads" >&5 @@ -10016,7 +10016,7 @@ int main (void) { - socklen_t foo; + socklen_t foo; ; return 0; diff --git a/unix/configure.ac b/unix/configure.ac index 766392e..f2a1b58 100644 --- a/unix/configure.ac +++ b/unix/configure.ac @@ -404,7 +404,7 @@ AC_CACHE_CHECK([for socklen_t], tcl_cv_type_socklen_t, [ #include #include ]], [[ - socklen_t foo; + socklen_t foo; ]])],[tcl_cv_type_socklen_t=yes],[tcl_cv_type_socklen_t=no])]) if test $tcl_cv_type_socklen_t = no; then AC_DEFINE(socklen_t, int, [Define as int if socklen_t is not available]) diff --git a/unix/dltest/embtest.c b/unix/dltest/embtest.c index ff58cc4..33f77a0 100644 --- a/unix/dltest/embtest.c +++ b/unix/dltest/embtest.c @@ -34,7 +34,7 @@ int main(int argc, char **argv) { exitcode = 1; } if (!exitcode) { - printf("All OK!\n"); + printf("All OK!\n"); } return exitcode; } diff --git a/unix/tcl.m4 b/unix/tcl.m4 index 7b84923..2b2299e 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -990,7 +990,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ ;; *) # Make sure only first arg gets _r - CC=`echo "$CC" | sed -e 's/^\([[^ ]]*\)/\1_r/'` + CC=`echo "$CC" | sed -e 's/^\([[^ ]]*\)/\1_r/'` ;; esac AC_MSG_RESULT([Using $CC for compiling with threads]) diff --git a/unix/tclUnixTest.c b/unix/tclUnixTest.c index b204c77..26c590d 100644 --- a/unix/tclUnixTest.c +++ b/unix/tclUnixTest.c @@ -549,7 +549,7 @@ TestalarmCmd( * None. * * Side effects: - * Calls the Tcl Async handler. + * Calls the Tcl Async handler. * *---------------------------------------------------------------------- */ @@ -566,7 +566,7 @@ AlarmHandler( * * TestgotsigCmd -- * - * Verify the signal was handled after the testalarm command. + * Verify the signal was handled after the testalarm command. * * Results: * None. diff --git a/win/Makefile.in b/win/Makefile.in index 18ce10d..0773bce 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -79,10 +79,10 @@ CFLAGS_OPTIMIZE = @CFLAGS_OPTIMIZE@ # To change the compiler switches, for example to change from optimization to # debugging symbols, change the following line: -#CFLAGS = $(CFLAGS_DEBUG) -#CFLAGS = $(CFLAGS_OPTIMIZE) -#CFLAGS = $(CFLAGS_DEBUG) $(CFLAGS_OPTIMIZE) -CFLAGS = @CFLAGS@ @CFLAGS_DEFAULT@ -DMP_FIXED_CUTOFFS -D__USE_MINGW_ANSI_STDIO=0 +#CFLAGS = $(CFLAGS_DEBUG) +#CFLAGS = $(CFLAGS_OPTIMIZE) +#CFLAGS = $(CFLAGS_DEBUG) $(CFLAGS_OPTIMIZE) +CFLAGS = @CFLAGS@ @CFLAGS_DEFAULT@ -DMP_FIXED_CUTOFFS -D__USE_MINGW_ANSI_STDIO=0 # To compile without backward compatibility and deprecated code uncomment the # following @@ -162,7 +162,7 @@ TEST_LOAD_FACILITIES = package ifneeded tcl::test ${VERSION}@TCL_PATCH_LEVEL@ [l ZLIB_DLL_FILE = zlib1.dll TOMMATH_DLL_FILE = libtommath.dll -SHARED_LIBRARIES = $(TCL_DLL_FILE) @ZLIB_DLL_FILE@ @TOMMATH_DLL_FILE@ +SHARED_LIBRARIES = $(TCL_DLL_FILE) @ZLIB_DLL_FILE@ @TOMMATH_DLL_FILE@ STATIC_LIBRARIES = $(TCL_LIB_FILE) TCLSH = tclsh$(VER)${EXESUFFIX} diff --git a/win/makefile.vc b/win/makefile.vc index 2a35668..d2826ea 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -57,7 +57,7 @@ # Any combination of the above may be used (comma separated). # 'none' will over-ride everything to nothing. # -# noembed = Without this option, the Tcl core library scripts +# noembed = Without this option, the Tcl core library scripts # are embedded into the executable if "static" is # specified in OPTS, or into the DLL otherwise. If # "noembed" is specified, the scripts are not embedded diff --git a/win/rules.vc b/win/rules.vc index 143ea9e..f1bcf4c 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -1248,7 +1248,7 @@ TKSTUBLIBNAME = tkstub.lib !endif !if $(DOING_TK) -WISH = $(OUT_DIR)\$(WISHNAME) +WISH = $(OUT_DIR)\$(WISHNAME) TKSTUBLIB = $(OUT_DIR)\$(TKSTUBLIBNAME) TKIMPLIB = $(OUT_DIR)\$(TKIMPLIBNAME) TKLIB = $(OUT_DIR)\$(TKLIBNAME) diff --git a/win/tcl.rc b/win/tcl.rc index 3d125f2..1ea6208 100644 --- a/win/tcl.rc +++ b/win/tcl.rc @@ -19,17 +19,17 @@ LANGUAGE 0x9, 0x1 /* LANG_ENGLISH, SUBLANG_DEFAULT */ VS_VERSION_INFO VERSIONINFO - FILEVERSION TCL_MAJOR_VERSION,TCL_MINOR_VERSION,TCL_RELEASE_LEVEL,TCL_RELEASE_SERIAL + FILEVERSION TCL_MAJOR_VERSION,TCL_MINOR_VERSION,TCL_RELEASE_LEVEL,TCL_RELEASE_SERIAL PRODUCTVERSION TCL_MAJOR_VERSION,TCL_MINOR_VERSION,TCL_RELEASE_LEVEL,TCL_RELEASE_SERIAL - FILEFLAGSMASK 0x3fL + FILEFLAGSMASK 0x3fL #ifdef DEBUG - FILEFLAGS VS_FF_DEBUG + FILEFLAGS VS_FF_DEBUG #else - FILEFLAGS 0x0L + FILEFLAGS 0x0L #endif - FILEOS VOS__WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE 0x0L + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN diff --git a/win/tclsh.rc b/win/tclsh.rc index f439d08..77d2d73 100644 --- a/win/tclsh.rc +++ b/win/tclsh.rc @@ -26,17 +26,17 @@ LANGUAGE 0x9, 0x1 /* LANG_ENGLISH, SUBLANG_DEFAULT */ VS_VERSION_INFO VERSIONINFO - FILEVERSION TCL_MAJOR_VERSION,TCL_MINOR_VERSION,TCL_RELEASE_LEVEL,TCL_RELEASE_SERIAL + FILEVERSION TCL_MAJOR_VERSION,TCL_MINOR_VERSION,TCL_RELEASE_LEVEL,TCL_RELEASE_SERIAL PRODUCTVERSION TCL_MAJOR_VERSION,TCL_MINOR_VERSION,TCL_RELEASE_LEVEL,TCL_RELEASE_SERIAL - FILEFLAGSMASK 0x3fL + FILEFLAGSMASK 0x3fL #ifdef DEBUG - FILEFLAGS VS_FF_DEBUG + FILEFLAGS VS_FF_DEBUG #else - FILEFLAGS 0x0L + FILEFLAGS 0x0L #endif - FILEOS VOS__WINDOWS32 - FILETYPE VFT_APP - FILESUBTYPE 0x0L + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN diff --git a/win/tcltest.rc b/win/tcltest.rc index 847a250..ea55a62 100644 --- a/win/tcltest.rc +++ b/win/tcltest.rc @@ -26,17 +26,17 @@ LANGUAGE 0x9, 0x1 /* LANG_ENGLISH, SUBLANG_DEFAULT */ VS_VERSION_INFO VERSIONINFO - FILEVERSION TCL_MAJOR_VERSION,TCL_MINOR_VERSION,TCL_RELEASE_LEVEL,TCL_RELEASE_SERIAL + FILEVERSION TCL_MAJOR_VERSION,TCL_MINOR_VERSION,TCL_RELEASE_LEVEL,TCL_RELEASE_SERIAL PRODUCTVERSION TCL_MAJOR_VERSION,TCL_MINOR_VERSION,TCL_RELEASE_LEVEL,TCL_RELEASE_SERIAL - FILEFLAGSMASK 0x3fL + FILEFLAGSMASK 0x3fL #ifdef DEBUG - FILEFLAGS VS_FF_DEBUG + FILEFLAGS VS_FF_DEBUG #else - FILEFLAGS 0x0L + FILEFLAGS 0x0L #endif - FILEOS VOS__WINDOWS32 - FILETYPE VFT_APP - FILESUBTYPE 0x0L + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN -- cgit v0.12 From 8635b3e8449e007fa9e3ccf2ef94b3e905edd730 Mon Sep 17 00:00:00 2001 From: dkf Date: Wed, 5 Jun 2024 14:12:19 +0000 Subject: A clearer way of writing what parity options are available --- unix/tclUnixChan.c | 52 ++++++++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c index edb1edb..12366ac 100644 --- a/unix/tclUnixChan.c +++ b/unix/tclUnixChan.c @@ -162,15 +162,15 @@ static int TtySetOptionProc(void *instanceData, static const Tcl_ChannelType fileChannelType = { "file", /* Type name. */ TCL_CHANNEL_VERSION_5, /* v5 channel */ - NULL, /* Close proc. */ + NULL, /* Deprecated close proc. */ FileInputProc, /* Input proc. */ FileOutputProc, /* Output proc. */ - NULL, + NULL, NULL, /* Set option proc. */ FileGetOptionProc, /* Get option proc. */ FileWatchProc, /* Initialize notifier. */ FileGetHandleProc, /* Get OS handles out of channel. */ - FileCloseProc, /* close2proc. */ + FileCloseProc, /* Close proc. */ FileBlockModeProc, /* Set blocking or non-blocking mode.*/ NULL, /* flush proc. */ NULL, /* handler proc. */ @@ -188,7 +188,7 @@ static const Tcl_ChannelType fileChannelType = { static const Tcl_ChannelType ttyChannelType = { "tty", /* Type name. */ TCL_CHANNEL_VERSION_5, /* v5 channel */ - NULL, /* Close proc. */ + NULL, /* Deprecated close proc. */ FileInputProc, /* Input proc. */ FileOutputProc, /* Output proc. */ NULL, /* Seek proc. */ @@ -196,7 +196,7 @@ static const Tcl_ChannelType ttyChannelType = { TtyGetOptionProc, /* Get option proc. */ FileWatchProc, /* Initialize notifier. */ FileGetHandleProc, /* Get OS handles out of channel. */ - TtyCloseProc, /* close2proc. */ + TtyCloseProc, /* Close proc. */ FileBlockModeProc, /* Set blocking or non-blocking mode.*/ NULL, /* flush proc. */ NULL, /* handler proc. */ @@ -225,7 +225,7 @@ static const Tcl_ChannelType ttyChannelType = { static int FileBlockModeProc( - void *instanceData, /* File state. */ + void *instanceData, /* File state. */ int mode) /* The mode to set. Can be TCL_MODE_BLOCKING * or TCL_MODE_NONBLOCKING. */ { @@ -258,7 +258,7 @@ FileBlockModeProc( static int FileInputProc( - void *instanceData, /* File state. */ + void *instanceData, /* File state. */ char *buf, /* Where to store data read. */ int toRead, /* How much space is available in the * buffer? */ @@ -308,7 +308,7 @@ FileInputProc( static int FileOutputProc( - void *instanceData, /* File state. */ + void *instanceData, /* File state. */ const char *buf, /* The data buffer. */ int toWrite, /* How many bytes to write? */ int *errorCodePtr) /* Where to store error code. */ @@ -355,7 +355,7 @@ FileOutputProc( static int FileCloseProc( - void *instanceData, /* File state. */ + void *instanceData, /* File state. */ TCL_UNUSED(Tcl_Interp *), int flags) { @@ -448,7 +448,7 @@ TtyCloseProc( static long long FileWideSeekProc( - void *instanceData, /* File state. */ + void *instanceData, /* File state. */ long long offset, /* Offset to seek to. */ int mode, /* Relative to where should we seek? Can be * one of SEEK_START, SEEK_CUR or SEEK_END. */ @@ -496,7 +496,7 @@ FileWatchNotifyChannelWrapper( static void FileWatchProc( - void *instanceData, /* The file state. */ + void *instanceData, /* The file state. */ int mask) /* Events of interest; an OR-ed combination of * TCL_READABLE, TCL_WRITABLE and * TCL_EXCEPTION. */ @@ -536,9 +536,9 @@ FileWatchProc( static int FileGetHandleProc( - void *instanceData, /* The file state. */ + void *instanceData, /* The file state. */ int direction, /* TCL_READABLE or TCL_WRITABLE */ - void **handlePtr) /* Where to store the handle. */ + void **handlePtr) /* Where to store the handle. */ { FileState *fsPtr = (FileState *)instanceData; @@ -758,7 +758,7 @@ TtyModemStatusStr( static int TtySetOptionProc( - void *instanceData, /* File state. */ + void *instanceData, /* File state. */ Tcl_Interp *interp, /* For error reporting - can be NULL. */ const char *optionName, /* Which option to set? */ const char *value) /* New value for option. */ @@ -1098,7 +1098,7 @@ TtySetOptionProc( static int TtyGetOptionProc( - void *instanceData, /* File state. */ + void *instanceData, /* File state. */ Tcl_Interp *interp, /* For error reporting - can be NULL. */ const char *optionName, /* Option to get. */ Tcl_DString *dsPtr) /* Where to store value(s). */ @@ -1637,22 +1637,18 @@ TtyParseMode( * not allow preprocessor directives in their arguments. */ - if ( -#if defined(PAREXT) - strchr("noems", parity) +#ifdef PAREXT +#define PARITY_CHARS "noems" +#define PARITY_MSG "n, o, e, m, or s" #else - strchr("noe", parity) +#define PARITY_CHARS "noe" +#define PARITY_MSG "n, o, or e" #endif /* PAREXT */ - == NULL) { + + if (strchr(PARITY_CHARS, parity) == NULL) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "%s parity: should be %s", bad, -#if defined(PAREXT) - "n, o, e, m, or s" -#else - "n, o, or e" -#endif /* PAREXT */ - )); + "%s parity: should be %s", bad, PARITY_MSG)); Tcl_SetErrorCode(interp, "TCL", "VALUE", "SERIALMODE", (char *)NULL); } return TCL_ERROR; @@ -2054,7 +2050,7 @@ Tcl_GetOpenFile( * Ignored, we always check that * the channel is open for the requested * mode. */ - void **filePtr) /* Store pointer to FILE structure here. */ + void **filePtr) /* Store pointer to FILE structure here. */ { Tcl_Channel chan; int chanMode, fd; -- cgit v0.12 From c5dbe187dec4a867f29ea96e01eb2185bc550409 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Thu, 6 Jun 2024 10:03:52 +0000 Subject: Fix one int -> Tcl_Size --- generic/tclListObj.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/generic/tclListObj.c b/generic/tclListObj.c index 683a0e7..483426d 100644 --- a/generic/tclListObj.c +++ b/generic/tclListObj.c @@ -2925,7 +2925,7 @@ TclLsetFlat( result = TCL_OK; /* Allocate if static array for pending invalidations is too small */ - if (indexCount > (int) (sizeof(pendingInvalidates) / + if (indexCount > (Tcl_Size) (sizeof(pendingInvalidates) / sizeof(pendingInvalidates[0]))) { pendingInvalidatesPtr = (Tcl_Obj **) Tcl_Alloc(indexCount * sizeof(*pendingInvalidatesPtr)); @@ -3032,9 +3032,8 @@ TclLsetFlat( * value of the lset variable. Later on, when we set valueObj * in its proper place, then all containing lists will have * their values changed, and will need their string reps - * spoiled. We maintain a list of all those Tcl_Obj's (via a - * little internalrep surgery) so we can spoil them at that - * time. + * spoiled. We maintain a list of all those Tcl_Obj's + * pendingInvalidatesPtr[] so we can spoil them at that time. */ pendingInvalidatesPtr[numPendingInvalidates] = parentList; -- cgit v0.12 From ba13c1f02f09fe1bb79ff75711b25b1d92bd5f08 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 7 Jun 2024 11:26:32 +0000 Subject: Fix CFLAGS=-ftrapv build --- generic/tclUtil.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/generic/tclUtil.c b/generic/tclUtil.c index b87b5d6..a3bfc09 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -3706,6 +3706,8 @@ GetEndOffsetFromObj( * as endValue will have to adjust accordingly. */ *widePtr = (endValue == -1) ? WIDE_MAX : endValue + 1; + } else if (offset == WIDE_MIN) { + *widePtr = (endValue == -1) ? WIDE_MIN : -1; } else if (offset < 0) { /* end-(n-1) - Different signs, sum cannot overflow */ *widePtr = endValue + offset + 1; -- cgit v0.12 From 46032e05dfc4e85c88751208d6c4aa931437680b Mon Sep 17 00:00:00 2001 From: dkf Date: Sun, 9 Jun 2024 10:33:06 +0000 Subject: Simpler commenting of Tcl_ChannelType instances; make zip channel type const --- generic/tclIO.c | 7 +++--- generic/tclIO.h | 9 ++++---- generic/tclIOGT.c | 38 +++++++++++++++---------------- generic/tclIORChan.c | 46 +++++++++++++++++++------------------- generic/tclIORTrans.c | 36 +++++++++++++++--------------- generic/tclZipfs.c | 40 ++++++++++++++++----------------- generic/tclZlib.c | 14 ++++++------ unix/tclUnixChan.c | 62 +++++++++++++++++++++++++-------------------------- unix/tclUnixPipe.c | 30 ++++++++++++------------- unix/tclUnixSock.c | 32 +++++++++++++------------- win/tclWinChan.c | 32 +++++++++++++------------- win/tclWinConsole.c | 34 ++++++++++++++-------------- win/tclWinPipe.c | 30 ++++++++++++------------- win/tclWinSerial.c | 32 +++++++++++++------------- win/tclWinSock.c | 32 +++++++++++++------------- 15 files changed, 237 insertions(+), 237 deletions(-) diff --git a/generic/tclIO.c b/generic/tclIO.c index 2000573..4859bc1 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -1599,7 +1599,7 @@ Tcl_Channel Tcl_CreateChannel( const Tcl_ChannelType *typePtr, /* The channel type record. */ const char *chanName, /* Name of channel to record. */ - void *instanceData, /* Instance specific data. */ + void *instanceData, /* Instance specific data. */ int mask) /* TCL_READABLE & TCL_WRITABLE to indicate if * the channel is readable, writable. */ { @@ -1809,7 +1809,7 @@ Tcl_StackChannel( const Tcl_ChannelType *typePtr, /* The channel type record for the new * channel. */ - void *instanceData, /* Instance specific data for the new + void *instanceData, /* Instance specific data for the new * channel. */ int mask, /* TCL_READABLE & TCL_WRITABLE to indicate if * the channel is readable, writable. */ @@ -10762,7 +10762,8 @@ Tcl_IsChannelExisting( const char * Tcl_ChannelName( - const Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ + const Tcl_ChannelType *chanTypePtr) + /* Pointer to channel type. */ { return chanTypePtr->typeName; } diff --git a/generic/tclIO.h b/generic/tclIO.h index d1f4a0a..711863b 100644 --- a/generic/tclIO.h +++ b/generic/tclIO.h @@ -96,7 +96,7 @@ typedef struct EventScriptRecord { typedef struct Channel { struct ChannelState *state; /* Split out state information */ - void *instanceData; /* Instance-specific data provided by creator + void *instanceData; /* Instance-specific data provided by creator * of channel. */ const Tcl_ChannelType *typePtr; /* Pointer to channel type structure. */ struct Channel *downChanPtr;/* Refers to channel this one was stacked @@ -160,7 +160,8 @@ typedef struct ChannelState { * input. */ #if TCL_MAJOR_VERSION < 9 int outEofChar; /* If nonzero, append this to the channel when - * it is closed if it is open for writing. For Tcl 8.x only */ + * it is closed if it is open for writing. + * For Tcl 8.x only */ #endif int unreportedError; /* Non-zero if an error report was deferred * because it happened in the background. The @@ -214,8 +215,8 @@ typedef struct ChannelState { * precedence over a Posix error code returned by a channel operation. */ - Tcl_Obj* chanMsg; - Tcl_Obj* unreportedMsg; /* Non-NULL if an error report was deferred + Tcl_Obj *chanMsg; + Tcl_Obj *unreportedMsg; /* Non-NULL if an error report was deferred * because it happened in the background. The * value is the chanMg, if any. #219's * companion to 'unreportedError'. */ diff --git a/generic/tclIOGT.c b/generic/tclIOGT.c index aa63cd0..a1ba9f9 100644 --- a/generic/tclIOGT.c +++ b/generic/tclIOGT.c @@ -115,23 +115,23 @@ static inline void ResultAdd(ResultBuffer *r, unsigned char *buf, */ static const Tcl_ChannelType transformChannelType = { - "transform", /* Type name. */ - TCL_CHANNEL_VERSION_5, /* v5 channel */ - NULL, /* Close proc. */ - TransformInputProc, /* Input proc. */ - TransformOutputProc, /* Output proc. */ - NULL, /* Seek proc. */ - TransformSetOptionProc, /* Set option proc. */ - TransformGetOptionProc, /* Get option proc. */ - TransformWatchProc, /* Initialize notifier. */ - TransformGetFileHandleProc, /* Get OS handles out of channel. */ - TransformCloseProc, /* close2proc */ - TransformBlockModeProc, /* Set blocking/nonblocking mode.*/ + "transform", + TCL_CHANNEL_VERSION_5, + NULL, /* Deprecated. */ + TransformInputProc, + TransformOutputProc, + NULL, /* Deprecated. */ + TransformSetOptionProc, + TransformGetOptionProc, + TransformWatchProc, + TransformGetFileHandleProc, + TransformCloseProc, + TransformBlockModeProc, NULL, /* Flush proc. */ - TransformNotifyProc, /* Handling of events bubbling up. */ - TransformWideSeekProc, /* Wide seek proc. */ - NULL, /* Thread action. */ - NULL /* Truncate. */ + TransformNotifyProc, + TransformWideSeekProc, + NULL, /* Thread action proc. */ + NULL /* Truncate proc. */ }; /* @@ -850,14 +850,14 @@ TransformOutputProc( static long long TransformWideSeekProc( - void *instanceData, /* The channel to manipulate. */ + void *instanceData, /* The channel to manipulate. */ long long offset, /* Size of movement. */ int mode, /* How to move. */ int *errorCodePtr) /* Location of error flag. */ { TransformChannelData *dataPtr = (TransformChannelData *)instanceData; Tcl_Channel parent = Tcl_GetStackedChannel(dataPtr->self); - const Tcl_ChannelType *parentType = Tcl_GetChannelType(parent); + const Tcl_ChannelType *parentType = Tcl_GetChannelType(parent); Tcl_DriverWideSeekProc *parentWideSeekProc = Tcl_ChannelWideSeekProc(parentType); void *parentData = Tcl_GetChannelInstanceData(parent); @@ -905,7 +905,7 @@ TransformWideSeekProc( *errorCodePtr = EINVAL; return -1; } - return parentWideSeekProc(parentData, offset, mode, errorCodePtr); + return parentWideSeekProc(parentData, offset, mode, errorCodePtr); } /* diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c index e8a243b..c8449aa 100644 --- a/generic/tclIORChan.c +++ b/generic/tclIORChan.c @@ -59,28 +59,28 @@ static int ReflectTruncate(void *clientData, * The C layer channel type/driver definition used by the reflection. */ -static const Tcl_ChannelType tclRChannelType = { - "tclrchannel", /* Type name. */ - TCL_CHANNEL_VERSION_5, /* v5 channel */ - NULL, /* Old close API */ - ReflectInput, /* Handle read request */ - ReflectOutput, /* Handle write request */ - NULL, - ReflectSetOption, /* Set options. */ - ReflectGetOption, /* Get options. */ - ReflectWatch, /* Initialize notifier */ - NULL, /* Get OS handle from the channel. */ - ReflectClose, /* Close channel. Clean instance data */ - ReflectBlock, /* Set blocking/nonblocking. */ - NULL, /* Flush channel. */ - NULL, /* Handle events. */ - ReflectSeekWide, /* Move access point (64 bit). */ +static const Tcl_ChannelType reflectedChannelType = { + "tclrchannel", + TCL_CHANNEL_VERSION_5, + NULL, /* Deprecated */ + ReflectInput, + ReflectOutput, + NULL, /* Deprecated */ + ReflectSetOption, + ReflectGetOption, + ReflectWatch, + NULL, /* Get OS handle from the channel. */ + ReflectClose, + ReflectBlock, + NULL, /* Flush channel. */ + NULL, /* Handle bubbled events. */ + ReflectSeekWide, #if TCL_THREADS - ReflectThread, /* thread action, tracking owner */ + ReflectThread, #else - NULL, /* thread action */ + NULL, /* Thread action proc */ #endif - ReflectTruncate /* Truncate. */ + ReflectTruncate /* Truncate proc. */ }; /* @@ -667,7 +667,7 @@ TclChanCreateObjCmd( * Everything is fine now. */ - chan = Tcl_CreateChannel(&tclRChannelType, TclGetString(rcId), rcPtr, + chan = Tcl_CreateChannel(&reflectedChannelType, TclGetString(rcId), rcPtr, mode); rcPtr->chan = chan; TclChannelPreserve(chan); @@ -682,7 +682,7 @@ TclChanCreateObjCmd( Tcl_ChannelType *clonePtr = (Tcl_ChannelType *)Tcl_Alloc(sizeof(Tcl_ChannelType)); - memcpy(clonePtr, &tclRChannelType, sizeof(Tcl_ChannelType)); + memcpy(clonePtr, &reflectedChannelType, sizeof(Tcl_ChannelType)); if (!(methods & FLAG(METH_CONFIGURE))) { clonePtr->setOptionProc = NULL; @@ -1179,7 +1179,7 @@ ReflectClose( #endif tctPtr = ((Channel *)rcPtr->chan)->typePtr; - if (tctPtr && tctPtr != &tclRChannelType) { + if (tctPtr && tctPtr != &reflectedChannelType) { Tcl_Free((void *)tctPtr); ((Channel *)rcPtr->chan)->typePtr = NULL; } @@ -1248,7 +1248,7 @@ ReflectClose( } #endif tctPtr = ((Channel *)rcPtr->chan)->typePtr; - if (tctPtr && tctPtr != &tclRChannelType) { + if (tctPtr && tctPtr != &reflectedChannelType) { Tcl_Free((void *)tctPtr); ((Channel *)rcPtr->chan)->typePtr = NULL; } diff --git a/generic/tclIORTrans.c b/generic/tclIORTrans.c index 0fe9d97..c151448 100644 --- a/generic/tclIORTrans.c +++ b/generic/tclIORTrans.c @@ -55,24 +55,24 @@ static int ReflectNotify(void *clientData, int mask); * The C layer channel type/driver definition used by the reflection. */ -static const Tcl_ChannelType tclRTransformType = { - "tclrtransform", /* Type name. */ - TCL_CHANNEL_VERSION_5, /* v5 channel. */ - NULL, - ReflectInput, /* Handle read request. */ - ReflectOutput, /* Handle write request. */ - NULL, /* Move location of access point. */ - ReflectSetOption, /* Set options. */ - ReflectGetOption, /* Get options. */ - ReflectWatch, /* Initialize notifier. */ - ReflectHandle, /* Get OS handle from the channel. */ - ReflectClose, /* Close channel, clean instance data. */ - ReflectBlock, /* Set blocking/nonblocking. */ +static const Tcl_ChannelType reflectedTransformType = { + "tclrtransform", + TCL_CHANNEL_VERSION_5, + NULL, /* Deprecated. */ + ReflectInput, + ReflectOutput, + NULL, /* Deprecated. */ + ReflectSetOption, + ReflectGetOption, + ReflectWatch, + ReflectHandle, + ReflectClose, + ReflectBlock, NULL, /* Flush channel. Not used by core. */ - ReflectNotify, /* Handle events. */ - ReflectSeekWide, /* Move access point (64 bit). */ - NULL, /* thread action */ - NULL /* truncate */ + ReflectNotify, + ReflectSeekWide, + NULL, /* Thread action proc. */ + NULL /* Truncate proc. */ }; /* @@ -678,7 +678,7 @@ TclChanPushObjCmd( rtPtr->methods = methods; rtPtr->mode = mode; - rtPtr->chan = Tcl_StackChannel(interp, &tclRTransformType, rtPtr, mode, + rtPtr->chan = Tcl_StackChannel(interp, &reflectedTransformType, rtPtr, mode, rtPtr->parent); /* diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index 4fef38c..683e4ff 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -433,28 +433,26 @@ static const Tcl_Filesystem zipfsFilesystem = { /* * The channel type/driver definition used for ZIP archive members. */ - -static Tcl_ChannelType ZipChannelType = { - "zip", /* Type name. */ +static const Tcl_ChannelType zipChannelType = { + "zip", TCL_CHANNEL_VERSION_5, - NULL, /* Close channel, clean instance data */ - ZipChannelRead, /* Handle read request */ - ZipChannelWrite, /* Handle write request */ - NULL, /* Move location of access point, NULL'able */ - NULL, /* Set options, NULL'able */ - NULL, /* Get options, NULL'able */ - ZipChannelWatchChannel, /* Initialize notifier */ - ZipChannelGetFile, /* Get OS handle from the channel */ - ZipChannelClose, /* 2nd version of close channel, NULL'able */ - NULL, /* Set blocking mode for raw channel, - * NULL'able */ - NULL, /* Function to flush channel, NULL'able */ - NULL, /* Function to handle event, NULL'able */ - ZipChannelWideSeek, /* Wide seek function, NULL'able */ - NULL, /* Thread action function, NULL'able */ - NULL, /* Truncate function, NULL'able */ + NULL, /* Deprecated. */ + ZipChannelRead, + ZipChannelWrite, + NULL, /* Deprecated. */ + NULL, /* Set options proc. */ + NULL, /* Get options proc. */ + ZipChannelWatchChannel, + ZipChannelGetFile, + ZipChannelClose, + NULL, /* Set blocking mode for raw channel. */ + NULL, /* Function to flush channel. */ + NULL, /* Function to handle bubbled events. */ + ZipChannelWideSeek, + NULL, /* Thread action function. */ + NULL, /* Truncate function. */ }; - + /* *------------------------------------------------------------------------ * @@ -4903,7 +4901,7 @@ ZipChannelOpen( ZipFS.idCount++); z->zipFilePtr->numOpen++; Unlock(); - return Tcl_CreateChannel(&ZipChannelType, cname, info, flags); + return Tcl_CreateChannel(&zipChannelType, cname, info, flags); error: Unlock(); diff --git a/generic/tclZlib.c b/generic/tclZlib.c index f3a2623..a1f4f12 100644 --- a/generic/tclZlib.c +++ b/generic/tclZlib.c @@ -208,21 +208,21 @@ static void ZlibTransformTimerRun(void *clientData); static const Tcl_ChannelType zlibChannelType = { "zlib", TCL_CHANNEL_VERSION_5, - NULL, + NULL, /* Deprecated. */ ZlibTransformInput, ZlibTransformOutput, - NULL, /* seekProc */ + NULL, /* Deprecated. */ ZlibTransformSetOption, ZlibTransformGetOption, ZlibTransformWatch, ZlibTransformGetHandle, - ZlibTransformClose, /* close2Proc */ + ZlibTransformClose, ZlibTransformBlockMode, - NULL, /* flushProc */ + NULL, /* Flush proc. */ ZlibTransformEventHandler, - NULL, /* wideSeekProc */ - NULL, - NULL + NULL, /* Seek proc. */ + NULL, /* Thread action proc. */ + NULL /* Truncate proc. */ }; /* diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c index 12366ac..693720c 100644 --- a/unix/tclUnixChan.c +++ b/unix/tclUnixChan.c @@ -161,22 +161,22 @@ static int TtySetOptionProc(void *instanceData, static const Tcl_ChannelType fileChannelType = { "file", /* Type name. */ - TCL_CHANNEL_VERSION_5, /* v5 channel */ - NULL, /* Deprecated close proc. */ - FileInputProc, /* Input proc. */ - FileOutputProc, /* Output proc. */ - NULL, + TCL_CHANNEL_VERSION_5, + NULL, /* Deprecated. */ + FileInputProc, + FileOutputProc, + NULL, /* Deprecated. */ NULL, /* Set option proc. */ - FileGetOptionProc, /* Get option proc. */ - FileWatchProc, /* Initialize notifier. */ - FileGetHandleProc, /* Get OS handles out of channel. */ - FileCloseProc, /* Close proc. */ - FileBlockModeProc, /* Set blocking or non-blocking mode.*/ - NULL, /* flush proc. */ - NULL, /* handler proc. */ - FileWideSeekProc, /* wide seek proc. */ - NULL, - FileTruncateProc /* truncate proc. */ + FileGetOptionProc, + FileWatchProc, + FileGetHandleProc, + FileCloseProc, + FileBlockModeProc, + NULL, /* Flush proc. */ + NULL, /* Bubbled event handler proc. */ + FileWideSeekProc, + NULL, /* Thread action proc. */ + FileTruncateProc }; #ifdef SUPPORTS_TTY @@ -186,23 +186,23 @@ static const Tcl_ChannelType fileChannelType = { */ static const Tcl_ChannelType ttyChannelType = { - "tty", /* Type name. */ - TCL_CHANNEL_VERSION_5, /* v5 channel */ - NULL, /* Deprecated close proc. */ - FileInputProc, /* Input proc. */ - FileOutputProc, /* Output proc. */ + "tty", + TCL_CHANNEL_VERSION_5, + NULL, /* Deprecated. */ + FileInputProc, + FileOutputProc, + NULL, /* Deprecated. */ + TtySetOptionProc, + TtyGetOptionProc, + FileWatchProc, + FileGetHandleProc, + TtyCloseProc, + FileBlockModeProc, + NULL, /* Flush proc. */ + NULL, /* Bubbled event handler proc. */ NULL, /* Seek proc. */ - TtySetOptionProc, /* Set option proc. */ - TtyGetOptionProc, /* Get option proc. */ - FileWatchProc, /* Initialize notifier. */ - FileGetHandleProc, /* Get OS handles out of channel. */ - TtyCloseProc, /* Close proc. */ - FileBlockModeProc, /* Set blocking or non-blocking mode.*/ - NULL, /* flush proc. */ - NULL, /* handler proc. */ - NULL, /* wide seek proc. */ - NULL, /* thread action proc. */ - NULL /* truncate proc. */ + NULL, /* Thread action proc. */ + NULL /* Truncate proc. */ }; #endif /* SUPPORTS_TTY */ diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c index ea1636e..78bba4f 100644 --- a/unix/tclUnixPipe.c +++ b/unix/tclUnixPipe.c @@ -78,23 +78,23 @@ static int SetupStdFile(TclFile file, int type); */ static const Tcl_ChannelType pipeChannelType = { - "pipe", /* Type name. */ - TCL_CHANNEL_VERSION_5, /* v5 channel */ - NULL, /* Close proc. */ - PipeInputProc, /* Input proc. */ - PipeOutputProc, /* Output proc. */ - NULL, /* Seek proc. */ + "pipe", + TCL_CHANNEL_VERSION_5, + NULL, /* Deprecated. */ + PipeInputProc, + PipeOutputProc, + NULL, /* Deprecated. */ NULL, /* Set option proc. */ NULL, /* Get option proc. */ - PipeWatchProc, /* Initialize notifier. */ - PipeGetHandleProc, /* Get OS handles out of channel. */ - PipeClose2Proc, /* close2proc. */ - PipeBlockModeProc, /* Set blocking or non-blocking mode.*/ - NULL, /* flush proc. */ - NULL, /* handler proc. */ - NULL, /* wide seek proc */ - NULL, /* thread action proc */ - NULL /* truncation */ + PipeWatchProc, + PipeGetHandleProc, + PipeClose2Proc, + PipeBlockModeProc, + NULL, /* Flush proc. */ + NULL, /* Bubbled event handler proc. */ + NULL, /* Seek proc. */ + NULL, /* Thread action proc. */ + NULL /* Truncation proc. */ }; /* diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c index 11193b7..d518453 100644 --- a/unix/tclUnixSock.c +++ b/unix/tclUnixSock.c @@ -154,23 +154,23 @@ static Tcl_FileProc WrapNotify; */ static const Tcl_ChannelType tcpChannelType = { - "tcp", /* Type name. */ - TCL_CHANNEL_VERSION_5, /* v5 channel */ - NULL, /* Close proc. */ - TcpInputProc, /* Input proc. */ - TcpOutputProc, /* Output proc. */ + "tcp", + TCL_CHANNEL_VERSION_5, + NULL, /* Deprecated. */ + TcpInputProc, + TcpOutputProc, + NULL, /* Deprecated. */ + TcpSetOptionProc, + TcpGetOptionProc, + TcpWatchProc, + TcpGetHandleProc, + TcpClose2Proc, + TcpBlockModeProc, + NULL, /* Flush proc. */ + NULL, /* Bubbled event handler proc. */ NULL, /* Seek proc. */ - TcpSetOptionProc, /* Set option proc. */ - TcpGetOptionProc, /* Get option proc. */ - TcpWatchProc, /* Initialize notifier. */ - TcpGetHandleProc, /* Get OS handles out of channel. */ - TcpClose2Proc, /* Close2 proc. */ - TcpBlockModeProc, /* Set blocking or non-blocking mode.*/ - NULL, /* flush proc. */ - NULL, /* handler proc. */ - NULL, /* wide seek proc. */ - TcpThreadActionProc, /* thread action proc. */ - NULL /* truncate proc. */ + TcpThreadActionProc, + NULL /* Truncate proc. */ }; /* diff --git a/win/tclWinChan.c b/win/tclWinChan.c index 248ca5b..b81af7e 100644 --- a/win/tclWinChan.c +++ b/win/tclWinChan.c @@ -106,23 +106,23 @@ static Tcl_Channel OpenFileChannel(HANDLE handle, char *channelName, */ static const Tcl_ChannelType fileChannelType = { - "file", /* Type name. */ - TCL_CHANNEL_VERSION_5, /* v5 channel */ - NULL, /* Close proc. */ - FileInputProc, /* Input proc. */ - FileOutputProc, /* Output proc. */ - NULL, + "file", + TCL_CHANNEL_VERSION_5, + NULL, /* Deprecated. */ + FileInputProc, + FileOutputProc, + NULL, /* Deprecated. */ NULL, /* Set option proc. */ - FileGetOptionProc, /* Get option proc. */ - FileWatchProc, /* Set up the notifier to watch the channel. */ - FileGetHandleProc, /* Get an OS handle from channel. */ - FileCloseProc, /* close2proc. */ - FileBlockProc, /* Set blocking or non-blocking mode.*/ - NULL, /* flush proc. */ - NULL, /* handler proc. */ - FileWideSeekProc, /* Wide seek proc. */ - FileThreadActionProc, /* Thread action proc. */ - FileTruncateProc /* Truncate proc. */ + FileGetOptionProc, + FileWatchProc, + FileGetHandleProc, + FileCloseProc, + FileBlockProc, + NULL, /* Flush proc. */ + NULL, /* Bubbled event handler proc. */ + FileWideSeekProc, + FileThreadActionProc, + FileTruncateProc }; /* diff --git a/win/tclWinConsole.c b/win/tclWinConsole.c index a498200..ee04b05 100644 --- a/win/tclWinConsole.c +++ b/win/tclWinConsole.c @@ -298,23 +298,23 @@ static ConsoleChannelInfo *gWatchingChannelList; */ static const Tcl_ChannelType consoleChannelType = { - "console", /* Type name. */ - TCL_CHANNEL_VERSION_5, /* v5 channel */ - NULL, /* Close proc. */ - ConsoleInputProc, /* Input proc. */ - ConsoleOutputProc, /* Output proc. */ - NULL, /* Seek proc. */ - ConsoleSetOptionProc, /* Set option proc. */ - ConsoleGetOptionProc, /* Get option proc. */ - ConsoleWatchProc, /* Set up notifier to watch the channel. */ - ConsoleGetHandleProc, /* Get an OS handle from channel. */ - ConsoleCloseProc, /* close2proc. */ - ConsoleBlockModeProc, /* Set blocking or non-blocking mode. */ - NULL, /* Flush proc. */ - NULL, /* Handler proc. */ - NULL, /* Wide seek proc. */ - ConsoleThreadActionProc, /* Thread action proc. */ - NULL /* Truncation proc. */ + "console", + TCL_CHANNEL_VERSION_5, + NULL, /* Deprecated. */ + ConsoleInputProc, + ConsoleOutputProc, + NULL, /* Deprecated. */ + ConsoleSetOptionProc, + ConsoleGetOptionProc, + ConsoleWatchProc, + ConsoleGetHandleProc, + ConsoleCloseProc, + ConsoleBlockModeProc, + NULL, /* Flush proc. */ + NULL, /* Bubbled event handler proc. */ + NULL, /* Seek proc. */ + ConsoleThreadActionProc, + NULL /* Truncation proc. */ }; /* diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index c4b60b9..eeb06f8 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -201,23 +201,23 @@ static void PipeThreadActionProc(void *instanceData, */ static const Tcl_ChannelType pipeChannelType = { - "pipe", /* Type name. */ - TCL_CHANNEL_VERSION_5, /* v5 channel */ - NULL, /* Close proc. */ - PipeInputProc, /* Input proc. */ - PipeOutputProc, /* Output proc. */ - NULL, /* Seek proc. */ + "pipe", + TCL_CHANNEL_VERSION_5, + NULL, /* Deprecated. */ + PipeInputProc, + PipeOutputProc, + NULL, /* Deprecated. */ NULL, /* Set option proc. */ NULL, /* Get option proc. */ - PipeWatchProc, /* Set up notifier to watch the channel. */ - PipeGetHandleProc, /* Get an OS handle from channel. */ - PipeClose2Proc, /* close2proc */ - PipeBlockModeProc, /* Set blocking or non-blocking mode.*/ - NULL, /* flush proc. */ - NULL, /* handler proc. */ - NULL, /* wide seek proc */ - PipeThreadActionProc, /* thread action proc */ - NULL /* truncate */ + PipeWatchProc, + PipeGetHandleProc, + PipeClose2Proc, + PipeBlockModeProc, + NULL, /* Flush proc. */ + NULL, /* Bubbled event handler proc. */ + NULL, /* Seek proc. */ + PipeThreadActionProc, + NULL /* Truncate proc. */ }; /* diff --git a/win/tclWinSerial.c b/win/tclWinSerial.c index 2ce432c..fe35c36 100644 --- a/win/tclWinSerial.c +++ b/win/tclWinSerial.c @@ -202,23 +202,23 @@ static int SerialBlockingWrite(SerialInfo *infoPtr, LPVOID buf, */ static const Tcl_ChannelType serialChannelType = { - "serial", /* Type name. */ - TCL_CHANNEL_VERSION_5, /* v5 channel */ - NULL, /* Close proc. */ - SerialInputProc, /* Input proc. */ - SerialOutputProc, /* Output proc. */ + "serial", + TCL_CHANNEL_VERSION_5, + NULL, /* Deprecated. */ + SerialInputProc, + SerialOutputProc, + NULL, /* Deprecated. */ + SerialSetOptionProc, + SerialGetOptionProc, + SerialWatchProc, + SerialGetHandleProc, + SerialCloseProc, + SerialBlockProc, + NULL, /* Flush proc. */ + NULL, /* Bubbled event handler proc. */ NULL, /* Seek proc. */ - SerialSetOptionProc, /* Set option proc. */ - SerialGetOptionProc, /* Get option proc. */ - SerialWatchProc, /* Set up notifier to watch the channel. */ - SerialGetHandleProc, /* Get an OS handle from channel. */ - SerialCloseProc, /* close2proc. */ - SerialBlockProc, /* Set blocking or non-blocking mode.*/ - NULL, /* flush proc. */ - NULL, /* handler proc. */ - NULL, /* wide seek proc */ - SerialThreadActionProc, /* thread action proc */ - NULL /* truncate */ + SerialThreadActionProc, + NULL /* Truncate proc. */ }; /* diff --git a/win/tclWinSock.c b/win/tclWinSock.c index 5239cd3..11c43f0 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -270,23 +270,23 @@ static Tcl_DriverGetHandleProc TcpGetHandleProc; */ static const Tcl_ChannelType tcpChannelType = { - "tcp", /* Type name. */ - TCL_CHANNEL_VERSION_5, /* v5 channel */ - NULL, /* Old close proc. Deprecated. */ - TcpInputProc, /* Input proc. */ - TcpOutputProc, /* Output proc. */ + "tcp", + TCL_CHANNEL_VERSION_5, + NULL, /* Deprecated. */ + TcpInputProc, + TcpOutputProc, + NULL, /* Deprecated. */ + TcpSetOptionProc, + TcpGetOptionProc, + TcpWatchProc, + TcpGetHandleProc, + TcpClose2Proc, + TcpBlockModeProc, + NULL, /* Flush proc. */ + NULL, /* Bubbled event handler proc. */ NULL, /* Seek proc. */ - TcpSetOptionProc, /* Set option proc. */ - TcpGetOptionProc, /* Get option proc. */ - TcpWatchProc, /* Initialize notifier. */ - TcpGetHandleProc, /* Get OS handles out of channel. */ - TcpClose2Proc, /* New close2 proc. */ - TcpBlockModeProc, /* Set blocking or non-blocking mode.*/ - NULL, /* flush proc. */ - NULL, /* handler proc. */ - NULL, /* wide seek proc. */ - TcpThreadActionProc, /* thread action proc. */ - NULL /* truncate proc. */ + TcpThreadActionProc, + NULL /* Truncate proc. */ }; /* -- cgit v0.12 From a2d8e9fb32060e1d4e6128b76e538ddead272901 Mon Sep 17 00:00:00 2001 From: dkf Date: Sun, 9 Jun 2024 12:13:40 +0000 Subject: Put ClockFmtScnStorageHashKeyType in read-only memory --- generic/tclClockFmt.c | 23 +++++++++++++---------- generic/tclHash.c | 33 +++++++++++++++------------------ generic/tclInt.h | 2 ++ 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/generic/tclClockFmt.c b/generic/tclClockFmt.c index fead7fd..0dfc9bb 100644 --- a/generic/tclClockFmt.c +++ b/generic/tclClockFmt.c @@ -22,20 +22,28 @@ static void ClockFmtObj_DupInternalRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr); static void ClockFmtObj_FreeInternalRep(Tcl_Obj *objPtr); static int ClockFmtObj_SetFromAny(Tcl_Interp *, Tcl_Obj *objPtr); static void ClockFmtObj_UpdateString(Tcl_Obj *objPtr); +static Tcl_HashEntry * ClockFmtScnStorageAllocProc(Tcl_HashTable *, void *keyPtr); +static void ClockFmtScnStorageFreeProc(Tcl_HashEntry *hPtr); +static void ClockFmtScnStorageDelete(ClockFmtScnStorage *fss); TCL_DECLARE_MUTEX(ClockFmtMutex); /* Serializes access to common format list. */ -static void ClockFmtScnStorageDelete(ClockFmtScnStorage *fss); - #ifndef TCL_CLOCK_FULL_COMPAT #define TCL_CLOCK_FULL_COMPAT 1 #endif /* - * Derivation of tclStringHashKeyType with another allocEntryProc + * Derivation of tclStringHashKeyType with extra memory management trickery. */ -static Tcl_HashKeyType ClockFmtScnStorageHashKeyType; +static const Tcl_HashKeyType ClockFmtScnStorageHashKeyType = { + TCL_HASH_KEY_TYPE_VERSION, /* version */ + 0, /* flags */ + TclHashStringKey, /* hashKeyProc */ + TclCompareStringKeys, /* compareKeysProc */ + ClockFmtScnStorageAllocProc, /* allocEntryProc */ + ClockFmtScnStorageFreeProc /* freeEntryProc */ +}; #define IntFieldAt(info, offset) \ ((int *) (((char *) (info)) + (offset))) @@ -543,7 +551,7 @@ FmtScn4HashEntry( static Tcl_HashEntry * ClockFmtScnStorageAllocProc( - TCL_UNUSED(Tcl_HashTable *), /* Hash table. */ + TCL_UNUSED(Tcl_HashTable *),/* Hash table. */ void *keyPtr) /* Key to store in the hash table entry. */ { ClockFmtScnStorage *fss; @@ -825,11 +833,6 @@ FindOrCreateFmtScnStorage( /* if not yet initialized */ if (!initialized) { - /* initialize type */ - memcpy(&ClockFmtScnStorageHashKeyType, &tclStringHashKeyType, sizeof(tclStringHashKeyType)); - ClockFmtScnStorageHashKeyType.allocEntryProc = ClockFmtScnStorageAllocProc; - ClockFmtScnStorageHashKeyType.freeEntryProc = ClockFmtScnStorageFreeProc; - /* initialize hash table */ Tcl_InitCustomHashTable(&FmtScnHashTable, TCL_CUSTOM_TYPE_KEYS, &ClockFmtScnStorageHashKeyType); diff --git a/generic/tclHash.c b/generic/tclHash.c index 89807e2..9bdb079 100644 --- a/generic/tclHash.c +++ b/generic/tclHash.c @@ -44,8 +44,6 @@ static size_t HashArrayKey(Tcl_HashTable *tablePtr, void *keyPtr); static Tcl_HashEntry * AllocStringEntry(Tcl_HashTable *tablePtr, void *keyPtr); -static int CompareStringKeys(void *keyPtr, Tcl_HashEntry *hPtr); -static size_t HashStringKey(Tcl_HashTable *tablePtr, void *keyPtr); /* * Function prototypes for static functions in this file: @@ -80,8 +78,8 @@ const Tcl_HashKeyType tclOneWordHashKeyType = { const Tcl_HashKeyType tclStringHashKeyType = { TCL_HASH_KEY_TYPE_VERSION, /* version */ 0, /* flags */ - HashStringKey, /* hashKeyProc */ - CompareStringKeys, /* compareKeysProc */ + TclHashStringKey, /* hashKeyProc */ + TclCompareStringKeys, /* compareKeysProc */ AllocStringEntry, /* allocEntryProc */ NULL /* freeEntryProc */ }; @@ -556,8 +554,7 @@ Tcl_FirstHashEntry( Tcl_HashEntry * Tcl_NextHashEntry( - Tcl_HashSearch *searchPtr) - /* Place to store information about progress + Tcl_HashSearch *searchPtr) /* Place to store information about progress * through the table. Must have been * initialized by calling * Tcl_FirstHashEntry. */ @@ -671,7 +668,7 @@ Tcl_HashStats( static Tcl_HashEntry * AllocArrayEntry( Tcl_HashTable *tablePtr, /* Hash table. */ - void *keyPtr) /* Key to store in the hash table entry. */ + void *keyPtr) /* Key to store in the hash table entry. */ { Tcl_HashEntry *hPtr; size_t count = tablePtr->keyType * sizeof(int); @@ -707,7 +704,7 @@ AllocArrayEntry( static int CompareArrayKeys( - void *keyPtr, /* New key to compare. */ + void *keyPtr, /* New key to compare. */ Tcl_HashEntry *hPtr) /* Existing key to compare. */ { size_t count = hPtr->tablePtr->keyType * sizeof(int); @@ -736,7 +733,7 @@ CompareArrayKeys( static size_t HashArrayKey( Tcl_HashTable *tablePtr, /* Hash table. */ - void *keyPtr) /* Key from which to compute hash value. */ + void *keyPtr) /* Key from which to compute hash value. */ { const int *array = (const int *) keyPtr; size_t result; @@ -768,7 +765,7 @@ HashArrayKey( static Tcl_HashEntry * AllocStringEntry( TCL_UNUSED(Tcl_HashTable *), - void *keyPtr) /* Key to store in the hash table entry. */ + void *keyPtr) /* Key to store in the hash table entry. */ { const char *string = (const char *) keyPtr; Tcl_HashEntry *hPtr; @@ -788,7 +785,7 @@ AllocStringEntry( /* *---------------------------------------------------------------------- * - * CompareStringKeys -- + * TclCompareStringKeys -- * * Compares two string keys. * @@ -802,9 +799,9 @@ AllocStringEntry( *---------------------------------------------------------------------- */ -static int -CompareStringKeys( - void *keyPtr, /* New key to compare. */ +int +TclCompareStringKeys( + void *keyPtr, /* New key to compare. */ Tcl_HashEntry *hPtr) /* Existing key to compare. */ { return !strcmp((char *)keyPtr, hPtr->key.string); @@ -813,7 +810,7 @@ CompareStringKeys( /* *---------------------------------------------------------------------- * - * HashStringKey -- + * TclHashStringKey -- * * Compute a one-word summary of a text string, which can be used to * generate a hash index. @@ -827,10 +824,10 @@ CompareStringKeys( *---------------------------------------------------------------------- */ -static size_t -HashStringKey( +size_t +TclHashStringKey( TCL_UNUSED(Tcl_HashTable *), - void *keyPtr) /* Key from which to compute hash value. */ + void *keyPtr) /* Key from which to compute hash value. */ { const char *string = (const char *)keyPtr; size_t result; diff --git a/generic/tclInt.h b/generic/tclInt.h index c9ff923..70bc4b8 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -3405,6 +3405,8 @@ MODULE_SCOPE int TclGetLoadedLibraries(Tcl_Interp *interp, const char *packageName); MODULE_SCOPE int TclGetWideBitsFromObj(Tcl_Interp *, Tcl_Obj *, Tcl_WideInt *); +MODULE_SCOPE int TclCompareStringKeys(void *keyPtr, Tcl_HashEntry *hPtr); +MODULE_SCOPE size_t TclHashStringKey(Tcl_HashTable *tablePtr, void *keyPtr); MODULE_SCOPE int TclIncrObj(Tcl_Interp *interp, Tcl_Obj *valuePtr, Tcl_Obj *incrPtr); MODULE_SCOPE Tcl_Obj * TclIncrObjVar2(Tcl_Interp *interp, Tcl_Obj *part1Ptr, -- cgit v0.12 From cb1ad4025929d604c977887bf4e60ebc678da5e9 Mon Sep 17 00:00:00 2001 From: dkf Date: Sun, 9 Jun 2024 14:06:20 +0000 Subject: Another record that ought to be read-only --- generic/tclLink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tclLink.c b/generic/tclLink.c index 3bd855b..2e7d3b0 100644 --- a/generic/tclLink.c +++ b/generic/tclLink.c @@ -109,7 +109,7 @@ static int SetInvalidRealFromAny(Tcl_Interp *interp, * A marker type used to flag weirdnesses so we can pass them around right. */ -static Tcl_ObjType invalidRealType = { +static const Tcl_ObjType invalidRealType = { "invalidReal", /* name */ NULL, /* freeIntRepProc */ NULL, /* dupIntRepProc */ -- cgit v0.12 From 84e40c54d2945aaa8d3dfa671673af17179af95f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 10 Jun 2024 13:06:57 +0000 Subject: TIP #494 changes were not fully incorporated in the documentation, so let's correct that. --- doc/Alloc.3 | 4 ++-- doc/Preserve.3 | 5 +---- doc/SetResult.3 | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/doc/Alloc.3 b/doc/Alloc.3 index 493eebc..999c1e8 100644 --- a/doc/Alloc.3 +++ b/doc/Alloc.3 @@ -13,7 +13,7 @@ Tcl_Alloc, Tcl_Free, Tcl_Realloc, Tcl_AttemptAlloc, Tcl_AttemptRealloc, Tcl_GetM .nf \fB#include \fR .sp -char * +void * \fBTcl_Alloc\fR(\fIsize\fR) .sp \fBTcl_Free\fR(\fIptr\fR) @@ -33,7 +33,7 @@ void * .AS char *size .AP "size_t" size in Size in bytes of the memory block to allocate. -.AP char *ptr in +.AP void *ptr in Pointer to memory block to free or realloc. .AP Tcl_DString *dsPtr in Initialized DString pointer. diff --git a/doc/Preserve.3 b/doc/Preserve.3 index e01cf80..d676b9a 100644 --- a/doc/Preserve.3 +++ b/doc/Preserve.3 @@ -81,14 +81,11 @@ type \fBTcl_FreeProc\fR: .PP .CS typedef void \fBTcl_FreeProc\fR( - char *\fIblockPtr\fR); + void *\fIblockPtr\fR); .CE .PP The \fIblockPtr\fR argument to \fIfreeProc\fR will be the same as the \fIclientData\fR argument to \fBTcl_EventuallyFree\fR. -The type of \fIblockPtr\fR (\fBchar *\fR) is different than the type of the -\fIclientData\fR argument to \fBTcl_EventuallyFree\fR for historical -reasons, but the value is the same. .PP When the \fIclientData\fR argument to \fBTcl_EventuallyFree\fR refers to storage allocated and returned by a prior call to diff --git a/doc/SetResult.3 b/doc/SetResult.3 index 9e009fa..8c89280 100644 --- a/doc/SetResult.3 +++ b/doc/SetResult.3 @@ -207,7 +207,7 @@ result that match the type \fBTcl_FreeProc\fR: .PP .CS typedef void \fBTcl_FreeProc\fR( - char *\fIblockPtr\fR); + void *\fIblockPtr\fR); .CE .PP When \fIfreeProc\fR is called, its \fIblockPtr\fR will be set to -- cgit v0.12 From 6dac6f978447f0fbcfbf7f5f646998eb6d6e13dd Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 11 Jun 2024 09:14:21 +0000 Subject: There are no "two triplets" any more in 9.0 --- doc/SaveInterpState.3 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/SaveInterpState.3 b/doc/SaveInterpState.3 index ce7f74a..619ff0b 100644 --- a/doc/SaveInterpState.3 +++ b/doc/SaveInterpState.3 @@ -36,9 +36,9 @@ Saved state token to be restored or discarded. These routines allows a C procedure to take a snapshot of the current state of an interpreter so that it can be restored after a call to \fBTcl_Eval\fR or some other routine that modifies the interpreter -state. There are two triplets of routines meant to work together. +state. .PP -The first triplet stores the snapshot of interpreter state in +\fBTcl_SaveInterpState\fR stores a snapshot of the interpreter state in an opaque token returned by \fBTcl_SaveInterpState\fR. That token value may then be passed back to one of \fBTcl_RestoreInterpState\fR or \fBTcl_DiscardInterpState\fR, depending on whether the interp -- cgit v0.12 From 917817da8ed2e5de68e00d243a6b114c7b7fe129 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 11 Jun 2024 20:37:08 +0000 Subject: Revert [eb627bda27] from 9.0, will be put in a separate branch for review --- doc/chan.n | 852 ++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 502 insertions(+), 350 deletions(-) diff --git a/doc/chan.n b/doc/chan.n index f89fc73..8bb564b 100644 --- a/doc/chan.n +++ b/doc/chan.n @@ -1,6 +1,5 @@ '\" '\" Copyright (c) 2005-2006 Donal K. Fellows -'\" Copyright (c) 2021 Nathan Coulter '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -9,68 +8,85 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME -chan \- Reads, writes and manipulates channels. +chan \- Read, write and manipulate channels .SH SYNOPSIS -\fBchan \fIoperation\fR ?\fIarg arg ...\fR? +\fBchan \fIoption\fR ?\fIarg arg ...\fR? .BE .SH DESCRIPTION .PP -\fBchan\fR provides several operations for reading from, writing to, and -otherwise manipulating channels, e.g. those created by \fBopen\fR and -\fBsocket\fR, or the default channels \fBstdin\fR, \fBstdout\fR or \fBstderr\fR -which correspond respectively to the standard input, output, and error streams -of the process. Any unique abbreviation for \fIoperation\fR is acceptable. -Available operations are: +This command provides several operations for reading from, writing to +and otherwise manipulating open channels (such as have been created +with the \fBopen\fR and \fBsocket\fR commands, or the default named +channels \fBstdin\fR, \fBstdout\fR or \fBstderr\fR which correspond to +the process's standard input, output and error streams respectively). +\fIOption\fR indicates what to do with the channel; any unique +abbreviation for \fIoption\fR is acceptable. Valid options are: .\" METHOD: blocked .TP -\fBchan blocked \fIchannelName\fR +\fBchan blocked \fIchannelId\fR . -Returns 1 when the channel is in non-blocking mode and the last input operation -on the channel failed because it would have otherwise caused the process to -block, and 0 otherwise. Each Tcl channel is in blocking mode unless configured -otherwise. +This tests whether the last input operation on the channel called +\fIchannelId\fR failed because it would have otherwise caused the +process to block, and returns 1 if that was the case. It returns 0 +otherwise. Note that this only ever returns 1 when the channel has +been configured to be non-blocking; all Tcl channels have blocking +turned on by default. .\" METHOD: close .TP -\fBchan close \fIchannelName\fR ?\fIdirection\fR? +\fBchan close \fIchannelId\fR ?\fIdirection\fR? . -Closes and destroys the named channel deleting any existing event handlers -established for the channel. The command returns the empty string. If -\fIdirection\fR is given, it is \fBread\fR, or \fBwrite\fR, or any unique -abbreviation of those words, and only that side of the channel is closed. I.e. a -read-write channel may become read-only or write-only. Closing a read-only -channel for reading, or closing a write-only channel for writing is the same as -simply closing the channel. It is an error to close a read-only channel for -writing or to close a write-only channel for reading. +Close and destroy the channel called \fIchannelId\fR. Note that this +deletes all existing file-events registered on the channel. +If the \fIdirection\fR argument (which must be \fBread\fR or \fBwrite\fR or +any unique abbreviation of them) is present, the channel will only be +half-closed, so that it can go from being read-write to write-only or +read-only respectively. If a read-only channel is closed for reading, it is +the same as if the channel is fully closed, and respectively similar for +write-only channels. Without the \fIdirection\fR argument, the channel is +closed for both reading and writing (but only if those directions are +currently open). It is an error to close a read-only channel for writing, or a +write-only channel for reading. .RS .PP -When a channel is closed for writing, any buffered output on the channel is -flushed. When a channel is closed for reading, any buffered input is discarded. -When a channel is destroyed the underlying resource is closed and the channel -is thereafter unavailable. -.PP -\fBchan close\fR fully flushes any output before closing the write side of a -channel unless it is non-blocking mode, where it returns immediately and the -channel is flushed in the background before finally being closed. -.PP -\fBchan close\fR may return an error if an error occurs while flushing -output. If a process in a command pipeline created by \fBopen\fR returns an -error (either by returning a non-zero exit code or writing to its standard -error file descriptor), \fBchan close\fR generates an error in the same -manner as \fBexec\fR. -.PP -Closing one side of a socket or command pipeline may lead to the shutdown() or -close() of the underlying system resource, leading to a reaction from whatever -is on the other side of the pipeline or socket. -.PP -If the channel for a command pipeline is in blocking mode, \fBchan close\fR -waits for the connected processes to complete. -.PP -\fBchan close\fR only affects the current interpreter. If the channel is open -in any other interpreter, its state is unchanged there. See \fBinterp\fR for a -description of channel sharing. -.PP -When the last interpreter sharing a channel is destroyed, the channel is -switched to blocking mode and fully flushed and then closed. +As part of closing the channel, all buffered output is flushed to the +channel's output device (only if the channel is ceasing to be writable), any +buffered input is discarded (only if the channel is ceasing to be readable), +the underlying operating system resource is closed and \fIchannelId\fR becomes +unavailable for future use (both only if the channel is being completely +closed). +.PP +If the channel is blocking and the channel is ceasing to be writable, the +command does not return until all output is flushed. If the channel is +non-blocking and there is unflushed output, the channel remains open and the +command returns immediately; output will be flushed in the background and the +channel will be closed when all the flushing is complete. +.PP +If \fIchannelId\fR is a blocking channel for a command pipeline then +\fBchan close\fR waits for the child processes to complete. +.PP +If the channel is shared between interpreters, then \fBchan close\fR +makes \fIchannelId\fR unavailable in the invoking interpreter but has +no other effect until all of the sharing interpreters have closed the +channel. When the last interpreter in which the channel is registered +invokes \fBchan close\fR (or \fBclose\fR), the cleanup actions +described above occur. With half-closing, the half-close of the channel only +applies to the current interpreter's view of the channel until all channels +have closed it in that direction (or completely). +See the \fBinterp\fR command for a description of channel sharing. +.PP +Channels are automatically fully closed when an interpreter is destroyed and +when the process exits. Channels are switched to blocking mode, to +ensure that all output is correctly flushed before the process exits. +.PP +The command returns an empty string, and may generate an error if +an error occurs while flushing output. If a command in a command +pipeline created with \fBopen\fR returns an error, \fBchan close\fR +generates an error (similar to the \fBexec\fR command.) +.PP +Note that half-closes of sockets and command pipelines can have important side +effects because they result in a shutdown() or close() of the underlying +system resource, which can change how other processes or systems respond to +the Tcl program. .PP Channels are automatically closed when an interpreter is destroyed and when the process exits. @@ -85,81 +101,105 @@ restores the previous behavior. .RE .\" METHOD: configure .TP -\fBchan configure \fIchannelName\fR ?\fIoptionName\fR? ?\fIvalue\fR? ?\fIoptionName value\fR?... +\fBchan configure \fIchannelId\fR ?\fIoptionName\fR? ?\fIvalue\fR? ?\fIoptionName value\fR?... . -Configures or retrieves the configuration of the channel \fIchannelName\fR. +Query or set the configuration options of the channel named +\fIchannelId\fR. .RS .PP -If no \fIoptionName\fR or \fIvalue\fR arguments are given, -\fBchan configure\fR returns a dictionary of option names and -values for the channel. If \fIoptionName\fR is supplied without a \fIvalue\fR, -\fBchan configure\fR returns the current value of the named option. If one or -more pairs of \fIoptionName\fR and \fIvalue\fR are supplied, -\fBchan configure\fR sets each of the named options to the corresponding -\fIvalue\fR and returns the empty string. -.PP -The options described below are supported for all channels. Each type of -channel may provide additional options. Those options are described in the -relevant documentation. For example, additional options are documented for -\fBsocket\fR, and also for serial devices at \fBopen\fR. +If no \fIoptionName\fR or \fIvalue\fR arguments are supplied, the +command returns a list containing alternating option names and values +for the channel. If \fIoptionName\fR is supplied but no \fIvalue\fR +then the command returns the current value of the given option. If +one or more pairs of \fIoptionName\fR and \fIvalue\fR are supplied, +the command sets each of the named options to the corresponding +\fIvalue\fR; in this case the return value is an empty string. +.PP +The options described below are supported for all channels. In +addition, each channel type may add options that only it supports. See +the manual entry for the command that creates each type of channel +for the options supported by that specific type of channel. For +example, see the manual entry for the \fBsocket\fR command for additional +options for sockets, and the \fBopen\fR command for additional options for +serial devices. +.RE .\" OPTION: -blocking .TP \fB\-blocking\fI boolean\fR . -If \fB\-blocking\fR is set to \fBtrue\fR (default), reading the channel -or writing to it may cause the process to block indefinitely. Otherwise, -operations such as \fBchan gets\fR, \fBchan read\fR, \fBchan puts\fR, \fBchan -flush\fR, and \fBchan close\fR take care not to block. Non-blocking mode in -general requires that the event loop is entered, e.g. by calling -\fBTcl_DoOneEvent\fR or \fBvwait\fR or by using Tk, to give Tcl a chance to -process events on the channel. +The \fB\-blocking\fR option determines whether I/O operations on the +channel can cause the process to block indefinitely. The value of the +option must be a proper boolean value. Channels are normally in +blocking mode; if a channel is placed into non-blocking mode it will +affect the operation of the \fBchan gets\fR, \fBchan read\fR, \fBchan +puts\fR, \fBchan flush\fR, and \fBchan close\fR commands; see the +documentation for those commands for details. For non-blocking mode to +work correctly, the application must be using the Tcl event loop +(e.g. by calling \fBTcl_DoOneEvent\fR or invoking the \fBvwait\fR +command). .\" OPTION: -buffering .TP \fB\-buffering\fI newValue\fR . -If \fInewValue\fR is \fBfull\fR, which is the default, output is buffered -until the internal buffer is full or until \fBchan flush\fR is called. If -\fInewValue\fR is \fBline\fR, output is flushed each time a end-of-line -character is written. If \fInewValue\fR is \fBnone\fR, output is flushed after -every output operation. For \fBstdin\fR, \fBstdout\fR, and channels that -connect to terminal-like devices, the default value is \fBline\fR. For -\fBstderr\fR the default value is \fBnone\fR. +If \fInewValue\fR is \fBfull\fR then the I/O system will buffer output +until its internal buffer is full or until the \fBchan flush\fR +command is invoked. If \fInewValue\fR is \fBline\fR, then the I/O +system will automatically flush output for the channel whenever a +newline character is output. If \fInewValue\fR is \fBnone\fR, the I/O +system will flush automatically after every output operation. The +default is for \fB\-buffering\fR to be set to \fBfull\fR except for +channels that connect to terminal-like devices; for these channels the +initial setting is \fBline\fR. Additionally, \fBstdin\fR and +\fBstdout\fR are initially set to \fBline\fR, and \fBstderr\fR is set +to \fBnone\fR. .\" OPTION: -buffersize .TP \fB\-buffersize\fI newSize\fR . -\fInewSize\fR, an integer no greater than one million, is the size in bytes of -any input or output buffers subsequently allocated for this channel. +\fInewSize\fR must be an integer; its value is used to set the size +of buffers, in bytes, subsequently allocated for this channel to store +input or output. \fInewSize\fR must be a number of no more than one +million, allowing buffers of up to one million bytes in size. .\" OPTION: -encoding .TP \fB\-encoding\fR \fIname\fR . -Sets the encoding of the channel to \fIname\fR which should be one of the names -returned by \fBencoding names\fR, or -.QW \fBbinary\fR -\&. Input is converted from the encoding into Unicode, and output is converted -from Unicode to the encoding. +This option is used to specify the encoding of the channel as one of +the named encodings returned by \fBencoding names\fR or the special +value \fBbinary\fR, so that the data can be converted to and from +Unicode for use in Tcl. For instance, in order for Tcl to read +characters from a Japanese file in \fBshiftjis\fR and properly process +and display the contents, the encoding would be set to \fBshiftjis\fR. +Thereafter, when reading from the channel, the bytes in the Japanese +file would be converted to Unicode as they are read. Writing is also +supported \- as Tcl strings are written to the channel they will +automatically be converted to the specified encoding on output. .RS .PP -\fBbinary\fR is an alias for \fBiso8859-1\fR. This alone is not sufficient for -working with binary data. Use \fB\-translation binary\fR instead. -.PP -The encoding of a new channel is the value of \fBencoding system\fR, -which returns the platform- and locale-dependent system encoding used to -interface with the operating system, +If a file contains pure binary data (for instance, a JPEG image), the +encoding for the channel should be configured to be \fBbinary\fR. Tcl +will then assign no interpretation to the data in the file and simply +read or write raw bytes. The Tcl \fBbinary\fR command can be used to +manipulate this byte-oriented data. It is usually better to set the +\fB\-translation\fR option to \fBbinary\fR when you want to transfer +binary data, as this turns off the other automatic interpretations of +the bytes in the stream as well. +.PP +The default encoding for newly opened channels is the same platform- +and locale-dependent system encoding used for interfacing with the +operating system, as returned by \fBencoding system\fR. .RE .\" OPTION: -eofchar .TP \fB\-eofchar\fI char\fR . -\fIchar\fR signals the end of the data when it is encountered in the input. -If \fIchar\fR is the empty string, there is no special character that marks -the end of the data. -.RS -.PP -The default value is the empty string. The acceptable range is \ex01 - -\ex7F. A value outside this range results in an error. -.RE +This option supports DOS file systems that use Control-z (\ex1A) as an +end of file marker. If \fIchar\fR is not an empty string, then this +character signals end-of-file when it is encountered during input. +Otherwise (the default) there is no special end of file character marker. +The acceptable range for \fB\-eofchar\fR values is \ex01 - \ex7f; +attempting to set \fB\-eofchar\fR to a value outside of this range will +generate an error. .VS "TCL8.7 TIP656" .\" OPTION: -profile .TP @@ -177,32 +217,41 @@ profiles. .TP \fB\-translation\fR \fB{\fIinTranslation outTranslation\fB}\fR . -In Tcl a single line feed (\en) represents the end of a line. However, -at the destination the end of a line may be represented differently on -different platforms, or even for different devices on the same platform. For -example, under UNIX line feed is used in files and a -carriage-return-linefeed sequence is normally used in network connections. -Therefore, on input, e.g. with \fBchan gets\fR and \fBchan read\fR, each -external end-of-line character is translated into a line feed. On -output, e.g. with \fBchan puts\fR, each line feed is translated to the external -end-of-line character. The default translation, \fBauto\fR, handles all the -common cases, and \fB\-translation\fR provides explicit control over the -end-of-line character. +In Tcl scripts the end of a line is always represented using a single +newline character (\en). However, in actual files and devices the end +of a line may be represented differently on different platforms, or +even for different devices on the same platform. For example, under +UNIX newlines are used in files, whereas carriage-return-linefeed +sequences are normally used in network connections. On input (i.e., +with \fBchan gets\fR and \fBchan read\fR) the Tcl I/O system +automatically translates the external end-of-line representation into +newline characters. Upon output (i.e., with \fBchan puts\fR), the I/O +system translates newlines to the external end-of-line representation. +The default translation mode, \fBauto\fR, handles all the common cases +automatically, but the \fB\-translation\fR option provides explicit +control over the end of line translations. .RS .PP -Returns the input translation for a read-only channel, the output translation -for a write-only channel, and both the input translation and the output -translation for a read-write channel. When two translations are given, they -are the input and output translation, respectively. When only one translation -is given for a read-write channel, it is the translation for both input and -output. The following values are currently supported: +The value associated with \fB\-translation\fR is a single item for +read-only and write-only channels. The value is a two-element list for +read-write channels; the read translation mode is the first element of +the list, and the write translation mode is the second element. As a +convenience, when setting the translation mode for a read-write channel +you can specify a single value that will apply to both reading and +writing. When querying the translation mode of a read-write channel, a +two-element list will always be returned. The following values are +currently supported: .IP \fBauto\fR -The default. For input each occurrence of a line feed (\fBlf\fR), carriage -return (\fBcr\fR), or carriage return followed by a line feed (\fBcrlf\fR) is -translated into a line feed. For output, each line feed is translated into a -platform-specific representation: For all Unix variants it is \fBlf\fR, and -for all Windows variants it is \fBcrlf\fR, except that for sockets on all -platforms it is \fBcrlf\fR for both input and output. +As the input translation mode, \fBauto\fR treats any of newline +(\fBlf\fR), carriage return (\fBcr\fR), or carriage return followed by +a newline (\fBcrlf\fR) as the end of line representation. The end of +line representation can even change from line-to-line, and all cases +are translated to a newline. As the output translation mode, +\fBauto\fR chooses a platform specific representation; for sockets on +all platforms Tcl chooses \fBcrlf\fR, for all Unix flavors, it chooses +\fBlf\fR, and for the various flavors of Windows it chooses +\fBcrlf\fR. The default setting for \fB\-translation\fR is \fBauto\fR +for both input and output. .IP \fBbinary\fR Like \fBlf\fR, no end-of-line translation is performed, but in addition, sets \fB\-eofchar\fR to the empty string to disable it, and sets \fB\-encoding\fR @@ -215,21 +264,24 @@ in the data remains in the range of 0 to 255 so that there is no distinction between binary data and text. For example, A JPEG image can be read from a such a channel, manipulated, and then written back to such a channel. .IP \fBcr\fR -The end of a line is represented in the external data by a single carriage -return character. For input, each carriage return is translated to a line -feed, and for output each line feed character is translated to a carriage -return. +The end of a line in the underlying file or device is represented by a +single carriage return character. As the input translation mode, +\fBcr\fR mode converts carriage returns to newline characters. As the +output translation mode, \fBcr\fR mode translates newline characters +to carriage returns. .IP \fBcrlf\fR -The end of a line is represented in the external data by a carriage return -character followed by a line feed. For input, each carriage-return-linefeed -sequence is translated to a line feed. For output, each line feed is -translated to a carriage-return-linefeed sequence. This translation is -typically used for network connections, and also on Windows systems. +The end of a line in the underlying file or device is represented by a +carriage return character followed by a linefeed character. As the +input translation mode, \fBcrlf\fR mode converts +carriage-return-linefeed sequences to newline characters. As the +output translation mode, \fBcrlf\fR mode translates newline characters +to carriage-return-linefeed sequences. This mode is typically used on +Windows platforms and for network connections. .IP \fBlf\fR -The end of a line in the external data is represented by a line feed so no -translations occur during either input or output. This translation is -typically used on UNIX platforms, -.RE +The end of a line in the underlying file or device is represented by a +single newline (linefeed) character. In this mode no translations +occur during either input or output. This mode is typically used on +UNIX platforms. .RE .\" METHOD: copy .TP @@ -274,81 +326,108 @@ error. .TP \fBchan create \fImode cmdPrefix\fR . -Creates a new channel, called a \fBreflected\fR channel, with \fIcmdPrefix\fR -as its handler, and returns the name of the channel. \fBcmdPrefix\fR is the -first words of a command that provides the interface for a \fBrefchan\fR. +This subcommand creates a new script level channel using the command +prefix \fIcmdPrefix\fR as its handler. Any such channel is called a +\fBreflected\fR channel. The specified command prefix, \fBcmdPrefix\fR, +must be a non-empty list, and should provide the API described in the +\fBrefchan\fR manual page. The handle of the new channel is +returned as the result of the \fBchan create\fR command, and the +channel is open. Use either \fBclose\fR or \fBchan close\fR to remove +the channel. .RS .PP -\fBImode\fR is a list of one or more of the strings +The argument \fImode\fR specifies if the new channel is opened for +reading, writing, or both. It has to be a list containing any of the +strings .QW \fBread\fR or .QW \fBwrite\fR , -indicating whether the channel is a read channel, a write channel, or both. -It is an error if the handler does not support the chosen mode. -.PP -The handler is called as needed from the global namespace at the top level, and -command resolution happens there at the time of the call. If the handler is -renamed or deleted any subsequent attempt to call it is an error, which may -not be able to describe the failure. -.PP -The handler is always called in the interpreter and thread it was created in, -even if the channel was shared with or moved into a different interpreter in a -different thread. This is achieved through event dispatch, so if the event -loop is not entered, e.g. by calling \fBTcl_DoOneEvent\fR or \fBvwait\fR or -using Tk, the thread performing the channel operation \fIblocks -indefinitely\fR, resulting in deadlock. -.PP -One side of a channel may be in one thread while the other side is in a -different thread, providing a stream-oriented bridge between the threads. This -provides a method for regular stream communication between threads as an -alternative to sending commands. -.PP -When the interpreter the handler is in is deleted each channel associated with -the handler is deleted as well, regardless of which interpreter or thread it -is currently in or shared with. -.PP -\fBchan create\fR is \fBsafe\fR and is accessible to safe interpreters. The -handler is always called in the safe interpreter it was created in. +The list must have at least one +element, as a channel you can neither write to nor read from makes no +sense. The handler command for the new channel must support the chosen +mode, or an error is thrown. +.PP +The command prefix is executed in the global namespace, at the top of +call stack, following the appending of arguments as described in the +\fBrefchan\fR manual page. Command resolution happens at the +time of the call. Renaming the command, or destroying it means that +the next call of a handler method may fail, causing the channel +command invoking the handler to fail as well. Depending on the +subcommand being invoked, the error message may not be able to explain +the reason for that failure. +.PP +Every channel created with this subcommand knows which interpreter it +was created in, and only ever executes its handler command in that +interpreter, even if the channel was shared with and/or was moved into +a different interpreter. Each reflected channel also knows the thread +it was created in, and executes its handler command only in that +thread, even if the channel was moved into a different thread. To this +end all invocations of the handler are forwarded to the original +thread by posting special events to it. This means that the original +thread (i.e. the thread that executed the \fBchan create\fR command) +must have an active event loop, i.e. it must be able to process such +events. Otherwise the thread sending them will \fIblock +indefinitely\fR. Deadlock may occur. +.PP +Note that this permits the creation of a channel whose two endpoints +live in two different threads, providing a stream-oriented bridge +between these threads. In other words, we can provide a way for +regular stream communication between threads instead of having to send +commands. +.PP +When a thread or interpreter is deleted, all channels created with +this subcommand and using this thread/interpreter as their computing +base are deleted as well, in all interpreters they have been shared +with or moved into, and in whatever thread they have been transferred +to. While this pulls the rug out under the other thread(s) and/or +interpreter(s), this cannot be avoided. Trying to use such a channel +will cause the generation of a regular error about unknown channel +handles. +.PP +This subcommand is \fBsafe\fR and made accessible to safe +interpreters. While it arranges for the execution of arbitrary Tcl +code the system also makes sure that the code is always executed +within the safe interpreter. .RE .\" METHOD: eof .TP -\fBchan eof \fIchannelName\fR +\fBchan eof \fIchannelId\fR . -Returns 1 if the last read on the channel failed because the end of the data -was already reached, and 0 otherwise. +Test whether the last input operation on the channel called +\fIchannelId\fR failed because the end of the data stream was reached, +returning 1 if end-of-file was reached, and 0 otherwise. .\" METHOD: event .TP -\fBchan event \fIchannelName event\fR ?\fIscript\fR? +\fBchan event \fIchannelId event\fR ?\fIscript\fR? . -Arranges for the given script, called a \fBchannel event handler\fR, to be -called whenever the given event, one of -.QW \fBreadable\fR -or -.QW \fBwritable\fR -occurs on the given channel, replacing any script that was previously set. If -\fIscript\fR is the empty string the current handler is deleted. It is also -deleted when the channel is closed. If \fIscript\fR is omitted, either the -existing script or the empty string is returned. The event loop must be -entered, e.g. via \fBvwait\fR or \fBupdate\fR, or by using Tk, for handlers to -be evaluated. +Arrange for the Tcl script \fIscript\fR to be installed as a \fIfile +event handler\fR to be called whenever the channel called +\fIchannelId\fR enters the state described by \fIevent\fR (which must +be either \fBreadable\fR or \fBwritable\fR); only one such handler may +be installed per event per channel at a time. If \fIscript\fR is the +empty string, the current handler is deleted (this also happens if the +channel is closed or the interpreter deleted). If \fIscript\fR is +omitted, the currently installed script is returned (or an empty +string if no such handler is installed). The callback is only +performed if the event loop is being serviced (e.g. via \fBvwait\fR or +\fBupdate\fR). .RS .PP -\fIscript\fR is evaluated at the global level in the interpreter it was -established in. Any resulting error is handled in the background, i.e. via -\fBinterp bgerror\fR. In order to prevent an endless loop due to a buggy -handler, the handler is deleted if \fIscript\fR returns an error so that it is -not evaluated again. -.PP -Without an event handler, \fBchan gets\fR or \fBchan read\fR on a channel in -blocking mode may block until data becomes available, during which the -thread is unable to perform other work or respond to events on other channels. -This could cause the application to appear to +A file event handler is a binding between a channel and a script, such +that the script is evaluated whenever the channel becomes readable or +writable. File event handlers are most commonly used to allow data to +be received from another process on an event-driven basis, so that the +receiver can continue to interact with the user or with other channels +while waiting for the data to arrive. If an application invokes +\fBchan gets\fR or \fBchan read\fR on a blocking channel when there is +no input data available, the process will block; until the input data +arrives, it will not be able to service other events, so it will +appear to the user to .QW "freeze up" \&. -Channel event handlers allow events on the channel to direct channel handling -so that the reader or writer can continue to perform other processing while -waiting for a channel to become available and then handle channel operations -when the channel is ready for the operation. +With \fBchan event\fR, the +process can tell when data is present and only invoke \fBchan gets\fR +or \fBchan read\fR when they will not block. .PP A channel is considered to be readable if there is unread data available on the underlying device. A channel is also considered to @@ -364,29 +443,47 @@ there is no special check for end of file, an infinite loop may occur where \fIscript\fR reads no data, returns, and is immediately invoked again. .PP -A channel is considered to be writable if at least one byte of data can be -written to the underlying file or device without blocking, or if an error -condition is present. Note that client sockets opened in asynchronous mode -become writable when they become connected or if the connection fails. -.PP -Event-driven channel handling works best for channels in non-blocking mode. A -channel in blocking mode blocks when \fBchan puts\fR writes more data than the -channel can accept at the moment, and when \fBchan gets\fR or \fBchan read\fR -requests more data than is currently available. When a channel blocks, the -thread can not do any other processing or service any other events. A channel -in non-blocking mode allows a thread to carry on with other work and get back -to the channel at the right time. +A channel is considered to be writable if at least one byte of data +can be written to the underlying file or device without blocking, or +if an error condition is present on the underlying file or device. +Note that client sockets opened in asynchronous mode become writable +when they become connected or if the connection fails. +.PP +Event-driven I/O works best for channels that have been placed into +non-blocking mode with the \fBchan configure\fR command. In blocking +mode, a \fBchan puts\fR command may block if you give it more data +than the underlying file or device can accept, and a \fBchan gets\fR +or \fBchan read\fR command will block if you attempt to read more data +than is ready; no events will be processed while the commands block. +In non-blocking mode \fBchan puts\fR, \fBchan read\fR, and \fBchan +gets\fR never block. +.PP +The script for a file event is executed at global level (outside the +context of any Tcl procedure) in the interpreter in which the \fBchan +event\fR command was invoked. If an error occurs while executing the +script then the command registered with \fBinterp bgerror\fR is used +to report the error. In addition, the file event handler is deleted +if it ever returns an error; this is done in order to prevent infinite +loops due to buggy handlers. .RE .\" METHOD: flush .TP -\fBchan flush \fIchannelName\fR +\fBchan flush \fIchannelId\fR . -For a channel in blocking mode, flushes all buffered output to the destination, -and then returns. For a channel in non-blocking mode, returns immediately -while all buffered output is flushed in the background as soon as possible. +Ensures that all pending output for the channel called \fIchannelId\fR +is written. +.RS +.PP +If the channel is in blocking mode the command does not return until +all the buffered output has been flushed to the channel. If the +channel is in non-blocking mode, the command may return before all +buffered output has been flushed; the remainder will be flushed in the +background as fast as the underlying file or device is able to absorb +it. +.RE .\" METHOD: gets .TP -\fBchan gets \fIchannelName\fR ?\fIvarName\fR? +\fBchan gets \fIchannelId\fR ?\fIvarName\fR? . Reads a line from the channel consisting of all characters up to the next end-of-line sequence or until end of file is seen. The line feed character @@ -434,126 +531,142 @@ changing the encoding in use. See \fBENCODING ERROR EXAMPLES\fR later. .TP \fBchan names\fR ?\fIpattern\fR? . -Returns a list of all channel names, or if \fIpattern\fR is given, only those -names that match according to the rules of \fBstring match\fR. +Produces a list of all channel names. If \fIpattern\fR is specified, +only those channel names that match it (according to the rules of +\fBstring match\fR) will be returned. .\" METHOD: pending .TP -\fBchan pending \fImode channelName\fR +\fBchan pending \fImode channelId\fR . -Returns the number of bytes of input -when \fImode\fR is -.QW\fBinput\fR -, or output when \fImode\fR is -.QW\fBoutput\fR -, that are currently internally buffered for the channel. Useful in a readable -event callback to impose limits on input line length to avoid a potential -denial-of-service attack where an extremely long line exceeds the available -memory to buffer it. Returns -1 if the channel was not opened for the mode in -question. +Depending on whether \fImode\fR is \fBinput\fR or \fBoutput\fR, +returns the number of +bytes of input or output (respectively) currently buffered +internally for \fIchannelId\fR (especially useful in a readable event +callback to impose application-specific limits on input line lengths to avoid +a potential denial-of-service attack where a hostile user crafts +an extremely long line that exceeds the available memory to buffer it). +Returns -1 if the channel was not opened for the mode in question. .\" METHOD: pipe .TP \fBchan pipe\fR . -Creates a pipe, i.e. a readable channel and a writable channel, and returns the -names of the readable channel and the writable channel. Data written to the -writable channel can be read from the readable channel. Because the pipe is a -real system-level pipe, it can be connected to other processes using -redirection. For example, to redirect \fBstderr\fR from a subprocess into one -channel, and \fBstdout\fR into another, \fBexec\fR with "2>@" and ">@", each -onto the writable side of a pipe, closing the writable side immediately -thereafter so that EOF is signaled on the read side once the subprocess has -closed its output, typically on exit. +Creates a standalone pipe whose read- and write-side channels are +returned as a 2-element list, the first element being the read side and +the second the write side. Can be useful e.g. to redirect +separately \fBstderr\fR and \fBstdout\fR from a subprocess. To do +this, spawn with "2>@" or +">@" redirection operators onto the write side of a pipe, and then +immediately close it in the parent. This is necessary to get an EOF on +the read side once the child has exited or otherwise closed its output. .RS .PP -Due to buffering, data written to one side of a pipe might not immediately -become available on the other side. Tcl's own buffers can be configured via -\fBchan configure -buffering\fR, but overall behaviour still depends on -operating system buffers outside of Tcl's control. Once the write side of the -channel is closed, any data remaining in the buffers is flushed through to the -read side. It may be useful to arrange for the connected process to flush at -some point after writing to the channel or to have it use some system-provided -mechanism to configure buffering. When two pipes are connected to the same -process, one to send data to the process, and one to read data from the -process, a deadlock may occur if the channels are in blocking mode: If -reading, the channel may block waiting for data that can never come because -buffers are only flushed on subsequent writes, and if writing, the channel may -block while waiting for the buffers to become free, which can never happen -because the reader can not read while the writer is blocking. To avoid this -issue, either put the channels into non-blocking mode and use event handlers, -or place the read channel and the write channel in separate interpreters in -separate threads. +Note that the pipe buffering semantics can vary at the operating system level +substantially; it is not safe to assume that a write performed on the output +side of the pipe will appear instantly to the input side. This is a +fundamental difference and Tcl cannot conceal it. The overall stream semantics +\fIare\fR compatible, so blocking reads and writes will not see most of the +differences, but the details of what exactly gets written when are not. This +is most likely to show up when using pipelines for testing; care should be +taken to ensure that deadlocks do not occur and that potential short reads are +allowed for. .RE .\" METHOD: pop .TP -\fBchan pop \fIchannelName\fR +\fBchan pop \fIchannelId\fR . -Removes the topmost transformation handler from the channel if there is one, -and closes the channel otherwise. The result is normally the empty string, but -may be an error in some situations, e.g. when closing the underlying resource -results in an error. +Removes the topmost transformation from the channel \fIchannelId\fR, if there +is any. If there are no transformations added to \fIchannelId\fR, this is +equivalent to \fBchan close\fR of that channel. The result is normally the +empty string, but can be an error in some situations (i.e. where the +underlying system stream is closed and that results in an error). .\" METHOD: postevent .TP -\fBchan postevent \fIchannelName eventSpec\fR +\fBchan postevent \fIchannelId eventSpec\fR . -For use by handlers established with \fBchan create\fR. Notifies Tcl that -that one or more event(s) listed in \fIeventSpec\fR, each of which is either -.QW\fBread\fR -or -.QW\fBwrite\fR. -, have occurred. +This subcommand is used by command handlers specified with \fBchan +create\fR. It notifies the channel represented by the handle +\fIchannelId\fR that the event(s) listed in the \fIeventSpec\fR have +occurred. The argument has to be a list containing any of the strings +\fBread\fR and \fBwrite\fR. The list must contain at least one +element as it does not make sense to invoke the command if there are +no events to post. .RS .PP -For use only by handlers for a channel created by \fBchan create\fR. It is an -error to post an event for any other channel. -.PP -Since only the handler for a reflected channel channel should post events it is -an error to post an event from any interpreter other than the interpreter that -created the channel. -.PP -It is an error to post an event that the channel has no interest in. See -\fBwatch\fR in the \fBrefchan\fR documentation for more information -.PP -\fBchan postevent\fR is available in safe interpreters, as any handler for a -reflected channel would have been created, and will be evaluated in that -interpreter as well. +Note that this subcommand can only be used with channel handles that +were created/opened by \fBchan create\fR. All other channels will +cause this subcommand to report an error. +.PP +As only the Tcl level of a channel, i.e. its command handler, should +post events to it we also restrict the usage of this command to the +interpreter that created the channel. In other words, posting events +to a reflected channel from an interpreter that does not contain it's +implementation is not allowed. Attempting to post an event from any +other interpreter will cause this subcommand to report an error. +.PP +Another restriction is that it is not possible to post events that the +I/O core has not registered an interest in. Trying to do so will cause +the method to throw an error. See the command handler method +\fBwatch\fR described in \fBrefchan\fR, the document specifying +the API of command handlers for reflected channels. +.PP +This command is \fBsafe\fR and made accessible to safe interpreters. +It can trigger the execution of \fBchan event\fR handlers, whether in the +current interpreter or in other interpreters or other threads, even +where the event is posted from a safe interpreter and listened for by +a trusted interpreter. \fBChan event\fR handlers are \fIalways\fR +executed in the interpreter that set them up. .RE .\" METHOD: push .TP -\fBchan push \fIchannelName cmdPrefix\fR +\fBchan push \fIchannelId cmdPrefix\fR . -Adds a new transformation handler on top of the channel and returns a handle -for the transformation. \fIcmdPrefix\fR is the first words of a command that -provides the interface documented for \fBtranschan\fR, and transforms data on -the channel, It is an error if handler does not support the mode(s) the channel -is in. +Adds a new transformation on top of the channel \fIchannelId\fR. The +\fIcmdPrefix\fR argument describes a list of one or more words which represent +a handler that will be used to implement the transformation. The command +prefix must provide the API described in the \fBtranschan\fR manual page. +The result of this subcommand is a handle to the transformation. Note that it +is important to make sure that the transformation is capable of supporting the +channel mode that it is used with or this can make the channel neither +readable nor writable. .\" METHOD: puts .TP -\fBchan puts\fR ?\fB\-nonewline\fR? ?\fIchannelName\fR? \fIstring\fR +\fBchan puts\fR ?\fB\-nonewline\fR? ?\fIchannelId\fR? \fIstring\fR . -Writes \fIstring\fR and a line feed to the channel. If \fB\-nonewline\fR is -given, the trailing line feed is not written. The default channel is +Writes \fIstring\fR to the channel named \fIchannelId\fR followed by a +newline character. A trailing newline character is written unless the +optional flag \fB\-nonewline\fR is given. If \fIchannelId\fR is +omitted, the string is written to the standard output channel, \fBstdout\fR. .RS .PP -Each line feed in the output is translated to the appropriate end of line -sequence as per the \fB\-translation\fR configuration setting of the channel. -.PP -Because Tcl internally buffers output, characters written to a channel may not -immediately be available at the destination. Tcl normally delays output until -the buffer is full or the channel is closed. \fBchan flush\fR forces output in -the direction of the destination. -.PP -When the output for a channel in blocking mode fills up, \fBchan puts\fR blocks -until space in the buffer is available again. On the other hand for a channel in -non-blocking mode, it returns immediately and the data is written in the -background as fast possible, constrained by the speed at which as the -destination accepts it. Output to a channel in non-blocking mode only works -properly when the application enters the event loop. When a channel is in -non-blocking mode, Tcl's internal buffers can hold an arbitrary amount of data, -possibly consuming a large amount of memory. To avoid wasting memory, channels -in non-blocking mode should normally be handled using \fBchan event\fR, where -the application only invokes \fBchan puts\fR after being notified through a file -event handler that the channel is ready for more output data. +Newline characters in the output are translated by \fBchan puts\fR to +platform-specific end-of-line sequences according to the currently +configured value of the \fB\-translation\fR option for the channel +(for example, on PCs newlines are normally replaced with +carriage-return-linefeed sequences; see \fBchan configure\fR above for +details). +.PP +Tcl buffers output internally, so characters written with \fBchan +puts\fR may not appear immediately on the output file or device; Tcl +will normally delay output until the buffer is full or the channel is +closed. You can force output to appear immediately with the \fBchan +flush\fR command. +.PP +When the output buffer fills up, the \fBchan puts\fR command will +normally block until all the buffered data has been accepted for +output by the operating system. If \fIchannelId\fR is in non-blocking +mode then the \fBchan puts\fR command will not block even if the +operating system cannot accept the data. Instead, Tcl continues to +buffer the data and writes it in the background as fast as the +underlying file or device can accept it. The application must use the +Tcl event loop for non-blocking output to work; otherwise Tcl never +finds out that the file or device is ready for more output data. It +is possible for an arbitrarily large amount of data to be buffered for +a channel in non-blocking mode, which could consume a large amount of +memory. To avoid wasting memory, non-blocking I/O should normally be +used in an event-driven fashion with the \fBchan event\fR command +(do not invoke \fBchan puts\fR unless you have recently been notified +via a file event that the channel is ready for more output data). .PP The command will raise an error exception with POSIX error code \fBEILSEQ\fR if the encoding profile \fBstrict\fR is in effect for the channel and the output @@ -562,34 +675,58 @@ may be partially written to the channel in this case. .RE .\" METHOD: read .TP -\fBchan read \fIchannelName\fR ?\fInumChars\fR? +\fBchan read \fIchannelId\fR ?\fInumChars\fR? .TP -\fBchan read \fR?\fB\-nonewline\fR? \fIchannelName\fR +\fBchan read \fR?\fB\-nonewline\fR? \fIchannelId\fR . -Reads and returns the next \fInumChars\fR characters from the channel. If -\fInumChars\fR is omitted, all available characters up to the end of the file -are read, or if the channel is in non-blocking mode, all currently-available -characters are read. If there is an error on the channel, reading ceases and -an error is returned. If \fInumChars\fR is not given, \fB\-nonewline\fR -may be given, causing any trailing line feed to be trimmed. +In the first form, the result will be the next \fInumChars\fR +characters read from the channel named \fIchannelId\fR; if +\fInumChars\fR is omitted, all characters up to the point when the +channel would signal a failure (whether an end-of-file, blocked or +other error condition) are read. In the second form (i.e. when +\fInumChars\fR has been omitted) the flag \fB\-nonewline\fR may be +given to indicate that any trailing newline in the string that has +been read should be trimmed. .RS .PP -If the channel is in non-blocking mode, fewer characters than requested may be -returned. If the channel is configured to use a multi-byte encoding, bytes -that do not form a complete character are retained in the buffers until enough -bytes to complete the character accumulate, or the end of the data is reached. -\fB\-nonewline\fR is ignored if characters are returned before reaching the end -of the file. +If \fIchannelId\fR is in non-blocking mode, \fBchan read\fR may not +read as many characters as requested: once all available input has +been read, the command will return the data that is available rather +than blocking for more input. If the channel is configured to use a +multi-byte encoding, then there may actually be some bytes remaining +in the internal buffers that do not form a complete character. These +bytes will not be returned until a complete character is available or +end-of-file is reached. The \fB\-nonewline\fR switch is ignored if +the command returns before reaching the end of the file. +.PP +\fBChan read\fR translates end-of-line sequences in the input into +newline characters according to the \fB\-translation\fR option for the +channel (see \fBchan configure\fR above for a discussion on the ways +in which \fBchan configure\fR will alter input). .PP -Each end-of-line sequence according to the value of \fB\-translation\fR is -translated into a line feed. +When reading from a serial port, most applications should configure +the serial port channel to be non-blocking, like this: .PP -When reading from a serial port, most applications should configure the serial -port channel to be in non-blocking mode, but not necessarily use an event -handler since most serial ports are comparatively slow. It is entirely -possible to get a \fBreadable\fR event for each individual character. In -blocking mode, \fBchan read\fR blocks forever when reading to the end of the -data if there is no \fBchan configure -eofchar\fR configured for the channel. +.CS +\fBchan configure \fIchannelId \fB\-blocking \fI0\fR. +.CE +.PP +Then \fBchan read\fR behaves much like described above. Note that +most serial ports are comparatively slow; it is entirely possible to +get a \fBreadable\fR event for each character read from them. Care +must be taken when using \fBchan read\fR on blocking serial ports: +.TP +\fBchan read \fIchannelId numChars\fR +. +In this form \fBchan read\fR blocks until \fInumChars\fR have been +received from the serial port. +.TP +\fBchan read \fIchannelId\fR +. +In this form \fBchan read\fR blocks until the reception of the +end-of-file character, see \fBchan configure -eofchar\fR. If there no +end-of-file character has been configured for the channel, then +\fBchan read\fR will block forever. .PP If the encoding profile \fBstrict\fR is in effect for the channel, the command will raise an exception with the POSIX error code \fBEILSEQ\fR if any encoding @@ -608,41 +745,56 @@ changing the encoding in use. See \fBENCODING ERROR EXAMPLES\fR later. .RE .\" METHOD: seek .TP -\fBchan seek \fIchannelName offset\fR ?\fIorigin\fR? +\fBchan seek \fIchannelId offset\fR ?\fIorigin\fR? . -Sets the current position for the data in the channel to integer \fIoffset\fR -bytes relative to \fIorigin\fR. A negative offset moves the current position -backwards from the origin. \fIorigin\fR is one of the -following: +Sets the current access position within the underlying data stream for +the channel named \fIchannelId\fR to be \fIoffset\fR bytes relative to +\fIorigin\fR. \fIOffset\fR must be an integer (which may be negative) +and \fIorigin\fR must be one of the following: .RS .IP \fBstart\fR -The origin is the start of the data. This is the default. +The new access position will be \fIoffset\fR bytes from the start +of the underlying file or device. .IP \fBcurrent\fR -The origin is the current position. +The new access position will be \fIoffset\fR bytes from the current +access position; a negative \fIoffset\fR moves the access position +backwards in the underlying file or device. .IP \fBend\fR -The origin is the end of the data. -.PP -\fBChan seek\fR flushes all buffered output even if the channel is in -non-blocking mode, discards any buffered and unread input, and returns the -empty string or an error if the channel does not support seeking. -.PP -\fIoffset\fR values are byte offsets, not character offsets. Unlike \fBchan -read\fR, both \fBchan seek\fR and \fBchan tell\fR operate in terms of bytes, -not characters, +The new access position will be \fIoffset\fR bytes from the end of the +file or device. A negative \fIoffset\fR places the access position +before the end of file, and a positive \fIoffset\fR places the access +position after the end of file. +.PP +The \fIorigin\fR argument defaults to \fBstart\fR. +.PP +\fBChan seek\fR flushes all buffered output for the channel before the +command returns, even if the channel is in non-blocking mode. It also +discards any buffered and unread input. This command returns an empty +string. An error occurs if this command is applied to channels whose +underlying file or device does not support seeking. +.PP +Note that \fIoffset\fR values are byte offsets, not character offsets. +Both \fBchan seek\fR and \fBchan tell\fR operate in terms of bytes, +not characters, unlike \fBchan read\fR. .RE .\" METHOD: tell .TP -\fBchan tell \fIchannelName\fR +\fBchan tell \fIchannelId\fR . -Returns the offset in bytes of the current position in the underlying data, or --1 if the channel does not support seeking. The value can be passed to \fBchan -seek\fR to set current position to that offset. +Returns a number giving the current access position within the +underlying data stream for the channel named \fIchannelId\fR. This +value returned is a byte offset that can be passed to \fBchan seek\fR +in order to set the channel to a particular position. Note that this +value is in terms of bytes, not characters like \fBchan read\fR. The +value returned is -1 for channels that do not support seeking. .\" METHOD: truncate .TP -\fBchan truncate \fIchannelName\fR ?\fIlength\fR? +\fBchan truncate \fIchannelId\fR ?\fIlength\fR? . -Flushes the channel and truncates the data in the channel to \fIlength\fR -bytes, or to the current position in bytes if \fIlength\fR is omitted. +Sets the byte length of the underlying data stream for the channel +named \fIchannelId\fR to be \fIlength\fR (or to the current byte +offset within the underlying data stream if \fIlength\fR is +omitted). The channel is flushed before truncation. . .SH EXAMPLES .SS "SIMPLE CHANNEL OPERATION EXAMPLES" @@ -753,7 +905,7 @@ preventing servicing of other connections at the same time: .PP .CS # This is a very simple logger... -proc log message { +proc log {message} { \fBchan puts\fR stdout $message } -- cgit v0.12 From a631afc83cc4a3cd380cad19a08399ee6f1cdeb0 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 11 Jun 2024 22:12:32 +0000 Subject: channelName -> channelId, for consistancy with other *.n manpages --- doc/transchan.n | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/transchan.n b/doc/transchan.n index a511c75..abae7b9 100644 --- a/doc/transchan.n +++ b/doc/transchan.n @@ -12,7 +12,7 @@ transchan \- command handler API of channel transforms .SH SYNOPSIS .nf -\fBchan push \fIchannelName cmdPrefix\fR +\fBchan push \fIchannelId cmdPrefix\fR \fIcmdPrefix \fBclear \fIhandle\fR \fIcmdPrefix \fBdrain \fIhandle\fR -- cgit v0.12 From d25acf4fe1b750bbb6934d1d6e1824a9ff7d17a1 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 12 Jun 2024 11:00:47 +0000 Subject: Tcl_AppendResultVA() is gone in Tcl 9.0 --- doc/SetResult.3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/SetResult.3 b/doc/SetResult.3 index 8c89280..d3201aa 100644 --- a/doc/SetResult.3 +++ b/doc/SetResult.3 @@ -234,7 +234,7 @@ interpreter result value; it should be copied instead of being relied upon to persist after the next Tcl API call, as most Tcl operations can modify the interpreter result. .PP -\fBTcl_SetResult\fR, \fBTcl_AppendResult\fR, \fBTcl_AppendResultVA\fR, +\fBTcl_SetResult\fR, \fBTcl_AppendResult\fR, \fBTcl_AppendElement\fR, and \fBTcl_ResetResult\fR all modify the interpreter result. They may cause the old interpreter result to have its reference count decremented and a new interpreter result to be allocated. After they have been -- cgit v0.12 From 0e43541e97cd06609288045cabdba0a25d46d2f1 Mon Sep 17 00:00:00 2001 From: dkf Date: Wed, 12 Jun 2024 20:24:40 +0000 Subject: Fix some indentation/wrapping for style --- generic/tclEncoding.c | 280 +++++++++++++++++++++++++++----------------------- 1 file changed, 153 insertions(+), 127 deletions(-) diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 129ca51..624705d 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -34,9 +34,9 @@ typedef struct { Tcl_EncodingFreeProc *freeProc; /* If non-NULL, function to call when this * encoding is deleted. */ - void *clientData; /* Arbitrary value associated with encoding + void *clientData; /* Arbitrary value associated with encoding * type. Passed to conversion functions. */ - Tcl_Size nullSize; /* Number of 0x00 bytes that signify + Tcl_Size nullSize; /* Number of 0x00 bytes that signify * end-of-string in this encoding. This number * is used to determine the source string * length when the srcLen argument is @@ -119,7 +119,8 @@ typedef struct { * entry in this array is 1, otherwise it is * 0. */ int numSubTables; /* Length of following array. */ - EscapeSubTable subTables[TCLFLEXARRAY];/* Information about each EscapeSubTable used + EscapeSubTable subTables[TCLFLEXARRAY]; + /* Information about each EscapeSubTable used * by this encoding type. The actual size is * as large as necessary to hold all * EscapeSubTables. */ @@ -201,19 +202,19 @@ static const struct TclEncodingProfiles { {"tcl8", TCL_ENCODING_PROFILE_TCL8}, }; -#define PROFILE_TCL8(flags_) \ +#define PROFILE_TCL8(flags_) \ (ENCODING_PROFILE_GET(flags_) == TCL_ENCODING_PROFILE_TCL8) -#define PROFILE_REPLACE(flags_) \ +#define PROFILE_REPLACE(flags_) \ (ENCODING_PROFILE_GET(flags_) == TCL_ENCODING_PROFILE_REPLACE) -#define PROFILE_STRICT(flags_) \ +#define PROFILE_STRICT(flags_) \ (!PROFILE_TCL8(flags_) && !PROFILE_REPLACE(flags_)) #define UNICODE_REPLACE_CHAR 0xFFFD -#define SURROGATE(c_) (((c_) & ~0x7FF) == 0xD800) -#define HIGH_SURROGATE(c_) (((c_) & ~0x3FF) == 0xD800) -#define LOW_SURROGATE(c_) (((c_) & ~0x3FF) == 0xDC00) +#define SURROGATE(c_) (((c_) & ~0x7FF) == 0xD800) +#define HIGH_SURROGATE(c_) (((c_) & ~0x3FF) == 0xD800) +#define LOW_SURROGATE(c_) (((c_) & ~0x3FF) == 0xDC00) /* * The following variable is used in the sparse matrix code for a @@ -259,9 +260,9 @@ static Tcl_EncodingConvertProc Iso88591FromUtfProc; static Tcl_EncodingConvertProc Iso88591ToUtfProc; /* - * A Tcl_ObjType for holding a cached Tcl_Encoding in the twoPtrValue.ptr1 field - * of the internalrep. This should help the lifetime of encodings be more useful. - * See concerns raised in [Bug 1077262]. + * A Tcl_ObjType for holding a cached Tcl_Encoding in the twoPtrValue.ptr1 + * field of the internalrep. This should help the lifetime of encodings be more + * useful. See concerns raised in [Bug 1077262]. */ static const Tcl_ObjType encodingType = { @@ -510,9 +511,13 @@ FillEncodingFileMap(void) * * To prevent conflicting bits, only define bits within 0xff00 mask here. */ -#define TCL_ENCODING_LE 0x100 /* Used to distinguish LE/BE variants */ -#define ENCODING_UTF 0x200 /* For UTF-8 encoding, allow 4-byte output sequences */ -#define ENCODING_INPUT 0x400 /* For UTF-8/CESU-8 encoding, means external -> internal */ +enum InternalEncodingFlags { + TCL_ENCODING_LE = 0x100, /* Used to distinguish LE/BE variants */ + ENCODING_UTF = 0x200, /* For UTF-8 encoding, allow 4-byte output + * sequences */ + ENCODING_INPUT = 0x400 /* For UTF-8/CESU-8 encoding, means + * external -> internal */ +}; void TclInitEncodingSubsystem(void) @@ -565,30 +570,30 @@ TclInitEncodingSubsystem(void) Tcl_CreateEncoding(&type); type.toUtfProc = Utf16ToUtfProc; - type.fromUtfProc = UtfToUcs2Proc; + type.fromUtfProc = UtfToUcs2Proc; type.freeProc = NULL; type.nullSize = 2; - type.encodingName = "ucs-2le"; + type.encodingName = "ucs-2le"; type.clientData = INT2PTR(TCL_ENCODING_LE); Tcl_CreateEncoding(&type); - type.encodingName = "ucs-2be"; + type.encodingName = "ucs-2be"; type.clientData = NULL; Tcl_CreateEncoding(&type); - type.encodingName = "ucs-2"; + type.encodingName = "ucs-2"; type.clientData = INT2PTR(leFlags); Tcl_CreateEncoding(&type); type.toUtfProc = Utf32ToUtfProc; - type.fromUtfProc = UtfToUtf32Proc; + type.fromUtfProc = UtfToUtf32Proc; type.freeProc = NULL; type.nullSize = 4; - type.encodingName = "utf-32le"; + type.encodingName = "utf-32le"; type.clientData = INT2PTR(TCL_ENCODING_LE); Tcl_CreateEncoding(&type); - type.encodingName = "utf-32be"; + type.encodingName = "utf-32be"; type.clientData = NULL; Tcl_CreateEncoding(&type); - type.encodingName = "utf-32"; + type.encodingName = "utf-32"; type.clientData = INT2PTR(leFlags); Tcl_CreateEncoding(&type); @@ -596,18 +601,18 @@ TclInitEncodingSubsystem(void) type.fromUtfProc = UtfToUtf16Proc; type.freeProc = NULL; type.nullSize = 2; - type.encodingName = "utf-16le"; + type.encodingName = "utf-16le"; type.clientData = INT2PTR(TCL_ENCODING_LE); Tcl_CreateEncoding(&type); - type.encodingName = "utf-16be"; + type.encodingName = "utf-16be"; type.clientData = NULL; Tcl_CreateEncoding(&type); - type.encodingName = "utf-16"; + type.encodingName = "utf-16"; type.clientData = INT2PTR(leFlags); Tcl_CreateEncoding(&type); #ifndef TCL_NO_DEPRECATED - type.encodingName = "unicode"; + type.encodingName = "unicode"; Tcl_CreateEncoding(&type); #endif @@ -924,7 +929,7 @@ Tcl_GetEncodingNames( * Tcl_GetEncodingNulLength -- * * Given an encoding, return the number of nul bytes used for the - * string termination. + * string termination. * * Results: * The number of nul bytes used for the string termination. @@ -1124,34 +1129,33 @@ Tcl_ExternalToUtfDString( * - *At most one* of TCL_ENCODING_PROFILE{DEFAULT,TCL8,STRICT} * * Results: - * The return value is one of - * TCL_OK: success. Converted string in *dstPtr - * TCL_ERROR: error in passed parameters. Error message in interp - * TCL_CONVERT_MULTIBYTE: source ends in truncated multibyte sequence - * TCL_CONVERT_SYNTAX: source is not conformant to encoding definition - * TCL_CONVERT_UNKNOWN: source contained a character that could not - * be represented in target encoding. + * The return value is one of + * TCL_OK: success. Converted string in *dstPtr + * TCL_ERROR: error in passed parameters. Error message in interp + * TCL_CONVERT_MULTIBYTE: source ends in truncated multibyte sequence + * TCL_CONVERT_SYNTAX: source is not conformant to encoding definition + * TCL_CONVERT_UNKNOWN: source contained a character that could not + * be represented in target encoding. * * Side effects: - * - * TCL_OK: The converted bytes are stored in the DString and NUL - * terminated in an encoding-specific manner. - * TCL_ERROR: an error, message is stored in the interp if not NULL. - * TCL_CONVERT_*: if errorLocPtr is NULL, an error message is stored - * in the interpreter (if not NULL). If errorLocPtr is not NULL, - * no error message is stored as it is expected the caller is - * interested in whatever is decoded so far and not treating this - * as an error condition. - * - * In addition, *dstPtr is always initialized and must be cleared - * by the caller irrespective of the return code. + * TCL_OK: The converted bytes are stored in the DString and NUL + * terminated in an encoding-specific manner. + * TCL_ERROR: an error, message is stored in the interp if not NULL. + * TCL_CONVERT_*: if errorLocPtr is NULL, an error message is stored + * in the interpreter (if not NULL). If errorLocPtr is not NULL, + * no error message is stored as it is expected the caller is + * interested in whatever is decoded so far and not treating this + * as an error condition. + * + * In addition, *dstPtr is always initialized and must be cleared + * by the caller irrespective of the return code. * *------------------------------------------------------------------------- */ int Tcl_ExternalToUtfDStringEx( - Tcl_Interp *interp, /* For error messages. May be NULL. */ + Tcl_Interp *interp, /* For error messages. May be NULL. */ Tcl_Encoding encoding, /* The encoding for the source string, or NULL * for the default system encoding. */ const char *src, /* Source string in specified encoding. */ @@ -1160,8 +1164,8 @@ Tcl_ExternalToUtfDStringEx( int flags, /* Conversion control flags. */ Tcl_DString *dstPtr, /* Uninitialized or free DString in which the * converted string is stored. */ - Tcl_Size *errorLocPtr) /* Where to store the error location - * (or TCL_INDEX_NONE if no error). May + Tcl_Size *errorLocPtr) /* Where to store the error location + * (or TCL_INDEX_NONE if no error). May * be NULL. */ { char *dst; @@ -1231,18 +1235,21 @@ Tcl_ExternalToUtfDStringEx( * Do not write error message into interpreter if caller * wants to know error location. */ - *errorLocPtr = result == TCL_OK ? TCL_INDEX_NONE : nBytesProcessed; + *errorLocPtr = result == TCL_OK + ? TCL_INDEX_NONE : nBytesProcessed; } else { /* Caller wants error message on failure */ if (result != TCL_OK && interp != NULL) { char buf[TCL_INTEGER_SPACE]; - snprintf(buf, sizeof(buf), "%" TCL_SIZE_MODIFIER "d", nBytesProcessed); + snprintf(buf, sizeof(buf), "%" TCL_SIZE_MODIFIER "d", + nBytesProcessed); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unexpected byte sequence starting at index %" TCL_SIZE_MODIFIER "d: '\\x%02X'", nBytesProcessed, UCHAR(srcStart[nBytesProcessed]))); Tcl_SetErrorCode( - interp, "TCL", "ENCODING", "ILLEGALSEQUENCE", buf, (void *)NULL); + interp, "TCL", "ENCODING", "ILLEGALSEQUENCE", buf, + (void *)NULL); } } if (result != TCL_OK) { @@ -1287,8 +1294,9 @@ Tcl_ExternalToUtf( Tcl_Encoding encoding, /* The encoding for the source string, or NULL * for the default system encoding. */ const char *src, /* Source string in specified encoding. */ - Tcl_Size srcLen, /* Source string length in bytes, or TCL_INDEX_NONE for - * encoding-specific string length. */ + Tcl_Size srcLen, /* Source string length in bytes, or + * TCL_INDEX_NONE for encoding-specific string + * length. */ int flags, /* Conversion control flags. */ Tcl_EncodingState *statePtr,/* Place for conversion routine to store state * information used during a piecewise @@ -1440,34 +1448,33 @@ Tcl_UtfToExternalDString( * - *At most one* of TCL_ENCODING_PROFILE_* * * Results: - * The return value is one of - * TCL_OK: success. Converted string in *dstPtr - * TCL_ERROR: error in passed parameters. Error message in interp - * TCL_CONVERT_MULTIBYTE: source ends in truncated multibyte sequence - * TCL_CONVERT_SYNTAX: source is not conformant to encoding definition - * TCL_CONVERT_UNKNOWN: source contained a character that could not - * be represented in target encoding. + * The return value is one of + * TCL_OK: success. Converted string in *dstPtr + * TCL_ERROR: error in passed parameters. Error message in interp + * TCL_CONVERT_MULTIBYTE: source ends in truncated multibyte sequence + * TCL_CONVERT_SYNTAX: source is not conformant to encoding definition + * TCL_CONVERT_UNKNOWN: source contained a character that could not + * be represented in target encoding. * * Side effects: - * - * TCL_OK: The converted bytes are stored in the DString and NUL - * terminated in an encoding-specific manner - * TCL_ERROR: an error, message is stored in the interp if not NULL. - * TCL_CONVERT_*: if errorLocPtr is NULL, an error message is stored - * in the interpreter (if not NULL). If errorLocPtr is not NULL, - * no error message is stored as it is expected the caller is - * interested in whatever is decoded so far and not treating this - * as an error condition. - * - * In addition, *dstPtr is always initialized and must be cleared - * by the caller irrespective of the return code. + * TCL_OK: The converted bytes are stored in the DString and NUL + * terminated in an encoding-specific manner + * TCL_ERROR: an error, message is stored in the interp if not NULL. + * TCL_CONVERT_*: if errorLocPtr is NULL, an error message is stored + * in the interpreter (if not NULL). If errorLocPtr is not NULL, + * no error message is stored as it is expected the caller is + * interested in whatever is decoded so far and not treating this + * as an error condition. + * + * In addition, *dstPtr is always initialized and must be cleared + * by the caller irrespective of the return code. * *------------------------------------------------------------------------- */ int Tcl_UtfToExternalDStringEx( - Tcl_Interp *interp, /* For error messages. May be NULL. */ + Tcl_Interp *interp, /* For error messages. May be NULL. */ Tcl_Encoding encoding, /* The encoding for the converted string, or * NULL for the default system encoding. */ const char *src, /* Source string in UTF-8. */ @@ -1476,8 +1483,8 @@ Tcl_UtfToExternalDStringEx( int flags, /* Conversion control flags. */ Tcl_DString *dstPtr, /* Uninitialized or free DString in which the * converted string is stored. */ - Tcl_Size *errorLocPtr) /* Where to store the error location - * (or TCL_INDEX_NONE if no error). May + Tcl_Size *errorLocPtr) /* Where to store the error location + * (or TCL_INDEX_NONE if no error). May * be NULL. */ { char *dst; @@ -1547,7 +1554,8 @@ Tcl_UtfToExternalDStringEx( * Do not write error message into interpreter if caller * wants to know error location. */ - *errorLocPtr = result == TCL_OK ? TCL_INDEX_NONE : nBytesProcessed; + *errorLocPtr = result == TCL_OK + ? TCL_INDEX_NONE : nBytesProcessed; } else { /* Caller wants error message on failure */ if (result != TCL_OK && interp != NULL) { @@ -1556,7 +1564,8 @@ Tcl_UtfToExternalDStringEx( char buf[TCL_INTEGER_SPACE]; TclUtfToUniChar(&srcStart[nBytesProcessed], &ucs4); - snprintf(buf, sizeof(buf), "%" TCL_SIZE_MODIFIER "d", nBytesProcessed); + snprintf(buf, sizeof(buf), "%" TCL_SIZE_MODIFIER "d", + nBytesProcessed); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unexpected character at index %" TCL_SIZE_MODIFIER "u: 'U+%06X'", @@ -1607,8 +1616,8 @@ Tcl_UtfToExternal( Tcl_Encoding encoding, /* The encoding for the converted string, or * NULL for the default system encoding. */ const char *src, /* Source string in UTF-8. */ - Tcl_Size srcLen, /* Source string length in bytes, or TCL_INDEX_NONE for - * strlen(). */ + Tcl_Size srcLen, /* Source string length in bytes, or + * TCL_INDEX_NONE for strlen(). */ int flags, /* Conversion control flags. */ Tcl_EncodingState *statePtr,/* Place for conversion routine to store state * information used during a piecewise @@ -1816,7 +1825,8 @@ OpenEncodingFileChannel( if ((NULL == chan) && (interp != NULL)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unknown encoding \"%s\"", name)); - Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "ENCODING", name, (void *)NULL); + Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "ENCODING", name, + (void *)NULL); } Tcl_DecrRefCount(fileNameObj); Tcl_DecrRefCount(searchPath); @@ -1890,7 +1900,8 @@ LoadEncodingFile( if ((encoding == NULL) && (interp != NULL)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "invalid encoding file \"%s\"", name)); - Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "ENCODING", name, (void *)NULL); + Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "ENCODING", name, + (void *)NULL); } Tcl_CloseEx(NULL, chan, 0); @@ -2280,8 +2291,8 @@ LoadEscapeEncoding( e = (Encoding *) Tcl_GetEncoding(NULL, est.name); if ((e != NULL) && (e->toUtfProc != TableToUtfProc) && (e->toUtfProc != Iso88591ToUtfProc)) { - Tcl_FreeEncoding((Tcl_Encoding) e); - e = NULL; + Tcl_FreeEncoding((Tcl_Encoding) e); + e = NULL; } est.encodingPtr = e; Tcl_DStringAppend(&escapeData, (char *) &est, sizeof(est)); @@ -2468,7 +2479,8 @@ UtfToUtfProc( result = TCL_CONVERT_NOSPACE; break; } - if (UCHAR(*src) < 0x80 && !((UCHAR(*src) == 0) && (flags & ENCODING_INPUT))) { + if (UCHAR(*src) < 0x80 + && !((UCHAR(*src) == 0) && (flags & ENCODING_INPUT))) { /* * Copy 7bit characters, but skip null-bytes when we are in input * mode, so that they get converted to \xC0\x80. @@ -2480,12 +2492,12 @@ UtfToUtfProc( /* Special sequence \xC0\x80 */ if (!PROFILE_TCL8(profile) && (flags & ENCODING_INPUT)) { if (PROFILE_REPLACE(profile)) { - dst += Tcl_UniCharToUtf(UNICODE_REPLACE_CHAR, dst); - src += 2; + dst += Tcl_UniCharToUtf(UNICODE_REPLACE_CHAR, dst); + src += 2; } else { - /* PROFILE_STRICT */ - result = TCL_CONVERT_SYNTAX; - break; + /* PROFILE_STRICT */ + result = TCL_CONVERT_SYNTAX; + break; } } else { /* @@ -2509,8 +2521,8 @@ UtfToUtfProc( /* Incomplete bytes for modified UTF-8 target */ if (PROFILE_STRICT(profile)) { result = (flags & TCL_ENCODING_CHAR_LIMIT) - ? TCL_CONVERT_MULTIBYTE - : TCL_CONVERT_SYNTAX; + ? TCL_CONVERT_MULTIBYTE + : TCL_CONVERT_SYNTAX; break; } } @@ -2527,7 +2539,8 @@ UtfToUtfProc( } else { size_t len = TclUtfToUniChar(src, &ch); if (flags & ENCODING_INPUT) { - if (((len < 2) && (ch != 0)) || ((ch > 0xFFFF) && !(flags & ENCODING_UTF))) { + if (((len < 2) && (ch != 0)) + || ((ch > 0xFFFF) && !(flags & ENCODING_UTF))) { if (PROFILE_STRICT(profile)) { result = TCL_CONVERT_SYNTAX; break; @@ -2539,7 +2552,8 @@ UtfToUtfProc( const char *saveSrc = src; src += len; - if (!(flags & ENCODING_UTF) && !(flags & ENCODING_INPUT) && (ch > 0x3FF)) { + if (!(flags & ENCODING_UTF) && !(flags & ENCODING_INPUT) + && (ch > 0x3FF)) { if (ch > 0xFFFF) { /* CESU-8 6-byte sequence for chars > U+FFFF */ ch -= 0x10000; @@ -2554,7 +2568,8 @@ UtfToUtfProc( continue; } else if (SURROGATE(ch)) { if (PROFILE_STRICT(profile)) { - result = (flags & ENCODING_INPUT) ? TCL_CONVERT_SYNTAX : TCL_CONVERT_UNKNOWN; + result = (flags & ENCODING_INPUT) + ? TCL_CONVERT_SYNTAX : TCL_CONVERT_UNKNOWN; src = saveSrc; break; } else if (PROFILE_REPLACE(profile)) { @@ -2589,7 +2604,7 @@ UtfToUtfProc( static int Utf32ToUtfProc( - void *clientData, /* additional flags, e.g. TCL_ENCODING_LE */ + void *clientData, /* additional flags, e.g. TCL_ENCODING_LE */ const char *src, /* Source string in Unicode. */ int srcLen, /* Source string length in bytes. */ int flags, /* Conversion control flags. */ @@ -2643,9 +2658,11 @@ Utf32ToUtfProc( } if (flags & TCL_ENCODING_LE) { - ch = (unsigned int)(src[3] & 0xFF) << 24 | (src[2] & 0xFF) << 16 | (src[1] & 0xFF) << 8 | (src[0] & 0xFF); + ch = (unsigned int)(src[3] & 0xFF) << 24 | (src[2] & 0xFF) << 16 + | (src[1] & 0xFF) << 8 | (src[0] & 0xFF); } else { - ch = (unsigned int)(src[0] & 0xFF) << 24 | (src[1] & 0xFF) << 16 | (src[2] & 0xFF) << 8 | (src[3] & 0xFF); + ch = (unsigned int)(src[0] & 0xFF) << 24 | (src[1] & 0xFF) << 16 + | (src[2] & 0xFF) << 8 | (src[3] & 0xFF); } if ((unsigned)ch > 0x10FFFF) { if (PROFILE_STRICT(flags)) { @@ -2718,7 +2735,7 @@ Utf32ToUtfProc( static int UtfToUtf32Proc( - void *clientData, /* additional flags, e.g. TCL_ENCODING_LE */ + void *clientData, /* additional flags, e.g. TCL_ENCODING_LE */ const char *src, /* Source string in UTF-8. */ int srcLen, /* Source string length in bytes. */ int flags, /* Conversion control flags. */ @@ -2817,7 +2834,7 @@ UtfToUtf32Proc( static int Utf16ToUtfProc( - void *clientData, /* additional flags, e.g. TCL_ENCODING_LE */ + void *clientData, /* additional flags, e.g. TCL_ENCODING_LE */ const char *src, /* Source string in Unicode. */ int srcLen, /* Source string length in bytes. */ int flags, /* Conversion control flags. */ @@ -2875,7 +2892,8 @@ Utf16ToUtfProc( dstStart = dst; dstEnd = dst + dstLen - TCL_UTF_MAX; - for (numChars = 0; src < srcEnd && numChars <= charLimit; src += 2, numChars++) { + for (numChars = 0; src < srcEnd && numChars <= charLimit; + src += 2, numChars++) { if (dst > dstEnd) { result = TCL_CONVERT_NOSPACE; break; @@ -2890,16 +2908,16 @@ Utf16ToUtfProc( if (HIGH_SURROGATE(prev) && !LOW_SURROGATE(ch)) { if (PROFILE_STRICT(flags)) { result = TCL_CONVERT_SYNTAX; - src -= 2; /* Go back to beginning of high surrogate */ - dst--; /* Also undo writing a single byte too much */ + src -= 2; /* Go back to beginning of high surrogate */ + dst--; /* Also undo writing a single byte too much */ numChars--; break; } else if (PROFILE_REPLACE(flags)) { /* * Previous loop wrote a single byte to mark the high surrogate. * Replace it with the replacement character. Further, restart - * current loop iteration since need to recheck destination space - * and reset processing of current character. + * current loop iteration since need to recheck destination + * space and reset processing of current character. */ ch = UNICODE_REPLACE_CHAR; dst--; @@ -2908,7 +2926,10 @@ Utf16ToUtfProc( numChars--; continue; } else { - /* Bug [10c2c17c32]. If Hi surrogate not followed by Lo surrogate, finish 3-byte UTF-8 */ + /* + * Bug [10c2c17c32]. If Hi surrogate not followed by Lo + * surrogate, finish 3-byte UTF-8 + */ dst += Tcl_UniCharToUtf(-1, dst); } } @@ -2995,7 +3016,7 @@ Utf16ToUtfProc( static int UtfToUtf16Proc( - void *clientData, /* additional flags, e.g. TCL_ENCODING_LE */ + void *clientData, /* additional flags, e.g. TCL_ENCODING_LE */ const char *src, /* Source string in UTF-8. */ int srcLen, /* Source string length in bytes. */ int flags, /* Conversion control flags. */ @@ -3103,7 +3124,7 @@ UtfToUtf16Proc( static int UtfToUcs2Proc( - void *clientData, /* additional flags, e.g. TCL_ENCODING_LE */ + void *clientData, /* additional flags, e.g. TCL_ENCODING_LE */ const char *src, /* Source string in UTF-8. */ int srcLen, /* Source string length in bytes. */ int flags, /* Conversion control flags. */ @@ -3207,7 +3228,7 @@ UtfToUcs2Proc( static int TableToUtfProc( - void *clientData, /* TableEncodingData that specifies + void *clientData, /* TableEncodingData that specifies * encoding. */ const char *src, /* Source string in specified encoding. */ int srcLen, /* Source string length in bytes. */ @@ -3270,7 +3291,8 @@ TableToUtfProc( } else if (PROFILE_REPLACE(flags)) { ch = UNICODE_REPLACE_CHAR; } else { - /* For prefix bytes, we don't fallback to cp1252, see [1355b9a874] */ + /* For prefix bytes, we don't fallback to cp1252, see + * [1355b9a874] */ ch = byte; } } else { @@ -3335,7 +3357,7 @@ TableToUtfProc( static int TableFromUtfProc( - void *clientData, /* TableEncodingData that specifies + void *clientData, /* TableEncodingData that specifies * encoding. */ const char *src, /* Source string in UTF-8. */ int srcLen, /* Source string length in bytes. */ @@ -3627,7 +3649,7 @@ Iso88591FromUtfProc( static void TableFreeProc( - void *clientData) /* TableEncodingData that specifies + void *clientData) /* TableEncodingData that specifies * encoding. */ { TableEncodingData *dataPtr = (TableEncodingData *)clientData; @@ -3662,7 +3684,7 @@ TableFreeProc( static int EscapeToUtfProc( - void *clientData, /* EscapeEncodingData that specifies + void *clientData, /* EscapeEncodingData that specifies * encoding. */ const char *src, /* Source string in specified encoding. */ int srcLen, /* Source string length in bytes. */ @@ -3875,7 +3897,7 @@ EscapeToUtfProc( static int EscapeFromUtfProc( - void *clientData, /* EscapeEncodingData that specifies + void *clientData, /* EscapeEncodingData that specifies * encoding. */ const char *src, /* Source string in UTF-8. */ int srcLen, /* Source string length in bytes. */ @@ -3942,7 +3964,7 @@ EscapeFromUtfProc( } encodingPtr = GetTableEncoding(dataPtr, state); - tableDataPtr = (const TableEncodingData *)encodingPtr->clientData; + tableDataPtr = (TableEncodingData *) encodingPtr->clientData; tablePrefixBytes = tableDataPtr->prefixBytes; tableFromUnicode = (const unsigned short *const *) tableDataPtr->fromUnicode; @@ -3970,7 +3992,7 @@ EscapeFromUtfProc( oldState = state; for (state = 0; state < dataPtr->numSubTables; state++) { encodingPtr = GetTableEncoding(dataPtr, state); - tableDataPtr = (const TableEncodingData *)encodingPtr->clientData; + tableDataPtr = (TableEncodingData *) encodingPtr->clientData; word = tableDataPtr->fromUnicode[(ch >> 8)][ch & 0xFF]; if (word != 0) { break; @@ -3984,7 +4006,7 @@ EscapeFromUtfProc( break; } encodingPtr = GetTableEncoding(dataPtr, state); - tableDataPtr = (const TableEncodingData *)encodingPtr->clientData; + tableDataPtr = (TableEncodingData *) encodingPtr->clientData; word = tableDataPtr->fallback; } @@ -4086,7 +4108,7 @@ EscapeFromUtfProc( static void EscapeFreeProc( - void *clientData) /* EscapeEncodingData that specifies + void *clientData) /* EscapeEncodingData that specifies * encoding. */ { EscapeEncodingData *dataPtr = (EscapeEncodingData *)clientData; @@ -4308,14 +4330,17 @@ TclEncodingProfileNameToId( profileName); for (i = 0; i < (numProfiles - 1); ++i) { Tcl_AppendStringsToObj( - errorObj, " ", encodingProfiles[i].name, ",", (void *)NULL); + errorObj, " ", encodingProfiles[i].name, ",", + (void *)NULL); } Tcl_AppendStringsToObj( - errorObj, " or ", encodingProfiles[numProfiles-1].name, (void *)NULL); + errorObj, " or ", encodingProfiles[numProfiles-1].name, + (void *)NULL); Tcl_SetObjResult(interp, errorObj); Tcl_SetErrorCode( - interp, "TCL", "ENCODING", "PROFILE", profileName, (void *)NULL); + interp, "TCL", "ENCODING", "PROFILE", profileName, + (void *)NULL); } return TCL_ERROR; } @@ -4342,7 +4367,8 @@ TclEncodingProfileIdToName( { size_t i; - for (i = 0; i < sizeof(encodingProfiles) / sizeof(encodingProfiles[0]); ++i) { + for (i = 0; i < sizeof(encodingProfiles) / sizeof(encodingProfiles[0]); + ++i) { if (profileValue == encodingProfiles[i].value) { return encodingProfiles[i].name; } @@ -4352,7 +4378,7 @@ TclEncodingProfileIdToName( "Internal error. Bad profile id \"%d\".", profileValue)); Tcl_SetErrorCode( - interp, "TCL", "ENCODING", "PROFILEID", (void *)NULL); + interp, "TCL", "ENCODING", "PROFILEID", (void *)NULL); } return NULL; } @@ -4381,12 +4407,12 @@ TclGetEncodingProfiles( n = sizeof(encodingProfiles) / sizeof(encodingProfiles[0]); objPtr = Tcl_NewListObj(n, NULL); for (i = 0; i < n; ++i) { - Tcl_ListObjAppendElement( - interp, objPtr, Tcl_NewStringObj(encodingProfiles[i].name, TCL_INDEX_NONE)); + Tcl_ListObjAppendElement(interp, objPtr, + Tcl_NewStringObj(encodingProfiles[i].name, TCL_INDEX_NONE)); } Tcl_SetObjResult(interp, objPtr); } - + /* * Local Variables: * mode: c -- cgit v0.12 From fb74fa4d32a761402939c6c0343c205d05433b95 Mon Sep 17 00:00:00 2001 From: dkf Date: Fri, 14 Jun 2024 18:44:09 +0000 Subject: Fix non-standard indentation pattern --- generic/tclListObj.c | 5 ++--- generic/tclScan.c | 14 ++++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/generic/tclListObj.c b/generic/tclListObj.c index 483426d..726a9db 100644 --- a/generic/tclListObj.c +++ b/generic/tclListObj.c @@ -498,9 +498,8 @@ ListLimitExceededError( Tcl_Interp *interp) { if (interp != NULL) { - Tcl_SetObjResult( - interp, - Tcl_NewStringObj("max length of a Tcl list exceeded", -1)); + Tcl_SetObjResult(interp, Tcl_NewStringObj( + "max length of a Tcl list exceeded", -1)); Tcl_SetErrorCode(interp, "TCL", "MEMORY", (char *)NULL); } return TCL_ERROR; diff --git a/generic/tclScan.c b/generic/tclScan.c index 4ffe177..b53b29c 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -358,17 +358,15 @@ ValidateFormat( /* Note ull >= 0 because of isdigit check above */ unsigned long long ull; ull = strtoull( - format - 1, (char **)&format, 10); /* INTL: "C" locale. */ + format - 1, (char **)&format, 10); /* INTL: "C" locale. */ /* Note >=, not >, to leave room for a nul */ if (ull >= TCL_SIZE_MAX) { - Tcl_SetObjResult( - interp, - Tcl_ObjPrintf("specified field width %" TCL_LL_MODIFIER - "u exceeds limit %" TCL_SIZE_MODIFIER "d.", - ull, - (Tcl_Size)TCL_SIZE_MAX-1)); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "specified field width %" TCL_LL_MODIFIER + "u exceeds limit %" TCL_SIZE_MODIFIER "d.", + ull, (Tcl_Size)TCL_SIZE_MAX-1)); Tcl_SetErrorCode( - interp, "TCL", "FORMAT", "WIDTHLIMIT", (char *)NULL); + interp, "TCL", "FORMAT", "WIDTHLIMIT", (char *)NULL); goto error; } flags |= SCAN_WIDTH; -- cgit v0.12 From 5b97aedd0b32abe3c3ab134c08fe01f6f496c2c6 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 17 Jun 2024 13:43:54 +0000 Subject: Change "channelId" to "channel" in documentation, error-handling and testcases --- doc/chan.n | 84 ++++++++++++++++++++++----------------------- doc/close.n | 2 +- doc/eof.n | 2 +- doc/fblocked.n | 2 +- doc/fconfigure.n | 6 ++-- doc/fileevent.n | 4 +-- doc/flush.n | 2 +- doc/gets.n | 2 +- doc/interp.n | 8 ++--- doc/puts.n | 2 +- doc/read.n | 4 +-- doc/refchan.n | 66 +++++++++++++++++------------------ doc/seek.n | 2 +- doc/tell.n | 2 +- doc/transchan.n | 2 +- generic/tclIO.c | 2 +- generic/tclIOCmd.c | 26 +++++++------- generic/tclInterp.c | 2 +- generic/tclTest.c | 2 +- library/tcltest/tcltest.tcl | 4 +-- tests/chan.test | 30 ++++++++-------- tests/chanio.test | 4 +-- tests/io.test | 4 +-- tests/ioCmd.test | 46 ++++++++++++------------- tests/pid.test | 2 +- tests/trace.test | 2 +- unix/tclUnixPipe.c | 2 +- win/tclWinPipe.c | 2 +- 28 files changed, 159 insertions(+), 159 deletions(-) diff --git a/doc/chan.n b/doc/chan.n index 8bb564b..7191121 100644 --- a/doc/chan.n +++ b/doc/chan.n @@ -23,19 +23,19 @@ the process's standard input, output and error streams respectively). abbreviation for \fIoption\fR is acceptable. Valid options are: .\" METHOD: blocked .TP -\fBchan blocked \fIchannelId\fR +\fBchan blocked \fIchannel\fR . This tests whether the last input operation on the channel called -\fIchannelId\fR failed because it would have otherwise caused the +\fIchannel\fR failed because it would have otherwise caused the process to block, and returns 1 if that was the case. It returns 0 otherwise. Note that this only ever returns 1 when the channel has been configured to be non-blocking; all Tcl channels have blocking turned on by default. .\" METHOD: close .TP -\fBchan close \fIchannelId\fR ?\fIdirection\fR? +\fBchan close \fIchannel\fR ?\fIdirection\fR? . -Close and destroy the channel called \fIchannelId\fR. Note that this +Close and destroy the channel called \fIchannel\fR. Note that this deletes all existing file-events registered on the channel. If the \fIdirection\fR argument (which must be \fBread\fR or \fBwrite\fR or any unique abbreviation of them) is present, the channel will only be @@ -51,7 +51,7 @@ write-only channel for reading. As part of closing the channel, all buffered output is flushed to the channel's output device (only if the channel is ceasing to be writable), any buffered input is discarded (only if the channel is ceasing to be readable), -the underlying operating system resource is closed and \fIchannelId\fR becomes +the underlying operating system resource is closed and \fIchannel\fR becomes unavailable for future use (both only if the channel is being completely closed). .PP @@ -61,11 +61,11 @@ non-blocking and there is unflushed output, the channel remains open and the command returns immediately; output will be flushed in the background and the channel will be closed when all the flushing is complete. .PP -If \fIchannelId\fR is a blocking channel for a command pipeline then +If \fIchannel\fR is a blocking channel for a command pipeline then \fBchan close\fR waits for the child processes to complete. .PP If the channel is shared between interpreters, then \fBchan close\fR -makes \fIchannelId\fR unavailable in the invoking interpreter but has +makes \fIchannel\fR unavailable in the invoking interpreter but has no other effect until all of the sharing interpreters have closed the channel. When the last interpreter in which the channel is registered invokes \fBchan close\fR (or \fBclose\fR), the cleanup actions @@ -101,10 +101,10 @@ restores the previous behavior. .RE .\" METHOD: configure .TP -\fBchan configure \fIchannelId\fR ?\fIoptionName\fR? ?\fIvalue\fR? ?\fIoptionName value\fR?... +\fBchan configure \fIchannel\fR ?\fIoptionName\fR? ?\fIvalue\fR? ?\fIoptionName value\fR?... . Query or set the configuration options of the channel named -\fIchannelId\fR. +\fIchannel\fR. .RS .PP If no \fIoptionName\fR or \fIvalue\fR arguments are supplied, the @@ -391,18 +391,18 @@ within the safe interpreter. .RE .\" METHOD: eof .TP -\fBchan eof \fIchannelId\fR +\fBchan eof \fIchannel\fR . Test whether the last input operation on the channel called -\fIchannelId\fR failed because the end of the data stream was reached, +\fIchannel\fR failed because the end of the data stream was reached, returning 1 if end-of-file was reached, and 0 otherwise. .\" METHOD: event .TP -\fBchan event \fIchannelId event\fR ?\fIscript\fR? +\fBchan event \fIchannel event\fR ?\fIscript\fR? . Arrange for the Tcl script \fIscript\fR to be installed as a \fIfile event handler\fR to be called whenever the channel called -\fIchannelId\fR enters the state described by \fIevent\fR (which must +\fIchannel\fR enters the state described by \fIevent\fR (which must be either \fBreadable\fR or \fBwritable\fR); only one such handler may be installed per event per channel at a time. If \fIscript\fR is the empty string, the current handler is deleted (this also happens if the @@ -468,9 +468,9 @@ loops due to buggy handlers. .RE .\" METHOD: flush .TP -\fBchan flush \fIchannelId\fR +\fBchan flush \fIchannel\fR . -Ensures that all pending output for the channel called \fIchannelId\fR +Ensures that all pending output for the channel called \fIchannel\fR is written. .RS .PP @@ -483,7 +483,7 @@ it. .RE .\" METHOD: gets .TP -\fBchan gets \fIchannelId\fR ?\fIvarName\fR? +\fBchan gets \fIchannel\fR ?\fIvarName\fR? . Reads a line from the channel consisting of all characters up to the next end-of-line sequence or until end of file is seen. The line feed character @@ -536,12 +536,12 @@ only those channel names that match it (according to the rules of \fBstring match\fR) will be returned. .\" METHOD: pending .TP -\fBchan pending \fImode channelId\fR +\fBchan pending \fImode channel\fR . Depending on whether \fImode\fR is \fBinput\fR or \fBoutput\fR, returns the number of bytes of input or output (respectively) currently buffered -internally for \fIchannelId\fR (especially useful in a readable event +internally for \fIchannel\fR (especially useful in a readable event callback to impose application-specific limits on input line lengths to avoid a potential denial-of-service attack where a hostile user crafts an extremely long line that exceeds the available memory to buffer it). @@ -572,20 +572,20 @@ allowed for. .RE .\" METHOD: pop .TP -\fBchan pop \fIchannelId\fR +\fBchan pop \fIchannel\fR . -Removes the topmost transformation from the channel \fIchannelId\fR, if there -is any. If there are no transformations added to \fIchannelId\fR, this is +Removes the topmost transformation from the channel \fIchannel\fR, if there +is any. If there are no transformations added to \fIchannel\fR, this is equivalent to \fBchan close\fR of that channel. The result is normally the empty string, but can be an error in some situations (i.e. where the underlying system stream is closed and that results in an error). .\" METHOD: postevent .TP -\fBchan postevent \fIchannelId eventSpec\fR +\fBchan postevent \fIchannel eventSpec\fR . This subcommand is used by command handlers specified with \fBchan create\fR. It notifies the channel represented by the handle -\fIchannelId\fR that the event(s) listed in the \fIeventSpec\fR have +\fIchannel\fR that the event(s) listed in the \fIeventSpec\fR have occurred. The argument has to be a list containing any of the strings \fBread\fR and \fBwrite\fR. The list must contain at least one element as it does not make sense to invoke the command if there are @@ -618,9 +618,9 @@ executed in the interpreter that set them up. .RE .\" METHOD: push .TP -\fBchan push \fIchannelId cmdPrefix\fR +\fBchan push \fIchannel cmdPrefix\fR . -Adds a new transformation on top of the channel \fIchannelId\fR. The +Adds a new transformation on top of the channel \fIchannel\fR. The \fIcmdPrefix\fR argument describes a list of one or more words which represent a handler that will be used to implement the transformation. The command prefix must provide the API described in the \fBtranschan\fR manual page. @@ -630,11 +630,11 @@ channel mode that it is used with or this can make the channel neither readable nor writable. .\" METHOD: puts .TP -\fBchan puts\fR ?\fB\-nonewline\fR? ?\fIchannelId\fR? \fIstring\fR +\fBchan puts\fR ?\fB\-nonewline\fR? ?\fIchannel\fR? \fIstring\fR . -Writes \fIstring\fR to the channel named \fIchannelId\fR followed by a +Writes \fIstring\fR to the channel named \fIchannel\fR followed by a newline character. A trailing newline character is written unless the -optional flag \fB\-nonewline\fR is given. If \fIchannelId\fR is +optional flag \fB\-nonewline\fR is given. If \fIchannel\fR is omitted, the string is written to the standard output channel, \fBstdout\fR. .RS @@ -654,7 +654,7 @@ flush\fR command. .PP When the output buffer fills up, the \fBchan puts\fR command will normally block until all the buffered data has been accepted for -output by the operating system. If \fIchannelId\fR is in non-blocking +output by the operating system. If \fIchannel\fR is in non-blocking mode then the \fBchan puts\fR command will not block even if the operating system cannot accept the data. Instead, Tcl continues to buffer the data and writes it in the background as fast as the @@ -675,12 +675,12 @@ may be partially written to the channel in this case. .RE .\" METHOD: read .TP -\fBchan read \fIchannelId\fR ?\fInumChars\fR? +\fBchan read \fIchannel\fR ?\fInumChars\fR? .TP -\fBchan read \fR?\fB\-nonewline\fR? \fIchannelId\fR +\fBchan read \fR?\fB\-nonewline\fR? \fIchannel\fR . In the first form, the result will be the next \fInumChars\fR -characters read from the channel named \fIchannelId\fR; if +characters read from the channel named \fIchannel\fR; if \fInumChars\fR is omitted, all characters up to the point when the channel would signal a failure (whether an end-of-file, blocked or other error condition) are read. In the second form (i.e. when @@ -689,7 +689,7 @@ given to indicate that any trailing newline in the string that has been read should be trimmed. .RS .PP -If \fIchannelId\fR is in non-blocking mode, \fBchan read\fR may not +If \fIchannel\fR is in non-blocking mode, \fBchan read\fR may not read as many characters as requested: once all available input has been read, the command will return the data that is available rather than blocking for more input. If the channel is configured to use a @@ -708,7 +708,7 @@ When reading from a serial port, most applications should configure the serial port channel to be non-blocking, like this: .PP .CS -\fBchan configure \fIchannelId \fB\-blocking \fI0\fR. +\fBchan configure \fIchannel \fB\-blocking \fI0\fR. .CE .PP Then \fBchan read\fR behaves much like described above. Note that @@ -716,12 +716,12 @@ most serial ports are comparatively slow; it is entirely possible to get a \fBreadable\fR event for each character read from them. Care must be taken when using \fBchan read\fR on blocking serial ports: .TP -\fBchan read \fIchannelId numChars\fR +\fBchan read \fIchannel numChars\fR . In this form \fBchan read\fR blocks until \fInumChars\fR have been received from the serial port. .TP -\fBchan read \fIchannelId\fR +\fBchan read \fIchannel\fR . In this form \fBchan read\fR blocks until the reception of the end-of-file character, see \fBchan configure -eofchar\fR. If there no @@ -745,10 +745,10 @@ changing the encoding in use. See \fBENCODING ERROR EXAMPLES\fR later. .RE .\" METHOD: seek .TP -\fBchan seek \fIchannelId offset\fR ?\fIorigin\fR? +\fBchan seek \fIchannel offset\fR ?\fIorigin\fR? . Sets the current access position within the underlying data stream for -the channel named \fIchannelId\fR to be \fIoffset\fR bytes relative to +the channel named \fIchannel\fR to be \fIoffset\fR bytes relative to \fIorigin\fR. \fIOffset\fR must be an integer (which may be negative) and \fIorigin\fR must be one of the following: .RS @@ -779,20 +779,20 @@ not characters, unlike \fBchan read\fR. .RE .\" METHOD: tell .TP -\fBchan tell \fIchannelId\fR +\fBchan tell \fIchannel\fR . Returns a number giving the current access position within the -underlying data stream for the channel named \fIchannelId\fR. This +underlying data stream for the channel named \fIchannel\fR. This value returned is a byte offset that can be passed to \fBchan seek\fR in order to set the channel to a particular position. Note that this value is in terms of bytes, not characters like \fBchan read\fR. The value returned is -1 for channels that do not support seeking. .\" METHOD: truncate .TP -\fBchan truncate \fIchannelId\fR ?\fIlength\fR? +\fBchan truncate \fIchannel\fR ?\fIlength\fR? . Sets the byte length of the underlying data stream for the channel -named \fIchannelId\fR to be \fIlength\fR (or to the current byte +named \fIchannel\fR to be \fIlength\fR (or to the current byte offset within the underlying data stream if \fIlength\fR is omitted). The channel is flushed before truncation. . diff --git a/doc/close.n b/doc/close.n index f3a61be..eecc48f 100644 --- a/doc/close.n +++ b/doc/close.n @@ -12,7 +12,7 @@ .SH NAME close \- Close an open channel .SH SYNOPSIS -\fBclose \fIchannelId\fR ?\fBr\fR(\fBead\fR)|\fBw\fR(\fBrite\fR)? +\fBclose \fIchannel\fR ?\fBr\fR(\fBead\fR)|\fBw\fR(\fBrite\fR)? .BE .SH DESCRIPTION .PP diff --git a/doc/eof.n b/doc/eof.n index 7eea515..36f4920 100644 --- a/doc/eof.n +++ b/doc/eof.n @@ -12,7 +12,7 @@ .SH NAME eof \- Check for end of file condition on channel .SH SYNOPSIS -\fBeof \fIchannelId\fR +\fBeof \fIchannel\fR .BE .SH DESCRIPTION .PP diff --git a/doc/fblocked.n b/doc/fblocked.n index 239c465..00fe7a7 100644 --- a/doc/fblocked.n +++ b/doc/fblocked.n @@ -10,7 +10,7 @@ .SH NAME fblocked \- Test whether the last input operation exhausted all available input .SH SYNOPSIS -\fBfblocked \fIchannelId\fR +\fBfblocked \fIchannel\fR .BE .SH DESCRIPTION .PP diff --git a/doc/fconfigure.n b/doc/fconfigure.n index 2870d54..e185122 100644 --- a/doc/fconfigure.n +++ b/doc/fconfigure.n @@ -12,9 +12,9 @@ fconfigure \- Set and get options on a channel .SH SYNOPSIS .nf -\fBfconfigure \fIchannelId\fR -\fBfconfigure \fIchannelId name\fR -\fBfconfigure \fIchannelId name value \fR?\fIname value ...\fR? +\fBfconfigure \fIchannel\fR +\fBfconfigure \fIchannel name\fR +\fBfconfigure \fIchannel name value \fR?\fIname value ...\fR? .fi .BE .SH DESCRIPTION diff --git a/doc/fileevent.n b/doc/fileevent.n index 4ba534a..d90e376 100644 --- a/doc/fileevent.n +++ b/doc/fileevent.n @@ -13,9 +13,9 @@ .SH NAME fileevent \- Execute a script when a channel becomes readable or writable .SH SYNOPSIS -\fBfileevent \fIchannelId \fBreadable \fR?\fIscript\fR? +\fBfileevent \fIchannel \fBreadable \fR?\fIscript\fR? .sp -\fBfileevent \fIchannelId \fBwritable \fR?\fIscript\fR? +\fBfileevent \fIchannel \fBwritable \fR?\fIscript\fR? .BE .SH DESCRIPTION .PP diff --git a/doc/flush.n b/doc/flush.n index 259f4cb..956750e 100644 --- a/doc/flush.n +++ b/doc/flush.n @@ -12,7 +12,7 @@ .SH NAME flush \- Flush buffered output for a channel .SH SYNOPSIS -\fBflush \fIchannelId\fR +\fBflush \fIchannel\fR .BE .SH DESCRIPTION .PP diff --git a/doc/gets.n b/doc/gets.n index 8ee0db1..59951e3 100644 --- a/doc/gets.n +++ b/doc/gets.n @@ -12,7 +12,7 @@ .SH NAME gets \- Read a line from a channel .SH SYNOPSIS -\fBgets \fIchannelId\fR ?\fIvarName\fR? +\fBgets \fIchannel\fR ?\fIvarName\fR? .BE .SH DESCRIPTION .PP diff --git a/doc/interp.n b/doc/interp.n index 2c08533..74745be 100644 --- a/doc/interp.n +++ b/doc/interp.n @@ -392,9 +392,9 @@ the maximum size of the C stack. .RE .\" METHOD: share .TP -\fBinterp share\fI srcPath channelId destPath\fR +\fBinterp share\fI srcPath channel destPath\fR . -Causes the IO channel identified by \fIchannelId\fR to become shared +Causes the IO channel identified by \fIchannel\fR to become shared between the interpreter identified by \fIsrcPath\fR and the interpreter identified by \fIdestPath\fR. Both interpreters have the same permissions on the IO channel. @@ -415,9 +415,9 @@ invoking interpreter or one of its descendants then an error is generated. The target command does not have to be defined at the time of this invocation. .\" METHOD: transfer .TP -\fBinterp transfer\fI srcPath channelId destPath\fR +\fBinterp transfer\fI srcPath channel destPath\fR . -Causes the IO channel identified by \fIchannelId\fR to become available in +Causes the IO channel identified by \fIchannel\fR to become available in the interpreter identified by \fIdestPath\fR and unavailable in the interpreter identified by \fIsrcPath\fR. .SH "CHILD COMMAND" diff --git a/doc/puts.n b/doc/puts.n index e818273..100bec8 100644 --- a/doc/puts.n +++ b/doc/puts.n @@ -12,7 +12,7 @@ .SH NAME puts \- Write to a channel .SH SYNOPSIS -\fBputs \fR?\fB\-nonewline\fR? ?\fIchannelId\fR? \fIstring\fR +\fBputs \fR?\fB\-nonewline\fR? ?\fIchannel\fR? \fIstring\fR .BE .SH DESCRIPTION .PP diff --git a/doc/read.n b/doc/read.n index d298138..8ba482e 100644 --- a/doc/read.n +++ b/doc/read.n @@ -12,9 +12,9 @@ .SH NAME read \- Read from a channel .SH SYNOPSIS -\fBread \fR?\fB\-nonewline\fR? \fIchannelId\fR +\fBread \fR?\fB\-nonewline\fR? \fIchannel\fR .sp -\fBread \fIchannelId numChars\fR +\fBread \fIchannel numChars\fR .BE .SH DESCRIPTION .PP diff --git a/doc/refchan.n b/doc/refchan.n index b997ddb..4f78a7b 100644 --- a/doc/refchan.n +++ b/doc/refchan.n @@ -14,16 +14,16 @@ refchan \- command handler API of reflected channels .nf \fBchan create \fImode cmdPrefix\fR -\fIcmdPrefix \fBblocking\fI channelId mode\fR -\fIcmdPrefix \fBcget\fI channelId option\fR -\fIcmdPrefix \fBcgetall\fI channelId\fR -\fIcmdPrefix \fBconfigure\fI channelId option value\fR -\fIcmdPrefix \fBfinalize\fI channelId\fR -\fIcmdPrefix \fBinitialize\fI channelId mode\fR -\fIcmdPrefix \fBread\fI channelId count\fR -\fIcmdPrefix \fBseek\fI channelId offset base\fR -\fIcmdPrefix \fBwatch\fI channelId eventspec\fR -\fIcmdPrefix \fBwrite\fI channelId data\fR +\fIcmdPrefix \fBblocking\fI channel mode\fR +\fIcmdPrefix \fBcget\fI channel option\fR +\fIcmdPrefix \fBcgetall\fI channel\fR +\fIcmdPrefix \fBconfigure\fI channel option value\fR +\fIcmdPrefix \fBfinalize\fI channel\fR +\fIcmdPrefix \fBinitialize\fI channel mode\fR +\fIcmdPrefix \fBread\fI channel count\fR +\fIcmdPrefix \fBseek\fI channel offset base\fR +\fIcmdPrefix \fBwatch\fI channel eventspec\fR +\fIcmdPrefix \fBwrite\fI channel data\fR .fi .BE .SH DESCRIPTION @@ -44,10 +44,10 @@ other subcommands is optional. .SS "MANDATORY SUBCOMMANDS" .\" METHOD: initialize .TP -\fIcmdPrefix \fBinitialize \fIchannelId mode\fR +\fIcmdPrefix \fBinitialize \fIchannel mode\fR . An invocation of this subcommand will be the first call the -\fIcmdPrefix\fR will receive for the specified new \fIchannelId\fR. It +\fIcmdPrefix\fR will receive for the specified new \fIchannel\fR. It is the responsibility of this subcommand to set up any internal data structures required to keep track of the channel and its state. .RS @@ -75,13 +75,13 @@ supported by the \fIcmdPrefix\fR. .RE .\" METHOD: finalize .TP -\fIcmdPrefix \fBfinalize \fIchannelId\fR +\fIcmdPrefix \fBfinalize \fIchannel\fR . An invocation of this subcommand will be the last call the -\fIcmdPrefix\fR will receive for the specified \fIchannelId\fR. It will +\fIcmdPrefix\fR will receive for the specified \fIchannel\fR. It will be generated just before the destruction of the data structures of the channel held by the Tcl core. The command handler \fImust not\fR -access the \fIchannelId\fR anymore in no way. Upon this subcommand being +access the \fIchannel\fR anymore in no way. Upon this subcommand being called, any internal resources allocated to this channel must be cleaned up. .RS @@ -98,10 +98,10 @@ aborted during \fBinitialize\fR (See above). .RE .\" METHOD: watch .TP -\fIcmdPrefix \fBwatch \fIchannelId eventspec\fR +\fIcmdPrefix \fBwatch \fIchannel eventspec\fR . This subcommand notifies the \fIcmdPrefix\fR that the specified -\fIchannelId\fR is interested in the events listed in the +\fIchannel\fR is interested in the events listed in the \fIeventspec\fR. This argument is a list containing any of \fBread\fR and \fBwrite\fR. The list may be empty, which signals that the channel does not wish to be notified of any events. In that situation, @@ -119,10 +119,10 @@ event which was not listed in the last call to \fBwatch\fR will cause .SS "OPTIONAL SUBCOMMANDS" .\" METHOD: read .TP -\fIcmdPrefix \fBread \fIchannelId count\fR +\fIcmdPrefix \fBread \fIchannel count\fR . This \fIoptional\fR subcommand is called when the user requests data from the -channel \fIchannelId\fR. \fIcount\fR specifies how many \fIbytes\fR have been +channel \fIchannel\fR. \fIcount\fR specifies how many \fIbytes\fR have been requested. If the subcommand is not supported then it is not possible to read from the channel handled by the command. .RS @@ -176,10 +176,10 @@ etc.) is treated as and converted to an error. .RE .\" METHOD: write .TP -\fIcmdPrefix \fBwrite \fIchannelId data\fR +\fIcmdPrefix \fBwrite \fIchannel data\fR . This \fIoptional\fR subcommand is called when the user writes data to -the channel \fIchannelId\fR. The \fIdata\fR argument contains \fIbytes\fR, not +the channel \fIchannel\fR. The \fIdata\fR argument contains \fIbytes\fR, not characters. Any type of transformation (EOL, encoding) configured for the channel has already been applied at this point. If this subcommand is not supported then it is not possible to write to the channel @@ -234,11 +234,11 @@ as and converted to an error. .RE .\" METHOD: seek .TP -\fIcmdPrefix \fBseek \fIchannelId offset base\fR +\fIcmdPrefix \fBseek \fIchannel offset base\fR . This \fIoptional\fR subcommand is responsible for the handling of \fBchan seek\fR and \fBchan tell\fR requests on the channel -\fIchannelId\fR. If it is not supported then seeking will not be possible for +\fIchannel\fR. If it is not supported then seeking will not be possible for the channel. .RS .PP @@ -271,10 +271,10 @@ the new location identical to the current one, which is then returned. .RE .\" METHOD: configure .TP -\fIcmdPrefix \fBconfigure \fIchannelId option value\fR +\fIcmdPrefix \fBconfigure \fIchannel option value\fR . This \fIoptional\fR subcommand is for setting the type-specific options of -channel \fIchannelId\fR. The \fIoption\fR argument indicates the option to be +channel \fIchannel\fR. The \fIoption\fR argument indicates the option to be written, and the \fIvalue\fR argument indicates the value to set the option to. .RS .PP @@ -291,10 +291,10 @@ converted to an error. .RE .\" METHOD: cget .TP -\fIcmdPrefix \fBcget \fIchannelId option\fR +\fIcmdPrefix \fBcget \fIchannel option\fR . This \fIoptional\fR subcommand is used when reading a single type-specific -option of channel \fIchannelId\fR. If this subcommand is supported then the +option of channel \fIchannel\fR. If this subcommand is supported then the subcommand \fBcgetall\fR must be supported as well. .RS .PP @@ -307,10 +307,10 @@ will appear to have thrown this error. Any exception beyond \fIerror\fR .RE .\" METHOD: cgetall .TP -\fIcmdPrefix \fBcgetall \fIchannelId\fR +\fIcmdPrefix \fBcgetall \fIchannel\fR . This \fIoptional\fR subcommand is used for reading all type-specific options -of channel \fIchannelId\fR. If this subcommand is supported then the +of channel \fIchannel\fR. If this subcommand is supported then the subcommand \fBcget\fR has to be supported as well. .RS .PP @@ -324,10 +324,10 @@ will appear to have thrown this error. Any exception beyond \fBerror\fR .RE .\" METHOD: blocking .TP -\fIcmdPrefix \fBblocking \fIchannelId mode\fR +\fIcmdPrefix \fBblocking \fIchannel mode\fR . This \fIoptional\fR subcommand handles changes to the blocking mode of the -channel \fIchannelId\fR. The \fImode\fR is a boolean flag. A true value means +channel \fIchannel\fR. The \fImode\fR is a boolean flag. A true value means that the channel has to be set to blocking, and a false value means that the channel should be non-blocking. .RS @@ -341,10 +341,10 @@ etc.) is treated as and converted to an error. .RE .\" METHOD: truncate .TP -\fIcmdPrefix \fBtruncate\fI channelId length\fR +\fIcmdPrefix \fBtruncate\fI channel length\fR . This \fIoptional\fR subcommand handles changing the length of the -underlying data stream for the channel \fIchannelId\fR. Its length +underlying data stream for the channel \fIchannel\fR. Its length gets set to \fIlength\fR. .RS .PP diff --git a/doc/seek.n b/doc/seek.n index 8f0e707..5aa3439 100644 --- a/doc/seek.n +++ b/doc/seek.n @@ -12,7 +12,7 @@ .SH NAME seek \- Change the access position for an open channel .SH SYNOPSIS -\fBseek \fIchannelId offset \fR?\fIorigin\fR? +\fBseek \fIchannel offset \fR?\fIorigin\fR? .BE .SH DESCRIPTION .PP diff --git a/doc/tell.n b/doc/tell.n index 4948a19..49c097c 100644 --- a/doc/tell.n +++ b/doc/tell.n @@ -12,7 +12,7 @@ .SH NAME tell \- Return current access position for an open channel .SH SYNOPSIS -\fBtell \fIchannelId\fR +\fBtell \fIchannel\fR .BE .SH DESCRIPTION .PP diff --git a/doc/transchan.n b/doc/transchan.n index abae7b9..d174d23 100644 --- a/doc/transchan.n +++ b/doc/transchan.n @@ -12,7 +12,7 @@ transchan \- command handler API of channel transforms .SH SYNOPSIS .nf -\fBchan push \fIchannelId cmdPrefix\fR +\fBchan push \fIchannel cmdPrefix\fR \fIcmdPrefix \fBclear \fIhandle\fR \fIcmdPrefix \fBdrain \fIhandle\fR diff --git a/generic/tclIO.c b/generic/tclIO.c index 4859bc1..4018e1a 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -9195,7 +9195,7 @@ Tcl_FileEventObjCmd( static const int maskArray[] = {TCL_READABLE, TCL_WRITABLE}; if ((objc != 3) && (objc != 4)) { - Tcl_WrongNumArgs(interp, 1, objv, "channelId event ?script?"); + Tcl_WrongNumArgs(interp, 1, objv, "channel event ?script?"); return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objv[2], modeOptions, "event name", 0, diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c index c7ecb76..0357471 100644 --- a/generic/tclIOCmd.c +++ b/generic/tclIOCmd.c @@ -138,7 +138,7 @@ Tcl_PutsObjCmd( /* Fall through */ default: /* [puts] or * [puts some bad number of arguments...] */ - Tcl_WrongNumArgs(interp, 1, objv, "?-nonewline? ?channelId? string"); + Tcl_WrongNumArgs(interp, 1, objv, "?-nonewline? ?channel? string"); return TCL_ERROR; } @@ -222,7 +222,7 @@ Tcl_FlushObjCmd( int mode; if (objc != 2) { - Tcl_WrongNumArgs(interp, 1, objv, "channelId"); + Tcl_WrongNumArgs(interp, 1, objv, "channel"); return TCL_ERROR; } chanObjPtr = objv[1]; @@ -288,7 +288,7 @@ Tcl_GetsObjCmd( int code = TCL_OK; if ((objc != 2) && (objc != 3)) { - Tcl_WrongNumArgs(interp, 1, objv, "channelId ?varName?"); + Tcl_WrongNumArgs(interp, 1, objv, "channel ?varName?"); return TCL_ERROR; } chanObjPtr = objv[1]; @@ -379,7 +379,7 @@ Tcl_ReadObjCmd( argerror: iPtr = (Interp *) interp; - Tcl_WrongNumArgs(interp, 1, objv, "channelId ?numChars?"); + Tcl_WrongNumArgs(interp, 1, objv, "channel ?numChars?"); /* * Do not append directly; that makes ensembles using this command as @@ -387,7 +387,7 @@ Tcl_ReadObjCmd( */ iPtr->flags |= INTERP_ALTERNATE_WRONG_ARGS; - Tcl_WrongNumArgs(interp, 1, objv, "?-nonewline? channelId"); + Tcl_WrongNumArgs(interp, 1, objv, "?-nonewline? channel"); return TCL_ERROR; } @@ -515,7 +515,7 @@ Tcl_SeekObjCmd( static const int modeArray[] = {SEEK_SET, SEEK_CUR, SEEK_END}; if ((objc != 3) && (objc != 4)) { - Tcl_WrongNumArgs(interp, 1, objv, "channelId offset ?origin?"); + Tcl_WrongNumArgs(interp, 1, objv, "channel offset ?origin?"); return TCL_ERROR; } if (TclGetChannelFromObj(interp, objv[1], &chan, NULL, 0) != TCL_OK) { @@ -584,7 +584,7 @@ Tcl_TellObjCmd( int code; if (objc != 2) { - Tcl_WrongNumArgs(interp, 1, objv, "channelId"); + Tcl_WrongNumArgs(interp, 1, objv, "channel"); return TCL_ERROR; } @@ -647,7 +647,7 @@ Tcl_CloseObjCmd( static const int dirArray[] = {TCL_CLOSE_READ, TCL_CLOSE_WRITE}; if ((objc != 2) && (objc != 3)) { - Tcl_WrongNumArgs(interp, 1, objv, "channelId ?direction?"); + Tcl_WrongNumArgs(interp, 1, objv, "channel ?direction?"); return TCL_ERROR; } @@ -753,7 +753,7 @@ Tcl_FconfigureObjCmd( int i; /* Iterate over arg-value pairs. */ if ((objc < 2) || (((objc % 2) == 1) && (objc != 3))) { - Tcl_WrongNumArgs(interp, 1, objv, "channelId ?-option value ...?"); + Tcl_WrongNumArgs(interp, 1, objv, "channel ?-option value ...?"); return TCL_ERROR; } @@ -826,7 +826,7 @@ Tcl_EofObjCmd( Tcl_Channel chan; if (objc != 2) { - Tcl_WrongNumArgs(interp, 1, objv, "channelId"); + Tcl_WrongNumArgs(interp, 1, objv, "channel"); return TCL_ERROR; } @@ -1038,7 +1038,7 @@ Tcl_FblockedObjCmd( int mode; if (objc != 2) { - Tcl_WrongNumArgs(interp, 1, objv, "channelId"); + Tcl_WrongNumArgs(interp, 1, objv, "channel"); return TCL_ERROR; } @@ -1808,7 +1808,7 @@ ChanPendingObjCmd( int mode; if (objc != 3) { - Tcl_WrongNumArgs(interp, 1, objv, "mode channelId"); + Tcl_WrongNumArgs(interp, 1, objv, "mode channel"); return TCL_ERROR; } @@ -1868,7 +1868,7 @@ ChanTruncateObjCmd( Tcl_WideInt length; if ((objc < 2) || (objc > 3)) { - Tcl_WrongNumArgs(interp, 1, objv, "channelId ?length?"); + Tcl_WrongNumArgs(interp, 1, objv, "channel ?length?"); return TCL_ERROR; } if (TclGetChannelFromObj(interp, objv[1], &chan, NULL, 0) != TCL_OK) { diff --git a/generic/tclInterp.c b/generic/tclInterp.c index 70e1246..985190f 100644 --- a/generic/tclInterp.c +++ b/generic/tclInterp.c @@ -1064,7 +1064,7 @@ NRInterpCmd( Tcl_Channel chan; if (objc != 5) { - Tcl_WrongNumArgs(interp, 2, objv, "srcPath channelId destPath"); + Tcl_WrongNumArgs(interp, 2, objv, "srcPath channel destPath"); return TCL_ERROR; } parentInterp = GetInterp(interp, objv[2]); diff --git a/generic/tclTest.c b/generic/tclTest.c index 0bb09f6..3b08cd6 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -6444,7 +6444,7 @@ TestChannelCmd( if (argc != 5) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " transform channelId -command cmd\"", (char *)NULL); + " transform channel -command cmd\"", (char *)NULL); return TCL_ERROR; } if (strcmp(argv[3], "-command") != 0) { diff --git a/library/tcltest/tcltest.tcl b/library/tcltest/tcltest.tcl index 79492f6..25304404 100644 --- a/library/tcltest/tcltest.tcl +++ b/library/tcltest/tcltest.tcl @@ -1639,7 +1639,7 @@ proc tcltest::Replace::puts {args} { # return [Puts [lindex $args 0]] } 2 { - # Either -nonewline or channelId has been specified + # Either -nonewline or channel has been specified if {[lindex $args 0] eq "-nonewline"} { append outData [lindex $args end] return @@ -1651,7 +1651,7 @@ proc tcltest::Replace::puts {args} { } 3 { if {[lindex $args 0] eq "-nonewline"} { - # Both -nonewline and channelId are specified, unless + # Both -nonewline and channel are specified, unless # it's an error. -nonewline is supposed to be argv[0]. set channel [lindex $args 1] set newline "" diff --git a/tests/chan.test b/tests/chan.test index 87d642c..04fd17e 100644 --- a/tests/chan.test +++ b/tests/chan.test @@ -29,10 +29,10 @@ test chan-1.2 {chan command general syntax} -body { test chan-2.1 {chan command: blocked subcommand} -body { chan blocked foo bar -} -returnCodes error -result "wrong # args: should be \"chan blocked channelId\"" +} -returnCodes error -result "wrong # args: should be \"chan blocked channel\"" test chan-3.1 {chan command: close subcommand} -body { chan close foo bar zet -} -returnCodes error -result "wrong # args: should be \"chan close channelId ?direction?\"" +} -returnCodes error -result "wrong # args: should be \"chan close channel ?direction?\"" test chan-3.2 {chan command: close subcommand} -setup { set chan [open [info script] r] } -body { @@ -49,7 +49,7 @@ test chan-3.3 {chan command: close subcommand} -setup { } -returnCodes error -result "Half-close of write-side not possible, side not opened or already closed" test chan-4.1 {chan command: configure subcommand} -body { chan configure -} -returnCodes error -result "wrong # args: should be \"chan configure channelId ?-option value ...?\"" +} -returnCodes error -result "wrong # args: should be \"chan configure channel ?-option value ...?\"" test chan-4.2 {chan command: [Bug 800753]} -body { chan configure stdout -eofchar Ā } -returnCodes error -result {bad value for -eofchar: must be non-NUL ASCII character} @@ -72,19 +72,19 @@ test chan-5.1 {chan command: copy subcommand} -body { test chan-6.1 {chan command: eof subcommand} -body { chan eof foo bar -} -returnCodes error -result "wrong # args: should be \"chan eof channelId\"" +} -returnCodes error -result "wrong # args: should be \"chan eof channel\"" test chan-7.1 {chan command: event subcommand} -body { chan event foo -} -returnCodes error -result "wrong # args: should be \"chan event channelId event ?script?\"" +} -returnCodes error -result "wrong # args: should be \"chan event channel event ?script?\"" test chan-8.1 {chan command: flush subcommand} -body { chan flush foo bar -} -returnCodes error -result "wrong # args: should be \"chan flush channelId\"" +} -returnCodes error -result "wrong # args: should be \"chan flush channel\"" test chan-9.1 {chan command: gets subcommand} -body { chan gets -} -returnCodes error -result "wrong # args: should be \"chan gets channelId ?varName?\"" +} -returnCodes error -result "wrong # args: should be \"chan gets channel ?varName?\"" test chan-10.1 {chan command: names subcommand} -body { chan names foo bar @@ -92,23 +92,23 @@ test chan-10.1 {chan command: names subcommand} -body { test chan-11.1 {chan command: puts subcommand} -body { chan puts foo bar foo bar -} -returnCodes error -result "wrong # args: should be \"chan puts ?-nonewline? ?channelId? string\"" +} -returnCodes error -result "wrong # args: should be \"chan puts ?-nonewline? ?channel? string\"" test chan-12.1 {chan command: read subcommand} -body { chan read -} -returnCodes error -result "wrong # args: should be \"chan read channelId ?numChars?\" or \"chan read ?-nonewline? channelId\"" +} -returnCodes error -result "wrong # args: should be \"chan read channel ?numChars?\" or \"chan read ?-nonewline? channel\"" test chan-13.1 {chan command: seek subcommand} -body { chan seek foo bar foo bar -} -returnCodes error -result "wrong # args: should be \"chan seek channelId offset ?origin?\"" +} -returnCodes error -result "wrong # args: should be \"chan seek channel offset ?origin?\"" test chan-14.1 {chan command: tell subcommand} -body { chan tell foo bar -} -returnCodes error -result "wrong # args: should be \"chan tell channelId\"" +} -returnCodes error -result "wrong # args: should be \"chan tell channel\"" test chan-15.1 {chan command: truncate subcommand} -body { chan truncate foo bar foo bar -} -returnCodes error -result "wrong \# args: should be \"chan truncate channelId ?length?\"" +} -returnCodes error -result "wrong \# args: should be \"chan truncate channel ?length?\"" test chan-15.2 {chan command: truncate subcommand} -setup { set file [makeFile {} testTruncate] set f [open $file w+] @@ -127,13 +127,13 @@ test chan-15.2 {chan command: truncate subcommand} -setup { # TIP 287: chan pending test chan-16.1 {chan command: pending subcommand} -body { chan pending -} -returnCodes error -result "wrong # args: should be \"chan pending mode channelId\"" +} -returnCodes error -result "wrong # args: should be \"chan pending mode channel\"" test chan-16.2 {chan command: pending subcommand} -body { chan pending stdin -} -returnCodes error -result "wrong # args: should be \"chan pending mode channelId\"" +} -returnCodes error -result "wrong # args: should be \"chan pending mode channel\"" test chan-16.3 {chan command: pending subcommand} -body { chan pending stdin stdout stderr -} -returnCodes error -result "wrong # args: should be \"chan pending mode channelId\"" +} -returnCodes error -result "wrong # args: should be \"chan pending mode channel\"" test chan-16.4 {chan command: pending subcommand} -body { chan pending {input output} stdout } -returnCodes error -result "bad mode \"input output\": must be input or output" diff --git a/tests/chanio.test b/tests/chanio.test index 6173d0d..e95a0ca 100644 --- a/tests/chanio.test +++ b/tests/chanio.test @@ -5505,10 +5505,10 @@ test chan-io-40.16 {verify no tilde substitution in open} -setup { test chan-io-41.1 {Tcl_FileeventCmd: errors} -constraints fileevent -body { chan event foo -} -returnCodes error -result {wrong # args: should be "chan event channelId event ?script?"} +} -returnCodes error -result {wrong # args: should be "chan event channel event ?script?"} test chan-io-41.2 {Tcl_FileeventCmd: errors} -constraints fileevent -body { chan event foo bar baz q -} -returnCodes error -result {wrong # args: should be "chan event channelId event ?script?"} +} -returnCodes error -result {wrong # args: should be "chan event channel event ?script?"} test chan-io-41.3 {Tcl_FileeventCmd: errors} -constraints fileevent -body { chan event gorp readable } -returnCodes error -result {can not find channel named "gorp"} diff --git a/tests/io.test b/tests/io.test index ad8d6b7..d550352 100644 --- a/tests/io.test +++ b/tests/io.test @@ -6074,10 +6074,10 @@ test io-40.17 {tilde substitution in open} { test io-41.1 {Tcl_FileeventCmd: errors} {fileevent} { list [catch {fileevent foo} msg] $msg -} {1 {wrong # args: should be "fileevent channelId event ?script?"}} +} {1 {wrong # args: should be "fileevent channel event ?script?"}} test io-41.2 {Tcl_FileeventCmd: errors} {fileevent} { list [catch {fileevent foo bar baz q} msg] $msg -} {1 {wrong # args: should be "fileevent channelId event ?script?"}} +} {1 {wrong # args: should be "fileevent channel event ?script?"}} test io-41.3 {Tcl_FileeventCmd: errors} {fileevent} { list [catch {fileevent gorp readable} msg] $msg } {1 {can not find channel named "gorp"}} diff --git a/tests/ioCmd.test b/tests/ioCmd.test index e8a9c57..07cf3cd 100644 --- a/tests/ioCmd.test +++ b/tests/ioCmd.test @@ -30,13 +30,13 @@ testConstraint testchannel [llength [info commands testchannel]] test iocmd-1.1 {puts command} { list [catch {puts} msg] $msg -} {1 {wrong # args: should be "puts ?-nonewline? ?channelId? string"}} +} {1 {wrong # args: should be "puts ?-nonewline? ?channel? string"}} test iocmd-1.2 {puts command} { list [catch {puts a b c d e f g} msg] $msg -} {1 {wrong # args: should be "puts ?-nonewline? ?channelId? string"}} +} {1 {wrong # args: should be "puts ?-nonewline? ?channel? string"}} test iocmd-1.3 {puts command} { list [catch {puts froboz -nonewline kablooie} msg] $msg -} {1 {wrong # args: should be "puts ?-nonewline? ?channelId? string"}} +} {1 {wrong # args: should be "puts ?-nonewline? ?channel? string"}} test iocmd-1.4 {puts command} { list [catch {puts froboz hello} msg] $msg } {1 {can not find channel named "froboz"}} @@ -70,10 +70,10 @@ test iocmd-1.8 {puts command} { test iocmd-2.1 {flush command} { list [catch {flush} msg] $msg -} {1 {wrong # args: should be "flush channelId"}} +} {1 {wrong # args: should be "flush channel"}} test iocmd-2.2 {flush command} { list [catch {flush a b c d e} msg] $msg -} {1 {wrong # args: should be "flush channelId"}} +} {1 {wrong # args: should be "flush channel"}} test iocmd-2.3 {flush command} { list [catch {flush foo} msg] $msg } {1 {can not find channel named "foo"}} @@ -83,10 +83,10 @@ test iocmd-2.4 {flush command} { test iocmd-3.1 {gets command} { list [catch {gets} msg] $msg -} {1 {wrong # args: should be "gets channelId ?varName?"}} +} {1 {wrong # args: should be "gets channel ?varName?"}} test iocmd-3.2 {gets command} { list [catch {gets a b c d e f g} msg] $msg -} {1 {wrong # args: should be "gets channelId ?varName?"}} +} {1 {wrong # args: should be "gets channel ?varName?"}} test iocmd-3.3 {gets command} { list [catch {gets aaa} msg] $msg } {1 {can not find channel named "aaa"}} @@ -107,16 +107,16 @@ test iocmd-3.5 {gets command} { test iocmd-4.1 {read command} { list [catch {read} msg] $msg -} {1 {wrong # args: should be "read channelId ?numChars?" or "read ?-nonewline? channelId"}} +} {1 {wrong # args: should be "read channel ?numChars?" or "read ?-nonewline? channel"}} test iocmd-4.2 {read command} { list [catch {read a b c d e f g h} msg] $msg -} {1 {wrong # args: should be "read channelId ?numChars?" or "read ?-nonewline? channelId"}} +} {1 {wrong # args: should be "read channel ?numChars?" or "read ?-nonewline? channel"}} test iocmd-4.3 {read command} { list [catch {read aaa} msg] $msg } {1 {can not find channel named "aaa"}} test iocmd-4.4 {read command} { list [catch {read -nonewline} msg] $msg -} {1 {wrong # args: should be "read channelId ?numChars?" or "read ?-nonewline? channelId"}} +} {1 {wrong # args: should be "read channel ?numChars?" or "read ?-nonewline? channel"}} test iocmd-4.5 {read command} { list [catch {read -nonew file4} msg] $msg $::errorCode } {1 {can not find channel named "-nonew"} {TCL LOOKUP CHANNEL -nonew}} @@ -136,7 +136,7 @@ test iocmd-4.8 {read command with incorrect combination of arguments} { set x [list [catch {read -nonewline $f 20 z} msg] $msg $::errorCode] close $f set x -} {1 {wrong # args: should be "read channelId ?numChars?" or "read ?-nonewline? channelId"} {TCL WRONGARGS}} +} {1 {wrong # args: should be "read channel ?numChars?" or "read ?-nonewline? channel"} {TCL WRONGARGS}} test iocmd-4.9 {read command} { list [catch {read stdin foo} msg] $msg $::errorCode } {1 {expected non-negative integer but got "foo"} {TCL VALUE NUMBER}} @@ -161,10 +161,10 @@ test iocmd-4.12 {read command} -setup { test iocmd-5.1 {seek command} -returnCodes error -body { seek -} -result {wrong # args: should be "seek channelId offset ?origin?"} +} -result {wrong # args: should be "seek channel offset ?origin?"} test iocmd-5.2 {seek command} -returnCodes error -body { seek a b c d e f g -} -result {wrong # args: should be "seek channelId offset ?origin?"} +} -result {wrong # args: should be "seek channel offset ?origin?"} test iocmd-5.3 {seek command} -returnCodes error -body { seek stdin gugu } -result {expected integer but got "gugu"} @@ -174,20 +174,20 @@ test iocmd-5.4 {seek command} -returnCodes error -body { test iocmd-6.1 {tell command} { list [catch {tell} msg] $msg -} {1 {wrong # args: should be "tell channelId"}} +} {1 {wrong # args: should be "tell channel"}} test iocmd-6.2 {tell command} { list [catch {tell a b c d e} msg] $msg -} {1 {wrong # args: should be "tell channelId"}} +} {1 {wrong # args: should be "tell channel"}} test iocmd-6.3 {tell command} { list [catch {tell aaa} msg] $msg } {1 {can not find channel named "aaa"}} test iocmd-7.1 {close command} { list [catch {close} msg] $msg -} {1 {wrong # args: should be "close channelId ?direction?"}} +} {1 {wrong # args: should be "close channel ?direction?"}} test iocmd-7.2 {close command} { list [catch {close a b c d e} msg] $msg -} {1 {wrong # args: should be "close channelId ?direction?"}} +} {1 {wrong # args: should be "close channel ?direction?"}} test iocmd-7.3 {close command} { list [catch {close aaa} msg] $msg } {1 {can not find channel named "aaa"}} @@ -216,10 +216,10 @@ proc expectedOpts {got extra} { } test iocmd-8.1 {fconfigure command} -returnCodes error -body { fconfigure -} -result {wrong # args: should be "fconfigure channelId ?-option value ...?"} +} -result {wrong # args: should be "fconfigure channel ?-option value ...?"} test iocmd-8.2 {fconfigure command} -returnCodes error -body { fconfigure a b c d e f -} -result {wrong # args: should be "fconfigure channelId ?-option value ...?"} +} -result {wrong # args: should be "fconfigure channel ?-option value ...?"} test iocmd-8.3 {fconfigure command} -returnCodes error -body { fconfigure a b } -result {can not find channel named "a"} @@ -376,10 +376,10 @@ test iocmd-8.23 {fconfigure -profile badprofile} -body { test iocmd-9.1 {eof command} { list [catch {eof} msg] $msg $::errorCode -} {1 {wrong # args: should be "eof channelId"} {TCL WRONGARGS}} +} {1 {wrong # args: should be "eof channel"} {TCL WRONGARGS}} test iocmd-9.2 {eof command} { list [catch {eof a b} msg] $msg $::errorCode -} {1 {wrong # args: should be "eof channelId"} {TCL WRONGARGS}} +} {1 {wrong # args: should be "eof channel"} {TCL WRONGARGS}} test iocmd-9.3 {eof command} { catch {close file100} list [catch {eof file100} msg] $msg $::errorCode @@ -389,10 +389,10 @@ test iocmd-9.3 {eof command} { test iocmd-10.1 {fblocked command} { list [catch {fblocked} msg] $msg -} {1 {wrong # args: should be "fblocked channelId"}} +} {1 {wrong # args: should be "fblocked channel"}} test iocmd-10.2 {fblocked command} { list [catch {fblocked a b c d e f g} msg] $msg -} {1 {wrong # args: should be "fblocked channelId"}} +} {1 {wrong # args: should be "fblocked channel"}} test iocmd-10.3 {fblocked command} { list [catch {fblocked file1000} msg] $msg } {1 {can not find channel named "file1000"}} diff --git a/tests/pid.test b/tests/pid.test index 3f62457..5abbe1f 100644 --- a/tests/pid.test +++ b/tests/pid.test @@ -47,7 +47,7 @@ test pid-1.3 {pid command} -constraints pidDefined -setup { } -result {} test pid-1.4 {pid command} pidDefined { list [catch {pid a b} msg] $msg -} {1 {wrong # args: should be "pid ?channelId?"}} +} {1 {wrong # args: should be "pid ?channel?"}} test pid-1.5 {pid command} pidDefined { list [catch {pid gorp} msg] $msg } {1 {can not find channel named "gorp"}} diff --git a/tests/trace.test b/tests/trace.test index 64c9111..16c858c 100644 --- a/tests/trace.test +++ b/tests/trace.test @@ -1695,7 +1695,7 @@ test trace-21.12 {bug 2438181} -setup { trace add execution set2 leave {puts one two three #;} } -body { set2 a hello -} -returnCodes 1 -result {wrong # args: should be "puts ?-nonewline? ?channelId? string"} +} -returnCodes 1 -result {wrong # args: should be "puts ?-nonewline? ?channel? string"} proc factorial {n} { if {$n != 1} { return [expr {$n * [factorial [expr {$n -1 }]]}] } diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c index a61c083..046ec90 100644 --- a/unix/tclUnixPipe.c +++ b/unix/tclUnixPipe.c @@ -1380,7 +1380,7 @@ Tcl_PidObjCmd( Tcl_Obj *resultPtr; if (objc > 2) { - Tcl_WrongNumArgs(interp, 1, objv, "?channelId?"); + Tcl_WrongNumArgs(interp, 1, objv, "?channel?"); return TCL_ERROR; } diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index eeb06f8..7b083a5 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -2762,7 +2762,7 @@ Tcl_PidObjCmd( Tcl_Obj *resultPtr; if (objc > 2) { - Tcl_WrongNumArgs(interp, 1, objv, "?channelId?"); + Tcl_WrongNumArgs(interp, 1, objv, "?channel?"); return TCL_ERROR; } if (objc == 1) { -- cgit v0.12