diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-01-20 01:36:10 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-01-20 01:36:10 (GMT) |
commit | ea65a9b87515afd2e9c9738a219a02a437892ed7 (patch) | |
tree | 394fc3dfe5f9a3af610de9fdea532cfd151326dc | |
parent | ff93a19122b26c504edd512b4692b935c0a3646c (diff) | |
parent | 5a02d5db9cec007d16a60b24bd8cd0b1912d123f (diff) | |
download | tcl-ea65a9b87515afd2e9c9738a219a02a437892ed7.zip tcl-ea65a9b87515afd2e9c9738a219a02a437892ed7.tar.gz tcl-ea65a9b87515afd2e9c9738a219a02a437892ed7.tar.bz2 |
Merge trunk. All callers of TclIndexDecode and related functions now adapted for enhanced index range.
-rw-r--r-- | generic/tclBasic.c | 2 | ||||
-rw-r--r-- | generic/tclCmdIL.c | 60 | ||||
-rw-r--r-- | generic/tclCmdMZ.c | 168 | ||||
-rw-r--r-- | generic/tclExecute.c | 4 | ||||
-rw-r--r-- | generic/tclFileName.c | 23 | ||||
-rw-r--r-- | generic/tclIORTrans.c | 18 | ||||
-rw-r--r-- | generic/tclIOUtil.c | 8 | ||||
-rw-r--r-- | generic/tclIndexObj.c | 6 | ||||
-rw-r--r-- | generic/tclInt.h | 28 | ||||
-rw-r--r-- | generic/tclListObj.c | 28 | ||||
-rw-r--r-- | generic/tclStringObj.c | 4 | ||||
-rw-r--r-- | generic/tclUtil.c | 40 | ||||
-rw-r--r-- | generic/tclZipfs.c | 25 | ||||
-rw-r--r-- | generic/tclZlib.c | 12 | ||||
-rw-r--r-- | tests/cmdIL.test | 5 |
15 files changed, 201 insertions, 230 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 7056099..549c751 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -7054,7 +7054,7 @@ ExprAbsFunc( goto unChanged; } else if (l == (Tcl_WideInt)0) { if (TclHasStringRep(objv[1])) { - int numBytes; + size_t numBytes; const char *bytes = TclGetStringFromObj(objv[1], &numBytes); while (numBytes) { diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index ae38dcb..51f8586 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -2420,7 +2420,8 @@ Tcl_LinsertObjCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { Tcl_Obj *listPtr; - int index, len, result; + size_t index; + int len, result; if (objc < 3) { Tcl_WrongNumArgs(interp, 1, objv, "list index ?element ...?"); @@ -2438,11 +2439,11 @@ Tcl_LinsertObjCmd( * appended to the list. */ - result = TclGetIntForIndexM2(interp, objv[2], /*end*/ len, &index); + result = TclGetIntForIndexM(interp, objv[2], /*end*/ len, &index); if (result != TCL_OK) { return result; } - if (index > len) { + if (index + 1 > (size_t)len + 1) { index = len; } @@ -2456,7 +2457,7 @@ Tcl_LinsertObjCmd( listPtr = TclListObjCopy(NULL, listPtr); } - if ((objc == 4) && (index == len)) { + if ((objc == 4) && (index == (size_t)len)) { /* * Special case: insert one element at the end of the list. */ @@ -2674,7 +2675,8 @@ Tcl_LrangeObjCmd( register Tcl_Obj *const objv[]) /* Argument objects. */ { - int listLen, first, last, result; + int listLen, result; + size_t first, last; if (objc != 4) { Tcl_WrongNumArgs(interp, 1, objv, "list first last"); @@ -2686,13 +2688,13 @@ Tcl_LrangeObjCmd( return result; } - result = TclGetIntForIndexM2(interp, objv[2], /*endValue*/ listLen - 1, + result = TclGetIntForIndexM(interp, objv[2], /*endValue*/ listLen - 1, &first); if (result != TCL_OK) { return result; } - result = TclGetIntForIndexM2(interp, objv[3], /*endValue*/ listLen - 1, + result = TclGetIntForIndexM(interp, objv[3], /*endValue*/ listLen - 1, &last); if (result != TCL_OK) { return result; @@ -2836,7 +2838,8 @@ Tcl_LreplaceObjCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { register Tcl_Obj *listPtr; - int first, last, listLen, numToDelete, result; + size_t first, last; + int listLen, numToDelete, result; if (objc < 4) { Tcl_WrongNumArgs(interp, 1, objv, @@ -2855,27 +2858,26 @@ Tcl_LreplaceObjCmd( * included for deletion. */ - result = TclGetIntForIndexM2(interp, objv[2], /*end*/ listLen-1, &first); + result = TclGetIntForIndexM(interp, objv[2], /*end*/ listLen-1, &first); if (result != TCL_OK) { return result; } - result = TclGetIntForIndexM2(interp, objv[3], /*end*/ listLen-1, &last); + result = TclGetIntForIndexM(interp, objv[3], /*end*/ listLen-1, &last); if (result != TCL_OK) { return result; } - if (first < 0) { + if (first == TCL_INDEX_NONE) { first = 0; - } - if (first > listLen) { + } else if (first > (size_t)listLen) { first = listLen; } - if (last >= listLen) { + if (last + 1 > (size_t)listLen) { last = listLen - 1; } - if (first <= last) { + if (first + 1 <= last + 1) { numToDelete = last - first + 1; } else { numToDelete = 0; @@ -3017,9 +3019,9 @@ Tcl_LsearchObjCmd( { const char *bytes, *patternBytes; int i, match, index, result=TCL_OK, listc, bisect; - size_t length = 0, elemLen; + size_t length = 0, elemLen, start; int allocatedIndexVector = 0; - int dataType, isIncreasing, lower, upper, start, groupSize, groupOffset; + int dataType, isIncreasing, lower, upper, groupSize, groupOffset; Tcl_WideInt patWide, objWide; int allMatches, inlineReturn, negatedMatch, returnSubindices, noCase; double patDouble, objDouble; @@ -3374,12 +3376,12 @@ Tcl_LsearchObjCmd( */ if (startPtr) { - result = TclGetIntForIndexM2(interp, startPtr, listc-1, &start); + result = TclGetIntForIndexM(interp, startPtr, listc-1, &start); if (result != TCL_OK) { goto done; } - if (start < 0) { - start = 0; + if (start == TCL_INDEX_NONE) { + start = TCL_INDEX_START; } /* @@ -3387,7 +3389,7 @@ Tcl_LsearchObjCmd( * "did not match anything at all" result straight away. [Bug 1374778] */ - if (start > listc-1) { + if (start >= (size_t)listc) { if (allMatches || inlineReturn) { Tcl_ResetResult(interp); } else { @@ -4705,7 +4707,8 @@ SelectObjFromSublist( */ for (i=0 ; i<infoPtr->indexc ; i++) { - int listLen, index; + int listLen; + int index; Tcl_Obj *currentObj; if (TclListObjLength(infoPtr->interp, objPtr, &listLen) != TCL_OK) { @@ -4721,9 +4724,16 @@ SelectObjFromSublist( return NULL; } if (currentObj == NULL) { - Tcl_SetObjResult(infoPtr->interp, Tcl_ObjPrintf( - "element %d missing from sublist \"%s\"", - index, TclGetString(objPtr))); + if (index == (int)TCL_INDEX_NONE) { + index = TCL_INDEX_END - infoPtr->indexv[i]; + Tcl_SetObjResult(infoPtr->interp, Tcl_ObjPrintf( + "element end-%d missing from sublist \"%s\"", + index, TclGetString(objPtr))); + } else { + Tcl_SetObjResult(infoPtr->interp, Tcl_ObjPrintf( + "element %d missing from sublist \"%s\"", + index, TclGetString(objPtr))); + } Tcl_SetErrorCode(infoPtr->interp, "TCL", "OPERATION", "LSORT", "INDEXFAILED", NULL); infoPtr->resultCode = TCL_ERROR; diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index cc97161..0af8133 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -126,7 +126,8 @@ Tcl_RegexpObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - int i, indices, match, about, offset, all, doinline, numMatchesSaved; + size_t offset; + int i, indices, match, about, all, doinline, numMatchesSaved; int cflags, eflags, stringLength, matchLength; Tcl_RegExp regExpr; Tcl_Obj *objPtr, *startIndex = NULL, *resultPtr = NULL; @@ -145,7 +146,7 @@ Tcl_RegexpObjCmd( indices = 0; about = 0; cflags = TCL_REG_ADVANCED; - offset = 0; + offset = TCL_INDEX_START; all = 0; doinline = 0; @@ -258,10 +259,10 @@ Tcl_RegexpObjCmd( stringLength = Tcl_GetCharLength(objPtr); if (startIndex) { - TclGetIntForIndexM2(interp, startIndex, stringLength, &offset); + TclGetIntForIndexM(interp, startIndex, stringLength, &offset); Tcl_DecrRefCount(startIndex); - if (offset < 0) { - offset = 0; + if (offset == TCL_INDEX_NONE) { + offset = TCL_INDEX_START; } } @@ -305,9 +306,9 @@ Tcl_RegexpObjCmd( * start of the string unless the previous character is a newline. */ - if (offset == 0) { + if (offset == TCL_INDEX_START) { eflags = 0; - } else if (offset > stringLength) { + } else if (offset + 1 > (size_t)stringLength + 1) { eflags = TCL_REG_NOTBOL; } else if (Tcl_GetUniChar(objPtr, offset-1) == '\n') { eflags = 0; @@ -380,7 +381,7 @@ Tcl_RegexpObjCmd( * match instead of the first character after the match. */ - if (end >= offset) { + if ((size_t)end + 1 >= offset + 1) { end--; } } else { @@ -443,7 +444,7 @@ Tcl_RegexpObjCmd( offset++; } all++; - if (offset >= stringLength) { + if (offset + 1 >= (size_t)stringLength + 1) { break; } } @@ -486,8 +487,8 @@ Tcl_RegsubObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - int idx, result, cflags, all, numMatches, offset; - size_t wlen, wsublen = 0; + int idx, result, cflags, all, numMatches; + size_t wlen, wsublen = 0, offset; int start, end, subStart, subEnd, match, command, numParts; Tcl_RegExp regExpr; Tcl_RegExpInfo info; @@ -507,7 +508,7 @@ Tcl_RegsubObjCmd( cflags = TCL_REG_ADVANCED; all = 0; - offset = 0; + offset = TCL_INDEX_START; command = 0; resultPtr = NULL; @@ -583,14 +584,14 @@ Tcl_RegsubObjCmd( if (startIndex) { size_t stringLength = Tcl_GetCharLength(objv[1]); - TclGetIntForIndexM2(interp, startIndex, stringLength, &offset); + TclGetIntForIndexM(interp, startIndex, stringLength, &offset); Tcl_DecrRefCount(startIndex); - if (offset < 0) { - offset = 0; + if (offset == TCL_INDEX_NONE) { + offset = TCL_INDEX_START; } } - if (all && (offset == 0) && (command == 0) + if (all && (offset == TCL_INDEX_START) && (command == 0) && (strpbrk(TclGetString(objv[2]), "&\\") == NULL) && (strpbrk(TclGetString(objv[0]), "*+?{}()[].\\|^$") == NULL)) { /* @@ -723,7 +724,7 @@ Tcl_RegsubObjCmd( */ numMatches = 0; - for ( ; (size_t)offset <= wlen; ) { + for ( ; offset <= wlen; ) { /* * The flags argument is set if string is part of a larger string, so @@ -745,7 +746,7 @@ Tcl_RegsubObjCmd( if (numMatches == 0) { resultPtr = Tcl_NewUnicodeObj(wstring, 0); Tcl_IncrRefCount(resultPtr); - if (offset > 0) { + if (offset > TCL_INDEX_START) { /* * Copy the initial portion of the string in if an offset was * specified. @@ -838,7 +839,7 @@ Tcl_RegsubObjCmd( * again at the same spot. */ - if ((size_t)offset < wlen) { + if (offset < wlen) { Tcl_AppendUnicodeToObj(resultPtr, wstring + offset, 1); } offset++; @@ -911,7 +912,7 @@ Tcl_RegsubObjCmd( * order to prevent infinite loops. */ - if ((size_t)offset < wlen) { + if (offset < wlen) { Tcl_AppendUnicodeToObj(resultPtr, wstring + offset, 1); } offset++; @@ -923,7 +924,7 @@ Tcl_RegsubObjCmd( * one more step so we don't match again at the same spot. */ - if ((size_t)offset < wlen) { + if (offset < wlen) { Tcl_AppendUnicodeToObj(resultPtr, wstring + offset, 1); } offset++; @@ -948,7 +949,7 @@ Tcl_RegsubObjCmd( resultPtr = objv[1]; Tcl_IncrRefCount(resultPtr); - } else if ((size_t)offset < wlen) { + } else if (offset < wlen) { Tcl_AppendUnicodeToObj(resultPtr, wstring + offset, wlen - offset); } if (objc == 4) { @@ -1323,7 +1324,7 @@ StringFirstCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - int start = 0; + size_t start = TCL_INDEX_START; if (objc < 3 || objc > 4) { Tcl_WrongNumArgs(interp, 1, objv, @@ -1334,13 +1335,10 @@ StringFirstCmd( if (objc == 4) { size_t end = Tcl_GetCharLength(objv[2]) - 1; - if (TCL_OK != TclGetIntForIndexM2(interp, objv[3], end, &start)) { + if (TCL_OK != TclGetIntForIndexM(interp, objv[3], end, &start)) { return TCL_ERROR; } } - if (start < -1) { - start = -1; - } Tcl_SetObjResult(interp, TclNewWideIntObjFromSize(TclStringFirst(objv[1], objv[2], start))); return TCL_OK; @@ -1371,7 +1369,7 @@ StringLastCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - int last = INT_MAX - 1; + size_t last = TCL_INDEX_END; if (objc < 3 || objc > 4) { Tcl_WrongNumArgs(interp, 1, objv, @@ -1382,13 +1380,10 @@ StringLastCmd( if (objc == 4) { size_t end = Tcl_GetCharLength(objv[2]) - 1; - if (TCL_OK != TclGetIntForIndexM2(interp, objv[3], end, &last)) { + if (TCL_OK != TclGetIntForIndexM(interp, objv[3], end, &last)) { return TCL_ERROR; } } - if (last < -1) { - last = -1; - } Tcl_SetObjResult(interp, TclNewWideIntObjFromSize(TclStringLast(objv[1], objv[2], last))); return TCL_OK; @@ -1419,8 +1414,7 @@ StringIndexCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - size_t end; - int index; + size_t index, end; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "string charIndex"); @@ -1432,11 +1426,11 @@ StringIndexCmd( */ end = Tcl_GetCharLength(objv[1]) - 1; - if (TclGetIntForIndexM2(interp, objv[2], end, &index) != TCL_OK) { + if (TclGetIntForIndexM(interp, objv[2], end, &index) != TCL_OK) { return TCL_ERROR; } - if ((index >= 0) && (index <= (int)end)) { + if ((index != TCL_INDEX_NONE) && ((size_t)index + 1 <= end + 1)) { int ch = Tcl_GetUniChar(objv[1], index); if (ch == -1) { @@ -2257,8 +2251,7 @@ StringRangeCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - size_t end; - int first, last; + size_t first, last, end; if (objc != 4) { Tcl_WrongNumArgs(interp, 1, objv, "string first last"); @@ -2272,18 +2265,18 @@ StringRangeCmd( end = Tcl_GetCharLength(objv[1]) - 1; - if (TclGetIntForIndexM2(interp, objv[2], end, &first) != TCL_OK || - TclGetIntForIndexM2(interp, objv[3], end, &last) != TCL_OK) { + if (TclGetIntForIndexM(interp, objv[2], end, &first) != TCL_OK || + TclGetIntForIndexM(interp, objv[3], end, &last) != TCL_OK) { return TCL_ERROR; } - if (first < 0) { - first = 0; + if (first == TCL_INDEX_NONE) { + first = TCL_INDEX_START; } - if (last >= (int)end) { + if (last + 1 >= end + 1) { last = end; } - if (last >= first) { + if (last + 1 >= first + 1) { Tcl_SetObjResult(interp, Tcl_GetRange(objv[1], first, last)); } return TCL_OK; @@ -2370,8 +2363,7 @@ StringRplcCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - int first, last; - size_t end; + size_t first, last, end; if (objc < 4 || objc > 5) { Tcl_WrongNumArgs(interp, 1, objv, "string first last ?string?"); @@ -2380,8 +2372,8 @@ StringRplcCmd( end = Tcl_GetCharLength(objv[1]) - 1; - if (TclGetIntForIndexM2(interp, objv[2], end, &first) != TCL_OK || - TclGetIntForIndexM2(interp, objv[3], end, &last) != TCL_OK){ + if (TclGetIntForIndexM(interp, objv[2], end, &first) != TCL_OK || + TclGetIntForIndexM(interp, objv[3], end, &last) != TCL_OK){ return TCL_ERROR; } @@ -2390,9 +2382,9 @@ StringRplcCmd( * candidates for replacement. When they are detected, no * replacement is done, and the result is the original string, */ - if ((last < 0) || /* Range ends before start of string */ - (first > (int)end) || /* Range begins after end of string */ - (last < first)) { /* Range begins after it starts */ + if ((last == TCL_INDEX_NONE) || /* Range ends before start of string */ + (first + 1 > end + 1) || /* Range begins after end of string */ + (last + 1 < first + 1)) { /* Range begins after it starts */ /* * BUT!!! when (end < 0) -- an empty original string -- we can @@ -2403,10 +2395,10 @@ StringRplcCmd( } else { Tcl_Obj *resultPtr; - if (first < 0) { - first = 0; + if (first == TCL_INDEX_NONE) { + first = TCL_INDEX_START; } - if (last > (int)end) { + if (last + 1 > end + 1) { last = end; } @@ -2481,8 +2473,7 @@ StringStartCmd( { Tcl_UniChar ch = 0; const char *p, *string; - int cur, index; - size_t numChars, length; + size_t numChars, length, cur, index; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "string index"); @@ -2491,17 +2482,17 @@ StringStartCmd( string = TclGetStringFromObj(objv[1], &length); numChars = Tcl_NumUtfChars(string, length) - 1; - if (TclGetIntForIndexM2(interp, objv[2], numChars, &index) != TCL_OK) { + if (TclGetIntForIndexM(interp, objv[2], numChars, &index) != TCL_OK) { return TCL_ERROR; } - string = TclGetStringFromObj(objv[1], &length); - if (index > (int)numChars) { + string = TclGetString(objv[1]); + if (index + 1 > numChars + 1) { index = numChars; } cur = 0; - if (index > 0) { + if (index + 1 > 1) { p = Tcl_UtfAtIndex(string, index); - for (cur = index; cur >= 0; cur--) { + for (cur = index; cur != TCL_INDEX_NONE; cur--) { TclUtfToUniChar(p, &ch); if (!Tcl_UniCharIsWordChar(ch)) { break; @@ -2512,7 +2503,7 @@ StringStartCmd( cur += 1; } } - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(cur)); + Tcl_SetObjResult(interp, TclNewWideIntObjFromSize(cur)); return TCL_OK; } @@ -2543,8 +2534,7 @@ StringEndCmd( { Tcl_UniChar ch = 0; const char *p, *end, *string; - int cur, index; - size_t length, numChars; + size_t length, numChars, cur, index; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "string index"); @@ -2553,14 +2543,14 @@ StringEndCmd( string = TclGetStringFromObj(objv[1], &length); numChars = Tcl_NumUtfChars(string, length) - 1; - if (TclGetIntForIndexM2(interp, objv[2], numChars, &index) != TCL_OK) { + if (TclGetIntForIndexM(interp, objv[2], numChars, &index) != TCL_OK) { return TCL_ERROR; } string = TclGetStringFromObj(objv[1], &length); - if (index < 0) { - index = 0; + if (index == TCL_INDEX_NONE) { + index = TCL_INDEX_START; } - if (index <= (int) numChars) { + if (index + 1 <= numChars + 1) { p = Tcl_UtfAtIndex(string, index); end = string+length; for (cur = index; p < end; cur++) { @@ -2575,7 +2565,7 @@ StringEndCmd( } else { cur = numChars + 1; } - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(cur)); + Tcl_SetObjResult(interp, TclNewWideIntObjFromSize(cur)); return TCL_OK; } @@ -2904,28 +2894,28 @@ StringLowerCmd( Tcl_SetObjLength(resultPtr, length1); Tcl_SetObjResult(interp, resultPtr); } else { - int first, last; + size_t first, last; const char *start, *end; Tcl_Obj *resultPtr; length1 = Tcl_NumUtfChars(string1, length1) - 1; - if (TclGetIntForIndexM2(interp,objv[2],length1, &first) != TCL_OK) { + if (TclGetIntForIndexM(interp,objv[2],length1, &first) != TCL_OK) { return TCL_ERROR; } - if (first < 0) { + if (first == TCL_INDEX_NONE) { first = 0; } last = first; - if ((objc == 4) && (TclGetIntForIndexM2(interp, objv[3], length1, + if ((objc == 4) && (TclGetIntForIndexM(interp, objv[3], length1, &last) != TCL_OK)) { return TCL_ERROR; } - if (last >= (int)length1) { + if (last + 1 >= length1 + 1) { last = length1; } - if (last < first) { + if (last + 1 < first + 1) { Tcl_SetObjResult(interp, objv[1]); return TCL_OK; } @@ -2989,28 +2979,28 @@ StringUpperCmd( Tcl_SetObjLength(resultPtr, length1); Tcl_SetObjResult(interp, resultPtr); } else { - int first, last; + size_t first, last; const char *start, *end; Tcl_Obj *resultPtr; length1 = Tcl_NumUtfChars(string1, length1) - 1; - if (TclGetIntForIndexM2(interp,objv[2],length1, &first) != TCL_OK) { + if (TclGetIntForIndexM(interp,objv[2],length1, &first) != TCL_OK) { return TCL_ERROR; } - if (first < 0) { - first = 0; + if (first == TCL_INDEX_NONE) { + first = TCL_INDEX_START; } last = first; - if ((objc == 4) && (TclGetIntForIndexM2(interp, objv[3], length1, + if ((objc == 4) && (TclGetIntForIndexM(interp, objv[3], length1, &last) != TCL_OK)) { return TCL_ERROR; } - if (last >= (int)length1) { + if (last + 1 >= length1 + 1) { last = length1; } - if (last < first) { + if (last + 1 < first + 1) { Tcl_SetObjResult(interp, objv[1]); return TCL_OK; } @@ -3074,28 +3064,28 @@ StringTitleCmd( Tcl_SetObjLength(resultPtr, length1); Tcl_SetObjResult(interp, resultPtr); } else { - int first, last; + size_t first, last; const char *start, *end; Tcl_Obj *resultPtr; length1 = Tcl_NumUtfChars(string1, length1) - 1; - if (TclGetIntForIndexM2(interp,objv[2],length1, &first) != TCL_OK) { + if (TclGetIntForIndexM(interp,objv[2],length1, &first) != TCL_OK) { return TCL_ERROR; } - if (first < 0) { - first = 0; + if (first == TCL_INDEX_NONE) { + first = TCL_INDEX_START; } last = first; - if ((objc == 4) && (TclGetIntForIndexM2(interp, objv[3], length1, + if ((objc == 4) && (TclGetIntForIndexM(interp, objv[3], length1, &last) != TCL_OK)) { return TCL_ERROR; } - if (last >= (int)length1) { + if (last + 1 >= length1 + 1) { last = length1; } - if (last < first) { + if (last + 1 < first + 1) { Tcl_SetObjResult(interp, objv[1]); return TCL_OK; } diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 4b2462b..42019b6 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -4771,7 +4771,7 @@ TEBCresume( NEXT_INST_F(9, 1, 1); } toIdx = TclIndexDecode(toIdx, objc - 1); - if ((int)toIdx < 0) { + if (toIdx == TCL_INDEX_NONE) { goto emptyList; } else if (toIdx + 1 >= (size_t)objc + 1) { toIdx = objc - 1; @@ -5242,7 +5242,7 @@ TEBCresume( NEXT_INST_F(1, 2, 1); case INST_STR_FIND_LAST: - slength = TclStringLast(OBJ_UNDER_TOS, OBJ_AT_TOS, (size_t)-2); + slength = TclStringLast(OBJ_UNDER_TOS, OBJ_AT_TOS, TCL_INDEX_END); TRACE(("%.20s %.20s => %" TCL_LL_MODIFIER "d\n", O2S(OBJ_UNDER_TOS), O2S(OBJ_AT_TOS), TclWideIntFromSize(slength))); diff --git a/generic/tclFileName.c b/generic/tclFileName.c index f7d1e76..d84ba63 100644 --- a/generic/tclFileName.c +++ b/generic/tclFileName.c @@ -386,8 +386,7 @@ TclpGetNativePathType( Tcl_Obj **driveNameRef) { Tcl_PathType type = TCL_PATH_ABSOLUTE; - int pathLen; - const char *path = TclGetStringFromObj(pathPtr, &pathLen); + const char *path = TclGetString(pathPtr); if (path[0] == '~') { /* @@ -557,7 +556,8 @@ Tcl_SplitPath( { Tcl_Obj *resultPtr = NULL; /* Needed only to prevent gcc warnings. */ Tcl_Obj *tmpPtr, *eltPtr; - int i, size, len; + int i; + size_t size, len; char *p; const char *str; @@ -977,7 +977,8 @@ Tcl_JoinPath( const char *const *argv, Tcl_DString *resultPtr) /* Pointer to previously initialized DString */ { - int i, len; + int i; + size_t len; Tcl_Obj *listObj = Tcl_NewObj(); Tcl_Obj *resultObj; const char *resultStr; @@ -1250,7 +1251,7 @@ Tcl_GlobObjCmd( for (i = 1; i < objc; i++) { if (Tcl_GetIndexFromObj(interp, objv[i], options, "option", 0, &index) != TCL_OK) { - string = TclGetStringFromObj(objv[i], &length); + string = TclGetString(objv[i]); if (string[0] == '-') { /* * It looks like the command contains an option so signal an @@ -1356,7 +1357,7 @@ Tcl_GlobObjCmd( } if (dir == PATH_GENERAL) { - int pathlength; + size_t pathlength; const char *last; const char *first = TclGetStringFromObj(pathOrDir,&pathlength); @@ -1982,7 +1983,7 @@ TclGlob( if (globFlags & TCL_GLOBMODE_TAILS) { int objc, i; Tcl_Obj **objv; - int prefixLen; + size_t prefixLen; const char *pre; /* @@ -2010,7 +2011,7 @@ TclGlob( Tcl_ListObjGetElements(NULL, filenamesObj, &objc, &objv); for (i = 0; i< objc; i++) { - int len; + size_t len; const char *oldStr = TclGetStringFromObj(objv[i], &len); Tcl_Obj *elem; @@ -2359,7 +2360,7 @@ DoGlob( Tcl_ListObjLength(NULL, matchesObj, &end); while (repair < end) { const char *bytes; - int numBytes; + size_t numBytes; Tcl_Obj *fixme, *newObj; Tcl_ListObjIndex(NULL, matchesObj, repair, &fixme); @@ -2446,7 +2447,7 @@ DoGlob( * The current prefix must end in a separator. */ - int len; + size_t len; const char *joined = TclGetStringFromObj(joinedPtr,&len); if (strchr(separators, joined[len-1]) == NULL) { @@ -2483,7 +2484,7 @@ DoGlob( * This behaviour is not currently tested for in the test suite. */ - int len; + size_t len; const char *joined = TclGetStringFromObj(joinedPtr,&len); if (strchr(separators, joined[len-1]) == NULL) { diff --git a/generic/tclIORTrans.c b/generic/tclIORTrans.c index 678fcc1..6ff466f 100644 --- a/generic/tclIORTrans.c +++ b/generic/tclIORTrans.c @@ -89,8 +89,8 @@ static const Tcl_ChannelType tclRTransformType = { typedef struct { unsigned char *buf; /* Reference to the buffer area. */ - int allocated; /* Allocated size of the buffer area. */ - int used; /* Number of bytes in the buffer, + size_t allocated; /* Allocated size of the buffer area. */ + size_t used; /* Number of bytes in the buffer, * <= allocated. */ } ResultBuffer; @@ -270,7 +270,7 @@ struct ForwardParamTransform { ForwardParamBase base; /* "Supertype". MUST COME FIRST. */ char *buf; /* I: Bytes to transform, * O: Bytes in transform result */ - int size; /* I: #bytes to transform, + size_t size; /* I: #bytes to transform, * O: #bytes in the transform result */ }; struct ForwardParamLimit { @@ -2590,7 +2590,7 @@ ForwardProc( if (InvokeTclMethod(rtPtr, "read", bufObj, NULL, &resObj) != TCL_OK) { ForwardSetObjError(paramPtr, resObj); - paramPtr->transform.size = -1; + paramPtr->transform.size = TCL_AUTO_LENGTH; } else { /* * Process a regular return. Contains the transformation result. @@ -2624,7 +2624,7 @@ ForwardProc( if (InvokeTclMethod(rtPtr, "write", bufObj, NULL, &resObj) != TCL_OK) { ForwardSetObjError(paramPtr, resObj); - paramPtr->transform.size = -1; + paramPtr->transform.size = TCL_AUTO_LENGTH; } else { /* * Process a regular return. Contains the transformation result. @@ -2654,7 +2654,7 @@ ForwardProc( case ForwardedDrain: if (InvokeTclMethod(rtPtr, "drain", NULL, NULL, &resObj) != TCL_OK) { ForwardSetObjError(paramPtr, resObj); - paramPtr->transform.size = -1; + paramPtr->transform.size = TCL_AUTO_LENGTH; } else { /* * Process a regular return. Contains the transformation result. @@ -2680,7 +2680,7 @@ ForwardProc( case ForwardedFlush: if (InvokeTclMethod(rtPtr, "flush", NULL, NULL, &resObj) != TCL_OK) { ForwardSetObjError(paramPtr, resObj); - paramPtr->transform.size = -1; + paramPtr->transform.size = TCL_AUTO_LENGTH; } else { /* * Process a regular return. Contains the transformation result. @@ -3037,7 +3037,7 @@ ResultCopy( */ copied = 0; - } else if (rPtr->used == toRead) { + } else if (rPtr->used == (size_t)toRead) { /* * We have just enough. Copy everything to the caller. */ @@ -3045,7 +3045,7 @@ ResultCopy( memcpy(buf, rPtr->buf, toRead); rPtr->used = 0; copied = toRead; - } else if (rPtr->used > toRead) { + } else if (rPtr->used > (size_t)toRead) { /* * The internal buffer contains more than requested. Copy the * requested subset to the caller, and shift the remaining bytes down. diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index 3a6233a..cb4f09a 100644 --- a/generic/tclIOUtil.c +++ b/generic/tclIOUtil.c @@ -539,7 +539,7 @@ TclFSCwdPointerEquals( if (tsdPtr->cwdPathPtr == *pathPtrPtr) { return 1; } else { - int len1, len2; + size_t len1, len2; const char *str1, *str2; str1 = TclGetStringFromObj(tsdPtr->cwdPathPtr, &len1); @@ -1203,7 +1203,7 @@ FsAddMountsToGlobResult( } if (!found && dir) { Tcl_Obj *norm; - int len, mlen; + size_t len, mlen; /* * We know mElt is absolute normalized and lies inside pathPtr, so @@ -1390,7 +1390,7 @@ TclFSNormalizeToUniquePath( { FilesystemRecord *fsRecPtr, *firstFsRecPtr; - int i; + size_t i; int isVfsPath = 0; char *path; @@ -1403,7 +1403,7 @@ TclFSNormalizeToUniquePath( * We check these first to avoid useless calls to the native filesystem's * normalizePathProc. */ - path = Tcl_GetStringFromObj(pathPtr, &i); + path = TclGetStringFromObj(pathPtr, &i); if ( (i >= 3) && ( (path[0] == '/' && path[1] == '/') || (path[0] == '\\' && path[1] == '\\') ) ) { diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c index db267de..8c2b694 100644 --- a/generic/tclIndexObj.c +++ b/generic/tclIndexObj.c @@ -634,7 +634,8 @@ PrefixAllObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - int tableObjc, result, t, length, elemLength; + int tableObjc, result, t; + size_t length, elemLength; const char *string, *elemString; Tcl_Obj **tableObjv, *resultPtr; @@ -691,7 +692,8 @@ PrefixLongestObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - int tableObjc, result, i, t, length, elemLength, resultLength; + int tableObjc, result, t; + size_t i, length, elemLength, resultLength; const char *string, *elemString, *resultString; Tcl_Obj **tableObjv; diff --git a/generic/tclInt.h b/generic/tclInt.h index ecc1ab2..ff297d0 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -2434,7 +2434,7 @@ typedef struct List { #define TclGetLongFromObj(interp, objPtr, longPtr) \ (((objPtr)->typePtr == &tclIntType \ && (objPtr)->internalRep.wideValue >= (Tcl_WideInt)(LONG_MIN) \ - && (objPtr)->internalRep.wideValue <= (Tcl_WideInt)(LONG_MAX)) \ + && (objPtr)->internalRep.wideValue <= (Tcl_WideInt)(LONG_MAX)) \ ? ((*(longPtr) = (long)(objPtr)->internalRep.wideValue), TCL_OK) \ : Tcl_GetLongFromObj((interp), (objPtr), (longPtr))) #endif @@ -2442,25 +2442,15 @@ typedef struct List { #define TclGetIntFromObj(interp, objPtr, intPtr) \ (((objPtr)->typePtr == &tclIntType \ && (objPtr)->internalRep.wideValue >= (Tcl_WideInt)(INT_MIN) \ - && (objPtr)->internalRep.wideValue <= (Tcl_WideInt)(INT_MAX)) \ + && (objPtr)->internalRep.wideValue <= (Tcl_WideInt)(INT_MAX)) \ ? ((*(intPtr) = (int)(objPtr)->internalRep.wideValue), TCL_OK) \ : Tcl_GetIntFromObj((interp), (objPtr), (intPtr))) #define TclGetIntForIndexM(interp, objPtr, endValue, idxPtr) \ (((objPtr)->typePtr == &tclIntType \ - && (objPtr)->internalRep.wideValue >= -1 \ - && (objPtr)->internalRep.wideValue <= INT_MAX) \ - ? ((*(idxPtr) = (size_t)(objPtr)->internalRep.wideValue), TCL_OK) \ + && (objPtr)->internalRep.wideValue <= (Tcl_WideInt)(INT_MAX)) \ + ? ((*(idxPtr) = ((objPtr)->internalRep.wideValue >= 0) \ + ? (size_t)(objPtr)->internalRep.wideValue : TCL_INDEX_NONE), TCL_OK) \ : TclGetIntForIndex((interp), (objPtr), (endValue), (idxPtr))) -/* TODO: Eliminate TclGetIntForIndex2() and TclGetIntForIndex2() usage everywhere */ -MODULE_SCOPE int TclGetIntForIndex2(Tcl_Interp *interp, - Tcl_Obj *objPtr, size_t endValue, - int *indexPtr); -#define TclGetIntForIndexM2(interp, objPtr, endValue, idxPtr) \ - (((objPtr)->typePtr == &tclIntType \ - && (objPtr)->internalRep.wideValue >= -1 \ - && (objPtr)->internalRep.wideValue <= INT_MAX) \ - ? ((*(idxPtr) = (int)(objPtr)->internalRep.wideValue), TCL_OK) \ - : TclGetIntForIndex2((interp), (objPtr), (endValue), (idxPtr))) /* * Macro used to save a function call for common uses of @@ -4912,10 +4902,10 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit; } while (0) #endif /* TCL_MEM_DEBUG */ -/* - * Macros to convert size_t to wide-int (and wide-int object) considering - * platform-related negative value ((size_t)-1), if wide-int and size_t - * have different dimensions (e. g. 32-bit platform). +/* + * Macros to convert size_t to wide-int (and wide-int object) considering + * platform-related negative value ((size_t)-1), if wide-int and size_t + * have different dimensions (e. g. 32-bit platform). */ #if (!defined(TCL_WIDE_INT_IS_LONG) || (LONG_MAX > UINT_MAX)) && (SIZE_MAX <= UINT_MAX) diff --git a/generic/tclListObj.c b/generic/tclListObj.c index a8b95a8..eb7290e 100644 --- a/generic/tclListObj.c +++ b/generic/tclListObj.c @@ -536,9 +536,10 @@ Tcl_ListObjGetElements( ListGetIntRep(listPtr, listRepPtr); if (listRepPtr == NULL) { - int result, length; + int result; + size_t length; - (void) Tcl_GetStringFromObj(listPtr, &length); + (void) TclGetStringFromObj(listPtr, &length); if (length == 0) { *objcPtr = 0; *objvPtr = NULL; @@ -659,9 +660,10 @@ Tcl_ListObjAppendElement( ListGetIntRep(listPtr, listRepPtr); if (listRepPtr == NULL) { - int result, length; + int result; + size_t length; - (void) Tcl_GetStringFromObj(listPtr, &length); + (void) TclGetStringFromObj(listPtr, &length); if (length == 0) { Tcl_SetListObj(listPtr, 1, &objPtr); return TCL_OK; @@ -833,9 +835,10 @@ Tcl_ListObjIndex( ListGetIntRep(listPtr, listRepPtr); if (listRepPtr == NULL) { - int result, length; + int result; + size_t length; - (void) Tcl_GetStringFromObj(listPtr, &length); + (void) TclGetStringFromObj(listPtr, &length); if (length == 0) { *objPtrPtr = NULL; return TCL_OK; @@ -889,9 +892,10 @@ Tcl_ListObjLength( ListGetIntRep(listPtr, listRepPtr); if (listRepPtr == NULL) { - int result, length; + int result; + size_t length; - (void) Tcl_GetStringFromObj(listPtr, &length); + (void) TclGetStringFromObj(listPtr, &length); if (length == 0) { *intPtr = 0; return TCL_OK; @@ -1777,9 +1781,10 @@ TclListObjSetElement( ListGetIntRep(listPtr, listRepPtr); if (listRepPtr == NULL) { - int result, length; + int result; + size_t length; - (void) Tcl_GetStringFromObj(listPtr, &length); + (void) TclGetStringFromObj(listPtr, &length); if (length == 0) { if (interp != NULL) { Tcl_SetObjResult(interp, @@ -2013,7 +2018,8 @@ SetListFromAny( Tcl_DictObjNext(&search, &keyPtr, &valuePtr, &done); } } else { - int estCount, length; + int estCount; + size_t length; const char *limit, *nextElem = TclGetStringFromObj(objPtr, &length); /* diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 715dbc1..084e2b0 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -651,8 +651,8 @@ Tcl_GetRange( String *stringPtr; size_t length; - if (first == TCL_AUTO_LENGTH) { - first = 0; + if (first == TCL_INDEX_NONE) { + first = TCL_INDEX_START; } if (last + 2 <= first + 1) { return Tcl_NewObj(); diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 0c811ed..e81dce7 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -3640,7 +3640,7 @@ TclGetIntForIndex( Tcl_WideInt wide; /* Use platform-related size_t to wide-int to consider negative value - * ((size_t)-1) if wide-int and size_t have different dimensions. */ + * TCL_INDEX_NONE if wide-int and size_t have different dimensions. */ if (GetWideForIndex(interp, objPtr, endValue, &wide) == TCL_ERROR) { return TCL_ERROR; } @@ -3653,35 +3653,6 @@ TclGetIntForIndex( } return TCL_OK; } - -int -TclGetIntForIndex2( - Tcl_Interp *interp, /* Interpreter to use for error reporting. If - * NULL, then no error message is left after - * errors. */ - Tcl_Obj *objPtr, /* Points to an object containing either "end" - * or an integer. */ - size_t endValue, /* The value to be stored at "indexPtr" if - * "objPtr" holds "end". */ - int *indexPtr) /* Location filled in with an integer - * representing an index. */ -{ - Tcl_WideInt wide; - - /* Use platform-related size_t to wide-int to consider negative value - * ((size_t)-1) if wide-int and size_t have different dimensions. */ - if (GetWideForIndex(interp, objPtr, endValue, &wide) == TCL_ERROR) { - return TCL_ERROR; - } - if (wide < 0) { - *indexPtr = -1; - } else if (wide > INT_MAX) { - *indexPtr = INT_MAX; - } else { - *indexPtr = (int) wide; - } - return TCL_OK; -} /* *---------------------------------------------------------------------- * @@ -3772,7 +3743,7 @@ GetEndOffsetFromObj( offset = irPtr->wideValue; - if (endValue == (size_t)-1) { + if (endValue == TCL_INDEX_NONE) { *widePtr = offset - 1; } else if (offset < 0) { /* Different signs, sum cannot overflow */ @@ -3921,10 +3892,13 @@ TclIndexDecode( int encoded, /* Value to decode */ size_t endValue) /* Meaning of "end" to use, > TCL_INDEX_END */ { - if (encoded <= (int)TCL_INDEX_END) { + if (encoded > (int)TCL_INDEX_END) { + return encoded; + } + if (endValue >= TCL_INDEX_END - encoded) { return endValue + encoded - TCL_INDEX_END; } - return (size_t) encoded; + return TCL_INDEX_NONE; } /* diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index c9a58df..4ea8124 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -3075,8 +3075,8 @@ ZipFSListObjCmd( return TCL_ERROR; } if (objc == 3) { - int n; - char *what = Tcl_GetStringFromObj(objv[1], &n); + size_t n; + char *what = TclGetStringFromObj(objv[1], &n); if ((n >= 2) && (strncmp(what, "-glob", n) == 0)) { pattern = Tcl_GetString(objv[2]); @@ -4045,13 +4045,11 @@ ZipFSOpenFileChannelProc( int mode, int permissions) { - int len; - pathPtr = Tcl_FSGetNormalizedPath(NULL, pathPtr); if (!pathPtr) { return NULL; } - return ZipChannelOpen(interp, Tcl_GetStringFromObj(pathPtr, &len), mode, + return ZipChannelOpen(interp, TclGetString(pathPtr), mode, permissions); } @@ -4077,13 +4075,12 @@ ZipFSStatProc( Tcl_Obj *pathPtr, Tcl_StatBuf *buf) { - int len; pathPtr = Tcl_FSGetNormalizedPath(NULL, pathPtr); if (!pathPtr) { return -1; } - return ZipEntryStat(Tcl_GetStringFromObj(pathPtr, &len), buf); + return ZipEntryStat(TclGetString(pathPtr), buf); } /* @@ -4108,13 +4105,11 @@ ZipFSAccessProc( Tcl_Obj *pathPtr, int mode) { - int len; - pathPtr = Tcl_FSGetNormalizedPath(NULL, pathPtr); if (!pathPtr) { return -1; } - return ZipEntryAccess(Tcl_GetStringFromObj(pathPtr, &len), mode); + return ZipEntryAccess(TclGetString(pathPtr), mode); } /* @@ -4173,8 +4168,8 @@ ZipFSMatchInDirectoryProc( Tcl_HashEntry *hPtr; Tcl_HashSearch search; Tcl_Obj *normPathPtr = Tcl_FSGetNormalizedPath(NULL, pathPtr); - int scnt, l, dirOnly = -1, prefixLen, strip = 0; - size_t len; + int scnt, l, dirOnly = -1, strip = 0; + size_t len, prefixLen; char *pat, *prefix, *path; Tcl_DString dsPref; @@ -4189,7 +4184,7 @@ ZipFSMatchInDirectoryProc( * The prefix that gets prepended to results. */ - prefix = Tcl_GetStringFromObj(pathPtr, &prefixLen); + prefix = TclGetStringFromObj(pathPtr, &prefixLen); /* * The (normalized) path we're searching. @@ -4493,7 +4488,7 @@ ZipFSFileAttrsGetProc( Tcl_Obj *pathPtr, Tcl_Obj **objPtrRef) { - int len, ret = TCL_OK; + int ret = TCL_OK; char *path; ZipEntry *z; @@ -4501,7 +4496,7 @@ ZipFSFileAttrsGetProc( if (!pathPtr) { return -1; } - path = Tcl_GetStringFromObj(pathPtr, &len); + path = Tcl_GetString(pathPtr); ReadLock(); z = ZipFSLookup(path); if (!z) { diff --git a/generic/tclZlib.c b/generic/tclZlib.c index b561ce9..b70603e 100644 --- a/generic/tclZlib.c +++ b/generic/tclZlib.c @@ -185,7 +185,7 @@ static int GenerateHeader(Tcl_Interp *interp, Tcl_Obj *dictObj, static int ZlibPushSubcmd(Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static inline int ResultCopy(ZlibChannelData *cd, char *buf, - int toRead); + size_t toRead); static int ResultGenerate(ZlibChannelData *cd, int n, int flush, int *errorCodePtr); static Tcl_Channel ZlibStackChannelTransform(Tcl_Interp *interp, @@ -3740,9 +3740,9 @@ static inline int ResultCopy( ZlibChannelData *cd, /* The location of the buffer to read from. */ char *buf, /* The buffer to copy into */ - int toRead) /* Number of requested bytes */ + size_t toRead) /* Number of requested bytes */ { - int have = Tcl_DStringLength(&cd->decompressed); + size_t have = Tcl_DStringLength(&cd->decompressed); if (have == 0) { /* @@ -4003,7 +4003,7 @@ int Tcl_ZlibStreamGet( Tcl_ZlibStream zshandle, Tcl_Obj *data, - int count) + size_t count) { return TCL_OK; } @@ -4041,7 +4041,7 @@ Tcl_ZlibInflate( unsigned int Tcl_ZlibCRC32( unsigned int crc, - const char *buf, + const unsigned char *buf, size_t len) { return 0; @@ -4050,7 +4050,7 @@ Tcl_ZlibCRC32( unsigned int Tcl_ZlibAdler32( unsigned int adler, - const char *buf, + const unsigned char *buf, size_t len) { return 0; diff --git a/tests/cmdIL.test b/tests/cmdIL.test index 360d6b0..e4931a4 100644 --- a/tests/cmdIL.test +++ b/tests/cmdIL.test @@ -232,7 +232,7 @@ test cmdIL-3.5.3 {SortCompare procedure, -index option (out of range, calculated } -returnCodes error -result {index "-2" cannot select an element from any list} test cmdIL-3.5.4 {SortCompare procedure, -index option (out of range, calculated index)} -body { lsort -index end-4 {{1 . c} {2 . b} {3 . a}} -} -returnCodes error -result {element -2 missing from sublist "1 . c"} +} -returnCodes error -result {element end-4 missing from sublist "1 . c"} test cmdIL-3.5.5 {SortCompare procedure, -index option} { lsort -index {} {a b} } {a b} @@ -248,6 +248,9 @@ test cmdIL-3.5.8 {SortCompare procedure, -index option (out of range, calculated test cmdIL-3.5.9 {SortCompare procedure, -index option (out of range, calculated index)} -body { lsort -index end+2 {{1 . c} {2 . b} {3 . a}} } -returnCodes error -result {index "end+2" cannot select an element from any list} +test cmdIL-3.5.10 {SortCompare procedure, -index option (out of range, calculated index)} -body { + lsort -index 0 {{}} +} -returnCodes error -result {element 0 missing from sublist ""} test cmdIL-3.6 {SortCompare procedure, -index option} { lsort -integer -index 2 {{1 15 30} {2 5 25} {3 25 20}} } {{3 25 20} {2 5 25} {1 15 30}} |