summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/tcl.decls4
-rw-r--r--generic/tcl.h8
-rw-r--r--generic/tclCompile.h12
-rw-r--r--generic/tclDecls.h8
-rw-r--r--generic/tclHash.c46
-rw-r--r--generic/tclInt.h6
-rw-r--r--generic/tclNamesp.c7
-rw-r--r--generic/tclStringRep.h10
-rw-r--r--generic/tclUtf.c14
9 files changed, 57 insertions, 58 deletions
diff --git a/generic/tcl.decls b/generic/tcl.decls
index 260bd7f..73a133b 100644
--- a/generic/tcl.decls
+++ b/generic/tcl.decls
@@ -1148,7 +1148,7 @@ declare 319 {
Tcl_QueuePosition position)
}
declare 320 {
- Tcl_UniChar Tcl_UniCharAtIndex(const char *src, int index)
+ Tcl_UniChar Tcl_UniCharAtIndex(const char *src, size_t index)
}
declare 321 {
Tcl_UniChar Tcl_UniCharToLower(int ch)
@@ -1163,7 +1163,7 @@ declare 324 {
int Tcl_UniCharToUtf(int ch, char *buf)
}
declare 325 {
- CONST84_RETURN char *Tcl_UtfAtIndex(const char *src, int index)
+ CONST84_RETURN char *Tcl_UtfAtIndex(const char *src, size_t index)
}
declare 326 {
int Tcl_UtfCharComplete(const char *src, size_t length)
diff --git a/generic/tcl.h b/generic/tcl.h
index 6929a71..87b25a4 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -1228,13 +1228,13 @@ struct Tcl_HashTable {
Tcl_HashEntry *staticBuckets[TCL_SMALL_HASH_TABLE];
/* Bucket array used for small tables (to
* avoid mallocs and frees). */
- size_t numBuckets1; /* Total number of buckets allocated at
+ size_t numBuckets; /* Total number of buckets allocated at
* **bucketPtr. */
size_t numEntries; /* Total number of entries present in
* table. */
- size_t rebuildSize1; /* Enlarge table when numEntries gets to be
+ size_t rebuildSize; /* Enlarge table when numEntries gets to be
* this large. */
- size_t mask1; /* Mask value used in hashing function. */
+ size_t mask; /* Mask value used in hashing function. */
int downShift; /* Shift count used in hashing function.
* Designed to use high-order bits of
* randomized keys. */
@@ -1258,7 +1258,7 @@ struct Tcl_HashTable {
typedef struct Tcl_HashSearch {
Tcl_HashTable *tablePtr; /* Table being searched. */
- size_t nextIndex1; /* Index of next bucket to be enumerated after
+ size_t nextIndex; /* Index of next bucket to be enumerated after
* present one. */
Tcl_HashEntry *nextEntryPtr;/* Next entry to be enumerated in the current
* bucket. */
diff --git a/generic/tclCompile.h b/generic/tclCompile.h
index 56c3768..d6b9fa3 100644
--- a/generic/tclCompile.h
+++ b/generic/tclCompile.h
@@ -87,7 +87,7 @@ typedef enum {
* to a catch PC offset. */
} ExceptionRangeType;
-typedef struct ExceptionRange {
+typedef struct {
ExceptionRangeType type; /* The kind of ExceptionRange. */
int nestingLevel; /* Static depth of the exception range. Used
* to find the most deeply-nested range
@@ -162,7 +162,7 @@ typedef struct ExceptionAux {
* source offset is not monotonic.
*/
-typedef struct CmdLocation {
+typedef struct {
int codeOffset; /* Offset of first byte of command code. */
int numCodeBytes; /* Number of bytes for command's code. */
int srcOffset; /* Offset of first char of the command. */
@@ -180,7 +180,7 @@ typedef struct CmdLocation {
* frame and associated information, like the path of a sourced file.
*/
-typedef struct ECL {
+typedef struct {
int srcOffset; /* Command location to find the entry. */
int nline; /* Number of words in the command */
int *line; /* Line information for all words in the
@@ -190,7 +190,7 @@ typedef struct ECL {
* lines. */
} ECL;
-typedef struct ExtCmdLoc {
+typedef struct {
int type; /* Context type. */
int start; /* Starting line for compiled script. Needed
* for the extended recompile check in
@@ -417,7 +417,7 @@ typedef struct ByteCode {
* procs are specific to an interpreter so the
* code emitted will depend on the
* interpreter. */
- unsigned int compileEpoch; /* Value of iPtr->compileEpoch when this
+ size_t compileEpoch; /* Value of iPtr->compileEpoch when this
* ByteCode was compiled. Used to invalidate
* code when, e.g., commands with compile
* procs are redefined. */
@@ -429,7 +429,7 @@ typedef struct ByteCode {
* ByteCode was compiled. Used to invalidate
* code when new namespace resolution rules
* are put into effect. */
- int refCount; /* Reference count: set 1 when created plus 1
+ size_t refCount; /* Reference count: set 1 when created plus 1
* for each execution of the code currently
* active. This structure can be freed when
* refCount becomes zero. */
diff --git a/generic/tclDecls.h b/generic/tclDecls.h
index 3e403da..8fcd413 100644
--- a/generic/tclDecls.h
+++ b/generic/tclDecls.h
@@ -957,7 +957,7 @@ EXTERN void Tcl_ThreadAlert(Tcl_ThreadId threadId);
EXTERN void Tcl_ThreadQueueEvent(Tcl_ThreadId threadId,
Tcl_Event *evPtr, Tcl_QueuePosition position);
/* 320 */
-EXTERN Tcl_UniChar Tcl_UniCharAtIndex(const char *src, int index);
+EXTERN Tcl_UniChar Tcl_UniCharAtIndex(const char *src, size_t index);
/* 321 */
EXTERN Tcl_UniChar Tcl_UniCharToLower(int ch);
/* 322 */
@@ -967,7 +967,7 @@ EXTERN Tcl_UniChar Tcl_UniCharToUpper(int ch);
/* 324 */
EXTERN int Tcl_UniCharToUtf(int ch, char *buf);
/* 325 */
-EXTERN CONST84_RETURN char * Tcl_UtfAtIndex(const char *src, int index);
+EXTERN CONST84_RETURN char * Tcl_UtfAtIndex(const char *src, size_t index);
/* 326 */
EXTERN int Tcl_UtfCharComplete(const char *src, size_t length);
/* 327 */
@@ -2182,12 +2182,12 @@ typedef struct TclStubs {
Tcl_Obj * (*tcl_SetVar2Ex) (Tcl_Interp *interp, const char *part1, const char *part2, Tcl_Obj *newValuePtr, int flags); /* 317 */
void (*tcl_ThreadAlert) (Tcl_ThreadId threadId); /* 318 */
void (*tcl_ThreadQueueEvent) (Tcl_ThreadId threadId, Tcl_Event *evPtr, Tcl_QueuePosition position); /* 319 */
- Tcl_UniChar (*tcl_UniCharAtIndex) (const char *src, int index); /* 320 */
+ Tcl_UniChar (*tcl_UniCharAtIndex) (const char *src, size_t index); /* 320 */
Tcl_UniChar (*tcl_UniCharToLower) (int ch); /* 321 */
Tcl_UniChar (*tcl_UniCharToTitle) (int ch); /* 322 */
Tcl_UniChar (*tcl_UniCharToUpper) (int ch); /* 323 */
int (*tcl_UniCharToUtf) (int ch, char *buf); /* 324 */
- CONST84_RETURN char * (*tcl_UtfAtIndex) (const char *src, int index); /* 325 */
+ CONST84_RETURN char * (*tcl_UtfAtIndex) (const char *src, size_t index); /* 325 */
int (*tcl_UtfCharComplete) (const char *src, size_t length); /* 326 */
int (*tcl_UtfBackslash) (const char *src, int *readPtr, char *dst); /* 327 */
CONST84_RETURN char * (*tcl_UtfFindFirst) (const char *src, int ch); /* 328 */
diff --git a/generic/tclHash.c b/generic/tclHash.c
index 3055eed..3ea9f66 100644
--- a/generic/tclHash.c
+++ b/generic/tclHash.c
@@ -35,7 +35,7 @@
*/
#define RANDOM_INDEX(tablePtr, i) \
- ((((i)*1103515245L) >> (tablePtr)->downShift) & (tablePtr)->mask1)
+ ((((i)*(size_t)1103515245) >> (tablePtr)->downShift) & (tablePtr)->mask)
/*
* Prototypes for the array hash key methods.
@@ -169,11 +169,11 @@ Tcl_InitCustomHashTable(
tablePtr->buckets = tablePtr->staticBuckets;
tablePtr->staticBuckets[0] = tablePtr->staticBuckets[1] = 0;
tablePtr->staticBuckets[2] = tablePtr->staticBuckets[3] = 0;
- tablePtr->numBuckets1 = TCL_SMALL_HASH_TABLE;
+ tablePtr->numBuckets = TCL_SMALL_HASH_TABLE;
tablePtr->numEntries = 0;
- tablePtr->rebuildSize1 = TCL_SMALL_HASH_TABLE*REBUILD_MULTIPLIER;
+ tablePtr->rebuildSize = TCL_SMALL_HASH_TABLE*REBUILD_MULTIPLIER;
tablePtr->downShift = 28;
- tablePtr->mask1 = 3;
+ tablePtr->mask = 3;
tablePtr->keyType = keyType;
tablePtr->findProc = FindHashEntry;
tablePtr->createProc = CreateHashEntry;
@@ -291,7 +291,7 @@ CreateHashEntry(
if (typePtr->flags & TCL_HASH_KEY_RANDOMIZE_HASH) {
index = RANDOM_INDEX(tablePtr, hash);
} else {
- index = hash & tablePtr->mask1;
+ index = hash & tablePtr->mask;
}
} else {
hash = (size_t) key;
@@ -360,7 +360,7 @@ CreateHashEntry(
* buckets.
*/
- if (tablePtr->numEntries >= tablePtr->rebuildSize1) {
+ if (tablePtr->numEntries >= tablePtr->rebuildSize) {
RebuildTable(tablePtr);
}
return hPtr;
@@ -411,7 +411,7 @@ Tcl_DeleteHashEntry(
|| typePtr->flags & TCL_HASH_KEY_RANDOMIZE_HASH) {
index = RANDOM_INDEX(tablePtr, entryPtr->hash);
} else {
- index = entryPtr->hash & tablePtr->mask1;
+ index = entryPtr->hash & tablePtr->mask;
}
bucketPtr = &tablePtr->buckets[index];
@@ -478,7 +478,7 @@ Tcl_DeleteHashTable(
* Free up all the entries in the table.
*/
- for (i = 0; i < tablePtr->numBuckets1; i++) {
+ for (i = 0; i < tablePtr->numBuckets; i++) {
hPtr = tablePtr->buckets[i];
while (hPtr != NULL) {
nextPtr = hPtr->nextPtr;
@@ -539,7 +539,7 @@ Tcl_FirstHashEntry(
* through the table. */
{
searchPtr->tablePtr = tablePtr;
- searchPtr->nextIndex1 = 0;
+ searchPtr->nextIndex = 0;
searchPtr->nextEntryPtr = NULL;
return Tcl_NextHashEntry(searchPtr);
}
@@ -575,12 +575,12 @@ Tcl_NextHashEntry(
Tcl_HashTable *tablePtr = searchPtr->tablePtr;
while (searchPtr->nextEntryPtr == NULL) {
- if (searchPtr->nextIndex1 >= tablePtr->numBuckets1) {
+ if (searchPtr->nextIndex >= tablePtr->numBuckets) {
return NULL;
}
searchPtr->nextEntryPtr =
- tablePtr->buckets[searchPtr->nextIndex1];
- searchPtr->nextIndex1++;
+ tablePtr->buckets[searchPtr->nextIndex];
+ searchPtr->nextIndex++;
}
hPtr = searchPtr->nextEntryPtr;
searchPtr->nextEntryPtr = hPtr->nextPtr;
@@ -624,7 +624,7 @@ Tcl_HashStats(
}
overflow = 0;
average = 0.0;
- for (i = 0; i < tablePtr->numBuckets1; i++) {
+ for (i = 0; i < tablePtr->numBuckets; i++) {
j = 0;
for (hPtr = tablePtr->buckets[i]; hPtr != NULL; hPtr = hPtr->nextPtr) {
j++;
@@ -646,7 +646,7 @@ Tcl_HashStats(
result = ckalloc((NUM_COUNTERS * 60) + 300);
sprintf(result, "%" TCL_LL_MODIFIER "d entries in table, %" TCL_LL_MODIFIER "d buckets\n",
- (Tcl_WideInt)tablePtr->numEntries, (Tcl_WideInt)tablePtr->numBuckets1);
+ (Tcl_WideInt)tablePtr->numEntries, (Tcl_WideInt)tablePtr->numBuckets);
p = result + strlen(result);
for (i = 0; i < NUM_COUNTERS; i++) {
sprintf(p, "number of buckets with %d entries: %" TCL_LL_MODIFIER "d\n",
@@ -984,7 +984,7 @@ static void
RebuildTable(
register Tcl_HashTable *tablePtr) /* Table to enlarge. */
{
- size_t count, index, oldSize = tablePtr->numBuckets1;
+ size_t count, index, oldSize = tablePtr->numBuckets;
Tcl_HashEntry **oldBuckets = tablePtr->buckets;
register Tcl_HashEntry **oldChainPtr, **newChainPtr;
register Tcl_HashEntry *hPtr;
@@ -992,7 +992,7 @@ RebuildTable(
/* Avoid outgrowing capability of the memory allocators */
if (oldSize > UINT_MAX / (4 * sizeof(Tcl_HashEntry *))) {
- tablePtr->rebuildSize1 = INT_MAX;
+ tablePtr->rebuildSize = INT_MAX;
return;
}
@@ -1012,21 +1012,21 @@ RebuildTable(
* constants for new array size.
*/
- tablePtr->numBuckets1 *= 4;
+ tablePtr->numBuckets *= 4;
if (typePtr->flags & TCL_HASH_KEY_SYSTEM_HASH) {
tablePtr->buckets = (Tcl_HashEntry **) TclpSysAlloc(
- tablePtr->numBuckets1 * sizeof(Tcl_HashEntry *));
+ tablePtr->numBuckets * sizeof(Tcl_HashEntry *));
} else {
tablePtr->buckets =
- ckalloc(tablePtr->numBuckets1 * sizeof(Tcl_HashEntry *));
+ ckalloc(tablePtr->numBuckets * sizeof(Tcl_HashEntry *));
}
- for (count = tablePtr->numBuckets1, newChainPtr = tablePtr->buckets;
+ for (count = tablePtr->numBuckets, newChainPtr = tablePtr->buckets;
count > 0; count--, newChainPtr++) {
*newChainPtr = NULL;
}
- tablePtr->rebuildSize1 *= 4;
+ tablePtr->rebuildSize *= 4;
tablePtr->downShift -= 2;
- tablePtr->mask1 = (tablePtr->mask1 << 2) + 3;
+ tablePtr->mask = (tablePtr->mask << 2) + 3;
/*
* Rehash all of the existing entries into the new bucket array.
@@ -1039,7 +1039,7 @@ RebuildTable(
|| typePtr->flags & TCL_HASH_KEY_RANDOMIZE_HASH) {
index = RANDOM_INDEX(tablePtr, hPtr->hash);
} else {
- index = hPtr->hash & tablePtr->mask1;
+ index = hPtr->hash & tablePtr->mask;
}
hPtr->nextPtr = tablePtr->buckets[index];
tablePtr->buckets[index] = hPtr;
diff --git a/generic/tclInt.h b/generic/tclInt.h
index ae83ca5..55d8c14 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -266,11 +266,11 @@ typedef struct Namespace {
* NULL, there are no children. */
#endif
size_t nsId; /* Unique id for the namespace. */
- Tcl_Interp *interp; /* The interpreter containing this
+ Tcl_Interp *interp; /* The interpreter containing this
* namespace. */
int flags; /* OR-ed combination of the namespace status
* flags NS_DYING and NS_DEAD listed below. */
- int activationCount; /* Number of "activations" or active call
+ size_t activationCount; /* Number of "activations" or active call
* frames for this namespace that are on the
* Tcl call stack. The namespace won't be
* freed until activationCount becomes zero. */
@@ -1516,7 +1516,7 @@ typedef struct LiteralTable {
* table. */
size_t rebuildSize; /* Enlarge table when numEntries gets to be
* this large. */
- TCL_HASH_TYPE mask; /* Mask value used in hashing function. */
+ size_t mask; /* Mask value used in hashing function. */
} LiteralTable;
/*
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c
index 054fd72..2ce89bc 100644
--- a/generic/tclNamesp.c
+++ b/generic/tclNamesp.c
@@ -415,9 +415,8 @@ Tcl_PopCallFrame(
*/
nsPtr = framePtr->nsPtr;
- nsPtr->activationCount--;
- if ((nsPtr->flags & NS_DYING)
- && (nsPtr->activationCount - (nsPtr == iPtr->globalNsPtr) == 0)) {
+ if ((--nsPtr->activationCount <= (nsPtr == iPtr->globalNsPtr))
+ && (nsPtr->flags & NS_DYING)) {
Tcl_DeleteNamespace((Tcl_Namespace *) nsPtr);
}
framePtr->nsPtr = NULL;
@@ -1003,7 +1002,7 @@ Tcl_DeleteNamespace(
* refCount reaches 0.
*/
- if (nsPtr->activationCount - (nsPtr == globalNsPtr) > 0) {
+ if (nsPtr->activationCount > (nsPtr == globalNsPtr)) {
nsPtr->flags |= NS_DYING;
if (nsPtr->parentPtr != NULL) {
entryPtr = Tcl_FindHashEntry(
diff --git a/generic/tclStringRep.h b/generic/tclStringRep.h
index b4125c1..0ee1a14 100644
--- a/generic/tclStringRep.h
+++ b/generic/tclStringRep.h
@@ -48,7 +48,7 @@
typedef struct {
size_t numChars; /* The number of chars in the string. (size_t)-1 means
- * this value has not been calculated. >= 0
+ * this value has not been calculated. Any other
* means that there is a valid Unicode rep, or
* that the number of UTF bytes == the number
* of chars. */
@@ -65,14 +65,14 @@ typedef struct {
} String;
#define STRING_MAXCHARS \
- (int)(((size_t)UINT_MAX - sizeof(String))/sizeof(Tcl_UniChar))
+ ((UINT_MAX - sizeof(String))/sizeof(Tcl_UniChar))
#define STRING_SIZE(numChars) \
(sizeof(String) + ((numChars) * sizeof(Tcl_UniChar)))
#define stringCheckLimits(numChars) \
do { \
- if ((numChars) < 0 || (numChars) > STRING_MAXCHARS) { \
- Tcl_Panic("max length for a Tcl unicode value (%d chars) exceeded", \
- (int)STRING_MAXCHARS); \
+ if ((size_t)(numChars) > STRING_MAXCHARS) { \
+ Tcl_Panic("max length for a Tcl unicode value (%" TCL_LL_MODIFIER "d chars) exceeded", \
+ (Tcl_WideInt)STRING_MAXCHARS); \
} \
} while (0)
#define stringAttemptAlloc(numChars) \
diff --git a/generic/tclUtf.c b/generic/tclUtf.c
index b0912ee..5f87ffa 100644
--- a/generic/tclUtf.c
+++ b/generic/tclUtf.c
@@ -701,12 +701,11 @@ Tcl_UtfPrev(
Tcl_UniChar
Tcl_UniCharAtIndex(
register const char *src, /* The UTF-8 string to dereference. */
- register int index) /* The position of the desired character. */
+ register size_t index) /* The position of the desired character. */
{
Tcl_UniChar ch = 0;
- while (index >= 0) {
- index--;
+ while (index--) {
src += TclUtfToUniChar(src, &ch);
}
return ch;
@@ -732,13 +731,14 @@ Tcl_UniCharAtIndex(
const char *
Tcl_UtfAtIndex(
register const char *src, /* The UTF-8 string. */
- register int index) /* The position of the desired character. */
+ register size_t index) /* The position of the desired character. */
{
Tcl_UniChar ch = 0;
- while (index > 0) {
- index--;
- src += TclUtfToUniChar(src, &ch);
+ if (index != (size_t)-1) {
+ while (index--) {
+ src += TclUtfToUniChar(src, &ch);
+ }
}
return src;
}