diff options
-rw-r--r-- | generic/tcl.h | 8 | ||||
-rw-r--r-- | generic/tclAssembly.c | 2 | ||||
-rw-r--r-- | generic/tclBasic.c | 2 | ||||
-rw-r--r-- | generic/tclCompCmds.c | 6 | ||||
-rw-r--r-- | generic/tclCompCmdsGR.c | 4 | ||||
-rw-r--r-- | generic/tclCompExpr.c | 12 | ||||
-rw-r--r-- | generic/tclCompile.c | 2 | ||||
-rw-r--r-- | generic/tclInt.h | 6 | ||||
-rw-r--r-- | generic/tclParse.c | 32 | ||||
-rw-r--r-- | generic/tclPathObj.c | 15 | ||||
-rw-r--r-- | generic/tclProc.c | 5 | ||||
-rw-r--r-- | generic/tclStringObj.c | 14 | ||||
-rw-r--r-- | generic/tclUtil.c | 33 | ||||
-rw-r--r-- | unix/tclUnixFCmd.c | 12 |
14 files changed, 70 insertions, 83 deletions
diff --git a/generic/tcl.h b/generic/tcl.h index 3f96d08..aa06037 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -797,9 +797,9 @@ typedef struct Tcl_CmdInfo { typedef struct Tcl_DString { char *string; /* Points to beginning of string: either * staticSpace below or a malloced array. */ - int length; /* Number of non-NULL characters in the + size_t length; /* Number of non-NULL characters in the * string. */ - int spaceAvl; /* Total number of bytes available for the + size_t spaceAvl; /* Total number of bytes available for the * string and its terminating NULL char. */ char staticSpace[TCL_DSTRING_STATIC_SIZE]; /* Space to use in common case where string is @@ -1516,7 +1516,7 @@ typedef struct Tcl_FSVersion_ *Tcl_FSVersion; typedef struct Tcl_Filesystem { const char *typeName; /* The name of the filesystem. */ - int structureLength; /* Length of this structure, so future binary + size_t structureLength; /* Length of this structure, so future binary * compatibility can be assured. */ Tcl_FSVersion version; /* Version of the filesystem type. */ Tcl_FSPathInFilesystemProc *pathInFilesystemProc; @@ -1821,7 +1821,7 @@ typedef struct Tcl_Token { typedef struct Tcl_Parse { const char *commentStart; /* Pointer to # that begins the first of one * or more comments preceding the command. */ - int commentSize; /* Number of bytes in comments (up through + size_t commentSize; /* Number of bytes in comments (up through * newline character that terminates the last * comment). If there were no comments, this * field is 0. */ diff --git a/generic/tclAssembly.c b/generic/tclAssembly.c index 475799b..688ed2d 100644 --- a/generic/tclAssembly.c +++ b/generic/tclAssembly.c @@ -2259,7 +2259,7 @@ GetListIndexOperand( * when list size limits grow. */ status = TclIndexEncode(interp, value, - TCL_INDEX_BEFORE,INT_MAX, result); + TCL_INDEX_BEFORE,TCL_INDEX_BEFORE, result); Tcl_DecrRefCount(value); *tokenPtrPtr = TokenAfter(tokenPtr); diff --git a/generic/tclBasic.c b/generic/tclBasic.c index cd0d084..b9f9797 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -5247,7 +5247,7 @@ TclArgumentBCEnter( void *codePtr, CmdFrame *cfPtr, int cmd, - int pc) + size_t pc) { ExtCmdLoc *eclPtr; int word; diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c index d9f0258..4c08034 100644 --- a/generic/tclCompCmds.c +++ b/generic/tclCompCmds.c @@ -2759,11 +2759,11 @@ CompileEachloopCmd( for (j = 0; j < numVars; j++) { Tcl_Obj *varNameObj; const char *bytes; - int numBytes, varIndex; + int varIndex; Tcl_ListObjIndex(NULL, varListObj, j, &varNameObj); - bytes = TclGetStringFromObj(varNameObj, &numBytes); - varIndex = LocalScalar(bytes, numBytes, envPtr); + bytes = TclGetString(varNameObj); + varIndex = LocalScalar(bytes, varNameObj->length, envPtr); if (varIndex < 0) { code = TCL_ERROR; goto done; diff --git a/generic/tclCompCmdsGR.c b/generic/tclCompCmdsGR.c index 969f4aa..0147465 100644 --- a/generic/tclCompCmdsGR.c +++ b/generic/tclCompCmdsGR.c @@ -2686,8 +2686,8 @@ TclCompileSyntaxError( CompileEnv *envPtr) { Tcl_Obj *msg = Tcl_GetObjResult(interp); - int numBytes; - const char *bytes = TclGetStringFromObj(msg, &numBytes); + const char *bytes = TclGetString(msg); + size_t numBytes = msg->length; TclErrorStackResetIf(interp, bytes, numBytes); TclEmitPush(TclRegisterLiteral(envPtr, bytes, numBytes, 0), envPtr); diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c index b894863..0b50d04 100644 --- a/generic/tclCompExpr.c +++ b/generic/tclCompExpr.c @@ -501,13 +501,13 @@ static void CompileExprTree(Tcl_Interp *interp, OpNode *nodes, int index, Tcl_Obj *const **litObjvPtr, Tcl_Obj *const *funcObjv, Tcl_Token *tokenPtr, CompileEnv *envPtr, int optimize); -static void ConvertTreeToTokens(const char *start, int numBytes, +static void ConvertTreeToTokens(const char *start, size_t numBytes, OpNode *nodes, Tcl_Token *tokenPtr, Tcl_Parse *parsePtr); static int ExecConstantExprTree(Tcl_Interp *interp, OpNode *nodes, int index, Tcl_Obj * const **litObjvPtr); static int ParseExpr(Tcl_Interp *interp, const char *start, - int numBytes, OpNode **opTreePtr, + size_t numBytes, OpNode **opTreePtr, Tcl_Obj *litList, Tcl_Obj *funcList, Tcl_Parse *parsePtr, int parseOnly); static size_t ParseLexeme(const char *start, size_t numBytes, @@ -548,7 +548,7 @@ static int ParseExpr( Tcl_Interp *interp, /* Used for error reporting. */ const char *start, /* Start of source string to parse. */ - int numBytes, /* Number of bytes in string. */ + size_t numBytes, /* Number of bytes in string. */ OpNode **opTreePtr, /* Points to space where a pointer to the * allocated OpNode tree should go. */ Tcl_Obj *litList, /* List to append literals to. */ @@ -1434,8 +1434,8 @@ ParseExpr( numBytes = parsePtr->end - parsePtr->string; Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf( "\n (parsing expression \"%.*s%s\")", - (numBytes < (int)limit) ? numBytes : (int)limit - 3, - parsePtr->string, (numBytes < (int)limit) ? "" : "...")); + (numBytes < limit) ? (int)numBytes : (int)limit - 3, + parsePtr->string, (numBytes < limit) ? "" : "...")); if (errCode) { Tcl_SetErrorCode(interp, "TCL", "PARSE", "EXPR", errCode, subErrCode, NULL); @@ -1471,7 +1471,7 @@ ParseExpr( static void ConvertTreeToTokens( const char *start, - int numBytes, + size_t numBytes, OpNode *nodes, Tcl_Token *tokenPtr, Tcl_Parse *parsePtr) diff --git a/generic/tclCompile.c b/generic/tclCompile.c index a73060c..4683aa0 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -1303,7 +1303,7 @@ CompileSubstObj( if (objPtr->typePtr != &substCodeType) { CompileEnv compEnv; const char *bytes = TclGetString(objPtr); - int numBytes = objPtr->length; + size_t numBytes = objPtr->length; /* TODO: Check for more TIP 280 */ TclInitCompileEnv(interp, &compEnv, bytes, numBytes, NULL, 0); diff --git a/generic/tclInt.h b/generic/tclInt.h index af4d36d..303cff3 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -1244,7 +1244,7 @@ typedef struct CFWord { typedef struct CFWordBC { CmdFrame *framePtr; /* CmdFrame to access. */ - int pc; /* Instruction pointer of a command in + size_t pc; /* Instruction pointer of a command in * ExtCmdLoc.loc[.] */ int word; /* Index of word in * ExtCmdLoc.loc[cmd]->line[.] */ @@ -2850,7 +2850,7 @@ MODULE_SCOPE void TclArgumentRelease(Tcl_Interp *interp, Tcl_Obj *objv[], int objc); MODULE_SCOPE void TclArgumentBCEnter(Tcl_Interp *interp, Tcl_Obj *objv[], int objc, - void *codePtr, CmdFrame *cfPtr, int cmd, int pc); + void *codePtr, CmdFrame *cfPtr, int cmd, size_t pc); MODULE_SCOPE void TclArgumentBCRelease(Tcl_Interp *interp, CmdFrame *cfPtr); MODULE_SCOPE void TclArgumentGet(Tcl_Interp *interp, Tcl_Obj *obj, @@ -3054,7 +3054,7 @@ MODULE_SCOPE int TclParseNumber(Tcl_Interp *interp, Tcl_Obj *objPtr, int numBytes, const char **endPtrPtr, int flags); MODULE_SCOPE void TclParseInit(Tcl_Interp *interp, const char *string, size_t numBytes, Tcl_Parse *parsePtr); -MODULE_SCOPE int TclParseAllWhiteSpace(const char *src, size_t numBytes); +MODULE_SCOPE size_t TclParseAllWhiteSpace(const char *src, size_t numBytes); MODULE_SCOPE int TclProcessReturn(Tcl_Interp *interp, int code, int level, Tcl_Obj *returnOpts); MODULE_SCOPE int TclpObjLstat(Tcl_Obj *pathPtr, Tcl_StatBuf *buf); diff --git a/generic/tclParse.c b/generic/tclParse.c index 8d29415..dc23f20 100644 --- a/generic/tclParse.c +++ b/generic/tclParse.c @@ -160,14 +160,14 @@ const char tclCharTypeTable[] = { * Prototypes for local functions defined in this file: */ -static inline int CommandComplete(const char *script, int numBytes); -static int ParseComment(const char *src, int numBytes, +static inline int CommandComplete(const char *script, size_t numBytes); +static size_t ParseComment(const char *src, size_t numBytes, Tcl_Parse *parsePtr); -static int ParseTokens(const char *src, int numBytes, int mask, +static int ParseTokens(const char *src, size_t numBytes, int mask, int flags, Tcl_Parse *parsePtr); -static int ParseWhiteSpace(const char *src, int numBytes, +static size_t ParseWhiteSpace(const char *src, size_t numBytes, int *incompletePtr, char *typePtr); -static int ParseAllWhiteSpace(const char *src, int numBytes, +static size_t ParseAllWhiteSpace(const char *src, size_t numBytes, int *incompletePtr); /* @@ -659,10 +659,10 @@ TclIsBareword( *---------------------------------------------------------------------- */ -static int +static size_t ParseWhiteSpace( const char *src, /* First character to parse. */ - register int numBytes, /* Max number of bytes to scan. */ + size_t numBytes, /* Max number of bytes to scan. */ int *incompletePtr, /* Set this boolean memory to true if parsing * indicates an incomplete command. */ char *typePtr) /* Points to location to store character type @@ -713,17 +713,17 @@ ParseWhiteSpace( *---------------------------------------------------------------------- */ -static int +static size_t ParseAllWhiteSpace( const char *src, /* First character to parse. */ - int numBytes, /* Max number of byes to scan */ + size_t numBytes, /* Max number of byes to scan */ int *incompletePtr) /* Set true if parse is incomplete. */ { char type; const char *p = src; do { - int scanned = ParseWhiteSpace(p, numBytes, incompletePtr, &type); + size_t scanned = ParseWhiteSpace(p, numBytes, incompletePtr, &type); p += scanned; numBytes -= scanned; @@ -731,7 +731,7 @@ ParseAllWhiteSpace( return (p-src); } -int +size_t TclParseAllWhiteSpace( const char *src, /* First character to parse. */ size_t numBytes) /* Max number of byes to scan */ @@ -1006,10 +1006,10 @@ TclParseBackslash( *---------------------------------------------------------------------- */ -static int +static size_t ParseComment( const char *src, /* First character to parse. */ - register int numBytes, /* Max number of bytes to scan. */ + size_t numBytes, /* Max number of bytes to scan. */ Tcl_Parse *parsePtr) /* Information about parse in progress. * Updated if parsing indicates an incomplete * command. */ @@ -1018,7 +1018,7 @@ ParseComment( int incomplete = parsePtr->incomplete; while (numBytes) { - int scanned = ParseAllWhiteSpace(p, numBytes, &incomplete); + size_t scanned = ParseAllWhiteSpace(p, numBytes, &incomplete); p += scanned; numBytes -= scanned; @@ -1082,7 +1082,7 @@ ParseComment( static int ParseTokens( register const char *src, /* First character to parse. */ - register int numBytes, /* Max number of bytes to scan. */ + size_t numBytes, /* Max number of bytes to scan. */ int mask, /* Specifies when to stop parsing. The parse * stops at the first unquoted character whose * CHAR_TYPE contains any of the bits in @@ -2431,7 +2431,7 @@ TclSubstTokens( static inline int CommandComplete( const char *script, /* Script to check. */ - int numBytes) /* Number of bytes in script. */ + size_t numBytes) /* Number of bytes in script. */ { Tcl_Parse parse; const char *p, *end; diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c index 7fa4198..44d0442 100644 --- a/generic/tclPathObj.c +++ b/generic/tclPathObj.c @@ -578,9 +578,8 @@ TclPathPart( * the standardPath code. */ - int numBytes; - const char *rest = - TclGetStringFromObj(fsPathPtr->normPathPtr, &numBytes); + const char *rest = TclGetString(fsPathPtr->normPathPtr); + size_t numBytes = fsPathPtr->normPathPtr->length; if (strchr(rest, '/') != NULL) { goto standardPath; @@ -616,9 +615,8 @@ TclPathPart( * we don't, and instead just use the standardPath code. */ - int numBytes; - const char *rest = - TclGetStringFromObj(fsPathPtr->normPathPtr, &numBytes); + const char *rest = TclGetString(fsPathPtr->normPathPtr); + size_t numBytes = fsPathPtr->normPathPtr->length; if (strchr(rest, '/') != NULL) { goto standardPath; @@ -1379,7 +1377,6 @@ AppendPath( Tcl_Obj *head, Tcl_Obj *tail) { - int numBytes; const char *bytes; Tcl_Obj *copy = Tcl_DuplicateObj(head); @@ -1391,8 +1388,8 @@ AppendPath( * intrep produce the same results; that is, bugward compatibility. If * we need to fix that bug here, it needs fixing in TclJoinPath() too. */ - bytes = TclGetStringFromObj(tail, &numBytes); - if (numBytes == 0) { + bytes = TclGetString(tail); + if (tail->length == 0) { Tcl_AppendToObj(copy, "/", 1); } else { TclpNativeJoinPath(copy, bytes); diff --git a/generic/tclProc.c b/generic/tclProc.c index 03a2880..f48ed41 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -305,7 +305,7 @@ Tcl_ProcObjCmd( } if ((procArgs[0] == 'a') && (strncmp(procArgs, "args", 4) == 0)) { - int numBytes; + size_t numBytes; procArgs +=4; while (*procArgs != '\0') { @@ -319,7 +319,8 @@ Tcl_ProcObjCmd( * The argument list is just "args"; check the body */ - procBody = TclGetStringFromObj(objv[3], &numBytes); + procBody = TclGetString(objv[3]); + numBytes = objv[3]->length; if (TclParseAllWhiteSpace(procBody, numBytes) < numBytes) { goto done; } diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 1e84ce2..786a0be 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -3086,7 +3086,7 @@ TclStringCat( first = last = objc - oc - 1; if (oc && (length == 0)) { - int numBytes; + size_t numBytes; /* assert ( pendingPtr != NULL ) */ @@ -3098,7 +3098,8 @@ TclStringCat( do { Tcl_Obj *objPtr = *ov++; - Tcl_GetStringFromObj(objPtr, &numBytes); /* PANIC? */ + Tcl_GetString(objPtr); /* PANIC? */ + numBytes = objPtr->length; } while (--oc && numBytes == 0 && pendingPtr->bytes == NULL); if (numBytes) { @@ -3111,7 +3112,7 @@ TclStringCat( if (numBytes) { first = last; } - } else if (numBytes > INT_MAX - length) { + } else if (numBytes + length > (size_t)INT_MAX) { goto overflow; } length += numBytes; @@ -3119,15 +3120,16 @@ TclStringCat( } while (oc && (length == 0)); while (oc) { - int numBytes; + size_t numBytes; Tcl_Obj *objPtr = *ov++; /* assert ( length > 0 && pendingPtr == NULL ) */ - Tcl_GetStringFromObj(objPtr, &numBytes); /* PANIC? */ + Tcl_GetString(objPtr); /* PANIC? */ + numBytes = objPtr->length; if (numBytes) { last = objc - oc; - if (numBytes > INT_MAX - length) { + if (numBytes + length > (size_t)INT_MAX) { goto overflow; } length += numBytes; diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 428149a..605595b 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -973,7 +973,7 @@ Tcl_ScanCountedElement( * Tcl_ConvertElement. */ { char flags = CONVERT_ANY; - int numBytes = TclScanElement(src, length, &flags); + size_t numBytes = TclScanElement(src, length, &flags); *flagPtr = flags; return numBytes; @@ -1025,7 +1025,7 @@ TclScanElement( int extra = 0; /* Count of number of extra bytes needed for * formatted element, assuming we use escape * sequences in formatting. */ - int bytesNeeded; /* Buffer length computed to complete the + size_t bytesNeeded; /* Buffer length computed to complete the * element formatting in the selected mode. */ #if COMPAT int preferEscape = 0; /* Use preferences to track whether to use */ @@ -1269,9 +1269,6 @@ TclScanElement( *flagPtr = CONVERT_NONE; overflowCheck: - if (bytesNeeded < 0) { - Tcl_Panic("TclScanElement: string length overflow"); - } return bytesNeeded; } @@ -1653,9 +1650,9 @@ UtfWellFormedEnd( static inline int TrimRight( const char *bytes, /* String to be trimmed... */ - int numBytes, /* ...and its length in bytes */ + size_t numBytes, /* ...and its length in bytes */ const char *trim, /* String of trim characters... */ - int numTrim) /* ...and its length in bytes */ + size_t numTrim) /* ...and its length in bytes */ { const char *p = bytes + numBytes; int pInc; @@ -1914,7 +1911,8 @@ Tcl_Concat( int argc, /* Number of strings to concatenate. */ const char *const *argv) /* Array of strings to concatenate. */ { - int i, needSpace = 0, bytesNeeded = 0; + int i, needSpace = 0; + size_t bytesNeeded = 0; char *result, *p; /* @@ -1933,24 +1931,13 @@ Tcl_Concat( for (i = 0; i < argc; i++) { bytesNeeded += strlen(argv[i]); - if (bytesNeeded < 0) { - Tcl_Panic("Tcl_Concat: max size of Tcl value exceeded"); - } - } - if (bytesNeeded + argc - 1 < 0) { - /* - * Panic test could be tighter, but not going to bother for this - * legacy routine. - */ - - Tcl_Panic("Tcl_Concat: max size of Tcl value exceeded"); } /* * All element bytes + (argc - 1) spaces + 1 terminating NULL. */ - result = ckalloc((unsigned) (bytesNeeded + argc)); + result = ckalloc(bytesNeeded + argc); for (p = result, i = 0; i < argc; i++) { size_t triml, trimr; @@ -2669,7 +2656,7 @@ Tcl_DStringAppend( * (size_t)-1, then append all of bytes, up to null * at end. */ { - int newSize; + size_t newSize; if (length == (size_t)-1) { length = strlen(bytes); @@ -2687,7 +2674,7 @@ Tcl_DStringAppend( if (dsPtr->string == dsPtr->staticSpace) { char *newString = ckalloc(dsPtr->spaceAvl); - memcpy(newString, dsPtr->string, (size_t) dsPtr->length); + memcpy(newString, dsPtr->string, dsPtr->length); dsPtr->string = newString; } else { int offset = -1; @@ -2773,7 +2760,7 @@ Tcl_DStringAppendElement( char *dst = dsPtr->string + dsPtr->length; int needSpace = TclNeedSpace(dsPtr->string, dst); char flags = needSpace ? TCL_DONT_QUOTE_HASH : 0; - int newSize = dsPtr->length + needSpace + size_t newSize = dsPtr->length + needSpace + TclScanElement(element, -1, &flags); /* diff --git a/unix/tclUnixFCmd.c b/unix/tclUnixFCmd.c index 548e96b..22a142a 100644 --- a/unix/tclUnixFCmd.c +++ b/unix/tclUnixFCmd.c @@ -554,7 +554,7 @@ TclUnixCopyFile( int dontCopyAtts) /* If flag set, don't copy attributes. */ { int srcFd, dstFd; - unsigned blockSize; /* Optimal I/O blocksize for filesystem */ + size_t blockSize; /* Optimal I/O blocksize for filesystem */ char *buffer; /* Data buffer for copy */ size_t nread; @@ -960,8 +960,8 @@ TraverseUnixTree( { Tcl_StatBuf statBuf; const char *source, *errfile; - int result, sourceLen; - int targetLen; + int result; + size_t targetLen, sourceLen; #ifndef HAVE_FTS int numProcessed = 0; Tcl_DirEntry *dirEntPtr; @@ -2054,7 +2054,7 @@ TclpObjNormalizePath( nativePath = Tcl_UtfToExternalDString(NULL, path,nextCheckpoint, &ds); if (Realpath(nativePath, normPath) != NULL) { - int newNormLen; + size_t newNormLen; wholeStringOk: newNormLen = strlen(normPath); @@ -2088,7 +2088,7 @@ TclpObjNormalizePath( */ Tcl_DStringFree(&ds); - Tcl_ExternalToUtfDString(NULL, normPath, (int) newNormLen, &ds); + Tcl_ExternalToUtfDString(NULL, normPath, newNormLen, &ds); if (path[nextCheckpoint] != '\0') { /* @@ -2290,7 +2290,7 @@ static WCHAR * winPathFromObj( Tcl_Obj *fileName) { - int size; + size_t size; const char *native = Tcl_FSGetNativePath(fileName); WCHAR *winPath; |