diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2004-09-18 19:24:53 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2004-09-18 19:24:53 (GMT) |
commit | db2dab191d956abec9f57c0ff0b8b66c99a3e2ca (patch) | |
tree | 0679f448060276303bb27ed7478d9fef74ca6a35 | |
parent | 9a4d29bde94d4183ffa1066d4da062e4a2a4e7f2 (diff) | |
download | tcl-db2dab191d956abec9f57c0ff0b8b66c99a3e2ca.zip tcl-db2dab191d956abec9f57c0ff0b8b66c99a3e2ca.tar.gz tcl-db2dab191d956abec9f57c0ff0b8b66c99a3e2ca.tar.bz2 |
Fix silly mistakes :} and make sure that the original bug is a test case.
-rw-r--r-- | generic/tclExecute.c | 30 | ||||
-rw-r--r-- | tests/expr.test | 7 |
2 files changed, 21 insertions, 16 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c index a5dd499..b45743c 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.148 2004/09/18 18:04:04 dkf Exp $ + * RCS: @(#) $Id: tclExecute.c,v 1.149 2004/09/18 19:24:53 dkf Exp $ */ #ifdef STDC_HEADERS @@ -3653,6 +3653,8 @@ TclExecuteByteCode(interp, codePtr) #endif /* TCL_COMPILE_DEBUG */ if (w < 0) { wResult = ~w; + } else { + wResult = w; } /* * Shift in steps when the shift gets large to prevent @@ -3661,14 +3663,14 @@ TclExecuteByteCode(interp, codePtr) if (i2 >= 64) { wResult = Tcl_LongAsWide(0); } else if (i2 > 60) { - wResult <<= 30; - wResult <<= 30; - wResult <<= i2-60; + wResult >>= 30; + wResult >>= 30; + wResult >>= i2-60; } else if (i2 > 30) { - wResult <<= 30; - wResult <<= i2-30; + wResult >>= 30; + wResult >>= i2-30; } else { - wResult <<= i2; + wResult >>= i2; } if (w < 0) { wResult = ~wResult; @@ -3678,6 +3680,8 @@ TclExecuteByteCode(interp, codePtr) } if (i < 0) { iResult = ~i; + } else { + iResult = i; } /* * Shift in steps when the shift gets large to prevent @@ -3686,14 +3690,14 @@ TclExecuteByteCode(interp, codePtr) if (i2 >= 64) { iResult = 0; } else if (i2 > 60) { - iResult <<= 30; - iResult <<= 30; - iResult <<= i2-60; + iResult >>= 30; + iResult >>= 30; + iResult >>= i2-60; } else if (i2 > 30) { - iResult <<= 30; - iResult <<= i2-30; + iResult >>= 30; + iResult >>= i2-30; } else { - iResult <<= i2; + iResult >>= i2; } if (i < 0) { iResult = ~iResult; diff --git a/tests/expr.test b/tests/expr.test index 028f56f..001412c 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.23 2004/09/18 18:04:06 dkf Exp $ +# RCS: @(#) $Id: expr.test,v 1.24 2004/09/18 19:24:54 dkf Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -867,8 +867,9 @@ test expr-24.3 {expr edge cases; shifting} {expr wide(5)>>32} 0 test expr-24.4 {expr edge cases; shifting} {expr wide(5)>>63} 0 test expr-24.5 {expr edge cases; shifting} {expr int(5)<<32} 0 test expr-24.6 {expr edge cases; shifting} {expr int(5)<<63} 0 -test expr-24.7 {expr edge cases; shifting} {expr wide(5)<<32} 0 -test expr-24.8 {expr edge cases; shifting} {expr wide(5)<<63} 0 +test expr-24.7 {expr edge cases; shifting} {expr wide(5)<<32} 21474836480 +test expr-24.8 {expr edge cases; shifting} {expr wide(10)<<63} 0 +test expr-24.9 {expr edge cases; shifting} {expr 5>>32} 0 # cleanup if {[info exists a]} { |