diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-09-18 14:11:05 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-09-18 14:11:05 (GMT) |
commit | b52d1ad00a9abb3ad9b0b89a71fd6d3d969679c0 (patch) | |
tree | a48131dbe292a945c46f434b0cfd535ac75a7948 /generic/tclCmdMZ.c | |
parent | 69ca53fb44da71d3f9dc902324395732f403d3d7 (diff) | |
download | tcl-b52d1ad00a9abb3ad9b0b89a71fd6d3d969679c0.zip tcl-b52d1ad00a9abb3ad9b0b89a71fd6d3d969679c0.tar.gz tcl-b52d1ad00a9abb3ad9b0b89a71fd6d3d969679c0.tar.bz2 |
int -> Tcl_Size (where appropriate). Make TclStringCmpOpts() static
Diffstat (limited to 'generic/tclCmdMZ.c')
-rw-r--r-- | generic/tclCmdMZ.c | 299 |
1 files changed, 162 insertions, 137 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 0b0f68a..c1b6044 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -29,6 +29,9 @@ static Tcl_NRPostProc TryPostFinal; static Tcl_NRPostProc TryPostHandler; static int UniCharIsAscii(int character); static int UniCharIsHexDigit(int character); +static int StringCmpOpts(Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[], int *nocase, + Tcl_Size *reqlength); /* * Default set of characters to trim in [string trim] and friends. This is a @@ -82,7 +85,7 @@ const char tclDefaultTrimSet[] = int Tcl_PwdObjCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -122,13 +125,13 @@ Tcl_PwdObjCmd( int Tcl_RegexpObjCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - int i, indices, match, about, offset, all, doinline, numMatchesSaved; - int cflags, eflags, stringLength, matchLength; + Tcl_Size offset, stringLength, matchLength, cflags, eflags; + int i, indices, match, about, all, doinline, numMatchesSaved; Tcl_RegExp regExpr; Tcl_Obj *objPtr, *startIndex = NULL, *resultPtr = NULL; Tcl_RegExpInfo info; @@ -191,11 +194,11 @@ Tcl_RegexpObjCmd( cflags |= TCL_REG_NLANCH; break; case REGEXP_START: { - int temp; + Tcl_Size temp; if (++i >= objc) { goto endOfForLoop; } - if (TclGetIntForIndexM(interp, objv[i], INT_MAX - 1, &temp) != TCL_OK) { + if (TclGetIntForIndexM(interp, objv[i], TCL_SIZE_MAX - 1, &temp) != TCL_OK) { goto optionError; } if (startIndex) { @@ -364,7 +367,7 @@ Tcl_RegexpObjCmd( Tcl_Obj *newPtr; if (indices) { - int start, end; + Tcl_Size start, end; Tcl_Obj *objs[2]; /* @@ -482,13 +485,14 @@ Tcl_RegexpObjCmd( int Tcl_RegsubObjCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - int idx, result, cflags, all, wlen, wsublen, numMatches, offset; - int start, end, subStart, subEnd, match, command, numParts; + int result, cflags, all, match, command; + Tcl_Size idx, wlen, wsublen, offset, numMatches, numParts; + Tcl_Size start, end, subStart, subEnd; Tcl_RegExp regExpr; Tcl_RegExpInfo info; Tcl_Obj *resultPtr, *subPtr, *objPtr, *startIndex = NULL; @@ -546,11 +550,11 @@ Tcl_RegsubObjCmd( cflags |= TCL_REG_NLANCH; break; case REGSUB_START: { - int temp; + Tcl_Size temp; if (++idx >= objc) { goto endOfForLoop; } - if (TclGetIntForIndexM(interp, objv[idx], INT_MAX - 1, &temp) != TCL_OK) { + if (TclGetIntForIndexM(interp, objv[idx], TCL_SIZE_MAX - 1, &temp) != TCL_OK) { goto optionError; } if (startIndex) { @@ -567,7 +571,7 @@ Tcl_RegsubObjCmd( } endOfForLoop: - if (objc-idx < 3 || objc-idx > 4) { + if (objc < idx + 3 || objc > idx + 4) { Tcl_WrongNumArgs(interp, 1, objv, "?-option ...? exp string subSpec ?varName?"); optionError: @@ -581,7 +585,7 @@ Tcl_RegsubObjCmd( objv += idx; if (startIndex) { - int stringLength = TclGetCharLength(objv[1]); + Tcl_Size stringLength = TclGetCharLength(objv[1]); TclGetIntForIndexM(interp, startIndex, stringLength, &offset); Tcl_DecrRefCount(startIndex); @@ -598,7 +602,8 @@ Tcl_RegsubObjCmd( * slightly modified version of the one pair STR_MAP code. */ - int slen, nocase, wsrclc; + Tcl_Size slen; + int nocase, wsrclc; int (*strCmpFn)(const Tcl_UniChar*,const Tcl_UniChar*,unsigned long); Tcl_UniChar *p; @@ -774,7 +779,7 @@ Tcl_RegsubObjCmd( if (command) { Tcl_Obj **args = NULL, **parts; - int numArgs; + Tcl_Size numArgs; TclListObjGetElementsM(interp, subPtr, &numParts, &parts); numArgs = numParts + info.nsubs + 1; @@ -1002,7 +1007,7 @@ Tcl_RegsubObjCmd( int Tcl_RenameObjCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -1038,7 +1043,7 @@ Tcl_RenameObjCmd( int Tcl_ReturnObjCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -1085,7 +1090,7 @@ Tcl_ReturnObjCmd( int Tcl_SourceObjCmd( - ClientData clientData, + void *clientData, Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -1095,7 +1100,7 @@ Tcl_SourceObjCmd( int TclNRSourceObjCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -1169,7 +1174,7 @@ TclNRSourceObjCmd( int Tcl_SplitObjCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -1179,7 +1184,7 @@ Tcl_SplitObjCmd( const char *splitChars; const char *stringPtr; const char *end; - int splitCharLen, stringLen; + Tcl_Size splitCharLen, stringLen; Tcl_Obj *listPtr, *objPtr; if (objc == 2) { @@ -1243,7 +1248,7 @@ Tcl_SplitObjCmd( * byte in length. */ - while (*stringPtr && (p=strchr(stringPtr,(int)*splitChars)) != NULL) { + while (*stringPtr && (p=strchr(stringPtr,*splitChars)) != NULL) { objPtr = Tcl_NewStringObj(stringPtr, p - stringPtr); Tcl_ListObjAppendElement(NULL, listPtr, objPtr); stringPtr = p + 1; @@ -1252,7 +1257,7 @@ Tcl_SplitObjCmd( Tcl_ListObjAppendElement(NULL, listPtr, objPtr); } else { const char *element, *p, *splitEnd; - int splitLen; + Tcl_Size splitLen; int splitChar; /* @@ -1302,12 +1307,12 @@ Tcl_SplitObjCmd( static int StringFirstCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - int start = 0; + Tcl_Size start = 0; if (objc < 3 || objc > 4) { Tcl_WrongNumArgs(interp, 1, objv, @@ -1316,9 +1321,9 @@ StringFirstCmd( } if (objc == 4) { - int size = TclGetCharLength(objv[2]); + Tcl_Size end = TclGetCharLength(objv[2]) - 1; - if (TCL_OK != TclGetIntForIndexM(interp, objv[3], size - 1, &start)) { + if (TCL_OK != TclGetIntForIndexM(interp, objv[3], end, &start)) { return TCL_ERROR; } } @@ -1346,12 +1351,12 @@ StringFirstCmd( static int StringLastCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - int last = INT_MAX - 1; + Tcl_Size last = TCL_SIZE_MAX; if (objc < 3 || objc > 4) { Tcl_WrongNumArgs(interp, 1, objv, @@ -1360,9 +1365,9 @@ StringLastCmd( } if (objc == 4) { - int size = TclGetCharLength(objv[2]); + Tcl_Size end = TclGetCharLength(objv[2]) - 1; - if (TCL_OK != TclGetIntForIndexM(interp, objv[3], size - 1, &last)) { + if (TCL_OK != TclGetIntForIndexM(interp, objv[3], end, &last)) { return TCL_ERROR; } } @@ -1390,12 +1395,12 @@ StringLastCmd( static int StringIndexCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - int length, index; + Tcl_Size index, end; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "string charIndex"); @@ -1406,12 +1411,12 @@ StringIndexCmd( * Get the char length to calculate what 'end' means. */ - length = TclGetCharLength(objv[1]); - if (TclGetIntForIndexM(interp, objv[2], length-1, &index) != TCL_OK) { + end = TclGetCharLength(objv[1]) - 1; + if (TclGetIntForIndexM(interp, objv[2], end, &index) != TCL_OK) { return TCL_ERROR; } - if ((index >= 0) && (index < length)) { + if ((index >= 0) && (index <= end)) { int ch = TclGetUniChar(objv[1], index); if (ch == -1) { @@ -1430,11 +1435,11 @@ StringIndexCmd( } else { char buf[4] = ""; - length = Tcl_UniCharToUtf(ch, buf); - if ((ch >= 0xD800) && (length < 3)) { - length += Tcl_UniCharToUtf(-1, buf + length); + end = Tcl_UniCharToUtf(ch, buf); + if ((ch >= 0xD800) && (end < 3)) { + end += Tcl_UniCharToUtf(-1, buf + end); } - Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, length)); + Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, end)); } } return TCL_OK; @@ -1460,13 +1465,13 @@ StringIndexCmd( static int StringInsertCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter */ int objc, /* Number of arguments */ Tcl_Obj *const objv[]) /* Argument objects */ { - int length; /* String length */ - int index; /* Insert index */ + Tcl_Size length; /* String length */ + Tcl_Size index; /* Insert index */ Tcl_Obj *outObj; /* Output object */ if (objc != 4) { @@ -1517,7 +1522,7 @@ StringInsertCmd( static int StringIsCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -1630,7 +1635,8 @@ StringIsCmd( chcomp = Tcl_UniCharIsControl; break; case STR_IS_DICT: { - int dresult, dsize; + int dresult; + Tcl_Size dsize; dresult = Tcl_DictObjSize(interp, objPtr, &dsize); Tcl_ResetResult(interp); @@ -1643,7 +1649,7 @@ StringIsCmd( */ const char *elemStart, *nextElem; - int lenRemain, elemSize; + Tcl_Size lenRemain, elemSize; const char *p; string1 = TclGetStringFromObj(objPtr, &length1); @@ -1694,7 +1700,7 @@ StringIsCmd( goto str_is_done; } end = string1 + length1; - if (TclParseNumber(NULL, objPtr, NULL, NULL, -1, + if (TclParseNumber(NULL, objPtr, NULL, NULL, TCL_INDEX_NONE, (const char **) &stop, 0) != TCL_OK) { result = 0; failat = 0; @@ -1724,7 +1730,7 @@ StringIsCmd( goto str_is_done; } end = string1 + length1; - if (TclParseNumber(NULL, objPtr, NULL, NULL, -1, + if (TclParseNumber(NULL, objPtr, NULL, NULL, TCL_INDEX_NONE, (const char **) &stop, TCL_PARSE_INTEGER_ONLY) == TCL_OK) { if (stop == end) { /* @@ -1775,7 +1781,7 @@ StringIsCmd( break; } end = string1 + length1; - if (TclParseNumber(NULL, objPtr, NULL, NULL, -1, + if (TclParseNumber(NULL, objPtr, NULL, NULL, TCL_INDEX_NONE, (const char **) &stop, TCL_PARSE_INTEGER_ONLY) == TCL_OK) { if (stop == end) { /* @@ -1823,7 +1829,7 @@ StringIsCmd( */ const char *elemStart, *nextElem; - int lenRemain, elemSize; + Tcl_Size lenRemain, elemSize; const char *p; string1 = TclGetStringFromObj(objPtr, &length1); @@ -1953,12 +1959,12 @@ UniCharIsHexDigit( static int StringMapCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - int length1, length2, mapElemc, index; + Tcl_Size length1, length2, mapElemc, index; int nocase = 0, mapWithDict = 0, copySource = 0; Tcl_Obj **mapElemv, *sourceObj, *resultPtr; Tcl_UniChar *ustring1, *ustring2, *p, *end; @@ -2086,7 +2092,8 @@ StringMapCmd( * larger strings. */ - int mapLen, u2lc; + Tcl_Size mapLen; + int u2lc; Tcl_UniChar *mapString; ustring2 = TclGetUnicodeFromObj(mapElemv[0], &length2); @@ -2119,7 +2126,8 @@ StringMapCmd( } } else { Tcl_UniChar **mapStrings; - int *mapLens, *u2lc = NULL; + Tcl_Size *mapLens; + int *u2lc = NULL; /* * Precompute pointers to the Unicode string and length. This saves us @@ -2128,8 +2136,8 @@ StringMapCmd( * case. */ - mapStrings = (Tcl_UniChar **)TclStackAlloc(interp, mapElemc*2*sizeof(Tcl_UniChar *)); - mapLens = (int *)TclStackAlloc(interp, mapElemc * 2 * sizeof(int)); + mapStrings = (Tcl_UniChar **)TclStackAlloc(interp, mapElemc*sizeof(Tcl_UniChar *)*2); + mapLens = (Tcl_Size *)TclStackAlloc(interp, mapElemc * sizeof(Tcl_Size) * 2); if (nocase) { u2lc = (int *)TclStackAlloc(interp, mapElemc * sizeof(int)); } @@ -2224,7 +2232,7 @@ StringMapCmd( static int StringMatchCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -2237,7 +2245,7 @@ StringMatchCmd( } if (objc == 4) { - int length; + Tcl_Size length; const char *string = TclGetStringFromObj(objv[1], &length); if ((length > 1) && @@ -2276,12 +2284,12 @@ StringMatchCmd( static int StringRangeCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - int length, first, last; + Tcl_Size first, last, end; if (objc != 4) { Tcl_WrongNumArgs(interp, 1, objv, "string first last"); @@ -2293,10 +2301,10 @@ StringRangeCmd( * 'end' refers to the last character, not one past it. */ - length = TclGetCharLength(objv[1]) - 1; + end = TclGetCharLength(objv[1]) - 1; - if (TclGetIntForIndexM(interp, objv[2], length, &first) != TCL_OK || - TclGetIntForIndexM(interp, objv[3], length, &last) != TCL_OK) { + if (TclGetIntForIndexM(interp, objv[2], end, &first) != TCL_OK || + TclGetIntForIndexM(interp, objv[3], end, &last) != TCL_OK) { return TCL_ERROR; } @@ -2326,7 +2334,7 @@ StringRangeCmd( static int StringReptCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -2382,20 +2390,19 @@ StringReptCmd( static int StringRplcCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - int first, last, length, end; + Tcl_Size first, last, end; if (objc < 4 || objc > 5) { Tcl_WrongNumArgs(interp, 1, objv, "string first last ?string?"); return TCL_ERROR; } - length = TclGetCharLength(objv[1]); - end = length - 1; + end = Tcl_GetCharLength(objv[1]) - 1; if (TclGetIntForIndexM(interp, objv[2], end, &first) != TCL_OK || TclGetIntForIndexM(interp, objv[3], end, &last) != TCL_OK) { @@ -2411,7 +2418,6 @@ StringRplcCmd( if ((last < 0) || /* Range ends before start of string */ (first > end) || /* Range begins after end of string */ (last < first)) { /* Range begins after it starts */ - /* * BUT!!! when (end < 0) -- an empty original string -- we can * have (first <= end < 0 <= last) and an empty string is permitted @@ -2433,6 +2439,9 @@ StringRplcCmd( last + 1 - first, (objc == 5) ? objv[4] : NULL, TCL_STRING_IN_PLACE); + if (resultPtr == NULL) { + return TCL_ERROR; + } Tcl_SetObjResult(interp, resultPtr); } return TCL_OK; @@ -2458,7 +2467,7 @@ StringRplcCmd( static int StringRevCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -2491,14 +2500,14 @@ StringRevCmd( static int StringStartCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { int ch; const Tcl_UniChar *p, *string; - int cur, index, length; + Tcl_Size cur, index, length; Tcl_Obj *obj; if (objc != 3) { @@ -2518,7 +2527,7 @@ StringStartCmd( p = &string[index]; ch = *p; - for (cur = index; cur >= 0; cur--) { + for (cur = index; cur != TCL_INDEX_NONE; cur--) { int delta = 0; const Tcl_UniChar *next; @@ -2562,14 +2571,14 @@ StringStartCmd( static int StringEndCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { int ch; const Tcl_UniChar *p, *end, *string; - int cur, index, length; + Tcl_Size cur, index, length; Tcl_Obj *obj; if (objc != 3) { @@ -2624,7 +2633,7 @@ StringEndCmd( static int StringEqualCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -2636,7 +2645,9 @@ StringEqualCmd( */ const char *string2; - int length, i, match, nocase = 0, reqlength = -1; + int i, match, nocase = 0; + Tcl_Size length; + Tcl_WideInt reqlength = -1; if (objc < 3 || objc > 6) { str_cmp_args: @@ -2655,9 +2666,12 @@ StringEqualCmd( goto str_cmp_args; } i++; - if (TclGetIntFromObj(interp, objv[i], &reqlength) != TCL_OK) { + if (Tcl_GetWideIntFromObj(interp, objv[i], &reqlength) != TCL_OK) { return TCL_ERROR; } + if ((Tcl_WideUInt)reqlength > TCL_SIZE_MAX) { + reqlength = -1; + } } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad option \"%s\": must be -nocase or -length", @@ -2699,7 +2713,7 @@ StringEqualCmd( static int StringCmpCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -2710,9 +2724,10 @@ StringCmpCmd( * the expr string comparison in INST_EQ/INST_NEQ/INST_LT/...). */ - int match, nocase, reqlength, status; + int match, nocase, status; + Tcl_Size reqlength; - status = TclStringCmpOpts(interp, objc, objv, &nocase, &reqlength); + status = StringCmpOpts(interp, objc, objv, &nocase, &reqlength); if (status != TCL_OK) { return status; } @@ -2724,17 +2739,18 @@ StringCmpCmd( } int -TclStringCmpOpts( +StringCmpOpts( Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[], /* Argument objects. */ int *nocase, - int *reqlength) + Tcl_Size *reqlength) { - int i, length; + int i; + Tcl_Size length; const char *string; + Tcl_WideInt wreqlength = -1; - *reqlength = -1; *nocase = 0; if (objc < 3 || objc > 6) { str_cmp_args: @@ -2753,9 +2769,14 @@ TclStringCmpOpts( goto str_cmp_args; } i++; - if (TclGetIntFromObj(interp, objv[i], reqlength) != TCL_OK) { + if (Tcl_GetWideIntFromObj(interp, objv[i], &wreqlength) != TCL_OK) { return TCL_ERROR; } + if ((Tcl_WideUInt)wreqlength > TCL_SIZE_MAX) { + *reqlength = -1; + } else { + *reqlength = wreqlength; + } } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad option \"%s\": must be -nocase or -length", @@ -2787,7 +2808,7 @@ TclStringCmpOpts( static int StringCatCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -2871,7 +2892,7 @@ StringBytesCmd( static int StringLenCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -2905,12 +2926,12 @@ StringLenCmd( static int StringLowerCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - int length1, length2; + Tcl_Size length1, length2; const char *string1; char *string2; @@ -2928,7 +2949,7 @@ StringLowerCmd( Tcl_SetObjLength(resultPtr, length1); Tcl_SetObjResult(interp, resultPtr); } else { - int first, last; + Tcl_Size first, last; const char *start, *end; Tcl_Obj *resultPtr; @@ -2990,12 +3011,12 @@ StringLowerCmd( static int StringUpperCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - int length1, length2; + Tcl_Size length1, length2; const char *string1; char *string2; @@ -3013,7 +3034,7 @@ StringUpperCmd( Tcl_SetObjLength(resultPtr, length1); Tcl_SetObjResult(interp, resultPtr); } else { - int first, last; + Tcl_Size first, last; const char *start, *end; Tcl_Obj *resultPtr; @@ -3075,12 +3096,12 @@ StringUpperCmd( static int StringTitleCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - int length1, length2; + Tcl_Size length1, length2; const char *string1; char *string2; @@ -3098,7 +3119,7 @@ StringTitleCmd( Tcl_SetObjLength(resultPtr, length1); Tcl_SetObjResult(interp, resultPtr); } else { - int first, last; + Tcl_Size first, last; const char *start, *end; Tcl_Obj *resultPtr; @@ -3160,7 +3181,7 @@ StringTitleCmd( static int StringTrimCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -3207,13 +3228,14 @@ StringTrimCmd( static int StringTrimLCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { const char *string1, *string2; - int trim, length1, length2; + int trim; + Tcl_Size length1, length2; if (objc == 3) { string2 = TclGetStringFromObj(objv[2], &length2); @@ -3253,13 +3275,14 @@ StringTrimLCmd( static int StringTrimRCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { const char *string1, *string2; - int trim, length1, length2; + int trim; + Tcl_Size length1, length2; if (objc == 3) { string2 = TclGetStringFromObj(objv[2], &length2); @@ -3359,7 +3382,7 @@ TclInitStringCmd( int TclSubstOptions( Tcl_Interp *interp, - int numOpts, + Tcl_Size numOpts, Tcl_Obj *const opts[], int *flagPtr) { @@ -3398,7 +3421,7 @@ TclSubstOptions( int Tcl_SubstObjCmd( - ClientData clientData, + void *clientData, Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -3408,7 +3431,7 @@ Tcl_SubstObjCmd( int TclNRSubstObjCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -3446,7 +3469,7 @@ TclNRSubstObjCmd( int Tcl_SwitchObjCmd( - ClientData clientData, + void *clientData, Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -3455,13 +3478,14 @@ Tcl_SwitchObjCmd( } int TclNRSwitchObjCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - int i,j, index, mode, foundmode, splitObjs, numMatchesSaved; - int noCase, patternLength; + int i, index, mode, foundmode, splitObjs, numMatchesSaved; + int noCase; + Tcl_Size patternLength, j; const char *pattern; Tcl_Obj *stringObj, *indexVarObj, *matchVarObj; Tcl_Obj *const *savedObjv = objv; @@ -3876,7 +3900,7 @@ TclNRSwitchObjCmd( if (ctxPtr->type == TCL_LOCATION_SOURCE && ctxPtr->line[bidx] >= 0) { int bline = ctxPtr->line[bidx]; - ctxPtr->line = (int *)ckalloc(objc * sizeof(int)); + ctxPtr->line = (Tcl_Size *)ckalloc(objc * sizeof(Tcl_Size)); ctxPtr->nline = objc; TclListLines(blist, bline, objc, ctxPtr->line, objv); } else { @@ -3890,7 +3914,7 @@ TclNRSwitchObjCmd( int k; - ctxPtr->line = (int *)ckalloc(objc * sizeof(int)); + ctxPtr->line = (Tcl_Size *)ckalloc(objc * sizeof(Tcl_Size)); ctxPtr->nline = objc; for (k=0; k < objc; k++) { ctxPtr->line[k] = -1; @@ -3917,13 +3941,13 @@ TclNRSwitchObjCmd( */ Tcl_NRAddCallback(interp, SwitchPostProc, INT2PTR(splitObjs), ctxPtr, - INT2PTR(pc), (ClientData) pattern); + INT2PTR(pc), (void *)pattern); return TclNREvalObjEx(interp, objv[j], 0, ctxPtr, splitObjs ? j : bidx+j); } static int SwitchPostProc( - ClientData data[], /* Data passed from Tcl_NRAddCallback above */ + void *data[], /* Data passed from Tcl_NRAddCallback above */ Tcl_Interp *interp, /* Tcl interpreter */ int result) /* Result to return*/ { @@ -3933,7 +3957,7 @@ SwitchPostProc( CmdFrame *ctxPtr = (CmdFrame *)data[1]; int pc = PTR2INT(data[2]); const char *pattern = (const char *)data[3]; - int patternLength = strlen(pattern); + Tcl_Size patternLength = strlen(pattern); /* * Clean up TIP 280 context information @@ -3986,13 +4010,13 @@ SwitchPostProc( int Tcl_ThrowObjCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { Tcl_Obj *options; - int len; + Tcl_Size len; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "type message"); @@ -4048,7 +4072,7 @@ Tcl_ThrowObjCmd( int Tcl_TimeObjCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -4146,7 +4170,7 @@ Tcl_TimeObjCmd( int Tcl_TimeRateObjCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -4692,7 +4716,7 @@ Tcl_TimeRateObjCmd( int Tcl_TryObjCmd( - ClientData clientData, + void *clientData, Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -4702,13 +4726,14 @@ Tcl_TryObjCmd( int TclNRTryObjCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { Tcl_Obj *bodyObj, *handlersObj, *finallyObj = NULL; - int i, bodyShared, haveHandlers, dummy, code; + int i, bodyShared, haveHandlers, code; + Tcl_Size dummy; static const char *const handlerNames[] = { "finally", "on", "trap", NULL }; @@ -4842,7 +4867,7 @@ TclNRTryObjCmd( */ Tcl_NRAddCallback(interp, TryPostBody, handlersObj, finallyObj, - (ClientData)objv, INT2PTR(objc)); + (void *)objv, INT2PTR(objc)); return TclNREvalObjEx(interp, bodyObj, 0, ((Interp *) interp)->cmdFramePtr, 1); } @@ -4900,13 +4925,13 @@ During( static int TryPostBody( - ClientData data[], + void *data[], Tcl_Interp *interp, int result) { Tcl_Obj *resultObj, *options, *handlersObj, *finallyObj, *cmdObj, **objv; - int i, code, objc; - int numHandlers = 0; + int code, objc; + Tcl_Size i, numHandlers = 0; handlersObj = (Tcl_Obj *)data[0]; finallyObj = (Tcl_Obj *)data[1]; @@ -4956,7 +4981,7 @@ TryPostBody( TclListObjGetElementsM(NULL, handlersObj, &numHandlers, &handlers); for (i=0 ; i<numHandlers ; i++) { Tcl_Obj *handlerBodyObj; - int numElems = 0; + Tcl_Size numElems = 0; TclListObjGetElementsM(NULL, handlers[i], &numElems, &info); if (!found) { @@ -4974,7 +4999,7 @@ TryPostBody( if (code == TCL_ERROR) { Tcl_Obj *errorCodeName, *errcode, **bits1, **bits2; - int len1, len2, j; + Tcl_Size len1, len2, j; TclNewLiteralStringObj(errorCodeName, "-errorcode"); Tcl_DictObjGet(NULL, options, errorCodeName, &errcode); @@ -5116,7 +5141,7 @@ TryPostBody( static int TryPostHandler( - ClientData data[], + void *data[], Tcl_Interp *interp, int result) { @@ -5202,7 +5227,7 @@ TryPostHandler( static int TryPostFinal( - ClientData data[], + void *data[], Tcl_Interp *interp, int result) { @@ -5269,7 +5294,7 @@ TryPostFinal( int Tcl_WhileObjCmd( - ClientData clientData, + void *clientData, Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -5279,7 +5304,7 @@ Tcl_WhileObjCmd( int TclNRWhileObjCmd( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -5328,18 +5353,18 @@ TclListLines( Tcl_Obj *listObj, /* Pointer to obj holding a string with list * structure. Assumed to be valid. Assumed to * contain n elements. */ - int line, /* Line the list as a whole starts on. */ - int n, /* #elements in lines */ - int *lines, /* Array of line numbers, to fill. */ + Tcl_Size line, /* Line the list as a whole starts on. */ + 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); |