diff options
author | eadler <eadler@FreeBSD.org> | 2018-03-03 10:18:32 +0000 |
---|---|---|
committer | eadler <eadler@FreeBSD.org> | 2018-03-03 10:18:32 +0000 |
commit | f499542137f29f320a81ac273865452211f8b4e1 (patch) | |
tree | f3fb0a6167624f06a2e7f62bd2a56e9957beeb58 /usr.bin | |
parent | fa4a5c63b08224d6b66a0c0824d5b3b51c33d4c9 (diff) | |
download | FreeBSD-src-f499542137f29f320a81ac273865452211f8b4e1.zip FreeBSD-src-f499542137f29f320a81ac273865452211f8b4e1.tar.gz |
MFC r314409:
dc(1): Introduce e command, equivalent to p, but writes to stderr
Obtained from: OpenBSD
MFC after: 2 weeks
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/dc/bcode.c | 14 | ||||
-rw-r--r-- | usr.bin/dc/dc.1 | 6 |
2 files changed, 19 insertions, 1 deletions
diff --git a/usr.bin/dc/bcode.c b/usr.bin/dc/bcode.c index 2834e4f..e6a980e 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 507bbe6..43ba6cf 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 |