Commit Graph

41 Commits

Author SHA1 Message Date
Alan Somers
0d119bab38 dc(1): fix modulo operations with fractional inputs
Our dc(1) has never correctly calculated remainders with fractional inputs.
Both bmod and bdivmod seem to have copy/pasted code from bdiv, which results
in the remainder having the wrong output scale.

PR:		162495
Reported by:	anonymous
Reviewed by:	pfg
Differential Revision:	https://reviews.freebsd.org/D13390
2017-12-07 02:08:55 +00:00
Alan Somers
95639a80ef dc(1): fix input of non-decimal fractional numbers
Inputting fractional non-decimal numbers has never worked correctly in our
OpenBSD-derived dc(1). It truncates the input to a number of decimal places
equal to the number of hexadecimal (or whatever base) places given on the
input. That's unacceptable, because many numbers require more precision to
represent in base 10 than in their original bases.

Fix this bug by using as many decimal places as needed to represent the
input, up to the maximum of the global scale factor.

This has one mildly surprising side effect: the scale of a number entered in
non-decimal mode will no longer necessarily equal the number of hexadecimal
(or whatever base) places given on the input. I think that's an acceptable
behavior change, given that inputting fractional non-decimal numbers never
worked in the first place, and the man page doesn't specify whether trailing
zeros on the input should affect a number's scale.

PR:		206230
Reported by:	nibbana@gmx.us
Reviewed by:	pfg
Differential Revision:	https://reviews.freebsd.org/D13336
2017-12-05 04:22:35 +00:00
Alan Somers
9ccdc62331 Reap dead code
usr.bin/dc/inout.c
	Reap some dead code that was killed back in 2003 in OpenBSD, in
	version 1.8 of this file.

MFC after:	3 weeks
2017-12-02 06:05:03 +00:00
Bryan Drewery
ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Pedro F. Giffuni
63433bc937 bc/dc/patch: make some use of reallocarray(3).
reallocarray(3) is a non portable extension from OpenBSD. Given that it is
already in FreeBSD, make easier future merges by adopting in some cases
where the code has some shared heritage with OpenBSD.

Obtained from:	OpenBSD
2017-03-05 16:10:35 +00:00
Pedro F. Giffuni
29dfec5294 dc(1): Introduce e command, equivalent to p, but writes to stderr
Obtained from:	OpenBSD
MFC after:	2 weeks
2017-02-28 20:50:49 +00:00
Pedro F. Giffuni
6ef0daee41 dc(1): Merge minor changes from OpenBSD.
Prefer setvbuf() to setlinebuf() for portability.
Some style(9) and redundant tests for NULL.

These are only meant to ease up merging newer changes but we are skipping
changes done in order to accomodate OpenBSD's pledge support.

Obtained from:	OpenBSD
MFC after:	2 weeks
2017-02-26 22:17:06 +00:00
Pedro F. Giffuni
7ba980521d dc(1): Catch up with OpenBSD tag.
OpenBSD rev 1.12 corresponds to our SVN r275162. Update the tag to make
easier future updates. No functional change.

MFC after:	3 days
2017-02-26 21:24:35 +00:00
Bryan Drewery
490a8aa9a1 DIRDEPS_BUILD: Update dependencies.
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2016-11-13 00:11:30 +00:00
Conrad Meyer
cd1693d3f9 Capsicumize some trivial stdio programs
Trivially capsicumize some simple programs that just interact with
stdio.  This list of programs uses 'pledge("stdio")' in OpenBSD.

No objection from:	allanjude, emaste, oshogbo
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D8307
2016-11-08 05:31:01 +00:00
Simon J. Gerraty
ccfb965433 Add META_MODE support.
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision:       D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Simon J. Gerraty
44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Simon J. Gerraty
98e0ffaefb Merge sync of head 2015-05-27 01:19:58 +00:00
Kevin Lo
8bc29bb269 Init array field in the proper place.
Obtained from:	OpenBSD
2014-11-27 01:37:01 +00:00
Baptiste Daroussin
3e11bd9e2a Convert to usr.bin/ to LIBADD
Reduce overlinking
2014-11-25 14:29:10 +00:00
Simon J. Gerraty
fae50821ae Updated dependencies 2014-05-16 14:09:51 +00:00
Simon J. Gerraty
3b8f084595 Merge head 2014-04-28 07:50:45 +00:00
Xin LI
be848c7a13 Sync with OpenBSD.
MFC after:	2 weeks
2014-04-16 23:14:05 +00:00
Simon J. Gerraty
69e6d7b75e sync from head 2013-04-12 20:48:55 +00:00
Simon J. Gerraty
7cf3a1c6b2 Updated dependencies 2013-03-11 17:21:52 +00:00
Glen Barber
eff269ee18 Properly handle '-h' argument.
PR:		176332
Reviewed by:	scottl
MFC after:	3 days
2013-02-28 01:22:14 +00:00
Simon J. Gerraty
f5f7c05209 Updated dependencies 2013-02-16 01:23:54 +00:00
David E. O'Brien
d9a447559b Sync with HEAD. 2013-02-08 16:10:16 +00:00
Kevin Lo
c3761c3848 - Use BN_set_negative() and BN_is_negative() instead of subtracting or
comparing to zero.
- Fix fractional number exponentiation, especially for negative exponents.

Obtained from:	OpenBSD
2012-12-30 15:20:27 +00:00
Marcel Moolenaar
7750ad47a9 Sync FreeBSD's bmake branch with Juniper's internal bmake branch.
Requested by: Simon Gerraty <sjg@juniper.net>
2012-08-22 19:25:57 +00:00
Joel Dahl
35471bf8ef Minor mdoc nits. 2012-05-13 14:16:04 +00:00
Kevin Lo
741e1faf5c - Fix an erroneous invocation of the editline.
- Fix wrong scaling in the bc.library.
- Let length(0.000) conform to what gnu bc does.

PR:	bin/159227
Submitted by:	AIDA Shinra <shinra at j10n dot org>
2012-03-15 01:43:44 +00:00
Ed Schouten
0c66031ab1 Remove unneeded CFLAGS.
Such optimisations should not be performed in this Makefile. Also, uqs@
suggested they have no effect, because the checksum of the resulting
binary is unchanged.

Discussed with:	gabor, uqs
2011-11-07 09:42:22 +00:00
Ed Schouten
267265e0dd Add missing static keywords to dc(1) 2011-11-06 08:14:57 +00:00
Ulrich Spörlein
cded07a878 Move most of the remaining USD/PSD/SMM papers into share/doc 2010-12-04 10:11:20 +00:00
Gabor Kovesdan
07f9cfc4ff - Axe out signal handling code, the shell will take care of this
Suggested by:	jilles
Approved by:	delphij (mentor)
2010-06-10 10:28:38 +00:00
Gabor Kovesdan
5349f70253 - Fix style(9)
Submitted by:	ed
Approved by:	delphij (mentor)
2010-06-10 10:17:00 +00:00
Gabor Kovesdan
85bf7ec797 - Fix signal handling in bc/dc. Now Ctrl-C terminates the execution.
Requested by:	gk (via private mail)
Approved by:	delphij (mentor)
2010-06-06 11:36:08 +00:00
Gabor Kovesdan
31dadaf609 - Fig segmentation fault
Submitted by:	Hizel Ildar <hizel@vyborg.ru> (via current@)
2010-06-06 11:32:38 +00:00
Gabor Kovesdan
7121df6349 - style(9)
Approved by:	delphij (mentor)
2010-02-03 21:06:13 +00:00
Gabor Kovesdan
4ef0890415 - Remove dead variable assignments
- Fix -x

Submitted by:	uqs
Approved by:	delphij (mentor)
2010-02-03 19:13:41 +00:00
Gabor Kovesdan
12360c49dd - style.Makefile(5)
Submitted by:	uqs
Approved by:	delphij (mentor)
2010-02-03 19:12:27 +00:00
Xin LI
ad4fe553c5 - Collapase short and long options together;
- Use consistent marking up with bc(1)'s reference section.

Reviewed by:	gabor
2010-01-22 23:50:46 +00:00
Xin LI
7ffc8ae56e Move USD documents from /usr/share/doc/papers to to /usr/share/doc/usd.
Reviewed by:	gabor
2010-01-22 23:19:48 +00:00
Xin LI
097d042584 Makefile cleanups:
o Enable building of USD
 o Remove commented out targets
 o Remove WARNS?=6 lines since it's the default

Reviewed by:	gabor
2010-01-21 17:46:14 +00:00
Gabor Kovesdan
fdf1f88bce Replace GNU bc/dc with BSDL versions ported from OpenBSD. They have a good
compatibility level with the GNU counterparts and have shown to be mature
enough. For now, the GNU versions aren't removed from the tree, just detached
from the build.

Sponsored by:		Google Summer of Code 2008
Portbuild run by:	erwin
Approved by:		delphij
2010-01-20 21:30:52 +00:00