summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-11-01 12:35:40 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-11-01 12:35:40 (GMT)
commit9e2ed8b729812f2ab4c70025a0e71f255bec1a78 (patch)
treee253e38402144ddbcfac37c63ebd46080350fec4
parentadc216698f7b3e45354f185b714df1754c429aa9 (diff)
downloadtcl-9e2ed8b729812f2ab4c70025a0e71f255bec1a78.zip
tcl-9e2ed8b729812f2ab4c70025a0e71f255bec1a78.tar.gz
tcl-9e2ed8b729812f2ab4c70025a0e71f255bec1a78.tar.bz2
Finally, get rid of tclWideIntType completely
-rw-r--r--generic/tclAssembly.c2
-rw-r--r--generic/tclBasic.c2
-rw-r--r--generic/tclCmdMZ.c4
-rw-r--r--generic/tclExecute.c68
-rw-r--r--generic/tclInt.h53
-rw-r--r--generic/tclObj.c67
-rw-r--r--generic/tclStrToD.c4
-rw-r--r--generic/tclTimer.c1
-rw-r--r--generic/tclUtil.c4
-rw-r--r--generic/tclZlib.c2
10 files changed, 56 insertions, 151 deletions
diff --git a/generic/tclAssembly.c b/generic/tclAssembly.c
index c7ded6e..0fd7c60 100644
--- a/generic/tclAssembly.c
+++ b/generic/tclAssembly.c
@@ -4266,7 +4266,7 @@ AddBasicBlockRangeToErrorInfo(
Tcl_AppendObjToErrorInfo(interp, lineNo);
Tcl_AddErrorInfo(interp, " and ");
if (bbPtr->successor1 != NULL) {
- TclSetWideIntObj(lineNo, bbPtr->successor1->startLine);
+ TclSetWideObj(lineNo, bbPtr->successor1->startLine);
Tcl_AppendObjToErrorInfo(interp, lineNo);
} else {
Tcl_AddErrorInfo(interp, "end of assembly code");
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index f69e861..f84b420 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -3651,7 +3651,7 @@ OldMathFuncProc(
*/
if (funcResult.type == TCL_INT) {
- TclNewLongObj(valuePtr, funcResult.intValue);
+ TclNewWideObj(valuePtr, funcResult.intValue);
} else if (funcResult.type == TCL_WIDE_INT) {
valuePtr = Tcl_NewWideIntObj(funcResult.wideValue);
} else {
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index c984bbe..8ab687f 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -1596,7 +1596,6 @@ StringIsCmd(
/* TODO */
if ((objPtr->typePtr == &tclDoubleType) ||
(objPtr->typePtr == &tclIntType) ||
- (objPtr->typePtr == &tclWideIntType) ||
(objPtr->typePtr == &tclBignumType)) {
break;
}
@@ -1631,7 +1630,6 @@ StringIsCmd(
goto failedIntParse;
case STR_IS_ENTIER:
if ((objPtr->typePtr == &tclIntType) ||
- (objPtr->typePtr == &tclWideIntType) ||
(objPtr->typePtr == &tclBignumType)) {
break;
}
@@ -4289,7 +4287,7 @@ TclNRTryObjCmd(
}
info[0] = objv[i]; /* type */
- TclNewLongObj(info[1], code); /* returnCode */
+ TclNewWideObj(info[1], code); /* returnCode */
if (info[2] == NULL) { /* errorCodePrefix */
TclNewObj(info[2]);
}
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 9eed936..51f9bff 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -325,7 +325,7 @@ VarHashCreateVar(
NEXT_INST_F(((condition)? TclGetInt4AtPtr(pc+1) : 5), (cleanup), 0); \
default: \
if ((condition) < 0) { \
- TclNewLongObj(objResultPtr, -1); \
+ TclNewWideObj(objResultPtr, -1); \
} else { \
objResultPtr = TCONST((condition) > 0); \
} \
@@ -346,7 +346,7 @@ VarHashCreateVar(
NEXT_INST_V(((condition)? TclGetInt4AtPtr(pc+1) : 5), (cleanup), 0); \
default: \
if ((condition) < 0) { \
- TclNewLongObj(objResultPtr, -1); \
+ TclNewWideObj(objResultPtr, -1); \
} else { \
objResultPtr = TCONST((condition) > 0); \
} \
@@ -357,7 +357,7 @@ VarHashCreateVar(
#define JUMP_PEEPHOLE_F(condition, pcAdjustment, cleanup) \
do{ \
if ((condition) < 0) { \
- TclNewLongObj(objResultPtr, -1); \
+ TclNewWideObj(objResultPtr, -1); \
} else { \
objResultPtr = TCONST((condition) > 0); \
} \
@@ -366,7 +366,7 @@ VarHashCreateVar(
#define JUMP_PEEPHOLE_V(condition, pcAdjustment, cleanup) \
do{ \
if ((condition) < 0) { \
- TclNewLongObj(objResultPtr, -1); \
+ TclNewWideObj(objResultPtr, -1); \
} else { \
objResultPtr = TCONST((condition) > 0); \
} \
@@ -498,7 +498,6 @@ VarHashCreateVar(
* ClientData *ptrPtr, int *tPtr);
*/
-#ifdef TCL_WIDE_INT_IS_LONG
#define GetNumberFromObj(interp, objPtr, ptrPtr, tPtr) \
(((objPtr)->typePtr == &tclIntType) \
? (*(tPtr) = TCL_NUMBER_WIDE, \
@@ -513,26 +512,6 @@ VarHashCreateVar(
(((objPtr)->bytes != NULL) && ((objPtr)->length == 0)) \
? TCL_ERROR : \
TclGetNumberFromObj((interp), (objPtr), (ptrPtr), (tPtr)))
-#else /* !TCL_WIDE_INT_IS_LONG */
-#define GetNumberFromObj(interp, objPtr, ptrPtr, tPtr) \
- (((objPtr)->typePtr == &tclIntType) \
- ? (*(tPtr) = TCL_NUMBER_WIDE, \
- *(ptrPtr) = (ClientData) \
- (&((objPtr)->internalRep.wideValue)), TCL_OK) : \
- ((objPtr)->typePtr == &tclWideIntType) \
- ? (*(tPtr) = TCL_NUMBER_WIDE, \
- *(ptrPtr) = (ClientData) \
- (&((objPtr)->internalRep.wideValue)), TCL_OK) : \
- ((objPtr)->typePtr == &tclDoubleType) \
- ? (((TclIsNaN((objPtr)->internalRep.doubleValue)) \
- ? (*(tPtr) = TCL_NUMBER_NAN) \
- : (*(tPtr) = TCL_NUMBER_DOUBLE)), \
- *(ptrPtr) = (ClientData) \
- (&((objPtr)->internalRep.doubleValue)), TCL_OK) : \
- (((objPtr)->bytes != NULL) && ((objPtr)->length == 0)) \
- ? TCL_ERROR : \
- TclGetNumberFromObj((interp), (objPtr), (ptrPtr), (tPtr)))
-#endif /* TCL_WIDE_INT_IS_LONG */
/*
* Macro used in this file to save a function call for common uses of
@@ -873,9 +852,9 @@ TclCreateExecEnv(
+ (size_t) (size-1) * sizeof(Tcl_Obj *));
eePtr->execStackPtr = esPtr;
- TclNewLongObj(eePtr->constants[0], 0);
+ TclNewWideObj(eePtr->constants[0], 0);
Tcl_IncrRefCount(eePtr->constants[0]);
- TclNewLongObj(eePtr->constants[1], 1);
+ TclNewWideObj(eePtr->constants[1], 1);
Tcl_IncrRefCount(eePtr->constants[1]);
eePtr->interp = interp;
eePtr->callbackPtr = NULL;
@@ -3676,7 +3655,7 @@ TEBCresume(
varPtr->value.objPtr = objResultPtr;
} else {
objResultPtr = objPtr;
- TclSetWideIntObj(objPtr, sum);
+ TclSetWideObj(objPtr, sum);
}
goto doneIncr;
}
@@ -3696,7 +3675,7 @@ TEBCresume(
* use macro form that doesn't range test again.
*/
- TclSetWideIntObj(objPtr, w+increment);
+ TclSetWideObj(objPtr, w+increment);
}
goto doneIncr;
} /* end if (type == TCL_NUMBER_WIDE) */
@@ -3709,7 +3688,7 @@ TEBCresume(
} else {
objResultPtr = objPtr;
}
- TclNewLongObj(incrPtr, increment);
+ TclNewWideObj(incrPtr, increment);
if (TclIncrObj(interp, objResultPtr, incrPtr) != TCL_OK) {
Tcl_DecrRefCount(incrPtr);
TRACE_ERROR(interp);
@@ -3723,7 +3702,7 @@ TEBCresume(
* All other cases, flow through to generic handling.
*/
- TclNewLongObj(incrPtr, increment);
+ TclNewWideObj(incrPtr, increment);
Tcl_IncrRefCount(incrPtr);
doIncrScalar:
@@ -4421,7 +4400,7 @@ TEBCresume(
NEXT_INST_F(1, 0, 1);
}
case INST_INFO_LEVEL_NUM:
- TclNewLongObj(objResultPtr, iPtr->varFramePtr->level);
+ TclNewWideObj(objResultPtr, iPtr->varFramePtr->level);
TRACE_WITH_OBJ(("=> "), objResultPtr);
NEXT_INST_F(1, 0, 1);
case INST_INFO_LEVEL_ARGS: {
@@ -4790,7 +4769,7 @@ TEBCresume(
TRACE_ERROR(interp);
goto gotError;
}
- TclNewLongObj(objResultPtr, length);
+ TclNewWideObj(objResultPtr, length);
TRACE_APPEND(("%d\n", length));
NEXT_INST_F(1, 1, 1);
@@ -5261,7 +5240,7 @@ TEBCresume(
case INST_STR_LEN:
valuePtr = OBJ_AT_TOS;
length = Tcl_GetCharLength(valuePtr);
- TclNewLongObj(objResultPtr, length);
+ TclNewWideObj(objResultPtr, length);
TRACE(("\"%.20s\" => %d\n", O2S(valuePtr), length));
NEXT_INST_F(1, 1, 1);
@@ -5616,7 +5595,7 @@ TEBCresume(
TRACE(("%.20s %.20s => %d\n",
O2S(OBJ_UNDER_TOS), O2S(OBJ_AT_TOS), match));
- TclNewLongObj(objResultPtr, match);
+ TclNewWideObj(objResultPtr, match);
NEXT_INST_F(1, 2, 1);
case INST_STR_FIND_LAST:
@@ -5624,7 +5603,7 @@ TEBCresume(
TRACE(("%.20s %.20s => %d\n",
O2S(OBJ_UNDER_TOS), O2S(OBJ_AT_TOS), match));
- TclNewLongObj(objResultPtr, match);
+ TclNewWideObj(objResultPtr, match);
NEXT_INST_F(1, 2, 1);
case INST_STR_CLASS:
@@ -5822,7 +5801,7 @@ TEBCresume(
type1 = TCL_NUMBER_WIDE;
}
}
- TclNewLongObj(objResultPtr, type1);
+ TclNewWideObj(objResultPtr, type1);
TRACE(("\"%.20s\" => %d\n", O2S(OBJ_AT_TOS), type1));
NEXT_INST_F(1, 1, 1);
@@ -6015,7 +5994,7 @@ TEBCresume(
if (w1 > 0L) {
objResultPtr = TCONST(0);
} else {
- TclNewLongObj(objResultPtr, -1);
+ TclNewWideObj(objResultPtr, -1);
}
TRACE(("%s\n", O2S(objResultPtr)));
NEXT_INST_F(1, 2, 1);
@@ -6326,7 +6305,7 @@ TEBCresume(
TRACE_APPEND(("%s\n", O2S(objResultPtr)));
NEXT_INST_F(1, 1, 1);
}
- TclSetWideIntObj(valuePtr, ~w1);
+ TclSetWideObj(valuePtr, ~w1);
TRACE_APPEND(("%s\n", O2S(valuePtr)));
NEXT_INST_F(1, 0, 0);
}
@@ -6364,7 +6343,7 @@ TEBCresume(
TRACE_APPEND(("%s\n", O2S(objResultPtr)));
NEXT_INST_F(1, 1, 1);
}
- TclSetWideIntObj(valuePtr, -w1);
+ TclSetWideObj(valuePtr, -w1);
TRACE_APPEND(("%s\n", O2S(valuePtr)));
NEXT_INST_F(1, 0, 0);
}
@@ -6525,10 +6504,10 @@ TEBCresume(
oldValuePtr = iterVarPtr->value.objPtr;
if (oldValuePtr == NULL) {
- TclNewLongObj(iterVarPtr->value.objPtr, -1);
+ TclNewWideObj(iterVarPtr->value.objPtr, -1);
Tcl_IncrRefCount(iterVarPtr->value.objPtr);
} else {
- TclSetLongObj(oldValuePtr, -1);
+ TclSetWideObj(oldValuePtr, -1);
}
TRACE(("%u => loop iter count temp %d\n", opnd, iterTmpIndex));
@@ -6563,7 +6542,7 @@ TEBCresume(
iterVarPtr = LOCAL(infoPtr->loopCtTemp);
valuePtr = iterVarPtr->value.objPtr;
iterNum = valuePtr->internalRep.wideValue + 1;
- TclSetLongObj(valuePtr, iterNum);
+ TclSetWideObj(valuePtr, iterNum);
/*
* Check whether all value lists are exhausted and we should stop the
@@ -6896,7 +6875,7 @@ TEBCresume(
NEXT_INST_F(1, 0, -1);
case INST_PUSH_RETURN_CODE:
- TclNewLongObj(objResultPtr, result);
+ TclNewWideObj(objResultPtr, result);
TRACE(("=> %u\n", result));
NEXT_INST_F(1, 0, 1);
@@ -7562,7 +7541,6 @@ TEBCresume(
default:
Tcl_Panic("clockRead instruction with unknown clock#");
}
- /* TclNewWideObj(objResultPtr, wval); doesn't exist */
objResultPtr = Tcl_NewWideIntObj(wval);
TRACE_WITH_OBJ(("=> "), objResultPtr);
NEXT_INST_F(2, 0, 1);
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 3799287..34e3e43 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -2451,12 +2451,13 @@ typedef struct List {
* WARNING: these macros eval their args more than once.
*/
-#define TclGetLongFromObj(interp, objPtr, longPtr) \
+#define TclGetLongFromObj(interp, objPtr, longPtr) Tcl_GetLongFromObj(interp, objPtr, longPtr)
+#define TclGetLongFromObjX(interp, objPtr, longPtr) \
(((objPtr)->typePtr == &tclIntType) \
? ((*(longPtr) = (objPtr)->internalRep.wideValue), TCL_OK) \
: Tcl_GetLongFromObj((interp), (objPtr), (longPtr)))
-#if (LONG_MAX == INT_MAX)
+#if 0
#define TclGetIntFromObj(interp, objPtr, intPtr) \
(((objPtr)->typePtr == &tclIntType) \
? ((*(intPtr) = (objPtr)->internalRep.wideValue), TCL_OK) \
@@ -2480,21 +2481,11 @@ typedef struct List {
* Tcl_WideInt *wideIntPtr);
*/
-#ifdef TCL_WIDE_INT_IS_LONG
#define TclGetWideIntFromObj(interp, objPtr, wideIntPtr) \
(((objPtr)->typePtr == &tclIntType) \
? (*(wideIntPtr) = (Tcl_WideInt) \
((objPtr)->internalRep.wideValue), TCL_OK) : \
Tcl_GetWideIntFromObj((interp), (objPtr), (wideIntPtr)))
-#else /* !TCL_WIDE_INT_IS_LONG */
-#define TclGetWideIntFromObj(interp, objPtr, wideIntPtr) \
- (((objPtr)->typePtr == &tclWideIntType) \
- ? (*(wideIntPtr) = (objPtr)->internalRep.wideValue, TCL_OK) : \
- ((objPtr)->typePtr == &tclIntType) \
- ? (*(wideIntPtr) = (Tcl_WideInt) \
- ((objPtr)->internalRep.wideValue), TCL_OK) : \
- Tcl_GetWideIntFromObj((interp), (objPtr), (wideIntPtr)))
-#endif /* TCL_WIDE_INT_IS_LONG */
/*
* Flag values for TclTraceDictPath().
@@ -2720,7 +2711,6 @@ MODULE_SCOPE const Tcl_ObjType tclDictType;
MODULE_SCOPE const Tcl_ObjType tclProcBodyType;
MODULE_SCOPE const Tcl_ObjType tclStringType;
MODULE_SCOPE const Tcl_ObjType tclEnsembleCmdType;
-MODULE_SCOPE const Tcl_ObjType tclWideIntType;
MODULE_SCOPE const Tcl_ObjType tclRegexpType;
MODULE_SCOPE Tcl_ObjType tclCmdNameType;
@@ -4533,13 +4523,12 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
* core. They should only be called on unshared objects. The ANSI C
* "prototypes" for these macros are:
*
- * MODULE_SCOPE void TclSetLongObj(Tcl_Obj *objPtr, long longValue);
- * MODULE_SCOPE void TclSetWideIntObj(Tcl_Obj *objPtr, Tcl_WideInt w);
+ * MODULE_SCOPE void TclSetWideObj(Tcl_Obj *objPtr, Tcl_WideInt w);
* MODULE_SCOPE void TclSetDoubleObj(Tcl_Obj *objPtr, double d);
*----------------------------------------------------------------
*/
-#define TclSetLongObj(objPtr, i) \
+#define TclSetWideObj(objPtr, i) \
do { \
TclInvalidateStringRep(objPtr); \
TclFreeIntRep(objPtr); \
@@ -4547,18 +4536,6 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
(objPtr)->typePtr = &tclIntType; \
} while (0)
-#ifdef TCL_WIDE_INT_IS_LONG
-#define TclSetWideIntObj(objPtr, w) TclSetLongObj(objPtr, w)
-#else
-#define TclSetWideIntObj(objPtr, w) \
- do { \
- TclInvalidateStringRep(objPtr); \
- TclFreeIntRep(objPtr); \
- (objPtr)->internalRep.wideValue = (Tcl_WideInt)(w); \
- (objPtr)->typePtr = &tclWideIntType; \
- } while (0)
-#endif
-
#define TclSetDoubleObj(objPtr, d) \
do { \
TclInvalidateStringRep(objPtr); \
@@ -4573,7 +4550,6 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
* types, avoiding the corresponding function calls in time critical parts of
* the core. The ANSI C "prototypes" for these macros are:
*
- * MODULE_SCOPE void TclNewLongObj(Tcl_Obj *objPtr, long l);
* MODULE_SCOPE void TclNewWideObj(Tcl_Obj *objPtr, Tcl_WideInt w);
* MODULE_SCOPE void TclNewDoubleObj(Tcl_Obj *objPtr, double d);
* MODULE_SCOPE void TclNewStringObj(Tcl_Obj *objPtr, const char *s, int len);
@@ -4583,7 +4559,7 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
*/
#ifndef TCL_MEM_DEBUG
-#define TclNewLongObj(objPtr, i) \
+#define TclNewWideObj(objPtr, i) \
do { \
TclIncrObjsAllocated(); \
TclAllocObjStorage(objPtr); \
@@ -4594,20 +4570,6 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
TCL_DTRACE_OBJ_CREATE(objPtr); \
} while (0)
-#ifndef TCL_WIDE_INT_IS_LONG
-#define TclNewWideObj(objPtr, i) \
- do { \
- TclIncrObjsAllocated(); \
- TclAllocObjStorage(objPtr); \
- (objPtr)->refCount = 0; \
- (objPtr)->bytes = NULL; \
- (objPtr)->internalRep.wideValue = (Tcl_WideInt)(i); \
- (objPtr)->typePtr = &tclWideIntType; \
- TCL_DTRACE_OBJ_CREATE(objPtr); \
- } while (0)
-#else
-#define TclNewWideObj(objPtr, i) TclNewLongObj(objPtr, i)
-#endif
#define TclNewDoubleObj(objPtr, d) \
do { \
TclIncrObjsAllocated(); \
@@ -4630,9 +4592,6 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
} while (0)
#else /* TCL_MEM_DEBUG */
-#define TclNewLongObj(objPtr, l) \
- (objPtr) = Tcl_NewLongObj(l)
-
#define TclNewWideObj(objPtr, w) \
(objPtr) = Tcl_NewWideIntObj(w)
diff --git a/generic/tclObj.c b/generic/tclObj.c
index e4613ba..04fdeaa 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -266,13 +266,6 @@ const Tcl_ObjType tclIntType = {
UpdateStringOfInt, /* updateStringProc */
SetIntFromAny /* setFromAnyProc */
};
-const Tcl_ObjType tclWideIntType = {
- "wideInt", /* name */
- NULL, /* freeIntRepProc */
- NULL, /* dupIntRepProc */
- UpdateStringOfInt, /* updateStringProc */
- SetIntFromAny /* setFromAnyProc */
-};
const Tcl_ObjType tclBignumType = {
"bignum", /* name */
FreeBignum, /* freeIntRepProc */
@@ -1753,7 +1746,7 @@ Tcl_NewBooleanObj(
{
register Tcl_Obj *objPtr;
- TclNewLongObj(objPtr, boolValue!=0);
+ TclNewWideObj(objPtr, boolValue!=0);
return objPtr;
}
#endif /* TCL_MEM_DEBUG */
@@ -1848,7 +1841,7 @@ Tcl_SetBooleanObj(
Tcl_Panic("%s called with shared object", "Tcl_SetBooleanObj");
}
- TclSetLongObj(objPtr, boolValue!=0);
+ TclSetWideObj(objPtr, boolValue!=0);
}
#endif /* TCL_NO_DEPRECATED */
@@ -1907,10 +1900,6 @@ Tcl_GetBooleanFromObj(
*boolPtr = 1;
return TCL_OK;
}
- if (objPtr->typePtr == &tclWideIntType) {
- *boolPtr = (objPtr->internalRep.wideValue != 0);
- return TCL_OK;
- }
} while ((ParseBoolean(objPtr) == TCL_OK) || (TCL_OK ==
TclParseNumber(interp, objPtr, "boolean value", NULL,-1,NULL,0)));
return TCL_ERROR;
@@ -1960,10 +1949,6 @@ TclSetBooleanFromAny(
goto badBoolean;
}
- if (objPtr->typePtr == &tclWideIntType) {
- goto badBoolean;
- }
-
if (objPtr->typePtr == &tclDoubleType) {
goto badBoolean;
}
@@ -2281,7 +2266,7 @@ Tcl_GetDoubleFromObj(
return TCL_OK;
}
if (objPtr->typePtr == &tclIntType) {
- *dblPtr = objPtr->internalRep.wideValue;
+ *dblPtr = (double) objPtr->internalRep.wideValue;
return TCL_OK;
}
if (objPtr->typePtr == &tclBignumType) {
@@ -2291,10 +2276,6 @@ Tcl_GetDoubleFromObj(
*dblPtr = TclBignumToDouble(&big);
return TCL_OK;
}
- if (objPtr->typePtr == &tclWideIntType) {
- *dblPtr = (double) objPtr->internalRep.wideValue;
- return TCL_OK;
- }
} while (SetDoubleFromAny(interp, objPtr) == TCL_OK);
return TCL_ERROR;
}
@@ -2412,7 +2393,7 @@ Tcl_NewIntObj(
{
register Tcl_Obj *objPtr;
- TclNewLongObj(objPtr, intValue);
+ TclNewWideObj(objPtr, intValue);
return objPtr;
}
#endif /* if TCL_MEM_DEBUG */
@@ -2445,7 +2426,7 @@ Tcl_SetIntObj(
Tcl_Panic("%s called with shared object", "Tcl_SetIntObj");
}
- TclSetLongObj(objPtr, intValue);
+ TclSetWideObj(objPtr, intValue);
}
/*
@@ -2610,7 +2591,7 @@ Tcl_NewLongObj(
{
register Tcl_Obj *objPtr;
- TclNewLongObj(objPtr, longValue);
+ TclNewWideObj(objPtr, longValue);
return objPtr;
}
#endif /* if TCL_MEM_DEBUG */
@@ -2711,7 +2692,7 @@ Tcl_SetLongObj(
Tcl_Panic("%s called with shared object", "Tcl_SetLongObj");
}
- TclSetLongObj(objPtr, longValue);
+ TclSetWideObj(objPtr, longValue);
}
/*
@@ -2742,11 +2723,13 @@ Tcl_GetLongFromObj(
register long *longPtr) /* Place to store resulting long. */
{
do {
+#if (LONG_MAX == LLONG_MAX)
if (objPtr->typePtr == &tclIntType) {
*longPtr = objPtr->internalRep.wideValue;
return TCL_OK;
}
- if (objPtr->typePtr == &tclWideIntType) {
+#else
+ if (objPtr->typePtr == &tclIntType) {
/*
* We return any integer in the range -ULONG_MAX to ULONG_MAX
* converted to a long, ignoring overflow. The rule preserves
@@ -2764,6 +2747,7 @@ Tcl_GetLongFromObj(
}
goto tooLarge;
}
+#endif
if (objPtr->typePtr == &tclDoubleType) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
@@ -2802,7 +2786,9 @@ Tcl_GetLongFromObj(
return TCL_OK;
}
}
+#if (LONG_MAX != LLONG_MAX)
tooLarge:
+#endif
if (interp != NULL) {
const char *s = "integer value too large to represent";
Tcl_Obj *msg = Tcl_NewStringObj(s, -1);
@@ -2966,12 +2952,7 @@ Tcl_SetWideIntObj(
Tcl_Panic("%s called with shared object", "Tcl_SetWideIntObj");
}
- if ((wideValue >= (Tcl_WideInt) LONG_MIN)
- && (wideValue <= (Tcl_WideInt) LONG_MAX)) {
- TclSetLongObj(objPtr, wideValue);
- } else {
- TclSetWideIntObj(objPtr, wideValue);
- }
+ TclSetWideObj(objPtr, wideValue);
}
/*
@@ -3003,12 +2984,8 @@ Tcl_GetWideIntFromObj(
/* Place to store resulting long. */
{
do {
- if (objPtr->typePtr == &tclWideIntType) {
- *wideIntPtr = objPtr->internalRep.wideValue;
- return TCL_OK;
- }
if (objPtr->typePtr == &tclIntType) {
- *wideIntPtr = (Tcl_WideInt) objPtr->internalRep.wideValue;
+ *wideIntPtr = objPtr->internalRep.wideValue;
return TCL_OK;
}
if (objPtr->typePtr == &tclDoubleType) {
@@ -3303,10 +3280,6 @@ GetBignumFromObj(
return TCL_OK;
}
if (objPtr->typePtr == &tclIntType) {
- TclInitBignumFromLong(bignumValue, objPtr->internalRep.wideValue);
- return TCL_OK;
- }
- if (objPtr->typePtr == &tclWideIntType) {
TclInitBignumFromWideInt(bignumValue,
objPtr->internalRep.wideValue);
return TCL_OK;
@@ -3435,9 +3408,9 @@ Tcl_SetBignumObj(
goto tooLargeForLong;
}
if (bignumValue->sign) {
- TclSetLongObj(objPtr, -(long)value);
+ TclSetWideObj(objPtr, -(long)value);
} else {
- TclSetLongObj(objPtr, (long)value);
+ TclSetWideObj(objPtr, (long)value);
}
mp_clear(bignumValue);
return;
@@ -3461,9 +3434,9 @@ Tcl_SetBignumObj(
goto tooLargeForWide;
}
if (bignumValue->sign) {
- TclSetWideIntObj(objPtr, -(Tcl_WideInt)value);
+ TclSetWideObj(objPtr, -(Tcl_WideInt)value);
} else {
- TclSetWideIntObj(objPtr, (Tcl_WideInt)value);
+ TclSetWideObj(objPtr, (Tcl_WideInt)value);
}
mp_clear(bignumValue);
return;
@@ -3550,7 +3523,7 @@ TclGetNumberFromObj(
*clientDataPtr = &objPtr->internalRep.doubleValue;
return TCL_OK;
}
- if (objPtr->typePtr == &tclIntType || objPtr->typePtr == &tclWideIntType) {
+ if (objPtr->typePtr == &tclIntType) {
*typePtr = TCL_NUMBER_WIDE;
*clientDataPtr = &objPtr->internalRep.wideValue;
return TCL_OK;
diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c
index c8bc7b5..9663c21 100644
--- a/generic/tclStrToD.c
+++ b/generic/tclStrToD.c
@@ -1272,7 +1272,7 @@ TclParseNumber(
(Tcl_WideUInt)(((~(unsigned long)0) >> 1) + signum)) {
#ifndef TCL_WIDE_INT_IS_LONG
if (octalSignificandWide <= (MOST_BITS + signum)) {
- objPtr->typePtr = &tclWideIntType;
+ objPtr->typePtr = &tclIntType;
if (signum) {
objPtr->internalRep.wideValue =
- (Tcl_WideInt) octalSignificandWide;
@@ -1319,7 +1319,7 @@ TclParseNumber(
(Tcl_WideUInt)(((~(unsigned long)0) >> 1) + signum)) {
#ifndef TCL_WIDE_INT_IS_LONG
if (significandWide <= MOST_BITS+signum) {
- objPtr->typePtr = &tclWideIntType;
+ objPtr->typePtr = &tclIntType;
if (signum) {
objPtr->internalRep.wideValue =
- (Tcl_WideInt) significandWide;
diff --git a/generic/tclTimer.c b/generic/tclTimer.c
index 279e110..54854d0 100644
--- a/generic/tclTimer.c
+++ b/generic/tclTimer.c
@@ -819,7 +819,6 @@ Tcl_AfterObjCmd(
*/
if (objv[1]->typePtr == &tclIntType
- || objv[1]->typePtr == &tclWideIntType
|| objv[1]->typePtr == &tclBignumType
|| (Tcl_GetIndexFromObj(NULL, objv[1], afterSubCmds, "", 0,
&index) != TCL_OK)) {
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 198424f..61a84ce 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -3768,9 +3768,7 @@ SetEndOffsetFromAny(
TCL_PARSE_INTEGER_ONLY) != TCL_OK) {
return TCL_ERROR;
}
- if ((objPtr->typePtr != &tclIntType)
- && (objPtr->typePtr != &tclWideIntType)
- ) {
+ if (objPtr->typePtr != &tclIntType) {
goto badIndexFormat;
}
offset = objPtr->internalRep.wideValue;
diff --git a/generic/tclZlib.c b/generic/tclZlib.c
index 33eebd1..dc124f7 100644
--- a/generic/tclZlib.c
+++ b/generic/tclZlib.c
@@ -373,7 +373,7 @@ ConvertErrorToList(
default:
TclNewLiteralStringObj(objv[2], "UNKNOWN");
- TclNewLongObj(objv[3], code);
+ TclNewWideObj(objv[3], code);
return Tcl_NewListObj(4, objv);
}
}