From 6bc86f4b98c36219302ec99939666f84264bc4da Mon Sep 17 00:00:00 2001 From: Miguel Sofer Date: Tue, 10 May 2005 10:02:07 +0000 Subject: * generic/tclExecute.c (ExponLong, ExponWide): fixed special case 'i**0' for i>0 [Bug 1198892] --- ChangeLog | 5 +++++ generic/tclExecute.c | 6 +++--- tests/expr.test | 5 ++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8635f6c..b0027c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-05-10 Miguel Sofer + + * generic/tclExecute.c (ExponLong, ExponWide): fixed special case + 'i**0' for i>0 [Bug 1198892] + 2005-05-06 Jeff Hobbs * unix/tcl.m4, unix/configure: correct Solaris 10 (5.10) check and diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 32c4535..ad91579 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.186 2005/04/25 10:05:25 msofer Exp $ + * RCS: @(#) $Id: tclExecute.c,v 1.187 2005/05/10 10:02:16 msofer Exp $ */ #include "tclInt.h" @@ -6917,7 +6917,7 @@ ExponWide(w, w2, errExpon) } } else if (w == -1) { return (w2 & 1) ? Tcl_LongAsWide(-1) : Tcl_LongAsWide(1); - } else if (w == 1) { + } else if ((w == 1) || (w2 == 0)) { return Tcl_LongAsWide(1); } else if (w>1 && w2<0) { return W0; @@ -6987,7 +6987,7 @@ ExponLong(i, i2, errExpon) } } else if (i == -1) { return (i2&1) ? -1L : 1L; - } else if (i == 1) { + } else if ((i == 1) || (i2 == 0)) { return 1L; } else if (i > 1 && i2 < 0) { return 0L; diff --git a/tests/expr.test b/tests/expr.test index 9811430..f7195af 100644 --- a/tests/expr.test +++ b/tests/expr.test @@ -10,7 +10,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: expr.test,v 1.30 2004/11/01 14:38:26 dkf Exp $ +# RCS: @(#) $Id: expr.test,v 1.31 2005/05/10 10:02:18 msofer Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -868,6 +868,9 @@ test expr-23.30 {INST_EXPON: special cases} {expr {wide(-1)**wide(2)}} 1 test expr-23.31 {INST_EXPON: special cases} {expr {wide(-1)**wide(-1)}} -1 test expr-23.32 {INST_EXPON: special cases} {expr {wide(1)**wide(1234567)}} 1 test expr-23.33 {INST_EXPON: special cases} {expr {wide(2)**wide(-2)}} 0 +test expr-23.34 {INST_EXPON: special cases} {expr {2**0}} 1 +test expr-23.35 {INST_EXPON: special cases} {expr {wide(2)**0}} 1 + # Some compilers get this wrong; ensure that we work around it correctly test expr-24.1 {expr edge cases; shifting} {expr int(5)>>32} 0 -- cgit v0.12