diff options
author | delphij <delphij@FreeBSD.org> | 2014-04-16 23:14:05 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2014-04-16 23:14:05 +0000 |
commit | c7c557e57388dd17a12ad000dd27d19fce515a4f (patch) | |
tree | 4287628ab93fcb1da08cdd812e5b72100fb7c76b /usr.bin/dc | |
parent | 14fb9d03d8281a35f81979d5f8ba6385edf6b0eb (diff) | |
download | FreeBSD-src-c7c557e57388dd17a12ad000dd27d19fce515a4f.zip FreeBSD-src-c7c557e57388dd17a12ad000dd27d19fce515a4f.tar.gz |
Sync with OpenBSD.
MFC after: 2 weeks
Diffstat (limited to 'usr.bin/dc')
-rw-r--r-- | usr.bin/dc/bcode.c | 19 | ||||
-rw-r--r-- | usr.bin/dc/bcode.h | 26 | ||||
-rw-r--r-- | usr.bin/dc/dc.1 | 28 | ||||
-rw-r--r-- | usr.bin/dc/inout.c | 2 |
4 files changed, 40 insertions, 35 deletions
diff --git a/usr.bin/dc/bcode.c b/usr.bin/dc/bcode.c index f17a0da..52ce85c 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 7dc5d2d..7911bc2 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 94dba76..507bbe6 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 e35f0ad..740fb35 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> |