blob: ef7b268e96fea9bfbee205f4dd020ee13a717467 [file] [log] [blame]
/*
* *****************************************************************************
*
* Copyright 2018 Gavin D. Howard
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* *****************************************************************************
*
* The dc help text.
*
*/
usage: %s [options] [file...]
dc is a reverse-polish notation command-line calculator which supports unlimited
precision arithmetic. See the FreeBSD man page
(https://www.unix.com/man-page/FreeBSD/1/dc/) and GNU dc manual
(https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html) for details.
This dc has a few differences from the two above:
1) When printing a byte stream (command "P"), this bc follows what the FreeBSD
dc does.
2) This dc implements the GNU extensions for divmod ("~") and modular
exponentiation ("|").
3) This dc implements all FreeBSD extensions, except for "J" and "M".
4) Like the FreeBSD dc, this dc supports extended registers. However, they are
implemented differently. When it encounters whitespace where a register
should be, it skips the whitespace. If the character following is not
a lowercase letter, an error is issued. Otherwise, the register name is
parsed by the following regex:
[a-z][a-z0-9_]*
This generally means that register names will be surrounded by whitespace.
Examples:
l idx s temp L index S temp2 < do_thing
Also note that, like the FreeBSD dc, extended registers are not allowed
unless the "-x" option is given.
Options:
-e expr --expression=expr run "expr" and quit. If multiple expressions or
files (see below) are given, they are all run.
-f file --file=file run the bc code in "file" and exit. See above.
-h --help print this usage message and exit.
-V --version print version and copyright and exit.
-x --extended-register enable extended register mode.