summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2003-04-16 23:33:43 (GMT)
committerdgp <dgp@users.sourceforge.net>2003-04-16 23:33:43 (GMT)
commit221d64cae9a7781a4b3dd2a2e2e273fd6196c09e (patch)
tree4156c4da5bb0e708ca942f78b5c01ec34686f8bb
parentcaa2e40c5ef3e6d45edebe3e156b25903fb30eba (diff)
downloadtcl-221d64cae9a7781a4b3dd2a2e2e273fd6196c09e.zip
tcl-221d64cae9a7781a4b3dd2a2e2e273fd6196c09e.tar.gz
tcl-221d64cae9a7781a4b3dd2a2e2e273fd6196c09e.tar.bz2
* generic/tcl.h Made changes so that the "wideInt" Tcl_ObjType
* generic/tclObj.c is defined on all platforms, even those where * generic/tclPort.h TCL_WIDE_INT_IS_LONG is defined. Also made the Tcl_Value struct have a wideValue field on all platforms. This is a ***POTENTIAL INCOMPATIBILITY*** for TCL_WIDE_INT_IS_LONG platforms because that struct changes size. This is the same TIP 72 incompatibility that was seen on other platforms at the 8.4.0 release, when this change should have happened as well. [Bug 713562] * generic/tclInt.h: New internal macros TclGetWide() and TclGetLongFromWide() to deal with both forms of the "wideInt" Tcl_ObjType, so that conditional TCL_WIDE_INT_IS_LONG code is confined to the header file. * generic/tclCmdAH.c: Replaced most coding that was conditional * generic/tclCmdIL.c: on TCL_WIDE_INT_IS_LONG with code that * generic/tclExecute.c: works across platforms, sometimes using * generic/tclTest.c: the new macros above to do it. * generic/tclUtil.c: * generic/tclVar.c:
-rw-r--r--ChangeLog23
-rw-r--r--generic/tcl.h7
-rw-r--r--generic/tclCmdAH.c14
-rw-r--r--generic/tclCmdIL.c7
-rw-r--r--generic/tclDictObj.c4
-rw-r--r--generic/tclExecute.c253
-rw-r--r--generic/tclInt.h24
-rw-r--r--generic/tclObj.c34
-rw-r--r--generic/tclPort.h14
-rw-r--r--generic/tclTest.c8
-rw-r--r--generic/tclUtil.c18
-rw-r--r--generic/tclVar.c15
12 files changed, 136 insertions, 285 deletions
diff --git a/ChangeLog b/ChangeLog
index 24c5398..886be9b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2003-04-16 Don Porter <dgp@users.sourceforge.net>
+
+ * generic/tcl.h Made changes so that the "wideInt" Tcl_ObjType
+ * generic/tclObj.c is defined on all platforms, even those where
+ * generic/tclPort.h TCL_WIDE_INT_IS_LONG is defined. Also made
+ the Tcl_Value struct have a wideValue field on all platforms. This is
+ a ***POTENTIAL INCOMPATIBILITY*** for TCL_WIDE_INT_IS_LONG platforms
+ because that struct changes size. This is the same TIP 72
+ incompatibility that was seen on other platforms at the 8.4.0 release,
+ when this change should have happened as well. [Bug 713562]
+
+ * generic/tclInt.h: New internal macros TclGetWide() and
+ TclGetLongFromWide() to deal with both forms of the "wideInt"
+ Tcl_ObjType, so that conditional TCL_WIDE_INT_IS_LONG code
+ is confined to the header file.
+
+ * generic/tclCmdAH.c: Replaced most coding that was conditional
+ * generic/tclCmdIL.c: on TCL_WIDE_INT_IS_LONG with code that
+ * generic/tclExecute.c: works across platforms, sometimes using
+ * generic/tclTest.c: the new macros above to do it.
+ * generic/tclUtil.c:
+ * generic/tclVar.c:
+
2003-04-17 Donal K. Fellows <fellowsd@cs.man.ac.uk>
* doc/socket.n: Added a paragraph to remind people to specify
diff --git a/generic/tcl.h b/generic/tcl.h
index c34f84a..5885e15 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -13,7 +13,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tcl.h,v 1.156 2003/04/05 01:25:10 dkf Exp $
+ * RCS: @(#) $Id: tcl.h,v 1.157 2003/04/16 23:33:43 dgp Exp $
*/
#ifndef _TCL
@@ -632,18 +632,13 @@ typedef struct stat *Tcl_OldStat_;
*/
typedef enum {
TCL_INT, TCL_DOUBLE, TCL_EITHER, TCL_WIDE_INT
-#ifdef TCL_WIDE_INT_IS_LONG
- = TCL_INT
-#endif
} Tcl_ValueType;
typedef struct Tcl_Value {
Tcl_ValueType type; /* Indicates intValue or doubleValue is
* valid, or both. */
long intValue; /* Integer value. */
double doubleValue; /* Double-precision floating value. */
-#ifndef TCL_WIDE_INT_IS_LONG
Tcl_WideInt wideValue; /* Wide (min. 64-bit) integer value. */
-#endif
} Tcl_Value;
/*
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c
index 25574ad..0536dd2 100644
--- a/generic/tclCmdAH.c
+++ b/generic/tclCmdAH.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdAH.c,v 1.30 2003/04/08 22:55:09 dkf Exp $
+ * RCS: @(#) $Id: tclCmdAH.c,v 1.31 2003/04/16 23:33:43 dgp Exp $
*/
#include "tclInt.h"
@@ -1949,10 +1949,8 @@ Tcl_FormatObjCmd(dummy, interp, objc, objv)
* it's a one-word value. */
double doubleValue; /* Used to hold value to pass to sprintf if
* it's a double value. */
-#ifndef TCL_WIDE_INT_IS_LONG
Tcl_WideInt wideValue; /* Used to hold value to pass to sprintf if
* it's a 'long long' value. */
-#endif /* TCL_WIDE_INT_IS_LONG */
int whichValue; /* Indicates which of intValue, ptrValue,
* or doubleValue has the value to pass to
* sprintf, according to the following
@@ -1991,9 +1989,7 @@ Tcl_FormatObjCmd(dummy, interp, objc, objv)
* been set for the current field. */
int gotZero; /* Non-zero indicates that a zero flag has
* been seen in the current field. */
-#ifndef TCL_WIDE_INT_IS_LONG
int useWide; /* Value to be printed is Tcl_WideInt. */
-#endif /* TCL_WIDE_INT_IS_LONG */
/*
* This procedure is a bit nasty. The goal is to use sprintf to
@@ -2024,9 +2020,7 @@ Tcl_FormatObjCmd(dummy, interp, objc, objv)
width = precision = noPercent = useShort = 0;
gotZero = gotMinus = gotPrecision = 0;
-#ifndef TCL_WIDE_INT_IS_LONG
useWide = 0;
-#endif /* TCL_WIDE_INT_IS_LONG */
whichValue = PTR_VALUE;
/*
@@ -2170,7 +2164,6 @@ Tcl_FormatObjCmd(dummy, interp, objc, objv)
}
}
if (*format == 'l') {
-#ifndef TCL_WIDE_INT_IS_LONG
useWide = 1;
/*
* Only add a 'll' modifier for integer values as it makes
@@ -2186,7 +2179,6 @@ Tcl_FormatObjCmd(dummy, interp, objc, objv)
strcpy(newPtr, TCL_LL_MODIFIER);
newPtr += TCL_LL_MODIFIER_SIZE;
}
-#endif /* TCL_WIDE_INT_IS_LONG */
format++;
} else if (*format == 'h') {
useShort = 1;
@@ -2208,7 +2200,6 @@ Tcl_FormatObjCmd(dummy, interp, objc, objv)
case 'u':
case 'x':
case 'X':
-#ifndef TCL_WIDE_INT_IS_LONG
if (useWide) {
if (Tcl_GetWideIntFromObj(interp, /* INTL: Tcl source. */
objv[objIndex], &wideValue) != TCL_OK) {
@@ -2218,7 +2209,6 @@ Tcl_FormatObjCmd(dummy, interp, objc, objv)
size = 40 + precision;
break;
}
-#endif /* TCL_WIDE_INT_IS_LONG */
if (Tcl_GetLongFromObj(interp, /* INTL: Tcl source. */
objv[objIndex], &intValue) != TCL_OK) {
goto fmtError;
@@ -2319,11 +2309,9 @@ Tcl_FormatObjCmd(dummy, interp, objc, objv)
case DOUBLE_VALUE:
sprintf(dst, newFormat, doubleValue); /* INTL: user locale. */
break;
-#ifndef TCL_WIDE_INT_IS_LONG
case WIDE_VALUE:
sprintf(dst, newFormat, wideValue);
break;
-#endif /* TCL_WIDE_INT_IS_LONG */
case INT_VALUE:
if (useShort) {
sprintf(dst, newFormat, (short) intValue);
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c
index 2c77649..1e4dd4c 100644
--- a/generic/tclCmdIL.c
+++ b/generic/tclCmdIL.c
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdIL.c,v 1.47 2003/02/27 16:01:55 dkf Exp $
+ * RCS: @(#) $Id: tclCmdIL.c,v 1.48 2003/04/16 23:33:43 dgp Exp $
*/
#include "tclInt.h"
@@ -323,12 +323,10 @@ Tcl_IncrObjCmd(dummy, interp, objc, objv)
if (objc == 2) {
incrAmount = 1;
} else {
-#ifdef TCL_WIDE_INT_IS_LONG
if (Tcl_GetLongFromObj(interp, objv[2], &incrAmount) != TCL_OK) {
Tcl_AddErrorInfo(interp, "\n (reading increment)");
return TCL_ERROR;
}
-#else
/*
* Need to be a bit cautious to ensure that [expr]-like rules
* are enforced for interpretation of wide integers, despite
@@ -337,7 +335,7 @@ Tcl_IncrObjCmd(dummy, interp, objc, objv)
if (objv[2]->typePtr == &tclIntType) {
incrAmount = objv[2]->internalRep.longValue;
} else if (objv[2]->typePtr == &tclWideIntType) {
- incrAmount = Tcl_WideAsLong(objv[2]->internalRep.wideValue);
+ TclGetLongFromWide(incrAmount,objv[2]);
} else {
Tcl_WideInt wide;
@@ -352,7 +350,6 @@ Tcl_IncrObjCmd(dummy, interp, objc, objv)
objv[2]->internalRep.longValue = incrAmount;
}
}
-#endif
}
/*
diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c
index ee5d7fa..53e7d66 100644
--- a/generic/tclDictObj.c
+++ b/generic/tclDictObj.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclDictObj.c,v 1.6 2003/04/07 13:52:52 dkf Exp $
+ * RCS: @(#) $Id: tclDictObj.c,v 1.7 2003/04/16 23:33:43 dgp Exp $
*/
#include "tclInt.h"
@@ -1712,7 +1712,6 @@ DictIncrCmd(interp, objc, objv)
}
if (valuePtr == NULL) {
valuePtr = Tcl_NewLongObj(incrValue);
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (valuePtr->typePtr == &tclWideIntType) {
Tcl_GetWideIntFromObj(NULL, valuePtr, &wValue);
if (Tcl_IsShared(valuePtr)) {
@@ -1724,7 +1723,6 @@ DictIncrCmd(interp, objc, objv)
}
goto valueAlreadyInDictionary;
}
-#endif /* !TCL_WIDE_INT_IS_LONG */
} else if (valuePtr->typePtr == &tclIntType) {
Tcl_GetLongFromObj(NULL, valuePtr, &lValue);
if (Tcl_IsShared(valuePtr)) {
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 0a54c16..24a48db 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclExecute.c,v 1.97 2003/04/01 07:18:37 dgp Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.98 2003/04/16 23:33:44 dgp Exp $
*/
#include "tclInt.h"
@@ -258,18 +258,6 @@ long tclObjsShared[TCL_MAX_SHARED_OBJ_STATS] = { 0, 0, 0, 0, 0 };
# define O2S(objPtr)
#endif /* TCL_COMPILE_DEBUG */
-
-/*
- * Most of the code to support working with wide values is factored
- * out here because it greatly reduces the number of conditionals
- * through the rest of the file. Note that this needs to be
- * conditional because we do not want to alter Tcl's behaviour on
- * native-64bit platforms...
- */
-
-#ifndef TCL_WIDE_INT_IS_LONG
-#define W0 Tcl_LongAsWide(0)
-
/*
* Macro to read a string containing either a wide or an int and
* decide which it is while decoding it at the same time. This
@@ -297,19 +285,6 @@ long tclObjsShared[TCL_MAX_SHARED_OBJ_STATS] = { 0, 0, 0, 0, 0 };
(objPtr)->internalRep.longValue = (longVar) \
= Tcl_WideAsLong(wideVar); \
}
-#define IS_INTEGER_TYPE(typePtr) \
- ((typePtr) == &tclIntType || (typePtr) == &tclWideIntType)
-/*
- * Extract a double value from a general numeric object.
- */
-#define GET_DOUBLE_VALUE(doubleVar, objPtr, typePtr) \
- if ((typePtr) == &tclIntType) { \
- (doubleVar) = (double) (objPtr)->internalRep.longValue; \
- } else if ((typePtr) == &tclWideIntType) { \
- (doubleVar) = Tcl_WideAsDouble((objPtr)->internalRep.wideValue);\
- } else { \
- (doubleVar) = (objPtr)->internalRep.doubleValue; \
- }
/*
* Combined with REQUIRE_WIDE_OR_INT, this gets a long value from
* an obj.
@@ -318,34 +293,37 @@ long tclObjsShared[TCL_MAX_SHARED_OBJ_STATS] = { 0, 0, 0, 0, 0 };
if ((objPtr)->typePtr == &tclWideIntType) { \
(longVar) = Tcl_WideAsLong(wideVar); \
}
+#define IS_INTEGER_TYPE(typePtr) \
+ ((typePtr) == &tclIntType || (typePtr) == &tclWideIntType)
+#define IS_NUMERIC_TYPE(typePtr) \
+ (IS_INTEGER_TYPE(typePtr) || (typePtr) == &tclDoubleType)
+
+#define W0 Tcl_LongAsWide(0)
/*
* For tracing that uses wide values.
*/
-#define LLTRACE(a) TRACE(a)
-#define LLTRACE_WITH_OBJ(a,b) TRACE_WITH_OBJ(a,b)
#define LLD "%" TCL_LL_MODIFIER "d"
-#else /* TCL_WIDE_INT_IS_LONG */
+
+#ifndef TCL_WIDE_INT_IS_LONG
/*
- * Versions of the above that do not use wide values.
+ * Extract a double value from a general numeric object.
*/
-#define REQUIRE_WIDE_OR_INT(resultVar, objPtr, longVar, wideVar) \
- (resultVar) = Tcl_GetLongFromObj(interp, (objPtr), &(longVar));
-#define GET_WIDE_OR_INT(resultVar, objPtr, longVar, wideVar) \
- (resultVar) = Tcl_GetLongFromObj((Tcl_Interp *) NULL, (objPtr), \
- &(longVar));
-#define IS_INTEGER_TYPE(typePtr) ((typePtr) == &tclIntType)
#define GET_DOUBLE_VALUE(doubleVar, objPtr, typePtr) \
if ((typePtr) == &tclIntType) { \
(doubleVar) = (double) (objPtr)->internalRep.longValue; \
+ } else if ((typePtr) == &tclWideIntType) { \
+ (doubleVar) = Tcl_WideAsDouble((objPtr)->internalRep.wideValue);\
+ } else { \
+ (doubleVar) = (objPtr)->internalRep.doubleValue; \
+ }
+#else /* TCL_WIDE_INT_IS_LONG */
+#define GET_DOUBLE_VALUE(doubleVar, objPtr, typePtr) \
+ if (((typePtr) == &tclIntType) || ((typePtr) == &tclWideIntType)) { \
+ (doubleVar) = (double) (objPtr)->internalRep.longValue; \
} else { \
(doubleVar) = (objPtr)->internalRep.doubleValue; \
}
-#define FORCE_LONG(objPtr, longVar, wideVar)
-#define LLTRACE(a)
-#define LLTRACE_WITH_OBJ(a,b)
#endif /* TCL_WIDE_INT_IS_LONG */
-#define IS_NUMERIC_TYPE(typePtr) \
- (IS_INTEGER_TYPE(typePtr) || (typePtr) == &tclDoubleType)
/*
* Declarations for local procedures to this file:
@@ -371,10 +349,8 @@ static int ExprSrandFunc _ANSI_ARGS_((Tcl_Interp *interp,
ExecEnv *eePtr, ClientData clientData));
static int ExprUnaryFunc _ANSI_ARGS_((Tcl_Interp *interp,
ExecEnv *eePtr, ClientData clientData));
-#ifndef TCL_WIDE_INT_IS_LONG
static int ExprWideFunc _ANSI_ARGS_((Tcl_Interp *interp,
ExecEnv *eePtr, ClientData clientData));
-#endif /* TCL_WIDE_INT_IS_LONG */
#ifdef TCL_COMPILE_STATS
static int EvalStatsCmd _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int objc,
@@ -437,11 +413,7 @@ BuiltinFunc tclBuiltinFuncTable[] = {
{"rand", 0, {TCL_EITHER}, ExprRandFunc, 0}, /* NOTE: rand takes no args. */
{"round", 1, {TCL_EITHER}, ExprRoundFunc, 0},
{"srand", 1, {TCL_INT}, ExprSrandFunc, 0},
-#ifdef TCL_WIDE_INT_IS_LONG
- {"wide", 1, {TCL_EITHER}, ExprIntFunc, 0},
-#else
{"wide", 1, {TCL_EITHER}, ExprWideFunc, 0},
-#endif /* TCL_WIDE_INT_IS_LONG */
{0},
};
@@ -1087,9 +1059,7 @@ TclExecuteByteCode(interp, codePtr)
char *bytes;
int length;
long i = 0; /* Init. avoids compiler warning. */
-#ifndef TCL_WIDE_INT_IS_LONG
Tcl_WideInt w;
-#endif
register int cleanup;
Tcl_Obj *objResultPtr;
char *part1, *part2;
@@ -1902,10 +1872,8 @@ TclExecuteByteCode(interp, codePtr)
valuePtr = stackPtr[stackTop];
if (valuePtr->typePtr == &tclIntType) {
i = valuePtr->internalRep.longValue;
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (valuePtr->typePtr == &tclWideIntType) {
- i = Tcl_WideAsLong(valuePtr->internalRep.wideValue);
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TclGetLongFromWide(i,valuePtr);
} else {
REQUIRE_WIDE_OR_INT(result, valuePtr, i, w);
if (result != TCL_OK) {
@@ -2092,10 +2060,9 @@ TclExecuteByteCode(interp, codePtr)
b = (valuePtr->internalRep.longValue != 0);
} else if (valuePtr->typePtr == &tclDoubleType) {
b = (valuePtr->internalRep.doubleValue != 0.0);
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (valuePtr->typePtr == &tclWideIntType) {
- b = (valuePtr->internalRep.wideValue != W0);
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TclGetWide(w,valuePtr);
+ b = (w != W0);
} else {
result = Tcl_GetBooleanFromObj(interp, valuePtr, &b);
if (result != TCL_OK) {
@@ -2147,27 +2114,20 @@ TclExecuteByteCode(interp, codePtr)
if ((t1Ptr == &tclIntType) || (t1Ptr == &tclBooleanType)) {
i1 = (valuePtr->internalRep.longValue != 0);
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (t1Ptr == &tclWideIntType) {
- i1 = (valuePtr->internalRep.wideValue != W0);
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TclGetWide(w,valuePtr);
+ i1 = (w != W0);
} else if (t1Ptr == &tclDoubleType) {
i1 = (valuePtr->internalRep.doubleValue != 0.0);
} else {
s = Tcl_GetStringFromObj(valuePtr, &length);
if (TclLooksLikeInt(s, length)) {
-#ifdef TCL_WIDE_INT_IS_LONG
- result = Tcl_GetLongFromObj((Tcl_Interp *) NULL,
- valuePtr, &i);
- i1 = (i != 0);
-#else /* !TCL_WIDE_INT_IS_LONG */
GET_WIDE_OR_INT(result, valuePtr, i, w);
if (valuePtr->typePtr == &tclIntType) {
i1 = (i != 0);
} else {
i1 = (w != W0);
}
-#endif /* TCL_WIDE_INT_IS_LONG */
} else {
result = Tcl_GetBooleanFromObj((Tcl_Interp *) NULL,
valuePtr, &i1);
@@ -2183,27 +2143,20 @@ TclExecuteByteCode(interp, codePtr)
if ((t2Ptr == &tclIntType) || (t2Ptr == &tclBooleanType)) {
i2 = (value2Ptr->internalRep.longValue != 0);
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (t2Ptr == &tclWideIntType) {
- i2 = (value2Ptr->internalRep.wideValue != W0);
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TclGetWide(w,value2Ptr);
+ i2 = (w != W0);
} else if (t2Ptr == &tclDoubleType) {
i2 = (value2Ptr->internalRep.doubleValue != 0.0);
} else {
s = Tcl_GetStringFromObj(value2Ptr, &length);
if (TclLooksLikeInt(s, length)) {
-#ifdef TCL_WIDE_INT_IS_LONG
- result = Tcl_GetLongFromObj((Tcl_Interp *) NULL,
- value2Ptr, &i);
- i2 = (i != 0);
-#else /* !TCL_WIDE_INT_IS_LONG */
GET_WIDE_OR_INT(result, value2Ptr, i, w);
if (value2Ptr->typePtr == &tclIntType) {
i2 = (i != 0);
} else {
i2 = (w != W0);
}
-#endif /* TCL_WIDE_INT_IS_LONG */
} else {
result = Tcl_GetBooleanFromObj((Tcl_Interp *) NULL, value2Ptr, &i2);
}
@@ -2818,7 +2771,6 @@ TclExecuteByteCode(interp, codePtr)
iResult = d1 >= d2;
break;
}
-#ifndef TCL_WIDE_INT_IS_LONG
} else if ((t1Ptr == &tclWideIntType)
|| (t2Ptr == &tclWideIntType)) {
Tcl_WideInt w2;
@@ -2827,13 +2779,13 @@ TclExecuteByteCode(interp, codePtr)
*/
if (t1Ptr == &tclIntType) {
w = Tcl_LongAsWide(valuePtr->internalRep.longValue);
- w2 = value2Ptr->internalRep.wideValue;
+ TclGetWide(w2,value2Ptr);
} else if (t2Ptr == &tclIntType) {
- w = valuePtr->internalRep.wideValue;
+ TclGetWide(w,valuePtr);
w2 = Tcl_LongAsWide(value2Ptr->internalRep.longValue);
} else {
- w = valuePtr->internalRep.wideValue;
- w2 = value2Ptr->internalRep.wideValue;
+ TclGetWide(w,valuePtr);
+ TclGetWide(w2,value2Ptr);
}
switch (*pc) {
case INST_EQ:
@@ -2855,7 +2807,6 @@ TclExecuteByteCode(interp, codePtr)
iResult = w >= w2;
break;
}
-#endif /* TCL_WIDE_INT_IS_LONG */
} else {
/*
* Compare as ints.
@@ -2922,19 +2873,15 @@ TclExecuteByteCode(interp, codePtr)
long i2 = 0, rem, negative;
long iResult = 0; /* Init. avoids compiler warning. */
-#ifndef TCL_WIDE_INT_IS_LONG
Tcl_WideInt w2, wResult = W0;
int doWide = 0;
-#endif /* TCL_WIDE_INT_IS_LONG */
value2Ptr = stackPtr[stackTop];
valuePtr = stackPtr[stackTop - 1];
if (valuePtr->typePtr == &tclIntType) {
i = valuePtr->internalRep.longValue;
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (valuePtr->typePtr == &tclWideIntType) {
- w = valuePtr->internalRep.wideValue;
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TclGetWide(w,valuePtr);
} else { /* try to convert to int */
REQUIRE_WIDE_OR_INT(result, valuePtr, i, w);
if (result != TCL_OK) {
@@ -2948,10 +2895,8 @@ TclExecuteByteCode(interp, codePtr)
}
if (value2Ptr->typePtr == &tclIntType) {
i2 = value2Ptr->internalRep.longValue;
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (value2Ptr->typePtr == &tclWideIntType) {
- w2 = value2Ptr->internalRep.wideValue;
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TclGetWide(w2,value2Ptr);
} else {
REQUIRE_WIDE_OR_INT(result, value2Ptr, i2, w2);
if (result != TCL_OK) {
@@ -2972,17 +2917,11 @@ TclExecuteByteCode(interp, codePtr)
* remainder always has the same sign as the divisor and
* a smaller absolute value.
*/
-#ifdef TCL_WIDE_INT_IS_LONG
- if (i2 == 0) {
- TRACE(("%ld %ld => DIVIDE BY ZERO\n", i, i2));
- goto divideByZero;
- }
-#else /* !TCL_WIDE_INT_IS_LONG */
if (value2Ptr->typePtr == &tclWideIntType && w2 == W0) {
if (valuePtr->typePtr == &tclIntType) {
- LLTRACE(("%ld "LLD" => DIVIDE BY ZERO\n", i, w2));
+ TRACE(("%ld "LLD" => DIVIDE BY ZERO\n", i, w2));
} else {
- LLTRACE((LLD" "LLD" => DIVIDE BY ZERO\n", w, w2));
+ TRACE((LLD" "LLD" => DIVIDE BY ZERO\n", w, w2));
}
goto divideByZero;
}
@@ -2990,13 +2929,11 @@ TclExecuteByteCode(interp, codePtr)
if (valuePtr->typePtr == &tclIntType) {
TRACE(("%ld %ld => DIVIDE BY ZERO\n", i, i2));
} else {
- LLTRACE((LLD" %ld => DIVIDE BY ZERO\n", w, i2));
+ TRACE((LLD" %ld => DIVIDE BY ZERO\n", w, i2));
}
goto divideByZero;
}
-#endif /* TCL_WIDE_INT_IS_LONG */
negative = 0;
-#ifndef TCL_WIDE_INT_IS_LONG
if (valuePtr->typePtr == &tclWideIntType
|| value2Ptr->typePtr == &tclWideIntType) {
Tcl_WideInt wRemainder;
@@ -3024,7 +2961,6 @@ TclExecuteByteCode(interp, codePtr)
doWide = 1;
break;
}
-#endif /* TCL_WIDE_INT_IS_LONG */
if (i2 < 0) {
i2 = -i2;
i = -i;
@@ -3040,7 +2976,6 @@ TclExecuteByteCode(interp, codePtr)
iResult = rem;
break;
case INST_LSHIFT:
-#ifndef TCL_WIDE_INT_IS_LONG
/*
* Shifts are never usefully 64-bits wide!
*/
@@ -3053,7 +2988,6 @@ TclExecuteByteCode(interp, codePtr)
doWide = 1;
break;
}
-#endif /* TCL_WIDE_INT_IS_LONG */
iResult = i << i2;
break;
case INST_RSHIFT:
@@ -3062,7 +2996,6 @@ TclExecuteByteCode(interp, codePtr)
* right shifts propagate the sign bit even on machines
* where ">>" won't do it by default.
*/
-#ifndef TCL_WIDE_INT_IS_LONG
/*
* Shifts are never usefully 64-bits wide!
*/
@@ -3079,7 +3012,6 @@ TclExecuteByteCode(interp, codePtr)
doWide = 1;
break;
}
-#endif /* TCL_WIDE_INT_IS_LONG */
if (i < 0) {
iResult = ~((~i) >> i2);
} else {
@@ -3087,7 +3019,6 @@ TclExecuteByteCode(interp, codePtr)
}
break;
case INST_BITOR:
-#ifndef TCL_WIDE_INT_IS_LONG
if (valuePtr->typePtr == &tclWideIntType
|| value2Ptr->typePtr == &tclWideIntType) {
/*
@@ -3102,11 +3033,9 @@ TclExecuteByteCode(interp, codePtr)
doWide = 1;
break;
}
-#endif /* TCL_WIDE_INT_IS_LONG */
iResult = i | i2;
break;
case INST_BITXOR:
-#ifndef TCL_WIDE_INT_IS_LONG
if (valuePtr->typePtr == &tclWideIntType
|| value2Ptr->typePtr == &tclWideIntType) {
/*
@@ -3121,11 +3050,9 @@ TclExecuteByteCode(interp, codePtr)
doWide = 1;
break;
}
-#endif /* TCL_WIDE_INT_IS_LONG */
iResult = i ^ i2;
break;
case INST_BITAND:
-#ifndef TCL_WIDE_INT_IS_LONG
if (valuePtr->typePtr == &tclWideIntType
|| value2Ptr->typePtr == &tclWideIntType) {
/*
@@ -3140,7 +3067,6 @@ TclExecuteByteCode(interp, codePtr)
doWide = 1;
break;
}
-#endif /* TCL_WIDE_INT_IS_LONG */
iResult = i & i2;
break;
}
@@ -3150,30 +3076,22 @@ TclExecuteByteCode(interp, codePtr)
*/
if (Tcl_IsShared(valuePtr)) {
-#ifndef TCL_WIDE_INT_IS_LONG
if (doWide) {
objResultPtr = Tcl_NewWideIntObj(wResult);
- LLTRACE((LLD" "LLD" => "LLD"\n", w, w2, wResult));
+ TRACE((LLD" "LLD" => "LLD"\n", w, w2, wResult));
} else {
-#endif /* TCL_WIDE_INT_IS_LONG */
objResultPtr = Tcl_NewLongObj(iResult);
TRACE(("%ld %ld => %ld\n", i, i2, iResult));
-#ifndef TCL_WIDE_INT_IS_LONG
}
-#endif /* TCL_WIDE_INT_IS_LONG */
NEXT_INST_F(1, 2, 1);
} else { /* reuse the valuePtr object */
-#ifndef TCL_WIDE_INT_IS_LONG
if (doWide) {
- LLTRACE((LLD" "LLD" => "LLD"\n", w, w2, wResult));
+ TRACE((LLD" "LLD" => "LLD"\n", w, w2, wResult));
Tcl_SetWideIntObj(valuePtr, wResult);
} else {
-#endif /* TCL_WIDE_INT_IS_LONG */
TRACE(("%ld %ld => %ld\n", i, i2, iResult));
Tcl_SetLongObj(valuePtr, iResult);
-#ifndef TCL_WIDE_INT_IS_LONG
}
-#endif /* TCL_WIDE_INT_IS_LONG */
NEXT_INST_F(1, 1, 0);
}
}
@@ -3194,11 +3112,9 @@ TclExecuteByteCode(interp, codePtr)
long iResult = 0; /* Init. avoids compiler warning. */
double dResult = 0.0; /* Init. avoids compiler warning. */
int doDouble = 0; /* 1 if doing floating arithmetic */
-#ifndef TCL_WIDE_INT_IS_LONG
Tcl_WideInt w2, wquot, wrem;
Tcl_WideInt wResult = W0; /* Init. avoids compiler warning. */
int doWide = 0; /* 1 if doing wide arithmetic. */
-#endif /* TCL_WIDE_INT_IS_LONG */
value2Ptr = stackPtr[stackTop];
valuePtr = stackPtr[stackTop - 1];
@@ -3207,10 +3123,8 @@ TclExecuteByteCode(interp, codePtr)
if (t1Ptr == &tclIntType) {
i = valuePtr->internalRep.longValue;
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (t1Ptr == &tclWideIntType) {
- w = valuePtr->internalRep.wideValue;
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TclGetWide(w,valuePtr);
} else if ((t1Ptr == &tclDoubleType)
&& (valuePtr->bytes == NULL)) {
/*
@@ -3241,10 +3155,8 @@ TclExecuteByteCode(interp, codePtr)
if (t2Ptr == &tclIntType) {
i2 = value2Ptr->internalRep.longValue;
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (t2Ptr == &tclWideIntType) {
- w2 = value2Ptr->internalRep.wideValue;
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TclGetWide(w2,value2Ptr);
} else if ((t2Ptr == &tclDoubleType)
&& (value2Ptr->bytes == NULL)) {
/*
@@ -3282,12 +3194,10 @@ TclExecuteByteCode(interp, codePtr)
d1 = i; /* promote value 1 to double */
} else if (t2Ptr == &tclIntType) {
d2 = i2; /* promote value 2 to double */
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (t1Ptr == &tclWideIntType) {
d1 = Tcl_WideAsDouble(w);
} else if (t2Ptr == &tclWideIntType) {
d2 = Tcl_WideAsDouble(w2);
-#endif /* TCL_WIDE_INT_IS_LONG */
}
switch (*pc) {
case INST_ADD:
@@ -3319,7 +3229,6 @@ TclExecuteByteCode(interp, codePtr)
result = TCL_ERROR;
goto checkForCatch;
}
-#ifndef TCL_WIDE_INT_IS_LONG
} else if ((t1Ptr == &tclWideIntType)
|| (t2Ptr == &tclWideIntType)) {
/*
@@ -3349,7 +3258,7 @@ TclExecuteByteCode(interp, codePtr)
* divisor and a smaller absolute value.
*/
if (w2 == W0) {
- LLTRACE((LLD" "LLD" => DIVIDE BY ZERO\n", w, w2));
+ TRACE((LLD" "LLD" => DIVIDE BY ZERO\n", w, w2));
goto divideByZero;
}
if (w2 < 0) {
@@ -3364,7 +3273,6 @@ TclExecuteByteCode(interp, codePtr)
wResult = wquot;
break;
}
-#endif /* TCL_WIDE_INT_IS_LONG */
} else {
/*
* Do integer arithmetic.
@@ -3412,11 +3320,9 @@ TclExecuteByteCode(interp, codePtr)
if (doDouble) {
objResultPtr = Tcl_NewDoubleObj(dResult);
TRACE(("%.6g %.6g => %.6g\n", d1, d2, dResult));
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (doWide) {
objResultPtr = Tcl_NewWideIntObj(wResult);
- LLTRACE((LLD" "LLD" => "LLD"\n", w, w2, wResult));
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TRACE((LLD" "LLD" => "LLD"\n", w, w2, wResult));
} else {
objResultPtr = Tcl_NewLongObj(iResult);
TRACE(("%ld %ld => %ld\n", i, i2, iResult));
@@ -3426,11 +3332,9 @@ TclExecuteByteCode(interp, codePtr)
if (doDouble) { /* NB: stack top is off by 1 */
TRACE(("%.6g %.6g => %.6g\n", d1, d2, dResult));
Tcl_SetDoubleObj(valuePtr, dResult);
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (doWide) {
- LLTRACE((LLD" "LLD" => "LLD"\n", w, w2, wResult));
+ TRACE((LLD" "LLD" => "LLD"\n", w, w2, wResult));
Tcl_SetWideIntObj(valuePtr, wResult);
-#endif /* TCL_WIDE_INT_IS_LONG */
} else {
TRACE(("%ld %ld => %ld\n", i, i2, iResult));
Tcl_SetLongObj(valuePtr, iResult);
@@ -3480,11 +3384,9 @@ TclExecuteByteCode(interp, codePtr)
if (tPtr == &tclIntType) {
i = valuePtr->internalRep.longValue;
objResultPtr = Tcl_NewLongObj(i);
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (tPtr == &tclWideIntType) {
- w = valuePtr->internalRep.wideValue;
+ TclGetWide(w,valuePtr);
objResultPtr = Tcl_NewWideIntObj(w);
-#endif /* TCL_WIDE_INT_IS_LONG */
} else {
d = valuePtr->internalRep.doubleValue;
objResultPtr = Tcl_NewDoubleObj(d);
@@ -3552,16 +3454,14 @@ TclExecuteByteCode(interp, codePtr)
objResultPtr = Tcl_NewLongObj(
(*pc == INST_UMINUS)? -i : !i);
TRACE_WITH_OBJ(("%ld => ", i), objResultPtr);
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (tPtr == &tclWideIntType) {
- w = valuePtr->internalRep.wideValue;
+ TclGetWide(w,valuePtr);
if (*pc == INST_UMINUS) {
objResultPtr = Tcl_NewWideIntObj(-w);
} else {
objResultPtr = Tcl_NewLongObj(w == W0);
}
- LLTRACE_WITH_OBJ((LLD" => ", w), objResultPtr);
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TRACE_WITH_OBJ((LLD" => ", w), objResultPtr);
} else {
d = valuePtr->internalRep.doubleValue;
if (*pc == INST_UMINUS) {
@@ -3585,16 +3485,14 @@ TclExecuteByteCode(interp, codePtr)
Tcl_SetLongObj(valuePtr,
(*pc == INST_UMINUS)? -i : !i);
TRACE_WITH_OBJ(("%ld => ", i), valuePtr);
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (tPtr == &tclWideIntType) {
- w = valuePtr->internalRep.wideValue;
+ TclGetWide(w,valuePtr);
if (*pc == INST_UMINUS) {
Tcl_SetWideIntObj(valuePtr, -w);
} else {
Tcl_SetLongObj(valuePtr, w == W0);
}
- LLTRACE_WITH_OBJ((LLD" => ", w), valuePtr);
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TRACE_WITH_OBJ((LLD" => ", w), valuePtr);
} else {
d = valuePtr->internalRep.doubleValue;
if (*pc == INST_UMINUS) {
@@ -3635,23 +3533,21 @@ TclExecuteByteCode(interp, codePtr)
}
}
-#ifndef TCL_WIDE_INT_IS_LONG
if (valuePtr->typePtr == &tclWideIntType) {
- w = valuePtr->internalRep.wideValue;
+ TclGetWide(w,valuePtr);
if (Tcl_IsShared(valuePtr)) {
objResultPtr = Tcl_NewWideIntObj(~w);
- LLTRACE(("0x%llx => (%llu)\n", w, ~w));
+ TRACE(("0x%llx => (%llu)\n", w, ~w));
NEXT_INST_F(1, 1, 1);
} else {
/*
* valuePtr is unshared. Modify it directly.
*/
Tcl_SetWideIntObj(valuePtr, ~w);
- LLTRACE(("0x%llx => (%llu)\n", w, ~w));
+ TRACE(("0x%llx => (%llu)\n", w, ~w));
NEXT_INST_F(1, 0, 0);
}
} else {
-#endif /* TCL_WIDE_INT_IS_LONG */
i = valuePtr->internalRep.longValue;
if (Tcl_IsShared(valuePtr)) {
objResultPtr = Tcl_NewLongObj(~i);
@@ -3665,9 +3561,7 @@ TclExecuteByteCode(interp, codePtr)
TRACE(("0x%lx => (%lu)\n", i, ~i));
NEXT_INST_F(1, 0, 0);
}
-#ifndef TCL_WIDE_INT_IS_LONG
}
-#endif /* TCL_WIDE_INT_IS_LONG */
}
case INST_CALL_BUILTIN_FUNC1:
@@ -3781,11 +3675,9 @@ TclExecuteByteCode(interp, codePtr)
if (tPtr == &tclIntType) {
i = valuePtr->internalRep.longValue;
objResultPtr = Tcl_NewLongObj(i);
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (tPtr == &tclWideIntType) {
- w = valuePtr->internalRep.wideValue;
+ TclGetWide(w,valuePtr);
objResultPtr = Tcl_NewWideIntObj(w);
-#endif /* TCL_WIDE_INT_IS_LONG */
} else {
d = valuePtr->internalRep.doubleValue;
objResultPtr = Tcl_NewDoubleObj(d);
@@ -4753,13 +4645,8 @@ VerifyExprObjType(interp, objPtr)
char *s = Tcl_GetStringFromObj(objPtr, &length);
if (TclLooksLikeInt(s, length)) {
-#ifdef TCL_WIDE_INT_IS_LONG
- long i;
- result = Tcl_GetLongFromObj((Tcl_Interp *) NULL, objPtr, &i);
-#else /* !TCL_WIDE_INT_IS_LONG */
Tcl_WideInt w;
result = Tcl_GetWideIntFromObj((Tcl_Interp *) NULL, objPtr, &w);
-#endif /* TCL_WIDE_INT_IS_LONG */
} else {
double d;
result = Tcl_GetDoubleFromObj((Tcl_Interp *) NULL, objPtr, &d);
@@ -4984,9 +4871,9 @@ ExprAbsFunc(interp, eePtr, clientData)
iResult = i;
}
PUSH_OBJECT(Tcl_NewLongObj(iResult));
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (valuePtr->typePtr == &tclWideIntType) {
- Tcl_WideInt wResult, w = valuePtr->internalRep.wideValue;
+ Tcl_WideInt wResult, w;
+ TclGetWide(w,valuePtr);
if (w < W0) {
wResult = -w;
if (wResult < 0) {
@@ -5002,7 +4889,6 @@ ExprAbsFunc(interp, eePtr, clientData)
wResult = w;
}
PUSH_OBJECT(Tcl_NewWideIntObj(wResult));
-#endif /* TCL_WIDE_INT_IS_LONG */
} else {
d = valuePtr->internalRep.doubleValue;
if (d < 0.0) {
@@ -5113,10 +4999,8 @@ ExprIntFunc(interp, eePtr, clientData)
if (valuePtr->typePtr == &tclIntType) {
iResult = valuePtr->internalRep.longValue;
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (valuePtr->typePtr == &tclWideIntType) {
- iResult = Tcl_WideAsLong(valuePtr->internalRep.wideValue);
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TclGetLongFromWide(iResult,valuePtr);
} else {
d = valuePtr->internalRep.doubleValue;
if (d < 0.0) {
@@ -5159,7 +5043,6 @@ ExprIntFunc(interp, eePtr, clientData)
return result;
}
-#ifndef TCL_WIDE_INT_IS_LONG
static int
ExprWideFunc(interp, eePtr, clientData)
Tcl_Interp *interp; /* The interpreter in which to execute the
@@ -5194,7 +5077,7 @@ ExprWideFunc(interp, eePtr, clientData)
}
if (valuePtr->typePtr == &tclWideIntType) {
- wResult = valuePtr->internalRep.wideValue;
+ TclGetWide(wResult,valuePtr);
} else if (valuePtr->typePtr == &tclIntType) {
wResult = Tcl_LongAsWide(valuePtr->internalRep.longValue);
} else {
@@ -5238,7 +5121,6 @@ ExprWideFunc(interp, eePtr, clientData)
DECACHE_STACK_INFO();
return result;
}
-#endif /* TCL_WIDE_INT_IS_LONG */
static int
ExprRandFunc(interp, eePtr, clientData)
@@ -5376,11 +5258,11 @@ ExprRoundFunc(interp, eePtr, clientData)
if (valuePtr->typePtr == &tclIntType) {
iResult = valuePtr->internalRep.longValue;
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (valuePtr->typePtr == &tclWideIntType) {
- PUSH_OBJECT(Tcl_NewWideIntObj(valuePtr->internalRep.wideValue));
+ Tcl_WideInt w;
+ TclGetWide(w,valuePtr);
+ PUSH_OBJECT(Tcl_NewWideIntObj(w));
goto done;
-#endif /* TCL_WIDE_INT_IS_LONG */
} else {
d = valuePtr->internalRep.doubleValue;
if (d < 0.0) {
@@ -5459,10 +5341,8 @@ ExprSrandFunc(interp, eePtr, clientData)
if (valuePtr->typePtr == &tclIntType) {
i = valuePtr->internalRep.longValue;
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (valuePtr->typePtr == &tclWideIntType) {
- i = Tcl_WideAsLong(valuePtr->internalRep.wideValue);
-#endif /* TCL_WIDE_INT_IS_LONG */
+ TclGetLongFromWide(i,valuePtr);
} else {
/*
* At this point, the only other possible type is double
@@ -5599,39 +5479,34 @@ ExprCallMathFunc(interp, eePtr, objc, objv)
if (mathFuncPtr->argTypes[k] == TCL_DOUBLE) {
args[k].type = TCL_DOUBLE;
args[k].doubleValue = i;
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (mathFuncPtr->argTypes[k] == TCL_WIDE_INT) {
args[k].type = TCL_WIDE_INT;
args[k].wideValue = Tcl_LongAsWide(i);
-#endif /* !TCL_WIDE_INT_IS_LONG */
} else {
args[k].type = TCL_INT;
args[k].intValue = i;
}
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (valuePtr->typePtr == &tclWideIntType) {
- Tcl_WideInt w = valuePtr->internalRep.wideValue;
+ Tcl_WideInt w;
+ TclGetWide(w,valuePtr);
if (mathFuncPtr->argTypes[k] == TCL_DOUBLE) {
args[k].type = TCL_DOUBLE;
- args[k].wideValue = (Tcl_WideInt) Tcl_WideAsDouble(w);
+ args[k].doubleValue = (Tcl_WideInt) Tcl_WideAsDouble(w);
} else if (mathFuncPtr->argTypes[k] == TCL_INT) {
args[k].type = TCL_INT;
- args[k].wideValue = Tcl_WideAsLong(w);
+ args[k].intValue = Tcl_WideAsLong(w);
} else {
args[k].type = TCL_WIDE_INT;
args[k].wideValue = w;
}
-#endif /* !TCL_WIDE_INT_IS_LONG */
} else {
d = valuePtr->internalRep.doubleValue;
if (mathFuncPtr->argTypes[k] == TCL_INT) {
args[k].type = TCL_INT;
args[k].intValue = (long) d;
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (mathFuncPtr->argTypes[k] == TCL_WIDE_INT) {
args[k].type = TCL_WIDE_INT;
args[k].wideValue = Tcl_DoubleAsWide(d);
-#endif /* !TCL_WIDE_INT_IS_LONG */
} else {
args[k].type = TCL_DOUBLE;
args[k].doubleValue = d;
@@ -5665,10 +5540,8 @@ ExprCallMathFunc(interp, eePtr, objc, objv)
if (funcResult.type == TCL_INT) {
PUSH_OBJECT(Tcl_NewLongObj(funcResult.intValue));
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (funcResult.type == TCL_WIDE_INT) {
PUSH_OBJECT(Tcl_NewWideIntObj(funcResult.wideValue));
-#endif /* !TCL_WIDE_INT_IS_LONG */
} else {
d = funcResult.doubleValue;
if (IS_NAN(d) || IS_INF(d)) {
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 02290fa..a4753b9 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclInt.h,v 1.123 2003/04/05 01:41:23 dkf Exp $
+ * RCS: @(#) $Id: tclInt.h,v 1.124 2003/04/16 23:33:44 dgp Exp $
*/
#ifndef _TCLINT
@@ -1561,9 +1561,7 @@ extern Tcl_ObjType tclStringType;
extern Tcl_ObjType tclArraySearchType;
extern Tcl_ObjType tclIndexType;
extern Tcl_ObjType tclNsNameType;
-#ifndef TCL_WIDE_INT_IS_LONG
extern Tcl_ObjType tclWideIntType;
-#endif
/*
* Variables denoting the hash key types defined in the core.
@@ -2215,6 +2213,26 @@ extern Tcl_Mutex tclObjMutex;
/*
*----------------------------------------------------------------
+ * Macro used by the Tcl core to get a Tcl_WideInt value out of
+ * a Tcl_Obj of the "wideInt" type. Different implementation on
+ * different platforms depending whether TCL_WIDE_INT_IS_LONG.
+ *----------------------------------------------------------------
+ */
+
+#ifdef TCL_WIDE_INT_IS_LONG
+# define TclGetWide(resultVar, objPtr) \
+ (resultVar) = (objPtr)->internalRep.longValue
+# define TclGetLongFromWide(resultVar, objPtr) \
+ (resultVar) = (objPtr)->internalRep.longValue
+#else
+# define TclGetWide(resultVar, objPtr) \
+ (resultVar) = (objPtr)->internalRep.wideValue
+# define TclGetLongFromWide(resultVar, objPtr) \
+ (resultVar) = Tcl_WideAsLong((objPtr)->internalRep.wideValue)
+#endif
+
+/*
+ *----------------------------------------------------------------
* Macro used by the Tcl core get a unicode char from a utf string.
* It checks to see if we have a one-byte utf char before calling
* the real Tcl_UtfToUniChar, as this will save a lot of time for
diff --git a/generic/tclObj.c b/generic/tclObj.c
index a5e34e6..4f5d784 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclObj.c,v 1.44 2003/04/07 10:12:10 dkf Exp $
+ * RCS: @(#) $Id: tclObj.c,v 1.45 2003/04/16 23:33:44 dgp Exp $
*/
#include "tclInt.h"
@@ -63,9 +63,9 @@ static int SetIntFromAny _ANSI_ARGS_((Tcl_Interp *interp,
static void UpdateStringOfBoolean _ANSI_ARGS_((Tcl_Obj *objPtr));
static void UpdateStringOfDouble _ANSI_ARGS_((Tcl_Obj *objPtr));
static void UpdateStringOfInt _ANSI_ARGS_((Tcl_Obj *objPtr));
-#ifndef TCL_WIDE_INT_IS_LONG
static int SetWideIntFromAny _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Obj *objPtr));
+#ifndef TCL_WIDE_INT_IS_LONG
static void UpdateStringOfWideInt _ANSI_ARGS_((Tcl_Obj *objPtr));
#endif
@@ -132,11 +132,10 @@ Tcl_ObjType tclWideIntType = {
(Tcl_DupInternalRepProc *) NULL, /* dupIntRepProc */
#ifdef TCL_WIDE_INT_IS_LONG
UpdateStringOfInt, /* updateStringProc */
- SetIntFromAny /* setFromAnyProc */
#else /* !TCL_WIDE_INT_IS_LONG */
UpdateStringOfWideInt, /* updateStringProc */
- SetWideIntFromAny /* setFromAnyProc */
#endif /* TCL_WIDE_INT_IS_LONG */
+ SetWideIntFromAny /* setFromAnyProc */
};
/*
@@ -2137,12 +2136,12 @@ Tcl_GetLongFromObj(interp, objPtr, longPtr)
*----------------------------------------------------------------------
*/
-#ifndef TCL_WIDE_INT_IS_LONG
static int
SetWideIntFromAny(interp, objPtr)
Tcl_Interp *interp; /* Used for error reporting if not NULL. */
register Tcl_Obj *objPtr; /* The object to convert. */
{
+#ifndef TCL_WIDE_INT_IS_LONG
Tcl_ObjType *oldTypePtr = objPtr->typePtr;
char *string, *end;
int length;
@@ -2228,10 +2227,14 @@ SetWideIntFromAny(interp, objPtr)
}
objPtr->internalRep.wideValue = newWide;
+#else
+ if (TCL_ERROR == SetIntFromAny(interp, objPtr)) {
+ return TCL_ERROR;
+ }
+#endif
objPtr->typePtr = &tclWideIntType;
return TCL_OK;
}
-#endif
/*
*----------------------------------------------------------------------
@@ -2318,9 +2321,6 @@ Tcl_NewWideIntObj(wideValue)
register Tcl_WideInt wideValue; /* Wide integer used to initialize
* the new object. */
{
-#ifdef TCL_WIDE_INT_IS_LONG
- return Tcl_NewLongObj(wideValue);
-#else
register Tcl_Obj *objPtr;
TclNewObj(objPtr);
@@ -2329,7 +2329,6 @@ Tcl_NewWideIntObj(wideValue)
objPtr->internalRep.wideValue = wideValue;
objPtr->typePtr = &tclWideIntType;
return objPtr;
-#endif /* TCL_WIDE_INT_IS_LONG */
}
#endif /* if TCL_MEM_DEBUG */
@@ -2379,9 +2378,6 @@ Tcl_DbNewWideIntObj(wideValue, file, line)
int line; /* Line number in the source file;
* used for debugging. */
{
-#ifdef TCL_WIDE_INT_IS_LONG
- return Tcl_DbNewLongObj(wideValue, file, line);
-#else
register Tcl_Obj *objPtr;
TclDbNewObj(objPtr, file, line);
@@ -2390,7 +2386,6 @@ Tcl_DbNewWideIntObj(wideValue, file, line)
objPtr->internalRep.wideValue = wideValue;
objPtr->typePtr = &tclWideIntType;
return objPtr;
-#endif
}
#else /* if not TCL_MEM_DEBUG */
@@ -2433,9 +2428,6 @@ Tcl_SetWideIntObj(objPtr, wideValue)
register Tcl_WideInt wideValue; /* Wide integer used to initialize
* the object's value. */
{
-#ifdef TCL_WIDE_INT_IS_LONG
- Tcl_SetLongObj(objPtr, wideValue);
-#else
register Tcl_ObjType *oldTypePtr = objPtr->typePtr;
if (Tcl_IsShared(objPtr)) {
@@ -2449,7 +2441,6 @@ Tcl_SetWideIntObj(objPtr, wideValue)
objPtr->internalRep.wideValue = wideValue;
objPtr->typePtr = &tclWideIntType;
Tcl_InvalidateStringRep(objPtr);
-#endif
}
/*
@@ -2479,12 +2470,6 @@ Tcl_GetWideIntFromObj(interp, objPtr, wideIntPtr)
register Tcl_Obj *objPtr; /* Object from which to get a wide int. */
register Tcl_WideInt *wideIntPtr; /* Place to store resulting long. */
{
-#ifdef TCL_WIDE_INT_IS_LONG
- /*
- * Next line is type-safe because we only do this when long = Tcl_WideInt
- */
- return Tcl_GetLongFromObj(interp, objPtr, wideIntPtr);
-#else
register int result;
if (objPtr->typePtr == &tclWideIntType) {
@@ -2496,7 +2481,6 @@ Tcl_GetWideIntFromObj(interp, objPtr, wideIntPtr)
*wideIntPtr = objPtr->internalRep.wideValue;
}
return result;
-#endif
}
/*
diff --git a/generic/tclPort.h b/generic/tclPort.h
index 930ae1d..2f07167 100644
--- a/generic/tclPort.h
+++ b/generic/tclPort.h
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclPort.h,v 1.6 2002/02/15 14:28:49 dkf Exp $
+ * RCS: @(#) $Id: tclPort.h,v 1.7 2003/04/16 23:33:44 dgp Exp $
*/
#ifndef _TCLPORT
@@ -28,12 +28,16 @@
# endif
#endif
-#if !defined(TCL_WIDE_INT_IS_LONG) && !defined(LLONG_MIN)
-# ifdef LLONG_BIT
-# define LLONG_MIN ((Tcl_WideInt)(Tcl_LongAsWide(1)<<(LLONG_BIT-1)))
+#if !defined(LLONG_MIN)
+# ifdef TCL_WIDE_INT_IS_LONG
+# define LLONG_MIN LONG_MIN
# else
+# ifdef LLONG_BIT
+# define LLONG_MIN ((Tcl_WideInt)(Tcl_LongAsWide(1)<<(LLONG_BIT-1)))
+# else
/* Assume we're on a system with a 64-bit 'long long' type */
-# define LLONG_MIN ((Tcl_WideInt)(Tcl_LongAsWide(1)<<63))
+# define LLONG_MIN ((Tcl_WideInt)(Tcl_LongAsWide(1)<<63))
+# endif
# endif
/* Assume that if LLONG_MIN is undefined, then so is LLONG_MAX */
# define LLONG_MAX (~LLONG_MIN)
diff --git a/generic/tclTest.c b/generic/tclTest.c
index d5370d6..6d04c6e 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclTest.c,v 1.66 2003/04/15 03:43:25 dgp Exp $
+ * RCS: @(#) $Id: tclTest.c,v 1.67 2003/04/16 23:33:44 dgp Exp $
*/
#define TCL_TEST
@@ -2795,14 +2795,12 @@ TestMathFunc2(clientData, interp, args, resultPtr)
resultPtr->type = TCL_DOUBLE;
resultPtr->doubleValue = ((d0 > d1)? d0 : d1);
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (args[1].type == TCL_WIDE_INT) {
Tcl_WideInt w0 = Tcl_LongAsWide(i0);
Tcl_WideInt w1 = args[1].wideValue;
resultPtr->type = TCL_WIDE_INT;
resultPtr->wideValue = ((w0 > w1)? w0 : w1);
-#endif
} else {
Tcl_SetResult(interp, "T3: wrong type for arg 2", TCL_STATIC);
result = TCL_ERROR;
@@ -2820,18 +2818,15 @@ TestMathFunc2(clientData, interp, args, resultPtr)
resultPtr->type = TCL_DOUBLE;
resultPtr->doubleValue = ((d0 > d1)? d0 : d1);
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (args[1].type == TCL_WIDE_INT) {
double d1 = Tcl_WideAsDouble(args[1].wideValue);
resultPtr->type = TCL_DOUBLE;
resultPtr->doubleValue = ((d0 > d1)? d0 : d1);
-#endif
} else {
Tcl_SetResult(interp, "T3: wrong type for arg 2", TCL_STATIC);
result = TCL_ERROR;
}
-#ifndef TCL_WIDE_INT_IS_LONG
} else if (args[0].type == TCL_WIDE_INT) {
Tcl_WideInt w0 = args[0].wideValue;
@@ -2855,7 +2850,6 @@ TestMathFunc2(clientData, interp, args, resultPtr)
Tcl_SetResult(interp, "T3: wrong type for arg 2", TCL_STATIC);
result = TCL_ERROR;
}
-#endif
} else {
Tcl_SetResult(interp, "T3: wrong type for arg 1", TCL_STATIC);
result = TCL_ERROR;
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index a4d783b..4c929ef 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUtil.c,v 1.36 2002/11/19 02:34:50 hobbs Exp $
+ * RCS: @(#) $Id: tclUtil.c,v 1.37 2003/04/16 23:33:44 dgp Exp $
*/
#include "tclInt.h"
@@ -2220,9 +2220,7 @@ TclGetIntForIndex(interp, objPtr, endValue, indexPtr)
{
char *bytes;
int offset;
-#ifndef TCL_WIDE_INT_IS_LONG
Tcl_WideInt wideOffset;
-#endif
/*
* If the object is already an integer, use it.
@@ -2237,16 +2235,14 @@ TclGetIntForIndex(interp, objPtr, endValue, indexPtr)
* If the object is already a wide-int, and it is not out of range
* for an integer, use it. [Bug #526717]
*/
-#ifndef TCL_WIDE_INT_IS_LONG
if (objPtr->typePtr == &tclWideIntType) {
- Tcl_WideInt wideOffset = objPtr->internalRep.wideValue;
+ TclGetWide(wideOffset,objPtr);
if (wideOffset >= Tcl_LongAsWide(INT_MIN)
&& wideOffset <= Tcl_LongAsWide(INT_MAX)) {
*indexPtr = (int) Tcl_WideAsLong(wideOffset);
return TCL_OK;
}
}
-#endif /* TCL_WIDE_INT_IS_LONG */
if (SetEndOffsetFromAny(NULL, objPtr) == TCL_OK) {
/*
@@ -2256,15 +2252,6 @@ TclGetIntForIndex(interp, objPtr, endValue, indexPtr)
*indexPtr = endValue + objPtr->internalRep.longValue;
-#ifdef TCL_WIDE_INT_IS_LONG
- } else if (Tcl_GetIntFromObj(NULL, objPtr, &offset) == TCL_OK) {
- /*
- * If the object can be converted to an integer, use that.
- */
-
- *indexPtr = offset;
-
-#else /* !TCL_WIDE_INT_IS_LONG */
} else if (Tcl_GetWideIntFromObj(NULL, objPtr, &wideOffset) == TCL_OK) {
/*
* If the object can be converted to a wide integer, use
@@ -2283,7 +2270,6 @@ TclGetIntForIndex(interp, objPtr, endValue, indexPtr)
}
*indexPtr = offset;
-#endif /* TCL_WIDE_INT_IS_LONG */
} else {
/*
* Report a parse error.
diff --git a/generic/tclVar.c b/generic/tclVar.c
index 65dad51..2d36e3a 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclVar.c,v 1.70 2003/03/24 00:49:00 msofer Exp $
+ * RCS: @(#) $Id: tclVar.c,v 1.71 2003/04/16 23:33:44 dgp Exp $
*/
#include "tclInt.h"
@@ -1839,17 +1839,9 @@ TclPtrIncrVar(interp, varPtr, arrayPtr, part1, part2, incrAmount, flags)
varValuePtr = Tcl_DuplicateObj(varValuePtr);
createdNewObj = 1;
}
-#ifdef TCL_WIDE_INT_IS_LONG
- if (Tcl_GetLongFromObj(interp, varValuePtr, &i) != TCL_OK) {
- if (createdNewObj) {
- Tcl_DecrRefCount(varValuePtr); /* free unneeded copy */
- }
- return NULL;
- }
- Tcl_SetLongObj(varValuePtr, (i + incrAmount));
-#else
if (varValuePtr->typePtr == &tclWideIntType) {
- Tcl_WideInt wide = varValuePtr->internalRep.wideValue;
+ Tcl_WideInt wide;
+ TclGetWide(wide,varValuePtr);
Tcl_SetWideIntObj(varValuePtr, wide + Tcl_LongAsWide(incrAmount));
} else if (varValuePtr->typePtr == &tclIntType) {
i = varValuePtr->internalRep.longValue;
@@ -1872,7 +1864,6 @@ TclPtrIncrVar(interp, varPtr, arrayPtr, part1, part2, incrAmount, flags)
Tcl_SetWideIntObj(varValuePtr, wide + Tcl_LongAsWide(incrAmount));
}
}
-#endif
/*
* Store the variable's new value and run any write traces.