summaryrefslogtreecommitdiffstats
path: root/generic/tclBasic.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclBasic.c')
-rw-r--r--generic/tclBasic.c50
1 files changed, 46 insertions, 4 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index 8b199ce..9d6255c 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -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: tclBasic.c,v 1.75.2.10 2004/09/29 19:36:36 msofer Exp $
+ * RCS: @(#) $Id: tclBasic.c,v 1.75.2.11 2005/01/28 01:50:26 hobbs Exp $
*/
#include "tclInt.h"
@@ -4139,11 +4139,29 @@ Tcl_ExprLong(interp, string, ptr)
/*
* Store an integer based on the expression result.
*/
-
+
if (resultPtr->typePtr == &tclIntType) {
*ptr = resultPtr->internalRep.longValue;
} else if (resultPtr->typePtr == &tclDoubleType) {
*ptr = (long) resultPtr->internalRep.doubleValue;
+ } else if (resultPtr->typePtr == &tclWideIntType) {
+#ifndef TCL_WIDE_INT_IS_LONG
+ /*
+ * See Tcl_GetIntFromObj for conversion comments.
+ */
+ Tcl_WideInt w = resultPtr->internalRep.wideValue;
+ if ((w >= -(Tcl_WideInt)(ULONG_MAX))
+ && (w <= (Tcl_WideInt)(ULONG_MAX))) {
+ *ptr = Tcl_WideAsLong(w);
+ } else {
+ Tcl_SetResult(interp,
+ "integer value too large to represent as non-long integer",
+ TCL_STATIC);
+ result = TCL_ERROR;
+ }
+#else
+ *ptr = resultPtr->internalRep.longValue;
+#endif
} else {
Tcl_SetResult(interp,
"expression didn't have numeric value", TCL_STATIC);
@@ -4190,11 +4208,29 @@ Tcl_ExprDouble(interp, string, ptr)
/*
* Store a double based on the expression result.
*/
-
+
if (resultPtr->typePtr == &tclIntType) {
*ptr = (double) resultPtr->internalRep.longValue;
} else if (resultPtr->typePtr == &tclDoubleType) {
*ptr = resultPtr->internalRep.doubleValue;
+ } else if (resultPtr->typePtr == &tclWideIntType) {
+#ifndef TCL_WIDE_INT_IS_LONG
+ /*
+ * See Tcl_GetIntFromObj for conversion comments.
+ */
+ Tcl_WideInt w = resultPtr->internalRep.wideValue;
+ if ((w >= -(Tcl_WideInt)(ULONG_MAX))
+ && (w <= (Tcl_WideInt)(ULONG_MAX))) {
+ *ptr = (double) Tcl_WideAsLong(w);
+ } else {
+ Tcl_SetResult(interp,
+ "integer value too large to represent as non-long integer",
+ TCL_STATIC);
+ result = TCL_ERROR;
+ }
+#else
+ *ptr = (double) resultPtr->internalRep.longValue;
+#endif
} else {
Tcl_SetResult(interp,
"expression didn't have numeric value", TCL_STATIC);
@@ -4241,11 +4277,17 @@ Tcl_ExprBoolean(interp, string, ptr)
/*
* Store a boolean based on the expression result.
*/
-
+
if (resultPtr->typePtr == &tclIntType) {
*ptr = (resultPtr->internalRep.longValue != 0);
} else if (resultPtr->typePtr == &tclDoubleType) {
*ptr = (resultPtr->internalRep.doubleValue != 0.0);
+ } else if (resultPtr->typePtr == &tclWideIntType) {
+#ifndef TCL_WIDE_INT_IS_LONG
+ *ptr = (resultPtr->internalRep.wideValue != 0);
+#else
+ *ptr = (resultPtr->internalRep.longValue != 0);
+#endif
} else {
result = Tcl_GetBooleanFromObj(interp, resultPtr, ptr);
}