Commit 47a52dc4 authored by Stefan Eßer's avatar Stefan Eßer
Browse files

Vendor import of Gavin Howard's bc version 3.2.6

parent 7fe0a3f2
...@@ -34,6 +34,13 @@ config.mak ...@@ -34,6 +34,13 @@ config.mak
timeconst.bc timeconst.bc
Makefile Makefile
tests/fuzzing/bc_outputs1/*
tests/fuzzing/bc_outputs2/*
tests/fuzzing/bc_outputs3/*
tests/fuzzing/dc_outputs/*
tests/bc_outputs/*
tests/dc_outputs/*
.gdb_history .gdb_history
# Ignore the generated test files # Ignore the generated test files
...@@ -57,5 +64,7 @@ perf.data.old ...@@ -57,5 +64,7 @@ perf.data.old
*.html *.html
*.profraw *.profraw
core.*
cscope*.out cscope*.out
tags tags
# License # License
Copyright (c) 2018-2020 Gavin D. Howard <yzena.tech@gmail.com> Copyright (c) 2018-2021 Gavin D. Howard <yzena.tech@gmail.com>
Redistribution and use in source and binary forms, with or without modification, Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met: are permitted provided that the following conditions are met:
...@@ -31,7 +31,7 @@ copyrights and license: ...@@ -31,7 +31,7 @@ copyrights and license:
Copyright (c) 2010-2014, Salvatore Sanfilippo <antirez at gmail dot com><br> Copyright (c) 2010-2014, Salvatore Sanfilippo <antirez at gmail dot com><br>
Copyright (c) 2010-2013, Pieter Noordhuis <pcnoordhuis at gmail dot com><br> Copyright (c) 2010-2013, Pieter Noordhuis <pcnoordhuis at gmail dot com><br>
Copyright (c) 2018 rain-1 <rain1@openmailbox.org><br> Copyright (c) 2018 rain-1 <rain1@openmailbox.org><br>
Copyright (c) 2018-2020, Gavin D. Howard <yzena.tech@gmail.com> Copyright (c) 2018-2021, Gavin D. Howard <yzena.tech@gmail.com>
Redistribution and use in source and binary forms, with or without modification, Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met: are permitted provided that the following conditions are met:
...@@ -53,3 +53,51 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ...@@ -53,3 +53,51 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
## Rand
The files `src/rand.c` and `include/rand.h` are under the following copyrights
and license:
Copyright (c) 2014-2017 Melissa O'Neill and PCG Project contributors
Copyright (c) 2018-2021 Gavin D. Howard <yzena.tech@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
## `safe-install.sh`
The file `safe-install.sh` is under the following copyright and license:
Copyright (c) 2021 Rich Felker
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# #
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: BSD-2-Clause
# #
# Copyright (c) 2018-2020 Gavin D. Howard and contributors. # Copyright (c) 2018-2021 Gavin D. Howard and contributors.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
# #
.POSIX: .POSIX:
VERSION = 3.2.4 VERSION = 3.2.6
SRC = %%SRC%% SRC = %%SRC%%
OBJ = %%OBJ%% OBJ = %%OBJ%%
...@@ -41,6 +41,13 @@ BC_ENABLED = %%BC_ENABLED%% ...@@ -41,6 +41,13 @@ BC_ENABLED = %%BC_ENABLED%%
DC_ENABLED_NAME = DC_ENABLED DC_ENABLED_NAME = DC_ENABLED
DC_ENABLED = %%DC_ENABLED%% DC_ENABLED = %%DC_ENABLED%%
HEADERS = include/args.h include/file.h include/lang.h include/lex.h include/num.h include/opt.h include/parse.h include/program.h include/read.h include/status.h include/vector.h include/vm.h
BC_HEADERS = include/bc.h
DC_HEADERS = include/dc.h
HISTORY_HEADERS = include/history.h
EXTRA_MATH_HEADERS = include/rand.h
LIBRARY_HEADERS = include/bcl.h include/library.h
GEN_DIR = gen GEN_DIR = gen
GEN = %%GEN%% GEN = %%GEN%%
GEN_EXEC = $(GEN_DIR)/$(GEN) GEN_EXEC = $(GEN_DIR)/$(GEN)
...@@ -82,6 +89,11 @@ DC = dc ...@@ -82,6 +89,11 @@ DC = dc
BC_EXEC = $(BIN)/$(EXEC_PREFIX)$(BC) BC_EXEC = $(BIN)/$(EXEC_PREFIX)$(BC)
DC_EXEC = $(BIN)/$(EXEC_PREFIX)$(DC) DC_EXEC = $(BIN)/$(EXEC_PREFIX)$(DC)
BC_TEST_OUTPUTS = tests/bc_outputs
BC_FUZZ_OUTPUTS = tests/fuzzing/bc_outputs1 tests/fuzzing/bc_outputs2 tests/fuzzing/bc_outputs3
DC_TEST_OUTPUTS = tests/dc_outputs
DC_FUZZ_OUTPUTS = tests/fuzzing/dc_outputs
LIB = libbcl LIB = libbcl
LIB_NAME = $(LIB).a LIB_NAME = $(LIB).a
LIBBC = $(BIN)/$(LIB_NAME) LIBBC = $(BIN)/$(LIB_NAME)
...@@ -125,6 +137,9 @@ BC_ENABLE_NLS = %%NLS%% ...@@ -125,6 +137,9 @@ BC_ENABLE_NLS = %%NLS%%
BC_ENABLE_PROMPT = %%PROMPT%% BC_ENABLE_PROMPT = %%PROMPT%%
BC_LONG_BIT = %%LONG_BIT%% BC_LONG_BIT = %%LONG_BIT%%
BC_ENABLE_AFL = %%FUZZ%%
BC_ENABLE_MEMCHECK = %%MEMCHECK%%
RM = rm RM = rm
MKDIR = mkdir MKDIR = mkdir
...@@ -138,6 +153,8 @@ LOCALE_UNINSTALL = ./locale_uninstall.sh ...@@ -138,6 +153,8 @@ LOCALE_UNINSTALL = ./locale_uninstall.sh
VALGRIND_ARGS = --error-exitcode=100 --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=all VALGRIND_ARGS = --error-exitcode=100 --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=all
TEST_STARS = "***********************************************************************"
BC_NUM_KARATSUBA_LEN = %%KARATSUBA_LEN%% BC_NUM_KARATSUBA_LEN = %%KARATSUBA_LEN%%
CPPFLAGS1 = -D$(BC_ENABLED_NAME)=$(BC_ENABLED) -D$(DC_ENABLED_NAME)=$(DC_ENABLED) CPPFLAGS1 = -D$(BC_ENABLED_NAME)=$(BC_ENABLED) -D$(DC_ENABLED_NAME)=$(DC_ENABLED)
...@@ -147,7 +164,8 @@ CPPFLAGS4 = $(CPPFLAGS3) -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 ...@@ -147,7 +164,8 @@ CPPFLAGS4 = $(CPPFLAGS3) -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700
CPPFLAGS5 = $(CPPFLAGS4) -DBC_NUM_KARATSUBA_LEN=$(BC_NUM_KARATSUBA_LEN) CPPFLAGS5 = $(CPPFLAGS4) -DBC_NUM_KARATSUBA_LEN=$(BC_NUM_KARATSUBA_LEN)
CPPFLAGS6 = $(CPPFLAGS5) -DBC_ENABLE_NLS=$(BC_ENABLE_NLS) -DBC_ENABLE_PROMPT=$(BC_ENABLE_PROMPT) 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) CPPFLAGS7 = $(CPPFLAGS6) -D$(BC_ENABLE_EXTRA_MATH_NAME)=$(BC_ENABLE_EXTRA_MATH)
CPPFLAGS = $(CPPFLAGS7) -DBC_ENABLE_HISTORY=$(BC_ENABLE_HISTORY) -DBC_ENABLE_LIBRARY=$(BC_ENABLE_LIBRARY) CPPFLAGS8 = $(CPPFLAGS7) -DBC_ENABLE_HISTORY=$(BC_ENABLE_HISTORY) -DBC_ENABLE_LIBRARY=$(BC_ENABLE_LIBRARY)
CPPFLAGS = $(CPPFLAGS8) -DBC_ENABLE_MEMCHECK=$(BC_ENABLE_MEMCHECK) -DBC_ENABLE_AFL=$(BC_ENABLE_AFL)
CFLAGS = $(CPPFLAGS) %%CPPFLAGS%% %%CFLAGS%% CFLAGS = $(CPPFLAGS) %%CPPFLAGS%% %%CFLAGS%%
LDFLAGS = %%LDFLAGS%% LDFLAGS = %%LDFLAGS%%
...@@ -159,20 +177,15 @@ HOSTCC = %%HOSTCC%% ...@@ -159,20 +177,15 @@ HOSTCC = %%HOSTCC%%
BC_LIB_C_ARGS = bc_lib bc_lib_name $(BC_ENABLED_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 BC_LIB2_C_ARGS = bc_lib2 bc_lib2_name "$(BC_ENABLED_NAME) && $(BC_ENABLE_EXTRA_MATH_NAME)" 1
OBJS = $(BC_HELP_O) $(DC_HELP_O) $(BC_LIB_O) $(BC_LIB2_O) $(OBJ) OBJS = $(DC_HELP_O) $(BC_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: all: %%DEFAULT_TARGET%%
$(CC) $(CFLAGS) -o $@ -c $<
all: %%ALL_PREREQ%%
execs: make_bin $(OBJ_TARGETS) %%DEFAULT_TARGET%%: %%DEFAULT_TARGET_PREREQS%%
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $(EXEC) %%DEFAULT_TARGET_CMD%%
%%LINK%%
library: make_bin $(OBJ) $(BC_LIB_O) $(BC_LIB2_O) %%SECOND_TARGET%%: %%SECOND_TARGET_PREREQS%%
ar -r -cu $(LIBBC) $(BC_LIB_O) $(BC_LIB2_O) $(OBJ) %%SECOND_TARGET_CMD%%
$(GEN_EXEC): $(GEN_EXEC):
%%GEN_EXEC_TARGET%% %%GEN_EXEC_TARGET%%
...@@ -180,18 +193,32 @@ $(GEN_EXEC): ...@@ -180,18 +193,32 @@ $(GEN_EXEC):
$(BC_LIB_C): $(GEN_EXEC) $(BC_LIB) $(BC_LIB_C): $(GEN_EXEC) $(BC_LIB)
$(GEN_EMU) $(GEN_EXEC) $(BC_LIB) $(BC_LIB_C) $(BC_LIB_C_ARGS) $(GEN_EMU) $(GEN_EXEC) $(BC_LIB) $(BC_LIB_C) $(BC_LIB_C_ARGS)
$(BC_LIB_O): $(BC_LIB_C)
$(CC) $(CFLAGS) -o $@ -c $<
$(BC_LIB2_C): $(GEN_EXEC) $(BC_LIB2) $(BC_LIB2_C): $(GEN_EXEC) $(BC_LIB2)
$(GEN_EMU) $(GEN_EXEC) $(BC_LIB2) $(BC_LIB2_C) $(BC_LIB2_C_ARGS) $(GEN_EMU) $(GEN_EXEC) $(BC_LIB2) $(BC_LIB2_C) $(BC_LIB2_C_ARGS)
$(BC_LIB2_O): $(BC_LIB2_C)
$(CC) $(CFLAGS) -o $@ -c $<
$(BC_HELP_C): $(GEN_EXEC) $(BC_HELP) $(BC_HELP_C): $(GEN_EXEC) $(BC_HELP)
$(GEN_EMU) $(GEN_EXEC) $(BC_HELP) $(BC_HELP_C) bc_help "" $(BC_ENABLED_NAME) $(GEN_EMU) $(GEN_EXEC) $(BC_HELP) $(BC_HELP_C) bc_help "" $(BC_ENABLED_NAME)
$(BC_HELP_O): $(BC_HELP_C)
$(CC) $(CFLAGS) -o $@ -c $<
$(DC_HELP_C): $(GEN_EXEC) $(DC_HELP) $(DC_HELP_C): $(GEN_EXEC) $(DC_HELP)
$(GEN_EMU) $(GEN_EXEC) $(DC_HELP) $(DC_HELP_C) dc_help "" $(DC_ENABLED_NAME) $(GEN_EMU) $(GEN_EXEC) $(DC_HELP) $(DC_HELP_C) dc_help "" $(DC_ENABLED_NAME)
make_bin: $(DC_HELP_O): $(DC_HELP_C)
$(CC) $(CFLAGS) -o $@ -c $<
$(BIN):
$(MKDIR) -p $(BIN) $(MKDIR) -p $(BIN)
headers: %%HEADERS%%
help: help:
@printf 'available targets:\n' @printf 'available targets:\n'
@printf '\n' @printf '\n'
...@@ -222,41 +249,68 @@ help: ...@@ -222,41 +249,68 @@ help:
@printf ' valgrind_dc runs the dc test suite, if dc has been built,\n' @printf ' valgrind_dc runs the dc test suite, if dc has been built,\n'
@printf ' through valgrind\n' @printf ' through valgrind\n'
run_all_tests:
%%BC_ALL_TESTS%%
%%TIMECONST_ALL_TESTS%%
%%DC_ALL_TESTS%%
check: test check: test
test: %%TESTS%% test: %%TESTS%%
test_bc: test_bc: test_bc_header test_bc_tests test_bc_scripts test_bc_stdin test_bc_read test_bc_errors test_bc_other
%%BC_TEST%% @printf '\nAll bc tests passed.\n\n$(TEST_STARS)\n'
test_bc_tests:%%BC_TESTS%%
test_bc_scripts:%%BC_SCRIPT_TESTS%%
test_bc_stdin:
@sh tests/stdin.sh bc %%BC_TEST_EXEC%%
test_bc_read:
@sh tests/read.sh bc %%BC_TEST_EXEC%%
test_bc_errors:
@sh tests/errors.sh bc %%BC_TEST_EXEC%%
test_bc_other:
@sh tests/other.sh bc %%BC_TEST_EXEC%%
test_bc_header:
@printf '$(TEST_STARS)\n\nRunning bc tests...\n\n'
test_dc: test_dc: test_dc_header test_dc_tests test_dc_scripts test_dc_stdin test_dc_read test_dc_errors test_dc_other
%%DC_TEST%% @printf '\nAll dc tests passed.\n\n$(TEST_STARS)\n'
time_test: time_test_bc timeconst time_test_dc test_dc_tests:%%DC_TESTS%%
time_test_bc: test_dc_scripts:%%DC_SCRIPT_TESTS%%
%%BC_TIME_TEST%%
time_test_dc: test_dc_stdin:
%%DC_TIME_TEST%% @sh tests/stdin.sh dc %%DC_TEST_EXEC%%
test_dc_read:
@sh tests/read.sh dc %%DC_TEST_EXEC%%
test_dc_errors:
@sh tests/errors.sh dc %%DC_TEST_EXEC%%
test_dc_other:
@sh tests/other.sh dc %%DC_TEST_EXEC%%
test_dc_header:
@printf '$(TEST_STARS)\n\nRunning dc tests...\n\n'
timeconst: timeconst:
%%TIMECONST%% %%TIMECONST%%
library_test: library library_test: $(LIBBC)
$(CC) $(CFLAGS) $(BCL_TEST_C) $(LIBBC) -o $(BCL_TEST) $(CC) $(CFLAGS) $(BCL_TEST_C) $(LIBBC) -o $(BCL_TEST)
test_library: library_test test_library: library_test
$(BCL_TEST) $(BCL_TEST)
valgrind: valgrind_bc valgrind_dc
valgrind_bc:
%%VG_BC_TEST%%
valgrind_dc:
%%VG_DC_TEST%%
karatsuba: karatsuba:
%%KARATSUBA%% %%KARATSUBA%%
...@@ -296,6 +350,8 @@ clean:%%CLEAN_PREREQS%% ...@@ -296,6 +350,8 @@ clean:%%CLEAN_PREREQS%%
@$(RM) -f $(BC_LIB2_C) $(BC_LIB2_O) @$(RM) -f $(BC_LIB2_C) $(BC_LIB2_O)
@$(RM) -f $(BC_HELP_C) $(BC_HELP_O) @$(RM) -f $(BC_HELP_C) $(BC_HELP_O)
@$(RM) -f $(DC_HELP_C) $(DC_HELP_O) @$(RM) -f $(DC_HELP_C) $(DC_HELP_O)
@$(RM) -fr $(BC_TEST_OUTPUTS) $(DC_TEST_OUTPUTS)
@$(RM) -fr $(BC_FUZZ_OUTPUTS) $(DC_FUZZ_OUTPUTS)
clean_config: clean clean_config: clean
@printf 'Cleaning config...\n' @printf 'Cleaning config...\n'
......
# News # News
## 3.2.6
This is a production release that fixes the build on FreeBSD.
There was a syntax error in `configure.sh` that the Linux shell did not catch,
and FreeBSD depends on the existence of `tests/all.sh`.
All users that already upgraded to `3.2.5` should update to this release, with
my apologies for the poor release of `3.2.5`. Other users should skip `3.2.5` in
favor of this version.
## 3.2.5
This is a production release that fixes several bugs and adds a couple small
things.
The two most important bugs were bugs that causes `dc` to access memory
out-of-bounds (crash in debug builds). This was found by upgrading to `afl++`
from `afl`. Both were caused by a failure to distinguish between the same two
cases.
Another bug was the failure to put all of the licenses in the `LICENSE.md` file.
Third, some warnings by `scan-build` were found and eliminated. This needed one
big change: `bc` and `dc` now bail out as fast as possible on fatal errors
instead of unwinding the stack.
Fourth, the pseudo-random number now attempts to seed itself with `/dev/random`
if `/dev/urandom` fails.
Finally, this release has a few quality-of-life changes to the build system. The
usage should not change at all; the only thing that changed was making sure the
`Makefile.in` was written to rebuild properly when headers changed and to not
rebuild when not necessary.
## 3.2.4 ## 3.2.4
This is a production release that fixes a warning on `gcc` 6 or older, which This is a production release that fixes a warning on `gcc` 6 or older, which
......
# Notice # Notice
Copyright 2018-2020 Gavin D. Howard and contributors. Copyright 2018-2021 Gavin D. Howard and contributors.
## Contributors ## Contributors
......
...@@ -39,6 +39,7 @@ Systems that are known to work: ...@@ -39,6 +39,7 @@ Systems that are known to work:
* Mac OSX * Mac OSX
* Solaris* (as long as the Solaris version supports POSIX 2008) * Solaris* (as long as the Solaris version supports POSIX 2008)
* AIX * AIX
* HP-UX* (except for history)
Please submit bug reports if this `bc` does not build out of the box on any Please submit bug reports if this `bc` does not build out of the box on any
system besides Windows. If Windows binaries are needed, they can be found at system besides Windows. If Windows binaries are needed, they can be found at
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# #
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: BSD-2-Clause
# #
# Copyright (c) 2018-2020 Gavin D. Howard and contributors. # Copyright (c) 2018-2021 Gavin D. Howard and contributors.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:
...@@ -33,6 +33,8 @@ script=$(basename "$script") ...@@ -33,6 +33,8 @@ script=$(basename "$script")
. "$scriptdir/functions.sh" . "$scriptdir/functions.sh"
cd "$scriptdir"
usage() { usage() {
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then
...@@ -48,7 +50,7 @@ usage() { ...@@ -48,7 +50,7 @@ usage() {
printf 'usage:\n' printf 'usage:\n'
printf ' %s -h\n' "$script" printf ' %s -h\n' "$script"
printf ' %s --help\n' "$script" printf ' %s --help\n' "$script"
printf ' %s [-a|-bD|-dB|-c] [-EfgGHlMNPT] [-O OPT_LEVEL] [-k KARATSUBA_LEN]\n' "$script" printf ' %s [-a|-bD|-dB|-c] [-CEfgGHlmMNPtTvz] [-O OPT_LEVEL] [-k KARATSUBA_LEN]\n' "$script"
printf ' %s \\\n' "$script" printf ' %s \\\n' "$script"
printf ' [--library|--bc-only --disable-dc|--dc-only --disable-bc|--coverage]\\\n' printf ' [--library|--bc-only --disable-dc|--dc-only --disable-bc|--coverage]\\\n'
printf ' [--force --debug --disable-extra-math --disable-generated-tests] \\\n' printf ' [--force --debug --disable-extra-math --disable-generated-tests] \\\n'
...@@ -73,6 +75,8 @@ usage() { ...@@ -73,6 +75,8 @@ usage() {
printf ' Generate test coverage code. Requires gcov and regcovr.\n' printf ' Generate test coverage code. Requires gcov and regcovr.\n'
printf ' It is an error if either "-b" ("-D") or "-d" ("-B") is specified.\n' 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 ' Requires a compiler that use gcc-compatible coverage options\n'
printf ' -C, --disable-clean\n'
printf ' Disable the clean that configure.sh does before configure.\n'
printf ' -d, --dc-only\n' printf ' -d, --dc-only\n'
printf ' Build dc only. It is an error if "-b", "--bc-only", "-D", or\n' printf ' Build dc only. It is an error if "-b", "--bc-only", "-D", or\n'
printf ' "--disable-dc" are specified too.\n' printf ' "--disable-dc" are specified too.\n'
...@@ -107,6 +111,8 @@ usage() { ...@@ -107,6 +111,8 @@ usage() {
printf ' Installs all locales, regardless of how many are on the system. This\n' printf ' Installs all locales, regardless of how many are on the system. This\n'
printf ' option is useful for package maintainers who want to make sure that\n' printf ' option is useful for package maintainers who want to make sure that\n'
printf ' a package contains all of the locales that end users might need.\n' printf ' a package contains all of the locales that end users might need.\n'
printf ' -m, --enable-memcheck\n'
printf ' Enable memcheck mode, to ensure no memory leaks. For development only.\n'
printf ' -M, --disable-man-pages\n' printf ' -M, --disable-man-pages\n'
printf ' Disable installing manpages.\n' printf ' Disable installing manpages.\n'
printf ' -N, --disable-nls\n' printf ' -N, --disable-nls\n'
...@@ -119,9 +125,15 @@ usage() { ...@@ -119,9 +125,15 @@ usage() {
printf ' Disables the prompt in the built bc. The prompt will never show up,\n' printf ' Disables the prompt in the built bc. The prompt will never show up,\n'
printf ' or in other words, it will be permanently disabled and cannot be\n' printf ' or in other words, it will be permanently disabled and cannot be\n'
printf ' enabled.\n' printf ' enabled.\n'
printf ' -t, --enable-test-timing\n'
printf ' Enable the timing of tests. This is for development only.\n'
printf ' -T, --disable-strip\n' printf ' -T, --disable-strip\n'
printf ' Disable stripping symbols from the compiled binary or binaries.\n' printf ' Disable stripping symbols from the compiled binary or binaries.\n'
printf ' Stripping symbols only happens when debug mode is off.\n' printf ' Stripping symbols only happens when debug mode is off.\n'
printf ' -v, --enable-valgrind\n'
printf ' Enable a build appropriate for valgrind. For development only.\n'
printf ' -z, --enable-fuzz-mode\n'
printf ' Enable fuzzing mode. THIS IS FOR DEVELOPMENT ONLY.\n'
printf ' --prefix PREFIX\n' printf ' --prefix PREFIX\n'
printf ' The prefix to install to. Overrides "$PREFIX" if it exists.\n' printf ' The prefix to install to. Overrides "$PREFIX" if it exists.\n'
printf ' If PREFIX is "/usr", install path will be "/usr/bin".\n' printf ' If PREFIX is "/usr", install path will be "/usr/bin".\n'
...@@ -277,6 +289,23 @@ replace() { ...@@ -277,6 +289,23 @@ replace() {
substring_replace "$_replace_str" "%%$_replace_needle%%" "$_replace_replacement" substring_replace "$_replace_str" "%%$_replace_needle%%" "$_replace_replacement"
} }
find_src_files() {
if [ "$#" -ge 1 ] && [ "$1" != "" ]; then
while [ "$#" -ge 1 ]; do
_find_src_files_a="${1## }"
shift
_find_src_files_args="$_find_src_files_args ! -path src/${_find_src_files_a}"
done
else
_find_src_files_args="-print"
fi
printf '%s\n' $(find src/ -depth -name "*.c" $_find_src_files_args)
}
gen_file_list() { gen_file_list() {
if [ "$#" -lt 1 ]; then if [ "$#" -lt 1 ]; then
...@@ -291,15 +320,9 @@ gen_file_list() { ...@@ -291,15 +320,9 @@ gen_file_list() {
cd "$scriptdir" cd "$scriptdir"
if [ "$#" -ge 1 ]; then if [ "$#" -ge 1 ]; then
_gen_file_list_unneeded="$@"
while [ "$#" -ge 1 ]; do
a="$1"
shift
args="$args ! -path src/${a}"
done
else else
args="-print" _gen_file_list_unneeded=""
fi fi
_gen_file_list_needle_src="SRC" _gen_file_list_needle_src="SRC"
...@@ -307,7 +330,7 @@ gen_file_list() { ...@@ -307,7 +330,7 @@ gen_file_list() {
_gen_file_list_needle_gcda="GCDA" _gen_file_list_needle_gcda="GCDA"
_gen_file_list_needle_gcno="GCNO" _gen_file_list_needle_gcno="GCNO"
_gen_file_list_replacement=$(find src/ -depth -name "*.c" $args | tr '\n' ' ') _gen_file_list_replacement=$(find_src_files $_gen_file_list_unneeded | tr '\n' ' ')
_gen_file_list_contents=$(replace "$_gen_file_list_contents" \ _gen_file_list_contents=$(replace "$_gen_file_list_contents" \
"$_gen_file_list_needle_src" "$_gen_file_list_replacement") "$_gen_file_list_needle_src" "$_gen_file_list_replacement")
...@@ -328,6 +351,101 @@ gen_file_list() { ...@@ -328,6 +351,101 @@ gen_file_list() {
printf '%s\n' "$_gen_file_list_contents" printf '%s\n' "$_gen_file_list_contents"
} }
gen_tests() {
_gen_tests_name="$1"
shift
_gen_tests_uname="$1"
shift
_gen_tests_extra_math="$1"
shift