diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-01-10 16:00:03 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-01-10 16:00:03 (GMT) |
commit | 8c3314fad91961fece370b6a28a8d6ee28655f2a (patch) | |
tree | d3f2a419f97a26bc8a997610fe8dee9db3b72426 | |
parent | 07829dc8b97cddd8d45cd926670016a965589bf7 (diff) | |
parent | 2d27c96b7eebdceae93e88adf3ca88ebbc6efab5 (diff) | |
download | tcl-8c3314fad91961fece370b6a28a8d6ee28655f2a.zip tcl-8c3314fad91961fece370b6a28a8d6ee28655f2a.tar.gz tcl-8c3314fad91961fece370b6a28a8d6ee28655f2a.tar.bz2 |
More WIP
-rw-r--r-- | generic/tclStrToD.c | 65 | ||||
-rw-r--r-- | libtommath/tommath_private.h | 4 | ||||
-rw-r--r-- | unix/tcl.pc.in | 2 |
3 files changed, 42 insertions, 29 deletions
diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c index 94e06ce..452e6fc 100644 --- a/generic/tclStrToD.c +++ b/generic/tclStrToD.c @@ -850,7 +850,7 @@ TclParseNumber( } else if (err == MP_OKAY) { err = mp_mul_2d(&significandBig, shift, &significandBig); if (err == MP_OKAY) { - mp_add_d(&significandBig, (mp_digit) d, &significandBig); + err = mp_add_d(&significandBig, (mp_digit) d, &significandBig); } } } @@ -888,17 +888,22 @@ TclParseNumber( ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || significandWide > ((Tcl_WideUInt)-1 >> shift))) { significandOverflow = 1; - mp_init_u64(&significandBig, + err = mp_init_u64(&significandBig, significandWide); } } if (!significandOverflow) { significandWide = (significandWide << shift) + 1; - } else { - mp_mul_2d(&significandBig, shift, &significandBig); - mp_add_d(&significandBig, (mp_digit) 1, &significandBig); + } else if (err == MP_OKAY) { + err = mp_mul_2d(&significandBig, shift, &significandBig); + if (err == MP_OKAY) { + err = mp_add_d(&significandBig, (mp_digit) 1, &significandBig); + } } } + if (err != MP_OKAY) { + return TCL_ERROR; + } numTrailZeros = 0; state = BINARY; break; @@ -1233,15 +1238,18 @@ TclParseNumber( ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || significandWide > (MOST_BITS + signum) >> shift)) { significandOverflow = 1; - mp_init_u64(&significandBig, significandWide); + err = mp_init_u64(&significandBig, significandWide); } if (shift) { if (!significandOverflow) { significandWide <<= shift; - } else { - mp_mul_2d(&significandBig, shift, &significandBig); + } else if (err == MP_OKAY) { + err = mp_mul_2d(&significandBig, shift, &significandBig); } } + if (err != MP_OKAY) { + return TCL_ERROR; + } goto returnInteger; case HEXADECIMAL: @@ -1254,15 +1262,18 @@ TclParseNumber( ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || significandWide > (MOST_BITS + signum) >> shift)) { significandOverflow = 1; - mp_init_u64(&significandBig, significandWide); + err = mp_init_u64(&significandBig, significandWide); } if (shift) { if (!significandOverflow) { significandWide <<= shift; - } else { - mp_mul_2d(&significandBig, shift, &significandBig); + } else if (err == MP_OKAY) { + err = mp_mul_2d(&significandBig, shift, &significandBig); } } + if (err != MP_OKAY) { + return TCL_ERROR; + } goto returnInteger; case OCTAL: @@ -1275,20 +1286,20 @@ TclParseNumber( ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || octalSignificandWide > (MOST_BITS + signum) >> shift)) { octalSignificandOverflow = 1; - mp_init_u64(&octalSignificandBig, + err = mp_init_u64(&octalSignificandBig, octalSignificandWide); } if (shift) { if (!octalSignificandOverflow) { octalSignificandWide <<= shift; - } else { - mp_mul_2d(&octalSignificandBig, shift, + } else if (err == MP_OKAY) { + err = mp_mul_2d(&octalSignificandBig, shift, &octalSignificandBig); } } if (!octalSignificandOverflow) { - if (octalSignificandWide > (MOST_BITS + signum)) { - mp_init_u64(&octalSignificandBig, + if ((err == MP_OKAY) && (octalSignificandWide > (MOST_BITS + signum))) { + err = mp_init_u64(&octalSignificandBig, octalSignificandWide); octalSignificandOverflow = 1; } else { @@ -1302,26 +1313,29 @@ TclParseNumber( } } } - if (octalSignificandOverflow) { + if ((err == MP_OKAY) && octalSignificandOverflow) { if (signum) { - (void)mp_neg(&octalSignificandBig, &octalSignificandBig); + err = mp_neg(&octalSignificandBig, &octalSignificandBig); } TclSetBignumIntRep(objPtr, &octalSignificandBig); } + if (err != MP_OKAY) { + return TCL_ERROR; + } break; case ZERO: case DECIMAL: significandOverflow = AccumulateDecimalDigit(0, numTrailZeros-1, &significandWide, &significandBig, significandOverflow); - if (!significandOverflow && (significandWide > MOST_BITS+signum)) { + if ((err == MP_OKAY) && !significandOverflow && (significandWide > MOST_BITS+signum)) { significandOverflow = 1; - mp_init_u64(&significandBig, significandWide); + err = mp_init_u64(&significandBig, significandWide); } returnInteger: if (!significandOverflow) { - if (significandWide > MOST_BITS+signum) { - mp_init_u64(&significandBig, + if ((err == MP_OKAY) && (significandWide > MOST_BITS+signum)) { + err = mp_init_u64(&significandBig, significandWide); significandOverflow = 1; } else { @@ -1335,12 +1349,15 @@ TclParseNumber( } } } - if (significandOverflow) { + if ((err == MP_OKAY) && significandOverflow) { if (signum) { - (void)mp_neg(&significandBig, &significandBig); + err = mp_neg(&significandBig, &significandBig); } TclSetBignumIntRep(objPtr, &significandBig); } + if (err != MP_OKAY) { + return TCL_ERROR; + } break; case FRACTION: diff --git a/libtommath/tommath_private.h b/libtommath/tommath_private.h index 072d603..5123f53 100644 --- a/libtommath/tommath_private.h +++ b/libtommath/tommath_private.h @@ -276,10 +276,6 @@ MP_DEPRECATED(s_mp_reverse) void bn_reverse(unsigned char *s, int len); MP_ZERO_DIGITS(a->dp + a->used, a->alloc - a->used); \ } -#ifdef _MSC_VER -/* Prevent false positive: unary minus operator applied to unsigned type, result still unsigned */ -#pragma warning(disable: 4146) -#endif #define MP_SET_SIGNED(name, uname, type, utype) \ void name(mp_int * a, type b) \ { \ diff --git a/unix/tcl.pc.in b/unix/tcl.pc.in index ca932d2..a343707 100644 --- a/unix/tcl.pc.in +++ b/unix/tcl.pc.in @@ -11,7 +11,7 @@ Name: Tool Command Language Description: Tcl is a powerful, easy-to-learn dynamic programming language, suitable for a wide range of uses. URL: http://www.tcl.tk/ Version: @TCL_VERSION@@TCL_PATCH_LEVEL@ -Requires.private: zlib >= 1.2.3 +Requires.private: zlib >= 1.2.3, libtommath >= 1.2.0 Libs: -L${libdir} @TCL_LIB_FLAG@ @TCL_STUB_LIB_FLAG@ Libs.private: @TCL_LIBS@ Cflags: -I${includedir} |