Date: Sat, 3 Mar 2018 10:18:32 +0000 (UTC) From: Eitan Adler <eadler@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r330317 - stable/11/usr.bin/dc Message-ID: <201803031018.w23AIWMV020827@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: eadler Date: Sat Mar 3 10:18:32 2018 New Revision: 330317 URL: https://svnweb.freebsd.org/changeset/base/330317 Log: MFC r314409: dc(1): Introduce e command, equivalent to p, but writes to stderr Obtained from: OpenBSD MFC after: 2 weeks Modified: stable/11/usr.bin/dc/bcode.c stable/11/usr.bin/dc/dc.1 Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/dc/bcode.c ============================================================================== --- stable/11/usr.bin/dc/bcode.c Sat Mar 3 10:15:37 2018 (r330316) +++ stable/11/usr.bin/dc/bcode.c Sat Mar 3 10:18:32 2018 (r330317) @@ -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 }, @@ -502,6 +504,18 @@ print_tos(void) if (value != NULL) { print_value(stdout, value, "", bmachine.obase); putchar('\n'); + } + else + warnx("stack empty"); +} + +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"); Modified: stable/11/usr.bin/dc/dc.1 ============================================================================== --- stable/11/usr.bin/dc/dc.1 Sat Mar 3 10:15:37 2018 (r330316) +++ stable/11/usr.bin/dc/dc.1 Sat Mar 3 10:18:32 2018 (r330317) @@ -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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803031018.w23AIWMV020827>