aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorPedro F. Giffuni <pfg@FreeBSD.org>2017-02-28 20:50:49 +0000
committerPedro F. Giffuni <pfg@FreeBSD.org>2017-02-28 20:50:49 +0000
commit29dfec52946a038ba85cae45ed06ad28eacb13cc (patch)
treeed52fe4d642f3187ad8db8f5bd835516d32aad33 /usr.bin
parentdf6186309a49309fbc188aa152d661b9e0c4163a (diff)
Notes
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/dc/bcode.c14
-rw-r--r--usr.bin/dc/dc.16
2 files changed, 19 insertions, 1 deletions
diff --git a/usr.bin/dc/bcode.c b/usr.bin/dc/bcode.c
index 2834e4f2b1c9..e6a980e4ac23 100644
--- a/usr.bin/dc/bcode.c
+++ b/usr.bin/dc/bcode.c
@@ -69,6 +69,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);
@@ -198,6 +199,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 },
@@ -508,6 +510,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();
diff --git a/usr.bin/dc/dc.1 b/usr.bin/dc/dc.1
index 507bbe6777d3..43ba6cf01cd4 100644
--- a/usr.bin/dc/dc.1
+++ b/usr.bin/dc/dc.1
@@ -35,7 +35,7 @@
.\"
.\" @(#)dc.1 8.1 (Berkeley) 6/6/93
.\"
-.Dd April 16, 2014
+.Dd February 27, 2017
.Dt DC 1
.Os
.Sh NAME
@@ -196,6 +196,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