aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncaen <mail@duncano.de>2017-05-19 18:59:44 +0200
committerDuncaen <mail@duncano.de>2017-05-19 18:59:44 +0200
commit85af83ec31243e616259461b33134bbc8b6d09d6 (patch)
treeae29307806fe54ebc70842b99c1daaf17f594608
parent88ae87dcf3f8cde80d4698390590599823f9be30 (diff)
downloadlobase-85af83ec31243e616259461b33134bbc8b6d09d6.tar.gz
usr.bin/dc: update to OPENBSD_6_1
-rw-r--r--usr.bin/dc/bcode.c22
-rw-r--r--usr.bin/dc/dc.110
-rw-r--r--usr.bin/dc/inout.c4
3 files changed, 27 insertions, 9 deletions
diff --git a/usr.bin/dc/bcode.c b/usr.bin/dc/bcode.c
index 1e41696..6a0e590 100644
--- a/usr.bin/dc/bcode.c
+++ b/usr.bin/dc/bcode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcode.c,v 1.49 2016/03/27 15:55:13 otto Exp $ */
+/* $OpenBSD: bcode.c,v 1.51 2017/02/26 11:29:55 otto Exp $ */
/*
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
@@ -67,6 +67,7 @@ static __inline struct number *pop_number(void);
static __inline char *pop_string(void);
static __inline void clear_stack(void);
static __inline void print_tos(void);
+static void print_err(void);
static void pop_print(void);
static void pop_printn(void);
static __inline void print_stack(void);
@@ -195,6 +196,7 @@ static const struct jump_entry jump_table_data[] = {
{ 'a', to_ascii },
{ 'c', clear_stack },
{ 'd', dup },
+ { 'e', print_err },
{ 'f', print_stack },
{ 'i', set_ibase },
{ 'k', set_scale },
@@ -384,7 +386,7 @@ split_number(const struct number *n, BIGNUM *i, BIGNUM *f)
bn_checkp(BN_copy(i, n->number));
if (n->scale == 0 && f != NULL)
- bn_check(BN_zero(f));
+ bn_check(BN_set_word(f, 0));
else if (n->scale < sizeof(factors)/sizeof(factors[0])) {
rem = BN_div_word(i, factors[n->scale]);
if (f != NULL)
@@ -497,6 +499,18 @@ print_tos(void)
}
static void
+print_err(void)
+{
+ struct value *value = tos();
+ if (value != NULL) {
+ print_value(stderr, value, "", bmachine.obase);
+ (void)putc('\n', stderr);
+ }
+ else
+ warnx("stack empty");
+}
+
+static void
pop_print(void)
{
struct value *value = pop();
@@ -790,7 +804,7 @@ load(void)
v = stack_tos(&bmachine.reg[idx]);
if (v == NULL) {
n = new_number();
- bn_check(BN_zero(n->number));
+ bn_check(BN_set_word(n->number, 0));
push_number(n);
} else
push(stack_dup_value(v, &copy));
@@ -874,7 +888,7 @@ load_array(void)
v = frame_retrieve(stack, idx);
if (v == NULL || v->type == BCODE_NONE) {
n = new_number();
- bn_check(BN_zero(n->number));
+ bn_check(BN_set_word(n->number, 0));
push_number(n);
}
else
diff --git a/usr.bin/dc/dc.1 b/usr.bin/dc/dc.1
index 42abbcd..8c2a4d1 100644
--- a/usr.bin/dc/dc.1
+++ b/usr.bin/dc/dc.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: dc.1,v 1.28 2015/10/03 17:15:26 deraadt Exp $
+.\" $OpenBSD: dc.1,v 1.30 2017/02/23 06:40:17 otto Exp $
.\"
.\" Copyright (C) Caldera International Inc. 2001-2002.
.\" All rights reserved.
@@ -34,7 +34,7 @@
.\"
.\" @(#)dc.1 8.1 (Berkeley) 6/6/93
.\"
-.Dd $Mdocdate: October 3 2015 $
+.Dd $Mdocdate: February 23 2017 $
.Dt DC 1
.Os
.Sh NAME
@@ -185,6 +185,10 @@ operator is a non-portable extension.
All values on the stack are popped.
.It Ic d
The top value on the stack is duplicated.
+.It Ic e
+Equivalent to
+.Ic p ,
+except that the output is written to the standard error stream.
.It Ic f
All values on the stack are printed, separated by newlines.
.It Ic G
@@ -516,7 +520,7 @@ command first appeared in
A complete rewrite of the
.Nm
command using the
-.Xr bn 3
+.Xr BN_new 3
big number routines first appeared in
.Ox 3.5 .
.Sh AUTHORS
diff --git a/usr.bin/dc/inout.c b/usr.bin/dc/inout.c
index 1045cee..cb98912 100644
--- a/usr.bin/dc/inout.c
+++ b/usr.bin/dc/inout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inout.c,v 1.19 2015/02/16 20:53:34 jca Exp $ */
+/* $OpenBSD: inout.c,v 1.20 2017/02/26 11:29:55 otto Exp $ */
/*
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
@@ -187,7 +187,7 @@ readnumber(struct source *src, u_int base)
u_int i;
n = new_number();
- bn_check(BN_zero(n->number));
+ bn_check(BN_set_word(n->number, 0));
while ((ch = (*src->vtable->readchar)(src)) != EOF) {