diff options
author | Kevin B Kenny <kennykb@acm.org> | 2005-08-17 19:34:23 (GMT) |
---|---|---|
committer | Kevin B Kenny <kennykb@acm.org> | 2005-08-17 19:34:23 (GMT) |
commit | 9d57fd3ed0e612b7f0cc39912981ef64b156c601 (patch) | |
tree | 9443cf41cbd449fe12e13104873536563d7924d5 | |
parent | f57b2db71f7dd7c6447a5b477cd12df76d8db5ca (diff) | |
download | tcl-9d57fd3ed0e612b7f0cc39912981ef64b156c601.zip tcl-9d57fd3ed0e612b7f0cc39912981ef64b156c601.tar.gz tcl-9d57fd3ed0e612b7f0cc39912981ef64b156c601.tar.bz2 |
fancier casts in Tcl_ExprLongObj to avoid unwanted sign-extension
-rw-r--r-- | generic/tclBasic.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c index e599e2d..264c25a 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.136.2.16 2005/08/17 19:12:09 kennykb Exp $ + * RCS: @(#) $Id: tclBasic.c,v 1.136.2.17 2005/08/17 19:34:23 kennykb Exp $ */ #include "tclInt.h" @@ -4278,8 +4278,10 @@ Tcl_ExprLongObj(interp, objPtr, ptr) Tcl_SetResult(interp, "integer value too large to represent", TCL_STATIC); result = TCL_ERROR; + } else if (d >= 0) { + *ptr = (long)(unsigned long)d; } else { - *ptr = (long)d; + *ptr = -(long)(unsigned long)-d; } } else { result = Tcl_GetLongFromObj(interp, resultPtr, ptr); |