summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-09-10 11:33:25 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-09-10 11:33:25 (GMT)
commit06d15abf35fabff20dcd2f953f3c52ed6d9bd7ce (patch)
tree8618aca4a3bc042191de3d1e3e277eeed60ba5e1
parent0e0be8492f32e304665caeadace916ce72829c5e (diff)
parent2592b1e93b713440a2fab51b01df4ad31bb21f7d (diff)
downloadtcl-06d15abf35fabff20dcd2f953f3c52ed6d9bd7ce.zip
tcl-06d15abf35fabff20dcd2f953f3c52ed6d9bd7ce.tar.gz
tcl-06d15abf35fabff20dcd2f953f3c52ed6d9bd7ce.tar.bz2
Merge 8.6
-rw-r--r--generic/tclCompCmds.c20
-rw-r--r--generic/tclEncoding.c2
-rw-r--r--generic/tclInt.h2
-rw-r--r--generic/tclStringRep.h4
-rw-r--r--tests/all.tcl2
5 files changed, 15 insertions, 15 deletions
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index 37adcef..3e2da23 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.c
@@ -390,9 +390,9 @@ TclCompileArraySetCmd(
keyVar = AnonymousLocal(envPtr);
valVar = AnonymousLocal(envPtr);
- infoPtr = (ForeachInfo *)ckalloc(sizeof(ForeachInfo));
+ infoPtr = (ForeachInfo *)ckalloc(offsetof(ForeachInfo, varLists) + sizeof(ForeachVarList *));
infoPtr->numLists = 1;
- infoPtr->varLists[0] = (ForeachVarList *)ckalloc(sizeof(ForeachVarList) + sizeof(int));
+ infoPtr->varLists[0] = (ForeachVarList *)ckalloc(offsetof(ForeachVarList, varIndexes) + 2 * sizeof(int));
infoPtr->varLists[0]->numVars = 2;
infoPtr->varLists[0]->varIndexes[0] = keyVar;
infoPtr->varLists[0]->varIndexes[1] = valVar;
@@ -1789,7 +1789,7 @@ TclCompileDictUpdateCmd(
* that are to be used.
*/
- duiPtr = (DictUpdateInfo *)ckalloc(sizeof(DictUpdateInfo) + sizeof(int) * (numVars - 1));
+ duiPtr = (DictUpdateInfo *)ckalloc(offsetof(DictUpdateInfo, varIndices) + sizeof(int) * numVars);
duiPtr->length = numVars;
keyTokenPtrs = (Tcl_Token **)TclStackAlloc(interp, sizeof(Tcl_Token *) * numVars);
tokenPtr = TokenAfter(dictVarTokenPtr);
@@ -2271,7 +2271,7 @@ DupDictUpdateInfo(
size_t len;
dui1Ptr = (DictUpdateInfo *)clientData;
- len = sizeof(DictUpdateInfo) + sizeof(int) * (dui1Ptr->length - 1);
+ len = offsetof(DictUpdateInfo, varIndices) + sizeof(int) * dui1Ptr->length;
dui2Ptr = (DictUpdateInfo *)ckalloc(len);
memcpy(dui2Ptr, dui1Ptr, len);
return dui2Ptr;
@@ -2721,8 +2721,8 @@ CompileEachloopCmd(
*/
numLists = (numWords - 2)/2;
- infoPtr = (ForeachInfo *)ckalloc(sizeof(ForeachInfo)
- + (numLists - 1) * sizeof(ForeachVarList *));
+ infoPtr = (ForeachInfo *)ckalloc(offsetof(ForeachInfo, varLists)
+ + numLists * sizeof(ForeachVarList *));
infoPtr->numLists = 0; /* Count this up as we go */
/*
@@ -2755,8 +2755,8 @@ CompileEachloopCmd(
goto done;
}
- varListPtr = (ForeachVarList *)ckalloc(sizeof(ForeachVarList)
- + (numVars - 1) * sizeof(int));
+ varListPtr = (ForeachVarList *)ckalloc(offsetof(ForeachVarList, varIndexes)
+ + numVars * sizeof(int));
varListPtr->numVars = numVars;
infoPtr->varLists[i/2] = varListPtr;
infoPtr->numLists++;
@@ -2891,7 +2891,7 @@ DupForeachInfo(
ForeachVarList *srcListPtr, *dupListPtr;
int numVars, i, j, numLists = srcPtr->numLists;
- dupPtr = (ForeachInfo *)ckalloc(sizeof(ForeachInfo)
+ dupPtr = (ForeachInfo *)ckalloc(offsetof(ForeachInfo, varLists)
+ numLists * sizeof(ForeachVarList *));
dupPtr->numLists = numLists;
dupPtr->firstValueTemp = srcPtr->firstValueTemp;
@@ -2900,7 +2900,7 @@ DupForeachInfo(
for (i = 0; i < numLists; i++) {
srcListPtr = srcPtr->varLists[i];
numVars = srcListPtr->numVars;
- dupListPtr = (ForeachVarList *)ckalloc(sizeof(ForeachVarList)
+ dupListPtr = (ForeachVarList *)ckalloc(offsetof(ForeachVarList, varIndexes)
+ numVars * sizeof(int));
dupListPtr->numVars = numVars;
for (j = 0; j < numVars; j++) {
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index ae02821..c774ce2 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -2053,7 +2053,7 @@ LoadEscapeEncoding(
Tcl_DStringFree(&lineString);
}
- size = sizeof(EscapeEncodingData) - sizeof(EscapeSubTable)
+ size = offsetof(EscapeEncodingData, subTables)
+ Tcl_DStringLength(&escapeData);
dataPtr = (EscapeEncodingData *)ckalloc(size);
dataPtr->initLen = strlen(init);
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 2f12b8f..b983b81 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -4935,7 +4935,7 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
* Computes number of bytes from beginning of structure to a given field.
*/
-#ifndef TCL_NO_DEPRECATED
+#if !defined(TCL_NO_DEPRECATED) && !defined(BUILD_tcl)
# define TclOffset(type, field) ((int) offsetof(type, field))
#endif
/* Workaround for platforms missing offsetof(), e.g. VC++ 6.0 */
diff --git a/generic/tclStringRep.h b/generic/tclStringRep.h
index fc5a713..1ad78a1 100644
--- a/generic/tclStringRep.h
+++ b/generic/tclStringRep.h
@@ -65,9 +65,9 @@ typedef struct {
} String;
#define STRING_MAXCHARS \
- (int)(((size_t)UINT_MAX - sizeof(String))/sizeof(Tcl_UniChar))
+ (int)(((size_t)UINT_MAX - 1 - offsetof(String, unicode))/sizeof(Tcl_UniChar))
#define STRING_SIZE(numChars) \
- (sizeof(String) + ((numChars) * sizeof(Tcl_UniChar)))
+ (offsetof(String, unicode) + ((numChars + 1) * sizeof(Tcl_UniChar)))
#define stringCheckLimits(numChars) \
do { \
if ((numChars) < 0 || (numChars) > STRING_MAXCHARS) { \
diff --git a/tests/all.tcl b/tests/all.tcl
index 52c8763..c72334a 100644
--- a/tests/all.tcl
+++ b/tests/all.tcl
@@ -1,7 +1,7 @@
# all.tcl --
#
# This file contains a top-level script to run all of the Tcl
-# tests. Execute it by invoking "source all.test" when running tcltest
+# tests. Execute it by invoking "source all.tcl" when running tcltest
# in this directory.
#
# Copyright (c) 1998-1999 by Scriptics Corporation.