Update LibTomMath to 1.2.0 (#84) * update C files * update other files * update headers * update makefiles * remove mp_set/get_double() * use ltm 1.2.0 API * update ltm_desc * use bundled tommath if system-tommath is too old * XMALLOC etc. were changed to MP_MALLOC etc.
author Steffen Jaeckel Tue, 26 May 2020 17:36:47 +0200 f52919ffd3b1
line wrap: on
line diff
```--- a/libtommath/bn_mp_read_radix.c	Tue May 26 23:27:26 2020 +0800
@@ -1,23 +1,18 @@
#include "tommath_private.h"
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- */
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+
+#define MP_TOUPPER(c) ((((c) >= 'a') && ((c) <= 'z')) ? (((c) + 'A') - 'a') : (c))

{
-   int     y, res, neg;
+   mp_err   err;
+   int      y;
+   mp_sign  neg;
unsigned pos;
-   char    ch;
+   char     ch;

/* zero the digit bignum */
mp_zero(a);
@@ -46,7 +41,7 @@
* this allows numbers like 1AB and 1ab to represent the same  value
* [e.g. in hex]
*/
-      ch = (radix <= 36) ? (char)toupper((int)*str) : *str;
+      ch = (radix <= 36) ? (char)MP_TOUPPER((int)*str) : *str;
pos = (unsigned)(ch - '(');
if (mp_s_rmap_reverse_sz < pos) {
break;
@@ -60,11 +55,11 @@
if ((y == 0xff) || (y >= radix)) {
break;
}
-      if ((res = mp_mul_d(a, (mp_digit)radix, a)) != MP_OKAY) {
-         return res;
+      if ((err = mp_mul_d(a, (mp_digit)radix, a)) != MP_OKAY) {
+         return err;
}
-      if ((res = mp_add_d(a, (mp_digit)y, a)) != MP_OKAY) {
-         return res;
+      if ((err = mp_add_d(a, (mp_digit)y, a)) != MP_OKAY) {
+         return err;
}
++str;
}
@@ -76,13 +71,9 @@
}

/* set the sign only if a != 0 */
-   if (mp_iszero(a) != MP_YES) {
+   if (!MP_IS_ZERO(a)) {
a->sign = neg;
}
return MP_OKAY;
}
#endif
-
-/* ref:         HEAD -> master, tag: v1.1.0 */