summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2020-10-04 19:32:15 +0000
committerchristos <christos@NetBSD.org>2020-10-04 19:32:15 +0000
commitae987621fe3f97469837617481d558ae8a66683f (patch)
tree32c7d217ab10c72a2747774b49cf10ee0332bce7
parent47d0e4d716b8b1165dbe5721a0f138e5df714e9e (diff)
downloadbsdgames-darwin-ae987621fe3f97469837617481d558ae8a66683f.tar.gz
bsdgames-darwin-ae987621fe3f97469837617481d558ae8a66683f.tar.zst
bsdgames-darwin-ae987621fe3f97469837617481d558ae8a66683f.zip
- Accept octal input.
- Don't play with the original string so we can print it.
-rw-r--r--factor/factor.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/factor/factor.c b/factor/factor.c
index 6d7de720..6bef9069 100644
--- a/factor/factor.c
+++ b/factor/factor.c
@@ -1,4 +1,4 @@
-/* $NetBSD: factor.c,v 1.30 2020/10/03 22:27:00 christos Exp $ */
+/* $NetBSD: factor.c,v 1.31 2020/10/04 19:32:15 christos Exp $ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -41,7 +41,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\
__SCCSID("@(#)factor.c 8.4 (Berkeley) 5/4/95");
#endif
#ifdef __RCSID
-__RCSID("$NetBSD: factor.c,v 1.30 2020/10/03 22:27:00 christos Exp $");
+__RCSID("$NetBSD: factor.c,v 1.31 2020/10/04 19:32:15 christos Exp $");
#endif
#ifdef __FBSDID
__FBSDID("$FreeBSD: head/usr.bin/factor/factor.c 356666 2020-01-12 20:25:11Z gad $");
@@ -424,9 +424,10 @@ convert_str2bn(BIGNUM **val, char *p)
if (*p == '-')
errx(1, "negative numbers aren't permitted.");
if (*p == '0') {
- p++;
- if (*p == 'x' || *p == 'X')
- n = BN_hex2bn(val, ++p);
+ if (p[1] == 'x' || p[1] == 'X')
+ n = BN_hex2bn(val, p + 2);
+ else
+ n = BN_oct2bn(val, p + 1);
} else {
n = is_hex_str(p) ? BN_hex2bn(val, p) : BN_dec2bn(val, p);
}