summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/tclExecute.c54
1 files changed, 10 insertions, 44 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 3d7fcb4..9a906ea 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.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: tclExecute.c,v 1.437 2009/06/02 17:56:19 dgp Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.438 2009/06/02 19:11:12 dgp Exp $
*/
#include "tclInt.h"
@@ -557,8 +557,14 @@ static const size_t Exp32ValueSize = sizeof(Exp32Value)/sizeof(long);
* Tcl_WideInt.
*/
-static Tcl_WideInt MaxBase64[15];
-static const size_t MaxBase64Size = 15;
+static const Tcl_WideInt MaxBase64[] = {
+ (Tcl_WideInt)46340*65536+62259, /* 3037000499 == isqrt(2**63-1) */
+ (Tcl_WideInt)2097151, (Tcl_WideInt)55108, (Tcl_WideInt)6208,
+ (Tcl_WideInt)1448, (Tcl_WideInt)511, (Tcl_WideInt)234, (Tcl_WideInt)127,
+ (Tcl_WideInt)78, (Tcl_WideInt)52, (Tcl_WideInt)38, (Tcl_WideInt)28,
+ (Tcl_WideInt)22, (Tcl_WideInt)18, (Tcl_WideInt)15
+};
+static const size_t MaxBase64Size = sizeof(MaxBase64)/sizeof(Tcl_WideInt);
/*
*Table giving 3, 4, ..., 13 raised to powers greater than 16 when the
@@ -725,10 +731,6 @@ InitByteCodeExecution(
* "tcl_traceExec" is linked to control
* instruction tracing. */
{
-#if (LONG_MAX > 0x7fffffff) || !defined(TCL_WIDE_INT_IS_LONG)
- int i, j;
- Tcl_WideInt w, x;
-#endif
#ifdef TCL_COMPILE_DEBUG
if (Tcl_LinkVar(interp, "tcl_traceExec", (char *) &tclTraceExec,
TCL_LINK_INT) != TCL_OK) {
@@ -738,42 +740,6 @@ InitByteCodeExecution(
#ifdef TCL_COMPILE_STATS
Tcl_CreateObjCommand(interp, "evalstats", EvalStatsCmd, NULL, NULL);
#endif /* TCL_COMPILE_STATS */
-#if (LONG_MAX > 0x7fffffff) || !defined(TCL_WIDE_INT_IS_LONG)
-
- /*
- * Fill in a table of what base can be raised to powers 2, 3, ... 16
- * without overflowing a Tcl_WideInt
- */
-
- for (i = 2; i - 2 < MaxBase64Size; ++i) {
- /*
- * Compute an initial guess in floating point.
- */
-
- w = (Tcl_WideInt) pow((double) LLONG_MAX, 1.0 / i) + 1;
-
- /*
- * Correct the guess if it's too high.
- */
-
- for (;;) {
- x = LLONG_MAX;
- for (j = 0; j < i; ++j) {
- x /= w;
- }
- if (x == 1) {
- break;
- }
-/*
-fprintf(stdout, "Adjust %d: %lld to %lld\n", i, w, w-1);
-fflush(stdout);
-*/
- --w;
- }
-
- MaxBase64[i - 2] = w;
- }
-#endif
}
/*
@@ -6250,7 +6216,7 @@ TclExecuteByteCode(
} else {
goto overflow;
}
- if (l2 - 2 <= MaxBase64Size
+ if (l2 - 2 < MaxBase64Size
&& w1 <= MaxBase64[l2 - 2]
&& w1 >= -MaxBase64[l2 - 2]) {
/*