From 7a116443a870099b88001b8017e2100cc8ee0937 Mon Sep 17 00:00:00 2001 From: rmax Date: Mon, 12 Dec 2005 11:28:22 +0000 Subject: * generic/tclExecute.c (ExprAbsFunc): fixed the abs(MIN_INT) case so that it doesn't break on compilers that don't assume integers to wrap around (e.g. gcc-4.1.0). --- ChangeLog | 6 ++++++ generic/tclExecute.c | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2c574b2..fd1b850 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-12-12 Reinhard Max + + * generic/tclExecute.c (ExprAbsFunc): fixed the abs(MIN_INT) case + so that it doesn't break on compilers that don't assume integers + to wrap around (e.g. gcc-4.1.0). + 2005-12-09 Donal K. Fellows * tests/lsearch.test (lsearch-10.8..10): If the -start is off the end, diff --git a/generic/tclExecute.c b/generic/tclExecute.c index c238a98..34e4ec1 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.2.17 2005/10/28 03:26:32 mdejong Exp $ + * RCS: @(#) $Id: tclExecute.c,v 1.94.2.18 2005/12/12 11:28:22 rmax Exp $ */ #include "tclInt.h" @@ -5074,8 +5074,7 @@ ExprAbsFunc(interp, eePtr, clientData) if (valuePtr->typePtr == &tclIntType) { i = valuePtr->internalRep.longValue; if (i < 0) { - iResult = -i; - if (iResult < 0) { + if (i == LONG_MIN) { #ifdef TCL_WIDE_INT_IS_LONG Tcl_SetObjResult(interp, Tcl_NewStringObj( "integer value too large to represent", -1)); @@ -5094,6 +5093,7 @@ ExprAbsFunc(interp, eePtr, clientData) #endif } + iResult = -i; } else { iResult = i; } -- cgit v0.12