summaryrefslogtreecommitdiffstats
path: root/generic/tclTestObj.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-03-09 15:46:47 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-03-09 15:46:47 (GMT)
commit651b6bd2ecd9aad53ab771ee5a182ecab420ba01 (patch)
tree379e22e4f1fd92276f930dee6272548a1b33c98e /generic/tclTestObj.c
parent2bc56d1709caa656983875156b1063a04226824a (diff)
parent0018893f3518509598c9945436bbd7b51ecacc70 (diff)
downloadtcl-651b6bd2ecd9aad53ab771ee5a182ecab420ba01.zip
tcl-651b6bd2ecd9aad53ab771ee5a182ecab420ba01.tar.gz
tcl-651b6bd2ecd9aad53ab771ee5a182ecab420ba01.tar.bz2
Merge 8.7
Diffstat (limited to 'generic/tclTestObj.c')
-rw-r--r--generic/tclTestObj.c214
1 files changed, 95 insertions, 119 deletions
diff --git a/generic/tclTestObj.c b/generic/tclTestObj.c
index 654208d..f858f54 100644
--- a/generic/tclTestObj.c
+++ b/generic/tclTestObj.c
@@ -30,10 +30,10 @@
* Forward declarations for functions defined later in this file:
*/
-static int CheckIfVarUnset(Tcl_Interp *interp, Tcl_Obj **varPtr, int varIndex);
+static int CheckIfVarUnset(Tcl_Interp *interp, Tcl_Obj **varPtr, size_t varIndex);
static int GetVariableIndex(Tcl_Interp *interp,
- const char *string, int *indexPtr);
-static void SetVarToObj(Tcl_Obj **varPtr, int varIndex, Tcl_Obj *objPtr);
+ Tcl_Obj *obj, size_t *indexPtr);
+static void SetVarToObj(Tcl_Obj **varPtr, size_t varIndex, Tcl_Obj *objPtr);
static Tcl_ObjCmdProc TestbignumobjCmd;
static Tcl_ObjCmdProc TestbooleanobjCmd;
static Tcl_ObjCmdProc TestdoubleobjCmd;
@@ -152,7 +152,8 @@ TestbignumobjCmd(
BIGNUM_SET, BIGNUM_GET, BIGNUM_MULT10, BIGNUM_DIV10, BIGNUM_ISEVEN,
BIGNUM_RADIXSIZE
};
- int index, varIndex;
+ int index;
+ size_t varIndex;
const char *string;
mp_int bignumValue;
Tcl_Obj **varPtr;
@@ -165,13 +166,12 @@ TestbignumobjCmd(
&index) != TCL_OK) {
return TCL_ERROR;
}
- string = Tcl_GetString(objv[2]);
- if (GetVariableIndex(interp, string, &varIndex) != TCL_OK) {
+ if (GetVariableIndex(interp, objv[2], &varIndex) != TCL_OK) {
return TCL_ERROR;
}
varPtr = GetVarPtr(interp);
- switch (index) {
+ switch ((enum options)index) {
case BIGNUM_SET:
if (objc != 4) {
Tcl_WrongNumArgs(interp, 2, objv, "var value");
@@ -284,9 +284,9 @@ TestbignumobjCmd(
return TCL_ERROR;
}
if (!Tcl_IsShared(varPtr[varIndex])) {
- Tcl_SetIntObj(varPtr[varIndex], mp_iszero(&bignumValue));
+ Tcl_SetWideIntObj(varPtr[varIndex], mp_iszero(&bignumValue));
} else {
- SetVarToObj(varPtr, varIndex, Tcl_NewIntObj(mp_iszero(&bignumValue)));
+ SetVarToObj(varPtr, varIndex, Tcl_NewWideIntObj(mp_iszero(&bignumValue)));
}
mp_clear(&bignumValue);
break;
@@ -307,9 +307,9 @@ TestbignumobjCmd(
return TCL_ERROR;
}
if (!Tcl_IsShared(varPtr[varIndex])) {
- Tcl_SetIntObj(varPtr[varIndex], index);
+ Tcl_SetWideIntObj(varPtr[varIndex], index);
} else {
- SetVarToObj(varPtr, varIndex, Tcl_NewIntObj(index));
+ SetVarToObj(varPtr, varIndex, Tcl_NewWideIntObj(index));
}
mp_clear(&bignumValue);
break;
@@ -344,8 +344,9 @@ TestbooleanobjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- int varIndex, boolValue;
- const char *index, *subCmd;
+ size_t varIndex;
+ int boolValue;
+ const char *subCmd;
Tcl_Obj **varPtr;
if (objc < 3) {
@@ -354,8 +355,7 @@ TestbooleanobjCmd(
return TCL_ERROR;
}
- index = Tcl_GetString(objv[2]);
- if (GetVariableIndex(interp, index, &varIndex) != TCL_OK) {
+ if (GetVariableIndex(interp, objv[2], &varIndex) != TCL_OK) {
return TCL_ERROR;
}
@@ -444,9 +444,9 @@ TestdoubleobjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- int varIndex;
+ size_t varIndex;
double doubleValue;
- const char *index, *subCmd, *string;
+ const char *subCmd;
Tcl_Obj **varPtr;
if (objc < 3) {
@@ -457,8 +457,7 @@ TestdoubleobjCmd(
varPtr = GetVarPtr(interp);
- index = Tcl_GetString(objv[2]);
- if (GetVariableIndex(interp, index, &varIndex) != TCL_OK) {
+ if (GetVariableIndex(interp, objv[2], &varIndex) != TCL_OK) {
return TCL_ERROR;
}
@@ -467,8 +466,7 @@ TestdoubleobjCmd(
if (objc != 4) {
goto wrongNumArgs;
}
- string = Tcl_GetString(objv[3]);
- if (Tcl_GetDouble(interp, string, &doubleValue) != TCL_OK) {
+ if (Tcl_GetDouble(interp, Tcl_GetString(objv[3]), &doubleValue) != TCL_OK) {
return TCL_ERROR;
}
@@ -562,7 +560,8 @@ TestindexobjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- int allowAbbrev, index, index2, setError, i, result;
+ int allowAbbrev, index, setError, i, result;
+ Tcl_WideInt index2;
const char **argv;
static const char *const tablePtr[] = {"a", "b", "check", NULL};
@@ -571,10 +570,9 @@ TestindexobjCmd(
*/
struct IndexRep {
void *tablePtr; /* Pointer to the table of strings. */
- size_t offset; /* Offset between table entries. */
- size_t index; /* Selected index into table. */
- };
- struct IndexRep *indexRep;
+ TCL_HASH_TYPE offset; /* Offset between table entries. */
+ TCL_HASH_TYPE index; /* Selected index into table. */
+ } *indexRep;
if ((objc == 3) && (strcmp(Tcl_GetString(objv[1]),
"check") == 0)) {
@@ -584,7 +582,7 @@ TestindexobjCmd(
* lookups.
*/
- if (Tcl_GetIntFromObj(interp, objv[2], &index2) != TCL_OK) {
+ if (Tcl_GetWideIntFromObj(interp, objv[2], &index2) != TCL_OK) {
return TCL_ERROR;
}
@@ -594,7 +592,7 @@ TestindexobjCmd(
result = Tcl_GetIndexFromObj(NULL, objv[1],
tablePtr, "token", 0, &index);
if (result == TCL_OK) {
- Tcl_SetIntObj(Tcl_GetObjResult(interp), index);
+ Tcl_SetWideIntObj(Tcl_GetObjResult(interp), index);
}
return result;
}
@@ -622,7 +620,7 @@ TestindexobjCmd(
&index);
Tcl_Free((void *)argv);
if (result == TCL_OK) {
- Tcl_SetIntObj(Tcl_GetObjResult(interp), index);
+ Tcl_SetWideIntObj(Tcl_GetObjResult(interp), index);
}
return result;
}
@@ -652,9 +650,10 @@ TestintobjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- int intValue, varIndex, i;
+ size_t varIndex;
+ int i;
Tcl_WideInt wideValue;
- const char *index, *subCmd, *string;
+ const char *subCmd;
Tcl_Obj **varPtr;
if (objc < 3) {
@@ -664,8 +663,7 @@ TestintobjCmd(
}
varPtr = GetVarPtr(interp);
- index = Tcl_GetString(objv[2]);
- if (GetVariableIndex(interp, index, &varIndex) != TCL_OK) {
+ if (GetVariableIndex(interp, objv[2], &varIndex) != TCL_OK) {
return TCL_ERROR;
}
@@ -674,11 +672,9 @@ TestintobjCmd(
if (objc != 4) {
goto wrongNumArgs;
}
- string = Tcl_GetString(objv[3]);
- if (Tcl_GetInt(interp, string, &i) != TCL_OK) {
+ if (Tcl_GetWideIntFromObj(interp, objv[3], &wideValue) != TCL_OK) {
return TCL_ERROR;
}
- intValue = i;
/*
* If the object currently bound to the variable with index varIndex
@@ -689,38 +685,34 @@ TestintobjCmd(
*/
if ((varPtr[varIndex] != NULL) && !Tcl_IsShared(varPtr[varIndex])) {
- Tcl_SetIntObj(varPtr[varIndex], intValue);
+ Tcl_SetWideIntObj(varPtr[varIndex], wideValue);
} else {
- SetVarToObj(varPtr, varIndex, Tcl_NewIntObj(intValue));
+ SetVarToObj(varPtr, varIndex, Tcl_NewWideIntObj(wideValue));
}
Tcl_SetObjResult(interp, varPtr[varIndex]);
} else if (strcmp(subCmd, "set2") == 0) { /* doesn't set result */
if (objc != 4) {
goto wrongNumArgs;
}
- string = Tcl_GetString(objv[3]);
- if (Tcl_GetInt(interp, string, &i) != TCL_OK) {
+ if (Tcl_GetWideIntFromObj(interp, objv[3], &wideValue) != TCL_OK) {
return TCL_ERROR;
}
- intValue = i;
if ((varPtr[varIndex] != NULL) && !Tcl_IsShared(varPtr[varIndex])) {
- Tcl_SetIntObj(varPtr[varIndex], intValue);
+ Tcl_SetWideIntObj(varPtr[varIndex], wideValue);
} else {
- SetVarToObj(varPtr, varIndex, Tcl_NewIntObj(intValue));
+ SetVarToObj(varPtr, varIndex, Tcl_NewWideIntObj(wideValue));
}
} else if (strcmp(subCmd, "setint") == 0) {
if (objc != 4) {
goto wrongNumArgs;
}
- string = Tcl_GetString(objv[3]);
- if (Tcl_GetInt(interp, string, &i) != TCL_OK) {
+ if (Tcl_GetWideIntFromObj(interp, objv[3], &wideValue) != TCL_OK) {
return TCL_ERROR;
}
- intValue = i;
if ((varPtr[varIndex] != NULL) && !Tcl_IsShared(varPtr[varIndex])) {
- Tcl_SetWideIntObj(varPtr[varIndex], intValue);
+ Tcl_SetWideIntObj(varPtr[varIndex], wideValue);
} else {
- SetVarToObj(varPtr, varIndex, Tcl_NewWideIntObj(intValue));
+ SetVarToObj(varPtr, varIndex, Tcl_NewWideIntObj(wideValue));
}
Tcl_SetObjResult(interp, varPtr[varIndex]);
} else if (strcmp(subCmd, "setmax") == 0) {
@@ -760,8 +752,7 @@ TestintobjCmd(
if (CheckIfVarUnset(interp, varPtr,varIndex)) {
return TCL_ERROR;
}
- string = Tcl_GetString(varPtr[varIndex]);
- Tcl_AppendToObj(Tcl_GetObjResult(interp), string, -1);
+ Tcl_AppendToObj(Tcl_GetObjResult(interp), Tcl_GetString(varPtr[varIndex]), -1);
} else if (strcmp(subCmd, "inttoobigtest") == 0) {
/*
* If long ints have more bits than ints on this platform, verify that
@@ -795,14 +786,14 @@ TestintobjCmd(
if (CheckIfVarUnset(interp, varPtr,varIndex)) {
return TCL_ERROR;
}
- if (Tcl_GetIntFromObj(interp, varPtr[varIndex],
- &intValue) != TCL_OK) {
+ if (Tcl_GetWideIntFromObj(interp, varPtr[varIndex],
+ &wideValue) != TCL_OK) {
return TCL_ERROR;
}
if (!Tcl_IsShared(varPtr[varIndex])) {
- Tcl_SetIntObj(varPtr[varIndex], intValue * 10);
+ Tcl_SetWideIntObj(varPtr[varIndex], wideValue * 10);
} else {
- SetVarToObj(varPtr, varIndex, Tcl_NewIntObj(intValue * 10));
+ SetVarToObj(varPtr, varIndex, Tcl_NewWideIntObj(wideValue * 10));
}
Tcl_SetObjResult(interp, varPtr[varIndex]);
} else if (strcmp(subCmd, "div10") == 0) {
@@ -812,14 +803,14 @@ TestintobjCmd(
if (CheckIfVarUnset(interp, varPtr,varIndex)) {
return TCL_ERROR;
}
- if (Tcl_GetIntFromObj(interp, varPtr[varIndex],
- &intValue) != TCL_OK) {
+ if (Tcl_GetWideIntFromObj(interp, varPtr[varIndex],
+ &wideValue) != TCL_OK) {
return TCL_ERROR;
}
if (!Tcl_IsShared(varPtr[varIndex])) {
- Tcl_SetIntObj(varPtr[varIndex], intValue / 10);
+ Tcl_SetWideIntObj(varPtr[varIndex], wideValue / 10);
} else {
- SetVarToObj(varPtr, varIndex, Tcl_NewIntObj(intValue / 10));
+ SetVarToObj(varPtr, varIndex, Tcl_NewWideIntObj(wideValue / 10));
}
Tcl_SetObjResult(interp, varPtr[varIndex]);
} else {
@@ -866,13 +857,11 @@ TestlistobjCmd(
LISTOBJ_SET,
LISTOBJ_GET,
LISTOBJ_REPLACE
- };
+ } cmdIndex;
- const char* index; /* Argument giving the variable number */
- int varIndex; /* Variable number converted to binary */
- int cmdIndex; /* Ordinal number of the subcommand */
- int first; /* First index in the list */
- int count; /* Count of elements in a list */
+ size_t varIndex; /* Variable number converted to binary */
+ Tcl_WideInt first; /* First index in the list */
+ Tcl_WideInt count; /* Count of elements in a list */
Tcl_Obj **varPtr;
if (objc < 3) {
@@ -880,8 +869,7 @@ TestlistobjCmd(
return TCL_ERROR;
}
varPtr = GetVarPtr(interp);
- index = Tcl_GetString(objv[2]);
- if (GetVariableIndex(interp, index, &varIndex) != TCL_OK) {
+ if (GetVariableIndex(interp, objv[2], &varIndex) != TCL_OK) {
return TCL_ERROR;
}
if (Tcl_GetIndexFromObj(interp, objv[1], subcommands, "command",
@@ -915,8 +903,8 @@ TestlistobjCmd(
"varIndex start count ?element...?");
return TCL_ERROR;
}
- if (Tcl_GetIntFromObj(interp, objv[3], &first) != TCL_OK
- || Tcl_GetIntFromObj(interp, objv[4], &count) != TCL_OK) {
+ if (Tcl_GetWideIntFromObj(interp, objv[3], &first) != TCL_OK
+ || Tcl_GetWideIntFromObj(interp, objv[4], &count) != TCL_OK) {
return TCL_ERROR;
}
if (Tcl_IsShared(varPtr[varIndex])) {
@@ -953,8 +941,9 @@ TestobjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- int varIndex, destIndex, i;
- const char *index, *subCmd, *string;
+ size_t varIndex, destIndex;
+ int i;
+ const char *subCmd;
const Tcl_ObjType *targetType;
Tcl_Obj **varPtr;
@@ -970,15 +959,13 @@ TestobjCmd(
if (objc != 4) {
goto wrongNumArgs;
}
- index = Tcl_GetString(objv[2]);
- if (GetVariableIndex(interp, index, &varIndex) != TCL_OK) {
+ if (GetVariableIndex(interp, objv[2], &varIndex) != TCL_OK) {
return TCL_ERROR;
}
if (CheckIfVarUnset(interp, varPtr,varIndex)) {
return TCL_ERROR;
}
- string = Tcl_GetString(objv[3]);
- if (GetVariableIndex(interp, string, &destIndex) != TCL_OK) {
+ if (GetVariableIndex(interp, objv[3], &destIndex) != TCL_OK) {
return TCL_ERROR;
}
SetVarToObj(varPtr, destIndex, varPtr[varIndex]);
@@ -988,29 +975,26 @@ TestobjCmd(
if (objc != 2) {
goto wrongNumArgs;
}
- elemObjPtr = Tcl_NewIntObj(123);
+ elemObjPtr = Tcl_NewWideIntObj(123);
listObjPtr = Tcl_NewListObj(1, &elemObjPtr);
/* Replace the single list element through itself, nonsense but legal. */
Tcl_ListObjReplace(interp, listObjPtr, 0, 1, 1, &elemObjPtr);
Tcl_SetObjResult(interp, listObjPtr);
return TCL_OK;
} else if (strcmp(subCmd, "convert") == 0) {
- const char *typeName;
if (objc != 4) {
goto wrongNumArgs;
}
- index = Tcl_GetString(objv[2]);
- if (GetVariableIndex(interp, index, &varIndex) != TCL_OK) {
+ if (GetVariableIndex(interp, objv[2], &varIndex) != TCL_OK) {
return TCL_ERROR;
}
if (CheckIfVarUnset(interp, varPtr,varIndex)) {
return TCL_ERROR;
}
- typeName = Tcl_GetString(objv[3]);
- if ((targetType = Tcl_GetObjType(typeName)) == NULL) {
+ if ((targetType = Tcl_GetObjType(Tcl_GetString(objv[3]))) == NULL) {
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
- "no type ", typeName, " found", NULL);
+ "no type ", Tcl_GetString(objv[3]), " found", NULL);
return TCL_ERROR;
}
if (Tcl_ConvertToType(interp, varPtr[varIndex], targetType)
@@ -1022,15 +1006,13 @@ TestobjCmd(
if (objc != 4) {
goto wrongNumArgs;
}
- index = Tcl_GetString(objv[2]);
- if (GetVariableIndex(interp, index, &varIndex) != TCL_OK) {
+ if (GetVariableIndex(interp, objv[2], &varIndex) != TCL_OK) {
return TCL_ERROR;
}
if (CheckIfVarUnset(interp, varPtr,varIndex)) {
return TCL_ERROR;
}
- string = Tcl_GetString(objv[3]);
- if (GetVariableIndex(interp, string, &destIndex) != TCL_OK) {
+ if (GetVariableIndex(interp, objv[3], &destIndex) != TCL_OK) {
return TCL_ERROR;
}
SetVarToObj(varPtr, destIndex, Tcl_DuplicateObj(varPtr[varIndex]));
@@ -1049,8 +1031,7 @@ TestobjCmd(
if (objc != 3) {
goto wrongNumArgs;
}
- index = Tcl_GetString(objv[2]);
- if (GetVariableIndex(interp, index, &varIndex) != TCL_OK) {
+ if (GetVariableIndex(interp, objv[2], &varIndex) != TCL_OK) {
return TCL_ERROR;
}
if (CheckIfVarUnset(interp, varPtr,varIndex)) {
@@ -1062,8 +1043,7 @@ TestobjCmd(
if (objc != 3) {
goto wrongNumArgs;
}
- index = Tcl_GetString(objv[2]);
- if (GetVariableIndex(interp, index, &varIndex) != TCL_OK) {
+ if (GetVariableIndex(interp, objv[2], &varIndex) != TCL_OK) {
return TCL_ERROR;
}
SetVarToObj(varPtr, varIndex, Tcl_NewObj());
@@ -1092,8 +1072,7 @@ TestobjCmd(
if (objc != 3) {
goto wrongNumArgs;
}
- index = Tcl_GetString(objv[2]);
- if (GetVariableIndex(interp, index, &varIndex) != TCL_OK) {
+ if (GetVariableIndex(interp, objv[2], &varIndex) != TCL_OK) {
return TCL_ERROR;
}
if (CheckIfVarUnset(interp, varPtr,varIndex)) {
@@ -1104,8 +1083,7 @@ TestobjCmd(
if (objc != 3) {
goto wrongNumArgs;
}
- index = Tcl_GetString(objv[2]);
- if (GetVariableIndex(interp, index, &varIndex) != TCL_OK) {
+ if (GetVariableIndex(interp, objv[2], &varIndex) != TCL_OK) {
return TCL_ERROR;
}
if (CheckIfVarUnset(interp, varPtr,varIndex)) {
@@ -1166,10 +1144,11 @@ TeststringobjCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tcl_UniChar *unicode;
- int varIndex, option, i, length;
- size_t size;
+ size_t size, varIndex;
+ int option, i;
+ Tcl_WideInt length;
#define MAX_STRINGS 11
- const char *index, *string, *strings[MAX_STRINGS+1];
+ const char *string, *strings[MAX_STRINGS+1];
String *strPtr;
Tcl_Obj **varPtr;
static const char *const options[] = {
@@ -1185,8 +1164,7 @@ TeststringobjCmd(
}
varPtr = GetVarPtr(interp);
- index = Tcl_GetString(objv[2]);
- if (GetVariableIndex(interp, index, &varIndex) != TCL_OK) {
+ if (GetVariableIndex(interp, objv[2], &varIndex) != TCL_OK) {
return TCL_ERROR;
}
@@ -1199,7 +1177,7 @@ TeststringobjCmd(
if (objc != 5) {
goto wrongNumArgs;
}
- if (Tcl_GetIntFromObj(interp, objv[4], &length) != TCL_OK) {
+ if (Tcl_GetWideIntFromObj(interp, objv[4], &length) != TCL_OK) {
return TCL_ERROR;
}
if (varPtr[varIndex] == NULL) {
@@ -1214,8 +1192,7 @@ TeststringobjCmd(
if (Tcl_IsShared(varPtr[varIndex])) {
SetVarToObj(varPtr, varIndex, Tcl_DuplicateObj(varPtr[varIndex]));
}
- string = Tcl_GetString(objv[3]);
- Tcl_AppendToObj(varPtr[varIndex], string, length);
+ Tcl_AppendToObj(varPtr[varIndex], Tcl_GetString(objv[3]), length);
Tcl_SetObjResult(interp, varPtr[varIndex]);
break;
case 1: /* appendstrings */
@@ -1262,8 +1239,7 @@ TeststringobjCmd(
if (CheckIfVarUnset(interp, varPtr, varIndex)) {
return TCL_ERROR;
}
- string = Tcl_GetString(varPtr[varIndex]);
- Tcl_AppendToObj(Tcl_GetObjResult(interp), string, -1);
+ Tcl_AppendToObj(Tcl_GetObjResult(interp), Tcl_GetString(varPtr[varIndex]), -1);
break;
case 4: /* length */
if (objc != 3) {
@@ -1284,7 +1260,7 @@ TeststringobjCmd(
} else {
length = -1;
}
- Tcl_SetIntObj(Tcl_GetObjResult(interp), length);
+ Tcl_SetWideIntObj(Tcl_GetObjResult(interp), length);
break;
case 6: /* set */
if (objc != 4) {
@@ -1319,7 +1295,7 @@ TeststringobjCmd(
if (objc != 4) {
goto wrongNumArgs;
}
- if (Tcl_GetIntFromObj(interp, objv[3], &length) != TCL_OK) {
+ if (Tcl_GetWideIntFromObj(interp, objv[3], &length) != TCL_OK) {
return TCL_ERROR;
}
if (varPtr[varIndex] != NULL) {
@@ -1338,7 +1314,7 @@ TeststringobjCmd(
} else {
length = -1;
}
- Tcl_SetIntObj(Tcl_GetObjResult(interp), length);
+ Tcl_SetWideIntObj(Tcl_GetObjResult(interp), length);
break;
case 10: /* appendself */
if (objc != 4) {
@@ -1359,16 +1335,16 @@ TeststringobjCmd(
string = Tcl_GetStringFromObj(varPtr[varIndex], &size);
- if (Tcl_GetIntFromObj(interp, objv[3], &i) != TCL_OK) {
+ if (Tcl_GetWideIntFromObj(interp, objv[3], &length) != TCL_OK) {
return TCL_ERROR;
}
- if ((i < 0) || ((size_t)i > size)) {
+ if ((length < 0) || ((Tcl_WideUInt)length > (Tcl_WideUInt)size)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"index value out of range", -1));
return TCL_ERROR;
}
- Tcl_AppendToObj(varPtr[varIndex], string + i, size - i);
+ Tcl_AppendToObj(varPtr[varIndex], string + length, size - length);
Tcl_SetObjResult(interp, varPtr[varIndex]);
break;
case 11: /* appendself2 */
@@ -1390,16 +1366,16 @@ TeststringobjCmd(
unicode = Tcl_GetUnicodeFromObj(varPtr[varIndex], &size);
- if (Tcl_GetIntFromObj(interp, objv[3], &i) != TCL_OK) {
+ if (Tcl_GetWideIntFromObj(interp, objv[3], &length) != TCL_OK) {
return TCL_ERROR;
}
- if ((i < 0) || ((size_t)i > size)) {
+ if ((length < 0) || ((Tcl_WideUInt)length > (Tcl_WideUInt)size)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"index value out of range", -1));
return TCL_ERROR;
}
- TclAppendUnicodeToObj(varPtr[varIndex], unicode + i, size - i);
+ TclAppendUnicodeToObj(varPtr[varIndex], unicode + length, size - length);
Tcl_SetObjResult(interp, varPtr[varIndex]);
break;
}
@@ -1429,7 +1405,7 @@ TeststringobjCmd(
static void
SetVarToObj(
Tcl_Obj **varPtr,
- int varIndex, /* Designates the assignment variable. */
+ size_t varIndex, /* Designates the assignment variable. */
Tcl_Obj *objPtr) /* Points to object to assign to var. */
{
if (varPtr[varIndex] != NULL) {
@@ -1460,14 +1436,14 @@ SetVarToObj(
static int
GetVariableIndex(
Tcl_Interp *interp, /* Interpreter for error reporting. */
- const char *string, /* String containing a variable index
+ Tcl_Obj *obj, /* The variable index
* specified as a nonnegative number less than
* NUMBER_OF_OBJECT_VARS. */
- int *indexPtr) /* Place to store converted result. */
+ size_t *indexPtr) /* Place to store converted result. */
{
- int index;
+ Tcl_WideInt index;
- if (Tcl_GetInt(interp, string, &index) != TCL_OK) {
+ if (Tcl_GetWideIntFromObj(interp, obj, &index) != TCL_OK) {
return TCL_ERROR;
}
if (index < 0 || index >= NUMBER_OF_OBJECT_VARS) {
@@ -1502,12 +1478,12 @@ static int
CheckIfVarUnset(
Tcl_Interp *interp, /* Interpreter for error reporting. */
Tcl_Obj ** varPtr,
- int varIndex) /* Index of the test variable to check. */
+ size_t varIndex) /* Index of the test variable to check. */
{
if (varPtr[varIndex] == NULL) {
char buf[32 + TCL_INTEGER_SPACE];
- sprintf(buf, "variable %d is unset (NULL)", varIndex);
+ sprintf(buf, "variable %" TCL_Z_MODIFIER "u is unset (NULL)", varIndex);
Tcl_ResetResult(interp);
Tcl_AppendToObj(Tcl_GetObjResult(interp), buf, -1);
return 1;