Tcl Source Code

Artifact [847a3aa7ae]
Login

Artifact 847a3aa7ae0f603050ff08233d34e330b3af719a:

Attachment "1109484.patch" to ticket [1109484fff] added by hobbs 2005-01-28 08:51:17.
Index: generic/tclBasic.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclBasic.c,v
retrieving revision 1.139
diff -u -r1.139 tclBasic.c
--- generic/tclBasic.c	21 Jan 2005 17:42:11 -0000	1.139
+++ generic/tclBasic.c	28 Jan 2005 01:49:30 -0000
@@ -3882,11 +3882,29 @@
 	    /*
 	     * 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);
@@ -3932,11 +3950,29 @@
 	    /*
 	     * 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);
@@ -3982,11 +4018,17 @@
 	    /*
 	     * 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);
 	    }