Update to version 3.2.0

This commit is contained in:
se 2020-11-26 17:39:51 +00:00
commit 153fa7cbf6
117 changed files with 26135 additions and 23023 deletions

View File

@ -9,6 +9,7 @@ bin/*bc
bin/*bc.exe
bin/*dc
bin/*dc.exe
bin/bcl
bc.old
*.o
*.a

View File

@ -29,33 +29,13 @@
#
.POSIX:
VERSION = 3.1.6
VERSION = 3.2.0
SRC = %%SRC%%
OBJ = %%OBJ%%
GCDA = %%GCDA%%
GCNO = %%GCNO%%
BC_SRC = %%BC_SRC%%
BC_OBJ = %%BC_OBJ%%
BC_GCDA = %%BC_GCDA%%
BC_GCNO = %%BC_GCNO%%
DC_SRC = %%DC_SRC%%
DC_OBJ = %%DC_OBJ%%
DC_GCDA = %%DC_GCDA%%
DC_GCNO = %%DC_GCNO%%
HISTORY_SRC = %%HISTORY_SRC%%
HISTORY_OBJ = %%HISTORY_OBJ%%
HISTORY_GCDA = %%HISTORY_GCDA%%
HISTORY_GCNO = %%HISTORY_GCNO%%
RAND_SRC = %%RAND_SRC%%
RAND_OBJ = %%RAND_OBJ%%
RAND_GCDA = %%RAND_GCDA%%
RAND_GCNO = %%RAND_GCNO%%
BC_ENABLED_NAME = BC_ENABLED
BC_ENABLED = %%BC_ENABLED%%
DC_ENABLED_NAME = DC_ENABLED
@ -102,6 +82,13 @@ DC = dc
BC_EXEC = $(BIN)/$(EXEC_PREFIX)$(BC)
DC_EXEC = $(BIN)/$(EXEC_PREFIX)$(DC)
LIB = libbcl
LIB_NAME = $(LIB).a
LIBBC = $(BIN)/$(LIB_NAME)
BCL = bcl
BCL_TEST = $(BIN)/$(BCL)
BCL_TEST_C = tests/$(BCL).c
MANUALS = manuals
BC_MANPAGE_NAME = $(EXEC_PREFIX)$(BC)$(EXEC_SUFFIX).1
BC_MANPAGE = $(MANUALS)/$(BC).1
@ -109,16 +96,28 @@ BC_MD = $(BC_MANPAGE).md
DC_MANPAGE_NAME = $(EXEC_PREFIX)$(DC)$(EXEC_SUFFIX).1
DC_MANPAGE = $(MANUALS)/$(DC).1
DC_MD = $(DC_MANPAGE).md
BCL_MANPAGE_NAME = bcl.3
BCL_MANPAGE = $(MANUALS)/$(BCL_MANPAGE_NAME)
BCL_MD = $(BCL_MANPAGE).md
MANPAGE_INSTALL_ARGS = -Dm644
BINARY_INSTALL_ARGS = -Dm755
BCL_HEADER_NAME = bcl.h
BCL_HEADER = include/$(BCL_HEADER_NAME)
%%DESTDIR%%
BINDIR = %%BINDIR%%
INCLUDEDIR = %%INCLUDEDIR%%
LIBDIR = %%LIBDIR%%
MAN1DIR = %%MAN1DIR%%
MAN3DIR = %%MAN3DIR%%
MAIN_EXEC = $(EXEC_PREFIX)$(%%MAIN_EXEC%%)$(EXEC_SUFFIX)
EXEC = $(%%EXEC%%)
NLSPATH = %%NLSPATH%%
BC_ENABLE_LIBRARY = %%LIBRARY%%
BC_ENABLE_HISTORY = %%HISTORY%%
BC_ENABLE_EXTRA_MATH_NAME = BC_ENABLE_EXTRA_MATH
BC_ENABLE_EXTRA_MATH = %%EXTRA_MATH%%
@ -129,7 +128,7 @@ BC_LONG_BIT = %%LONG_BIT%%
RM = rm
MKDIR = mkdir
INSTALL = ./install.sh
INSTALL = ./exec-install.sh
SAFE_INSTALL = ./safe-install.sh
LINK = ./link.sh
MANPAGE = ./manpage.sh
@ -148,7 +147,7 @@ CPPFLAGS4 = $(CPPFLAGS3) -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700
CPPFLAGS5 = $(CPPFLAGS4) -DBC_NUM_KARATSUBA_LEN=$(BC_NUM_KARATSUBA_LEN)
CPPFLAGS6 = $(CPPFLAGS5) -DBC_ENABLE_NLS=$(BC_ENABLE_NLS) -DBC_ENABLE_PROMPT=$(BC_ENABLE_PROMPT)
CPPFLAGS7 = $(CPPFLAGS6) -D$(BC_ENABLE_EXTRA_MATH_NAME)=$(BC_ENABLE_EXTRA_MATH)
CPPFLAGS = $(CPPFLAGS7) -DBC_ENABLE_HISTORY=$(BC_ENABLE_HISTORY)
CPPFLAGS = $(CPPFLAGS7) -DBC_ENABLE_HISTORY=$(BC_ENABLE_HISTORY) -DBC_ENABLE_LIBRARY=$(BC_ENABLE_LIBRARY)
CFLAGS = $(CPPFLAGS) %%CPPFLAGS%% %%CFLAGS%%
LDFLAGS = %%LDFLAGS%%
@ -157,21 +156,24 @@ HOSTCFLAGS = %%HOSTCFLAGS%%
CC = %%CC%%
HOSTCC = %%HOSTCC%%
BC_LIB_C_ARGS = bc_lib bc.h bc_lib_name $(BC_ENABLED_NAME) 1
BC_LIB2_C_ARGS = bc_lib2 bc.h bc_lib2_name "$(BC_ENABLED_NAME) && $(BC_ENABLE_EXTRA_MATH_NAME)" 1
BC_LIB_C_ARGS = bc_lib bc_lib_name $(BC_ENABLED_NAME) 1
BC_LIB2_C_ARGS = bc_lib2 bc_lib2_name "$(BC_ENABLED_NAME) && $(BC_ENABLE_EXTRA_MATH_NAME)" 1
OBJS1 = $(OBJ) $(DC_OBJ) $(BC_OBJ) $(HISTORY_OBJ) $(RAND_OBJ) $(BC_HELP_O) $(DC_HELP_O)
OBJS = $(OBJS1) $(BC_LIB_O) $(BC_LIB2_O) $(BC_LIB3_O)
OBJ_TARGETS1 = $(DC_HELP_O) $(BC_HELP_O) $(BC_LIB_O) $(BC_LIB2_O) $(BC_LIB3_O)
OBJ_TARGETS = $(OBJ_TARGETS1) $(BC_OBJ) $(DC_OBJ) $(HISTORY_OBJ) $(RAND_OBJ) $(OBJ)
OBJS = $(BC_HELP_O) $(DC_HELP_O) $(BC_LIB_O) $(BC_LIB2_O) $(OBJ)
OBJ_TARGETS = $(DC_HELP_O) $(BC_HELP_O) $(BC_LIB_O) $(BC_LIB2_O) $(OBJ)
.c.o:
$(CC) $(CFLAGS) -o $@ -c $<
all: make_bin $(OBJ_TARGETS)
all: %%ALL_PREREQ%%
execs: make_bin $(OBJ_TARGETS)
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $(EXEC)
%%LINK%%
library: make_bin $(OBJ) $(BC_LIB_O) $(BC_LIB2_O)
ar -r -cu $(LIBBC) $(BC_LIB_O) $(BC_LIB2_O) $(OBJ)
$(GEN_EXEC):
%%GEN_EXEC_TARGET%%
@ -182,10 +184,10 @@ $(BC_LIB2_C): $(GEN_EXEC) $(BC_LIB2)
$(GEN_EMU) $(GEN_EXEC) $(BC_LIB2) $(BC_LIB2_C) $(BC_LIB2_C_ARGS)
$(BC_HELP_C): $(GEN_EXEC) $(BC_HELP)
$(GEN_EMU) $(GEN_EXEC) $(BC_HELP) $(BC_HELP_C) bc_help bc.h "" $(BC_ENABLED_NAME)
$(GEN_EMU) $(GEN_EXEC) $(BC_HELP) $(BC_HELP_C) bc_help "" $(BC_ENABLED_NAME)
$(DC_HELP_C): $(GEN_EXEC) $(DC_HELP)
$(GEN_EMU) $(GEN_EXEC) $(DC_HELP) $(DC_HELP_C) dc_help dc.h "" $(DC_ENABLED_NAME)
$(GEN_EMU) $(GEN_EXEC) $(DC_HELP) $(DC_HELP_C) dc_help "" $(DC_ENABLED_NAME)
make_bin:
$(MKDIR) -p $(BIN)
@ -222,7 +224,7 @@ help:
check: test
test: test_bc timeconst test_dc
test: %%TESTS%%
test_bc:
%%BC_TEST%%
@ -241,6 +243,12 @@ time_test_dc:
timeconst:
%%TIMECONST%%
library_test: library
$(CC) $(CFLAGS) $(BCL_TEST_C) $(LIBBC) -o $(BCL_TEST)
test_library: library_test
$(BCL_TEST)
valgrind: valgrind_bc valgrind_dc
valgrind_bc:
@ -272,6 +280,7 @@ extra_math:
manpages:
$(MANPAGE) bc
$(MANPAGE) dc
$(MANPAGE) bcl
clean_gen:
@$(RM) -f $(GEN_EXEC)
@ -279,10 +288,6 @@ clean_gen:
clean:%%CLEAN_PREREQS%%
@printf 'Cleaning files...\n'
@$(RM) -f $(OBJ)
@$(RM) -f $(BC_OBJ)
@$(RM) -f $(DC_OBJ)
@$(RM) -f $(HISTORY_OBJ)
@$(RM) -f $(RAND_OBJ)
@$(RM) -f $(BC_EXEC)
@$(RM) -f $(DC_EXEC)
@$(RM) -fr $(BIN)
@ -343,9 +348,20 @@ install_bc_manpage:
install_dc_manpage:
$(SAFE_INSTALL) $(MANPAGE_INSTALL_ARGS) $(DC_MANPAGE) $(DESTDIR)$(MAN1DIR)/$(DC_MANPAGE_NAME)
install:%%INSTALL_LOCALES_PREREQS%%%%INSTALL_PREREQS%%
install_bcl_manpage:
$(SAFE_INSTALL) $(MANPAGE_INSTALL_ARGS) $(BCL_MANPAGE) $(DESTDIR)$(MAN3DIR)/$(BCL_MANPAGE_NAME)
install_bcl_header:
$(SAFE_INSTALL) $(MANPAGE_INSTALL_ARGS) $(BCL_HEADER) $(DESTDIR)$(INCLUDEDIR)/$(BCL_HEADER_NAME)
install_execs:
$(INSTALL) $(DESTDIR)$(BINDIR) "$(EXEC_SUFFIX)"
install_library:
$(SAFE_INSTALL) $(BINARY_INSTALL_ARGS) $(LIBBC) $(DESTDIR)$(LIBDIR)/$(LIB_NAME)
install:%%INSTALL_LOCALES_PREREQS%%%%INSTALL_MAN_PREREQS%%%%INSTALL_PREREQS%%
uninstall_locales:
$(LOCALE_UNINSTALL) $(NLSPATH) $(MAIN_EXEC) $(DESTDIR)
@ -361,4 +377,13 @@ uninstall_dc_manpage:
uninstall_dc:
$(RM) -f $(DESTDIR)$(BINDIR)/$(EXEC_PREFIX)$(DC)$(EXEC_SUFFIX)
uninstall_library:
$(RM) -f $(DESTDIR)$(LIBDIR)/$(LIB_NAME)
uninstall_bcl_header:
$(RM) -f $(DESTDIR)$(INCLUDEDIR)/$(BCL_HEADER_NAME)
uninstall_bcl_manpage:
$(RM) -f $(DESTDIR)$(MAN3DIR)/$(BCL_MANPAGE_NAME)
uninstall:%%UNINSTALL_LOCALES_PREREQS%%%%UNINSTALL_MAN_PREREQS%%%%UNINSTALL_PREREQS%%

View File

@ -1,5 +1,23 @@
# News
## 3.2.0
This is a production release that has one bug fix and a major addition.
The bug fix was a missing `auto` variable in the bessel `j()` function in the
math library.
The major addition is a way to build a version of `bc`'s math code as a library.
This is done with the `-a` option to `configure.sh`. The API for the library can
be read in `./manuals/bcl.3.md` or `man bcl` once the library is installed with
`make install`.
This library was requested by developers before I even finished version 1.0, but
I could not figure out how to do it until now.
If the library has API breaking changes, the major version of `bc` will be
incremented.
## 3.1.6
This is a production release that fixes a new warning from Clang 12 for FreeBSD

View File

@ -107,6 +107,23 @@ other locations, use the `PREFIX` environment variable when running
`configure.sh` or pass the `--prefix=<prefix>` option to `configure.sh`. See the
[build manual][5], or run `./configure.sh --help`, for more details.
### Library
This `bc` does provide a way to build a math library with C bindings. This is
done by the `-a` or `--library` options to `configure.sh`:
```
./configure.sh -a
```
When building the library, the executables are not built. For more information,
see the [build manual][5].
The library API can be found in [`manuals/bcl.3.md`][26] or `man bcl` once the
library is installed.
The library is built as `bin/libbcl.a`.
### Package and Distro Maintainers
#### Recommended Compiler
@ -335,3 +352,4 @@ Folders:
[23]: https://svnweb.freebsd.org/base/head/contrib/bc/
[24]: https://bugs.freebsd.org/
[25]: https://reviews.freebsd.org/
[26]: ./manuals/bcl.3.md

View File

@ -45,22 +45,27 @@ usage() {
_usage_val=0
fi
printf 'usage: %s -h\n' "$script"
printf ' %s --help\n' "$script"
printf ' %s [-bD|-dB|-c] [-EfgGHlMNPT] [-O OPT_LEVEL] [-k KARATSUBA_LEN]\n' "$script"
printf ' %s \\\n' "$script"
printf ' [--bc-only --disable-dc|--dc-only --disable-bc|--coverage] \\\n'
printf ' [--debug --disable-extra-math --disable-generated-tests] \\\n'
printf ' [--disable-history --disable-man-pages --disable-nls] \\\n'
printf ' [--disable-prompt --disable-strip] [--install-all-locales] \\\n'
printf ' [--opt=OPT_LEVEL] [--karatsuba-len=KARATSUBA_LEN] \\\n'
printf ' [--prefix=PREFIX] [--bindir=BINDIR] [--datarootdir=DATAROOTDIR] \\\n'
printf ' [--datadir=DATADIR] [--mandir=MANDIR] [--man1dir=MAN1DIR] \\\n'
printf ' [--force] \\\n'
printf 'usage:\n'
printf ' %s -h\n' "$script"
printf ' %s --help\n' "$script"
printf ' %s [-a|-bD|-dB|-c] [-EfgGHlMNPT] [-O OPT_LEVEL] [-k KARATSUBA_LEN]\n' "$script"
printf ' %s \\\n' "$script"
printf ' [--library|--bc-only --disable-dc|--dc-only --disable-bc|--coverage]\\\n'
printf ' [--force --debug --disable-extra-math --disable-generated-tests] \\\n'
printf ' [--disable-history --disable-man-pages --disable-nls] \\\n'
printf ' [--disable-prompt --disable-strip] [--install-all-locales] \\\n'
printf ' [--opt=OPT_LEVEL] [--karatsuba-len=KARATSUBA_LEN] \\\n'
printf ' [--prefix=PREFIX] [--bindir=BINDIR] [--datarootdir=DATAROOTDIR] \\\n'
printf ' [--datadir=DATADIR] [--mandir=MANDIR] [--man1dir=MAN1DIR] \\\n'
printf '\n'
printf ' -a, --library\n'
printf ' Build the libbc instead of the programs. This is meant to be used with\n'
printf ' Other software like programming languages that want to make use of the\n'
printf ' parsing and math capabilities. This option will install headers using\n'
printf ' `make install`.\n'
printf ' -b, --bc-only\n'
printf ' Build bc only. It is an error if "-d", "--dc-only", "-B", or "--disable-bc"\n'
printf ' are specified too.\n'
printf ' Build bc only. It is an error if "-d", "--dc-only", "-B", or\n'
printf ' "--disable-bc" are specified too.\n'
printf ' -B, --disable-bc\n'
printf ' Disable bc. It is an error if "-b", "--bc-only", "-D", or "--disable-dc"\n'
printf ' are specified too.\n'
@ -69,10 +74,10 @@ usage() {
printf ' It is an error if either "-b" ("-D") or "-d" ("-B") is specified.\n'
printf ' Requires a compiler that use gcc-compatible coverage options\n'
printf ' -d, --dc-only\n'
printf ' Build dc only. It is an error if "-b", "--bc-only", "-D", or "--disable-dc"\n'
printf ' are specified too.\n'
printf ' Build dc only. It is an error if "-b", "--bc-only", "-D", or\n'
printf ' "--disable-dc" are specified too.\n'
printf ' -D, --disable-dc\n'
printf ' Disable dc. It is an error if "-d", "--dc-only" "-B", or "--disable-bc"\n'
printf ' Disable dc. It is an error if "-d", "--dc-only", "-B", or "--disable-bc"\n'
printf ' are specified too.\n'
printf ' -E, --disable-extra-math\n'
printf ' Disable extra math. This includes: "$" operator (truncate to integer),\n'
@ -122,8 +127,14 @@ usage() {
printf ' If PREFIX is "/usr", install path will be "/usr/bin".\n'
printf ' Default is "/usr/local".\n'
printf ' --bindir BINDIR\n'
printf ' The directory to install binaries. Overrides "$BINDIR" if it exists.\n'
printf ' The directory to install binaries in. Overrides "$BINDIR" if it exists.\n'
printf ' Default is "$PREFIX/bin".\n'
printf ' --includedir INCLUDEDIR\n'
printf ' The directory to install headers in. Overrides "$INCLUDEDIR" if it\n'
printf ' exists. Default is "$PREFIX/include".\n'
printf ' --libdir LIBDIR\n'
printf ' The directory to install libraries in. Overrides "$LIBDIR" if it exists.\n'
printf ' Default is "$PREFIX/lib".\n'
printf ' --datarootdir DATAROOTDIR\n'
printf ' The root location for data files. Overrides "$DATAROOTDIR" if it exists.\n'
printf ' Default is "$PREFIX/share".\n'
@ -136,6 +147,9 @@ usage() {
printf ' --man1dir MAN1DIR\n'
printf ' The location to install Section 1 manpages to. Overrides "$MAN1DIR" if\n'
printf ' it exists. Default is "$MANDIR/man1".\n'
printf ' --man3dir MAN3DIR\n'
printf ' The location to install Section 3 manpages to. Overrides "$MAN3DIR" if\n'
printf ' it exists. Default is "$MANDIR/man3".\n'
printf '\n'
printf 'In addition, the following environment variables are used:\n'
printf '\n'
@ -157,12 +171,18 @@ usage() {
printf ' LDFLAGS Linker flags. Default is "".\n'
printf ' PREFIX The prefix to install to. Default is "/usr/local".\n'
printf ' If PREFIX is "/usr", install path will be "/usr/bin".\n'
printf ' BINDIR The directory to install binaries. Default is "$PREFIX/bin".\n'
printf ' BINDIR The directory to install binaries in. Default is "$PREFIX/bin".\n'
printf ' INCLUDEDIR The directory to install header files in. Default is\n'
printf ' "$PREFIX/include".\n'
printf ' LIBDIR The directory to install libraries in. Default is\n'
printf ' "$PREFIX/lib".\n'
printf ' DATAROOTDIR The root location for data files. Default is "$PREFIX/share".\n'
printf ' DATADIR The location for data files. Default is "$DATAROOTDIR".\n'
printf ' MANDIR The location to install manpages to. Default is "$DATADIR/man".\n'
printf ' MAN1DIR The location to install Section 1 manpages to. Default is\n'
printf ' "$MANDIR/man1".\n'
printf ' MAN3DIR The location to install Section 3 manpages to. Default is\n'
printf ' "$MANDIR/man3".\n'
printf ' NLSPATH The location to install locale catalogs to. Must be an absolute\n'
printf ' path (or contain one). This is treated the same as the POSIX\n'
printf ' definition of $NLSPATH (see POSIX environment variables for\n'
@ -257,56 +277,55 @@ replace() {
substring_replace "$_replace_str" "%%$_replace_needle%%" "$_replace_replacement"
}
gen_file_lists() {
gen_file_list() {
if [ "$#" -lt 3 ]; then
if [ "$#" -lt 1 ]; then
err_exit "Invalid number of args to $0"
fi
_gen_file_lists_contents="$1"
_gen_file_list_contents="$1"
shift
_gen_file_lists_filedir="$1"
shift
p=$(pwd)
_gen_file_lists_typ="$1"
shift
cd "$scriptdir"
# If there is an extra argument, and it
# is zero, we keep the file lists empty.
if [ "$#" -gt 0 ]; then
_gen_file_lists_use="$1"
else
_gen_file_lists_use="1"
fi
if [ "$#" -ge 1 ]; then
_gen_file_lists_needle_src="${_gen_file_lists_typ}SRC"
_gen_file_lists_needle_obj="${_gen_file_lists_typ}OBJ"
_gen_file_lists_needle_gcda="${_gen_file_lists_typ}GCDA"
_gen_file_lists_needle_gcno="${_gen_file_lists_typ}GCNO"
if [ "$_gen_file_lists_use" -ne 0 ]; then
_gen_file_lists_replacement=$(cd "$_gen_file_lists_filedir" && find . ! -name . -prune -name "*.c" | cut -d/ -f2 | sed "s@^@$_gen_file_lists_filedir/@g" | tr '\n' ' ')
_gen_file_lists_contents=$(replace "$_gen_file_lists_contents" "$_gen_file_lists_needle_src" "$_gen_file_lists_replacement")
_gen_file_lists_replacement=$(replace_exts "$_gen_file_lists_replacement" "c" "o")
_gen_file_lists_contents=$(replace "$_gen_file_lists_contents" "$_gen_file_lists_needle_obj" "$_gen_file_lists_replacement")
_gen_file_lists_replacement=$(replace_exts "$_gen_file_lists_replacement" "o" "gcda")
_gen_file_lists_contents=$(replace "$_gen_file_lists_contents" "$_gen_file_lists_needle_gcda" "$_gen_file_lists_replacement")
_gen_file_lists_replacement=$(replace_exts "$_gen_file_lists_replacement" "gcda" "gcno")
_gen_file_lists_contents=$(replace "$_gen_file_lists_contents" "$_gen_file_lists_needle_gcno" "$_gen_file_lists_replacement")
while [ "$#" -ge 1 ]; do
a="$1"
shift
args="$args ! -wholename src/${a}"
done
else
_gen_file_lists_contents=$(replace "$_gen_file_lists_contents" "$_gen_file_lists_needle_src" "")
_gen_file_lists_contents=$(replace "$_gen_file_lists_contents" "$_gen_file_lists_needle_obj" "")
_gen_file_lists_contents=$(replace "$_gen_file_lists_contents" "$_gen_file_lists_needle_gcda" "")
_gen_file_lists_contents=$(replace "$_gen_file_lists_contents" "$_gen_file_lists_needle_gcno" "")
args="-print"
fi
printf '%s\n' "$_gen_file_lists_contents"
_gen_file_list_needle_src="SRC"
_gen_file_list_needle_obj="OBJ"
_gen_file_list_needle_gcda="GCDA"
_gen_file_list_needle_gcno="GCNO"
_gen_file_list_replacement=$(find src/ -depth -name "*.c" $args | tr '\n' ' ')
_gen_file_list_contents=$(replace "$_gen_file_list_contents" \
"$_gen_file_list_needle_src" "$_gen_file_list_replacement")
_gen_file_list_replacement=$(replace_exts "$_gen_file_list_replacement" "c" "o")
_gen_file_list_contents=$(replace "$_gen_file_list_contents" \
"$_gen_file_list_needle_obj" "$_gen_file_list_replacement")
_gen_file_list_replacement=$(replace_exts "$_gen_file_list_replacement" "o" "gcda")
_gen_file_list_contents=$(replace "$_gen_file_list_contents" \
"$_gen_file_list_needle_gcda" "$_gen_file_list_replacement")
_gen_file_list_replacement=$(replace_exts "$_gen_file_list_replacement" "gcda" "gcno")
_gen_file_list_contents=$(replace "$_gen_file_list_contents" \
"$_gen_file_list_needle_gcno" "$_gen_file_list_replacement")
cd "$p"
printf '%s\n' "$_gen_file_list_contents"
}
bc_only=0
@ -324,10 +343,12 @@ prompt=1
force=0
strip_bin=1
all_locales=0
library=0
while getopts "bBcdDEfgGhHk:lMNO:PST-" opt; do
while getopts "abBcdDEfgGhHk:lMNO:PST-" opt; do
case "$opt" in
a) library=1 ;;
b) bc_only=1 ;;
B) dc_only=1 ;;
c) coverage=1 ;;
@ -352,6 +373,7 @@ while getopts "bBcdDEfgGhHk:lMNO:PST-" opt; do
LONG_OPTARG="${arg#*=}"
case $arg in
help) usage ;;
library) library=1 ;;
bc-only) bc_only=1 ;;
dc-only) dc_only=1 ;;
coverage) coverage=1 ;;
@ -371,6 +393,20 @@ while getopts "bBcdDEfgGhHk:lMNO:PST-" opt; do
fi
BINDIR="$2"
shift ;;
includedir=?*) INCLUDEDIR="$LONG_OPTARG" ;;
includedir)
if [ "$#" -lt 2 ]; then
usage "No argument given for '--$arg' option"
fi
INCLUDEDIR="$2"
shift ;;
libdir=?*) LIBDIR="$LONG_OPTARG" ;;
libdir)
if [ "$#" -lt 2 ]; then
usage "No argument given for '--$arg' option"
fi
LIBDIR="$2"
shift ;;
datarootdir=?*) DATAROOTDIR="$LONG_OPTARG" ;;
datarootdir)
if [ "$#" -lt 2 ]; then
@ -399,6 +435,13 @@ while getopts "bBcdDEfgGhHk:lMNO:PST-" opt; do
fi
MAN1DIR="$2"
shift ;;
man3dir=?*) MAN3DIR="$LONG_OPTARG" ;;
man3dir)
if [ "$#" -lt 2 ]; then
usage "No argument given for '--$arg' option"
fi
MAN3DIR="$2"
shift ;;
localedir=?*) LOCALEDIR="$LONG_OPTARG" ;;
localedir)
if [ "$#" -lt 2 ]; then
@ -454,6 +497,12 @@ if [ "$bc_only" -eq 1 ] && [ "$dc_only" -eq 1 ]; then
usage "Can only specify one of -b(-D) or -d(-B)"
fi
if [ "$library" -ne 0 ]; then
if [ "$bc_only" -eq 1 ] || [ "$dc_only" -eq 1 ]; then
usage "Must not specify -b(-D) or -d(-B) when building the library"
fi
fi
case $karatsuba_len in
(*[!0-9]*|'') usage "KARATSUBA_LEN is not a number" ;;
(*) ;;
@ -529,6 +578,8 @@ link="@printf 'No link necessary\\\\n'"
main_exec="BC"
executable="BC_EXEC"
tests="test_bc timeconst test_dc"
bc_test="@tests/all.sh bc $extra_math 1 $generate_tests 0 \$(BC_EXEC)"
bc_time_test="@tests/all.sh bc $extra_math 1 $generate_tests 1 \$(BC_EXEC)"
@ -567,7 +618,8 @@ if [ "$bc_only" -eq 1 ]; then
dc_time_test="@printf 'No dc tests to run\\\\n'"
vg_dc_test="@printf 'No dc tests to run\\\\n'"
install_prereqs=" install_bc_manpage"
install_prereqs=" install_execs"
install_man_prereqs=" install_bc_manpage"
uninstall_prereqs=" uninstall_bc"
uninstall_man_prereqs=" uninstall_bc_manpage"
@ -590,7 +642,8 @@ elif [ "$dc_only" -eq 1 ]; then
timeconst="@printf 'timeconst cannot be run because bc is not built\\\\n'"
install_prereqs=" install_dc_manpage"
install_prereqs=" install_execs"
install_man_prereqs=" install_dc_manpage"
uninstall_prereqs=" uninstall_dc"
uninstall_man_prereqs=" uninstall_dc_manpage"
@ -606,9 +659,18 @@ else
karatsuba="@\$(KARATSUBA) 30 0 \$(BC_EXEC)"
karatsuba_test="@\$(KARATSUBA) 1 100 \$(BC_EXEC)"
install_prereqs=" install_bc_manpage install_dc_manpage"
uninstall_prereqs=" uninstall_bc uninstall_dc"
uninstall_man_prereqs=" uninstall_bc_manpage uninstall_dc_manpage"
if [ "$library" -eq 0 ]; then
install_prereqs=" install_execs"
install_man_prereqs=" install_bc_manpage install_dc_manpage"
uninstall_prereqs=" uninstall_bc uninstall_dc"
uninstall_man_prereqs=" uninstall_bc_manpage uninstall_dc_manpage"
else
install_prereqs=" install_library install_bcl_header"
install_man_prereqs=" install_bcl_manpage"
uninstall_prereqs=" uninstall_library uninstall_bcl_header"
uninstall_man_prereqs=" uninstall_bcl_manpage"
tests="test_library"
fi
fi
@ -664,6 +726,14 @@ if [ -z "${BINDIR+set}" ]; then
BINDIR="$PREFIX/bin"
fi
if [ -z "${INCLUDEDIR+set}" ]; then
INCLUDEDIR="$PREFIX/include"
fi
if [ -z "${LIBDIR+set}" ]; then
LIBDIR="$PREFIX/lib"
fi
if [ "$install_manpages" -ne 0 ] || [ "$nls" -ne 0 ]; then
if [ -z "${DATAROOTDIR+set}" ]; then
DATAROOTDIR="$PREFIX/share"
@ -684,11 +754,25 @@ if [ "$install_manpages" -ne 0 ]; then
MAN1DIR="$MANDIR/man1"
fi
if [ -z "${MAN3DIR+set}" ]; then
MAN3DIR="$MANDIR/man3"
fi
else
install_prereqs=""
install_man_prereqs=""
uninstall_man_prereqs=""
fi
if [ "$library" -ne 0 ]; then
extra_math=1
nls=0
hist=0
prompt=0
ALL_PREREQ="library"
else
ALL_PREREQ="execs"
fi
if [ "$nls" -ne 0 ]; then
set +e
@ -776,11 +860,11 @@ if [ "$hist" -eq 1 ]; then
printf 'Testing history...\n'
flags="-DBC_ENABLE_HISTORY=1 -DBC_ENABLED=$bc -DDC_ENABLED=$dc"
flags="$flags -DBC_ENABLE_NLS=$nls"
flags="$flags -DBC_ENABLE_NLS=$nls -DBC_ENABLE_LIBRARY=0"
flags="$flags -DBC_ENABLE_EXTRA_MATH=$extra_math -I./include/"
flags="$flags -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700"
"$CC" $CPPFLAGS $CFLAGS $flags -c "src/history/history.c" -o "$scriptdir/history.o" > /dev/null 2>&1
"$CC" $CPPFLAGS $CFLAGS $flags -c "src/history.c" -o "$scriptdir/history.o" > /dev/null 2>&1
err="$?"
@ -804,7 +888,11 @@ if [ "$hist" -eq 1 ]; then
fi
if [ "$extra_math" -eq 1 ] && [ "$bc" -ne 0 ]; then
if [ "$library" -eq 1 ]; then
bc_lib=""
fi
if [ "$extra_math" -eq 1 ] && [ "$bc" -ne 0 ] && [ "$library" -eq 0 ]; then
BC_LIB2_O="\$(GEN_DIR)/lib2.o"
else
BC_LIB2_O=""
@ -846,6 +934,33 @@ if [ "$manpage_args" = "" ]; then
manpage_args="A"
fi
unneeded=""
if [ "$hist" -eq 0 ]; then
unneeded="$unneeded history.c"
fi
if [ "$bc" -eq 0 ]; then
unneeded="$unneeded bc.c bc_lex.c bc_parse.c"
fi
if [ "$dc" -eq 0 ]; then
unneeded="$unneeded dc.c dc_lex.c dc_parse.c"
fi
if [ "$extra_math" -eq 0 ]; then
unneeded="$unneeded rand.c"
fi
if [ "$library" -ne 0 ]; then
unneeded="$unneeded args.c opt.c read.c file.c main.c"
unneeded="$unneeded lang.c lex.c parse.c program.c"
unneeded="$unneeded bc.c bc_lex.c bc_parse.c"
unneeded="$unneeded dc.c dc_lex.c dc_parse.c"
else
unneeded="$unneeded library.c"
fi
# Print out the values; this is for debugging.
if [ "$bc" -ne 0 ]; then
printf 'Building bc\n'
@ -858,6 +973,7 @@ else
printf 'Not building dc\n'
fi
printf '\n'
printf 'BC_ENABLE_LIBRARY=%s\n\n' "$library"
printf 'BC_ENABLE_HISTORY=%s\n' "$hist"
printf 'BC_ENABLE_EXTRA_MATH=%s\n' "$extra_math"
printf 'BC_ENABLE_NLS=%s\n' "$nls"
@ -873,10 +989,13 @@ printf 'CPPFLAGS=%s\n' "$CPPFLAGS"
printf 'LDFLAGS=%s\n' "$LDFLAGS"
printf 'PREFIX=%s\n' "$PREFIX"
printf 'BINDIR=%s\n' "$BINDIR"
printf 'INCLUDEDIR=%s\n' "$INCLUDEDIR"
printf 'LIBDIR=%s\n' "$LIBDIR"
printf 'DATAROOTDIR=%s\n' "$DATAROOTDIR"
printf 'DATADIR=%s\n' "$DATADIR"
printf 'MANDIR=%s\n' "$MANDIR"
printf 'MAN1DIR=%s\n' "$MAN1DIR"
printf 'MAN3DIR=%s\n' "$MAN3DIR"
printf 'NLSPATH=%s\n' "$NLSPATH"
printf 'EXECSUFFIX=%s\n' "$EXECSUFFIX"
printf 'EXECPREFIX=%s\n' "$EXECPREFIX"
@ -892,16 +1011,17 @@ replacement='*** WARNING: Autogenerated from Makefile.in. DO NOT MODIFY ***'
contents=$(replace "$contents" "$needle" "$replacement")
contents=$(gen_file_lists "$contents" "$scriptdir/src" "")
contents=$(gen_file_lists "$contents" "$scriptdir/src/bc" "BC_" "$bc")
contents=$(gen_file_lists "$contents" "$scriptdir/src/dc" "DC_" "$dc")
contents=$(gen_file_lists "$contents" "$scriptdir/src/history" "HISTORY_" "$hist")
contents=$(gen_file_lists "$contents" "$scriptdir/src/rand" "RAND_" "$extra_math")
if [ "$unneeded" = "" ]; then
contents=$(gen_file_list "$contents" "library.c")
else
contents=$(gen_file_list "$contents" $unneeded)
fi
contents=$(replace "$contents" "BC_ENABLED" "$bc")
contents=$(replace "$contents" "DC_ENABLED" "$dc")
contents=$(replace "$contents" "LINK" "$link")
contents=$(replace "$contents" "LIBRARY" "$library")
contents=$(replace "$contents" "HISTORY" "$hist")
contents=$(replace "$contents" "EXTRA_MATH" "$extra_math")
contents=$(replace "$contents" "NLS" "$nls")
@ -917,7 +1037,10 @@ contents=$(replace "$contents" "DESTDIR" "$destdir")
contents=$(replace "$contents" "EXECSUFFIX" "$EXECSUFFIX")
contents=$(replace "$contents" "EXECPREFIX" "$EXECPREFIX")
contents=$(replace "$contents" "BINDIR" "$BINDIR")
contents=$(replace "$contents" "INCLUDEDIR" "$INCLUDEDIR")
contents=$(replace "$contents" "LIBDIR" "$LIBDIR")
contents=$(replace "$contents" "MAN1DIR" "$MAN1DIR")
contents=$(replace "$contents" "MAN3DIR" "$MAN3DIR")
contents=$(replace "$contents" "CFLAGS" "$CFLAGS")
contents=$(replace "$contents" "HOSTCFLAGS" "$HOSTCFLAGS")
contents=$(replace "$contents" "CPPFLAGS" "$CPPFLAGS")
@ -927,15 +1050,19 @@ contents=$(replace "$contents" "HOSTCC" "$HOSTCC")
contents=$(replace "$contents" "COVERAGE_OUTPUT" "$COVERAGE_OUTPUT")
contents=$(replace "$contents" "COVERAGE_PREREQS" "$COVERAGE_PREREQS")
contents=$(replace "$contents" "INSTALL_PREREQS" "$install_prereqs")
contents=$(replace "$contents" "INSTALL_MAN_PREREQS" "$install_man_prereqs")
contents=$(replace "$contents" "INSTALL_LOCALES" "$install_locales")
contents=$(replace "$contents" "INSTALL_LOCALES_PREREQS" "$install_locales_prereqs")
contents=$(replace "$contents" "UNINSTALL_MAN_PREREQS" "$uninstall_man_prereqs")
contents=$(replace "$contents" "UNINSTALL_PREREQS" "$uninstall_prereqs")
contents=$(replace "$contents" "UNINSTALL_LOCALES_PREREQS" "$uninstall_locales_prereqs")
contents=$(replace "$contents" "ALL_PREREQ" "$ALL_PREREQ")
contents=$(replace "$contents" "EXECUTABLES" "$executables")
contents=$(replace "$contents" "MAIN_EXEC" "$main_exec")
contents=$(replace "$contents" "EXEC" "$executable")
contents=$(replace "$contents" "TESTS" "$tests")
contents=$(replace "$contents" "BC_TEST" "$bc_test")
contents=$(replace "$contents" "BC_TIME_TEST" "$bc_time_test")

View File

@ -173,7 +173,7 @@ define a(x){
return((m*a+r)/n)
}
define j(n,x){
auto b,s,o,a,i,v,f
auto b,s,o,a,i,r,v,f
b=ibase
ibase=A
s=scale

View File

@ -45,13 +45,14 @@
static const char* const bc_gen_header =
"// Copyright (c) 2018-2020 Gavin D. Howard and contributors.\n"
"// Licensed under the 2-clause BSD license.\n"
"// *** AUTOMATICALLY GENERATED FROM %s. DO NOT MODIFY. ***\n";
"// *** AUTOMATICALLY GENERATED FROM %s. DO NOT MODIFY. ***\n\n";
static const char* const bc_gen_include = "#include <%s>\n\n";
static const char* const bc_gen_label = "const char *%s = \"%s\";\n\n";
static const char* const bc_gen_label_extern = "extern const char *%s;\n\n";
static const char* const bc_gen_ifdef = "#if %s\n";
static const char* const bc_gen_endif = "#endif // %s\n";
static const char* const bc_gen_name = "const char %s[] = {\n";
static const char* const bc_gen_name_extern = "extern const char %s[];\n\n";
#define IO_ERR (1)
#define INVALID_INPUT_FILE (2)
@ -62,7 +63,7 @@ static const char* const bc_gen_name = "const char %s[] = {\n";
int main(int argc, char *argv[]) {
FILE *in, *out;
char *label, *define, *name, *include;
char *label, *define, *name;
int c, count, slashes, err = IO_ERR;
bool has_label, has_define, remove_tabs;
@ -72,15 +73,14 @@ int main(int argc, char *argv[]) {
}
name = argv[3];
include = argv[4];
has_label = (argc > 5 && strcmp("", argv[5]) != 0);
label = has_label ? argv[5] : "";
has_label = (argc > 4 && strcmp("", argv[4]) != 0);
label = has_label ? argv[4] : "";
has_define = (argc > 6 && strcmp("", argv[6]) != 0);
define = has_define ? argv[6] : "";
has_define = (argc > 5 && strcmp("", argv[5]) != 0);
define = has_define ? argv[5] : "";
remove_tabs = (argc > 7);
remove_tabs = (argc > 6);
in = fopen(argv[1], "r");
if (!in) return INVALID_INPUT_FILE;
@ -89,8 +89,9 @@ int main(int argc, char *argv[]) {
if (!out) goto out_err;
if (fprintf(out, bc_gen_header, argv[1]) < 0) goto err;
if (has_label && fprintf(out, bc_gen_label_extern, label) < 0) goto err;
if (fprintf(out, bc_gen_name_extern, name) < 0) goto err;
if (has_define && fprintf(out, bc_gen_ifdef, define) < 0) goto err;
if (fprintf(out, bc_gen_include, include) < 0) goto err;
if (has_label && fprintf(out, bc_gen_label, label, argv[1]) < 0) goto err;
if (fprintf(out, bc_gen_name, name) < 0) goto err;

View File

@ -32,7 +32,7 @@ export LC_CTYPE=C
progname=${0##*/}
if [ $# -lt 4 ]; then
if [ $# -lt 3 ]; then
echo "usage: $progname input output name header [label [define [remove_tabs]]]"
exit 1
fi
@ -40,16 +40,16 @@ fi
input="$1"
output="$2"
name="$3"
header="$4"
label="$5"
define="$6"
remove_tabs="$7"
label="$4"
define="$5"
remove_tabs="$6"
exec < "$input"
exec > "$output"
if [ -n "$label" ]; then
nameline="const char *${label} = \"${input}\";"
labelexternline="extern const char *${label};"
fi
if [ -n "$define" ]; then
@ -64,11 +64,14 @@ if [ -n "$remove_tabs" ]; then
fi
cat<<EOF
// Copyright (c) 2018-2020 Gavin D. Howard and contributors.
// Licensed under the 2-clause BSD license.
// *** AUTOMATICALLY GENERATED FROM ${input}. DO NOT MODIFY. ***
${condstart}
#include <${header}>
$labelexternline
extern const char $name[];
$nameline

184
contrib/bc/include/bcl.h Normal file
View File

@ -0,0 +1,184 @@
/*
* *****************************************************************************
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *****************************************************************************
*
* The public header for the bc library.
*
*/
#ifndef BC_BCL_H
#define BC_BCL_H
#include <stdbool.h>
#include <stdlib.h>
#include <limits.h>
#include <stdint.h>
#include <sys/types.h>
#define BC_SEED_ULONGS (4)
#define BC_SEED_SIZE (sizeof(long) * BC_SEED_ULONGS)
// For some reason, LONG_BIT is not defined in some versions of gcc.
// I define it here to the minimum accepted value in the POSIX standard.
#ifndef LONG_BIT
#define LONG_BIT (32)
#endif // LONG_BIT
#ifndef BC_LONG_BIT
#define BC_LONG_BIT LONG_BIT
#endif // BC_LONG_BIT
#if BC_LONG_BIT > LONG_BIT
#error BC_LONG_BIT cannot be greater than LONG_BIT
#endif // BC_LONG_BIT > LONG_BIT
#if BC_LONG_BIT >= 64
typedef uint64_t BclBigDig;
typedef uint64_t BclRandInt;
#elif BC_LONG_BIT >= 32
typedef uint32_t BclBigDig;
typedef uint32_t BclRandInt;
#else
#error BC_LONG_BIT must be at least 32
#endif // BC_LONG_BIT >= 64
typedef enum BclError {
BCL_ERROR_NONE,
BCL_ERROR_INVALID_NUM,
BCL_ERROR_INVALID_CONTEXT,
BCL_ERROR_SIGNAL,
BCL_ERROR_MATH_NEGATIVE,
BCL_ERROR_MATH_NON_INTEGER,
BCL_ERROR_MATH_OVERFLOW,
BCL_ERROR_MATH_DIVIDE_BY_ZERO,
BCL_ERROR_PARSE_INVALID_STR,
BCL_ERROR_FATAL_ALLOC_ERR,
BCL_ERROR_FATAL_UNKNOWN_ERR,
BCL_ERROR_NELEMS,
} BclError;
typedef struct BclNumber {
size_t i;
} BclNumber;
struct BclCtxt;
typedef struct BclCtxt* BclContext;
void bcl_handleSignal(void);
bool bcl_running(void);
BclError bcl_init(void);
void bcl_free(void);
bool bcl_abortOnFatalError(void);
void bcl_setAbortOnFatalError(bool abrt);
void bcl_gc(void);
BclError bcl_pushContext(BclContext ctxt);
void bcl_popContext(void);
BclContext bcl_context(void);
BclContext bcl_ctxt_create(void);
void bcl_ctxt_free(BclContext ctxt);
void bcl_ctxt_freeNums(BclContext ctxt);
size_t bcl_ctxt_scale(BclContext ctxt);
void bcl_ctxt_setScale(BclContext ctxt, size_t scale);
size_t bcl_ctxt_ibase(BclContext ctxt);
void bcl_ctxt_setIbase(BclContext ctxt, size_t ibase);
size_t bcl_ctxt_obase(BclContext ctxt);
void bcl_ctxt_setObase(BclContext ctxt, size_t obase);
BclError bcl_err(BclNumber n);
BclNumber bcl_num_create(void);
void bcl_num_free(BclNumber n);
bool bcl_num_neg(BclNumber n);
void bcl_num_setNeg(BclNumber n, bool neg);
size_t bcl_num_scale(BclNumber n);
BclError bcl_num_setScale(BclNumber n, size_t scale);
size_t bcl_num_len(BclNumber n);
BclError bcl_copy(BclNumber d, BclNumber s);
BclNumber bcl_dup(BclNumber s);
BclError bcl_bigdig(BclNumber n, BclBigDig *result);
BclNumber bcl_bigdig2num(BclBigDig val);
BclNumber bcl_add(BclNumber a, BclNumber b);
BclNumber bcl_sub(BclNumber a, BclNumber b);
BclNumber bcl_mul(BclNumber a, BclNumber b);
BclNumber bcl_div(BclNumber a, BclNumber b);
BclNumber bcl_mod(BclNumber a, BclNumber b);
BclNumber bcl_pow(BclNumber a, BclNumber b);
BclNumber bcl_lshift(BclNumber a, BclNumber b);
BclNumber bcl_rshift(BclNumber a, BclNumber b);
BclNumber bcl_sqrt(BclNumber a);
BclError bcl_divmod(BclNumber a, BclNumber b, BclNumber *c, BclNumber *d);
BclNumber bcl_modexp(BclNumber a, BclNumber b, BclNumber c);
ssize_t bcl_cmp(BclNumber a, BclNumber b);
void bcl_zero(BclNumber n);
void bcl_one(BclNumber n);
BclNumber bcl_parse(const char *restrict val);
char* bcl_string(BclNumber n);
BclNumber bcl_irand(BclNumber a);
BclNumber bcl_frand(size_t places);
BclNumber bcl_ifrand(BclNumber a, size_t places);
BclError bcl_rand_seedWithNum(BclNumber n);
BclError bcl_rand_seed(unsigned char seed[BC_SEED_SIZE]);
void bcl_rand_reseed(void);
BclNumber bcl_rand_seed2num(void);
BclRandInt bcl_rand_int(void);
BclRandInt bcl_rand_bounded(BclRandInt bound);
#endif // BC_BCL_H

View File

@ -62,6 +62,4 @@ void bc_file_printf(BcFile *restrict f, const char *fmt, ...);
void bc_file_vprintf(BcFile *restrict f, const char *fmt, va_list args);
void bc_file_puts(BcFile *restrict f, const char *str);
void bc_file_ultoa(unsigned long long val, char buf[BC_FILE_ULL_LENGTH]);
#endif // BC_FILE_H

View File

@ -43,8 +43,8 @@
#include <vector.h>
#include <lang.h>
#define bc_lex_err(l, e) (bc_vm_error((e), (l)->line))
#define bc_lex_verr(l, e, ...) (bc_vm_error((e), (l)->line, __VA_ARGS__))
#define bc_lex_err(l, e) (bc_vm_handleError((e), (l)->line))
#define bc_lex_verr(l, e, ...) (bc_vm_handleError((e), (l)->line, __VA_ARGS__))
#if BC_ENABLED

View File

@ -0,0 +1,165 @@
/*
* *****************************************************************************
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *****************************************************************************
*
* The private header for the bc library.
*
*/
#ifndef LIBBC_PRIVATE_H
#define LIBBC_PRIVATE_H
#include <bcl.h>
#include <num.h>
#define BC_FUNC_HEADER_LOCK(l) \
do { \
BC_SIG_LOCK; \
BC_SETJMP_LOCKED(l); \
vm.err = BCL_ERROR_NONE; \
vm.running = 1; \
} while (0)
#define BC_FUNC_FOOTER_UNLOCK(e) \
do { \
BC_SIG_ASSERT_LOCKED; \
e = vm.err; \
vm.running = 0; \
BC_UNSETJMP; \
BC_LONGJMP_STOP; \
vm.sig_lock = 0; \
} while (0)
#define BC_FUNC_HEADER(l) \
do { \
BC_SETJMP(l); \
vm.err = BCL_ERROR_NONE; \
vm.running = 1; \
} while (0)
#define BC_FUNC_HEADER_INIT(l) \
do { \
BC_SETJMP_LOCKED(l); \
vm.err = BCL_ERROR_NONE; \
vm.running = 1; \
} while (0)
#define BC_FUNC_FOOTER_NO_ERR \
do { \
vm.running = 0; \
BC_UNSETJMP; \
BC_LONGJMP_STOP; \
vm.sig_lock = 0; \
} while (0)
#define BC_FUNC_FOOTER(e) \
do { \
e = vm.err; \
BC_FUNC_FOOTER_NO_ERR; \
} while (0)
#define BC_FUNC_RESETJMP(l) \
do { \
BC_SIG_ASSERT_LOCKED; \
BC_UNSETJMP; \
BC_SETJMP_LOCKED(l); \
} while (0)
#define BC_MAYBE_SETUP(c, e, n, idx) \
do { \
if (BC_ERR((e) != BCL_ERROR_NONE)) { \
if ((n).num != NULL) bc_num_free(&(n)); \
idx.i = 0 - (size_t) (e); \
} \
else idx = bcl_num_insert(c, &(n)); \
} while (0)
#define BC_CHECK_CTXT(c) \
do { \
c = bcl_context(); \
if (BC_ERR(c == NULL)) { \
BclNumber n_num; \
n_num.i = 0 - (size_t) BCL_ERROR_INVALID_CONTEXT; \
return n_num; \
} \
} while (0)
#define BC_CHECK_CTXT_ERR(c) \
do { \
c = bcl_context(); \
if (BC_ERR(c == NULL)) { \
return BCL_ERROR_INVALID_CONTEXT; \
} \
} while (0)
#define BC_CHECK_CTXT_ASSERT(c) \
do { \
c = bcl_context(); \
assert(c != NULL); \
} while (0)
#define BC_CHECK_NUM(c, n) \
do { \
if (BC_ERR((n).i >= (c)->nums.len)) { \
if ((n).i > 0 - (size_t) BCL_ERROR_NELEMS) return (n); \
else { \
BclNumber n_num; \
n_num.i = 0 - (size_t) BCL_ERROR_INVALID_NUM; \
return n_num; \
} \
} \
} while (0)
#define BC_CHECK_NUM_ERR(c, n) \
do { \
if (BC_ERR((n).i >= (c)->nums.len)) { \
if ((n).i > 0 - (size_t) BCL_ERROR_NELEMS) \
return (BclError) (0 - (n).i); \
else return BCL_ERROR_INVALID_NUM; \
} \
} while (0)
#define BC_NUM(c, n) ((BcNum*) bc_vec_item(&(c)->nums, (n).i))
typedef size_t (*BcReqOp)(const BcNum*, const BcNum*, size_t);
typedef struct BclCtxt {
size_t scale;
size_t ibase;
size_t obase;
BcVec nums;
BcVec free_nums;
} BclCtxt;
#endif // LIBBC_PRIVATE_H

View File

@ -45,6 +45,7 @@
#include <status.h>
#include <vector.h>
#include <bcl.h>
#ifndef BC_ENABLE_EXTRA_MATH
#define BC_ENABLE_EXTRA_MATH (1)
@ -54,25 +55,10 @@
typedef unsigned long ulong;
// For some reason, LONG_BIT is not defined in some versions of gcc.
// I define it here to the minimum accepted value in the POSIX standard.
#ifndef LONG_BIT
#define LONG_BIT (32)
#endif // LONG_BIT
#ifndef BC_LONG_BIT
#define BC_LONG_BIT LONG_BIT
#endif // BC_LONG_BIT
#if BC_LONG_BIT > LONG_BIT
#error BC_LONG_BIT cannot be greater than LONG_BIT
#endif // BC_LONG_BIT > LONG_BIT
typedef BclBigDig BcBigDig;
#if BC_LONG_BIT >= 64
typedef int_least32_t BcDig;
typedef uint64_t BcBigDig;
#define BC_NUM_BIGDIG_MAX ((BcBigDig) UINT64_MAX)
#define BC_BASE_DIGS (9)
@ -80,10 +66,9 @@ typedef uint64_t BcBigDig;
#define BC_NUM_BIGDIG_C UINT64_C
#elif BC_LONG_BIT >= 32
typedef int_least32_t BcDig;
typedef int_least16_t BcDig;
typedef uint32_t BcBigDig;
#elif BC_LONG_BIT >= 32
#define BC_NUM_BIGDIG_MAX ((BcBigDig) UINT32_MAX)
@ -92,6 +77,8 @@ typedef uint32_t BcBigDig;
#define BC_NUM_BIGDIG_C UINT32_C
typedef int_least16_t BcDig;
#else
#error BC_LONG_BIT must be at least 32
@ -106,7 +93,6 @@ typedef struct BcNum {
size_t scale;
size_t len;
size_t cap;
bool neg;
} BcNum;
#if BC_ENABLE_EXTRA_MATH
@ -150,6 +136,30 @@ struct BcRNG;
#define BC_NUM_ROUND_POW(s) (bc_vm_growSize((s), BC_BASE_DIGS - 1))
#define BC_NUM_RDX(s) (BC_NUM_ROUND_POW(s) / BC_BASE_DIGS)
#define BC_NUM_RDX_VAL(n) ((n)->rdx >> 1)
#define BC_NUM_RDX_VAL_NP(n) ((n).rdx >> 1)
#define BC_NUM_RDX_SET(n, v) \
((n)->rdx = (((v) << 1) | ((n)->rdx & (BcBigDig) 1)))
#define BC_NUM_RDX_SET_NP(n, v) \
((n).rdx = (((v) << 1) | ((n).rdx & (BcBigDig) 1)))
#define BC_NUM_RDX_SET_NEG(n, v, neg) \
((n)->rdx = (((v) << 1) | (neg)))
#define BC_NUM_RDX_VALID(n) \
(BC_NUM_ZERO(n) || BC_NUM_RDX_VAL(n) * BC_BASE_DIGS >= (n)->scale)
#define BC_NUM_RDX_VALID_NP(n) \
((!(n).len) || BC_NUM_RDX_VAL_NP(n) * BC_BASE_DIGS >= (n).scale)
#define BC_NUM_NEG(n) ((n)->rdx & ((BcBigDig) 1))
#define BC_NUM_NEG_NP(n) ((n).rdx & ((BcBigDig) 1))
#define BC_NUM_NEG_CLR(n) ((n)->rdx &= ~((BcBigDig) 1))
#define BC_NUM_NEG_CLR_NP(n) ((n).rdx &= ~((BcBigDig) 1))
#define BC_NUM_NEG_SET(n) ((n)->rdx |= ((BcBigDig) 1))
#define BC_NUM_NEG_TGL(n) ((n)->rdx ^= ((BcBigDig) 1))
#define BC_NUM_NEG_TGL_NP(n) ((n).rdx ^= ((BcBigDig) 1))
#define BC_NUM_NEG_VAL(n, v) (((n)->rdx & ~((BcBigDig) 1)) | (v))
#define BC_NUM_NEG_VAL_NP(n, v) (((n).rdx & ~((BcBigDig) 1)) | (v))
#define BC_NUM_SIZE(n) ((n) * sizeof(BcDig))
#if BC_DEBUG_CODE
@ -183,7 +193,7 @@ void bc_num_bigdig2num(BcNum *restrict n, BcBigDig val);
#if BC_ENABLE_EXTRA_MATH && BC_ENABLE_RAND
void bc_num_irand(const BcNum *restrict a, BcNum *restrict b,
struct BcRNG *restrict rng);
struct BcRNG *restrict rng);
void bc_num_rng(const BcNum *restrict n, struct BcRNG *rng);
void bc_num_createFromRNG(BcNum *restrict n, struct BcRNG *rng);
#endif // BC_ENABLE_EXTRA_MATH && BC_ENABLE_RAND
@ -200,28 +210,34 @@ void bc_num_lshift(BcNum *a, BcNum *b, BcNum *c, size_t scale);
void bc_num_rshift(BcNum *a, BcNum *b, BcNum *c, size_t scale);
#endif // BC_ENABLE_EXTRA_MATH
void bc_num_sqrt(BcNum *restrict a, BcNum *restrict b, size_t scale);
void bc_num_sr(BcNum *restrict a, BcNum *restrict b, size_t scale);
void bc_num_divmod(BcNum *a, BcNum *b, BcNum *c, BcNum *d, size_t scale);
size_t bc_num_addReq(const BcNum* a, const BcNum* b, size_t scale);
size_t bc_num_mulReq(const BcNum *a, const BcNum *b, size_t scale);
size_t bc_num_divReq(const BcNum *a, const BcNum *b, size_t scale);
size_t bc_num_powReq(const BcNum *a, const BcNum *b, size_t scale);
#if BC_ENABLE_EXTRA_MATH
size_t bc_num_placesReq(const BcNum *a, const BcNum *b, size_t scale);
#endif // BC_ENABLE_EXTRA_MATH
void bc_num_truncate(BcNum *restrict n, size_t places);
void bc_num_extend(BcNum *restrict n, size_t places);
void bc_num_shiftRight(BcNum *restrict n, size_t places);
ssize_t bc_num_cmp(const BcNum *a, const BcNum *b);
#if DC_ENABLED
void bc_num_modexp(BcNum *a, BcNum *b, BcNum *c, BcNum *restrict d);
#endif // DC_ENABLED
void bc_num_zero(BcNum *restrict n);
void bc_num_one(BcNum *restrict n);
ssize_t bc_num_cmpZero(const BcNum *n);
void bc_num_parse(BcNum *restrict n, const char *restrict val,
BcBigDig base, bool letter);
bool bc_num_strValid(const char *restrict val);
void bc_num_parse(BcNum *restrict n, const char *restrict val, BcBigDig base);
void bc_num_print(BcNum *restrict n, BcBigDig base, bool newline);
#if DC_ENABLED
void bc_num_stream(BcNum *restrict n, BcBigDig base);
@ -238,6 +254,8 @@ extern const char bc_num_hex_digits[];
extern const BcBigDig bc_num_pow10[BC_BASE_DIGS + 1];
extern const BcDig bc_num_bigdigMax[];
extern const BcDig bc_num_bigdigMax2[];
extern const size_t bc_num_bigdigMax_size;
extern const size_t bc_num_bigdigMax2_size;
#endif // BC_NUM_H

View File

@ -62,8 +62,9 @@
#define bc_parse_push(p, i) (bc_vec_pushByte(&(p)->func->code, (uchar) (i)))
#define bc_parse_pushIndex(p, idx) (bc_vec_pushIndex(&(p)->func->code, (idx)))
#define bc_parse_err(p, e) (bc_vm_error((e), (p)->l.line))
#define bc_parse_verr(p, e, ...) (bc_vm_error((e), (p)->l.line, __VA_ARGS__))
#define bc_parse_err(p, e) (bc_vm_handleError((e), (p)->l.line))
#define bc_parse_verr(p, e, ...) \
(bc_vm_handleError((e), (p)->l.line, __VA_ARGS__))
typedef struct BcParseNext {
uchar len;
@ -110,7 +111,7 @@ void bc_parse_updateFunc(BcParse *p, size_t fidx);
void bc_parse_pushName(const BcParse* p, char *name, bool var);
void bc_parse_text(BcParse *p, const char *text);
extern const char bc_parse_zero[];
extern const char bc_parse_one[];
extern const char bc_parse_zero[2];
extern const char bc_parse_one[2];
#endif // BC_PARSE_H

View File

@ -223,6 +223,7 @@ void bc_rand_seed(BcRNG *r, ulong state1, ulong state2, ulong inc1, ulong inc2);
void bc_rand_push(BcRNG *r);
void bc_rand_pop(BcRNG *r, bool reset);
void bc_rand_getRands(BcRNG *r, BcRand *s1, BcRand *s2, BcRand *i1, BcRand *i2);
void bc_rand_srand(BcRNGData *rng);
extern const BcRandState bc_rand_multiplier;

View File

@ -46,6 +46,8 @@
#define DC_ENABLED (1)
#endif // DC_ENABLED
#include <bcl.h>
typedef enum BcStatus {
BC_STATUS_SUCCESS = 0,
@ -58,75 +60,75 @@ typedef enum BcStatus {
} BcStatus;
typedef enum BcError {
typedef enum BcErr {
BC_ERROR_MATH_NEGATIVE,
BC_ERROR_MATH_NON_INTEGER,
BC_ERROR_MATH_OVERFLOW,
BC_ERROR_MATH_DIVIDE_BY_ZERO,
BC_ERR_MATH_NEGATIVE,
BC_ERR_MATH_NON_INTEGER,
BC_ERR_MATH_OVERFLOW,
BC_ERR_MATH_DIVIDE_BY_ZERO,
BC_ERROR_FATAL_ALLOC_ERR,
BC_ERROR_FATAL_IO_ERR,
BC_ERROR_FATAL_FILE_ERR,
BC_ERROR_FATAL_BIN_FILE,
BC_ERROR_FATAL_PATH_DIR,
BC_ERROR_FATAL_OPTION,
BC_ERROR_FATAL_OPTION_NO_ARG,
BC_ERROR_FATAL_OPTION_ARG,
BC_ERR_FATAL_ALLOC_ERR,
BC_ERR_FATAL_IO_ERR,
BC_ERR_FATAL_FILE_ERR,
BC_ERR_FATAL_BIN_FILE,
BC_ERR_FATAL_PATH_DIR,
BC_ERR_FATAL_OPTION,
BC_ERR_FATAL_OPTION_NO_ARG,
BC_ERR_FATAL_OPTION_ARG,
BC_ERROR_EXEC_IBASE,
BC_ERROR_EXEC_OBASE,
BC_ERROR_EXEC_SCALE,
BC_ERROR_EXEC_READ_EXPR,
BC_ERROR_EXEC_REC_READ,
BC_ERROR_EXEC_TYPE,
BC_ERR_EXEC_IBASE,
BC_ERR_EXEC_OBASE,
BC_ERR_EXEC_SCALE,
BC_ERR_EXEC_READ_EXPR,
BC_ERR_EXEC_REC_READ,
BC_ERR_EXEC_TYPE,
BC_ERROR_EXEC_STACK,
BC_ERR_EXEC_STACK,
BC_ERROR_EXEC_PARAMS,
BC_ERROR_EXEC_UNDEF_FUNC,
BC_ERROR_EXEC_VOID_VAL,
BC_ERR_EXEC_PARAMS,
BC_ERR_EXEC_UNDEF_FUNC,
BC_ERR_EXEC_VOID_VAL,
BC_ERROR_PARSE_EOF,
BC_ERROR_PARSE_CHAR,
BC_ERROR_PARSE_STRING,
BC_ERROR_PARSE_COMMENT,
BC_ERROR_PARSE_TOKEN,
BC_ERR_PARSE_EOF,
BC_ERR_PARSE_CHAR,
BC_ERR_PARSE_STRING,
BC_ERR_PARSE_COMMENT,
BC_ERR_PARSE_TOKEN,
#if BC_ENABLED
BC_ERROR_PARSE_EXPR,
BC_ERROR_PARSE_EMPTY_EXPR,
BC_ERROR_PARSE_PRINT,
BC_ERROR_PARSE_FUNC,
BC_ERROR_PARSE_ASSIGN,
BC_ERROR_PARSE_NO_AUTO,
BC_ERROR_PARSE_DUP_LOCAL,
BC_ERROR_PARSE_BLOCK,
BC_ERROR_PARSE_RET_VOID,
BC_ERROR_PARSE_REF_VAR,
BC_ERR_PARSE_EXPR,
BC_ERR_PARSE_EMPTY_EXPR,
BC_ERR_PARSE_PRINT,
BC_ERR_PARSE_FUNC,
BC_ERR_PARSE_ASSIGN,
BC_ERR_PARSE_NO_AUTO,
BC_ERR_PARSE_DUP_LOCAL,
BC_ERR_PARSE_BLOCK,
BC_ERR_PARSE_RET_VOID,
BC_ERR_PARSE_REF_VAR,
BC_ERROR_POSIX_NAME_LEN,
BC_ERROR_POSIX_COMMENT,
BC_ERROR_POSIX_KW,
BC_ERROR_POSIX_DOT,
BC_ERROR_POSIX_RET,
BC_ERROR_POSIX_BOOL,
BC_ERROR_POSIX_REL_POS,
BC_ERROR_POSIX_MULTIREL,
BC_ERROR_POSIX_FOR,
BC_ERROR_POSIX_EXP_NUM,
BC_ERROR_POSIX_REF,
BC_ERROR_POSIX_VOID,
BC_ERROR_POSIX_BRACE,
BC_ERR_POSIX_NAME_LEN,
BC_ERR_POSIX_COMMENT,
BC_ERR_POSIX_KW,
BC_ERR_POSIX_DOT,
BC_ERR_POSIX_RET,
BC_ERR_POSIX_BOOL,
BC_ERR_POSIX_REL_POS,
BC_ERR_POSIX_MULTIREL,
BC_ERR_POSIX_FOR,
BC_ERR_POSIX_EXP_NUM,
BC_ERR_POSIX_REF,
BC_ERR_POSIX_VOID,
BC_ERR_POSIX_BRACE,
#endif // BC_ENABLED
BC_ERROR_NELEMS,
BC_ERR_NELEMS,
#if BC_ENABLED
BC_ERROR_POSIX_START = BC_ERROR_POSIX_NAME_LEN,
BC_ERROR_POSIX_END = BC_ERROR_POSIX_BRACE,
BC_ERR_POSIX_START = BC_ERR_POSIX_NAME_LEN,
BC_ERR_POSIX_END = BC_ERR_POSIX_BRACE,
#endif // BC_ENABLED
} BcError;
} BcErr;
#define BC_ERR_IDX_MATH (0)
#define BC_ERR_IDX_PARSE (1)
@ -163,6 +165,12 @@ typedef enum BcError {
#define BC_MUST_RETURN
#endif // __STDC_VERSION__
#if defined(__clang__) || defined(__GNUC__)
#define BC_FALLTHROUGH __attribute__((fallthrough));
#else // defined(__clang__) || defined(__GNUC__)
#define BC_FALLTHROUGH
#endif //defined(__clang__) || defined(__GNUC__)
// Workarounds for AIX's POSIX incompatibility.
#ifndef SIZE_MAX
#define SIZE_MAX __SIZE_MAX__

View File

@ -62,6 +62,7 @@ typedef struct BcVec {
void bc_vec_init(BcVec *restrict v, size_t esize, BcVecFree dtor);
void bc_vec_expand(BcVec *restrict v, size_t req);
void bc_vec_grow(BcVec *restrict v, size_t n);
void bc_vec_npop(BcVec *restrict v, size_t n);
void bc_vec_npopAt(BcVec *restrict v, size_t n, size_t idx);

View File

@ -36,6 +36,7 @@
#ifndef BC_VM_H
#define BC_VM_H
#include <assert.h>
#include <stddef.h>
#include <limits.h>
@ -56,7 +57,10 @@
#include <parse.h>
#include <program.h>
#include <history.h>
#if !BC_ENABLE_LIBRARY
#include <file.h>
#endif // !BC_ENABLE_LIBRARY
#if !BC_ENABLED && !DC_ENABLED
#error Must define BC_ENABLED, DC_ENABLED, or both
@ -91,6 +95,8 @@
#define isatty _isatty
#endif // _WIN32
#if !BC_ENABLE_LIBRARY
#if DC_ENABLED
#define DC_FLAG_X (UINTMAX_C(1)<<0)
#endif // DC_ENABLED
@ -149,6 +155,8 @@
#define BC_USE_PROMPT (!BC_P && BC_TTY)
#endif // BC_ENABLED
#endif // !BC_ENABLE_LIBRARY
#define BC_MAX(a, b) ((a) > (b) ? (a) : (b))
#define BC_MIN(a, b) ((a) < (b) ? (a) : (b))
@ -270,31 +278,75 @@
#define BC_VM_SAFE_RESULT(r) ((r)->t >= BC_RESULT_TEMP)
#define bc_vm_err(e) (bc_vm_error((e), 0))
#define bc_vm_verr(e, ...) (bc_vm_error((e), 0, __VA_ARGS__))
#if BC_ENABLE_LIBRARY
#define bc_vm_error(e, l, ...) (bc_vm_handleError((e)))
#define bc_vm_err(e) (bc_vm_handleError((e)))
#define bc_vm_verr(e, ...) (bc_vm_handleError((e)))
#else // BC_ENABLE_LIBRARY
#define bc_vm_error(e, l, ...) (bc_vm_handleError((e), (l), __VA_ARGS__))
#define bc_vm_err(e) (bc_vm_handleError((e), 0))
#define bc_vm_verr(e, ...) (bc_vm_handleError((e), 0, __VA_ARGS__))
#endif // BC_ENABLE_LIBRARY
#define BC_STATUS_IS_ERROR(s) \
((s) >= BC_STATUS_ERROR_MATH && (s) <= BC_STATUS_ERROR_FATAL)
#define BC_VM_INVALID_CATALOG ((nl_catd) -1)
#if BC_DEBUG_CODE
#define BC_VM_FUNC_ENTER \
do { \
bc_file_printf(&vm.ferr, "Entering %s\n", __func__); \
bc_file_flush(&vm.ferr); \
} while (0);
#define BC_VM_FUNC_EXIT \
do { \
bc_file_printf(&vm.ferr, "Leaving %s\n", __func__); \
bc_file_flush(&vm.ferr); \
} while (0);
#else // BC_DEBUG_CODE
#define BC_VM_FUNC_ENTER
#define BC_VM_FUNC_EXIT
#endif // BC_DEBUG_CODE
typedef struct BcVm {
volatile sig_atomic_t status;
volatile sig_atomic_t sig_pop;
#if !BC_ENABLE_LIBRARY
BcParse prs;
BcProgram prog;
#endif // BC_ENABLE_LIBRARY
BcVec jmp_bufs;
BcVec temps;
#if BC_ENABLE_LIBRARY
BcVec ctxts;
BcVec out;
BcRNG rng;
BclError err;
bool abrt;
unsigned int refs;
volatile sig_atomic_t running;
#endif // BC_ENABLE_LIBRARY
#if !BC_ENABLE_LIBRARY
const char* file;
const char *sigmsg;
#endif // BC_ENABLE_LIBRARY
volatile sig_atomic_t sig_lock;
volatile sig_atomic_t sig;
#if !BC_ENABLE_LIBRARY
uchar siglen;
uchar read_ret;
@ -305,9 +357,11 @@ typedef struct BcVm {
bool no_exit_exprs;
bool eof;
#endif // BC_ENABLE_LIBRARY
BcBigDig maxes[BC_PROG_GLOBALS_LEN + BC_ENABLE_EXTRA_MATH];
#if !BC_ENABLE_LIBRARY
BcVec files;
BcVec exprs;
@ -325,21 +379,27 @@ typedef struct BcVm {
const char *func_header;
const char *err_ids[BC_ERR_IDX_NELEMS + BC_ENABLED];
const char *err_msgs[BC_ERROR_NELEMS];
const char *err_msgs[BC_ERR_NELEMS];
const char *locale;
#endif // BC_ENABLE_LIBRARY
BcBigDig last_base;
BcBigDig last_pow;
BcBigDig last_exp;
BcBigDig last_rem;
#if !BC_ENABLE_LIBRARY
char *env_args_buffer;
BcVec env_args;
#endif // BC_ENABLE_LIBRARY
BcNum max;
BcNum max2;
BcDig max_num[BC_NUM_BIGDIG_LOG10];
BcDig max2_num[BC_NUM_BIGDIG_LOG10];
#if !BC_ENABLE_LIBRARY
BcFile fout;
BcFile ferr;
@ -349,13 +409,16 @@ typedef struct BcVm {
char *buf;
size_t buf_len;
#endif // !BC_ENABLE_LIBRARY
} BcVm;
void bc_vm_info(const char* const help);
void bc_vm_boot(int argc, char *argv[], const char *env_len,
const char* const env_args);
void bc_vm_init(void);
void bc_vm_shutdown(void);
void bc_vm_freeTemps(void);
void bc_vm_printf(const char *fmt, ...);
void bc_vm_putchar(int c);
@ -371,7 +434,11 @@ void bc_vm_jmp(const char *f);
void bc_vm_jmp(void);
#endif // BC_DEBUG_CODE
void bc_vm_error(BcError e, size_t line, ...);
#if BC_ENABLE_LIBRARY
void bc_vm_handleError(BcErr e);
#else // BC_ENABLE_LIBRARY
void bc_vm_handleError(BcErr e, size_t line, ...);
#endif // BC_ENABLE_LIBRARY
extern const char bc_copyright[];
extern const char* const bc_err_line;

View File

@ -32,6 +32,21 @@ usage() {
exit 1
}
print_manpage() {
_print_manpage_md="$1"
shift
_print_manpage_out="$1"
shift
cat "$manualsdir/header.txt" > "$_print_manpage_out"
cat "$manualsdir/header_${manpage}.txt" >> "$_print_manpage_out"
pandoc -f markdown -t man "$_print_manpage_md" >> "$_print_manpage_out"
}
gen_manpage() {
_gen_manpage_args="$1"
@ -84,10 +99,7 @@ gen_manpage() {
IFS="$_gen_manpage_ifs"
cat "$manualsdir/header.txt" > "$_gen_manpage_out"
cat "$manualsdir/header_${manpage}.txt" >> "$_gen_manpage_out"
pandoc -f markdown -t man "$_gen_manpage_md" >> "$_gen_manpage_out"
print_manpage "$_gen_manpage_md" "$_gen_manpage_out"
}
set -e
@ -108,6 +120,12 @@ test "$#" -eq 1 || usage
manpage="$1"
shift
for a in $ARGS; do
gen_manpage "$a"
done
if [ "$manpage" != "bcl" ]; then
for a in $ARGS; do
gen_manpage "$a"
done
else
print_manpage "$manualsdir/${manpage}.3.md" "$manualsdir/${manpage}.3"
fi

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# NAME
bc - arbitrary-precision arithmetic language and calculator
bc - arbitrary-precision decimal arithmetic language and calculator
# SYNOPSIS
@ -477,9 +477,9 @@ if they were valid digits, regardless of the value of **ibase**. This means that
{{ A H N P HN HP NP HNP }}
In addition, bc(1) accepts numbers in scientific notation. These have the form
**\<number\>e\<integer\>**. The power (the portion after the **e**) must be an
integer. An example is **1.89237e9**, which is equal to **1892370000**. Negative
exponents are also allowed, so **4.2890e-3** is equal to **0.0042890**.
**\<number\>e\<integer\>**. The exponent (the portion after the **e**) must be
an integer. An example is **1.89237e9**, which is equal to **1892370000**.
Negative exponents are also allowed, so **4.2890e-3** is equal to **0.0042890**.
Using scientific notation is an error or warning if the **-s** or **-w**,
respectively, command-line options (or equivalents) are given.
@ -652,7 +652,7 @@ The operators will be described in more detail below.
: The **power** operator (not the **exclusive or** operator, as it would be in
C) takes two expressions and raises the first to the power of the value of
the second.
the second. The *scale* of the result is equal to **scale**.
The second expression must be an integer (no *scale*), and if it is
negative, the first value must be non-zero.
@ -1019,6 +1019,8 @@ The extended library is a **non-portable extension**.
: Calculates **x** to the power of **y**, even if **y** is not an integer, and
returns the result to the current **scale**.
It is an error if **y** is negative and **x** is **0**.
This is a transcendental function (see the *Transcendental Functions*
subsection below).
@ -1798,7 +1800,7 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHORS
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html
[2]: https://www.gnu.org/software/bc/

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# NAME
bc - arbitrary-precision arithmetic language and calculator
bc - arbitrary-precision decimal arithmetic language and calculator
# SYNOPSIS
@ -419,9 +419,9 @@ if they were valid digits, regardless of the value of **ibase**. This means that
**35**.
In addition, bc(1) accepts numbers in scientific notation. These have the form
**\<number\>e\<integer\>**. The power (the portion after the **e**) must be an
integer. An example is **1.89237e9**, which is equal to **1892370000**. Negative
exponents are also allowed, so **4.2890e-3** is equal to **0.0042890**.
**\<number\>e\<integer\>**. The exponent (the portion after the **e**) must be
an integer. An example is **1.89237e9**, which is equal to **1892370000**.
Negative exponents are also allowed, so **4.2890e-3** is equal to **0.0042890**.
Using scientific notation is an error or warning if the **-s** or **-w**,
respectively, command-line options (or equivalents) are given.
@ -584,7 +584,7 @@ The operators will be described in more detail below.
: The **power** operator (not the **exclusive or** operator, as it would be in
C) takes two expressions and raises the first to the power of the value of
the second.
the second. The *scale* of the result is equal to **scale**.
The second expression must be an integer (no *scale*), and if it is
negative, the first value must be non-zero.
@ -933,6 +933,8 @@ The extended library is a **non-portable extension**.
: Calculates **x** to the power of **y**, even if **y** is not an integer, and
returns the result to the current **scale**.
It is an error if **y** is negative and **x** is **0**.
This is a transcendental function (see the *Transcendental Functions*
subsection below).
@ -1681,7 +1683,7 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHORS
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html
[2]: https://www.gnu.org/software/bc/

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# NAME
bc - arbitrary-precision arithmetic language and calculator
bc - arbitrary-precision decimal arithmetic language and calculator
# SYNOPSIS
@ -457,7 +457,7 @@ The operators will be described in more detail below.
: The **power** operator (not the **exclusive or** operator, as it would be in
C) takes two expressions and raises the first to the power of the value of
the second.
the second. The *scale* of the result is equal to **scale**.
The second expression must be an integer (no *scale*), and if it is
negative, the first value must be non-zero.
@ -1075,7 +1075,7 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHORS
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html
[2]: https://www.gnu.org/software/bc/

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# NAME
bc - arbitrary-precision arithmetic language and calculator
bc - arbitrary-precision decimal arithmetic language and calculator
# SYNOPSIS
@ -454,7 +454,7 @@ The operators will be described in more detail below.
: The **power** operator (not the **exclusive or** operator, as it would be in
C) takes two expressions and raises the first to the power of the value of
the second.
the second. The *scale* of the result is equal to **scale**.
The second expression must be an integer (no *scale*), and if it is
negative, the first value must be non-zero.
@ -1059,7 +1059,7 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHORS
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html
[2]: https://www.gnu.org/software/bc/

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# NAME
bc - arbitrary-precision arithmetic language and calculator
bc - arbitrary-precision decimal arithmetic language and calculator
# SYNOPSIS
@ -454,7 +454,7 @@ The operators will be described in more detail below.
: The **power** operator (not the **exclusive or** operator, as it would be in
C) takes two expressions and raises the first to the power of the value of
the second.
the second. The *scale* of the result is equal to **scale**.
The second expression must be an integer (no *scale*), and if it is
negative, the first value must be non-zero.
@ -1051,7 +1051,7 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHORS
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html
[2]: https://www.gnu.org/software/bc/

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# NAME
bc - arbitrary-precision arithmetic language and calculator
bc - arbitrary-precision decimal arithmetic language and calculator
# SYNOPSIS
@ -450,7 +450,7 @@ The operators will be described in more detail below.
: The **power** operator (not the **exclusive or** operator, as it would be in
C) takes two expressions and raises the first to the power of the value of
the second.
the second. The *scale* of the result is equal to **scale**.
The second expression must be an integer (no *scale*), and if it is
negative, the first value must be non-zero.
@ -1045,7 +1045,7 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHORS
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html
[2]: https://www.gnu.org/software/bc/

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# NAME
bc - arbitrary-precision arithmetic language and calculator
bc - arbitrary-precision decimal arithmetic language and calculator
# SYNOPSIS
@ -450,7 +450,7 @@ The operators will be described in more detail below.
: The **power** operator (not the **exclusive or** operator, as it would be in
C) takes two expressions and raises the first to the power of the value of
the second.
the second. The *scale* of the result is equal to **scale**.
The second expression must be an integer (no *scale*), and if it is
negative, the first value must be non-zero.
@ -1053,7 +1053,7 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHORS
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html
[2]: https://www.gnu.org/software/bc/

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# NAME
bc - arbitrary-precision arithmetic language and calculator
bc - arbitrary-precision decimal arithmetic language and calculator
# SYNOPSIS
@ -457,7 +457,7 @@ The operators will be described in more detail below.
: The **power** operator (not the **exclusive or** operator, as it would be in
C) takes two expressions and raises the first to the power of the value of
the second.
the second. The *scale* of the result is equal to **scale**.
The second expression must be an integer (no *scale*), and if it is
negative, the first value must be non-zero.
@ -1067,7 +1067,7 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHORS
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html
[2]: https://www.gnu.org/software/bc/

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# NAME
bc - arbitrary-precision arithmetic language and calculator
bc - arbitrary-precision decimal arithmetic language and calculator
# SYNOPSIS
@ -453,7 +453,7 @@ The operators will be described in more detail below.
: The **power** operator (not the **exclusive or** operator, as it would be in
C) takes two expressions and raises the first to the power of the value of
the second.
the second. The *scale* of the result is equal to **scale**.
The second expression must be an integer (no *scale*), and if it is
negative, the first value must be non-zero.
@ -1061,7 +1061,7 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHORS
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html
[2]: https://www.gnu.org/software/bc/

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# NAME
bc - arbitrary-precision arithmetic language and calculator
bc - arbitrary-precision decimal arithmetic language and calculator
# SYNOPSIS
@ -453,7 +453,7 @@ The operators will be described in more detail below.
: The **power** operator (not the **exclusive or** operator, as it would be in
C) takes two expressions and raises the first to the power of the value of
the second.
the second. The *scale* of the result is equal to **scale**.
The second expression must be an integer (no *scale*), and if it is
negative, the first value must be non-zero.
@ -1069,7 +1069,7 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHORS
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html
[2]: https://www.gnu.org/software/bc/

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# NAME
bc - arbitrary-precision arithmetic language and calculator
bc - arbitrary-precision decimal arithmetic language and calculator
# SYNOPSIS
@ -415,9 +415,9 @@ if they were valid digits, regardless of the value of **ibase**. This means that
**35**.
In addition, bc(1) accepts numbers in scientific notation. These have the form
**\<number\>e\<integer\>**. The power (the portion after the **e**) must be an
integer. An example is **1.89237e9**, which is equal to **1892370000**. Negative
exponents are also allowed, so **4.2890e-3** is equal to **0.0042890**.
**\<number\>e\<integer\>**. The exponent (the portion after the **e**) must be
an integer. An example is **1.89237e9**, which is equal to **1892370000**.
Negative exponents are also allowed, so **4.2890e-3** is equal to **0.0042890**.
Using scientific notation is an error or warning if the **-s** or **-w**,
respectively, command-line options (or equivalents) are given.
@ -580,7 +580,7 @@ The operators will be described in more detail below.
: The **power** operator (not the **exclusive or** operator, as it would be in
C) takes two expressions and raises the first to the power of the value of
the second.
the second. The *scale* of the result is equal to **scale**.
The second expression must be an integer (no *scale*), and if it is
negative, the first value must be non-zero.
@ -929,6 +929,8 @@ The extended library is a **non-portable extension**.
: Calculates **x** to the power of **y**, even if **y** is not an integer, and
returns the result to the current **scale**.
It is an error if **y** is negative and **x** is **0**.
This is a transcendental function (see the *Transcendental Functions*
subsection below).
@ -1664,7 +1666,7 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHORS
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html
[2]: https://www.gnu.org/software/bc/

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# NAME
bc - arbitrary-precision arithmetic language and calculator
bc - arbitrary-precision decimal arithmetic language and calculator
# SYNOPSIS
@ -415,9 +415,9 @@ if they were valid digits, regardless of the value of **ibase**. This means that
**35**.
In addition, bc(1) accepts numbers in scientific notation. These have the form
**\<number\>e\<integer\>**. The power (the portion after the **e**) must be an
integer. An example is **1.89237e9**, which is equal to **1892370000**. Negative
exponents are also allowed, so **4.2890e-3** is equal to **0.0042890**.
**\<number\>e\<integer\>**. The exponent (the portion after the **e**) must be
an integer. An example is **1.89237e9**, which is equal to **1892370000**.
Negative exponents are also allowed, so **4.2890e-3** is equal to **0.0042890**.
Using scientific notation is an error or warning if the **-s** or **-w**,
respectively, command-line options (or equivalents) are given.
@ -580,7 +580,7 @@ The operators will be described in more detail below.
: The **power** operator (not the **exclusive or** operator, as it would be in
C) takes two expressions and raises the first to the power of the value of
the second.
the second. The *scale* of the result is equal to **scale**.
The second expression must be an integer (no *scale*), and if it is
negative, the first value must be non-zero.
@ -929,6 +929,8 @@ The extended library is a **non-portable extension**.
: Calculates **x** to the power of **y**, even if **y** is not an integer, and
returns the result to the current **scale**.
It is an error if **y** is negative and **x** is **0**.
This is a transcendental function (see the *Transcendental Functions*
subsection below).
@ -1656,7 +1658,7 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHORS
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html
[2]: https://www.gnu.org/software/bc/

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# NAME
bc - arbitrary-precision arithmetic language and calculator
bc - arbitrary-precision decimal arithmetic language and calculator
# SYNOPSIS
@ -411,9 +411,9 @@ if they were valid digits, regardless of the value of **ibase**. This means that
**35**.
In addition, bc(1) accepts numbers in scientific notation. These have the form
**\<number\>e\<integer\>**. The power (the portion after the **e**) must be an
integer. An example is **1.89237e9**, which is equal to **1892370000**. Negative
exponents are also allowed, so **4.2890e-3** is equal to **0.0042890**.
**\<number\>e\<integer\>**. The exponent (the portion after the **e**) must be
an integer. An example is **1.89237e9**, which is equal to **1892370000**.
Negative exponents are also allowed, so **4.2890e-3** is equal to **0.0042890**.
Using scientific notation is an error or warning if the **-s** or **-w**,
respectively, command-line options (or equivalents) are given.
@ -576,7 +576,7 @@ The operators will be described in more detail below.
: The **power** operator (not the **exclusive or** operator, as it would be in
C) takes two expressions and raises the first to the power of the value of
the second.
the second. The *scale* of the result is equal to **scale**.
The second expression must be an integer (no *scale*), and if it is
negative, the first value must be non-zero.
@ -925,6 +925,8 @@ The extended library is a **non-portable extension**.
: Calculates **x** to the power of **y**, even if **y** is not an integer, and
returns the result to the current **scale**.
It is an error if **y** is negative and **x** is **0**.
This is a transcendental function (see the *Transcendental Functions*
subsection below).
@ -1650,7 +1652,7 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHORS
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html
[2]: https://www.gnu.org/software/bc/

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# NAME
bc - arbitrary-precision arithmetic language and calculator
bc - arbitrary-precision decimal arithmetic language and calculator
# SYNOPSIS
@ -411,9 +411,9 @@ if they were valid digits, regardless of the value of **ibase**. This means that
**35**.
In addition, bc(1) accepts numbers in scientific notation. These have the form
**\<number\>e\<integer\>**. The power (the portion after the **e**) must be an
integer. An example is **1.89237e9**, which is equal to **1892370000**. Negative
exponents are also allowed, so **4.2890e-3** is equal to **0.0042890**.
**\<number\>e\<integer\>**. The exponent (the portion after the **e**) must be
an integer. An example is **1.89237e9**, which is equal to **1892370000**.
Negative exponents are also allowed, so **4.2890e-3** is equal to **0.0042890**.
Using scientific notation is an error or warning if the **-s** or **-w**,
respectively, command-line options (or equivalents) are given.
@ -576,7 +576,7 @@ The operators will be described in more detail below.
: The **power** operator (not the **exclusive or** operator, as it would be in
C) takes two expressions and raises the first to the power of the value of
the second.
the second. The *scale* of the result is equal to **scale**.
The second expression must be an integer (no *scale*), and if it is
negative, the first value must be non-zero.
@ -925,6 +925,8 @@ The extended library is a **non-portable extension**.
: Calculates **x** to the power of **y**, even if **y** is not an integer, and
returns the result to the current **scale**.
It is an error if **y** is negative and **x** is **0**.
This is a transcendental function (see the *Transcendental Functions*
subsection below).
@ -1658,7 +1660,7 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHORS
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html
[2]: https://www.gnu.org/software/bc/

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# NAME
bc - arbitrary-precision arithmetic language and calculator
bc - arbitrary-precision decimal arithmetic language and calculator
# SYNOPSIS
@ -419,9 +419,9 @@ if they were valid digits, regardless of the value of **ibase**. This means that
**35**.
In addition, bc(1) accepts numbers in scientific notation. These have the form
**\<number\>e\<integer\>**. The power (the portion after the **e**) must be an
integer. An example is **1.89237e9**, which is equal to **1892370000**. Negative
exponents are also allowed, so **4.2890e-3** is equal to **0.0042890**.
**\<number\>e\<integer\>**. The exponent (the portion after the **e**) must be
an integer. An example is **1.89237e9**, which is equal to **1892370000**.
Negative exponents are also allowed, so **4.2890e-3** is equal to **0.0042890**.
Using scientific notation is an error or warning if the **-s** or **-w**,
respectively, command-line options (or equivalents) are given.
@ -584,7 +584,7 @@ The operators will be described in more detail below.
: The **power** operator (not the **exclusive or** operator, as it would be in
C) takes two expressions and raises the first to the power of the value of
the second.
the second. The *scale* of the result is equal to **scale**.
The second expression must be an integer (no *scale*), and if it is
negative, the first value must be non-zero.
@ -933,6 +933,8 @@ The extended library is a **non-portable extension**.
: Calculates **x** to the power of **y**, even if **y** is not an integer, and
returns the result to the current **scale**.
It is an error if **y** is negative and **x** is **0**.
This is a transcendental function (see the *Transcendental Functions*
subsection below).
@ -1673,7 +1675,7 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHORS
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html
[2]: https://www.gnu.org/software/bc/

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# NAME
bc - arbitrary-precision arithmetic language and calculator
bc - arbitrary-precision decimal arithmetic language and calculator
# SYNOPSIS
@ -415,9 +415,9 @@ if they were valid digits, regardless of the value of **ibase**. This means that
**35**.
In addition, bc(1) accepts numbers in scientific notation. These have the form
**\<number\>e\<integer\>**. The power (the portion after the **e**) must be an
integer. An example is **1.89237e9**, which is equal to **1892370000**. Negative
exponents are also allowed, so **4.2890e-3** is equal to **0.0042890**.
**\<number\>e\<integer\>**. The exponent (the portion after the **e**) must be
an integer. An example is **1.89237e9**, which is equal to **1892370000**.
Negative exponents are also allowed, so **4.2890e-3** is equal to **0.0042890**.
Using scientific notation is an error or warning if the **-s** or **-w**,
respectively, command-line options (or equivalents) are given.
@ -580,7 +580,7 @@ The operators will be described in more detail below.
: The **power** operator (not the **exclusive or** operator, as it would be in
C) takes two expressions and raises the first to the power of the value of
the second.
the second. The *scale* of the result is equal to **scale**.
The second expression must be an integer (no *scale*), and if it is
negative, the first value must be non-zero.
@ -929,6 +929,8 @@ The extended library is a **non-portable extension**.
: Calculates **x** to the power of **y**, even if **y** is not an integer, and
returns the result to the current **scale**.
It is an error if **y** is negative and **x** is **0**.
This is a transcendental function (see the *Transcendental Functions*
subsection below).
@ -1667,7 +1669,7 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHORS
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html
[2]: https://www.gnu.org/software/bc/

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# NAME
bc - arbitrary-precision arithmetic language and calculator
bc - arbitrary-precision decimal arithmetic language and calculator
# SYNOPSIS
@ -415,9 +415,9 @@ if they were valid digits, regardless of the value of **ibase**. This means that
**35**.
In addition, bc(1) accepts numbers in scientific notation. These have the form
**\<number\>e\<integer\>**. The power (the portion after the **e**) must be an
integer. An example is **1.89237e9**, which is equal to **1892370000**. Negative
exponents are also allowed, so **4.2890e-3** is equal to **0.0042890**.
**\<number\>e\<integer\>**. The exponent (the portion after the **e**) must be
an integer. An example is **1.89237e9**, which is equal to **1892370000**.
Negative exponents are also allowed, so **4.2890e-3** is equal to **0.0042890**.
Using scientific notation is an error or warning if the **-s** or **-w**,
respectively, command-line options (or equivalents) are given.
@ -580,7 +580,7 @@ The operators will be described in more detail below.
: The **power** operator (not the **exclusive or** operator, as it would be in
C) takes two expressions and raises the first to the power of the value of
the second.
the second. The *scale* of the result is equal to **scale**.
The second expression must be an integer (no *scale*), and if it is
negative, the first value must be non-zero.
@ -929,6 +929,8 @@ The extended library is a **non-portable extension**.
: Calculates **x** to the power of **y**, even if **y** is not an integer, and
returns the result to the current **scale**.
It is an error if **y** is negative and **x** is **0**.
This is a transcendental function (see the *Transcendental Functions*
subsection below).
@ -1675,7 +1677,7 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHORS
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html
[2]: https://www.gnu.org/software/bc/

1365
contrib/bc/manuals/bcl.3 Normal file

File diff suppressed because it is too large Load Diff

1177
contrib/bc/manuals/bcl.3.md Normal file

File diff suppressed because it is too large Load Diff

View File

@ -282,6 +282,29 @@ following forms:
--option=arg
```
### Library
To build the math library, use the following commands for the configure step:
```
./configure.sh -a
./configure.sh --library
```
Both commands are equivalent.
When the library is built, history, prompt, and locales are disabled, and the
functionality for `bc` and `dc` are both enabled, though the executables are
*not* built. This is because the library's options clash with the executables.
To build an optimized version of the library, users can pass optimization
options to `configure.sh` or include them in `CFLAGS`.
The library API can be found in `manuals/bcl.3.md` or `man bcl` once the library
is installed.
The library is built as `bin/libbcl.a`.
### `bc` Only
To build `bc` only (no `dc`), use any one of the following commands for the

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# Name
dc - arbitrary-precision reverse-Polish notation calculator
dc - arbitrary-precision decimal reverse-Polish notation calculator
# SYNOPSIS
@ -235,9 +235,9 @@ if they were valid digits, regardless of the value of **ibase**. This means that
{{ A H N P HN HP NP HNP }}
In addition, dc(1) accepts numbers in scientific notation. These have the form
**\<number\>e\<integer\>**. The power (the portion after the **e**) must be an
integer. An example is **1.89237e9**, which is equal to **1892370000**. Negative
exponents are also allowed, so **4.2890e_3** is equal to **0.0042890**.
**\<number\>e\<integer\>**. The exponent (the portion after the **e**) must be
an integer. An example is **1.89237e9**, which is equal to **1892370000**.
Negative exponents are also allowed, so **4.2890e_3** is equal to **0.0042890**.
**WARNING**: Both the number and the exponent in scientific notation are
interpreted according to the current **ibase**, but the number is still
@ -355,7 +355,8 @@ These are the commands used for arithmetic.
**\^**
: The top two values are popped off the stack, the second is raised to the
power of the first, and the result is pushed onto the stack.
power of the first, and the result is pushed onto the stack. The *scale* of
the result is equal to **scale**.
The first value popped off of the stack must be an integer, and if that
value is negative, the second value popped off of the stack must be
@ -1252,6 +1253,6 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHOR
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# Name
dc - arbitrary-precision reverse-Polish notation calculator
dc - arbitrary-precision decimal reverse-Polish notation calculator
# SYNOPSIS
@ -222,9 +222,9 @@ if they were valid digits, regardless of the value of **ibase**. This means that
**15**.
In addition, dc(1) accepts numbers in scientific notation. These have the form
**\<number\>e\<integer\>**. The power (the portion after the **e**) must be an
integer. An example is **1.89237e9**, which is equal to **1892370000**. Negative
exponents are also allowed, so **4.2890e_3** is equal to **0.0042890**.
**\<number\>e\<integer\>**. The exponent (the portion after the **e**) must be
an integer. An example is **1.89237e9**, which is equal to **1892370000**.
Negative exponents are also allowed, so **4.2890e_3** is equal to **0.0042890**.
**WARNING**: Both the number and the exponent in scientific notation are
interpreted according to the current **ibase**, but the number is still
@ -339,7 +339,8 @@ These are the commands used for arithmetic.
**\^**
: The top two values are popped off the stack, the second is raised to the
power of the first, and the result is pushed onto the stack.
power of the first, and the result is pushed onto the stack. The *scale* of
the result is equal to **scale**.
The first value popped off of the stack must be an integer, and if that
value is negative, the second value popped off of the stack must be
@ -1189,6 +1190,6 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHOR
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# Name
dc - arbitrary-precision reverse-Polish notation calculator
dc - arbitrary-precision decimal reverse-Polish notation calculator
# SYNOPSIS
@ -289,7 +289,8 @@ These are the commands used for arithmetic.
**\^**
: The top two values are popped off the stack, the second is raised to the
power of the first, and the result is pushed onto the stack.
power of the first, and the result is pushed onto the stack. The *scale* of
the result is equal to **scale**.
The first value popped off of the stack must be an integer, and if that
value is negative, the second value popped off of the stack must be
@ -1025,6 +1026,6 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHOR
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# Name
dc - arbitrary-precision reverse-Polish notation calculator
dc - arbitrary-precision decimal reverse-Polish notation calculator
# SYNOPSIS
@ -289,7 +289,8 @@ These are the commands used for arithmetic.
**\^**
: The top two values are popped off the stack, the second is raised to the
power of the first, and the result is pushed onto the stack.
power of the first, and the result is pushed onto the stack. The *scale* of
the result is equal to **scale**.
The first value popped off of the stack must be an integer, and if that
value is negative, the second value popped off of the stack must be
@ -1012,6 +1013,6 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHOR
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# Name
dc - arbitrary-precision reverse-Polish notation calculator
dc - arbitrary-precision decimal reverse-Polish notation calculator
# SYNOPSIS
@ -289,7 +289,8 @@ These are the commands used for arithmetic.
**\^**
: The top two values are popped off the stack, the second is raised to the
power of the first, and the result is pushed onto the stack.
power of the first, and the result is pushed onto the stack. The *scale* of
the result is equal to **scale**.
The first value popped off of the stack must be an integer, and if that
value is negative, the second value popped off of the stack must be
@ -1007,6 +1008,6 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHOR
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# Name
dc - arbitrary-precision reverse-Polish notation calculator
dc - arbitrary-precision decimal reverse-Polish notation calculator
# SYNOPSIS
@ -286,7 +286,8 @@ These are the commands used for arithmetic.
**\^**
: The top two values are popped off the stack, the second is raised to the
power of the first, and the result is pushed onto the stack.
power of the first, and the result is pushed onto the stack. The *scale* of
the result is equal to **scale**.
The first value popped off of the stack must be an integer, and if that
value is negative, the second value popped off of the stack must be
@ -1002,6 +1003,6 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHOR
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# Name
dc - arbitrary-precision reverse-Polish notation calculator
dc - arbitrary-precision decimal reverse-Polish notation calculator
# SYNOPSIS
@ -286,7 +286,8 @@ These are the commands used for arithmetic.
**\^**
: The top two values are popped off the stack, the second is raised to the
power of the first, and the result is pushed onto the stack.
power of the first, and the result is pushed onto the stack. The *scale* of
the result is equal to **scale**.
The first value popped off of the stack must be an integer, and if that
value is negative, the second value popped off of the stack must be
@ -1007,6 +1008,6 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHOR
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# Name
dc - arbitrary-precision reverse-Polish notation calculator
dc - arbitrary-precision decimal reverse-Polish notation calculator
# SYNOPSIS
@ -289,7 +289,8 @@ These are the commands used for arithmetic.
**\^**
: The top two values are popped off the stack, the second is raised to the
power of the first, and the result is pushed onto the stack.
power of the first, and the result is pushed onto the stack. The *scale* of
the result is equal to **scale**.
The first value popped off of the stack must be an integer, and if that
value is negative, the second value popped off of the stack must be
@ -1020,6 +1021,6 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHOR
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# Name
dc - arbitrary-precision reverse-Polish notation calculator
dc - arbitrary-precision decimal reverse-Polish notation calculator
# SYNOPSIS
@ -286,7 +286,8 @@ These are the commands used for arithmetic.
**\^**
: The top two values are popped off the stack, the second is raised to the
power of the first, and the result is pushed onto the stack.
power of the first, and the result is pushed onto the stack. The *scale* of
the result is equal to **scale**.
The first value popped off of the stack must be an integer, and if that
value is negative, the second value popped off of the stack must be
@ -1015,6 +1016,6 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHOR
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# Name
dc - arbitrary-precision reverse-Polish notation calculator
dc - arbitrary-precision decimal reverse-Polish notation calculator
# SYNOPSIS
@ -286,7 +286,8 @@ These are the commands used for arithmetic.
**\^**
: The top two values are popped off the stack, the second is raised to the
power of the first, and the result is pushed onto the stack.
power of the first, and the result is pushed onto the stack. The *scale* of
the result is equal to **scale**.
The first value popped off of the stack must be an integer, and if that
value is negative, the second value popped off of the stack must be
@ -1020,6 +1021,6 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHOR
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# Name
dc - arbitrary-precision reverse-Polish notation calculator
dc - arbitrary-precision decimal reverse-Polish notation calculator
# SYNOPSIS
@ -222,9 +222,9 @@ if they were valid digits, regardless of the value of **ibase**. This means that
**15**.
In addition, dc(1) accepts numbers in scientific notation. These have the form
**\<number\>e\<integer\>**. The power (the portion after the **e**) must be an
integer. An example is **1.89237e9**, which is equal to **1892370000**. Negative
exponents are also allowed, so **4.2890e_3** is equal to **0.0042890**.
**\<number\>e\<integer\>**. The exponent (the portion after the **e**) must be
an integer. An example is **1.89237e9**, which is equal to **1892370000**.
Negative exponents are also allowed, so **4.2890e_3** is equal to **0.0042890**.
**WARNING**: Both the number and the exponent in scientific notation are
interpreted according to the current **ibase**, but the number is still
@ -339,7 +339,8 @@ These are the commands used for arithmetic.
**\^**
: The top two values are popped off the stack, the second is raised to the
power of the first, and the result is pushed onto the stack.
power of the first, and the result is pushed onto the stack. The *scale* of
the result is equal to **scale**.
The first value popped off of the stack must be an integer, and if that
value is negative, the second value popped off of the stack must be
@ -1176,6 +1177,6 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHOR
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# Name
dc - arbitrary-precision reverse-Polish notation calculator
dc - arbitrary-precision decimal reverse-Polish notation calculator
# SYNOPSIS
@ -222,9 +222,9 @@ if they were valid digits, regardless of the value of **ibase**. This means that
**15**.
In addition, dc(1) accepts numbers in scientific notation. These have the form
**\<number\>e\<integer\>**. The power (the portion after the **e**) must be an
integer. An example is **1.89237e9**, which is equal to **1892370000**. Negative
exponents are also allowed, so **4.2890e_3** is equal to **0.0042890**.
**\<number\>e\<integer\>**. The exponent (the portion after the **e**) must be
an integer. An example is **1.89237e9**, which is equal to **1892370000**.
Negative exponents are also allowed, so **4.2890e_3** is equal to **0.0042890**.
**WARNING**: Both the number and the exponent in scientific notation are
interpreted according to the current **ibase**, but the number is still
@ -339,7 +339,8 @@ These are the commands used for arithmetic.
**\^**
: The top two values are popped off the stack, the second is raised to the
power of the first, and the result is pushed onto the stack.
power of the first, and the result is pushed onto the stack. The *scale* of
the result is equal to **scale**.
The first value popped off of the stack must be an integer, and if that
value is negative, the second value popped off of the stack must be
@ -1171,6 +1172,6 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHOR
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# Name
dc - arbitrary-precision reverse-Polish notation calculator
dc - arbitrary-precision decimal reverse-Polish notation calculator
# SYNOPSIS
@ -219,9 +219,9 @@ if they were valid digits, regardless of the value of **ibase**. This means that
**15**.
In addition, dc(1) accepts numbers in scientific notation. These have the form
**\<number\>e\<integer\>**. The power (the portion after the **e**) must be an
integer. An example is **1.89237e9**, which is equal to **1892370000**. Negative
exponents are also allowed, so **4.2890e_3** is equal to **0.0042890**.
**\<number\>e\<integer\>**. The exponent (the portion after the **e**) must be
an integer. An example is **1.89237e9**, which is equal to **1892370000**.
Negative exponents are also allowed, so **4.2890e_3** is equal to **0.0042890**.
**WARNING**: Both the number and the exponent in scientific notation are
interpreted according to the current **ibase**, but the number is still
@ -336,7 +336,8 @@ These are the commands used for arithmetic.
**\^**
: The top two values are popped off the stack, the second is raised to the
power of the first, and the result is pushed onto the stack.
power of the first, and the result is pushed onto the stack. The *scale* of
the result is equal to **scale**.
The first value popped off of the stack must be an integer, and if that
value is negative, the second value popped off of the stack must be
@ -1166,6 +1167,6 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHOR
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# Name
dc - arbitrary-precision reverse-Polish notation calculator
dc - arbitrary-precision decimal reverse-Polish notation calculator
# SYNOPSIS
@ -219,9 +219,9 @@ if they were valid digits, regardless of the value of **ibase**. This means that
**15**.
In addition, dc(1) accepts numbers in scientific notation. These have the form
**\<number\>e\<integer\>**. The power (the portion after the **e**) must be an
integer. An example is **1.89237e9**, which is equal to **1892370000**. Negative
exponents are also allowed, so **4.2890e_3** is equal to **0.0042890**.
**\<number\>e\<integer\>**. The exponent (the portion after the **e**) must be
an integer. An example is **1.89237e9**, which is equal to **1892370000**.
Negative exponents are also allowed, so **4.2890e_3** is equal to **0.0042890**.
**WARNING**: Both the number and the exponent in scientific notation are
interpreted according to the current **ibase**, but the number is still
@ -336,7 +336,8 @@ These are the commands used for arithmetic.
**\^**
: The top two values are popped off the stack, the second is raised to the
power of the first, and the result is pushed onto the stack.
power of the first, and the result is pushed onto the stack. The *scale* of
the result is equal to **scale**.
The first value popped off of the stack must be an integer, and if that
value is negative, the second value popped off of the stack must be
@ -1171,6 +1172,6 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHOR
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# Name
dc - arbitrary-precision reverse-Polish notation calculator
dc - arbitrary-precision decimal reverse-Polish notation calculator
# SYNOPSIS
@ -222,9 +222,9 @@ if they were valid digits, regardless of the value of **ibase**. This means that
**15**.
In addition, dc(1) accepts numbers in scientific notation. These have the form
**\<number\>e\<integer\>**. The power (the portion after the **e**) must be an
integer. An example is **1.89237e9**, which is equal to **1892370000**. Negative
exponents are also allowed, so **4.2890e_3** is equal to **0.0042890**.
**\<number\>e\<integer\>**. The exponent (the portion after the **e**) must be
an integer. An example is **1.89237e9**, which is equal to **1892370000**.
Negative exponents are also allowed, so **4.2890e_3** is equal to **0.0042890**.
**WARNING**: Both the number and the exponent in scientific notation are
interpreted according to the current **ibase**, but the number is still
@ -339,7 +339,8 @@ These are the commands used for arithmetic.
**\^**
: The top two values are popped off the stack, the second is raised to the
power of the first, and the result is pushed onto the stack.
power of the first, and the result is pushed onto the stack. The *scale* of
the result is equal to **scale**.
The first value popped off of the stack must be an integer, and if that
value is negative, the second value popped off of the stack must be
@ -1184,6 +1185,6 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHOR
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# Name
dc - arbitrary-precision reverse-Polish notation calculator
dc - arbitrary-precision decimal reverse-Polish notation calculator
# SYNOPSIS
@ -219,9 +219,9 @@ if they were valid digits, regardless of the value of **ibase**. This means that
**15**.
In addition, dc(1) accepts numbers in scientific notation. These have the form
**\<number\>e\<integer\>**. The power (the portion after the **e**) must be an
integer. An example is **1.89237e9**, which is equal to **1892370000**. Negative
exponents are also allowed, so **4.2890e_3** is equal to **0.0042890**.
**\<number\>e\<integer\>**. The exponent (the portion after the **e**) must be
an integer. An example is **1.89237e9**, which is equal to **1892370000**.
Negative exponents are also allowed, so **4.2890e_3** is equal to **0.0042890**.
**WARNING**: Both the number and the exponent in scientific notation are
interpreted according to the current **ibase**, but the number is still
@ -336,7 +336,8 @@ These are the commands used for arithmetic.
**\^**
: The top two values are popped off the stack, the second is raised to the
power of the first, and the result is pushed onto the stack.
power of the first, and the result is pushed onto the stack. The *scale* of
the result is equal to **scale**.
The first value popped off of the stack must be an integer, and if that
value is negative, the second value popped off of the stack must be
@ -1179,6 +1180,6 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHOR
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
# Name
dc - arbitrary-precision reverse-Polish notation calculator
dc - arbitrary-precision decimal reverse-Polish notation calculator
# SYNOPSIS
@ -219,9 +219,9 @@ if they were valid digits, regardless of the value of **ibase**. This means that
**15**.
In addition, dc(1) accepts numbers in scientific notation. These have the form
**\<number\>e\<integer\>**. The power (the portion after the **e**) must be an
integer. An example is **1.89237e9**, which is equal to **1892370000**. Negative
exponents are also allowed, so **4.2890e_3** is equal to **0.0042890**.
**\<number\>e\<integer\>**. The exponent (the portion after the **e**) must be
an integer. An example is **1.89237e9**, which is equal to **1892370000**.
Negative exponents are also allowed, so **4.2890e_3** is equal to **0.0042890**.
**WARNING**: Both the number and the exponent in scientific notation are
interpreted according to the current **ibase**, but the number is still
@ -336,7 +336,8 @@ These are the commands used for arithmetic.
**\^**
: The top two values are popped off the stack, the second is raised to the
power of the first, and the result is pushed onto the stack.
power of the first, and the result is pushed onto the stack. The *scale* of
the result is equal to **scale**.
The first value popped off of the stack must be an integer, and if that
value is negative, the second value popped off of the stack must be
@ -1184,6 +1185,6 @@ None are known. Report bugs at https://git.yzena.com/gavin/bc.
# AUTHOR
Gavin D. Howard <yzena.tech@gmail.com> and contributors.
Gavin D. Howard <gavin@yzena.com> and contributors.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html

View File

@ -0,0 +1,27 @@
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2018-2020 Gavin D. Howard and contributors.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are met:
.\"
.\" * Redistributions of source code must retain the above copyright notice,
.\" this list of conditions and the following disclaimer.
.\"
.\" * Redistributions in binary form must reproduce the above copyright notice,
.\" this list of conditions and the following disclaimer in the documentation
.\" and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
.\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"

View File

@ -0,0 +1 @@
.TH "BC" "1" "October 2020" "Gavin D. Howard" "General Commands Manual"

View File

@ -0,0 +1 @@
.TH "BCL" "3" "October 2020" "Gavin D. Howard" "Libraries Manual"

View File

@ -0,0 +1 @@
.TH "DC" "1" "October 2020" "Gavin D. Howard" "General Commands Manual"

View File

@ -263,6 +263,35 @@ runtestseries() {
done
}
runlibtests() {
_runlibtests_CFLAGS="$1"
shift
_runlibtests_CC="$1"
shift
_runlibtests_configure_flags="$1"
shift
_runlibtests_run_tests="$1"
shift
_runlibtests_configure_flags="$_runlibtests_configure_flags -a"
build "$_runlibtests_CFLAGS" "$_runlibtests_CC" "$_runlibtests_configure_flags" 1 64
if [ "$_runlibtests_run_tests" -ne 0 ]; then
runtest
fi
build "$_runlibtests_CFLAGS" "$_runlibtests_CC" "$_runlibtests_configure_flags" 1 32
if [ "$_runlibtests_run_tests" -ne 0 ]; then
runtest
fi
}
runtests() {
_runtests_CFLAGS="$1"
@ -326,6 +355,12 @@ debug() {
if [ "$_debug_CC" = "clang" -a "$run_sanitizers" -ne 0 ]; then
runtests "$debug -fsanitize=undefined" "$_debug_CC" "-g" "$_debug_run_tests"
fi
runlibtests "$debug" "$_debug_CC" "-g" "$_debug_run_tests"
if [ "$_debug_CC" = "clang" -a "$run_sanitizers" -ne 0 ]; then
runlibtests "$debug -fsanitize=undefined" "$_debug_CC" "-g" "$_debug_run_tests"
fi
}
release() {
@ -337,6 +372,8 @@ release() {
shift
runtests "$release" "$_release_CC" "-O3" "$_release_run_tests"
runlibtests "$release" "$_release_CC" "-O3" "$_release_run_tests"
}
reldebug() {
@ -353,6 +390,13 @@ reldebug() {
runtests "$debug -fsanitize=address" "$_reldebug_CC" "-gO3" "$_reldebug_run_tests"
runtests "$debug -fsanitize=memory" "$_reldebug_CC" "-gO3" "$_reldebug_run_tests"
fi
runlibtests "$debug" "$_reldebug_CC" "-gO3" "$_reldebug_run_tests"
if [ "$_reldebug_CC" = "clang" -a "$run_sanitizers" -ne 0 ]; then
runlibtests "$debug -fsanitize=address" "$_reldebug_CC" "-gO3" "$_reldebug_run_tests"
runlibtests "$debug -fsanitize=memory" "$_reldebug_CC" "-gO3" "$_reldebug_run_tests"
fi
}
minsize() {
@ -364,6 +408,8 @@ minsize() {
shift
runtests "$release" "$_minsize_CC" "-Os" "$_minsize_run_tests"
runlibtests "$release" "$_minsize_CC" "-Os" "$_minsize_run_tests"
}
build_set() {

View File

@ -41,10 +41,8 @@
#include <unistd.h>
#include <status.h>
#include <vector.h>
#include <read.h>
#include <vm.h>
#include <args.h>
#include <opt.h>
@ -109,7 +107,7 @@ void bc_args(int argc, char *argv[]) {
case 'e':
{
if (vm.no_exit_exprs)
bc_vm_verr(BC_ERROR_FATAL_OPTION, "-e (--expression)");
bc_vm_verr(BC_ERR_FATAL_OPTION, "-e (--expression)");
bc_args_exprs(opts.optarg);
break;
}
@ -119,7 +117,7 @@ void bc_args(int argc, char *argv[]) {
if (!strcmp(opts.optarg, "-")) vm.no_exit_exprs = true;
else {
if (vm.no_exit_exprs)
bc_vm_verr(BC_ERROR_FATAL_OPTION, "-f (--file)");
bc_vm_verr(BC_ERR_FATAL_OPTION, "-f (--file)");
bc_args_file(opts.optarg);
}
break;

View File

@ -37,7 +37,6 @@
#include <string.h>
#include <status.h>
#include <bc.h>
#include <vm.h>

View File

@ -39,7 +39,6 @@
#include <ctype.h>
#include <string.h>
#include <lex.h>
#include <bc.h>
#include <vm.h>
@ -58,7 +57,7 @@ static void bc_lex_identifier(BcLex *l) {
l->t = BC_LEX_KW_AUTO + (BcLexType) i;
if (!BC_LEX_KW_POSIX(kw))
bc_lex_verr(l, BC_ERROR_POSIX_KW, kw->name);
bc_lex_verr(l, BC_ERR_POSIX_KW, kw->name);
// We minus 1 because the index has already been incremented.
l->i += n - 1;
@ -69,7 +68,7 @@ static void bc_lex_identifier(BcLex *l) {
bc_lex_name(l);
if (BC_ERR(l->str.len - 1 > 1))
bc_lex_verr(l, BC_ERROR_POSIX_NAME_LEN, l->str.v);
bc_lex_verr(l, BC_ERR_POSIX_NAME_LEN, l->str.v);
}
static void bc_lex_string(BcLex *l) {
@ -84,7 +83,7 @@ static void bc_lex_string(BcLex *l) {
if (BC_ERR(c == '\0')) {
l->i = i;
bc_lex_err(l, BC_ERROR_PARSE_STRING);
bc_lex_err(l, BC_ERR_PARSE_STRING);
}
len = i - l->i;
@ -126,7 +125,7 @@ void bc_lex_token(BcLex *l) {
bc_lex_assign(l, BC_LEX_OP_REL_NE, BC_LEX_OP_BOOL_NOT);
if (l->t == BC_LEX_OP_BOOL_NOT)
bc_lex_verr(l, BC_ERROR_POSIX_BOOL, "!");
bc_lex_verr(l, BC_ERR_POSIX_BOOL, "!");
break;
}
@ -139,7 +138,7 @@ void bc_lex_token(BcLex *l) {
case '#':
{
bc_lex_err(l, BC_ERROR_POSIX_COMMENT);
bc_lex_err(l, BC_ERR_POSIX_COMMENT);
bc_lex_lineComment(l);
break;
}
@ -155,7 +154,7 @@ void bc_lex_token(BcLex *l) {
c2 = l->buf[l->i];
if (BC_NO_ERR(c2 == '&')) {
bc_lex_verr(l, BC_ERROR_POSIX_BOOL, "&&");
bc_lex_verr(l, BC_ERR_POSIX_BOOL, "&&");
l->i += 1;
l->t = BC_LEX_OP_BOOL_AND;
@ -224,7 +223,7 @@ void bc_lex_token(BcLex *l) {
if (BC_LEX_NUM_CHAR(c2, true, false)) bc_lex_number(l, c);
else {
l->t = BC_LEX_KW_LAST;
bc_lex_err(l, BC_ERROR_POSIX_DOT);
bc_lex_err(l, BC_ERR_POSIX_DOT);
}
break;
}
@ -391,7 +390,7 @@ void bc_lex_token(BcLex *l) {
if (BC_NO_ERR(c2 == '|')) {
bc_lex_verr(l, BC_ERROR_POSIX_BOOL, "||");
bc_lex_verr(l, BC_ERR_POSIX_BOOL, "||");
l->i += 1;
l->t = BC_LEX_OP_BOOL_OR;

View File

@ -42,8 +42,6 @@
#include <setjmp.h>
#include <lex.h>
#include <parse.h>
#include <bc.h>
#include <num.h>
#include <vm.h>
@ -190,7 +188,7 @@ static void bc_parse_params(BcParse *p, uint8_t flags) {
if (comma) bc_lex_next(&p->l);
}
if (BC_ERR(comma)) bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
if (BC_ERR(comma)) bc_parse_err(p, BC_ERR_PARSE_TOKEN);
bc_parse_push(p, BC_INST_CALL);
bc_parse_pushIndex(p, nparams);
}
@ -251,7 +249,7 @@ static void bc_parse_name(BcParse *p, BcInst *type,
if (p->l.t == BC_LEX_RBRACKET) {
if (BC_ERR(!(flags & BC_PARSE_ARRAY)))
bc_parse_err(p, BC_ERROR_PARSE_EXPR);
bc_parse_err(p, BC_ERR_PARSE_EXPR);
*type = BC_INST_ARRAY;
*can_assign = false;
@ -264,7 +262,7 @@ static void bc_parse_name(BcParse *p, BcInst *type,
bc_parse_expr_status(p, flags2, bc_parse_next_elem);
if (BC_ERR(p->l.t != BC_LEX_RBRACKET))
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
*type = BC_INST_ARRAY_ELEM;
*can_assign = true;
@ -278,7 +276,7 @@ static void bc_parse_name(BcParse *p, BcInst *type,
else if (p->l.t == BC_LEX_LPAREN) {
if (BC_ERR(flags & BC_PARSE_NOCALL))
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
*type = BC_INST_CALL;
*can_assign = false;
@ -301,10 +299,10 @@ static void bc_parse_name(BcParse *p, BcInst *type,
static void bc_parse_noArgBuiltin(BcParse *p, BcInst inst) {
bc_lex_next(&p->l);
if (BC_ERR(p->l.t != BC_LEX_LPAREN)) bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
if (BC_ERR(p->l.t != BC_LEX_LPAREN)) bc_parse_err(p, BC_ERR_PARSE_TOKEN);
bc_lex_next(&p->l);
if ((p->l.t != BC_LEX_RPAREN)) bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
if ((p->l.t != BC_LEX_RPAREN)) bc_parse_err(p, BC_ERR_PARSE_TOKEN);
bc_parse_push(p, inst);
@ -316,7 +314,7 @@ static void bc_parse_builtin(BcParse *p, BcLexType type,
{
bc_lex_next(&p->l);
if (BC_ERR(p->l.t != BC_LEX_LPAREN))
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
bc_lex_next(&p->l);
@ -327,7 +325,7 @@ static void bc_parse_builtin(BcParse *p, BcLexType type,
bc_parse_expr_status(p, flags, bc_parse_next_rel);
if (BC_ERR(p->l.t != BC_LEX_RPAREN))
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
*prev = type - BC_LEX_KW_LENGTH + BC_INST_LENGTH;
bc_parse_push(p, *prev);
@ -356,7 +354,7 @@ static void bc_parse_scale(BcParse *p, BcInst *type,
bc_parse_expr_status(p, flags, bc_parse_next_rel);
if (BC_ERR(p->l.t != BC_LEX_RPAREN))
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
bc_parse_push(p, BC_INST_SCALE_FUNC);
@ -376,12 +374,12 @@ static void bc_parse_incdec(BcParse *p, BcInst *prev, bool *can_assign,
if (BC_ERR(last == BC_LEX_OP_INC || last == BC_LEX_OP_DEC ||
last == BC_LEX_RPAREN))
{
bc_parse_err(p, BC_ERROR_PARSE_ASSIGN);
bc_parse_err(p, BC_ERR_PARSE_ASSIGN);
}
if (BC_PARSE_INST_VAR(etype)) {
if (!*can_assign) bc_parse_err(p, BC_ERROR_PARSE_ASSIGN);
if (!*can_assign) bc_parse_err(p, BC_ERR_PARSE_ASSIGN);
*prev = inst = BC_INST_INC + (p->l.t != BC_LEX_OP_INC);
bc_parse_push(p, inst);
@ -412,10 +410,10 @@ static void bc_parse_incdec(BcParse *p, BcInst *prev, bool *can_assign,
bc_lex_next(&p->l);
if (BC_ERR(p->l.t == BC_LEX_LPAREN))
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
else bc_parse_push(p, BC_INST_SCALE);
}
else bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
else bc_parse_err(p, BC_ERR_PARSE_TOKEN);
*can_assign = false;
@ -455,7 +453,7 @@ static void bc_parse_print(BcParse *p) {
t = p->l.t;
if (bc_parse_isDelimiter(p)) bc_parse_err(p, BC_ERROR_PARSE_PRINT);
if (bc_parse_isDelimiter(p)) bc_parse_err(p, BC_ERR_PARSE_PRINT);
do {
if (t == BC_LEX_STR) bc_parse_str(p, BC_INST_PRINT_POP);
@ -469,14 +467,14 @@ static void bc_parse_print(BcParse *p) {
if (comma) bc_lex_next(&p->l);
else {
if (!bc_parse_isDelimiter(p))
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
else break;
}
t = p->l.t;
} while (true);
if (BC_ERR(comma)) bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
if (BC_ERR(comma)) bc_parse_err(p, BC_ERR_PARSE_TOKEN);
}
static void bc_parse_return(BcParse *p) {
@ -485,7 +483,7 @@ static void bc_parse_return(BcParse *p) {
bool paren;
uchar inst = BC_INST_RET0;
if (BC_ERR(!BC_PARSE_FUNC(p))) bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
if (BC_ERR(!BC_PARSE_FUNC(p))) bc_parse_err(p, BC_ERR_PARSE_TOKEN);
if (p->func->voidfn) inst = BC_INST_RET_VOID;
@ -507,10 +505,10 @@ static void bc_parse_return(BcParse *p) {
}
if (!paren || p->l.last != BC_LEX_RPAREN) {
bc_parse_err(p, BC_ERROR_POSIX_RET);
bc_parse_err(p, BC_ERR_POSIX_RET);
}
else if (BC_ERR(p->func->voidfn))
bc_parse_verr(p, BC_ERROR_PARSE_RET_VOID, p->func->name);
bc_parse_verr(p, BC_ERR_PARSE_RET_VOID, p->func->name);
bc_parse_push(p, BC_INST_RET);
}
@ -526,7 +524,7 @@ static void bc_parse_endBody(BcParse *p, bool brace) {
bool has_brace, new_else = false;
if (BC_ERR(p->flags.len <= 1)) bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
if (BC_ERR(p->flags.len <= 1)) bc_parse_err(p, BC_ERR_PARSE_TOKEN);
if (brace) {
@ -534,7 +532,7 @@ static void bc_parse_endBody(BcParse *p, bool brace) {
bc_lex_next(&p->l);
if (BC_ERR(!bc_parse_isDelimiter(p)))
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
}
has_brace = (BC_PARSE_BRACE(p) != 0);
@ -543,7 +541,7 @@ static void bc_parse_endBody(BcParse *p, bool brace) {
size_t len = p->flags.len;
bool loop;
if (has_brace && !brace) bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
if (has_brace && !brace) bc_parse_err(p, BC_ERR_PARSE_TOKEN);
loop = (BC_PARSE_LOOP_INNER(p) != 0);
@ -595,7 +593,7 @@ static void bc_parse_endBody(BcParse *p, bool brace) {
!(has_brace = (BC_PARSE_BRACE(p) != 0)));
if (BC_ERR(p->flags.len == 1 && brace))
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
else if (brace && BC_PARSE_BRACE(p)) {
uint16_t flags = BC_PARSE_TOP_FLAG(p);
@ -623,12 +621,12 @@ static void bc_parse_if(BcParse *p) {
bc_lex_next(&p->l);
if (BC_ERR(p->l.t != BC_LEX_LPAREN))
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
bc_lex_next(&p->l);
bc_parse_expr_status(p, flags, bc_parse_next_rel);
if (BC_ERR(p->l.t != BC_LEX_RPAREN))
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
bc_lex_next(&p->l);
bc_parse_push(p, BC_INST_JUMP_ZERO);
@ -645,7 +643,7 @@ static void bc_parse_else(BcParse *p) {
size_t idx = p->func->labels.len;
if (BC_ERR(!BC_PARSE_IF_END(p)))
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
bc_parse_push(p, BC_INST_JUMP);
bc_parse_pushIndex(p, idx);
@ -665,7 +663,7 @@ static void bc_parse_while(BcParse *p) {
bc_lex_next(&p->l);
if (BC_ERR(p->l.t != BC_LEX_LPAREN))
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
bc_lex_next(&p->l);
bc_parse_createCondLabel(p, p->func->labels.len);
@ -674,7 +672,7 @@ static void bc_parse_while(BcParse *p) {
bc_parse_expr_status(p, flags, bc_parse_next_rel);
if (BC_ERR(p->l.t != BC_LEX_RPAREN))
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
bc_lex_next(&p->l);
bc_parse_push(p, BC_INST_JUMP_ZERO);
@ -688,15 +686,15 @@ static void bc_parse_for(BcParse *p) {
bc_lex_next(&p->l);
if (BC_ERR(p->l.t != BC_LEX_LPAREN))
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
bc_lex_next(&p->l);
if (p->l.t != BC_LEX_SCOLON)
bc_parse_expr_status(p, 0, bc_parse_next_for);
else bc_parse_err(p, BC_ERROR_POSIX_FOR);
else bc_parse_err(p, BC_ERR_POSIX_FOR);
if (BC_ERR(p->l.t != BC_LEX_SCOLON))
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
bc_lex_next(&p->l);
cond_idx = p->func->labels.len;
@ -715,14 +713,14 @@ static void bc_parse_for(BcParse *p) {
// Set this for the next call to bc_parse_number.
// This is safe to set because the current token
// is a semicolon, which has no string requirement.
bc_vec_string(&p->l.str, strlen(bc_parse_const1), bc_parse_const1);
bc_vec_string(&p->l.str, sizeof(bc_parse_one) - 1, bc_parse_one);
bc_parse_number(p);
bc_parse_err(p, BC_ERROR_POSIX_FOR);
bc_parse_err(p, BC_ERR_POSIX_FOR);
}
if (BC_ERR(p->l.t != BC_LEX_SCOLON))
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
bc_lex_next(&p->l);
@ -735,10 +733,10 @@ static void bc_parse_for(BcParse *p) {
if (p->l.t != BC_LEX_RPAREN)
bc_parse_expr_status(p, 0, bc_parse_next_rel);
else bc_parse_err(p, BC_ERROR_POSIX_FOR);
else bc_parse_err(p, BC_ERR_POSIX_FOR);
if (BC_ERR(p->l.t != BC_LEX_RPAREN))
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
bc_parse_push(p, BC_INST_JUMP);
bc_parse_pushIndex(p, cond_idx);
bc_parse_createLabel(p, p->func->code.len);
@ -753,11 +751,11 @@ static void bc_parse_loopExit(BcParse *p, BcLexType type) {
size_t i;
BcInstPtr *ip;
if (BC_ERR(!BC_PARSE_LOOP(p))) bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
if (BC_ERR(!BC_PARSE_LOOP(p))) bc_parse_err(p, BC_ERR_PARSE_TOKEN);
if (type == BC_LEX_KW_BREAK) {
if (BC_ERR(!p->exits.len)) bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
if (BC_ERR(!p->exits.len)) bc_parse_err(p, BC_ERR_PARSE_TOKEN);
i = p->exits.len - 1;
ip = bc_vec_item(&p->exits, i);
@ -783,7 +781,7 @@ static void bc_parse_func(BcParse *p) {
bc_lex_next(&p->l);
if (BC_ERR(p->l.t != BC_LEX_NAME))
bc_parse_err(p, BC_ERROR_PARSE_FUNC);
bc_parse_err(p, BC_ERR_PARSE_FUNC);
voidfn = (!BC_IS_POSIX && p->l.t == BC_LEX_NAME &&
!strcmp(p->l.str.v, "void"));
@ -793,12 +791,12 @@ static void bc_parse_func(BcParse *p) {
voidfn = (voidfn && p->l.t == BC_LEX_NAME);
if (voidfn) {
bc_parse_err(p, BC_ERROR_POSIX_VOID);
bc_parse_err(p, BC_ERR_POSIX_VOID);
bc_lex_next(&p->l);
}
if (BC_ERR(p->l.t != BC_LEX_LPAREN))
bc_parse_err(p, BC_ERROR_PARSE_FUNC);
bc_parse_err(p, BC_ERR_PARSE_FUNC);
assert(p->prog->fns.len == p->prog->fn_map.len);
@ -821,11 +819,11 @@ static void bc_parse_func(BcParse *p) {
if (p->l.t == BC_LEX_OP_MULTIPLY) {
t = BC_TYPE_REF;
bc_lex_next(&p->l);
bc_parse_err(p, BC_ERROR_POSIX_REF);
bc_parse_err(p, BC_ERR_POSIX_REF);
}
if (BC_ERR(p->l.t != BC_LEX_NAME))
bc_parse_err(p, BC_ERROR_PARSE_FUNC);
bc_parse_err(p, BC_ERR_PARSE_FUNC);
p->func->nparams += 1;
@ -840,12 +838,12 @@ static void bc_parse_func(BcParse *p) {
bc_lex_next(&p->l);
if (BC_ERR(p->l.t != BC_LEX_RBRACKET))
bc_parse_err(p, BC_ERROR_PARSE_FUNC);
bc_parse_err(p, BC_ERR_PARSE_FUNC);
bc_lex_next(&p->l);
}
else if (BC_ERR(t == BC_TYPE_REF))
bc_parse_verr(p, BC_ERROR_PARSE_REF_VAR, p->buf.v);
bc_parse_verr(p, BC_ERR_PARSE_REF_VAR, p->buf.v);
comma = (p->l.t == BC_LEX_COMMA);
if (comma) {
@ -855,21 +853,21 @@ static void bc_parse_func(BcParse *p) {
bc_func_insert(p->func, p->prog, p->buf.v, t, p->l.line);
}
if (BC_ERR(comma)) bc_parse_err(p, BC_ERROR_PARSE_FUNC);
if (BC_ERR(comma)) bc_parse_err(p, BC_ERR_PARSE_FUNC);
flags = BC_PARSE_FLAG_FUNC | BC_PARSE_FLAG_FUNC_INNER;
bc_parse_startBody(p, flags);
bc_lex_next(&p->l);
if (p->l.t != BC_LEX_LBRACE) bc_parse_err(p, BC_ERROR_POSIX_BRACE);
if (p->l.t != BC_LEX_LBRACE) bc_parse_err(p, BC_ERR_POSIX_BRACE);
}
static void bc_parse_auto(BcParse *p) {
bool comma, one;
if (BC_ERR(!p->auto_part)) bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
if (BC_ERR(!p->auto_part)) bc_parse_err(p, BC_ERR_PARSE_TOKEN);
bc_lex_next(&p->l);
p->auto_part = comma = false;
@ -890,7 +888,7 @@ static void bc_parse_auto(BcParse *p) {
bc_lex_next(&p->l);
if (BC_ERR(p->l.t != BC_LEX_RBRACKET))
bc_parse_err(p, BC_ERROR_PARSE_FUNC);
bc_parse_err(p, BC_ERR_PARSE_FUNC);
bc_lex_next(&p->l);
}
@ -902,10 +900,10 @@ static void bc_parse_auto(BcParse *p) {
bc_func_insert(p->func, p->prog, p->buf.v, t, p->l.line);
}
if (BC_ERR(comma)) bc_parse_err(p, BC_ERROR_PARSE_FUNC);
if (BC_ERR(!one)) bc_parse_err(p, BC_ERROR_PARSE_NO_AUTO);
if (BC_ERR(comma)) bc_parse_err(p, BC_ERR_PARSE_FUNC);
if (BC_ERR(!one)) bc_parse_err(p, BC_ERR_PARSE_NO_AUTO);
if (BC_ERR(!bc_parse_isDelimiter(p)))
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
}
static void bc_parse_body(BcParse *p, bool brace) {
@ -919,7 +917,7 @@ static void bc_parse_body(BcParse *p, bool brace) {
if (*flag_ptr & BC_PARSE_FLAG_FUNC_INNER) {
if (BC_ERR(!brace)) bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
if (BC_ERR(!brace)) bc_parse_err(p, BC_ERR_PARSE_TOKEN);
p->auto_part = (p->l.t != BC_LEX_KW_AUTO);
@ -1134,13 +1132,13 @@ static void bc_parse_stmt(BcParse *p) {
default:
{
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
}
}
if (len == p->flags.len && flags == BC_PARSE_TOP_FLAG(p)) {
if (BC_ERR(!bc_parse_isDelimiter(p)))
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
}
// Make sure semicolons are eaten.
@ -1153,10 +1151,10 @@ void bc_parse_parse(BcParse *p) {
BC_SETJMP(exit);
if (BC_ERR(p->l.t == BC_LEX_EOF)) bc_parse_err(p, BC_ERROR_PARSE_EOF);
if (BC_ERR(p->l.t == BC_LEX_EOF)) bc_parse_err(p, BC_ERR_PARSE_EOF);
else if (p->l.t == BC_LEX_KW_DEFINE) {
if (BC_ERR(BC_PARSE_NO_EXEC(p)))
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
bc_parse_func(p);
}
else bc_parse_stmt(p);
@ -1198,7 +1196,7 @@ static BcParseStatus bc_parse_expr_err(BcParse *p, uint8_t flags,
case BC_LEX_OP_INC:
case BC_LEX_OP_DEC:
{
if (BC_ERR(incdec)) bc_parse_err(p, BC_ERROR_PARSE_ASSIGN);
if (BC_ERR(incdec)) bc_parse_err(p, BC_ERR_PARSE_ASSIGN);
bc_parse_incdec(p, &prev, &can_assign, &nexprs, flags);
rprn = get_token = bin_last = false;
incdec = true;
@ -1210,7 +1208,7 @@ static BcParseStatus bc_parse_expr_err(BcParse *p, uint8_t flags,
case BC_LEX_OP_TRUNC:
{
if (BC_ERR(!BC_PARSE_LEAF(prev, bin_last, rprn)))
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
// I can just add the instruction because
// negative will already be taken care of.
@ -1246,9 +1244,11 @@ static BcParseStatus bc_parse_expr_err(BcParse *p, uint8_t flags,
case BC_LEX_OP_ASSIGN:
{
if (!BC_PARSE_INST_VAR(prev))
bc_parse_err(p, BC_ERROR_PARSE_ASSIGN);
bc_parse_err(p, BC_ERR_PARSE_ASSIGN);
}
// Fallthrough.
BC_FALLTHROUGH
case BC_LEX_OP_POWER:
case BC_LEX_OP_MULTIPLY:
case BC_LEX_OP_DIVIDE:
@ -1271,10 +1271,10 @@ static BcParseStatus bc_parse_expr_err(BcParse *p, uint8_t flags,
{
if (BC_PARSE_OP_PREFIX(t)) {
if (BC_ERR(!bin_last && !BC_PARSE_OP_PREFIX(p->l.last)))
bc_parse_err(p, BC_ERROR_PARSE_EXPR);
bc_parse_err(p, BC_ERR_PARSE_EXPR);
}
else if (BC_ERR(BC_PARSE_PREV_PREFIX(prev) || bin_last))
bc_parse_err(p, BC_ERROR_PARSE_EXPR);
bc_parse_err(p, BC_ERR_PARSE_EXPR);
nrelops += (t >= BC_LEX_OP_REL_EQ && t <= BC_LEX_OP_REL_GT);
prev = BC_PARSE_TOKEN_INST(t);
@ -1290,7 +1290,7 @@ static BcParseStatus bc_parse_expr_err(BcParse *p, uint8_t flags,
case BC_LEX_LPAREN:
{
if (BC_ERR(BC_PARSE_LEAF(prev, bin_last, rprn)))
bc_parse_err(p, BC_ERROR_PARSE_EXPR);
bc_parse_err(p, BC_ERR_PARSE_EXPR);
nparens += 1;
rprn = incdec = can_assign = false;
@ -1308,7 +1308,7 @@ static BcParseStatus bc_parse_expr_err(BcParse *p, uint8_t flags,
return BC_PARSE_STATUS_EMPTY_EXPR;
if (BC_ERR(bin_last || BC_PARSE_PREV_PREFIX(prev)))
bc_parse_err(p, BC_ERROR_PARSE_EXPR);
bc_parse_err(p, BC_ERR_PARSE_EXPR);
if (!nparens) {
done = true;
@ -1328,7 +1328,7 @@ static BcParseStatus bc_parse_expr_err(BcParse *p, uint8_t flags,
case BC_LEX_NAME:
{
if (BC_ERR(BC_PARSE_LEAF(prev, bin_last, rprn)))
bc_parse_err(p, BC_ERROR_PARSE_EXPR);
bc_parse_err(p, BC_ERR_PARSE_EXPR);
get_token = bin_last = false;
bc_parse_name(p, &prev, &can_assign,
@ -1343,7 +1343,7 @@ static BcParseStatus bc_parse_expr_err(BcParse *p, uint8_t flags,
case BC_LEX_NUMBER:
{
if (BC_ERR(BC_PARSE_LEAF(prev, bin_last, rprn)))
bc_parse_err(p, BC_ERROR_PARSE_EXPR);
bc_parse_err(p, BC_ERR_PARSE_EXPR);
bc_parse_number(p);
nexprs += 1;
@ -1363,7 +1363,7 @@ static BcParseStatus bc_parse_expr_err(BcParse *p, uint8_t flags,
#endif // BC_ENABLE_EXTRA_MATH && BC_ENABLE_RAND
{
if (BC_ERR(BC_PARSE_LEAF(prev, bin_last, rprn)))
bc_parse_err(p, BC_ERROR_PARSE_EXPR);
bc_parse_err(p, BC_ERR_PARSE_EXPR);
prev = t - BC_LEX_KW_LAST + BC_INST_LAST;
bc_parse_push(p, prev);
@ -1384,7 +1384,7 @@ static BcParseStatus bc_parse_expr_err(BcParse *p, uint8_t flags,
#endif // BC_ENABLE_EXTRA_MATH && BC_ENABLE_RAND
{
if (BC_ERR(BC_PARSE_LEAF(prev, bin_last, rprn)))
bc_parse_err(p, BC_ERROR_PARSE_EXPR);
bc_parse_err(p, BC_ERR_PARSE_EXPR);
bc_parse_builtin(p, t, flags, &prev);
rprn = get_token = bin_last = incdec = can_assign = false;
@ -1406,9 +1406,9 @@ static BcParseStatus bc_parse_expr_err(BcParse *p, uint8_t flags,
#endif // BC_ENABLE_EXTRA_MATH && BC_ENABLE_RAND
{
if (BC_ERR(BC_PARSE_LEAF(prev, bin_last, rprn)))
bc_parse_err(p, BC_ERROR_PARSE_EXPR);
bc_parse_err(p, BC_ERR_PARSE_EXPR);
else if (t == BC_LEX_KW_READ && BC_ERR(flags & BC_PARSE_NOREAD))
bc_parse_err(p, BC_ERROR_EXEC_REC_READ);
bc_parse_err(p, BC_ERR_EXEC_REC_READ);
else {
prev = t - BC_LEX_KW_READ + BC_INST_READ;
bc_parse_noArgBuiltin(p, prev);
@ -1424,7 +1424,7 @@ static BcParseStatus bc_parse_expr_err(BcParse *p, uint8_t flags,
case BC_LEX_KW_SCALE:
{
if (BC_ERR(BC_PARSE_LEAF(prev, bin_last, rprn)))
bc_parse_err(p, BC_ERROR_PARSE_EXPR);
bc_parse_err(p, BC_ERR_PARSE_EXPR);
bc_parse_scale(p, &prev, &can_assign, flags);
rprn = get_token = bin_last = false;
@ -1437,7 +1437,7 @@ static BcParseStatus bc_parse_expr_err(BcParse *p, uint8_t flags,
default:
{
#ifndef NDEBUG
bc_parse_err(p, BC_ERROR_PARSE_TOKEN);
bc_parse_err(p, BC_ERR_PARSE_TOKEN);
break;
#endif // NDEBUG
}
@ -1452,7 +1452,7 @@ static BcParseStatus bc_parse_expr_err(BcParse *p, uint8_t flags,
assign = top >= BC_LEX_OP_ASSIGN_POWER && top <= BC_LEX_OP_ASSIGN;
if (BC_ERR(top == BC_LEX_LPAREN || top == BC_LEX_RPAREN))
bc_parse_err(p, BC_ERROR_PARSE_EXPR);
bc_parse_err(p, BC_ERR_PARSE_EXPR);
bc_parse_push(p, BC_PARSE_TOKEN_INST(top));
@ -1462,16 +1462,16 @@ static BcParseStatus bc_parse_expr_err(BcParse *p, uint8_t flags,
incdec = false;
}
if (BC_ERR(nexprs != 1)) bc_parse_err(p, BC_ERROR_PARSE_EXPR);
if (BC_ERR(nexprs != 1)) bc_parse_err(p, BC_ERR_PARSE_EXPR);
for (i = 0; i < next.len && t != next.tokens[i]; ++i);
if (BC_ERR(i == next.len && !bc_parse_isDelimiter(p)))
bc_parse_err(p, BC_ERROR_PARSE_EXPR);
bc_parse_err(p, BC_ERR_PARSE_EXPR);
if (!(flags & BC_PARSE_REL) && nrelops)
bc_parse_err(p, BC_ERROR_POSIX_REL_POS);
bc_parse_err(p, BC_ERR_POSIX_REL_POS);
else if ((flags & BC_PARSE_REL) && nrelops > 1)
bc_parse_err(p, BC_ERROR_POSIX_MULTIREL);
bc_parse_err(p, BC_ERR_POSIX_MULTIREL);
if (!(flags & BC_PARSE_NEEDVAL) && !pfirst) {
@ -1522,7 +1522,7 @@ void bc_parse_expr_status(BcParse *p, uint8_t flags, BcParseNext next) {
BcParseStatus s = bc_parse_expr_err(p, flags, next);
if (BC_ERR(s == BC_PARSE_STATUS_EMPTY_EXPR))
bc_parse_err(p, BC_ERROR_PARSE_EMPTY_EXPR);
bc_parse_err(p, BC_ERR_PARSE_EMPTY_EXPR);
}
void bc_parse_expr(BcParse *p, uint8_t flags) {

View File

@ -43,6 +43,8 @@
#include <program.h>
#include <vm.h>
#if !BC_ENABLE_LIBRARY
#if BC_ENABLED
const char bc_sig_msg[] = "\ninterrupt (type \"quit\" to exit)\n";
const uchar bc_sig_msg_len = (uchar) (sizeof(bc_sig_msg) - 1);
@ -664,11 +666,8 @@ const char* bc_inst_names[] = {
};
#endif // BC_DEBUG_CODE
#if BC_ENABLE_EXTRA_MATH && BC_ENABLE_RAND
const BcRandState bc_rand_multiplier = BC_RAND_MULTIPLIER;
#endif // BC_ENABLE_EXTRA_MATH && BC_ENABLE_RAND
const char bc_parse_zero[2] = "0";
const char bc_parse_one[2] = "1";
#if BC_ENABLED
const BcLexKeyword bc_lex_kws[] = {
@ -712,8 +711,6 @@ const BcLexKeyword bc_lex_kws[] = {
const size_t bc_lex_kws_len = sizeof(bc_lex_kws) / sizeof(BcLexKeyword);
const char* const bc_parse_const1 = "1";
// This is an array that corresponds to token types. An entry is
// true if the token is valid in an expression, false otherwise.
const uint8_t bc_parse_exprs[] = {
@ -937,11 +934,26 @@ const uchar dc_parse_insts[] = {
};
#endif // DC_ENABLED
#endif // !BC_ENABLE_LIBRARY
#if BC_ENABLE_EXTRA_MATH && BC_ENABLE_RAND
const BcRandState bc_rand_multiplier = BC_RAND_MULTIPLIER;
#endif // BC_ENABLE_EXTRA_MATH && BC_ENABLE_RAND
#if BC_LONG_BIT >= 64
const BcDig bc_num_bigdigMax[] = {
709551616U,
446744073U,
18U
18U,
};
const BcDig bc_num_bigdigMax2[] = {
768211456U,
374607431U,
938463463U,
282366920U,
340U,
};
#else // BC_LONG_BIT >= 64
const BcDig bc_num_bigdigMax[] = {
@ -949,12 +961,17 @@ const BcDig bc_num_bigdigMax[] = {
9496U,
42U,
};
const BcDig bc_num_bigdigMax2[] = {
1616U,
955U,
737U,
6744U,
1844U,
};
#endif // BC_LONG_BIT >= 64
const size_t bc_num_bigdigMax_size = sizeof(bc_num_bigdigMax) / sizeof(BcDig);
const char bc_parse_zero[] = "0";
const char bc_parse_one[] = "1";
const size_t bc_num_bigdigMax2_size = sizeof(bc_num_bigdigMax2) / sizeof(BcDig);
const char bc_num_hex_digits[] = "0123456789ABCDEF";
@ -973,6 +990,8 @@ const BcBigDig bc_num_pow10[BC_BASE_DIGS + 1] = {
#endif // BC_BASE_DIGS > 4
};
#if !BC_ENABLE_LIBRARY
const BcNumBinaryOp bc_program_ops[] = {
bc_num_pow, bc_num_mul, bc_num_div, bc_num_mod, bc_num_add, bc_num_sub,
#if BC_ENABLE_EXTRA_MATH
@ -981,7 +1000,7 @@ const BcNumBinaryOp bc_program_ops[] = {
};
const BcNumBinaryOpReq bc_program_opReqs[] = {
bc_num_powReq, bc_num_mulReq, bc_num_mulReq, bc_num_mulReq,
bc_num_powReq, bc_num_mulReq, bc_num_divReq, bc_num_divReq,
bc_num_addReq, bc_num_addReq,
#if BC_ENABLE_EXTRA_MATH
bc_num_placesReq, bc_num_placesReq, bc_num_placesReq,
@ -1002,3 +1021,5 @@ const char bc_program_ready_msg[] = "ready for more input\n";
const size_t bc_program_ready_msg_len = sizeof(bc_program_ready_msg) - 1;
const char bc_program_esc_chars[] = "ab\\efnqrt";
const char bc_program_esc_seqs[] = "\a\b\\\\\f\n\"\r\t";
#endif // !BC_ENABLE_LIBRARY

View File

@ -37,7 +37,6 @@
#include <string.h>
#include <status.h>
#include <dc.h>
#include <vm.h>

Some files were not shown because too many files have changed in this diff Show More