summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2005-12-14 08:10:03 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2005-12-14 08:10:03 +0000
commit47a8aeddfb335933f1aa8739782de15e62092fd2 (patch)
treef4f43017b7740224749387b28ccfc506c21d4800 /usr.bin
parent4d38a126630f9e0ed9241f8095164c9708237426 (diff)
Fix parsing of non-decimal fractions, which was giving bogus results.
Noted by Zvezdan Petkovic in PR 4940.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/dc/inout.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/usr.bin/dc/inout.c b/usr.bin/dc/inout.c
index 2574065b4c5..1afbbd888c9 100644
--- a/usr.bin/dc/inout.c
+++ b/usr.bin/dc/inout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inout.c,v 1.12 2005/03/29 10:53:54 otto Exp $ */
+/* $OpenBSD: inout.c,v 1.13 2005/12/14 08:10:02 otto Exp $ */
/*
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
@@ -17,7 +17,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: inout.c,v 1.12 2005/03/29 10:53:54 otto Exp $";
+static const char rcsid[] = "$OpenBSD: inout.c,v 1.13 2005/12/14 08:10:02 otto Exp $";
#endif /* not lint */
#include <ssl/ssl.h>
@@ -192,6 +192,7 @@ readnumber(struct source *src, u_int base)
bool sign = false;
bool dot = false;
BN_ULONG v;
+ u_int i;
n = new_number();
bn_check(BN_zero(n->number));
@@ -225,6 +226,11 @@ readnumber(struct source *src, u_int base)
#endif
bn_check(BN_add_word(n->number, v));
}
+ if (base != 10) {
+ scale_number(n->number, n->scale);
+ for (i = 0; i < n->scale; i++)
+ BN_div_word(n->number, base);
+ }
if (sign)
negate(n);
return n;