diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-12-20 19:31:13 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-12-20 19:31:13 (GMT) |
commit | b8dbe57714f7e25a957a706d5915a4487c786924 (patch) | |
tree | 042d23eb7659ef165af94528064e0ec9d131b350 | |
parent | 436c0de967e27c66804e2c1008287c4345d41b44 (diff) | |
download | tcl-b8dbe57714f7e25a957a706d5915a4487c786924.zip tcl-b8dbe57714f7e25a957a706d5915a4487c786924.tar.gz tcl-b8dbe57714f7e25a957a706d5915a4487c786924.tar.bz2 |
Spacing
-rw-r--r-- | doc/const.n | 18 | ||||
-rw-r--r-- | generic/tclCompCmds.c | 4 | ||||
-rw-r--r-- | generic/tclExecute.c | 2 | ||||
-rw-r--r-- | generic/tclInt.h | 4 | ||||
-rw-r--r-- | generic/tclVar.c | 20 | ||||
-rw-r--r-- | tests/var.test | 24 |
6 files changed, 36 insertions, 36 deletions
diff --git a/doc/const.n b/doc/const.n index b432655..9bc77ba 100644 --- a/doc/const.n +++ b/doc/const.n @@ -15,25 +15,25 @@ const \- create and initialize a constant .BE .SH DESCRIPTION .PP -This command is normally used within a procedure body (or method body, -or lambda term) to create a constant within that procedure, or within a -\fBnamespace eval\fR body to create a constant within that namespace. -The constant is an unmodifiable variable, called \fIvarName\fR, that is +This command is normally used within a procedure body (or method body, +or lambda term) to create a constant within that procedure, or within a +\fBnamespace eval\fR body to create a constant within that namespace. +The constant is an unmodifiable variable, called \fIvarName\fR, that is initialized with \fIvalue\fR. The result of \fBconst\fR is always the empty string on success. .PP -If a variable \fIvarName\fR does not exist, it is created with its value set +If a variable \fIvarName\fR does not exist, it is created with its value set to \fIvalue\fR and marked as a constant; this means that no other command (e.g., \fBset\fR, \fBappend\fR, \fBincr\fR, \fBunset\fR) -may modify or remove the variable; variables are checked for whether they +may modify or remove the variable; variables are checked for whether they are constants before any traces are called. -If a variable \fIvarName\fR already exists, it is an error unless that +If a variable \fIvarName\fR already exists, it is an error unless that variable is marked as a constant (in which case \fBconst\fR is a no-op). .PP -The \fIvarName\fR may not be a qualified name or reference an element of an +The \fIvarName\fR may not be a qualified name or reference an element of an array by any means. If the variable exists and is an array, that is an error. .PP -Constants are normally only removed by their containing procedure exiting or +Constants are normally only removed by their containing procedure exiting or their namespace being deleted. .SH EXAMPLES .PP diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c index 2536ba7..495c307 100644 --- a/generic/tclCompCmds.c +++ b/generic/tclCompCmds.c @@ -947,7 +947,7 @@ TclCompileConstCmd( int isScalar, localIndex; /* - * Need exactly two arguments. + * Need exactly two arguments. */ if (parsePtr->numWords != 3) { return TCL_ERROR; @@ -967,7 +967,7 @@ TclCompileConstCmd( /* * If the user specified an array element, we don't bother handling - * that. + * that. */ if (!isScalar) { return TCL_ERROR; diff --git a/generic/tclExecute.c b/generic/tclExecute.c index f4ea875..225cc53 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -3975,7 +3975,7 @@ TEBCresume( Tcl_Obj *resPtr; DECACHE_STACK_INFO(); - resPtr = TclPtrSetVarIdx(interp, varPtr, arrayPtr, part1Ptr, NULL, + resPtr = TclPtrSetVarIdx(interp, varPtr, arrayPtr, part1Ptr, NULL, objPtr, TCL_LEAVE_ERR_MSG, opnd); CACHE_STACK_INFO(); if (resPtr == NULL) { diff --git a/generic/tclInt.h b/generic/tclInt.h index 95374eb..c9b4814 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -661,8 +661,8 @@ typedef struct VarInHash { * through "upvar" and "global" commands, or * through references to variables in enclosing * namespaces. - * VAR_CONSTANT - 1 means this is a constant "variable", and - * cannot be written to by ordinary commands. + * VAR_CONSTANT - 1 means this is a constant "variable", and + * cannot be written to by ordinary commands. * Structurally, it's the same as a scalar when * being read, but writes are rejected. Constants * are not supported inside arrays. diff --git a/generic/tclVar.c b/generic/tclVar.c index 4ab9dd5..125091a 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -180,7 +180,7 @@ typedef struct ArrayVarHashTable { */ static void AppendLocals(Tcl_Interp *interp, Tcl_Obj *listPtr, - Tcl_Obj *patternPtr, int includeLinks, + Tcl_Obj *patternPtr, int includeLinks, int justConstants); static void ArrayPopulateSearch(Tcl_Interp *interp, Tcl_Obj *arrayNameObj, Var *varPtr, @@ -4845,7 +4845,7 @@ Tcl_GetVariableFullName( *---------------------------------------------------------------------- * * Tcl_ConstObjCmd -- - * + * * This function is invoked to process the "const" Tcl command. * See the user documentation for details on what it does. * @@ -4854,7 +4854,7 @@ Tcl_GetVariableFullName( * * Side effects: * See the user documentation. - * + * *---------------------------------------------------------------------- */ @@ -4874,7 +4874,7 @@ Tcl_ConstObjCmd( } part1Ptr = objv[1]; - varPtr = TclObjLookupVarEx(interp, part1Ptr, NULL, TCL_LEAVE_ERR_MSG, + varPtr = TclObjLookupVarEx(interp, part1Ptr, NULL, TCL_LEAVE_ERR_MSG, "const", /*createPart1*/ 1, /*createPart2*/ 1, &arrayPtr); if (TclIsVarArray(varPtr)) { TclObjVarErrMsg(interp, part1Ptr, NULL, "make constant", ISARRAY, -1); @@ -4891,7 +4891,7 @@ Tcl_ConstObjCmd( } /* - * If already exists, either a constant (no problem) or an error. + * If already exists, either a constant (no problem) or an error. */ if (!TclIsVarUndefined(varPtr)) { if (TclIsVarConstant(varPtr)) { @@ -4905,7 +4905,7 @@ Tcl_ConstObjCmd( /* * Make the variable and flag it as a constant. */ - if (TclPtrSetVar(interp, (Tcl_Var) varPtr, NULL, objv[1], NULL, + if (TclPtrSetVar(interp, (Tcl_Var) varPtr, NULL, objv[1], NULL, objv[2], TCL_LEAVE_ERR_MSG) == NULL) { if (TclIsVarUndefined(varPtr)) { CleanupVar(varPtr, arrayPtr); @@ -6522,8 +6522,8 @@ ContextObjectContainsConstant( Tcl_Obj *varNamePtr) { /* - * Helper for AppendLocals to check if an object contains a variable - * that is a constant. It's too complicated without factoring this + * Helper for AppendLocals to check if an object contains a variable + * that is a constant. It's too complicated without factoring this * check out! */ @@ -6642,7 +6642,7 @@ AppendLocals( } if (iPtr->varFramePtr->isProcCallFrame & FRAME_IS_METHOD) { - Tcl_ObjectContext context = (Tcl_ObjectContext) + Tcl_ObjectContext context = (Tcl_ObjectContext) iPtr->varFramePtr->clientData; Method *mPtr = (Method *) Tcl_ObjectContextMethod(context); PrivateVariableMapping *privatePtr; @@ -6652,7 +6652,7 @@ AppendLocals( FOREACH(objNamePtr, oPtr->variables) { Tcl_CreateHashEntry(&addedTable, objNamePtr, &added); - if (justConstants && !ContextObjectContainsConstant(context, + if (justConstants && !ContextObjectContainsConstant(context, objNamePtr)) { continue; } diff --git a/tests/var.test b/tests/var.test index a42f6cb..405a4b8 100644 --- a/tests/var.test +++ b/tests/var.test @@ -1951,12 +1951,12 @@ test var-29.2 {const: TclOO variable resolution} -setup { method checkWrite {} { list [catch { set X abc - } msg] $msg + } msg] $msg } method checkUnset {} { list [catch { unset X - } msg] $msg + } msg] $msg } method checkProbe {} { info constant X @@ -1985,12 +1985,12 @@ test var-29.3 {const: TclOO variable resolution} -setup { method checkWrite {} { list [catch { set X abc - } msg] $msg + } msg] $msg } method checkUnset {} { list [catch { unset X - } msg] $msg + } msg] $msg } method checkProbe {} { info constant X @@ -2019,13 +2019,13 @@ test var-29.4 {const: TclOO variable resolution} -setup { method checkWrite {} { list [catch { set X abc - } msg] $msg + } msg] $msg } method checkUnset {} { list [catch { unset X set X gorp - } msg] $msg + } msg] $msg } method checkProbe {} { info constant X @@ -2053,12 +2053,12 @@ test var-29.5 {const: TclOO variable resolution} -setup { method checkWrite {} { list [catch { set X abc - } msg] $msg + } msg] $msg } method checkUnset {} { list [catch { unset X - } msg] $msg + } msg] $msg } method checkProbe {} { info constant X @@ -2086,12 +2086,12 @@ test var-29.6 {const: TclOO variable resolution} -setup { method checkWrite {} { list [catch { set X abc - } msg] $msg + } msg] $msg } method checkUnset {} { list [catch { unset X - } msg] $msg + } msg] $msg } method checkProbe {} { info constant X @@ -2119,13 +2119,13 @@ test var-29.7 {const: TclOO variable resolution} -setup { method checkWrite {} { list [catch { set X abc - } msg] $msg + } msg] $msg } method checkUnset {} { list [catch { unset X set X gorp - } msg] $msg + } msg] $msg } method checkProbe {} { info constant X |