Module Name: src Committed By: bouyer Date: Fri Jun 30 18:10:12 UTC 2023
Modified Files: src/usr.bin/dc [netbsd-10]: bcode.c Log Message: Pull up following revision(s) (requested by martin in ticket #220): usr.bin/dc/bcode.c: revision 1.4 Make this compile when BIGNUM limbs (BN_ULONG) are not the same size as "unsigned long" (e.g. in bn(64/32) configurations of openssl). To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.3.14.1 src/usr.bin/dc/bcode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/dc/bcode.c diff -u src/usr.bin/dc/bcode.c:1.3 src/usr.bin/dc/bcode.c:1.3.14.1 --- src/usr.bin/dc/bcode.c:1.3 Tue Feb 6 17:58:19 2018 +++ src/usr.bin/dc/bcode.c Fri Jun 30 18:10:12 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: bcode.c,v 1.3 2018/02/06 17:58:19 christos Exp $ */ +/* $NetBSD: bcode.c,v 1.3.14.1 2023/06/30 18:10:12 bouyer Exp $ */ /* $OpenBSD: bcode.c,v 1.51 2017/02/26 11:29:55 otto Exp $ */ /* @@ -17,7 +17,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <sys/cdefs.h> -__RCSID("$NetBSD: bcode.c,v 1.3 2018/02/06 17:58:19 christos Exp $"); +__RCSID("$NetBSD: bcode.c,v 1.3.14.1 2023/06/30 18:10:12 bouyer Exp $"); #include <err.h> #include <limits.h> @@ -338,7 +338,7 @@ max(u_int a, u_int b) return a > b ? a : b; } -static unsigned long factors[] = { +static BN_ULONG factors[] = { 0, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 }; @@ -370,7 +370,7 @@ scale_number(BIGNUM *n, int s) bn_checkp(ctx); bn_check(BN_set_word(a, 10)); - bn_check(BN_set_word(p, abs_scale)); + bn_check(BN_set_word(p, (BN_ULONG)abs_scale)); bn_check(BN_exp(a, a, p, ctx)); if (s > 0) bn_check(BN_mul(n, n, a, ctx)); @@ -394,7 +394,7 @@ split_number(const struct number *n, BIG else if (n->scale < sizeof(factors)/sizeof(factors[0])) { rem = BN_div_word(i, factors[n->scale]); if (f != NULL) - bn_check(BN_set_word(f, rem)); + bn_check(BN_set_word(f, (BN_ULONG)rem)); } else { BIGNUM *a, *p; BN_CTX *ctx; @@ -663,7 +663,7 @@ stackdepth(void) i = stack_size(&bmachine.stack); n = new_number(); - bn_check(BN_set_word(n->number, i)); + bn_check(BN_set_word(n->number, (BN_ULONG)i)); push_number(n); } @@ -732,12 +732,12 @@ num_digits(void) case BCODE_NUMBER: digits = count_digits(value->u.num); n = new_number(); - bn_check(BN_set_word(n->number, digits)); + bn_check(BN_set_word(n->number, (BN_ULONG)digits)); break; case BCODE_STRING: digits = strlen(value->u.string); n = new_number(); - bn_check(BN_set_word(n->number, digits)); + bn_check(BN_set_word(n->number, (BN_ULONG)digits)); break; } stack_free_value(value);