summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2003-11-17 11:12:36 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2003-11-17 11:12:36 +0000
commit69a52453f852dfcc264e1b848b8bbf26dfc4b3d6 (patch)
tree9eb5164af4b4cac0216e61f99f5b945f8b2d4199 /usr.bin
parent20e60ea9fc40f1f7e837c7da4c0e70d379a45d64 (diff)
A basic stack operation that is missing from the original dc (and
GNU dc as well): drop ('R').
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/dc/bcode.c14
-rw-r--r--usr.bin/dc/dc.15
2 files changed, 16 insertions, 3 deletions
diff --git a/usr.bin/dc/bcode.c b/usr.bin/dc/bcode.c
index 2021a408d3d..86cb98a93a9 100644
--- a/usr.bin/dc/bcode.c
+++ b/usr.bin/dc/bcode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcode.c,v 1.16 2003/11/14 20:25:16 otto Exp $ */
+/* $OpenBSD: bcode.c,v 1.17 2003/11/17 11:12:35 otto Exp $ */
/*
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
@@ -17,7 +17,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: bcode.c,v 1.16 2003/11/14 20:25:16 otto Exp $";
+static const char rcsid[] = "$OpenBSD: bcode.c,v 1.17 2003/11/17 11:12:35 otto Exp $";
#endif /* not lint */
#include <ssl/ssl.h>
@@ -71,6 +71,7 @@ static void pop_printn(void);
static __inline void print_stack();
static __inline void dup(void);
static void swap(void);
+static void drop(void);
static void get_scale(void);
static void set_scale(void);
@@ -179,6 +180,7 @@ static const struct jump_entry jump_table_data[] = {
{ 'O', get_obase },
{ 'P', pop_print },
{ 'Q', quitN },
+ { 'R', drop },
{ 'S', store_stack },
{ 'X', push_scale },
{ 'Z', num_digits },
@@ -516,6 +518,14 @@ swap(void)
}
static void
+drop(void)
+{
+ struct value *v = pop();
+ if (v != NULL)
+ stack_free_value(v);
+}
+
+static void
get_scale(void)
{
struct number *n;
diff --git a/usr.bin/dc/dc.1 b/usr.bin/dc/dc.1
index 58c4696d169..34beefe403a 100644
--- a/usr.bin/dc/dc.1
+++ b/usr.bin/dc/dc.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: dc.1,v 1.16 2003/11/14 20:25:16 otto Exp $
+.\" $OpenBSD: dc.1,v 1.17 2003/11/17 11:12:35 otto Exp $
.\"
.\" Copyright (C) Caldera International Inc. 2001-2002.
.\" All rights reserved.
@@ -243,6 +243,9 @@ by that value.
Exits the program.
If executing a string, the recursion level is
popped by two.
+.It Ic R
+The top of the stack is removed (popped).
+This is a non-portable extension.
.It Ic r
The top two values on the stack are reversed (swapped).
This is a non-portable extension.