From owner-svn-src-stable@freebsd.org Sat Mar 3 10:18:32 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CD3A7F2DA86; Sat, 3 Mar 2018 10:18:32 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7B7D178FFB; Sat, 3 Mar 2018 10:18:32 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7621724F10; Sat, 3 Mar 2018 10:18:32 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w23AIWb7020829; Sat, 3 Mar 2018 10:18:32 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w23AIWMV020827; Sat, 3 Mar 2018 10:18:32 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201803031018.w23AIWMV020827@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Sat, 3 Mar 2018 10:18:32 +0000 (UTC) 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 X-SVN-Group: stable-11 X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: stable/11/usr.bin/dc X-SVN-Commit-Revision: 330317 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Mar 2018 10:18:33 -0000 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