diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tcl.h | 7 | ||||
-rw-r--r-- | generic/tclCmdAH.c | 19 | ||||
-rw-r--r-- | generic/tclCmdIL.c | 7 | ||||
-rw-r--r-- | generic/tclExecute.c | 253 | ||||
-rw-r--r-- | generic/tclInt.h | 24 | ||||
-rw-r--r-- | generic/tclObj.c | 34 | ||||
-rw-r--r-- | generic/tclPort.h | 14 | ||||
-rw-r--r-- | generic/tclTest.c | 8 | ||||
-rw-r--r-- | generic/tclUtil.c | 18 | ||||
-rw-r--r-- | generic/tclVar.c | 15 |
10 files changed, 112 insertions, 287 deletions
diff --git a/generic/tcl.h b/generic/tcl.h index 9a76328..a2aaefe 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.153.2.1 2003/03/12 19:19:29 dgp Exp $ + * RCS: @(#) $Id: tcl.h,v 1.153.2.2 2003/04/16 23:31:41 dgp Exp $ */ #ifndef _TCL @@ -630,18 +630,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 0d15bde..596795a 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.27.2.4 2003/04/08 22:59:36 dkf Exp $ + * RCS: @(#) $Id: tclCmdAH.c,v 1.27.2.5 2003/04/16 23:31:42 dgp Exp $ */ #include "tclInt.h" @@ -1939,10 +1939,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 @@ -1981,9 +1979,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 @@ -2014,9 +2010,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; /* @@ -2160,7 +2154,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 @@ -2176,7 +2169,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; @@ -2200,7 +2192,6 @@ Tcl_FormatObjCmd(dummy, interp, objc, objv) case 'X': size = 40 + precision; -#ifndef TCL_WIDE_INT_IS_LONG /* * Peek what kind of value we've got so as not to be * converting stuff unduly. [Bug #699060] @@ -2241,12 +2232,6 @@ Tcl_FormatObjCmd(dummy, interp, objc, objv) goto fmtError; } } -#else /* TCL_WIDE_INT_IS_LONG */ - if (Tcl_GetLongFromObj(interp, /* INTL: Tcl source. */ - objv[objIndex], &intValue) != TCL_OK) { - goto fmtError; - } -#endif /* !TCL_WIDE_INT_IS_LONG */ #if (LONG_MAX > INT_MAX) /* * Add the 'l' for long format type because we are on an @@ -2342,11 +2327,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..48ddefb 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.47.2.1 2003/04/16 23:31: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/tclExecute.c b/generic/tclExecute.c index 18bba5d..e0dd860 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.94 2003/02/19 14:33:39 msofer Exp $ + * RCS: @(#) $Id: tclExecute.c,v 1.94.2.1 2003/04/16 23:31:43 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}, }; @@ -1097,9 +1069,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; @@ -1909,10 +1879,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) { @@ -2099,10 +2067,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) { @@ -2154,27 +2121,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); @@ -2190,27 +2150,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); } @@ -2825,7 +2778,6 @@ TclExecuteByteCode(interp, codePtr) iResult = d1 >= d2; break; } -#ifndef TCL_WIDE_INT_IS_LONG } else if ((t1Ptr == &tclWideIntType) || (t2Ptr == &tclWideIntType)) { Tcl_WideInt w2; @@ -2834,13 +2786,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: @@ -2862,7 +2814,6 @@ TclExecuteByteCode(interp, codePtr) iResult = w >= w2; break; } -#endif /* TCL_WIDE_INT_IS_LONG */ } else { /* * Compare as ints. @@ -2929,19 +2880,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) { @@ -2955,10 +2902,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) { @@ -2979,17 +2924,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; } @@ -2997,13 +2936,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; @@ -3031,7 +2968,6 @@ TclExecuteByteCode(interp, codePtr) doWide = 1; break; } -#endif /* TCL_WIDE_INT_IS_LONG */ if (i2 < 0) { i2 = -i2; i = -i; @@ -3047,7 +2983,6 @@ TclExecuteByteCode(interp, codePtr) iResult = rem; break; case INST_LSHIFT: -#ifndef TCL_WIDE_INT_IS_LONG /* * Shifts are never usefully 64-bits wide! */ @@ -3060,7 +2995,6 @@ TclExecuteByteCode(interp, codePtr) doWide = 1; break; } -#endif /* TCL_WIDE_INT_IS_LONG */ iResult = i << i2; break; case INST_RSHIFT: @@ -3069,7 +3003,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! */ @@ -3086,7 +3019,6 @@ TclExecuteByteCode(interp, codePtr) doWide = 1; break; } -#endif /* TCL_WIDE_INT_IS_LONG */ if (i < 0) { iResult = ~((~i) >> i2); } else { @@ -3094,7 +3026,6 @@ TclExecuteByteCode(interp, codePtr) } break; case INST_BITOR: -#ifndef TCL_WIDE_INT_IS_LONG if (valuePtr->typePtr == &tclWideIntType || value2Ptr->typePtr == &tclWideIntType) { /* @@ -3109,11 +3040,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) { /* @@ -3128,11 +3057,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) { /* @@ -3147,7 +3074,6 @@ TclExecuteByteCode(interp, codePtr) doWide = 1; break; } -#endif /* TCL_WIDE_INT_IS_LONG */ iResult = i & i2; break; } @@ -3157,30 +3083,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); } } @@ -3201,11 +3119,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]; @@ -3214,10 +3130,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)) { /* @@ -3248,10 +3162,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)) { /* @@ -3289,12 +3201,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: @@ -3326,7 +3236,6 @@ TclExecuteByteCode(interp, codePtr) result = TCL_ERROR; goto checkForCatch; } -#ifndef TCL_WIDE_INT_IS_LONG } else if ((t1Ptr == &tclWideIntType) || (t2Ptr == &tclWideIntType)) { /* @@ -3356,7 +3265,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) { @@ -3371,7 +3280,6 @@ TclExecuteByteCode(interp, codePtr) wResult = wquot; break; } -#endif /* TCL_WIDE_INT_IS_LONG */ } else { /* * Do integer arithmetic. @@ -3419,11 +3327,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)); @@ -3433,11 +3339,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); @@ -3487,11 +3391,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); @@ -3559,16 +3461,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) { @@ -3592,16 +3492,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) { @@ -3642,23 +3540,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); @@ -3672,9 +3568,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: @@ -3788,11 +3682,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); @@ -4760,13 +4652,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); @@ -4991,9 +4878,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) { @@ -5009,7 +4896,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) { @@ -5120,10 +5006,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) { @@ -5166,7 +5050,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 @@ -5201,7 +5084,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 { @@ -5245,7 +5128,6 @@ ExprWideFunc(interp, eePtr, clientData) DECACHE_STACK_INFO(); return result; } -#endif /* TCL_WIDE_INT_IS_LONG */ static int ExprRandFunc(interp, eePtr, clientData) @@ -5383,11 +5265,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) { @@ -5466,10 +5348,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 @@ -5606,39 +5486,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; @@ -5672,10 +5547,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 077c65b..39343aa 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.118.2.2 2003/03/21 03:24:08 dgp Exp $ + * RCS: @(#) $Id: tclInt.h,v 1.118.2.3 2003/04/16 23:31:44 dgp Exp $ */ #ifndef _TCLINT @@ -1564,9 +1564,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. @@ -2211,6 +2209,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 6320060..050dfb6 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.42.2.1 2003/04/07 12:27:30 dkf Exp $ + * RCS: @(#) $Id: tclObj.c,v 1.42.2.2 2003/04/16 23:31:45 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 + SetWideIntFromAny /* setFromAnyProc */ }; /* @@ -2136,12 +2135,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; @@ -2227,10 +2226,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 /* *---------------------------------------------------------------------- @@ -2317,9 +2320,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); @@ -2328,7 +2328,6 @@ Tcl_NewWideIntObj(wideValue) objPtr->internalRep.wideValue = wideValue; objPtr->typePtr = &tclWideIntType; return objPtr; -#endif /* TCL_WIDE_INT_IS_LONG */ } #endif /* if TCL_MEM_DEBUG */ @@ -2378,9 +2377,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); @@ -2389,7 +2385,6 @@ Tcl_DbNewWideIntObj(wideValue, file, line) objPtr->internalRep.wideValue = wideValue; objPtr->typePtr = &tclWideIntType; return objPtr; -#endif } #else /* if not TCL_MEM_DEBUG */ @@ -2432,9 +2427,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)) { @@ -2448,7 +2440,6 @@ Tcl_SetWideIntObj(objPtr, wideValue) objPtr->internalRep.wideValue = wideValue; objPtr->typePtr = &tclWideIntType; Tcl_InvalidateStringRep(objPtr); -#endif } /* @@ -2478,12 +2469,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) { @@ -2495,7 +2480,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..d724c73 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.6.2.1 2003/04/16 23:31:46 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 ed7e0ad..327c470 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.62 2003/02/18 10:13:25 vincentdarley Exp $ + * RCS: @(#) $Id: tclTest.c,v 1.62.2.1 2003/04/16 23:31:46 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..2572891 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.36.2.1 2003/04/16 23:31:46 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 d3778c6..f9957fe 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.69.2.1 2003/03/24 00:55:16 msofer Exp $ + * RCS: @(#) $Id: tclVar.c,v 1.69.2.2 2003/04/16 23:31:47 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. |