diff options
| -rw-r--r-- | doc/Encoding.3 | 11 | ||||
| -rw-r--r-- | generic/tcl.h | 4 | ||||
| -rw-r--r-- | generic/tclAssembly.c | 2 | ||||
| -rw-r--r-- | generic/tclBasic.c | 27 | ||||
| -rw-r--r-- | generic/tclCmdMZ.c | 12 | ||||
| -rw-r--r-- | generic/tclCompCmdsSZ.c | 32 | ||||
| -rw-r--r-- | generic/tclCompile.c | 47 | ||||
| -rw-r--r-- | generic/tclCompile.h | 8 | ||||
| -rw-r--r-- | generic/tclEncoding.c | 5 | ||||
| -rw-r--r-- | generic/tclEnsemble.c | 10 | ||||
| -rw-r--r-- | generic/tclExecute.c | 22 | ||||
| -rw-r--r-- | generic/tclInt.h | 21 | ||||
| -rw-r--r-- | generic/tclOOMethod.c | 4 | ||||
| -rw-r--r-- | generic/tclObj.c | 16 | ||||
| -rw-r--r-- | generic/tclParse.c | 23 | ||||
| -rw-r--r-- | generic/tclProc.c | 6 | ||||
| -rw-r--r-- | generic/tclTestObj.c | 22 | ||||
| -rw-r--r-- | generic/tclZipfs.c | 13 | ||||
| -rw-r--r-- | tests/bigdata.test | 15 | ||||
| -rw-r--r-- | tests/encoding.test | 2 | ||||
| -rw-r--r-- | tests/listObj.test | 35 | ||||
| -rw-r--r-- | tests/utfext.test | 6 |
22 files changed, 208 insertions, 135 deletions
diff --git a/doc/Encoding.3 b/doc/Encoding.3 index 19e7fab..9fac9e9 100644 --- a/doc/Encoding.3 +++ b/doc/Encoding.3 @@ -218,17 +218,16 @@ used. The return value is a pointer to the value stored in the DString. be used to specify the profile to be used for the transform. The \fBTCL_ENCODING_START\fR and \fBTCL_ENCODING_END\fR bits in \fBflags\fR are ignored as the function assumes the entire source string to be decoded is passed -into the function. On success, the function returns \fBTCL_ERROR\fR with the -converted string stored in \fB*dstPtr\fR. For errors other than conversion -errors, such as invalid flags, the function returns \fBTCL_OK\fR with an error +into the function. On success, the function returns \fBTCL_OK\fR with the +converted string stored in \fB*dstPtr\fR. For errors \fIother than conversion +errors\fR, such as invalid flags, the function returns \fBTCL_ERROR\fR with an error message in \fBinterp\fR if it is not NULL. -.PP For conversion errors, \fBTcl_ExternalToUtfDStringEx\fR returns one of the \fBTCL_CONVERT_*\fR errors listed below for \fBTcl_ExternalToUtf\fR. When one of these conversion errors is returned, an error message is stored in \fBinterp\fR only if \fBerrorIdxPtr\fR is NULL. Otherwise, no error message -is stored as the function expects the caller is interested whatever is -decoded to that point and not treating this as an immediate error condition. +is stored as the function expects the caller is interested the decoded data +up to that point and not treating this as an immediate error condition. The index of the error location is stored in \fB*errorIdxPtr\fR. .PP The caller must call \fBTcl_DStringFree\fR to free up the \fB*dstPtr\fR resources diff --git a/generic/tcl.h b/generic/tcl.h index 41757ea..727f0c5 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -679,9 +679,9 @@ typedef struct Tcl_ObjType { # define TCL_OBJTYPE_V0 0, \ 0,0,0,0,0,0,0,0 /* Pre-Tcl 9 */ # define TCL_OBJTYPE_V1(a) offsetof(Tcl_ObjType, indexProc), \ - a,0,0,0,0,0,0,0 /* Tcl 9 Version 1 */ + a,INT2PTR(1),INT2PTR(1),INT2PTR(1),INT2PTR(1),INT2PTR(1),INT2PTR(1),INT2PTR(1) /* Tcl 9 Version 1 */ # define TCL_OBJTYPE_V2(a,b,c,d,e,f,g) offsetof(Tcl_ObjType, reservedProc), \ - a,b,c,d,e,f,g,0 /* Tcl 9 - AbstractLists */ + a,b,c,d,e,f,g,INT2PTR(1) /* Tcl 9 - AbstractLists */ # define TCL_OBJTYPE_V3(a,b,c,d,e,f,g,h) sizeof(Tcl_ObjType), \ a,b,c,d,e,f,g,h /* Tcl 9 - AbstractLists, version 3 */ #else diff --git a/generic/tclAssembly.c b/generic/tclAssembly.c index 4aa241a..f3f8144 100644 --- a/generic/tclAssembly.c +++ b/generic/tclAssembly.c @@ -224,7 +224,7 @@ typedef struct AssemblyEnv { * offsets of the labels. */ Tcl_Size cmdLine; /* Current line number within the assembly * code */ - int* clNext; /* Invisible continuation line for + Tcl_Size* clNext; /* Invisible continuation line for * [info frame] */ BasicBlock* head_bb; /* First basic block in the code */ BasicBlock* curr_bb; /* Current basic block */ diff --git a/generic/tclBasic.c b/generic/tclBasic.c index b412cd3..241dc78 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -5147,7 +5147,7 @@ TclEvalEx( * evaluation of the script. Only * TCL_EVAL_GLOBAL is currently supported. */ Tcl_Size line, /* The line the script starts on. */ - int *clNextOuter, /* Information about an outer context for */ + Tcl_Size *clNextOuter, /* Information about an outer context for */ const char *outerScript) /* continuation line data. This is set only in * TclSubstTokens(), to properly handle * [...]-nested commands. The 'outerScript' @@ -5169,7 +5169,8 @@ TclEvalEx( const char *p, *next; const int minObjs = 20; Tcl_Obj **objv, **objvSpace; - int *expand, *lines, *lineSpace; + int *expand; + Tcl_Size *lines, *lineSpace; Tcl_Token *tokenPtr; int expandRequested, code = TCL_OK; Tcl_Size bytesLeft, commandLength; @@ -5187,10 +5188,10 @@ TclEvalEx( Tcl_Obj **stackObjArray = (Tcl_Obj **) TclStackAlloc(interp, minObjs * sizeof(Tcl_Obj *)); int *expandStack = (int *)TclStackAlloc(interp, minObjs * sizeof(int)); - int *linesStack = (int *)TclStackAlloc(interp, minObjs * sizeof(int)); + Tcl_Size *linesStack = (Tcl_Size *)TclStackAlloc(interp, minObjs * sizeof(Tcl_Size)); /* TIP #280 Structures for tracking of command * locations. */ - int *clNext = NULL; /* Pointer for the tracking of invisible + Tcl_Size *clNext = NULL; /* Pointer for the tracking of invisible * continuation lines. Initialized only if the * caller gave us a table of locations to * track, via scriptCLLocPtr. It always refers @@ -5314,7 +5315,7 @@ TclEvalEx( Tcl_Size wordLine = line; const char *wordStart = parsePtr->commandStart; - int *wordCLNext = clNext; + Tcl_Size *wordCLNext = clNext; Tcl_Size objectsNeeded = 0; Tcl_Size numWords = parsePtr->numWords; @@ -5325,7 +5326,7 @@ TclEvalEx( if (numWords > minObjs) { expand = (int *)Tcl_Alloc(numWords * sizeof(int)); objvSpace = (Tcl_Obj **)Tcl_Alloc(numWords * sizeof(Tcl_Obj *)); - lineSpace = (int *)Tcl_Alloc(numWords * sizeof(int)); + lineSpace = (Tcl_Size *)Tcl_Alloc(numWords * sizeof(Tcl_Size)); } expandRequested = 0; objv = objvSpace; @@ -5351,7 +5352,7 @@ TclEvalEx( wordStart = tokenPtr->start; lines[objectsUsed] = TclWordKnownAtCompileTime(tokenPtr, NULL) - ? (int)wordLine : -1; + ? wordLine : -1; if (eeFramePtr->type == TCL_LOCATION_SOURCE) { iPtr->evalFlags |= TCL_EVAL_FILE; @@ -5417,14 +5418,14 @@ TclEvalEx( */ Tcl_Obj **copy = objvSpace; - int *lcopy = lineSpace; - int wordIdx = numWords; - int objIdx = objectsNeeded - 1; + Tcl_Size *lcopy = lineSpace; + Tcl_Size wordIdx = numWords; + Tcl_Size objIdx = objectsNeeded - 1; if ((numWords > minObjs) || (objectsNeeded > minObjs)) { objv = objvSpace = (Tcl_Obj **)Tcl_Alloc(objectsNeeded * sizeof(Tcl_Obj *)); - lines = lineSpace = (int *)Tcl_Alloc(objectsNeeded * sizeof(int)); + lines = lineSpace = (Tcl_Size *)Tcl_Alloc(objectsNeeded * sizeof(Tcl_Size)); } objectsUsed = 0; @@ -5659,7 +5660,7 @@ TclAdvanceLines( void TclAdvanceContinuations( Tcl_Size *line, - int **clNextPtrPtr, + Tcl_Size **clNextPtrPtr, int loc) { /* @@ -5837,7 +5838,7 @@ TclArgumentBCEnter( int objc, void *codePtr, CmdFrame *cfPtr, - int cmd, + Tcl_Size cmd, Tcl_Size pc) { ExtCmdLoc *eclPtr; diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index e6bda99..b27d3a9 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -3848,7 +3848,7 @@ TclNRSwitchObjCmd( if (ctxPtr->type == TCL_LOCATION_SOURCE && ctxPtr->line[bidx] >= 0) { int bline = ctxPtr->line[bidx]; - ctxPtr->line = (int *)Tcl_Alloc(objc * sizeof(int)); + ctxPtr->line = (Tcl_Size *)Tcl_Alloc(objc * sizeof(Tcl_Size)); ctxPtr->nline = objc; TclListLines(blist, bline, objc, ctxPtr->line, objv); } else { @@ -3862,7 +3862,7 @@ TclNRSwitchObjCmd( int k; - ctxPtr->line = (int *)Tcl_Alloc(objc * sizeof(int)); + ctxPtr->line = (Tcl_Size *)Tcl_Alloc(objc * sizeof(Tcl_Size)); ctxPtr->nline = objc; for (k=0; k < objc; k++) { ctxPtr->line[k] = -1; @@ -5302,17 +5302,17 @@ TclListLines( * structure. Assumed to be valid. Assumed to * contain n elements. */ Tcl_Size line, /* Line the list as a whole starts on. */ - int n, /* #elements in lines */ - int *lines, /* Array of line numbers, to fill. */ + Tcl_Size n, /* #elements in lines */ + Tcl_Size *lines, /* Array of line numbers, to fill. */ Tcl_Obj *const *elems) /* The list elems as Tcl_Obj*, in need of * derived continuation data */ { const char *listStr = TclGetString(listObj); const char *listHead = listStr; - int i, length = strlen(listStr); + Tcl_Size i, length = strlen(listStr); const char *element = NULL, *next = NULL; ContLineLoc *clLocPtr = TclContinuationsGet(listObj); - int *clNext = (clLocPtr ? &clLocPtr->loc[0] : NULL); + Tcl_Size *clNext = (clLocPtr ? &clLocPtr->loc[0] : NULL); for (i = 0; i < n; i++) { TclFindElement(NULL, listStr, length, &element, &next, NULL, NULL); diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c index 05d50e9..0a21226 100644 --- a/generic/tclCompCmdsSZ.c +++ b/generic/tclCompCmdsSZ.c @@ -41,12 +41,12 @@ static int CompileUnaryOpCmd(Tcl_Interp *interp, CompileEnv *envPtr); static void IssueSwitchChainedTests(Tcl_Interp *interp, CompileEnv *envPtr, int mode, int noCase, - int numWords, Tcl_Token **bodyToken, - int *bodyLines, int **bodyNext); + Tcl_Size numWords, Tcl_Token **bodyToken, + Tcl_Size *bodyLines, Tcl_Size **bodyNext); static void IssueSwitchJumpTable(Tcl_Interp *interp, CompileEnv *envPtr, int numWords, - Tcl_Token **bodyToken, int *bodyLines, - int **bodyContLines); + Tcl_Token **bodyToken, Tcl_Size *bodyLines, + Tcl_Size **bodyContLines); static int IssueTryClausesInstructions(Tcl_Interp *interp, CompileEnv *envPtr, Tcl_Token *bodyToken, int numHandlers, int *matchCodes, @@ -1800,14 +1800,14 @@ TclCompileSwitchCmd( Tcl_Token *bodyTokenArray; /* Array of real pattern list items. */ Tcl_Token **bodyToken; /* Array of pointers to pattern list items. */ - int *bodyLines; /* Array of line numbers for body list + Tcl_Size *bodyLines; /* Array of line numbers for body list * items. */ - int **bodyContLines; /* Array of continuation line info. */ + Tcl_Size **bodyContLines; /* Array of continuation line info. */ int noCase; /* Has the -nocase flag been given? */ int foundMode = 0; /* Have we seen a mode flag yet? */ int i, valueIndex; int result = TCL_ERROR; - int *clNext = envPtr->clNext; + Tcl_Size *clNext = envPtr->clNext; /* * Only handle the following versions: @@ -1964,8 +1964,8 @@ TclCompileSwitchCmd( } bodyTokenArray = (Tcl_Token *)Tcl_Alloc(sizeof(Tcl_Token) * maxLen); bodyToken = (Tcl_Token **)Tcl_Alloc(sizeof(Tcl_Token *) * maxLen); - bodyLines = (int *)Tcl_Alloc(sizeof(int) * maxLen); - bodyContLines = (int **)Tcl_Alloc(sizeof(int*) * maxLen); + bodyLines = (Tcl_Size *)Tcl_Alloc(sizeof(Tcl_Size) * maxLen); + bodyContLines = (Tcl_Size **)Tcl_Alloc(sizeof(Tcl_Size*) * maxLen); bline = mapPtr->loc[eclIndex].line[valueIndex+1]; numWords = 0; @@ -2025,8 +2025,8 @@ TclCompileSwitchCmd( */ bodyToken = (Tcl_Token **)Tcl_Alloc(sizeof(Tcl_Token *) * numWords); - bodyLines = (int *)Tcl_Alloc(sizeof(int) * numWords); - bodyContLines = (int **)Tcl_Alloc(sizeof(int*) * numWords); + bodyLines = (Tcl_Size *)Tcl_Alloc(sizeof(Tcl_Size) * numWords); + bodyContLines = (Tcl_Size **)Tcl_Alloc(sizeof(Tcl_Size*) * numWords); bodyTokenArray = NULL; for (i=0 ; i<numWords ; i++) { /* @@ -2116,13 +2116,13 @@ IssueSwitchChainedTests( CompileEnv *envPtr, /* Holds resulting instructions. */ int mode, /* Exact, Glob or Regexp */ int noCase, /* Case-insensitivity flag. */ - int numBodyTokens, /* Number of tokens describing things the + Tcl_Size numBodyTokens, /* Number of tokens describing things the * switch can match against and bodies to * execute when the match succeeds. */ Tcl_Token **bodyToken, /* Array of pointers to pattern list items. */ - int *bodyLines, /* Array of line numbers for body list + Tcl_Size *bodyLines, /* Array of line numbers for body list * items. */ - int **bodyContLines) /* Array of continuation line info. */ + Tcl_Size **bodyContLines) /* Array of continuation line info. */ { enum {Switch_Exact, Switch_Glob, Switch_Regexp}; int foundDefault; /* Flag to indicate whether a "default" clause @@ -2368,9 +2368,9 @@ IssueSwitchJumpTable( * switch can match against and bodies to * execute when the match succeeds. */ Tcl_Token **bodyToken, /* Array of pointers to pattern list items. */ - int *bodyLines, /* Array of line numbers for body list + Tcl_Size *bodyLines, /* Array of line numbers for body list * items. */ - int **bodyContLines) /* Array of continuation line info. */ + Tcl_Size **bodyContLines) /* Array of continuation line info. */ { JumptableInfo *jtPtr; int infoIndex, isNew, *finalFixups, numRealBodies = 0, jumpLocation; diff --git a/generic/tclCompile.c b/generic/tclCompile.c index b974c30..c0723cd 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -701,7 +701,8 @@ static void StartExpanding(CompileEnv *envPtr); */ static void EnterCmdWordData(ExtCmdLoc *eclPtr, Tcl_Size srcOffset, Tcl_Token *tokenPtr, const char *cmd, - Tcl_Size numWords, Tcl_Size line, int *clNext, int **lines, + Tcl_Size numWords, Tcl_Size line, + Tcl_Size *clNext, Tcl_Size **lines, CompileEnv *envPtr); static void ReleaseCmdWordData(ExtCmdLoc *eclPtr); @@ -1953,7 +1954,8 @@ CompileCmdCompileProc( CompileEnv *envPtr) { DefineLineInformation; - int unwind = 0, incrOffset = -1; + int unwind = 0; + Tcl_Size incrOffset = -1; int depth = TclGetStackDepth(envPtr); /* @@ -2040,11 +2042,11 @@ CompileCommandTokens( Command *cmdPtr = NULL; int code = TCL_ERROR; int cmdKnown, expand = -1; - int *wlines, wlineat; - int cmdLine = envPtr->line; - int *clNext = envPtr->clNext; - int cmdIdx = envPtr->numCommands; - int startCodeOffset = envPtr->codeNext - envPtr->codeStart; + Tcl_Size *wlines, wlineat; + Tcl_Size cmdLine = envPtr->line; + Tcl_Size *clNext = envPtr->clNext; + Tcl_Size cmdIdx = envPtr->numCommands; + Tcl_Size startCodeOffset = envPtr->codeNext - envPtr->codeStart; int depth = TclGetStackDepth(envPtr); assert ((int)parsePtr->numWords > 0); @@ -2194,7 +2196,7 @@ TclCompileScript( Tcl_SetObjResult(interp, Tcl_ObjPrintf("Script length %" TCL_SIZE_MODIFIER "d exceeds max permitted length %d.", - numBytes, (int)INT_MAX-1)); + numBytes, INT_MAX-1)); Tcl_SetErrorCode(interp, "TCL", "LIMIT", "SCRIPTLENGTH", NULL); TclCompileSyntaxError(interp, envPtr); return; @@ -2421,19 +2423,20 @@ TclCompileTokens( Tcl_Interp *interp, /* Used for error and status reporting. */ Tcl_Token *tokenPtr, /* Pointer to first in an array of tokens to * compile. */ - size_t count1, /* Number of tokens to consider at tokenPtr. + size_t count1, /* Number of tokens to consider at tokenPtr. * Must be at least 1. */ CompileEnv *envPtr) /* Holds the resulting instructions. */ { Tcl_DString textBuffer; /* Holds concatenated chars from adjacent * TCL_TOKEN_TEXT, TCL_TOKEN_BS tokens. */ char buffer[4] = ""; - int i, numObjsToConcat, adjust; + Tcl_Size i, numObjsToConcat, adjust; size_t length; unsigned char *entryCodeNext = envPtr->codeNext; #define NUM_STATIC_POS 20 - int isLiteral, maxNumCL, numCL; - int *clPosition = NULL; + int isLiteral; + Tcl_Size maxNumCL, numCL; + Tcl_Size *clPosition = NULL; int depth = TclGetStackDepth(envPtr); int count = count1; @@ -2463,7 +2466,7 @@ TclCompileTokens( if (isLiteral) { maxNumCL = NUM_STATIC_POS; - clPosition = (int *)Tcl_Alloc(maxNumCL * sizeof(int)); + clPosition = (Tcl_Size *)Tcl_Alloc(maxNumCL * sizeof(Tcl_Size)); } adjust = 0; @@ -2503,8 +2506,8 @@ TclCompileTokens( if (numCL >= maxNumCL) { maxNumCL *= 2; - clPosition = (int *)Tcl_Realloc(clPosition, - maxNumCL * sizeof(int)); + clPosition = (Tcl_Size *)Tcl_Realloc(clPosition, + maxNumCL * sizeof(Tcl_Size)); } clPosition[numCL] = clPos; numCL ++; @@ -3330,14 +3333,14 @@ EnterCmdWordData( const char *cmd, Tcl_Size numWords, Tcl_Size line, - int *clNext, - int **wlines, + Tcl_Size *clNext, + Tcl_Size **wlines, CompileEnv *envPtr) { ECL *ePtr; const char *last; Tcl_Size wordIdx, wordLine; - int *wwlines, *wordNext; + Tcl_Size *wwlines, *wordNext; if (eclPtr->nuloc >= eclPtr->nloc) { /* @@ -3356,10 +3359,10 @@ EnterCmdWordData( ePtr = &eclPtr->loc[eclPtr->nuloc]; ePtr->srcOffset = srcOffset; - ePtr->line = (int *)Tcl_Alloc(numWords * sizeof(int)); - ePtr->next = (int **)Tcl_Alloc(numWords * sizeof(int *)); + ePtr->line = (Tcl_Size *)Tcl_Alloc(numWords * sizeof(Tcl_Size)); + ePtr->next = (Tcl_Size **)Tcl_Alloc(numWords * sizeof(Tcl_Size *)); ePtr->nline = numWords; - wwlines = (int *)Tcl_Alloc(numWords * sizeof(int)); + wwlines = (Tcl_Size *)Tcl_Alloc(numWords * sizeof(Tcl_Size)); last = cmd; wordLine = line; @@ -3372,7 +3375,7 @@ EnterCmdWordData( /* See Ticket 4b61afd660 */ wwlines[wordIdx] = ((wordIdx == 0) || TclWordKnownAtCompileTime(tokenPtr, NULL)) - ? (int)wordLine : -1; + ? wordLine : -1; ePtr->line[wordIdx] = wordLine; ePtr->next[wordIdx] = wordNext; last = tokenPtr->start; diff --git a/generic/tclCompile.h b/generic/tclCompile.h index 558742f..90ae8a7 100644 --- a/generic/tclCompile.h +++ b/generic/tclCompile.h @@ -183,16 +183,16 @@ typedef struct { typedef struct { Tcl_Size srcOffset; /* Command location to find the entry. */ Tcl_Size nline; /* Number of words in the command */ - int *line; /* Line information for all words in the + Tcl_Size *line; /* Line information for all words in the * command. */ - int **next; /* Transient information used by the compiler + Tcl_Size **next; /* Transient information used by the compiler * for tracking of hidden continuation * lines. */ } ECL; typedef struct { int type; /* Context type. */ - int start; /* Starting line for compiled script. Needed + Tcl_Size start; /* Starting line for compiled script. Needed * for the extended recompile check in * tclCompileObj. */ Tcl_Obj *path; /* Path of the sourced file the command is @@ -392,7 +392,7 @@ typedef struct CompileEnv { * encountered that have not yet been paired * with a corresponding * INST_INVOKE_EXPANDED. */ - int *clNext; /* If not NULL, it refers to the next slot in + Tcl_Size *clNext; /* If not NULL, it refers to the next slot in * clLoc to check for an invisible * continuation line. */ } CompileEnv; diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 8dae256..6cec532 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -186,6 +186,7 @@ TCL_DECLARE_MUTEX(encodingMutex) static Tcl_Encoding defaultEncoding = NULL; static Tcl_Encoding systemEncoding = NULL; Tcl_Encoding tclIdentityEncoding = NULL; +Tcl_Encoding tclUtf8Encoding = NULL; /* * Names of encoding profiles and corresponding integer values. @@ -609,7 +610,7 @@ TclInitEncodingSubsystem(void) type.freeProc = NULL; type.nullSize = 1; type.clientData = INT2PTR(ENCODING_UTF); - Tcl_CreateEncoding(&type); + tclUtf8Encoding = Tcl_CreateEncoding(&type); type.clientData = NULL; type.encodingName = "cesu-8"; Tcl_CreateEncoding(&type); @@ -731,6 +732,8 @@ TclFinalizeEncodingSubsystem(void) defaultEncoding = NULL; FreeEncoding(tclIdentityEncoding); tclIdentityEncoding = NULL; + FreeEncoding(tclUtf8Encoding); + tclUtf8Encoding = NULL; hPtr = Tcl_FirstHashEntry(&encodingTable, &search); while (hPtr != NULL) { diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c index c238141..deabfe2 100644 --- a/generic/tclEnsemble.c +++ b/generic/tclEnsemble.c @@ -3293,7 +3293,7 @@ TclAttemptCompileProc( Tcl_Size i; Tcl_Token *saveTokenPtr = parsePtr->tokenPtr; Tcl_Size savedStackDepth = envPtr->currStackDepth; - unsigned savedCodeNext = envPtr->codeNext - envPtr->codeStart; + Tcl_Size savedCodeNext = envPtr->codeNext - envPtr->codeStart; Tcl_Size savedAuxDataArrayNext = envPtr->auxDataArrayNext; Tcl_Size savedExceptArrayNext = envPtr->exceptArrayNext; #ifdef TCL_COMPILE_DEBUG @@ -3356,13 +3356,13 @@ TclAttemptCompileProc( ExceptionAux *auxPtr = envPtr->exceptAuxArrayPtr; for (i = 0; i < savedExceptArrayNext; i++) { - while ((int)auxPtr->numBreakTargets > 0 - && auxPtr->breakTargets[auxPtr->numBreakTargets - 1] + while (auxPtr->numBreakTargets > 0 + && (Tcl_Size) auxPtr->breakTargets[auxPtr->numBreakTargets - 1] >= savedCodeNext) { auxPtr->numBreakTargets--; } - while ((int)auxPtr->numContinueTargets > 0 - && auxPtr->continueTargets[auxPtr->numContinueTargets - 1] + while (auxPtr->numContinueTargets > 0 + && (Tcl_Size) auxPtr->continueTargets[auxPtr->numContinueTargets - 1] >= savedCodeNext) { auxPtr->numContinueTargets--; } diff --git a/generic/tclExecute.c b/generic/tclExecute.c index b9cf44b..097c60e 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -634,7 +634,7 @@ static ExceptionRange * GetExceptRangeForPc(const unsigned char *pc, int searchMode, ByteCode *codePtr); static const char * GetSrcInfoForPc(const unsigned char *pc, ByteCode *codePtr, Tcl_Size *lengthPtr, - const unsigned char **pcBeg, int *cmdIdxPtr); + const unsigned char **pcBeg, Tcl_Size *cmdIdxPtr); static Tcl_Obj ** GrowEvaluationStack(ExecEnv *eePtr, TCL_HASH_TYPE growth, int move); static void IllegalExprOperandType(Tcl_Interp *interp, @@ -1850,7 +1850,7 @@ ArgumentBCEnter( int objc, Tcl_Obj **objv) { - int cmd; + Tcl_Size cmd; if (GetSrcInfoForPc(pc, codePtr, NULL, NULL, &cmd)) { TclArgumentBCEnter(interp, objv, objc, codePtr, &tdPtr->cmdFrame, cmd, @@ -9163,7 +9163,7 @@ TclGetSrcInfoForPc( ExtCmdLoc *eclPtr; ECL *locPtr = NULL; Tcl_Size srcOffset; - int i; + Tcl_Size i; Interp *iPtr = (Interp *) *codePtr->interpHandle; Tcl_HashEntry *hePtr = Tcl_FindHashEntry(iPtr->lineBCPtr, codePtr); @@ -9175,7 +9175,7 @@ TclGetSrcInfoForPc( srcOffset = cfPtr->cmd - codePtr->source; eclPtr = (ExtCmdLoc *)Tcl_GetHashValue(hePtr); - for (i=0; i < (int)eclPtr->nuloc; i++) { + for (i=0; i < eclPtr->nuloc; i++) { if (eclPtr->loc[i].srcOffset == srcOffset) { locPtr = eclPtr->loc+i; break; @@ -9215,7 +9215,7 @@ GetSrcInfoForPc( const unsigned char **pcBeg,/* If non-NULL, the bytecode location * where the current instruction starts. * If NULL; no pointer is stored. */ - int *cmdIdxPtr) /* If non-NULL, the location where the index + Tcl_Size *cmdIdxPtr) /* If non-NULL, the location where the index * of the command containing the pc should * be stored. */ { @@ -9224,10 +9224,10 @@ GetSrcInfoForPc( unsigned char *codeDeltaNext, *codeLengthNext; unsigned char *srcDeltaNext, *srcLengthNext; Tcl_Size codeOffset, codeLen, codeEnd, srcOffset, srcLen, delta, i; - int bestDist = INT_MAX; /* Distance of pc to best cmd's start pc. */ - int bestSrcOffset = -1; /* Initialized to avoid compiler warning. */ - int bestSrcLength = -1; /* Initialized to avoid compiler warning. */ - int bestCmdIdx = -1; + Tcl_Size bestDist = TCL_SIZE_MAX; /* Distance of pc to best cmd's start pc. */ + Tcl_Size bestSrcOffset = -1; /* Initialized to avoid compiler warning. */ + Tcl_Size bestSrcLength = -1; /* Initialized to avoid compiler warning. */ + Tcl_Size bestCmdIdx = -1; /* The pc must point within the bytecode */ assert ((pcOffset >= 0) && (pcOffset < codePtr->numCodeBytes)); @@ -9306,7 +9306,7 @@ GetSrcInfoForPc( * instructions. Stop when crossing pc; keep previous. */ - curr = ((bestDist == INT_MAX) ? codePtr->codeStart : pc - bestDist); + curr = ((bestDist == TCL_SIZE_MAX) ? codePtr->codeStart : pc - bestDist); prev = curr; while (curr <= pc) { prev = curr; @@ -9315,7 +9315,7 @@ GetSrcInfoForPc( *pcBeg = prev; } - if (bestDist == INT_MAX) { + if (bestDist == TCL_SIZE_MAX) { return NULL; } diff --git a/generic/tclInt.h b/generic/tclInt.h index 599fb2d..d8c6882 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -1314,7 +1314,7 @@ typedef struct CmdFrame { int type; /* Values see below. */ int level; /* Number of frames in stack, prevent O(n) * scan of list. */ - int *line; /* Lines the words of the command start on. */ + Tcl_Size *line; /* Lines the words of the command start on. */ Tcl_Size nline; CallFrame *framePtr; /* Procedure activation record, may be * NULL. */ @@ -1409,7 +1409,7 @@ typedef struct CFWordBC { typedef struct ContLineLoc { Tcl_Size num; /* Number of entries in loc, not counting the * final -1 marker entry. */ - int loc[TCLFLEXARRAY];/* Table of locations, as character offsets. + Tcl_Size loc[TCLFLEXARRAY];/* Table of locations, as character offsets. * The table is allocated as part of the * structure, extending behind the nominal end * of the structure. An entry containing the @@ -3023,6 +3023,7 @@ MODULE_SCOPE TclPlatformType tclPlatform; */ MODULE_SCOPE Tcl_Encoding tclIdentityEncoding; +MODULE_SCOPE Tcl_Encoding tclUtf8Encoding; MODULE_SCOPE int TclEncodingProfileNameToId(Tcl_Interp *interp, const char *profileName, @@ -3199,7 +3200,7 @@ MODULE_SCOPE void TclAppendBytesToByteArray(Tcl_Obj *objPtr, const unsigned char *bytes, Tcl_Size len); MODULE_SCOPE int TclNREvalCmd(Tcl_Interp *interp, Tcl_Obj *objPtr, int flags); -MODULE_SCOPE void TclAdvanceContinuations(Tcl_Size *line, int **next, +MODULE_SCOPE void TclAdvanceContinuations(Tcl_Size *line, Tcl_Size **next, int loc); MODULE_SCOPE void TclAdvanceLines(Tcl_Size *line, const char *start, const char *end); @@ -3209,7 +3210,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, Tcl_Size pc); + void *codePtr, CmdFrame *cfPtr, Tcl_Size cmd, Tcl_Size pc); MODULE_SCOPE void TclArgumentBCRelease(Tcl_Interp *interp, CmdFrame *cfPtr); MODULE_SCOPE void TclArgumentGet(Tcl_Interp *interp, Tcl_Obj *obj, @@ -3234,9 +3235,9 @@ MODULE_SCOPE Tcl_NRPostProc TclClearRootEnsemble; MODULE_SCOPE int TclCompareTwoNumbers(Tcl_Obj *valuePtr, Tcl_Obj *value2Ptr); MODULE_SCOPE ContLineLoc *TclContinuationsEnter(Tcl_Obj *objPtr, Tcl_Size num, - int *loc); + Tcl_Size *loc); MODULE_SCOPE void TclContinuationsEnterDerived(Tcl_Obj *objPtr, - int start, int *clNext); + Tcl_Size start, Tcl_Size *clNext); MODULE_SCOPE ContLineLoc *TclContinuationsGet(Tcl_Obj *objPtr); MODULE_SCOPE void TclContinuationsCopy(Tcl_Obj *objPtr, Tcl_Obj *originObjPtr); @@ -3261,7 +3262,7 @@ MODULE_SCOPE int TclFindDictElement(Tcl_Interp *interp, /* TIP #280 - Modified token based evaluation, with line information. */ MODULE_SCOPE int TclEvalEx(Tcl_Interp *interp, const char *script, Tcl_Size numBytes, int flags, Tcl_Size line, - int *clNextOuter, const char *outerScript); + Tcl_Size *clNextOuter, const char *outerScript); MODULE_SCOPE Tcl_ObjCmdProc TclFileAttrsCmd; MODULE_SCOPE Tcl_ObjCmdProc TclFileCopyCmd; MODULE_SCOPE Tcl_ObjCmdProc TclFileDeleteCmd; @@ -3382,8 +3383,8 @@ MODULE_SCOPE Tcl_Obj * TclLindexFlat(Tcl_Interp *interp, Tcl_Obj *listPtr, Tcl_Size indexCount, Tcl_Obj *const indexArray[]); MODULE_SCOPE Tcl_Obj * TclListObjGetElement(Tcl_Obj *listObj, Tcl_Size index); /* TIP #280 */ -MODULE_SCOPE void TclListLines(Tcl_Obj *listObj, Tcl_Size line, int n, - int *lines, Tcl_Obj *const *elems); +MODULE_SCOPE void TclListLines(Tcl_Obj *listObj, Tcl_Size line, Tcl_Size n, + Tcl_Size *lines, Tcl_Obj *const *elems); MODULE_SCOPE int TclListObjAppendElements(Tcl_Interp *interp, Tcl_Obj *toObj, Tcl_Size elemCount, Tcl_Obj *const elemObjv[]); @@ -3551,7 +3552,7 @@ MODULE_SCOPE void TclSubstParse(Tcl_Interp *interp, const char *bytes, Tcl_InterpState *statePtr); MODULE_SCOPE int TclSubstTokens(Tcl_Interp *interp, Tcl_Token *tokenPtr, Tcl_Size count, int *tokensLeftPtr, Tcl_Size line, - int *clNextOuter, const char *outerScript); + Tcl_Size *clNextOuter, const char *outerScript); MODULE_SCOPE Tcl_Size TclTrim(const char *bytes, Tcl_Size numBytes, const char *trim, Tcl_Size numTrim, Tcl_Size *trimRight); MODULE_SCOPE Tcl_Size TclTrimLeft(const char *bytes, Tcl_Size numBytes, diff --git a/generic/tclOOMethod.c b/generic/tclOOMethod.c index 34437c7..7a941b8 100644 --- a/generic/tclOOMethod.c +++ b/generic/tclOOMethod.c @@ -588,7 +588,7 @@ TclOOMakeProcInstanceMethod( cfPtr->level = -1; cfPtr->type = context.type; - cfPtr->line = (int *)Tcl_Alloc(sizeof(int)); + cfPtr->line = (Tcl_Size *)Tcl_Alloc(sizeof(Tcl_Size)); cfPtr->line[0] = context.line[3]; cfPtr->nline = 1; cfPtr->framePtr = NULL; @@ -701,7 +701,7 @@ TclOOMakeProcMethod( cfPtr->level = -1; cfPtr->type = context.type; - cfPtr->line = (int *)Tcl_Alloc(sizeof(int)); + cfPtr->line = (Tcl_Size *)Tcl_Alloc(sizeof(Tcl_Size)); cfPtr->line[0] = context.line[3]; cfPtr->nline = 1; cfPtr->framePtr = NULL; diff --git a/generic/tclObj.c b/generic/tclObj.c index 784162e..8b0aa47 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -555,13 +555,13 @@ ContLineLoc * TclContinuationsEnter( Tcl_Obj *objPtr, Tcl_Size num, - int *loc) + Tcl_Size *loc) { int newEntry; ThreadSpecificData *tsdPtr = TclGetContLineTable(); Tcl_HashEntry *hPtr = Tcl_CreateHashEntry(tsdPtr->lineCLPtr, objPtr, &newEntry); - ContLineLoc *clLocPtr = (ContLineLoc *)Tcl_Alloc(offsetof(ContLineLoc, loc) + (num + 1U) *sizeof(int)); + ContLineLoc *clLocPtr = (ContLineLoc *)Tcl_Alloc(offsetof(ContLineLoc, loc) + (num + 1U) *sizeof(Tcl_Size)); if (!newEntry) { /* @@ -589,7 +589,7 @@ TclContinuationsEnter( } clLocPtr->num = num; - memcpy(&clLocPtr->loc, loc, num*sizeof(int)); + memcpy(&clLocPtr->loc, loc, num*sizeof(Tcl_Size)); clLocPtr->loc[num] = CLL_END; /* Sentinel */ Tcl_SetHashValue(hPtr, clLocPtr); @@ -618,12 +618,12 @@ TclContinuationsEnter( void TclContinuationsEnterDerived( Tcl_Obj *objPtr, - int start, - int *clNext) + Tcl_Size start, + Tcl_Size *clNext) { Tcl_Size length; - int end, num; - int *wordCLLast = clNext; + Tcl_Size end, num; + Tcl_Size *wordCLLast = clNext; /* * We have to handle invisible continuations lines here as well, despite @@ -666,7 +666,7 @@ TclContinuationsEnterDerived( num = wordCLLast - clNext; if (num) { - int i; + Tcl_Size i; ContLineLoc *clLocPtr = TclContinuationsEnter(objPtr, num, clNext); /* diff --git a/generic/tclParse.c b/generic/tclParse.c index d8b40e4..55fd63d 100644 --- a/generic/tclParse.c +++ b/generic/tclParse.c @@ -1072,7 +1072,7 @@ ParseTokens( * termination information. */ { char type; - int originalTokens; + Tcl_Size originalTokens; int noSubstCmds = !(flags & TCL_SUBST_COMMANDS); int noSubstVars = !(flags & TCL_SUBST_VARIABLES); int noSubstBS = !(flags & TCL_SUBST_BACKSLASHES); @@ -1106,7 +1106,7 @@ ParseTokens( tokenPtr->size = src - tokenPtr->start; parsePtr->numTokens++; } else if (*src == '$') { - int varToken; + Tcl_Size varToken; if (noSubstVars) { tokenPtr->type = TCL_TOKEN_TEXT; @@ -1233,7 +1233,7 @@ ParseTokens( */ if (mask & TYPE_SPACE) { - if ((int)parsePtr->numTokens == originalTokens) { + if (parsePtr->numTokens == originalTokens) { goto finishToken; } break; @@ -1254,7 +1254,7 @@ ParseTokens( Tcl_Panic("ParseTokens encountered unknown character"); } } - if ((int)parsePtr->numTokens == originalTokens) { + if (parsePtr->numTokens == originalTokens) { /* * There was nothing in this range of text. Add an empty token for the * empty range, so that there is always at least one token added. @@ -1651,8 +1651,7 @@ Tcl_ParseBraces( { Tcl_Token *tokenPtr; const char *src; - int startIndex, level; - Tcl_Size length; + Tcl_Size length, startIndex, level; if (numBytes < 0 && start) { numBytes = strlen(start); @@ -1703,7 +1702,7 @@ Tcl_ParseBraces( */ if ((src != tokenPtr->start) - || ((int)parsePtr->numTokens == startIndex)) { + || (parsePtr->numTokens == startIndex)) { tokenPtr->size = (src - tokenPtr->start); parsePtr->numTokens++; } @@ -2122,7 +2121,7 @@ TclSubstTokens( * integer representing the number of tokens * left to be substituted will be written */ Tcl_Size line, /* The line the script starts on. */ - int *clNextOuter, /* Information about an outer context for */ + Tcl_Size *clNextOuter, /* Information about an outer context for */ const char *outerScript) /* continuation line data. This is set by * EvalEx() to properly handle [...]-nested * commands. The 'outerScript' refers to the @@ -2145,7 +2144,7 @@ TclSubstTokens( #define NUM_STATIC_POS 20 int isLiteral; Tcl_Size i, maxNumCL, numCL, adjust; - int *clPosition = NULL; + Tcl_Size *clPosition = NULL; Interp *iPtr = (Interp *) interp; int inFile = iPtr->evalFlags & TCL_EVAL_FILE; @@ -2180,7 +2179,7 @@ TclSubstTokens( if (isLiteral) { maxNumCL = NUM_STATIC_POS; - clPosition = (int *)Tcl_Alloc(maxNumCL * sizeof(int)); + clPosition = (Tcl_Size *)Tcl_Alloc(maxNumCL * sizeof(Tcl_Size)); } adjust = 0; @@ -2230,8 +2229,8 @@ TclSubstTokens( if (numCL >= maxNumCL) { maxNumCL *= 2; - clPosition = (int *)Tcl_Realloc(clPosition, - maxNumCL * sizeof(int)); + clPosition = (Tcl_Size *)Tcl_Realloc(clPosition, + maxNumCL * sizeof(Tcl_Size)); } clPosition[numCL] = clPos; numCL++; diff --git a/generic/tclProc.c b/generic/tclProc.c index 8c84446..85e5c6f 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -268,7 +268,7 @@ Tcl_ProcObjCmd( cfPtr->level = -1; cfPtr->type = contextPtr->type; - cfPtr->line = (int *)Tcl_Alloc(sizeof(int)); + cfPtr->line = (Tcl_Size *)Tcl_Alloc(sizeof(Tcl_Size)); cfPtr->line[0] = contextPtr->line[3]; cfPtr->nline = 1; cfPtr->framePtr = NULL; @@ -2547,7 +2547,7 @@ SetLambdaFromAny( if (contextPtr->line && (contextPtr->nline >= 2) && (contextPtr->line[1] >= 0)) { - int buf[2]; + Tcl_Size buf[2]; /* * Move from approximation (line of list cmd word) to actual @@ -2559,7 +2559,7 @@ SetLambdaFromAny( cfPtr->level = -1; cfPtr->type = contextPtr->type; - cfPtr->line = (int *)Tcl_Alloc(sizeof(int)); + cfPtr->line = (Tcl_Size *)Tcl_Alloc(sizeof(Tcl_Size)); cfPtr->line[0] = buf[1]; cfPtr->nline = 1; cfPtr->framePtr = NULL; diff --git a/generic/tclTestObj.c b/generic/tclTestObj.c index 5271a54..99b8116 100644 --- a/generic/tclTestObj.c +++ b/generic/tclTestObj.c @@ -891,6 +891,7 @@ TestlistobjCmd( "replace", "indexmemcheck", "getelementsmemcheck", + "index", NULL }; enum listobjCmdIndex { @@ -899,6 +900,7 @@ TestlistobjCmd( LISTOBJ_REPLACE, LISTOBJ_INDEXMEMCHECK, LISTOBJ_GETELEMENTSMEMCHECK, + LISTOBJ_INDEX, } cmdIndex; Tcl_Size varIndex; /* Variable number converted to binary */ @@ -1007,6 +1009,26 @@ TestlistobjCmd( } } break; + case LISTOBJ_INDEX: + /* + * Tcl_ListObjIndex semantics differ from lindex for out of bounds. + * Hence this explicit test. + */ + if (objc != 4) { + Tcl_WrongNumArgs(interp, 2, objv, + "varIndex listIndex"); + return TCL_ERROR; + } + if (Tcl_GetIntForIndex(interp, objv[3], TCL_INDEX_NONE, &first) != TCL_OK) { + return TCL_ERROR; + } else { + Tcl_Obj *objP; + if (Tcl_ListObjIndex(interp, varPtr[varIndex], first, &objP) != TCL_OK) { + return TCL_ERROR; + } + Tcl_SetObjResult(interp, objP ? objP : Tcl_NewStringObj("null", -1)); + } + break; } return TCL_OK; } diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index e9f7157..2df7705 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -273,15 +273,11 @@ static struct { * they are believed to not be UTF-8; only * written to from Tcl code in a trusted * interpreter, so not protected by mutex. */ - Tcl_Encoding utf8; /* The UTF-8 encoding that we prefer to use - * for the strings (especially filenames) - * embedded in a ZIP. Other encodings are used - * dynamically. */ int idCount; /* Counter for channel names */ Tcl_HashTable fileHash; /* File name to ZipEntry mapping */ Tcl_HashTable zipHash; /* Mount to ZipFile mapping */ } ZipFS = { - 0, 0, 0, DEFAULT_WRITE_MAX_SIZE, NULL, NULL, 0, + 0, 0, 0, DEFAULT_WRITE_MAX_SIZE, NULL, 0, {0,{0,0,0,0},0,0,0,0,0,0,0,0,0}, {0,{0,0,0,0},0,0,0,0,0,0,0,0,0} }; @@ -743,7 +739,7 @@ DecodeZipEntryText( while (1) { int srcRead, dstWrote; - int result = Tcl_ExternalToUtf(NULL, ZipFS.utf8, src, srcLen, flags, + int result = Tcl_ExternalToUtf(NULL, tclUtf8Encoding, src, srcLen, flags, &state, dst, dstLen, &srcRead, &dstWrote, NULL); int soFar = dst + dstWrote - Tcl_DStringValue(dstPtr); @@ -1860,7 +1856,6 @@ ZipfsSetup(void) ZipFS.fallbackEntryEncoding = (char *) Tcl_Alloc(strlen(ZIPFS_FALLBACK_ENCODING) + 1); strcpy(ZipFS.fallbackEntryEncoding, ZIPFS_FALLBACK_ENCODING); - ZipFS.utf8 = Tcl_GetEncoding(NULL, "utf-8"); ZipFS.initialized = 1; Tcl_CreateExitHandler(ZipfsExitHandler, NULL); } @@ -2541,7 +2536,7 @@ ZipAddFile( * crazy enough to embed NULs in filenames, they deserve what they get! */ - zpathExt = Tcl_UtfToExternalDString(ZipFS.utf8, zpathTcl, -1, &zpathDs); + zpathExt = Tcl_UtfToExternalDString(tclUtf8Encoding, zpathTcl, -1, &zpathDs); zpathlen = strlen(zpathExt); if (zpathlen + ZIP_CENTRAL_HEADER_LEN > bufsize) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( @@ -3210,7 +3205,7 @@ ZipFSMkZipOrImg( } z = (ZipEntry *) Tcl_GetHashValue(hPtr); - name = Tcl_UtfToExternalDString(ZipFS.utf8, z->name, TCL_INDEX_NONE, &ds); + name = Tcl_UtfToExternalDString(tclUtf8Encoding, z->name, TCL_INDEX_NONE, &ds); len = Tcl_DStringLength(&ds); SerializeCentralDirectoryEntry(start, end, (unsigned char *) buf, z, len); diff --git a/tests/bigdata.test b/tests/bigdata.test index b7afbbc..d173e90 100644 --- a/tests/bigdata.test +++ b/tests/bigdata.test @@ -1147,6 +1147,21 @@ test puts-bigdata-2 "puts" -setup { set written } -result {2345—} +test source-bigdata-1 "source" -setup { + # This test crashes because the frame linenumber tracking + # wraps around at INT_MAX + set fpath [tcltest::makeFile {} source-bigdata-1.tcl] + set fd [open $fpath w] + fconfigure $fd -translation lf + puts -nonewline $fd [string repeat \n 4294967296] + puts $fd {dict get [info frame 0] line} + close $fd +} -constraints { + bigdata knownBug +} -body { + set line [source $fpath] +} -result 4294967297 + # # TODO # lremove diff --git a/tests/encoding.test b/tests/encoding.test index c7575cb..23d6b38 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -577,7 +577,7 @@ test encoding-16.23 {Utf16ToUtfProc, strict, bug [db7a085bd9]} -body { encoding convertfrom -profile strict utf-16le \x00\xDC } -returnCodes 1 -result {unexpected byte sequence starting at index 0: '\x00'} test encoding-16.24 {Utf32ToUtfProc} -body { - encoding convertfrom utf-32 "\xFF\xFF\xFF\xFF" + encoding convertfrom -profile tcl8 utf-32 "\xFF\xFF\xFF\xFF" } -result \uFFFD test {encoding-16.25 strict} {Utf32ToUtfProc} -body { encoding convertfrom -profile strict utf-32 "\x01\x00\x00\x01" diff --git a/tests/listObj.test b/tests/listObj.test index c5ebbb0..838c676 100644 --- a/tests/listObj.test +++ b/tests/listObj.test @@ -291,6 +291,41 @@ test listobj-13.3 {Tcl_ListObjElements memory leaks for lseq} -constraints { }] $errorMessage } -result {0 {}} +# Tests for Tcl_ListObjIndex as sematics are different from lindex for +# out of bounds indices. Out of bounds should return a null pointer and +# not empty string. +test listobj-14.1 {Tcl_ListObjIndex out-of-bounds index for native lists} -constraints { + testobj +} -setup { + testobj set 1 [list a b c] +} -cleanup { + testobj freeallvars +} -body { + list [testlistobj index 1 -1] [testlistobj index 1 3] +} -result {null null} + +test listobj-14.2 {Tcl_ListObjIndex out-of-bounds index for native lists with spans} -constraints { + testobj +} -setup { + testobj set 1 [testlistrep new 1000 100 100] +} -cleanup { + testobj freeallvars +} -body { + list [testlistobj index 1 -1] [testlistobj index 1 1000] +} -result {null null} + +test listobj-14.3 {Tcl_ListObjIndex out-of-bounds index for lseq} -constraints { + testobj +} -setup { + testobj set 1 [lseq 3] +} -cleanup { + testobj freeallvars +} -constraints { + bug-30e4e9102f +} -body { + list [testlistobj index 1 -1] [testlistobj index 1 3] +} -result {null null} + # cleanup ::tcltest::cleanupTests return diff --git a/tests/utfext.test b/tests/utfext.test index 1ae2374..31ac392 100644 --- a/tests/utfext.test +++ b/tests/utfext.test @@ -76,9 +76,9 @@ test xx-bufferoverflow {buffer overflow Tcl_ExternalToUtf} -body { test TableToUtf-bug-5be203d6ca {Bug 5be203d6ca - truncated prefix in table encoding} -body { set src \x82\x4F\x82\x50\x82 - lassign [testencoding Tcl_ExternalToUtf shiftjis $src {start} 0 16 srcRead dstWritten charsWritten] buf - set result [list [testencoding Tcl_ExternalToUtf shiftjis $src {start} 0 16 srcRead dstWritten charsWritten] $srcRead $dstWritten $charsWritten] - lappend result {*}[list [testencoding Tcl_ExternalToUtf shiftjis [string range $src $srcRead end] {end} 0 10 srcRead dstWritten charsWritten] $srcRead $dstWritten $charsWritten] + lassign [testencoding Tcl_ExternalToUtf shiftjis $src {start profiletcl8} 0 16 srcRead dstWritten charsWritten] buf + set result [list [testencoding Tcl_ExternalToUtf shiftjis $src {start profiletcl8} 0 16 srcRead dstWritten charsWritten] $srcRead $dstWritten $charsWritten] + lappend result {*}[list [testencoding Tcl_ExternalToUtf shiftjis [string range $src $srcRead end] {end profiletcl8} 0 10 srcRead dstWritten charsWritten] $srcRead $dstWritten $charsWritten] } -result [list [list multibyte 0 \xEF\xBC\x90\xEF\xBC\x91\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF] 4 6 2 [list ok 0 \xC2\x82\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF] 1 2 1] |
