summaryrefslogtreecommitdiff
path: root/usr.bin/dc
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2014-04-16 23:14:05 +0000
committerXin LI <delphij@FreeBSD.org>2014-04-16 23:14:05 +0000
commitbe848c7a13013b0555c07bfe92892b5dd546163f (patch)
tree4287628ab93fcb1da08cdd812e5b72100fb7c76b /usr.bin/dc
parent2ae4b3d100e93bf8942ef07933ebb723476b4a25 (diff)
downloadsrc-test2-be848c7a13013b0555c07bfe92892b5dd546163f.tar.gz
src-test2-be848c7a13013b0555c07bfe92892b5dd546163f.zip
Sync with OpenBSD.
MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=264573
Diffstat (limited to 'usr.bin/dc')
-rw-r--r--usr.bin/dc/bcode.c19
-rw-r--r--usr.bin/dc/bcode.h26
-rw-r--r--usr.bin/dc/dc.128
-rw-r--r--usr.bin/dc/inout.c2
4 files changed, 40 insertions, 35 deletions
diff --git a/usr.bin/dc/bcode.c b/usr.bin/dc/bcode.c
index f17a0da56c28..52ce85c00c9d 100644
--- a/usr.bin/dc/bcode.c
+++ b/usr.bin/dc/bcode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcode.c,v 1.40 2009/10/27 23:59:37 deraadt Exp $ */
+/* $OpenBSD: bcode.c,v 1.45 2012/11/07 11:06:14 otto Exp $ */
/*
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
@@ -29,7 +29,7 @@ __FBSDID("$FreeBSD$");
#include "extern.h"
-#define __inline
+/* #define DEBUGGING */
#define MAX_ARRAY_INDEX 2048
#define READSTACK_SIZE 8
@@ -253,7 +253,7 @@ init_bmachine(bool extended_registers)
u_int
bmachine_scale(void)
{
- return (bmachine.scale);
+ return bmachine.scale;
}
/* Reset the things needed before processing a (new) file */
@@ -428,7 +428,6 @@ get_ulong(struct number *n)
void
negate(struct number *n)
{
-
BN_set_negative(n->number, !BN_is_negative(n->number));
}
@@ -695,7 +694,7 @@ count_digits(const struct number *n)
u_int i;
if (BN_is_zero(n->number))
- return (n->scale ? n->scale : 1);
+ return n->scale ? n->scale : 1;
int_part = new_number();
fract_part = new_number();
@@ -1171,9 +1170,10 @@ bdivmod(void)
static void
bexp(void)
{
- struct number *a, *p, *r;
- u_int rscale;
- bool neg;
+ struct number *a, *p;
+ struct number *r;
+ bool neg;
+ u_int rscale;
p = pop_number();
if (p == NULL) {
@@ -1193,8 +1193,7 @@ bexp(void)
bn_checkp(f);
split_number(p, i, f);
if (!BN_is_zero(f))
- warnx("Runtime warning: non-zero fractional part "
- "in exponent");
+ warnx("Runtime warning: non-zero fractional part in exponent");
BN_free(i);
BN_free(f);
}
diff --git a/usr.bin/dc/bcode.h b/usr.bin/dc/bcode.h
index 7dc5d2db805f..7911bc21ff32 100644
--- a/usr.bin/dc/bcode.h
+++ b/usr.bin/dc/bcode.h
@@ -1,5 +1,5 @@
/* $FreeBSD$ */
-/* $OpenBSD: bcode.h,v 1.5 2006/01/16 08:09:25 otto Exp $ */
+/* $OpenBSD: bcode.h,v 1.7 2012/11/07 11:06:14 otto Exp $ */
/*
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
@@ -83,15 +83,15 @@ struct source {
int lastchar;
};
-void init_bmachine(bool);
-void reset_bmachine(struct source *);
-u_int bmachine_scale(void);
-void scale_number(BIGNUM *, int);
-void normalize(struct number *, u_int);
-void eval(void);
-void pn(const char *, const struct number *);
-void pbn(const char *, const BIGNUM *);
-void negate(struct number *);
-void split_number(const struct number *, BIGNUM *, BIGNUM *);
-void bmul_number(struct number *, struct number *,
- struct number *, u_int);
+void init_bmachine(bool);
+void reset_bmachine(struct source *);
+u_int bmachine_scale(void);
+void scale_number(BIGNUM *, int);
+void normalize(struct number *, u_int);
+void eval(void);
+void pn(const char *, const struct number *);
+void pbn(const char *, const BIGNUM *);
+void negate(struct number *);
+void split_number(const struct number *, BIGNUM *, BIGNUM *);
+void bmul_number(struct number *, struct number *,
+ struct number *, u_int scale);
diff --git a/usr.bin/dc/dc.1 b/usr.bin/dc/dc.1
index 94dba767e653..507bbe6777d3 100644
--- a/usr.bin/dc/dc.1
+++ b/usr.bin/dc/dc.1
@@ -1,5 +1,5 @@
.\" $FreeBSD$
-.\" $OpenBSD: dc.1,v 1.24 2010/01/02 19:48:56 schwarze Exp $
+.\" $OpenBSD: dc.1,v 1.27 2012/08/19 12:07:21 jmc Exp $
.\"
.\" Copyright (C) Caldera International Inc. 2001-2002.
.\" All rights reserved.
@@ -35,7 +35,7 @@
.\"
.\" @(#)dc.1 8.1 (Berkeley) 6/6/93
.\"
-.Dd January 22, 2010
+.Dd April 16, 2014
.Dt DC 1
.Os
.Sh NAME
@@ -73,12 +73,6 @@ Evaluate
If multiple
.Fl e
options are specified, they will be processed in the order given.
-If no
-.Ar filename
-argument is given, execution will stop after processing the expressions
-given on the command line,
-otherwise processing will continue with the contents of
-.Ar filename .
.It Fl f Ar filename , Fl Fl file Ar filename
Process the content of the given file before further calculations are done.
If multiple
@@ -98,14 +92,26 @@ See
for a more detailed description.
.El
.Pp
+If neither
+.Ar expression
+nor
+.Ar file
+are specified on the command line,
+.Nm
+reads from the standard input.
+Otherwise
+.Ar expression
+and
+.Ar file
+are processed and
+.Nm
+exits.
+.Pp
Ordinarily,
.Nm
operates on decimal integers,
but one may specify an input base, output base,
and a number of fractional digits (scale) to be maintained.
-If an argument is given,
-input is taken from that file until its end,
-then from the standard input.
Whitespace is ignored, except where it signals the end of a number,
end of a line or when a register name is expected.
The following constructions are recognized:
diff --git a/usr.bin/dc/inout.c b/usr.bin/dc/inout.c
index e35f0ad45942..740fb35bae7f 100644
--- a/usr.bin/dc/inout.c
+++ b/usr.bin/dc/inout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inout.c,v 1.15 2009/10/27 23:59:37 deraadt Exp $ */
+/* $OpenBSD: inout.c,v 1.17 2012/11/07 11:06:14 otto Exp $ */
/*
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>