From 0bceead396460bd96a148e6a6c9e55acc1ed7311 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 27 Feb 2018 20:30:00 +0000 Subject: No need to set/restore tcl_precision in this test-case --- tests/basic.test | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tests/basic.test b/tests/basic.test index d47613a..0e4ddea 100644 --- a/tests/basic.test +++ b/tests/basic.test @@ -893,21 +893,17 @@ test basic-48.16.$noComp {expansion: testing for leaks} -setup { rename stress {} } -result 0 -test basic-48.17.$noComp {expansion: object safety} -setup { - set old_precision $::tcl_precision - set ::tcl_precision 4 - } -constraints $constraints -body { +test basic-48.17.$noComp {expansion: object safety} -constraints $constraints -body { set third [expr {1.0/3.0}] set l [list $third $third] set x [run {list $third {*}$l $third}] - set res [list] + set res [list] foreach t $x { lappend res [expr {$t * 3.0}] } set res } -cleanup { - set ::tcl_precision $old_precision - unset old_precision res t l x third + unset res t l x third } -result {1.0 1.0 1.0 1.0} test basic-48.18.$noComp {expansion: list semantics} -constraints $constraints -body { -- cgit v0.12 From 9a809e614ae7603730d8cc5f60b454b66dffa972 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 27 Feb 2018 20:48:00 +0000 Subject: Use mp_isneg() in stead of mp_cmp_d() when the output of this function is simply compared with MP_LT. --- generic/tclBasic.c | 2 +- generic/tclExecute.c | 18 +++++++++--------- generic/tclScan.c | 2 +- generic/tclStrToD.c | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/generic/tclBasic.c b/generic/tclBasic.c index a182139..3d16b70 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -7527,7 +7527,7 @@ ExprAbsFunc( } if (type == TCL_NUMBER_BIG) { - if (mp_cmp_d((const mp_int *) ptr, 0) == MP_LT) { + if (mp_isneg((const mp_int *) ptr)) { Tcl_GetBignumFromObj(NULL, objv[1], &big); tooLarge: mp_neg(&big, &big); diff --git a/generic/tclExecute.c b/generic/tclExecute.c index a83023c..1c69474 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -8092,7 +8092,7 @@ ExecuteExtendedBinaryMathOp( break; case TCL_NUMBER_BIG: Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2); - invalid = (mp_cmp_d(&big2, 0) == MP_LT); + invalid = mp_isneg(&big2); mp_clear(&big2); break; default: @@ -8171,7 +8171,7 @@ ExecuteExtendedBinaryMathOp( break; case TCL_NUMBER_BIG: Tcl_TakeBignumFromObj(NULL, valuePtr, &big1); - zero = (mp_cmp_d(&big1, 0) == MP_GT); + zero = (!mp_isneg(&big1)); mp_clear(&big1); break; default: @@ -8209,7 +8209,7 @@ ExecuteExtendedBinaryMathOp( } else { mp_init(&bigRemainder); mp_div_2d(&big1, shift, &bigResult, &bigRemainder); - if (mp_cmp_d(&bigRemainder, 0) == MP_LT) { + if (mp_isneg(&bigRemainder)) { /* * Convert to Tcl's integer division rules. */ @@ -8236,14 +8236,14 @@ ExecuteExtendedBinaryMathOp( * arguments is negative, store it in 'Second'. */ - if (mp_cmp_d(&big1, 0) != MP_LT) { - numPos = 1 + (mp_cmp_d(&big2, 0) != MP_LT); + if (!mp_isneg(&big1)) { + numPos = 1 + !mp_isneg(&big2); First = &big1; Second = &big2; } else { First = &big2; Second = &big1; - numPos = (mp_cmp_d(First, 0) != MP_LT); + numPos = (!mp_isneg(First)); } mp_init(&bigResult); @@ -8445,7 +8445,7 @@ ExecuteExtendedBinaryMathOp( break; case TCL_NUMBER_BIG: Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2); - negativeExponent = (mp_cmp_d(&big2, 0) == MP_LT); + negativeExponent = mp_isneg(&big2); mp_mod_2d(&big2, 1, &big2); oddExponent = !mp_iszero(&big2); mp_clear(&big2); @@ -8995,7 +8995,7 @@ TclCompareTwoNumbers( goto wideCompare; case TCL_NUMBER_BIG: Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2); - if (mp_cmp_d(&big2, 0) == MP_LT) { + if (mp_isneg(&big2)) { compare = MP_GT; } else { compare = MP_LT; @@ -9032,7 +9032,7 @@ TclCompareTwoNumbers( } Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2); if ((d1 < (double)LONG_MAX) && (d1 > (double)LONG_MIN)) { - if (mp_cmp_d(&big2, 0) == MP_LT) { + if (mp_isneg(&big2)) { compare = MP_GT; } else { compare = MP_LT; diff --git a/generic/tclScan.c b/generic/tclScan.c index 25c6c2b..d55d29b 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -942,7 +942,7 @@ Tcl_ScanObjCmd( if (flags & SCAN_UNSIGNED) { mp_int big; if ((Tcl_GetBignumFromObj(interp, objPtr, &big) != TCL_OK) - || (mp_cmp_d(&big, 0) == MP_LT)) { + || mp_isneg(&big)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "unsigned bignum scans are invalid", -1)); Tcl_SetErrorCode(interp, "TCL", "FORMAT", "BADUNSIGNED",NULL); diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c index ac2ca68..0434919 100644 --- a/generic/tclStrToD.c +++ b/generic/tclStrToD.c @@ -4697,7 +4697,7 @@ TclCeil( mp_int b; mp_init(&b); - if (mp_cmp_d(a, 0) == MP_LT) { + if (mp_isneg(a)) { mp_neg(a, &b); r = -TclFloor(&b); } else { @@ -4754,7 +4754,7 @@ TclFloor( mp_int b; mp_init(&b); - if (mp_cmp_d(a, 0) == MP_LT) { + if (mp_isneg(a)) { mp_neg(a, &b); r = -TclCeil(&b); } else { -- cgit v0.12