summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2018-01-31 12:18:58 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2018-01-31 12:18:58 (GMT)
commit66b69b8d36c7218cee80e94890e1e6fb9b27fcc2 (patch)
treeb78771f1522d0793b7a2f92659410cadf9bb42be
parent8a2f752e5139eb86c0d294c1c3222011fa7dde82 (diff)
downloadtcl-66b69b8d36c7218cee80e94890e1e6fb9b27fcc2.zip
tcl-66b69b8d36c7218cee80e94890e1e6fb9b27fcc2.tar.gz
tcl-66b69b8d36c7218cee80e94890e1e6fb9b27fcc2.tar.bz2
Change Tcl_Token definition (int -> size_t). Many related code-changes.
-rw-r--r--doc/ParseCmd.34
-rw-r--r--generic/tcl.h4
-rw-r--r--generic/tclAssembly.c2
-rw-r--r--generic/tclCmdMZ.c3
-rw-r--r--generic/tclCompCmds.c12
-rw-r--r--generic/tclCompCmdsGR.c8
-rw-r--r--generic/tclCompCmdsSZ.c10
-rw-r--r--generic/tclCompExpr.c10
-rw-r--r--generic/tclCompile.c6
-rw-r--r--generic/tclCompile.h2
-rw-r--r--generic/tclDictObj.c3
-rw-r--r--generic/tclInt.decls2
-rw-r--r--generic/tclInt.h4
-rw-r--r--generic/tclIntDecls.h4
-rw-r--r--generic/tclListObj.c3
-rw-r--r--generic/tclParse.c9
-rw-r--r--generic/tclUtf.c2
-rw-r--r--generic/tclUtil.c15
18 files changed, 57 insertions, 46 deletions
diff --git a/doc/ParseCmd.3 b/doc/ParseCmd.3
index 01b4065..41f43cb 100644
--- a/doc/ParseCmd.3
+++ b/doc/ParseCmd.3
@@ -208,8 +208,8 @@ typedef struct Tcl_Parse {
typedef struct Tcl_Token {
int \fItype\fR;
const char *\fIstart\fR;
- int \fIsize\fR;
- int \fInumComponents\fR;
+ size_t \fIsize\fR;
+ size_t \fInumComponents\fR;
} \fBTcl_Token\fR;
.CE
.PP
diff --git a/generic/tcl.h b/generic/tcl.h
index 7c07f5f..a11cb44 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -1716,8 +1716,8 @@ typedef struct Tcl_Token {
int type; /* Type of token, such as TCL_TOKEN_WORD; see
* below for valid types. */
const char *start; /* First character in token. */
- int size; /* Number of bytes in token. */
- int numComponents; /* If this token is composed of other tokens,
+ size_t size; /* Number of bytes in token. */
+ size_t numComponents; /* If this token is composed of other tokens,
* this field tells how many of them there are
* (including components of components, etc.).
* The component tokens immediately follow
diff --git a/generic/tclAssembly.c b/generic/tclAssembly.c
index 4c5ae68..60be03d 100644
--- a/generic/tclAssembly.c
+++ b/generic/tclAssembly.c
@@ -979,7 +979,7 @@ TclCompileAssembleCmd(
Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
"\n (\"%.*s\" body, line %d)",
- parsePtr->tokenPtr->size, parsePtr->tokenPtr->start,
+ (int)parsePtr->tokenPtr->size, parsePtr->tokenPtr->start,
Tcl_GetErrorLine(interp)));
envPtr->numCommands = numCommands;
envPtr->codeNext = envPtr->codeStart + offset;
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index d867172..5f46fee 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -1756,7 +1756,8 @@ StringIsCmd(
*/
const char *elemStart, *nextElem;
- int lenRemain, elemSize;
+ int lenRemain;
+ size_t elemSize;
register const char *p;
string1 = TclGetStringFromObj(objPtr, &length1);
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index b9bc228..3823364 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.c
@@ -1084,7 +1084,8 @@ TclCompileDictIncrCmd(
if (parsePtr->numWords == 4) {
const char *word;
- int numBytes, code;
+ size_t numBytes;
+ int code;
Tcl_Token *incrTokenPtr;
Tcl_Obj *intObj;
@@ -3346,7 +3347,7 @@ TclLocalScalarFromToken(
int
TclLocalScalar(
const char *bytes,
- int numBytes,
+ size_t numBytes,
CompileEnv *envPtr)
{
Tcl_Token token[2] = {{TCL_TOKEN_SIMPLE_WORD, NULL, 0, 1},
@@ -3397,9 +3398,10 @@ TclPushVarName(
{
register const char *p;
const char *name, *elName;
- register int i, n;
+ register size_t i, n;
Tcl_Token *elemTokenPtr = NULL;
- int nameChars, elNameChars, simpleVarName, localIndex;
+ size_t nameChars, elNameChars;
+ int simpleVarName, localIndex;
int elemTokenCount = 0, allocedTokens = 0, removedParen = 0;
/*
@@ -3471,7 +3473,7 @@ TclPushVarName(
}
}
if (simpleVarName) {
- int remainingChars;
+ size_t remainingChars;
/*
* Check the last token: if it is just ')', do not count it.
diff --git a/generic/tclCompCmdsGR.c b/generic/tclCompCmdsGR.c
index ff5495c..24553ba 100644
--- a/generic/tclCompCmdsGR.c
+++ b/generic/tclCompCmdsGR.c
@@ -196,7 +196,8 @@ TclCompileIfCmd(
* determined. */
Tcl_Token *tokenPtr, *testTokenPtr;
int jumpIndex = 0; /* Avoid compiler warning. */
- int jumpFalseDist, numWords, wordIdx, numBytes, j, code;
+ size_t numBytes;
+ int jumpFalseDist, numWords, wordIdx, j, code;
const char *word;
int realCond = 1; /* Set to 0 for static conditions:
* "if 0 {..}" */
@@ -514,7 +515,7 @@ TclCompileIncrCmd(
incrTokenPtr = TokenAfter(varTokenPtr);
if (incrTokenPtr->type == TCL_TOKEN_SIMPLE_WORD) {
const char *word = incrTokenPtr[1].start;
- int numBytes = incrTokenPtr[1].size;
+ size_t numBytes = incrTokenPtr[1].size;
int code;
Tcl_Obj *intObj = Tcl_NewStringObj(word, numBytes);
@@ -2204,7 +2205,8 @@ TclCompileRegexpCmd(
{
Tcl_Token *varTokenPtr; /* Pointer to the Tcl_Token representing the
* parse of the RE or string. */
- int i, len, nocase, exact, sawLast, simple;
+ size_t len;
+ int i, nocase, exact, sawLast, simple;
const char *str;
DefineLineInformation; /* TIP #280 */
diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c
index 25d10d6..d101899 100644
--- a/generic/tclCompCmdsSZ.c
+++ b/generic/tclCompCmdsSZ.c
@@ -789,7 +789,8 @@ TclCompileStringMatchCmd(
{
DefineLineInformation; /* TIP #280 */
Tcl_Token *tokenPtr;
- int i, length, exactMatch = 0, nocase = 0;
+ size_t length;
+ int i, exactMatch = 0, nocase = 0;
const char *str;
if (parsePtr->numWords < 3 || parsePtr->numWords > 4) {
@@ -1480,7 +1481,8 @@ TclSubstCompile(
*/
if (tokenPtr->numComponents > 1) {
- int i, foundCommand = 0;
+ size_t i;
+ int foundCommand = 0;
for (i=2 ; i<=tokenPtr->numComponents ; i++) {
if (tokenPtr[i].type == TCL_TOKEN_COMMAND) {
@@ -1753,7 +1755,7 @@ TclCompileSwitchCmd(
*/
for (; numWords>=3 ; tokenPtr=TokenAfter(tokenPtr),numWords--) {
- register unsigned size = tokenPtr[1].size;
+ register size_t size = tokenPtr[1].size;
register const char *chrs = tokenPtr[1].start;
/*
@@ -1844,7 +1846,7 @@ TclCompileSwitchCmd(
if (numWords == 1) {
const char *bytes;
- int maxLen, numBytes;
+ size_t maxLen, numBytes;
int bline; /* TIP #280: line of the pattern/action list,
* and start of list for when tracking the
* location. This list comes immediately after
diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c
index a77077c..b5802b0 100644
--- a/generic/tclCompExpr.c
+++ b/generic/tclCompExpr.c
@@ -571,7 +571,7 @@ ParseExpr(
* no need for array growth and
* reallocation. */
unsigned int nodesUsed = 0; /* Number of OpNodes filled. */
- int scanned = 0; /* Capture number of byte scanned by parsing
+ size_t scanned = 0; /* Capture number of byte scanned by parsing
* routines. */
int lastParsed; /* Stores info about what the lexeme parsed
* the previous pass through the parsing loop
@@ -615,7 +615,7 @@ ParseExpr(
* error in the expression. */
int insertMark = 0; /* A boolean controlling whether the "mark"
* should be inserted. */
- const int limit = 25; /* Portions of the error message are
+ const unsigned limit = 25; /* Portions of the error message are
* constructed out of substrings of the
* original expression. In order to keep the
* error message readable, we impose this
@@ -1406,7 +1406,7 @@ ParseExpr(
Tcl_AppendPrintfToObj(msg, "\nin expression \"%s%.*s%.*s%s%s%.*s%s\"",
((start - limit) < parsePtr->string) ? "" : "...",
((start - limit) < parsePtr->string)
- ? (int) (start - parsePtr->string) : limit - 3,
+ ? (int) (start - parsePtr->string) : (int)limit - 3,
((start - limit) < parsePtr->string)
? parsePtr->string : start - limit + 3,
(scanned < limit) ? scanned : limit - 3, start,
@@ -1434,8 +1434,8 @@ ParseExpr(
numBytes = parsePtr->end - parsePtr->string;
Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
"\n (parsing expression \"%.*s%s\")",
- (numBytes < limit) ? numBytes : limit - 3,
- parsePtr->string, (numBytes < limit) ? "" : "..."));
+ (numBytes < (int)limit) ? numBytes : (int)limit - 3,
+ parsePtr->string, (numBytes < (int)limit) ? "" : "..."));
if (errCode) {
Tcl_SetErrorCode(interp, "TCL", "PARSE", "EXPR", errCode,
subErrCode, NULL);
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index 52c1f11..f463820 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -2276,8 +2276,8 @@ TclCompileVarSubst(
CompileEnv *envPtr)
{
const char *p, *name = tokenPtr[1].start;
- int nameBytes = tokenPtr[1].size;
- int i, localVar, localVarName = 1;
+ size_t i, nameBytes = tokenPtr[1].size;
+ int localVar, localVarName = 1;
/*
* Determine how the variable name should be handled: if it contains any
@@ -2485,7 +2485,7 @@ TclCompileTokens(
default:
Tcl_Panic("Unexpected token type in TclCompileTokens: %d; %.*s",
- tokenPtr->type, tokenPtr->size, tokenPtr->start);
+ tokenPtr->type, (int)tokenPtr->size, tokenPtr->start);
}
}
diff --git a/generic/tclCompile.h b/generic/tclCompile.h
index 0730c08..1620c5d 100644
--- a/generic/tclCompile.h
+++ b/generic/tclCompile.h
@@ -1138,7 +1138,7 @@ MODULE_SCOPE void TclFinalizeLoopExceptionRange(CompileEnv *envPtr,
MODULE_SCOPE char * TclLiteralStats(LiteralTable *tablePtr);
MODULE_SCOPE int TclLog2(int value);
#endif
-MODULE_SCOPE int TclLocalScalar(const char *bytes, int numBytes,
+MODULE_SCOPE int TclLocalScalar(const char *bytes, size_t numBytes,
CompileEnv *envPtr);
MODULE_SCOPE int TclLocalScalarFromToken(Tcl_Token *tokenPtr,
CompileEnv *envPtr);
diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c
index 1943a07..910bf7f 100644
--- a/generic/tclDictObj.c
+++ b/generic/tclDictObj.c
@@ -642,7 +642,8 @@ SetDictFromAny(
while (nextElem < limit) {
Tcl_Obj *keyPtr, *valuePtr;
const char *elemStart;
- int elemSize, literal;
+ size_t elemSize;
+ int literal;
if (TclFindDictElement(interp, nextElem, (limit - nextElem),
&elemStart, &nextElem, &elemSize, &literal) != TCL_OK) {
diff --git a/generic/tclInt.decls b/generic/tclInt.decls
index 1776679..1b7411f 100644
--- a/generic/tclInt.decls
+++ b/generic/tclInt.decls
@@ -108,7 +108,7 @@ declare 16 {
declare 22 {
int TclFindElement(Tcl_Interp *interp, const char *listStr,
int listLength, const char **elementPtr, const char **nextPtr,
- int *sizePtr, int *bracePtr)
+ size_t *sizePtr, int *bracePtr)
}
declare 23 {
Proc *TclFindProc(Interp *iPtr, const char *procName)
diff --git a/generic/tclInt.h b/generic/tclInt.h
index dfd255a..54c5691 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -2875,7 +2875,7 @@ MODULE_SCOPE void TclDeleteNamespaceVars(Namespace *nsPtr);
MODULE_SCOPE int TclFindDictElement(Tcl_Interp *interp,
const char *dict, int dictLength,
const char **elementPtr, const char **nextPtr,
- int *sizePtr, int *literalPtr);
+ size_t *sizePtr, int *literalPtr);
/* TIP #280 - Modified token based evaluation, with line information. */
MODULE_SCOPE int TclEvalEx(Tcl_Interp *interp, const char *script,
int numBytes, int flags, int line,
@@ -3032,7 +3032,7 @@ MODULE_SCOPE int TclObjInvokeNamespace(Tcl_Interp *interp,
MODULE_SCOPE int TclObjUnsetVar2(Tcl_Interp *interp,
Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr, int flags);
MODULE_SCOPE int TclParseBackslash(const char *src,
- int numBytes, int *readPtr, char *dst);
+ int numBytes, size_t *readPtr, char *dst);
MODULE_SCOPE int TclParseHex(const char *src, int numBytes,
int *resultPtr);
MODULE_SCOPE int TclParseNumber(Tcl_Interp *interp, Tcl_Obj *objPtr,
diff --git a/generic/tclIntDecls.h b/generic/tclIntDecls.h
index 837ebae..5e65c9f 100644
--- a/generic/tclIntDecls.h
+++ b/generic/tclIntDecls.h
@@ -89,7 +89,7 @@ EXTERN void TclExprFloatError(Tcl_Interp *interp, double value);
EXTERN int TclFindElement(Tcl_Interp *interp,
const char *listStr, int listLength,
const char **elementPtr,
- const char **nextPtr, int *sizePtr,
+ const char **nextPtr, size_t *sizePtr,
int *bracePtr);
/* 23 */
EXTERN Proc * TclFindProc(Interp *iPtr, const char *procName);
@@ -605,7 +605,7 @@ typedef struct TclIntStubs {
void (*reserved19)(void);
void (*reserved20)(void);
void (*reserved21)(void);
- int (*tclFindElement) (Tcl_Interp *interp, const char *listStr, int listLength, const char **elementPtr, const char **nextPtr, int *sizePtr, int *bracePtr); /* 22 */
+ int (*tclFindElement) (Tcl_Interp *interp, const char *listStr, int listLength, const char **elementPtr, const char **nextPtr, size_t *sizePtr, int *bracePtr); /* 22 */
Proc * (*tclFindProc) (Interp *iPtr, const char *procName); /* 23 */
int (*tclFormatInt) (char *buffer, long n); /* 24 */
void (*tclFreePackageInfo) (Interp *iPtr); /* 25 */
diff --git a/generic/tclListObj.c b/generic/tclListObj.c
index 25e775c..2993241 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -1870,7 +1870,8 @@ SetListFromAny(
while (nextElem < limit) {
const char *elemStart;
- int elemSize, literal;
+ size_t elemSize;
+ int literal;
if (TCL_OK != TclFindElement(interp, nextElem, limit - nextElem,
&elemStart, &nextElem, &elemSize, &literal)) {
diff --git a/generic/tclParse.c b/generic/tclParse.c
index a2227f7..b012222a 100644
--- a/generic/tclParse.c
+++ b/generic/tclParse.c
@@ -385,7 +385,7 @@ Tcl_ParseCommand(
/* Haven't seen prefix already */
&& (1 == parsePtr->numTokens - expIdx)
/* Only one token */
- && (((1 == (size_t) expPtr->size)
+ && (((1 == expPtr->size)
/* Same length as prefix */
&& (expPtr->start[0] == '*')))
/* Is the prefix */
@@ -466,7 +466,7 @@ Tcl_ParseCommand(
*/
while (nextElem < listEnd) {
- int size;
+ size_t size;
code = TclFindElement(NULL, nextElem, listEnd - nextElem,
&elemStart, &nextElem, &size, &literal);
@@ -821,7 +821,7 @@ TclParseBackslash(
const char *src, /* Points to the backslash character of a a
* backslash sequence. */
int numBytes, /* Max number of bytes to scan. */
- int *readPtr, /* NULL, or points to storage where the number
+ size_t *readPtr, /* NULL, or points to storage where the number
* of bytes scanned should be written. */
char *dst) /* NULL, or points to buffer where the UTF-8
* encoding of the backslash sequence is to be
@@ -1649,7 +1649,8 @@ Tcl_ParseBraces(
{
Tcl_Token *tokenPtr;
register const char *src;
- int startIndex, level, length;
+ int startIndex, level;
+ size_t length;
if ((numBytes == 0) || (start == NULL)) {
return TCL_ERROR;
diff --git a/generic/tclUtf.c b/generic/tclUtf.c
index 6153a92..659d358 100644
--- a/generic/tclUtf.c
+++ b/generic/tclUtf.c
@@ -798,7 +798,7 @@ Tcl_UtfBackslash(
* backslash sequence. */
{
#define LINE_LENGTH 128
- int numRead;
+ size_t numRead;
int result;
result = TclParseBackslash(src, LINE_LENGTH, &numRead, dst);
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 0bc27fd..3c125d4 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -107,7 +107,7 @@ static void UpdateStringOfEndOffset(Tcl_Obj *objPtr);
static int FindElement(Tcl_Interp *interp, const char *string,
int stringLength, const char *typeStr,
const char *typeCode, const char **elementPtr,
- const char **nextPtr, int *sizePtr,
+ const char **nextPtr, size_t *sizePtr,
int *literalPtr);
/*
* The following is the Tcl object type definition for an object that
@@ -493,7 +493,7 @@ TclFindElement(
const char **nextPtr, /* Fill in with location of character just
* after all white space following end of
* argument (next arg or end of list). */
- int *sizePtr, /* If non-zero, fill in with size of
+ size_t *sizePtr, /* If non-zero, fill in with size of
* element. */
int *literalPtr) /* If non-zero, fill in with non-zero/zero to
* indicate that the substring of *sizePtr
@@ -522,7 +522,7 @@ TclFindDictElement(
const char **nextPtr, /* Fill in with location of character just
* after all white space following end of
* element (next arg or end of list). */
- int *sizePtr, /* If non-zero, fill in with size of
+ size_t *sizePtr, /* If non-zero, fill in with size of
* element. */
int *literalPtr) /* If non-zero, fill in with non-zero/zero to
* indicate that the substring of *sizePtr
@@ -554,7 +554,7 @@ FindElement(
const char **nextPtr, /* Fill in with location of character just
* after all white space following end of
* argument (next arg or end of list/dict). */
- int *sizePtr, /* If non-zero, fill in with size of
+ size_t *sizePtr, /* If non-zero, fill in with size of
* element. */
int *literalPtr) /* If non-zero, fill in with non-zero/zero to
* indicate that the substring of *sizePtr
@@ -569,7 +569,7 @@ FindElement(
int openBraces = 0; /* Brace nesting level during parse. */
int inQuotes = 0;
int size = 0; /* lint. */
- int numChars;
+ size_t numChars;
int literal = 1;
const char *p2;
@@ -792,7 +792,7 @@ TclCopyAndCollapse(
char c = *src;
if (c == '\\') {
- int numRead;
+ size_t numRead;
int backslashCount = TclParseBackslash(src, count, &numRead, dst);
dst += backslashCount;
@@ -851,7 +851,8 @@ Tcl_SplitList(
{
const char **argv, *end, *element;
char *p;
- int length, size, i, result, elSize;
+ int length, size, i, result;
+ size_t elSize;
/*
* Allocate enough space to work in. A (const char *) for each (possible)