diff options
author | apnadkarni <apnmbx-wits@yahoo.com> | 2023-04-08 08:22:20 (GMT) |
---|---|---|
committer | apnadkarni <apnmbx-wits@yahoo.com> | 2023-04-08 08:22:20 (GMT) |
commit | 3643909840952b5e4dc9edd9d1fec509c43d2c08 (patch) | |
tree | 34836ca13ff39d9a644837ea8bbba902683aee65 /generic/tclTestObj.c | |
parent | 0fb466009e4163785bf459cbc6d77be178e62f67 (diff) | |
parent | 9365f75b619c40e1112a29085e1f491dfcbfc873 (diff) | |
download | tcl-3643909840952b5e4dc9edd9d1fec509c43d2c08.zip tcl-3643909840952b5e4dc9edd9d1fec509c43d2c08.tar.gz tcl-3643909840952b5e4dc9edd9d1fec509c43d2c08.tar.bz2 |
Merge 9.0
Diffstat (limited to 'generic/tclTestObj.c')
-rw-r--r-- | generic/tclTestObj.c | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/generic/tclTestObj.c b/generic/tclTestObj.c index a7b7382..97e0ad2 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, size_t varIndex); +static int CheckIfVarUnset(Tcl_Interp *interp, Tcl_Obj **varPtr, Tcl_Size varIndex); static int GetVariableIndex(Tcl_Interp *interp, - Tcl_Obj *obj, size_t *indexPtr); -static void SetVarToObj(Tcl_Obj **varPtr, size_t varIndex, Tcl_Obj *objPtr); + Tcl_Obj *obj, Tcl_Size *indexPtr); +static void SetVarToObj(Tcl_Obj **varPtr, Tcl_Size varIndex, Tcl_Obj *objPtr); static Tcl_ObjCmdProc TestbignumobjCmd; static Tcl_ObjCmdProc TestbooleanobjCmd; static Tcl_ObjCmdProc TestdoubleobjCmd; @@ -153,7 +153,7 @@ TestbignumobjCmd( BIGNUM_RADIXSIZE } idx; int index; - size_t varIndex; + Tcl_Size varIndex; const char *string; mp_int bignumValue; Tcl_Obj **varPtr; @@ -344,7 +344,7 @@ TestbooleanobjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - size_t varIndex; + Tcl_Size varIndex; int boolValue; const char *subCmd; Tcl_Obj **varPtr; @@ -444,7 +444,7 @@ TestdoubleobjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - size_t varIndex; + Tcl_Size varIndex; double doubleValue; const char *subCmd; Tcl_Obj **varPtr; @@ -561,7 +561,7 @@ TestindexobjCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { int allowAbbrev, index, setError, i, result; - Tcl_WideInt index2; + Tcl_Size index2; const char **argv; static const char *const tablePtr[] = {"a", "b", "check", NULL}; @@ -570,8 +570,8 @@ TestindexobjCmd( */ struct IndexRep { void *tablePtr; /* Pointer to the table of strings. */ - TCL_HASH_TYPE offset; /* Offset between table entries. */ - TCL_HASH_TYPE index; /* Selected index into table. */ + Tcl_Size offset; /* Offset between table entries. */ + Tcl_Size index; /* Selected index into table. */ } *indexRep; if ((objc == 3) && (strcmp(Tcl_GetString(objv[1]), @@ -582,7 +582,7 @@ TestindexobjCmd( * lookups. */ - if (Tcl_GetWideIntFromObj(interp, objv[2], &index2) != TCL_OK) { + if (Tcl_GetIntForIndex(interp, objv[2], TCL_INDEX_NONE, &index2) != TCL_OK) { return TCL_ERROR; } @@ -592,7 +592,7 @@ TestindexobjCmd( result = Tcl_GetIndexFromObj(NULL, objv[1], tablePtr, "token", 0, &index); if (result == TCL_OK) { - Tcl_SetWideIntObj(Tcl_GetObjResult(interp), index); + Tcl_SetWideIntObj(Tcl_GetObjResult(interp), (Tcl_WideInt)((Tcl_WideUInt)(index + 1U)) - 1); } return result; } @@ -620,7 +620,7 @@ TestindexobjCmd( &index); Tcl_Free((void *)argv); if (result == TCL_OK) { - Tcl_SetWideIntObj(Tcl_GetObjResult(interp), index); + Tcl_SetWideIntObj(Tcl_GetObjResult(interp), (Tcl_WideInt)((Tcl_WideUInt)(index + 1U)) - 1); } return result; } @@ -650,7 +650,7 @@ TestintobjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - size_t varIndex; + Tcl_Size varIndex; #if (INT_MAX != LONG_MAX) /* int is not the same size as long */ int i; #endif @@ -895,9 +895,9 @@ TestlistobjCmd( LISTOBJ_GETELEMENTSMEMCHECK, } cmdIndex; - 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_Size varIndex; /* Variable number converted to binary */ + Tcl_Size first; /* First index in the list */ + Tcl_Size count; /* Count of elements in a list */ Tcl_Obj **varPtr; int i, len; @@ -913,7 +913,7 @@ TestlistobjCmd( 0, &cmdIndex) != TCL_OK) { return TCL_ERROR; } - switch (cmdIndex) { + switch(cmdIndex) { case LISTOBJ_SET: if ((varPtr[varIndex] != NULL) && !Tcl_IsShared(varPtr[varIndex])) { Tcl_SetListObj(varPtr[varIndex], objc-3, objv+3); @@ -940,8 +940,8 @@ TestlistobjCmd( "varIndex start count ?element...?"); return TCL_ERROR; } - if (Tcl_GetWideIntFromObj(interp, objv[3], &first) != TCL_OK - || Tcl_GetWideIntFromObj(interp, objv[4], &count) != TCL_OK) { + if (Tcl_GetIntForIndex(interp, objv[3], TCL_INDEX_NONE, &first) != TCL_OK + || Tcl_GetIntForIndex(interp, objv[4], TCL_INDEX_NONE, &count) != TCL_OK) { return TCL_ERROR; } if (Tcl_IsShared(varPtr[varIndex])) { @@ -1028,7 +1028,7 @@ TestobjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - size_t varIndex, destIndex; + Tcl_Size varIndex, destIndex; int i; const Tcl_ObjType *targetType; Tcl_Obj **varPtr; @@ -1199,7 +1199,7 @@ TestobjCmd( if (objc != 3) { goto wrongNumArgs; } - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(varPtr[varIndex]->refCount)); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj((Tcl_WideInt)((Tcl_WideUInt)(varPtr[varIndex]->refCount + 1U)) - 1)); break; case TESTOBJ_TYPE: if (objc != 3) { @@ -1250,9 +1250,9 @@ TeststringobjCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { Tcl_UniChar *unicode; - size_t size, varIndex; + Tcl_Size size, varIndex; int option, i; - Tcl_WideInt length; + Tcl_Size length; #define MAX_STRINGS 11 const char *string, *strings[MAX_STRINGS+1]; String *strPtr; @@ -1283,7 +1283,7 @@ TeststringobjCmd( if (objc != 5) { goto wrongNumArgs; } - if (Tcl_GetWideIntFromObj(interp, objv[4], &length) != TCL_OK) { + if (Tcl_GetIntForIndex(interp, objv[4], TCL_INDEX_NONE, &length) != TCL_OK) { return TCL_ERROR; } if (varPtr[varIndex] == NULL) { @@ -1364,9 +1364,9 @@ TeststringobjCmd( strPtr = (String *)varPtr[varIndex]->internalRep.twoPtrValue.ptr1; length = strPtr->allocated; } else { - length = -1; + length = TCL_INDEX_NONE; } - Tcl_SetWideIntObj(Tcl_GetObjResult(interp), length); + Tcl_SetWideIntObj(Tcl_GetObjResult(interp), (Tcl_WideInt)((Tcl_WideUInt)(length + 1U)) - 1); break; case 6: /* set */ if (objc != 4) { @@ -1401,7 +1401,7 @@ TeststringobjCmd( if (objc != 4) { goto wrongNumArgs; } - if (Tcl_GetWideIntFromObj(interp, objv[3], &length) != TCL_OK) { + if (Tcl_GetIntForIndex(interp, objv[3], TCL_INDEX_NONE, &length) != TCL_OK) { return TCL_ERROR; } if (varPtr[varIndex] != NULL) { @@ -1418,17 +1418,17 @@ TeststringobjCmd( strPtr = (String *)varPtr[varIndex]->internalRep.twoPtrValue.ptr1; length = strPtr->maxChars; } else { - length = -1; + length = TCL_INDEX_NONE; } - Tcl_SetWideIntObj(Tcl_GetObjResult(interp), length); + Tcl_SetWideIntObj(Tcl_GetObjResult(interp), (Tcl_WideInt)((Tcl_WideUInt)(length + 1U)) - 1); break; case 10: { /* range */ - Tcl_WideInt first, last; + Tcl_Size first, last; if (objc != 5) { goto wrongNumArgs; } - if ((Tcl_GetWideIntFromObj(interp, objv[3], &first) != TCL_OK) - || (Tcl_GetWideIntFromObj(interp, objv[4], &last) != TCL_OK)) { + if ((Tcl_GetIntForIndex(interp, objv[3], TCL_INDEX_NONE, &first) != TCL_OK) + || (Tcl_GetIntForIndex(interp, objv[4], TCL_INDEX_NONE, &last) != TCL_OK)) { return TCL_ERROR; } Tcl_SetObjResult(interp, Tcl_GetRange(varPtr[varIndex], first, last)); @@ -1453,10 +1453,10 @@ TeststringobjCmd( string = Tcl_GetStringFromObj(varPtr[varIndex], &size); - if (Tcl_GetWideIntFromObj(interp, objv[3], &length) != TCL_OK) { + if (Tcl_GetIntForIndex(interp, objv[3], size-1, &length) != TCL_OK) { return TCL_ERROR; } - if ((length < 0) || ((Tcl_WideUInt)length > (Tcl_WideUInt)size)) { + if (length == TCL_INDEX_NONE) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "index value out of range", -1)); return TCL_ERROR; @@ -1484,10 +1484,10 @@ TeststringobjCmd( unicode = Tcl_GetUnicodeFromObj(varPtr[varIndex], &size); - if (Tcl_GetWideIntFromObj(interp, objv[3], &length) != TCL_OK) { + if (Tcl_GetIntForIndex(interp, objv[3], size-1, &length) != TCL_OK) { return TCL_ERROR; } - if ((length < 0) || ((Tcl_WideUInt)length > (Tcl_WideUInt)size)) { + if (length == TCL_INDEX_NONE) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "index value out of range", -1)); return TCL_ERROR; @@ -1540,7 +1540,7 @@ TeststringobjCmd( static void SetVarToObj( Tcl_Obj **varPtr, - size_t varIndex, /* Designates the assignment variable. */ + Tcl_Size varIndex, /* Designates the assignment variable. */ Tcl_Obj *objPtr) /* Points to object to assign to var. */ { if (varPtr[varIndex] != NULL) { @@ -1574,14 +1574,14 @@ GetVariableIndex( Tcl_Obj *obj, /* The variable index * specified as a nonnegative number less than * NUMBER_OF_OBJECT_VARS. */ - size_t *indexPtr) /* Place to store converted result. */ + Tcl_Size *indexPtr) /* Place to store converted result. */ { - Tcl_WideInt index; + Tcl_Size index; - if (Tcl_GetWideIntFromObj(interp, obj, &index) != TCL_OK) { + if (Tcl_GetIntForIndex(interp, obj, NUMBER_OF_OBJECT_VARS - 1, &index) != TCL_OK) { return TCL_ERROR; } - if (index < 0 || index >= NUMBER_OF_OBJECT_VARS) { + if (index == TCL_INDEX_NONE) { Tcl_ResetResult(interp); Tcl_AppendToObj(Tcl_GetObjResult(interp), "bad variable index", -1); return TCL_ERROR; @@ -1613,7 +1613,7 @@ static int CheckIfVarUnset( Tcl_Interp *interp, /* Interpreter for error reporting. */ Tcl_Obj ** varPtr, - size_t varIndex) /* Index of the test variable to check. */ + Tcl_Size varIndex) /* Index of the test variable to check. */ { if (varPtr[varIndex] == NULL) { char buf[32 + TCL_INTEGER_SPACE]; |