From 44d4804d1945435745518cd09eb8ae6ab22ecef4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20E=C3=9Fer?= Date: Tue, 10 Aug 2021 10:42:54 +0200 Subject: [PATCH] =?UTF-8?q?usr.bin/gh=C3=A4-bc,=20contrib/bc:=20update=20t?= =?UTF-8?q?o=20version=205.0.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge commit 2f57ecae4b98e76e5d675563785a7e6c59c868c4 This is a new major release with a number of changes and extensions: - Limited the number of temporary numbers and made the space for them static so that allocating more space for them cannot fail. - Allowed integers with non-zero scale to be used with power, places, and shift operators. - Added greatest common divisor and least common multiple to lib2.bc. - Made bc and dc UTF-8 capable. - Added the ability for users to have bc and dc quit on SIGINT. - Added the ability for users to disable prompt and TTY mode by environment variables. - Added the ability for users to redefine keywords. - Added dc's modular exponentiation and divmod to bc. - Added the ability to assign strings to variables and array elements and pass them to functions in bc. - Added dc's asciify command and stream printing to bc. - Added bitwise and, or, xor, left shift, right shift, reverse, left rotate, right rotate, and mod functions to lib2.bc. - Added the functions s2u(x) and s2un(x,n), to lib2.bc. MFC after: 1 week --- contrib/bc/.gitattributes | 2 +- contrib/bc/.gitignore | 8 +- contrib/bc/LICENSE.md | 14 +- contrib/bc/Makefile.in | 217 +- contrib/bc/NEWS.md | 61 +- contrib/bc/README.md | 50 +- contrib/bc/RELEASE.md | 54 - contrib/bc/bc.vcxproj | 80 +- contrib/bc/bcl.vcxproj | 24 +- contrib/bc/benchmarks/bc/add.bc | 21 + .../bc.dict => benchmarks/bc/arrays.bc} | 44 +- .../bc/benchmarks/bc/arrays_and_constants.bc | 35 + contrib/bc/benchmarks/bc/bitfuncs.bc | 18 + .../diff.sh => benchmarks/bc/constants.bc} | 30 +- contrib/bc/benchmarks/bc/divide.bc | 26 + contrib/bc/benchmarks/bc/functions.bc | 34 + contrib/bc/benchmarks/bc/irand_long.bc | 9 + contrib/bc/benchmarks/bc/irand_short.bc | 5 + contrib/bc/benchmarks/bc/lib.bc | 7 + contrib/bc/benchmarks/bc/multiply.bc | 23 + contrib/bc/benchmarks/bc/postfix_incdec.bc | 7 + contrib/bc/benchmarks/bc/power.bc | 2 + contrib/bc/benchmarks/bc/strings.bc | 36 + contrib/bc/benchmarks/bc/subtract.bc | 22 + contrib/bc/benchmarks/dc/modexp.dc | 42 + contrib/bc/configure | 1322 +--- contrib/bc/configure.sh | 383 +- contrib/bc/gen/bc_help.txt | 52 + contrib/bc/gen/dc_help.txt | 30 + contrib/bc/gen/lib.bc | 2 +- contrib/bc/gen/lib2.bc | 247 +- contrib/bc/gen/strgen.c | 112 +- contrib/bc/gen/strgen.sh | 3 + contrib/bc/include/args.h | 11 +- contrib/bc/include/bc.h | 302 +- contrib/bc/include/bcl.h | 147 +- contrib/bc/include/dc.h | 42 +- contrib/bc/include/file.h | 88 + contrib/bc/include/history.h | 106 +- contrib/bc/include/lang.h | 464 +- contrib/bc/include/lex.h | 364 +- contrib/bc/include/library.h | 90 +- contrib/bc/include/num.h | 652 +- contrib/bc/include/opt.h | 61 + contrib/bc/include/parse.h | 188 +- contrib/bc/include/program.h | 814 ++- contrib/bc/include/rand.h | 328 +- contrib/bc/include/read.h | 44 +- contrib/bc/include/status.h | 642 +- contrib/bc/include/vector.h | 378 +- contrib/bc/include/version.h | 5 +- contrib/bc/include/vm.h | 682 ++- contrib/bc/locales/de_DE.ISO8859-1.msg | 13 +- contrib/bc/locales/de_DE.UTF-8.msg | 13 +- contrib/bc/locales/en_US.msg | 13 +- contrib/bc/locales/es_ES.ISO8859-1.msg | 13 +- contrib/bc/locales/es_ES.UTF-8.msg | 13 +- contrib/bc/locales/fr_FR.ISO8859-1.msg | 13 +- contrib/bc/locales/fr_FR.UTF-8.msg | 13 +- contrib/bc/locales/ja_JP.UTF-8.msg | 32 +- contrib/bc/locales/ja_JP.eucJP.msg | 32 +- contrib/bc/locales/nl_NL.ISO8859-1.msg | 22 +- contrib/bc/locales/nl_NL.UTF-8.msg | 22 +- contrib/bc/locales/pl_PL.ISO8859-2.msg | 22 +- contrib/bc/locales/pl_PL.UTF-8.msg | 22 +- contrib/bc/locales/pt_PT.ISO8859-1.msg | 13 +- contrib/bc/locales/pt_PT.UTF-8.msg | 13 +- contrib/bc/locales/ru_RU.CP1251.msg | 22 +- contrib/bc/locales/ru_RU.CP866.msg | 22 +- contrib/bc/locales/ru_RU.ISO8859-5.msg | 22 +- contrib/bc/locales/ru_RU.KOI8-R.msg | 15 +- contrib/bc/locales/ru_RU.UTF-8.msg | 22 +- contrib/bc/locales/zh_CN.GB18030.msg | 17 +- contrib/bc/locales/zh_CN.GB2312.msg | 17 +- contrib/bc/locales/zh_CN.GBK.msg | 17 +- contrib/bc/locales/zh_CN.UTF-8.msg | 15 +- contrib/bc/locales/zh_CN.eucCN.msg | 17 +- contrib/bc/manpage.sh | 131 - contrib/bc/manuals/algorithms.md | 162 +- contrib/bc/manuals/bc.1.md.in | 1840 ------ contrib/bc/manuals/bc/A.1 | 2567 ++++---- contrib/bc/manuals/bc/A.1.md | 663 +- contrib/bc/manuals/bc/E.1 | 1281 ++-- contrib/bc/manuals/bc/E.1.md | 324 +- contrib/bc/manuals/bc/EH.1 | 1252 ++-- contrib/bc/manuals/bc/EH.1.md | 296 +- contrib/bc/manuals/bc/EHN.1 | 1252 ++-- contrib/bc/manuals/bc/EHN.1.md | 296 +- contrib/bc/manuals/bc/EHNP.1 | 1375 ----- contrib/bc/manuals/bc/EHNP.1.md | 1069 ---- contrib/bc/manuals/bc/EHP.1 | 1382 ----- contrib/bc/manuals/bc/EHP.1.md | 1077 ---- contrib/bc/manuals/bc/EN.1 | 1281 ++-- contrib/bc/manuals/bc/EN.1.md | 324 +- contrib/bc/manuals/bc/ENP.1 | 1393 ----- contrib/bc/manuals/bc/ENP.1.md | 1085 ---- contrib/bc/manuals/bc/EP.1 | 1400 ----- contrib/bc/manuals/bc/EP.1.md | 1093 ---- contrib/bc/manuals/bc/H.1 | 2540 ++++---- contrib/bc/manuals/bc/H.1.md | 640 +- contrib/bc/manuals/bc/HN.1 | 2540 ++++---- contrib/bc/manuals/bc/HN.1.md | 640 +- contrib/bc/manuals/bc/HNP.1 | 2223 ------- contrib/bc/manuals/bc/HNP.1.md | 1679 ----- contrib/bc/manuals/bc/HP.1 | 2230 ------- contrib/bc/manuals/bc/HP.1.md | 1687 ----- contrib/bc/manuals/bc/N.1 | 2567 ++++---- contrib/bc/manuals/bc/N.1.md | 663 +- contrib/bc/manuals/bc/NP.1 | 2243 ------- contrib/bc/manuals/bc/NP.1.md | 1696 ------ contrib/bc/manuals/bc/P.1 | 2250 ------- contrib/bc/manuals/bc/P.1.md | 1704 ------ contrib/bc/manuals/bcl.3 | 1749 +++--- contrib/bc/manuals/bcl.3.md | 253 +- contrib/bc/manuals/benchmarks.md | 673 -- contrib/bc/manuals/build.md | 207 +- contrib/bc/manuals/dc.1.md.in | 1289 ---- contrib/bc/manuals/dc/A.1 | 1592 +++-- contrib/bc/manuals/dc/A.1.md | 235 +- contrib/bc/manuals/dc/E.1 | 1400 +++-- contrib/bc/manuals/dc/E.1.md | 235 +- contrib/bc/manuals/dc/EH.1 | 1371 ++--- contrib/bc/manuals/dc/EH.1.md | 211 +- contrib/bc/manuals/dc/EHN.1 | 1369 ++--- contrib/bc/manuals/dc/EHN.1.md | 209 +- contrib/bc/manuals/dc/EHNP.1 | 1307 ---- contrib/bc/manuals/dc/EHNP.1.md | 1023 ---- contrib/bc/manuals/dc/EHP.1 | 1311 ---- contrib/bc/manuals/dc/EHP.1.md | 1028 ---- contrib/bc/manuals/dc/EN.1 | 1398 +++-- contrib/bc/manuals/dc/EN.1.md | 233 +- contrib/bc/manuals/dc/ENP.1 | 1322 ---- contrib/bc/manuals/dc/ENP.1.md | 1036 ---- contrib/bc/manuals/dc/EP.1 | 1326 ---- contrib/bc/manuals/dc/EP.1.md | 1041 ---- contrib/bc/manuals/dc/H.1 | 1563 +++-- contrib/bc/manuals/dc/H.1.md | 211 +- contrib/bc/manuals/dc/HN.1 | 1561 +++-- contrib/bc/manuals/dc/HN.1.md | 209 +- contrib/bc/manuals/dc/HNP.1 | 1536 ----- contrib/bc/manuals/dc/HNP.1.md | 1190 ---- contrib/bc/manuals/dc/HP.1 | 1540 ----- contrib/bc/manuals/dc/HP.1.md | 1195 ---- contrib/bc/manuals/dc/N.1 | 1590 +++-- contrib/bc/manuals/dc/N.1.md | 233 +- contrib/bc/manuals/dc/NP.1 | 1551 ----- contrib/bc/manuals/dc/NP.1.md | 1203 ---- contrib/bc/manuals/dc/P.1 | 1555 ----- contrib/bc/manuals/dc/P.1.md | 1208 ---- contrib/bc/manuals/development.md | 4950 +++++++++++++++ contrib/bc/manuals/header.txt | 27 - contrib/bc/manuals/header_bc.txt | 1 - contrib/bc/manuals/header_bcl.txt | 1 - contrib/bc/manuals/header_dc.txt | 1 - contrib/bc/manuals/release.md | 72 + contrib/bc/{tests => scripts}/afl.py | 79 +- contrib/bc/scripts/alloc.sh | 84 + contrib/bc/scripts/benchmark.sh | 159 + contrib/bc/scripts/bitgen.c | 101 + contrib/bc/{ => scripts}/exec-install.sh | 6 +- contrib/bc/{ => scripts}/functions.sh | 68 +- contrib/bc/scripts/fuzz_prep.sh | 81 + contrib/bc/{ => scripts}/karatsuba.py | 29 +- contrib/bc/{ => scripts}/link.sh | 5 +- contrib/bc/{ => scripts}/locale_install.sh | 53 +- contrib/bc/{ => scripts}/locale_uninstall.sh | 1 + contrib/bc/scripts/manpage.sh | 175 + contrib/bc/scripts/ministat.c | 670 ++ contrib/bc/scripts/package.sh | 173 + contrib/bc/{tests => scripts}/radamsa.sh | 29 +- contrib/bc/{tests => scripts}/radamsa.txt | 0 contrib/bc/{tests => scripts}/randmath.py | 161 +- contrib/bc/{ => scripts}/release.sh | 290 +- contrib/bc/scripts/release_settings.txt | 16 + contrib/bc/{ => scripts}/safe-install.sh | 0 contrib/bc/scripts/test_settings.sh | 77 + contrib/bc/scripts/test_settings.txt | 93 + contrib/bc/src/args.c | 118 +- contrib/bc/src/bc.c | 11 +- contrib/bc/src/bc_lex.c | 84 +- contrib/bc/src/bc_parse.c | 866 ++- contrib/bc/src/data.c | 447 +- contrib/bc/src/dc.c | 11 +- contrib/bc/src/dc_lex.c | 91 +- contrib/bc/src/dc_parse.c | 93 +- contrib/bc/src/file.c | 63 +- contrib/bc/src/history.c | 680 ++- contrib/bc/src/lang.c | 133 +- contrib/bc/src/lex.c | 123 +- contrib/bc/src/library.c | 172 +- contrib/bc/src/main.c | 13 +- contrib/bc/src/num.c | 1585 ++++- contrib/bc/src/opt.c | 129 +- contrib/bc/src/parse.c | 83 +- contrib/bc/src/program.c | 1931 ++++-- contrib/bc/src/rand.c | 185 +- contrib/bc/src/read.c | 87 +- contrib/bc/src/vector.c | 302 +- contrib/bc/src/vm.c | 711 ++- contrib/bc/tests/all.sh | 26 +- contrib/bc/tests/bc/all.txt | 9 +- contrib/bc/tests/bc/bitfuncs.txt | 5400 +++++++++++++++++ contrib/bc/tests/bc/bitfuncs_results.txt | 5400 +++++++++++++++++ contrib/bc/tests/bc/decimal.txt | 4 + contrib/bc/tests/bc/decimal_results.txt | 9 +- contrib/bc/tests/bc/divmod.txt | 64 + contrib/bc/tests/bc/divmod_results.txt | 126 + contrib/bc/tests/bc/errors.txt | 48 +- contrib/bc/tests/bc/errors/25.txt | 4 + contrib/bc/tests/bc/errors/26.txt | Bin 0 -> 317 bytes contrib/bc/tests/bc/errors/27.txt | 1 + contrib/bc/tests/bc/errors/28.txt | 2 + contrib/bc/tests/bc/errors/29.txt | 20 + contrib/bc/tests/bc/errors/30.txt | 3 + contrib/bc/tests/bc/errors/31.txt | 3 + contrib/bc/tests/bc/errors/32.txt | Bin 0 -> 1701 bytes contrib/bc/tests/bc/lib2.txt | 7 + contrib/bc/tests/bc/lib2_results.txt | 7 + contrib/bc/tests/bc/modexp.txt | 103 + contrib/bc/tests/bc/modexp_results.txt | 103 + contrib/bc/tests/bc/pi_results.txt | 3 +- contrib/bc/tests/bc/posix_errors.txt | 1 + contrib/bc/tests/bc/power.txt | 43 + contrib/bc/tests/bc/power_results.txt | 72 + contrib/bc/tests/bc/recursive_arrays.txt | 353 ++ .../bc/tests/bc/recursive_arrays_results.txt | 1 + contrib/bc/tests/bc/scripts/add.bc | 2 +- contrib/bc/tests/bc/scripts/all.txt | 9 +- contrib/bc/tests/bc/scripts/array.bc | 0 contrib/bc/tests/bc/scripts/atan.bc | 0 contrib/bc/tests/bc/scripts/bessel.bc | 0 contrib/bc/tests/bc/scripts/divide.bc | 1 + contrib/bc/tests/bc/scripts/globals.bc | 0 contrib/bc/tests/bc/scripts/multiply.bc | 1 + contrib/bc/tests/bc/scripts/parse.bc | 0 contrib/bc/tests/bc/scripts/print.bc | 0 contrib/bc/tests/bc/scripts/references.bc | 0 contrib/bc/tests/bc/scripts/screen.bc | 0 contrib/bc/tests/bc/scripts/strings2.bc | 7 + contrib/bc/tests/bc/scripts/subtract.bc | 2 +- contrib/bc/tests/bc/strings.txt | 61 + contrib/bc/tests/bc/strings_results.txt | 45 + contrib/bc/tests/bc/timeconst.sh | 22 +- contrib/bc/tests/bc/vars_results.txt | 3 +- contrib/bc/tests/bcl.c | 64 +- contrib/bc/tests/dc/all.txt | 2 + contrib/bc/tests/dc/decimal.txt | 5 + contrib/bc/tests/dc/decimal_results.txt | 11 +- contrib/bc/tests/dc/errors.txt | 4 + .../dc_inputs/17.txt => dc/errors/32.txt} | 2 +- contrib/bc/tests/dc/errors/33.txt | Bin 0 -> 329 bytes .../dc_inputs/26.txt => dc/errors/34.txt} | 104 +- contrib/bc/tests/dc/exec_stack_len.txt | 6 + .../bc/tests/dc/exec_stack_len_results.txt | 8 + contrib/bc/tests/dc/length.txt | 2 + contrib/bc/tests/dc/length_results.txt | 2 + contrib/bc/tests/dc/scientific.txt | 4 + contrib/bc/tests/dc/scientific_results.txt | 4 + contrib/bc/tests/dc/scripts/array.dc | 0 contrib/bc/tests/dc/scripts/asciify.dc | 0 contrib/bc/tests/dc/scripts/easter.sh | 4 +- contrib/bc/tests/dc/scripts/else.dc | 0 contrib/bc/tests/dc/scripts/factorial.dc | 0 contrib/bc/tests/dc/scripts/loop.dc | 0 contrib/bc/tests/dc/scripts/prime.dc | 0 contrib/bc/tests/dc/scripts/quit.dc | 0 contrib/bc/tests/dc/scripts/stream.dc | 2 +- contrib/bc/tests/dc/scripts/stream.txt | Bin 0 -> 130834 bytes contrib/bc/tests/dc/scripts/weird.dc | 0 contrib/bc/tests/dc/stack_len.txt | 15 + contrib/bc/tests/dc/stack_len_results.txt | 10 + contrib/bc/tests/dc/strings.txt | 1 + contrib/bc/tests/dc/strings_results.txt | 1 + contrib/bc/tests/errors.sh | 54 +- contrib/bc/tests/extra_required.txt | 1 + contrib/bc/tests/fuzzing/bc_afl.yaml | 125 + contrib/bc/tests/fuzzing/bc_afl_continue.yaml | 122 + contrib/bc/tests/fuzzing/bc_inputs1/abs.txt | 7 - contrib/bc/tests/fuzzing/bc_inputs1/add.txt | 146 - .../tests/fuzzing/bc_inputs1/arctangent.txt | 26 - contrib/bc/tests/fuzzing/bc_inputs1/array.bc | 60 - .../bc/tests/fuzzing/bc_inputs1/arrays.txt | 10 - .../tests/fuzzing/bc_inputs1/assignments.txt | 122 - contrib/bc/tests/fuzzing/bc_inputs1/basic.txt | 7 - .../bc/tests/fuzzing/bc_inputs1/boolean.txt | 184 - .../bc/tests/fuzzing/bc_inputs1/cosine.txt | 44 - .../bc/tests/fuzzing/bc_inputs1/decimal.txt | 35 - .../bc/tests/fuzzing/bc_inputs1/divide.txt | 31 - .../tests/fuzzing/bc_inputs1/engineering.txt | 19 - .../bc/tests/fuzzing/bc_inputs1/exponent.txt | 22 - .../bc/tests/fuzzing/bc_inputs1/functions.bc | 7 - .../bc/tests/fuzzing/bc_inputs1/functions.txt | 13 - .../bc/tests/fuzzing/bc_inputs1/globals.txt | 21 - contrib/bc/tests/fuzzing/bc_inputs1/len.bc | 48 - .../bc/tests/fuzzing/bc_inputs1/length.txt | 59 - contrib/bc/tests/fuzzing/bc_inputs1/lib10.txt | 4 - contrib/bc/tests/fuzzing/bc_inputs1/lib11.txt | 4 - contrib/bc/tests/fuzzing/bc_inputs1/lib12.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs1/lib2.txt | 15 - contrib/bc/tests/fuzzing/bc_inputs1/lib3.txt | 6 - contrib/bc/tests/fuzzing/bc_inputs1/lib4.txt | 10 - contrib/bc/tests/fuzzing/bc_inputs1/lib5.txt | 2 - contrib/bc/tests/fuzzing/bc_inputs1/lib6.txt | 5 - contrib/bc/tests/fuzzing/bc_inputs1/lib7.txt | 12 - contrib/bc/tests/fuzzing/bc_inputs1/lib8.txt | 3 - .../bc/tests/fuzzing/bc_inputs1/strings.txt | 14 + contrib/bc/tests/fuzzing/bc_inputs2/lib13.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib14.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib15.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib16.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib19.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib20.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib21.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib22.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib23.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib24.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/log.txt | 22 - contrib/bc/tests/fuzzing/bc_inputs2/misc.txt | 13 - contrib/bc/tests/fuzzing/bc_inputs2/misc1.txt | 76 - contrib/bc/tests/fuzzing/bc_inputs2/misc2.txt | 110 - contrib/bc/tests/fuzzing/bc_inputs2/misc3.txt | 12 - .../bc/tests/fuzzing/bc_inputs2/modulus.txt | 69 - .../bc/tests/fuzzing/bc_inputs2/multiply.txt | 40 - contrib/bc/tests/fuzzing/bc_inputs2/pi.txt | 4 - .../bc/tests/fuzzing/bc_inputs2/places.txt | 19 - contrib/bc/tests/fuzzing/bc_inputs2/power.txt | 44 - .../bc/tests/fuzzing/bc_inputs2/print2.txt | 194 - .../bc/tests/fuzzing/bc_inputs2/references.bc | 408 -- contrib/bc/tests/fuzzing/bc_inputs2/scale.txt | 57 - .../tests/fuzzing/bc_inputs2/scientific.txt | 51 - contrib/bc/tests/fuzzing/bc_inputs2/shift.txt | 281 - contrib/bc/tests/fuzzing/bc_inputs2/sine.txt | 207 - contrib/bc/tests/fuzzing/bc_inputs3/01.txt | 339 -- contrib/bc/tests/fuzzing/bc_inputs3/02.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/03.txt | 2 - contrib/bc/tests/fuzzing/bc_inputs3/04.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/05.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/06.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/07.txt | 8 - contrib/bc/tests/fuzzing/bc_inputs3/08.txt | 3 - contrib/bc/tests/fuzzing/bc_inputs3/09.txt | 11 - contrib/bc/tests/fuzzing/bc_inputs3/10.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/11.txt | 99 - contrib/bc/tests/fuzzing/bc_inputs3/12.txt | 2 - contrib/bc/tests/fuzzing/bc_inputs3/13.txt | 56 - contrib/bc/tests/fuzzing/bc_inputs3/14.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/15.txt | 3 - contrib/bc/tests/fuzzing/bc_inputs3/16.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/17.txt | 11 - contrib/bc/tests/fuzzing/bc_inputs3/18.txt | 3 - contrib/bc/tests/fuzzing/bc_inputs3/19.txt | 5 - contrib/bc/tests/fuzzing/bc_inputs3/20.txt | 51 - contrib/bc/tests/fuzzing/bc_inputs3/21.txt | 10 - contrib/bc/tests/fuzzing/bc_inputs3/22.txt | 2 - contrib/bc/tests/fuzzing/bc_inputs3/23.txt | Bin 1024 -> 0 bytes contrib/bc/tests/fuzzing/bc_inputs3/24.txt | 4 - contrib/bc/tests/fuzzing/bc_inputs3/sqrt.txt | 14 - .../bc/tests/fuzzing/bc_inputs3/strings.txt | 12 - .../bc/tests/fuzzing/bc_inputs3/subtract.txt | 153 - contrib/bc/tests/fuzzing/bc_inputs3/trunc.txt | 15 - contrib/bc/tests/fuzzing/bc_inputs3/void.txt | 20 - contrib/bc/tests/fuzzing/dc_inputs/01.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/02.txt | 5 - contrib/bc/tests/fuzzing/dc_inputs/03.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/04.txt | 9 - contrib/bc/tests/fuzzing/dc_inputs/05.txt | 3 - contrib/bc/tests/fuzzing/dc_inputs/06.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/07.txt | 3 - contrib/bc/tests/fuzzing/dc_inputs/08.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/09.txt | 9 - contrib/bc/tests/fuzzing/dc_inputs/10.txt | 11 - contrib/bc/tests/fuzzing/dc_inputs/11.txt | 4 - contrib/bc/tests/fuzzing/dc_inputs/12.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/13.txt | 7 - contrib/bc/tests/fuzzing/dc_inputs/14.txt | 7 - contrib/bc/tests/fuzzing/dc_inputs/15.txt | 11 - contrib/bc/tests/fuzzing/dc_inputs/16.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/18.txt | 3 - contrib/bc/tests/fuzzing/dc_inputs/19.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/20.txt | 3 - contrib/bc/tests/fuzzing/dc_inputs/21.txt | 5 - contrib/bc/tests/fuzzing/dc_inputs/22.txt | 36 - contrib/bc/tests/fuzzing/dc_inputs/23.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/24.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/25.txt | 6 - contrib/bc/tests/fuzzing/dc_inputs/27.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/28.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/29.txt | 13 - contrib/bc/tests/fuzzing/dc_inputs/30.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/31.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/abs.txt | 7 - contrib/bc/tests/fuzzing/dc_inputs/add.txt | 33 - contrib/bc/tests/fuzzing/dc_inputs/array.dc | 2 - .../bc/tests/fuzzing/dc_inputs/boolean.txt | 80 - .../bc/tests/fuzzing/dc_inputs/decimal.txt | 36 - contrib/bc/tests/fuzzing/dc_inputs/divide.txt | 33 - contrib/bc/tests/fuzzing/dc_inputs/divmod.txt | 64 - contrib/bc/tests/fuzzing/dc_inputs/else.dc | 4 - .../tests/fuzzing/dc_inputs/engineering.txt | 19 - contrib/bc/tests/fuzzing/dc_inputs/loop.dc | 3 - contrib/bc/tests/fuzzing/dc_inputs/misc.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/modexp.txt | 103 - .../bc/tests/fuzzing/dc_inputs/modulus.txt | 70 - .../bc/tests/fuzzing/dc_inputs/multiply.txt | 42 - contrib/bc/tests/fuzzing/dc_inputs/places.txt | 14 - contrib/bc/tests/fuzzing/dc_inputs/power.txt | 36 - contrib/bc/tests/fuzzing/dc_inputs/quit.dc | 2 - .../bc/tests/fuzzing/dc_inputs/scientific.txt | 51 - contrib/bc/tests/fuzzing/dc_inputs/shift.txt | 42 - contrib/bc/tests/fuzzing/dc_inputs/sqrt.txt | 14 - .../bc/tests/fuzzing/dc_inputs/stack_len.txt | 1 + contrib/bc/tests/fuzzing/dc_inputs/stdin.txt | 205 - contrib/bc/tests/fuzzing/dc_inputs/stream.dc | 2 - .../bc/tests/fuzzing/dc_inputs/strings.txt | 50 - .../bc/tests/fuzzing/dc_inputs/subtract.txt | 33 - contrib/bc/tests/fuzzing/dc_inputs/trunc.txt | 11 - contrib/bc/tests/fuzzing/dc_inputs/vars.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/weird.dc | 2 - contrib/bc/tests/history.py | 1087 ++++ contrib/bc/tests/history.sh | 92 + contrib/bc/tests/other.sh | 90 +- contrib/bc/tests/read.sh | 21 +- contrib/bc/tests/script.sed | 9 + contrib/bc/tests/script.sh | 18 +- contrib/bc/tests/scripts.sh | 2 + contrib/bc/tests/stdin.sh | 15 +- contrib/bc/tests/test.sh | 13 +- usr.bin/gh-bc/Makefile | 20 +- usr.bin/gh-bc/tests/Makefile | 4 +- 429 files changed, 54549 insertions(+), 73052 deletions(-) delete mode 100644 contrib/bc/RELEASE.md create mode 100644 contrib/bc/benchmarks/bc/add.bc rename contrib/bc/{tests/fuzzing/bc.dict => benchmarks/bc/arrays.bc} (66%) create mode 100644 contrib/bc/benchmarks/bc/arrays_and_constants.bc create mode 100644 contrib/bc/benchmarks/bc/bitfuncs.bc rename contrib/bc/{tests/diff.sh => benchmarks/bc/constants.bc} (81%) mode change 100755 => 100644 create mode 100644 contrib/bc/benchmarks/bc/divide.bc create mode 100644 contrib/bc/benchmarks/bc/functions.bc create mode 100644 contrib/bc/benchmarks/bc/irand_long.bc create mode 100644 contrib/bc/benchmarks/bc/irand_short.bc create mode 100644 contrib/bc/benchmarks/bc/lib.bc create mode 100644 contrib/bc/benchmarks/bc/multiply.bc create mode 100644 contrib/bc/benchmarks/bc/postfix_incdec.bc create mode 100644 contrib/bc/benchmarks/bc/power.bc create mode 100644 contrib/bc/benchmarks/bc/strings.bc create mode 100644 contrib/bc/benchmarks/bc/subtract.bc create mode 100644 contrib/bc/benchmarks/dc/modexp.dc mode change 100755 => 120000 contrib/bc/configure delete mode 100755 contrib/bc/manpage.sh delete mode 100644 contrib/bc/manuals/bc.1.md.in delete mode 100644 contrib/bc/manuals/bc/EHNP.1 delete mode 100644 contrib/bc/manuals/bc/EHNP.1.md delete mode 100644 contrib/bc/manuals/bc/EHP.1 delete mode 100644 contrib/bc/manuals/bc/EHP.1.md delete mode 100644 contrib/bc/manuals/bc/ENP.1 delete mode 100644 contrib/bc/manuals/bc/ENP.1.md delete mode 100644 contrib/bc/manuals/bc/EP.1 delete mode 100644 contrib/bc/manuals/bc/EP.1.md delete mode 100644 contrib/bc/manuals/bc/HNP.1 delete mode 100644 contrib/bc/manuals/bc/HNP.1.md delete mode 100644 contrib/bc/manuals/bc/HP.1 delete mode 100644 contrib/bc/manuals/bc/HP.1.md delete mode 100644 contrib/bc/manuals/bc/NP.1 delete mode 100644 contrib/bc/manuals/bc/NP.1.md delete mode 100644 contrib/bc/manuals/bc/P.1 delete mode 100644 contrib/bc/manuals/bc/P.1.md delete mode 100644 contrib/bc/manuals/benchmarks.md delete mode 100644 contrib/bc/manuals/dc.1.md.in delete mode 100644 contrib/bc/manuals/dc/EHNP.1 delete mode 100644 contrib/bc/manuals/dc/EHNP.1.md delete mode 100644 contrib/bc/manuals/dc/EHP.1 delete mode 100644 contrib/bc/manuals/dc/EHP.1.md delete mode 100644 contrib/bc/manuals/dc/ENP.1 delete mode 100644 contrib/bc/manuals/dc/ENP.1.md delete mode 100644 contrib/bc/manuals/dc/EP.1 delete mode 100644 contrib/bc/manuals/dc/EP.1.md delete mode 100644 contrib/bc/manuals/dc/HNP.1 delete mode 100644 contrib/bc/manuals/dc/HNP.1.md delete mode 100644 contrib/bc/manuals/dc/HP.1 delete mode 100644 contrib/bc/manuals/dc/HP.1.md delete mode 100644 contrib/bc/manuals/dc/NP.1 delete mode 100644 contrib/bc/manuals/dc/NP.1.md delete mode 100644 contrib/bc/manuals/dc/P.1 delete mode 100644 contrib/bc/manuals/dc/P.1.md create mode 100644 contrib/bc/manuals/development.md delete mode 100644 contrib/bc/manuals/header.txt delete mode 100644 contrib/bc/manuals/header_bc.txt delete mode 100644 contrib/bc/manuals/header_bcl.txt delete mode 100644 contrib/bc/manuals/header_dc.txt create mode 100644 contrib/bc/manuals/release.md rename contrib/bc/{tests => scripts}/afl.py (59%) create mode 100755 contrib/bc/scripts/alloc.sh create mode 100755 contrib/bc/scripts/benchmark.sh create mode 100644 contrib/bc/scripts/bitgen.c rename contrib/bc/{ => scripts}/exec-install.sh (88%) rename contrib/bc/{ => scripts}/functions.sh (68%) create mode 100755 contrib/bc/scripts/fuzz_prep.sh rename contrib/bc/{ => scripts}/karatsuba.py (84%) rename contrib/bc/{ => scripts}/link.sh (90%) rename contrib/bc/{ => scripts}/locale_install.sh (68%) rename contrib/bc/{ => scripts}/locale_uninstall.sh (98%) create mode 100755 contrib/bc/scripts/manpage.sh create mode 100644 contrib/bc/scripts/ministat.c create mode 100755 contrib/bc/scripts/package.sh rename contrib/bc/{tests => scripts}/radamsa.sh (77%) rename contrib/bc/{tests => scripts}/radamsa.txt (100%) rename contrib/bc/{tests => scripts}/randmath.py (59%) rename contrib/bc/{ => scripts}/release.sh (53%) create mode 100644 contrib/bc/scripts/release_settings.txt rename contrib/bc/{ => scripts}/safe-install.sh (100%) create mode 100755 contrib/bc/scripts/test_settings.sh create mode 100644 contrib/bc/scripts/test_settings.txt create mode 100644 contrib/bc/tests/bc/bitfuncs.txt create mode 100644 contrib/bc/tests/bc/bitfuncs_results.txt create mode 100644 contrib/bc/tests/bc/divmod.txt create mode 100644 contrib/bc/tests/bc/divmod_results.txt create mode 100644 contrib/bc/tests/bc/errors/25.txt create mode 100644 contrib/bc/tests/bc/errors/26.txt create mode 100644 contrib/bc/tests/bc/errors/27.txt create mode 100644 contrib/bc/tests/bc/errors/28.txt create mode 100644 contrib/bc/tests/bc/errors/29.txt create mode 100644 contrib/bc/tests/bc/errors/30.txt create mode 100644 contrib/bc/tests/bc/errors/31.txt create mode 100644 contrib/bc/tests/bc/errors/32.txt create mode 100644 contrib/bc/tests/bc/modexp.txt create mode 100644 contrib/bc/tests/bc/modexp_results.txt create mode 100644 contrib/bc/tests/bc/recursive_arrays.txt create mode 100644 contrib/bc/tests/bc/recursive_arrays_results.txt mode change 100755 => 100644 contrib/bc/tests/bc/scripts/array.bc mode change 100755 => 100644 contrib/bc/tests/bc/scripts/atan.bc mode change 100755 => 100644 contrib/bc/tests/bc/scripts/bessel.bc mode change 100755 => 100644 contrib/bc/tests/bc/scripts/globals.bc mode change 100755 => 100644 contrib/bc/tests/bc/scripts/parse.bc mode change 100755 => 100644 contrib/bc/tests/bc/scripts/print.bc mode change 100755 => 100644 contrib/bc/tests/bc/scripts/references.bc mode change 100755 => 100644 contrib/bc/tests/bc/scripts/screen.bc create mode 100644 contrib/bc/tests/bc/scripts/strings2.bc rename contrib/bc/tests/{fuzzing/dc_inputs/17.txt => dc/errors/32.txt} (95%) create mode 100644 contrib/bc/tests/dc/errors/33.txt rename contrib/bc/tests/{fuzzing/dc_inputs/26.txt => dc/errors/34.txt} (58%) create mode 100644 contrib/bc/tests/dc/exec_stack_len.txt create mode 100644 contrib/bc/tests/dc/exec_stack_len_results.txt mode change 100755 => 100644 contrib/bc/tests/dc/scripts/array.dc mode change 100755 => 100644 contrib/bc/tests/dc/scripts/asciify.dc mode change 100644 => 100755 contrib/bc/tests/dc/scripts/easter.sh mode change 100755 => 100644 contrib/bc/tests/dc/scripts/else.dc mode change 100755 => 100644 contrib/bc/tests/dc/scripts/factorial.dc mode change 100755 => 100644 contrib/bc/tests/dc/scripts/loop.dc mode change 100755 => 100644 contrib/bc/tests/dc/scripts/prime.dc mode change 100755 => 100644 contrib/bc/tests/dc/scripts/quit.dc mode change 100755 => 100644 contrib/bc/tests/dc/scripts/stream.dc create mode 100644 contrib/bc/tests/dc/scripts/stream.txt mode change 100755 => 100644 contrib/bc/tests/dc/scripts/weird.dc create mode 100644 contrib/bc/tests/dc/stack_len.txt create mode 100644 contrib/bc/tests/dc/stack_len_results.txt create mode 100644 contrib/bc/tests/fuzzing/bc_afl.yaml create mode 100644 contrib/bc/tests/fuzzing/bc_afl_continue.yaml delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/abs.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/add.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/arctangent.txt delete mode 100755 contrib/bc/tests/fuzzing/bc_inputs1/array.bc delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/arrays.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/assignments.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/basic.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/boolean.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/cosine.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/decimal.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/divide.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/engineering.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/exponent.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/functions.bc delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/functions.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/globals.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/len.bc delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/length.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/lib10.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/lib11.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/lib12.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/lib2.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/lib3.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/lib4.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/lib5.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/lib6.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/lib7.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/lib8.txt create mode 100644 contrib/bc/tests/fuzzing/bc_inputs1/strings.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/lib13.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/lib14.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/lib15.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/lib16.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/lib19.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/lib20.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/lib21.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/lib22.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/lib23.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/lib24.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/log.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/misc.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/misc1.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/misc2.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/misc3.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/modulus.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/multiply.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/pi.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/places.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/power.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/print2.txt delete mode 100755 contrib/bc/tests/fuzzing/bc_inputs2/references.bc delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/scale.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/scientific.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/shift.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs2/sine.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/01.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/02.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/03.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/04.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/05.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/06.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/07.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/08.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/09.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/10.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/11.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/12.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/13.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/14.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/15.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/16.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/17.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/18.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/19.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/20.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/21.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/22.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/23.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/24.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/sqrt.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/strings.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/subtract.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/trunc.txt delete mode 100644 contrib/bc/tests/fuzzing/bc_inputs3/void.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/01.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/02.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/03.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/04.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/05.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/06.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/07.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/08.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/09.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/10.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/11.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/12.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/13.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/14.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/15.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/16.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/18.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/19.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/20.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/21.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/22.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/23.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/24.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/25.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/27.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/28.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/29.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/30.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/31.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/abs.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/add.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/array.dc delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/boolean.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/decimal.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/divide.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/divmod.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/else.dc delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/engineering.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/loop.dc delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/misc.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/modexp.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/modulus.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/multiply.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/places.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/power.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/quit.dc delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/scientific.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/shift.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/sqrt.txt create mode 120000 contrib/bc/tests/fuzzing/dc_inputs/stack_len.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/stdin.txt delete mode 100755 contrib/bc/tests/fuzzing/dc_inputs/stream.dc delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/strings.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/subtract.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/trunc.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/vars.txt delete mode 100644 contrib/bc/tests/fuzzing/dc_inputs/weird.dc create mode 100755 contrib/bc/tests/history.py create mode 100755 contrib/bc/tests/history.sh create mode 100644 contrib/bc/tests/script.sed diff --git a/contrib/bc/.gitattributes b/contrib/bc/.gitattributes index 22d6e60bce68..1e2c56dde215 100644 --- a/contrib/bc/.gitattributes +++ b/contrib/bc/.gitattributes @@ -1,3 +1,3 @@ *.vcxproj eol=crlf *.vcxproj.filters eol=crlf -*.sln eol= crlf +*.sln eol=crlf diff --git a/contrib/bc/.gitignore b/contrib/bc/.gitignore index b131d5813764..31e43aa61efc 100644 --- a/contrib/bc/.gitignore +++ b/contrib/bc/.gitignore @@ -51,11 +51,17 @@ print_results.txt bessel.txt bessel_results.txt prime.txt -stream.txt +strings2.txt +strings2_results.txt tests/bc/scripts/add.txt tests/bc/scripts/divide.txt tests/bc/scripts/multiply.txt tests/bc/scripts/subtract.txt +tests/bc/scripts/strings2.txt +benchmarks/bc/*.txt +benchmarks/dc/*.txt +scripts/ministat +scripts/bitgen perf.data perf.data.old *.gcda diff --git a/contrib/bc/LICENSE.md b/contrib/bc/LICENSE.md index 269e131cc81d..8ab2e6069881 100644 --- a/contrib/bc/LICENSE.md +++ b/contrib/bc/LICENSE.md @@ -79,9 +79,9 @@ 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` +## `scripts/safe-install.sh` -The file `safe-install.sh` is under the following copyright and license: +The file `scripts/safe-install.sh` is under the following copyright and license: Copyright (c) 2021 Rich Felker @@ -101,3 +101,13 @@ 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. + +## `scripts/ministat.c` + +The file `scripts/ministat.c` is under the following license: + +"THE BEER-WARE LICENSE" (Revision 42): + + wrote this file. As long as you retain this notice you +can do whatever you want with this stuff. If we meet some day, and you think +this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp diff --git a/contrib/bc/Makefile.in b/contrib/bc/Makefile.in index 2b50476a79fe..c3a41854fe9e 100644 --- a/contrib/bc/Makefile.in +++ b/contrib/bc/Makefile.in @@ -134,39 +134,64 @@ BC_ENABLE_HISTORY = %%HISTORY%% BC_ENABLE_EXTRA_MATH_NAME = BC_ENABLE_EXTRA_MATH BC_ENABLE_EXTRA_MATH = %%EXTRA_MATH%% BC_ENABLE_NLS = %%NLS%% -BC_ENABLE_PROMPT = %%PROMPT%% BC_LONG_BIT = %%LONG_BIT%% BC_ENABLE_AFL = %%FUZZ%% BC_ENABLE_MEMCHECK = %%MEMCHECK%% +BC_DEFAULT_BANNER = %%BC_DEFAULT_BANNER%% +BC_DEFAULT_SIGINT_RESET = %%BC_DEFAULT_SIGINT_RESET%% +DC_DEFAULT_SIGINT_RESET = %%DC_DEFAULT_SIGINT_RESET%% +BC_DEFAULT_TTY_MODE = %%BC_DEFAULT_TTY_MODE%% +DC_DEFAULT_TTY_MODE = %%DC_DEFAULT_TTY_MODE%% +BC_DEFAULT_PROMPT = %%BC_DEFAULT_PROMPT%% +DC_DEFAULT_PROMPT = %%DC_DEFAULT_PROMPT%% + RM = rm MKDIR = mkdir -INSTALL = ./exec-install.sh -SAFE_INSTALL = ./safe-install.sh -LINK = ./link.sh -MANPAGE = ./manpage.sh -KARATSUBA = ./karatsuba.py -LOCALE_INSTALL = ./locale_install.sh -LOCALE_UNINSTALL = ./locale_uninstall.sh +SCRIPTS = ./scripts + +MINISTAT = ministat +MINISTAT_EXEC = $(SCRIPTS)/$(MINISTAT) + +BITFUNCGEN = bitfuncgen +BITFUNCGEN_EXEC = $(SCRIPTS)/$(BITFUNCGEN) + +INSTALL = $(SCRIPTS)/exec-install.sh +SAFE_INSTALL = $(SCRIPTS)/safe-install.sh +LINK = $(SCRIPTS)/link.sh +MANPAGE = $(SCRIPTS)/manpage.sh +KARATSUBA = $(SCRIPTS)/karatsuba.py +LOCALE_INSTALL = $(SCRIPTS)/locale_install.sh +LOCALE_UNINSTALL = $(SCRIPTS)/locale_uninstall.sh VALGRIND_ARGS = --error-exitcode=100 --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=all -TEST_STARS = "***********************************************************************" +TEST_STARS = *********************************************************************** BC_NUM_KARATSUBA_LEN = %%KARATSUBA_LEN%% +BC_DEFS0 = -DBC_DEFAULT_BANNER=$(BC_DEFAULT_BANNER) +BC_DEFS1 = -DBC_DEFAULT_SIGINT_RESET=$(BC_DEFAULT_SIGINT_RESET) +BC_DEFS2 = -DBC_DEFAULT_TTY_MODE=$(BC_DEFAULT_TTY_MODE) +BC_DEFS3 = -DBC_DEFAULT_PROMPT=$(BC_DEFAULT_PROMPT) +BC_DEFS = $(BC_DEFS0) $(BC_DEFS1) $(BC_DEFS2) $(BC_DEFS3) +DC_DEFS1 = -DDC_DEFAULT_SIGINT_RESET=$(DC_DEFAULT_SIGINT_RESET) +DC_DEFS2 = -DDC_DEFAULT_TTY_MODE=$(DC_DEFAULT_TTY_MODE) +DC_DEFS3 = -DDC_DEFAULT_PROMPT=$(DC_DEFAULT_PROMPT) +DC_DEFS = $(DC_DEFS1) $(DC_DEFS2) $(DC_DEFS3) + CPPFLAGS1 = -D$(BC_ENABLED_NAME)=$(BC_ENABLED) -D$(DC_ENABLED_NAME)=$(DC_ENABLED) CPPFLAGS2 = $(CPPFLAGS1) -I./include/ -DBUILD_TYPE=$(BC_BUILD_TYPE) %%LONG_BIT_DEFINE%% CPPFLAGS3 = $(CPPFLAGS2) -DEXECPREFIX=$(EXEC_PREFIX) -DMAINEXEC=$(MAIN_EXEC) -CPPFLAGS4 = $(CPPFLAGS3) -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 +CPPFLAGS4 = $(CPPFLAGS3) -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 %%BSD%% 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) CPPFLAGS7 = $(CPPFLAGS6) -D$(BC_ENABLE_EXTRA_MATH_NAME)=$(BC_ENABLE_EXTRA_MATH) 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) $(BC_DEFS) $(DC_DEFS) %%CPPFLAGS%% %%CFLAGS%% LDFLAGS = %%LDFLAGS%% HOSTCFLAGS = %%HOSTCFLAGS%% @@ -219,6 +244,12 @@ $(BIN): headers: %%HEADERS%% +$(MINISTAT): + $(HOSTCC) $(HOSTCFLAGS) -lm -o $(MINISTAT_EXEC) scripts/ministat.c + +$(BITFUNCGEN): + $(HOSTCC) $(HOSTCFLAGS) -lm -o $(BITFUNCGEN_EXEC) scripts/bitfuncgen.c + help: @printf 'available targets:\n' @printf '\n' @@ -249,16 +280,25 @@ help: @printf ' valgrind_dc runs the dc test suite, if dc has been built,\n' @printf ' through valgrind\n' -run_all_tests: +run_all_tests: bc_all_tests timeconst_all_tests dc_all_tests history_all_tests + +bc_all_tests: %%BC_ALL_TESTS%% + +timeconst_all_tests: %%TIMECONST_ALL_TESTS%% + +dc_all_tests: %%DC_ALL_TESTS%% +history_all_tests: + %%HISTORY_TESTS%% + check: test test: %%TESTS%% -test_bc: test_bc_header test_bc_tests test_bc_scripts test_bc_stdin test_bc_read test_bc_errors test_bc_other +test_bc: test_bc_header test_bc_tests test_bc_scripts test_bc_errors test_bc_stdin test_bc_read test_bc_other @printf '\nAll bc tests passed.\n\n$(TEST_STARS)\n' test_bc_tests:%%BC_TESTS%% @@ -275,12 +315,12 @@ test_bc_errors: @sh tests/errors.sh bc %%BC_TEST_EXEC%% test_bc_other: - @sh tests/other.sh bc %%BC_TEST_EXEC%% + @sh tests/other.sh bc $(BC_ENABLE_EXTRA_MATH) %%BC_TEST_EXEC%% test_bc_header: @printf '$(TEST_STARS)\n\nRunning bc tests...\n\n' -test_dc: test_dc_header test_dc_tests test_dc_scripts test_dc_stdin test_dc_read test_dc_errors test_dc_other +test_dc: test_dc_header test_dc_tests test_dc_scripts test_dc_errors test_dc_stdin test_dc_read test_dc_other @printf '\nAll dc tests passed.\n\n$(TEST_STARS)\n' test_dc_tests:%%DC_TESTS%% @@ -297,7 +337,7 @@ test_dc_errors: @sh tests/errors.sh dc %%DC_TEST_EXEC%% test_dc_other: - @sh tests/other.sh dc %%DC_TEST_EXEC%% + @sh tests/other.sh dc $(BC_ENABLE_EXTRA_MATH) %%DC_TEST_EXEC%% test_dc_header: @printf '$(TEST_STARS)\n\nRunning dc tests...\n\n' @@ -305,6 +345,122 @@ test_dc_header: timeconst: %%TIMECONST%% +test_history: test_history_header test_bc_history test_dc_history + @printf '\nAll history tests passed.\n\n$(TEST_STARS)\n' + +test_bc_history:%%BC_HISTORY_TEST_PREREQS%% + +test_bc_history_all: test_bc_history0 test_bc_history1 test_bc_history2 test_bc_history3 test_bc_history4 test_bc_history5 test_bc_history6 test_bc_history7 test_bc_history8 test_bc_history9 test_bc_history10 test_bc_history11 test_bc_history12 test_bc_history13 test_bc_history14 test_bc_history15 test_bc_history16 test_bc_history17 test_bc_history18 test_bc_history19 test_bc_history20 test_bc_history21 + +test_bc_history_skip: + @printf 'No bc history tests to run\n' + +test_bc_history0: + @sh tests/history.sh bc 0 %%BC_TEST_EXEC%% + +test_bc_history1: + @sh tests/history.sh bc 1 %%BC_TEST_EXEC%% + +test_bc_history2: + @sh tests/history.sh bc 2 %%BC_TEST_EXEC%% + +test_bc_history3: + @sh tests/history.sh bc 3 %%BC_TEST_EXEC%% + +test_bc_history4: + @sh tests/history.sh bc 4 %%BC_TEST_EXEC%% + +test_bc_history5: + @sh tests/history.sh bc 5 %%BC_TEST_EXEC%% + +test_bc_history6: + @sh tests/history.sh bc 6 %%BC_TEST_EXEC%% + +test_bc_history7: + @sh tests/history.sh bc 7 %%BC_TEST_EXEC%% + +test_bc_history8: + @sh tests/history.sh bc 8 %%BC_TEST_EXEC%% + +test_bc_history9: + @sh tests/history.sh bc 9 %%BC_TEST_EXEC%% + +test_bc_history10: + @sh tests/history.sh bc 10 %%BC_TEST_EXEC%% + +test_bc_history11: + @sh tests/history.sh bc 11 %%BC_TEST_EXEC%% + +test_bc_history12: + @sh tests/history.sh bc 12 %%BC_TEST_EXEC%% + +test_bc_history13: + @sh tests/history.sh bc 13 %%BC_TEST_EXEC%% + +test_bc_history14: + @sh tests/history.sh bc 14 %%BC_TEST_EXEC%% + +test_bc_history15: + @sh tests/history.sh bc 15 %%BC_TEST_EXEC%% + +test_bc_history16: + @sh tests/history.sh bc 16 %%BC_TEST_EXEC%% + +test_bc_history17: + @sh tests/history.sh bc 17 %%BC_TEST_EXEC%% + +test_bc_history18: + @sh tests/history.sh bc 18 %%BC_TEST_EXEC%% + +test_bc_history19: + @sh tests/history.sh bc 19 %%BC_TEST_EXEC%% + +test_bc_history20: + @sh tests/history.sh bc 20 %%BC_TEST_EXEC%% + +test_bc_history21: + @sh tests/history.sh bc 21 %%BC_TEST_EXEC%% + +test_dc_history:%%DC_HISTORY_TEST_PREREQS%% + +test_dc_history_all: test_dc_history0 test_dc_history1 test_dc_history2 test_dc_history3 test_dc_history4 test_dc_history5 test_dc_history6 test_dc_history7 test_dc_history8 test_dc_history9 + +test_dc_history_skip: + @printf 'No dc history tests to run\n' + +test_dc_history0: + @sh tests/history.sh dc 0 %%DC_TEST_EXEC%% + +test_dc_history1: + @sh tests/history.sh dc 1 %%DC_TEST_EXEC%% + +test_dc_history2: + @sh tests/history.sh dc 2 %%DC_TEST_EXEC%% + +test_dc_history3: + @sh tests/history.sh dc 3 %%DC_TEST_EXEC%% + +test_dc_history4: + @sh tests/history.sh dc 4 %%DC_TEST_EXEC%% + +test_dc_history5: + @sh tests/history.sh dc 5 %%DC_TEST_EXEC%% + +test_dc_history6: + @sh tests/history.sh dc 6 %%DC_TEST_EXEC%% + +test_dc_history7: + @sh tests/history.sh dc 7 %%DC_TEST_EXEC%% + +test_dc_history8: + @sh tests/history.sh dc 8 %%DC_TEST_EXEC%% + +test_dc_history9: + @sh tests/history.sh dc 9 %%DC_TEST_EXEC%% + +test_history_header: + @printf '$(TEST_STARS)\n\nRunning history tests...\n\n' + library_test: $(LIBBC) $(CC) $(CFLAGS) $(BCL_TEST_C) $(LIBBC) -o $(BCL_TEST) @@ -322,12 +478,6 @@ coverage_output: coverage:%%COVERAGE_PREREQS%% -libcname: - @printf '%s' "$(BC_LIB_C)" - -extra_math: - @printf '%s' "$(BC_ENABLE_EXTRA_MATH)" - manpages: $(MANPAGE) bc $(MANPAGE) dc @@ -348,15 +498,19 @@ clean:%%CLEAN_PREREQS%% @$(RM) -f $(BC_LIB2_C) $(BC_LIB2_O) @$(RM) -f $(BC_HELP_C) $(BC_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) @$(RM) -fr Debug/ Release/ -clean_config: clean +clean_benchmarks: + @printf 'Cleaning benchmarks...\n' + @$(RM) -f $(MINISTAT_EXEC) + @$(RM) -f benchmarks/bc/*.txt + @$(RM) -f benchmarks/dc/*.txt + +clean_config: clean clean_benchmarks @printf 'Cleaning config...\n' @$(RM) -f Makefile - @$(RM) -f $(BC_MD) $(DC_MD) - @$(RM) -f $(BC_MANPAGE) $(DC_MANPAGE) + @$(RM) -f $(BC_MD) $(BC_MANPAGE) + @$(RM) -f $(DC_MD) $(DC_MANPAGE) clean_coverage: @printf 'Cleaning coverage files...\n' @@ -376,9 +530,12 @@ clean_coverage: clean_tests: clean clean_config clean_coverage @printf 'Cleaning test files...\n' + @$(RM) -fr $(BC_TEST_OUTPUTS) $(DC_TEST_OUTPUTS) + @$(RM) -fr $(BC_FUZZ_OUTPUTS) $(DC_FUZZ_OUTPUTS) @$(RM) -f tests/bc/parse.txt tests/bc/parse_results.txt @$(RM) -f tests/bc/print.txt tests/bc/print_results.txt @$(RM) -f tests/bc/bessel.txt tests/bc/bessel_results.txt + @$(RM) -f tests/bc/strings2.txt tests/bc/strings2_results.txt @$(RM) -f tests/bc/scripts/bessel.txt @$(RM) -f tests/bc/scripts/parse.txt @$(RM) -f tests/bc/scripts/print.txt @@ -386,13 +543,15 @@ clean_tests: clean clean_config clean_coverage @$(RM) -f tests/bc/scripts/divide.txt @$(RM) -f tests/bc/scripts/multiply.txt @$(RM) -f tests/bc/scripts/subtract.txt - @$(RM) -f tests/dc/scripts/prime.txt tests/dc/scripts/stream.txt + @$(RM) -f tests/bc/scripts/strings2.txt + @$(RM) -f tests/dc/scripts/prime.txt @$(RM) -f .log_*.txt @$(RM) -f .math.txt .results.txt .ops.txt @$(RM) -f .test.txt @$(RM) -f tags .gdbbreakpoints .gdb_history .gdbsetup @$(RM) -f cscope.* @$(RM) -f bc.old + @$(RM) -f $(BITFUNCGEN_EXEC) install_locales: %%INSTALL_LOCALES%% diff --git a/contrib/bc/NEWS.md b/contrib/bc/NEWS.md index c78bddd27e76..3b1477cafb26 100644 --- a/contrib/bc/NEWS.md +++ b/contrib/bc/NEWS.md @@ -1,5 +1,55 @@ # News +## 5.0.0 + +This is a major production release with several changes: + +* Added support for OpenBSD's `pledge()` and `unveil()`. +* Fixed print bug where a backslash newline combo was printed even if only one + digit was left, something I blindly copied from GNU `bc`, like a fool. +* Fixed bugs in the manuals. +* Fixed a possible multiplication overflow in power. +* Temporary numbers are garbage collected if allocation fails, and the + allocation is retried. This is to make `bc` and `dc` more resilient to running + out of memory. +* Limited the number of temporary numbers and made the space for them static so + that allocating more space for them cannot fail. +* Allowed integers with non-zero `scale` to be used with power, places, and + shift operators. +* Added greatest common divisor and least common multiple to `lib2.bc`. +* Added `SIGQUIT` handling to history. +* Added a command to `dc` (`y`) to get the length of register stacks. +* Fixed multi-digit bugs in `lib2.bc`. +* Removed the no prompt build option. +* Created settings that builders can set defaults for and users can set their + preferences for. This includes the `bc` banner, resetting on `SIGINT`, TTY + mode, and prompt. +* Added history support to Windows. +* Fixed bugs with the handling of register names in `dc`. +* Fixed bugs with multi-line comments and strings in both calculators. +* Added a new error type and message for `dc` when register stacks don't have + enough items. +* Optimized string allocation. +* Made `bc` and `dc` UTF-8 capable. +* Fixed a bug with `void` functions. +* Fixed a misspelled symbol in `bcl`. This is technically a breaking change, + which requires this to be `5.0.0`. +* Added the ability for users to get the copyright banner back. +* Added the ability for users to have `bc` and `dc` quit on `SIGINT`. +* Added the ability for users to disable prompt and TTY mode by environment + variables. +* Added the ability for users to redefine keywords. This is another reason this + is `5.0.0`. +* Added `dc`'s modular exponentiation and divmod to `bc`. +* Added the ability to assign strings to variables and array elements and pass + them to functions in `bc`. +* Added `dc`'s asciify command and stream printing to `bc`. +* Added a command to `dc` (`Y`) to get the length of an array. +* Added a command to `dc` (`,`) to get the depth of the execution stack. +* Added bitwise and, or, xor, left shift, right shift, reverse, left rotate, + right rotate, and mod functions to `lib2.bc`. +* Added the functions `s2u(x)` and `s2un(x,n)`, to `lib2.bc`. + ## 4.0.2 This is a production release that fixes two bugs: @@ -310,8 +360,8 @@ running tests during install. **If `bc` segfaults while running arg tests when updating, it is because the global locale files have not been replaced. Make sure to either prevent the test suite from running on update or remove the old locale files before updating.** (Removing the locale files can be done with -`make uninstall` or by running the `locale_uninstall.sh` script.) Once this is -done, `bc` should install without problems.* +`make uninstall` or by running the [`locale_uninstall.sh`][22] script.) Once +this is done, `bc` should install without problems.* *Second, **the option to build without signal support has been removed**. See below for the reasons why.* @@ -396,7 +446,7 @@ diameter of the universe in Planck lengths. (For 32-bit, these numbers are either 32 integer digits or 12 integer digits and 20 fractional digits. These are also quite big, and going much bigger on a -32-bit system seems a little pointless since 12 digits in just under a trillion +32-bit system seems a little pointless since 12 digits is just under a trillion and 20 fractional digits is still enough for about any use since `10^-20` light years is just under a millimeter.) @@ -1084,7 +1134,7 @@ not thoroughly tested. [1]: https://docs.microsoft.com/en-us/windows/wsl/install-win10 [2]: https://pkg.musl.cc/bc/ [3]: http://lcamtuf.coredump.cx/afl/ -[4]: ./karatsuba.py +[4]: ./scripts/karatsuba.py [5]: ./README.md [6]: ./configure.sh [7]: https://github.com/rain-1/linenoise-mob @@ -1092,7 +1142,7 @@ not thoroughly tested. [9]: ./manuals/bc/A.1.md [10]: ./manuals/dc/A.1.md [11]: https://scan.coverity.com/projects/gavinhoward-bc -[12]: ./locale_install.sh +[12]: ./scripts/locale_install.sh [13]: ./manuals/build.md [14]: https://github.com/stesser [15]: https://github.com/bugcrazy @@ -1102,3 +1152,4 @@ not thoroughly tested. [19]: ./manuals/benchmarks.md [20]: https://github.com/apjanke/ronn-ng [21]: https://pandoc.org/ +[22]: ./scripts/locale_uninstall.sh diff --git a/contrib/bc/README.md b/contrib/bc/README.md index f0dcecf15bde..c46d66b7e3ea 100644 --- a/contrib/bc/README.md +++ b/contrib/bc/README.md @@ -1,7 +1,5 @@ # `bc` -[![Coverity Scan Build Status][17]][18] - ***WARNING: This project has moved to [https://git.yzena.com/][20] for [these reasons][21], though GitHub will remain a mirror.*** @@ -23,6 +21,8 @@ This `bc` also provides `bc`'s math as a library with C bindings, called `bcl`. For more information, see the full manual for `bcl`. +## License + This `bc` is Free and Open Source Software (FOSS). It is offered under the BSD 2-clause License. Full license text may be found in the [`LICENSE.md`][4] file. @@ -55,6 +55,12 @@ system. ## Build +This `bc` should build unmodified on any POSIX-compliant system or on Windows +starting with Windows 10 (though earlier versions may work). + +For more complex build requirements than the ones below, see the +[build manual][5]. + ### Windows There is no guarantee that this `bc` will work on any version of Windows earlier @@ -96,12 +102,6 @@ where `` is either one of `Debug` or `Release`. ### POSIX-Compatible Systems -This `bc` should build unmodified on any POSIX-compliant system or on Windows -starting with Windows 10 (though earlier versions may work). - -For more complex build requirements than the ones below, see the -[build manual][5]. - On POSIX-compatible systems, `bc` is built as `bin/bc` and `dc` is built as `bin/dc` by default. On Windows, they are built as `Release/bc/bc.exe` and `Release/bc/dc.exe`. @@ -243,7 +243,7 @@ allowed. ##### Karatsuba Number Package and distro maintainers have one tool at their disposal to build this -`bc` in the optimal configuration: `karatsuba.py`. +`bc` in the optimal configuration: `scripts/karatsuba.py`. This script is not a compile-time or runtime prerequisite; it is for package and distro maintainers to run once when a package is being created. It finds the @@ -272,6 +272,21 @@ releases with additional features. However, it *is* actively maintained, so if any bugs are found, they will be fixed in new releases. Also, additional translations will also be added as they are provided. +### Development + +If I (Gavin D. Howard) get [hit by a bus][27] and future programmers need to +handle work themselves, the best place to start is the [Development manual][28]. + +## Vim Syntax + +I have developed (using other people's code to start) [`vim` syntax files][17] +for this `bc` and `dc`, including the extensions. + +## `bc` Libs + +I have gathered some excellent [`bc` and `dc` libraries][18]. These libraries +may prove useful to any serious users. + ## Comparison to GNU `bc` This `bc` compares favorably to GNU `bc`. @@ -366,20 +381,10 @@ Files: bcl.vcxproj.filters The Visual Studio filters file for bcl. configure A symlink to configure.sh to make packaging easier. configure.sh The configure script. - functions.sh A script with functions used by other scripts. - install.sh Install script. - karatsuba.py Script to find the optimal Karatsuba number. LICENSE.md A Markdown form of the BSD 2-clause License. - link.sh A script to link dc to bc. - locale_install.sh A script to install locales, if desired. - locale_uninstall.sh A script to uninstall locales. Makefile.in The Makefile template. - manpage.sh Script to generate man pages from markdown files - (maintainer use only). NOTICE.md List of contributors and copyright owners. RELEASE.md A checklist for making a release (maintainer use only). - release.sh A script to test for release (maintainer use only). - safe-install.sh Safe install script from musl libc. Folders: @@ -388,6 +393,7 @@ Folders: locales Locale files, in .msg format. Patches welcome for translations. manuals Manuals for both programs. src All source code. + scripts A bunch of shell scripts to help with development and building. tests All tests. [1]: https://www.gnu.org/software/bc/ @@ -399,8 +405,8 @@ Folders: [10]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html [11]: http://semver.org/ [12]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html -[17]: https://img.shields.io/coverity/scan/16609.svg -[18]: https://scan.coverity.com/projects/gavinhoward-bc +[17]: https://git.yzena.com/gavin/vim-bc +[18]: https://git.yzena.com/gavin/bc_libs [19]: ./manuals/benchmarks.md [20]: https://git.yzena.com/gavin/bc [21]: https://gavinhoward.com/2020/04/i-am-moving-away-from-github/ @@ -409,3 +415,5 @@ Folders: [24]: https://bugs.freebsd.org/ [25]: https://reviews.freebsd.org/ [26]: ./manuals/bcl.3.md +[27]: https://en.wikipedia.org/wiki/Bus_factor +[28]: ./manuals/development.md diff --git a/contrib/bc/RELEASE.md b/contrib/bc/RELEASE.md deleted file mode 100644 index 487ef95b051b..000000000000 --- a/contrib/bc/RELEASE.md +++ /dev/null @@ -1,54 +0,0 @@ -# Release Checklist - -This is the checklist for cutting a release. - -1. Update the README. -2. Update the manuals. -3. Test history manually. -4. Test with POSIX test suite. -5. Run the randmath.py script an excessive amount and add failing tests to - test suite. - * debug - * release - * minrelease -6. Fuzz with AFL. - * reldebug -7. Fix AFL crashes. -8. Find ASan crashes on AFL test cases. -9. Fix ASan crashes. -10. Build with xstatic. -11. Run and pass the `release.sh` script on my own machine. -12. Run and pass the `release.sh` script, without generated tests and - sanitizers, on FreeBSD. -13. Run and pass the `release.sh` script, without generated tests, sanitizers, - and 64-bit, on Thalheim's ARM server. -14. Run and pass the release script, with no generated tests, no clang, no - sanitizers, and no valgrind, on NetBSD. -15. Run and pass the release script, with no generated tests, no clang, no - sanitizers, and no valgrind, on OpenBSD. -16. Run Coverity Scan and eliminate warnings, if possible (both only). - * debug -17. Run `scan-build make`. -18. Repeat steps 3-14 again and repeat until nothing is found. -19. Update the benchmarks. -20. Change the version (remove "-dev") and commit. -21. Run `make clean_tests`. -22. Run the release script. -23. Upload the custom tarball to GitHub. -24. Add sha's to release notes. -25. Edit release notes for the changelog. -26. Increment to the next version (with "-dev"). -27. Notify the following: - * FreeBSD - * Adelie Linux - * Ataraxia Linux - * Sabotage - * xstatic - * OpenBSD - * NetBSD -28. Submit new packages for the following: - * Alpine Linux - * Void Linux - * Gentoo Linux - * Linux from Scratch - * Arch Linux diff --git a/contrib/bc/bc.vcxproj b/contrib/bc/bc.vcxproj index 2dbbd558618f..8d4f34a2a0e6 100644 --- a/contrib/bc/bc.vcxproj +++ b/contrib/bc/bc.vcxproj @@ -64,33 +64,33 @@ Building strgen - CL /Fo:$(Configuration)\$(ProjectName)\ /Fe:$(Configuration)\$(ProjectName)\strgen.exe gen\strgen.c + CL /Fo:$(Configuration)\$(Platform)\$(ProjectName)\ /Fe:$(Configuration)\$(Platform)\$(ProjectName)\strgen.exe gen\strgen.c gen\strgen.c - $(Configuration)\$(ProjectName)\strgen.exe + $(Configuration)\$(Platform)\$(ProjectName)\strgen.exe - Generating $(Configuration)\$(ProjectName)/lib.c - START $(Configuration)\$(ProjectName)/strgen gen\lib.bc $(Configuration)\$(ProjectName)/lib.c bc_lib bc_lib_name BC_ENABLED 1 - $(Configuration)\$(ProjectName)\strgen.exe;gen\lib.bc - $(Configuration)\$(ProjectName)\lib.c + Generating $(Configuration)\$(Platform)\$(ProjectName)/lib.c + START $(Configuration)\$(Platform)\$(ProjectName)/strgen gen\lib.bc $(Configuration)\$(Platform)\$(ProjectName)/lib.c bc_lib bc_lib_name BC_ENABLED 1 + $(Configuration)\$(Platform)\$(ProjectName)\strgen.exe;gen\lib.bc + $(Configuration)\$(Platform)\$(ProjectName)\lib.c - Generating $(Configuration)\$(ProjectName)/lib2.c - START $(Configuration)\$(ProjectName)/strgen gen\lib2.bc $(Configuration)\$(ProjectName)/lib2.c bc_lib2 bc_lib2_name BC_ENABLED 1 - $(Configuration)\$(ProjectName)\strgen.exe;gen\lib2.bc - $(Configuration)\$(ProjectName)\lib2.c + Generating $(Configuration)\$(Platform)\$(ProjectName)/lib2.c + START $(Configuration)\$(Platform)\$(ProjectName)/strgen gen\lib2.bc $(Configuration)\$(Platform)\$(ProjectName)/lib2.c bc_lib2 bc_lib2_name BC_ENABLED 1 + $(Configuration)\$(Platform)\$(ProjectName)\strgen.exe;gen\lib2.bc + $(Configuration)\$(Platform)\$(ProjectName)\lib2.c - Generating $(Configuration)\$(ProjectName)/bc_help.c - START $(Configuration)\$(ProjectName)/strgen gen\bc_help.txt $(Configuration)\$(ProjectName)\bc_help.c bc_help "" BC_ENABLED - $(Configuration)\$(ProjectName)\strgen.exe;gen\bc_help.txt - $(Configuration)\$(ProjectName)\bc_help.c + Generating $(Configuration)\$(Platform)\$(ProjectName)/bc_help.c + START $(Configuration)\$(Platform)\$(ProjectName)/strgen gen\bc_help.txt $(Configuration)\$(Platform)\$(ProjectName)\bc_help.c bc_help "" BC_ENABLED + $(Configuration)\$(Platform)\$(ProjectName)\strgen.exe;gen\bc_help.txt + $(Configuration)\$(Platform)\$(ProjectName)\bc_help.c - Generating $(Configuration)\$(ProjectName)/dc_help.c - START $(Configuration)\$(ProjectName)/strgen gen\dc_help.txt $(Configuration)\$(ProjectName)\dc_help.c dc_help "" DC_ENABLED - $(Configuration)\$(ProjectName)\strgen.exe;gen\dc_help.txt - $(Configuration)\$(ProjectName)\dc_help.c + Generating $(Configuration)\$(Platform)\$(ProjectName)/dc_help.c + START $(Configuration)\$(Platform)\$(ProjectName)/strgen gen\dc_help.txt $(Configuration)\$(Platform)\$(ProjectName)\dc_help.c dc_help "" DC_ENABLED + $(Configuration)\$(Platform)\$(ProjectName)\strgen.exe;gen\dc_help.txt + $(Configuration)\$(Platform)\$(ProjectName)\dc_help.c @@ -99,27 +99,27 @@ true - $(SolutionDir)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)\$(Configuration)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\ false - $(SolutionDir)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)\$(Configuration)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\ true - $(SolutionDir)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)\$(Configuration)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\ false - $(SolutionDir)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)\$(Configuration)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\ - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_ENABLE_PROMPT=1;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;EXECSUFFIX=.exe;BUILD_TYPE=HN + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=1;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;EXECSUFFIX=.exe;BUILD_TYPE=N;BC_DEFAULT_BANNER=1;BC_DEFAULT_SIGINT_RESET=0;DC_DEFAULT_SIGINT_RESET=0;BC_DEFAULT_TTY_MODE=1;DC_DEFAULT_TTY_MODE=1;BC_DEFAULT_PROMPT=1;DC_DEFAULT_PROMPT=1 $(SolutionDir)\include;%(AdditionalIncludeDirectories) MultiThreadedDebugDLL Level3 @@ -130,12 +130,12 @@ MachineX86 - true + DebugFastLink Console kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;bcrypt.lib;ucrt.lib;%(AdditionalDependencies) - copy /b "$(SolutionDir)\$(Configuration)\$(ProjectName)\bc.exe" "$(SolutionDir)\$(Configuration)\$(ProjectName)\dc.exe" + copy /b "$(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\bc.exe" "$(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\dc.exe" Copying bc to dc... @@ -143,7 +143,7 @@ - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_ENABLE_PROMPT=1;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;EXECSUFFIX=.exe;BUILD_TYPE=HN + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=1;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;EXECSUFFIX=.exe;BUILD_TYPE=N;BC_DEFAULT_BANNER=1;BC_DEFAULT_SIGINT_RESET=0;DC_DEFAULT_SIGINT_RESET=0;BC_DEFAULT_TTY_MODE=1;DC_DEFAULT_TTY_MODE=1;BC_DEFAULT_PROMPT=1;DC_DEFAULT_PROMPT=1 $(SolutionDir)\include;%(AdditionalIncludeDirectories) MultiThreadedDLL Level3 @@ -161,7 +161,7 @@ true - copy /b "$(SolutionDir)\$(Configuration)\$(ProjectName)\bc.exe" "$(SolutionDir)\$(Configuration)\$(ProjectName)\dc.exe" + copy /b "$(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\bc.exe" "$(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\dc.exe" Copying bc to dc... @@ -169,7 +169,7 @@ - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_ENABLE_PROMPT=1;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;EXECSUFFIX=.exe;BUILD_TYPE=HN + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=1;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;EXECSUFFIX=.exe;BUILD_TYPE=N;BC_DEFAULT_BANNER=1;BC_DEFAULT_SIGINT_RESET=0;DC_DEFAULT_SIGINT_RESET=0;BC_DEFAULT_TTY_MODE=1;DC_DEFAULT_TTY_MODE=1;BC_DEFAULT_PROMPT=1;DC_DEFAULT_PROMPT=1 $(SolutionDir)\include;%(AdditionalIncludeDirectories) MultiThreadedDebugDLL Level3 @@ -185,7 +185,7 @@ kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;bcrypt.lib;ucrt.lib;%(AdditionalDependencies) - copy /b "$(SolutionDir)\$(Configuration)\$(ProjectName)\bc.exe" "$(SolutionDir)\$(Configuration)\$(ProjectName)\dc.exe" + copy /b "$(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\bc.exe" "$(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\dc.exe" Copying bc to dc... @@ -193,7 +193,7 @@ - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_ENABLE_PROMPT=1;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;EXECSUFFIX=.exe;BUILD_TYPE=HN + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=1;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=0;EXECSUFFIX=.exe;BUILD_TYPE=N;BC_DEFAULT_BANNER=1;BC_DEFAULT_SIGINT_RESET=0;DC_DEFAULT_SIGINT_RESET=0;BC_DEFAULT_TTY_MODE=1;DC_DEFAULT_TTY_MODE=1;BC_DEFAULT_PROMPT=1;DC_DEFAULT_PROMPT=1 $(SolutionDir)\include;%(AdditionalIncludeDirectories) MultiThreadedDLL Level3 @@ -205,22 +205,22 @@ MachineX64 - false + DebugFastLink Console kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;bcrypt.lib;ucrt.lib;%(AdditionalDependencies) - copy /b "$(SolutionDir)\$(Configuration)\$(ProjectName)\bc.exe" "$(SolutionDir)\$(Configuration)\$(ProjectName)\dc.exe" + copy /b "$(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\bc.exe" "$(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\dc.exe" Copying bc to dc... - - - - + + + + diff --git a/contrib/bc/bcl.vcxproj b/contrib/bc/bcl.vcxproj index 3b79c8b9ef64..c1031045e34a 100644 --- a/contrib/bc/bcl.vcxproj +++ b/contrib/bc/bcl.vcxproj @@ -65,27 +65,27 @@ true - $(SolutionDir)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)\$(Configuration)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\ true - $(SolutionDir)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)\$(Configuration)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\ true - $(SolutionDir)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)\$(Configuration)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\ true - $(SolutionDir)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)\$(Configuration)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\ + $(SolutionDir)\$(Configuration)\$(Platform)\$(ProjectName)\ - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_ENABLE_PROMPT=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=1 + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=1 MultiThreadedDebugDLL Level3 ProgramDatabase @@ -100,7 +100,7 @@ - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_ENABLE_PROMPT=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=1 + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=1 MultiThreadedDLL Level3 ProgramDatabase @@ -116,13 +116,13 @@ - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_ENABLE_PROMPT=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=1 + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=1 $(SolutionDir)\include - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_ENABLE_PROMPT=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=1 + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);BC_ENABLED=1;DC_ENABLED=1;BC_ENABLE_EXTRA_MATH=1;BC_ENABLE_HISTORY=0;BC_ENABLE_NLS=0;BC_DEBUG_CODE=0;BC_ENABLE_LIBRARY=1 $(SolutionDir)\include diff --git a/contrib/bc/benchmarks/bc/add.bc b/contrib/bc/benchmarks/bc/add.bc new file mode 100644 index 000000000000..90a83e4758d9 --- /dev/null +++ b/contrib/bc/benchmarks/bc/add.bc @@ -0,0 +1,21 @@ +#! /usr/bin/bc -lq + +print "scale = 20\n" +print "x = 1234567890 / scale\n" +print "len = length(x) + 1 + scale\n" +print "len *= 2\n" + +scale = 20 +x = 1234567890 / scale +len = length(x) + 1 + scale +len *= 2 + +for (i = 0; i <= len; ++i) { + print "a[", i, "] = x * (10^", i, ")\n" +} + +for (i = 1; i <= 10000; ++i) { + for (j = 0; j < len; ++j) { + print "v = a[", i, "] + a[", j, "]\n" + } +} diff --git a/contrib/bc/tests/fuzzing/bc.dict b/contrib/bc/benchmarks/bc/arrays.bc similarity index 66% rename from contrib/bc/tests/fuzzing/bc.dict rename to contrib/bc/benchmarks/bc/arrays.bc index f4dc965844e1..e3c463187d78 100644 --- a/contrib/bc/tests/fuzzing/bc.dict +++ b/contrib/bc/benchmarks/bc/arrays.bc @@ -1,3 +1,4 @@ +#! /usr/bin/bc # # SPDX-License-Identifier: BSD-2-Clause # @@ -25,44 +26,9 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # -# AFL dictionary for bc -# -keyword_abs="abs" -keyword_auto="auto" -keyword_break="break" -keyword_continue="continue" -keyword_define="define" -keyword_else="else" -keyword_for="for" -keyword_halt="halt" -keyword_ibase="ibase" -keyword_if="if" -keyword_irand="irand" -keyword_last="last" -keyword_length="length" -keyword_limits="limits" -keyword_maxibase="maxibase" -keyword_maxobase="maxobase" -keyword_maxrand="maxrand" -keyword_maxscale="maxscale" -keyword_obase="obase" -keyword_print="print" -keyword_quit="quit" -keyword_rand="rand" -keyword_read="read" -keyword_return="return" -keyword_scale="scale" -keyword_seed="seed" -keyword_sqrt="sqrt" -keyword_while="while" +max = 1000000 -"{" -"}" -"," -"[" -"]" -"1" -"1.234" -"-3.2892" -"3e4" +for (i = 0; i < max; ++i) { + print "a", i, "[0] = ", i, "\n" +} diff --git a/contrib/bc/benchmarks/bc/arrays_and_constants.bc b/contrib/bc/benchmarks/bc/arrays_and_constants.bc new file mode 100644 index 000000000000..93c5594bec20 --- /dev/null +++ b/contrib/bc/benchmarks/bc/arrays_and_constants.bc @@ -0,0 +1,35 @@ +#! /usr/bin/bc +# +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2018-2021 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. +# + +max = 1000000 + +for (i = 0; i < max; ++i) { + print "b", i, "[100] = ", i, "\n" +} + diff --git a/contrib/bc/benchmarks/bc/bitfuncs.bc b/contrib/bc/benchmarks/bc/bitfuncs.bc new file mode 100644 index 000000000000..1c2a6529d04b --- /dev/null +++ b/contrib/bc/benchmarks/bc/bitfuncs.bc @@ -0,0 +1,18 @@ +#! /usr/bin/bc -lq + +scale = 0 +max = 10000 + +print "scale = 0\n" + +for (i = 0; i < max; ++i) { + + a = rand() + b = rand() + + print "band(", a, ", ", b, ")\n" + print "bor(", a, ", ", b, ")\n" + print "bxor(", a, ", ", b, ")\n" + print "blshift(", a, ", ", b % 32, ")\n" + print "brshift(", a, ", ", b % 32, ")\n" +} diff --git a/contrib/bc/tests/diff.sh b/contrib/bc/benchmarks/bc/constants.bc old mode 100755 new mode 100644 similarity index 81% rename from contrib/bc/tests/diff.sh rename to contrib/bc/benchmarks/bc/constants.bc index 6d664a8a81b8..1f7b92d47566 --- a/contrib/bc/tests/diff.sh +++ b/contrib/bc/benchmarks/bc/constants.bc @@ -1,4 +1,4 @@ -#! /bin/sh +#! /usr/bin/bc # # SPDX-License-Identifier: BSD-2-Clause # @@ -27,25 +27,15 @@ # POSSIBILITY OF SUCH DAMAGE. # -set -e +max = 1000 +max2 = 1000 -script="$0" +for (i = 0; i < max; ++i) { -testdir=$(dirname "$script") + print "c = ", i, "\n" + print "e = 0.", i, "\n" -if [ "$#" -lt 2 ]; then - printf 'usage: %s dir test\n' "$0" - printf 'valid dirs are:\n' - printf '\n' - cat "$testdir/all.txt" - printf '\n' - exit 1 -fi - -d="$1" -shift - -t="$1" -shift - -exec diff "$testdir/$d/${t}_results.txt" "$testdir/${d}_outputs/${t}_results.txt" + for (j = 0; j < max2; ++j) { + print "d = ", i, ".", j, "\n" + } +} diff --git a/contrib/bc/benchmarks/bc/divide.bc b/contrib/bc/benchmarks/bc/divide.bc new file mode 100644 index 000000000000..227794badbcb --- /dev/null +++ b/contrib/bc/benchmarks/bc/divide.bc @@ -0,0 +1,26 @@ +#! /usr/bin/bc -lq + +print "scale = 20\n" +print "x = 1234567890 * 10^(-scale)\n" +print "len = 1 + 2 * scale\n" +print "scale += 10\n" + +scale = 20 +x = 1234567890 * 10^(-scale) +len = 1 + 2 * scale + +scale += 10 + +for (i = 0; i <= len; ++i) { + print "a[", i, "] = x * (10^", i, ")\n" +} + +for (i = 1; i <= 10000; ++i) { + for (j = 0; j < len; ++j) { + print "v = a[0] / a[", j, "]\n" + print "v = a[", i, "] / a[", j, "]\n" + print "v = (a[0] * ", i, ") / a[", j, "]\n" + print "v = a[0] / (a[", j, "] * ", i, ")\n" + print "v = (a[0] * ", i, ") / (a[", j, "] * ", i, ")\n" + } +} diff --git a/contrib/bc/benchmarks/bc/functions.bc b/contrib/bc/benchmarks/bc/functions.bc new file mode 100644 index 000000000000..dc6ae8d6edc5 --- /dev/null +++ b/contrib/bc/benchmarks/bc/functions.bc @@ -0,0 +1,34 @@ +#! /usr/bin/bc +# +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2018-2021 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. +# + +max = 1000000 + +for (i = 0; i < max; ++i) { + print "define etsna", i, "(n) {\n\tn\n}\n" +} diff --git a/contrib/bc/benchmarks/bc/irand_long.bc b/contrib/bc/benchmarks/bc/irand_long.bc new file mode 100644 index 000000000000..9274f8953b60 --- /dev/null +++ b/contrib/bc/benchmarks/bc/irand_long.bc @@ -0,0 +1,9 @@ +#! /usr/bin/bc -lq + +start = 2^256 +end = start + 10000000 + +for (i = start; i < end; ++i) { + print "irand(", i, ")\n" +} + diff --git a/contrib/bc/benchmarks/bc/irand_short.bc b/contrib/bc/benchmarks/bc/irand_short.bc new file mode 100644 index 000000000000..16ae863f2e2b --- /dev/null +++ b/contrib/bc/benchmarks/bc/irand_short.bc @@ -0,0 +1,5 @@ +#! /usr/bin/bc -lq + +for (i = 2; i < 10000000; ++i) { + print "irand(", i, ")\n" +} diff --git a/contrib/bc/benchmarks/bc/lib.bc b/contrib/bc/benchmarks/bc/lib.bc new file mode 100644 index 000000000000..87b5f9168458 --- /dev/null +++ b/contrib/bc/benchmarks/bc/lib.bc @@ -0,0 +1,7 @@ +#! /usr/bin/bc -lq + +print "for (i = 100; i < 1000; ++i) {\n" +print " v = pi(i)\n" +print " v = e(v)\n" +print " v = l(v)\n" +print "}\n" diff --git a/contrib/bc/benchmarks/bc/multiply.bc b/contrib/bc/benchmarks/bc/multiply.bc new file mode 100644 index 000000000000..d4ed08e055c8 --- /dev/null +++ b/contrib/bc/benchmarks/bc/multiply.bc @@ -0,0 +1,23 @@ +#! /usr/bin/bc -lq + +print "scale = 20\n" +print "x = 1234567890 / scale\n" +print "len = length(x) + 1 + scale\n" + +scale = 20 +x = 1234567890 / scale +len = length(x) + 1 + scale + +for (i = 0; i <= len; ++i) { + print "a[", i, "] = x * (10^", i, ")\n" +} + +for (i = 1; i <= 10000; ++i) { + for (j = 0; j < len; ++j) { + print "v = a[0] * a[", j, "]\n" + print "v = a[", i, "] * a[", j, "]\n" + print "v = (a[0] * ", i, ") * a[", j, "]\n" + print "v = a[0] * (a[", j, "] * ", i, ")\n" + print "v = (a[0] * ", i, ") * (a[", j, "] * ", i, ")\n" + } +} diff --git a/contrib/bc/benchmarks/bc/postfix_incdec.bc b/contrib/bc/benchmarks/bc/postfix_incdec.bc new file mode 100644 index 000000000000..922a065a8172 --- /dev/null +++ b/contrib/bc/benchmarks/bc/postfix_incdec.bc @@ -0,0 +1,7 @@ +#! /usr/bin/bc -lq + +max = 1000000 + +for (i = 0; i < max; ++i) { + print "i++\ni--\n" +} diff --git a/contrib/bc/benchmarks/bc/power.bc b/contrib/bc/benchmarks/bc/power.bc new file mode 100644 index 000000000000..b067aa732d10 --- /dev/null +++ b/contrib/bc/benchmarks/bc/power.bc @@ -0,0 +1,2 @@ +#! /usr/bin/bc -lq + diff --git a/contrib/bc/benchmarks/bc/strings.bc b/contrib/bc/benchmarks/bc/strings.bc new file mode 100644 index 000000000000..13cf200cdb89 --- /dev/null +++ b/contrib/bc/benchmarks/bc/strings.bc @@ -0,0 +1,36 @@ +#! /usr/bin/bc +# +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2018-2021 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. +# + +max = 1000000 + +print "\qasotehnuasnotehustnaoheusntaoheustnaoheusntaoehunsatoheuastoehuaosnetuhaosetnuhaosentuahoesntuahoeuhstoeunhatoehusanotehusatnoheus\q\n" + +for (i = 0; i < max; ++i) { + print "\qabc", i, " = ", i, "\\n\q\n" +} diff --git a/contrib/bc/benchmarks/bc/subtract.bc b/contrib/bc/benchmarks/bc/subtract.bc new file mode 100644 index 000000000000..b88bd60e935c --- /dev/null +++ b/contrib/bc/benchmarks/bc/subtract.bc @@ -0,0 +1,22 @@ +#! /usr/bin/bc -lq + +print "scale = 20\n" +print "x = 1234567890 / scale\n" +print "len = length(x) + 1 + scale\n" +print "len *= 2\n" + +scale = 20 +x = 1234567890 / scale +len = length(x) + 1 + scale +len *= 2 + +for (i = 0; i <= len; ++i) { + print "a[", i, "] = x * (10^", i, ")\n" +} + +for (i = 1; i <= 10000; ++i) { + for (j = 0; j < len; ++j) { + print "v = a[", i, "] - a[", j, "]\n" + } +} + diff --git a/contrib/bc/benchmarks/dc/modexp.dc b/contrib/bc/benchmarks/dc/modexp.dc new file mode 100644 index 000000000000..48f304cb92da --- /dev/null +++ b/contrib/bc/benchmarks/dc/modexp.dc @@ -0,0 +1,42 @@ +#! /usr/bin/dc +# +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2018-2021 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. + +[ ]ss +[|]so +100sm 0si +[ + li1+si 0sj + [ + lj1+sj 0sk + [ + lk1+sk lin lsn ljn lsn lkn lsn lon 10P lk lm !> "$scriptdir/Makefile" - continue - fi - - fi - - printf 'test_%s_%s:\n\t@sh tests/test.sh %s %s %s %s %s\n\n' \ - "$_gen_tests_name" "$_gen_tests_t" "$_gen_tests_name" \ - "$_gen_tests_t" "$generate_tests" "$time_tests" \ - "$*" >> "$scriptdir/Makefile" - - done -} - -gen_test_targets() { - - _gen_test_targets_name="$1" - shift - - _gen_test_targets_tests=$(cat "$scriptdir/tests/${_gen_test_targets_name}/all.txt") - - for _gen_test_targets_t in $_gen_test_targets_tests; do - printf ' test_%s_%s' "$_gen_test_targets_name" "$_gen_test_targets_t" - done - - printf '\n' -} - -gen_script_tests() { - - _gen_script_tests_name="$1" - shift - - _gen_script_tests_extra_math="$1" - shift - - _gen_script_tests_generate="$1" - shift - - _gen_script_tests_time="$1" - shift - - _gen_script_tests_tests=$(cat "$scriptdir/tests/$_gen_script_tests_name/scripts/all.txt") - - for _gen_script_tests_f in $_gen_script_tests_tests; do - - _gen_script_tests_b=$(basename "$_gen_script_tests_f" ".${_gen_script_tests_name}") - - printf 'test_%s_script_%s:\n\t@sh tests/script.sh %s %s %s 1 %s %s %s\n\n' \ - "$_gen_script_tests_name" "$_gen_script_tests_b" "$_gen_script_tests_name" \ - "$_gen_script_tests_f" "$_gen_script_tests_extra_math" "$_gen_script_tests_generate" \ - "$_gen_script_tests_time" "$*" >> "$scriptdir/Makefile" - done -} - -gen_script_test_targets() { - - _gen_script_test_targets_name="$1" - shift - - _gen_script_test_targets_tests=$(cat "$scriptdir/tests/$_gen_script_test_targets_name/scripts/all.txt") - - for _gen_script_test_targets_f in $_gen_script_test_targets_tests; do - _gen_script_test_targets_b=$(basename "$_gen_script_test_targets_f" \ - ".$_gen_script_test_targets_name") - printf ' test_%s_script_%s' "$_gen_script_test_targets_name" \ - "$_gen_script_test_targets_b" - done - - printf '\n' -} - -bc_only=0 -dc_only=0 -coverage=0 -karatsuba_len=32 -debug=0 -hist=1 -extra_math=1 -optimization="" -generate_tests=1 -install_manpages=1 -nls=1 -prompt=1 -force=0 -strip_bin=1 -all_locales=0 -library=0 -fuzz=0 -time_tests=0 -vg=0 -memcheck=0 -clean=1 - -while getopts "abBcdDEfgGhHk:lMmNO:PStTvz-" opt; do - - case "$opt" in - a) library=1 ;; - b) bc_only=1 ;; - B) dc_only=1 ;; - c) coverage=1 ;; - C) clean=0 ;; - d) dc_only=1 ;; - D) bc_only=1 ;; - E) extra_math=0 ;; - f) force=1 ;; - g) debug=1 ;; - G) generate_tests=0 ;; - h) usage ;; - H) hist=0 ;; - k) karatsuba_len="$OPTARG" ;; - l) all_locales=1 ;; - m) memcheck=1 ;; - M) install_manpages=0 ;; - N) nls=0 ;; - O) optimization="$OPTARG" ;; - P) prompt=0 ;; - t) time_tests=1 ;; - T) strip_bin=0 ;; - v) vg=1 ;; - z) fuzz=1 ;; - -) - arg="$1" - arg="${arg#--}" - LONG_OPTARG="${arg#*=}" - case $arg in - help) usage ;; - library) library=1 ;; - bc-only) bc_only=1 ;; - dc-only) dc_only=1 ;; - coverage) coverage=1 ;; - debug) debug=1 ;; - force) force=1 ;; - prefix=?*) PREFIX="$LONG_OPTARG" ;; - prefix) - if [ "$#" -lt 2 ]; then - usage "No argument given for '--$arg' option" - fi - PREFIX="$2" - shift ;; - bindir=?*) BINDIR="$LONG_OPTARG" ;; - bindir) - if [ "$#" -lt 2 ]; then - usage "No argument given for '--$arg' option" - 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 - usage "No argument given for '--$arg' option" - fi - DATAROOTDIR="$2" - shift ;; - datadir=?*) DATADIR="$LONG_OPTARG" ;; - datadir) - if [ "$#" -lt 2 ]; then - usage "No argument given for '--$arg' option" - fi - DATADIR="$2" - shift ;; - mandir=?*) MANDIR="$LONG_OPTARG" ;; - mandir) - if [ "$#" -lt 2 ]; then - usage "No argument given for '--$arg' option" - fi - MANDIR="$2" - shift ;; - man1dir=?*) MAN1DIR="$LONG_OPTARG" ;; - man1dir) - if [ "$#" -lt 2 ]; then - usage "No argument given for '--$arg' option" - 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 - usage "No argument given for '--$arg' option" - fi - LOCALEDIR="$2" - shift ;; - karatsuba-len=?*) karatsuba_len="$LONG_OPTARG" ;; - karatsuba-len) - if [ "$#" -lt 2 ]; then - usage "No argument given for '--$arg' option" - fi - karatsuba_len="$1" - shift ;; - opt=?*) optimization="$LONG_OPTARG" ;; - opt) - if [ "$#" -lt 2 ]; then - usage "No argument given for '--$arg' option" - fi - optimization="$1" - shift ;; - disable-bc) dc_only=1 ;; - disable-dc) bc_only=1 ;; - disable-clean) clean=0 ;; - disable-extra-math) extra_math=0 ;; - disable-generated-tests) generate_tests=0 ;; - disable-history) hist=0 ;; - disable-man-pages) install_manpages=0 ;; - disable-nls) nls=0 ;; - disable-prompt) prompt=0 ;; - disable-strip) strip_bin=0 ;; - enable-test-timing) time_tests=1 ;; - enable-valgrind) vg=1 ;; - enable-fuzz-mode) fuzz=1 ;; - enable-memcheck) memcheck=1 ;; - install-all-locales) all_locales=1 ;; - help* | bc-only* | dc-only* | coverage* | debug*) - usage "No arg allowed for --$arg option" ;; - disable-bc* | disable-dc* | disable-clean*) - usage "No arg allowed for --$arg option" ;; - disable-extra-math*) - usage "No arg allowed for --$arg option" ;; - disable-generated-tests* | disable-history*) - usage "No arg allowed for --$arg option" ;; - disable-man-pages* | disable-nls* | disable-strip*) - usage "No arg allowed for --$arg option" ;; - enable-fuzz-mode* | enable-test-timing* | enable-valgrind*) - usage "No arg allowed for --$arg option" ;; - enable-memcheck* | install-all-locales*) - usage "No arg allowed for --$arg option" ;; - '') break ;; # "--" terminates argument processing - * ) usage "Invalid option $LONG_OPTARG" ;; - esac - shift - OPTIND=1 ;; - ?) usage "Invalid option $opt" ;; - esac - -done - -if [ "$clean" -ne 0 ]; then - if [ -f ./Makefile ]; then - make clean_config > /dev/null - fi -fi - -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" ;; - (*) ;; -esac - -if [ "$karatsuba_len" -lt 16 ]; then - usage "KARATSUBA_LEN is less than 16" -fi - -set -e - -if [ -z "${LONG_BIT+set}" ]; then - LONG_BIT_DEFINE="" -elif [ "$LONG_BIT" -lt 32 ]; then - usage "LONG_BIT is less than 32" -else - LONG_BIT_DEFINE="-DBC_LONG_BIT=\$(BC_LONG_BIT)" -fi - -if [ -z "$CC" ]; then - CC="c99" -else - ccbase=$(basename "$CC") - suffix=" *" - prefix="* " - - if [ "${ccbase%%$suffix}" != "$ccbase" ]; then - ccflags="${ccbase#$prefix}" - cc="${ccbase%%$suffix}" - ccdir=$(dirname "$CC") - if [ "$ccdir" = "." ] && [ "${CC#.}" = "$CC" ]; then - ccdir="" - else - ccdir="$ccdir/" - fi - CC="${ccdir}${cc}" - CFLAGS="$CFLAGS $ccflags" - fi -fi - -if [ -z "$HOSTCC" ] && [ -z "$HOST_CC" ]; then - HOSTCC="$CC" -elif [ -z "$HOSTCC" ]; then - HOSTCC="$HOST_CC" -fi - -if [ "$HOSTCC" != "$CC" ]; then - ccbase=$(basename "$HOSTCC") - suffix=" *" - prefix="* " - - if [ "${ccbase%%$suffix}" != "$ccbase" ]; then - ccflags="${ccbase#$prefix}" - cc="${ccbase%%$suffix}" - ccdir=$(dirname "$HOSTCC") - if [ "$ccdir" = "." ] && [ "${HOSTCC#.}" = "$HOSTCC" ]; then - ccdir="" - else - ccdir="$ccdir/" - fi - HOSTCC="${ccdir}${cc}" - HOSTCFLAGS="$HOSTCFLAGS $ccflags" - fi -fi - -if [ -z "${HOSTCFLAGS+set}" ] && [ -z "${HOST_CFLAGS+set}" ]; then - HOSTCFLAGS="$CFLAGS" -elif [ -z "${HOSTCFLAGS+set}" ]; then - HOSTCFLAGS="$HOST_CFLAGS" -fi - -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)" -dc_test="@tests/all.sh dc $extra_math 1 $generate_tests 0 \$(DC_EXEC)" - -timeconst="@tests/bc/timeconst.sh tests/bc/scripts/timeconst.bc \$(BC_EXEC)" - -# In order to have cleanup at exit, we need to be in -# debug mode, so don't run valgrind without that. -if [ "$vg" -ne 0 ]; then - debug=1 - bc_test_exec='valgrind $(VALGRIND_ARGS) $(BC_EXEC)' - dc_test_exec='valgrind $(VALGRIND_ARGS) $(DC_EXEC)' -else - bc_test_exec='$(BC_EXEC)' - dc_test_exec='$(DC_EXEC)' -fi - -karatsuba="@printf 'karatsuba cannot be run because one of bc or dc is not built\\\\n'" -karatsuba_test="@printf 'karatsuba cannot be run because one of bc or dc is not built\\\\n'" - -bc_lib="\$(GEN_DIR)/lib.o" -bc_help="\$(GEN_DIR)/bc_help.o" -dc_help="\$(GEN_DIR)/dc_help.o" - -default_target_prereqs="\$(BIN) \$(OBJS)" -default_target_cmd="\$(CC) \$(CFLAGS) \$(OBJS) \$(LDFLAGS) -o \$(EXEC)" -default_target="\$(DC_EXEC)" - -second_target_prereqs="" -second_target_cmd="$default_target_cmd" -second_target="\$(BC_EXEC)" - -if [ "$library" -ne 0 ]; then - - extra_math=1 - nls=0 - hist=0 - prompt=0 - bc=1 - dc=1 - - default_target_prereqs="\$(BIN) \$(OBJ)" - default_target_cmd="ar -r -cu \$(LIBBC) \$(OBJ)" - default_target="\$(LIBBC)" - tests="test_library" - -elif [ "$bc_only" -eq 1 ]; then - - bc=1 - dc=0 - - dc_help="" - - executables="bc" - - dc_test="@printf 'No dc tests to run\\\\n'" - - install_prereqs=" install_execs" - install_man_prereqs=" install_bc_manpage" - uninstall_prereqs=" uninstall_bc" - uninstall_man_prereqs=" uninstall_bc_manpage" - - default_target="\$(BC_EXEC)" - second_target="\$(DC_EXEC)" - tests="test_bc timeconst" - -elif [ "$dc_only" -eq 1 ]; then - - bc=0 - dc=1 - - bc_lib="" - bc_help="" - - executables="dc" - - main_exec="DC" - executable="DC_EXEC" - - bc_test="@printf 'No bc tests to run\\\\n'" - - timeconst="@printf 'timeconst cannot be run because bc is not built\\\\n'" - - install_prereqs=" install_execs" - install_man_prereqs=" install_dc_manpage" - uninstall_prereqs=" uninstall_dc" - uninstall_man_prereqs=" uninstall_dc_manpage" - - tests="test_dc" - -else - - bc=1 - dc=1 - - executables="bc and dc" - - karatsuba="@\$(KARATSUBA) 30 0 \$(BC_EXEC)" - karatsuba_test="@\$(KARATSUBA) 1 100 \$(BC_EXEC)" - - 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 - - second_target_prereqs="$default_target_prereqs" - default_target_prereqs="$second_target" - default_target_cmd="\$(LINK) \$(BIN) \$(EXEC_PREFIX)\$(DC)" - -fi - -if [ "$fuzz" -ne 0 ]; then - debug=1 - hist=0 - prompt=0 - nls=0 - optimization="3" -fi - -if [ "$debug" -eq 1 ]; then - - if [ -z "$CFLAGS" ] && [ -z "$optimization" ]; then - CFLAGS="-O0" - fi - - CFLAGS="-g $CFLAGS" - -else - CPPFLAGS="-DNDEBUG $CPPFLAGS" - if [ "$strip_bin" -ne 0 ]; then - LDFLAGS="-s $LDFLAGS" - fi -fi - -if [ -n "$optimization" ]; then - CFLAGS="-O$optimization $CFLAGS" -fi - -if [ "$coverage" -eq 1 ]; then - - if [ "$bc_only" -eq 1 ] || [ "$dc_only" -eq 1 ]; then - usage "Can only specify -c without -b or -d" - fi - - CFLAGS="-fprofile-arcs -ftest-coverage -g -O0 $CFLAGS" - CPPFLAGS="-DNDEBUG $CPPFLAGS" - - COVERAGE_OUTPUT="@gcov -pabcdf \$(GCDA) \$(BC_GCDA) \$(DC_GCDA) \$(HISTORY_GCDA) \$(RAND_GCDA)" - COVERAGE_OUTPUT="$COVERAGE_OUTPUT;\$(RM) -f \$(GEN)*.gc*" - COVERAGE_OUTPUT="$COVERAGE_OUTPUT;gcovr --html-details --output index.html" - COVERAGE_PREREQS=" test coverage_output" - -else - COVERAGE_OUTPUT="@printf 'Coverage not generated\\\\n'" - COVERAGE_PREREQS="" -fi - -if [ -z "${DESTDIR+set}" ]; then - destdir="" -else - destdir="DESTDIR = $DESTDIR" -fi - -if [ -z "${PREFIX+set}" ]; then - PREFIX="/usr/local" -fi - -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" - fi -fi - -if [ "$install_manpages" -ne 0 ]; then - - if [ -z "${DATADIR+set}" ]; then - DATADIR="$DATAROOTDIR" - fi - - if [ -z "${MANDIR+set}" ]; then - MANDIR="$DATADIR/man" - fi - - if [ -z "${MAN1DIR+set}" ]; then - MAN1DIR="$MANDIR/man1" - fi - - if [ -z "${MAN3DIR+set}" ]; then - MAN3DIR="$MANDIR/man3" - fi - -else - install_man_prereqs="" - uninstall_man_prereqs="" -fi - -if [ "$nls" -ne 0 ]; then - - set +e - - printf 'Testing NLS...\n' - - flags="-DBC_ENABLE_NLS=1 -DBC_ENABLED=$bc -DDC_ENABLED=$dc" - flags="$flags -DBC_ENABLE_HISTORY=$hist" - 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/vm.c" -o "$scriptdir/vm.o" > /dev/null 2>&1 - - err="$?" - - rm -rf "$scriptdir/vm.o" - - # If this errors, it is probably because of building on Windows, - # and NLS is not supported on Windows, so disable it. - if [ "$err" -ne 0 ]; then - printf 'NLS does not work.\n' - if [ $force -eq 0 ]; then - printf 'Disabling NLS...\n\n' - nls=0 - else - printf 'Forcing NLS...\n\n' - fi - else - printf 'NLS works.\n\n' - - printf 'Testing gencat...\n' - gencat "$scriptdir/en_US.cat" "$scriptdir/locales/en_US.msg" > /dev/null 2>&1 - - err="$?" - - rm -rf "$scriptdir/en_US.cat" - - if [ "$err" -ne 0 ]; then - printf 'gencat does not work.\n' - if [ $force -eq 0 ]; then - printf 'Disabling NLS...\n\n' - nls=0 - else - printf 'Forcing NLS...\n\n' - fi - else - - printf 'gencat works.\n\n' - - if [ "$HOSTCC" != "$CC" ]; then - printf 'Cross-compile detected.\n\n' - printf 'WARNING: Catalog files generated with gencat may not be portable\n' - printf ' across different architectures.\n\n' - fi - - if [ -z "$NLSPATH" ]; then - NLSPATH="/usr/share/locale/%L/%N" - fi - - install_locales_prereqs=" install_locales" - uninstall_locales_prereqs=" uninstall_locales" - - fi - - fi - - set -e - -else - install_locales_prereqs="" - uninstall_locales_prereqs="" - all_locales=0 -fi - -if [ "$nls" -ne 0 ] && [ "$all_locales" -ne 0 ]; then - install_locales="\$(LOCALE_INSTALL) -l \$(NLSPATH) \$(MAIN_EXEC) \$(DESTDIR)" -else - install_locales="\$(LOCALE_INSTALL) \$(NLSPATH) \$(MAIN_EXEC) \$(DESTDIR)" -fi - -if [ "$hist" -eq 1 ]; then - - set +e - - printf 'Testing history...\n' - - flags="-DBC_ENABLE_HISTORY=1 -DBC_ENABLED=$bc -DDC_ENABLED=$dc" - 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.c" -o "$scriptdir/history.o" > /dev/null 2>&1 - - err="$?" - - rm -rf "$scriptdir/history.o" - - # If this errors, it is probably because of building on Windows, - # and history is not supported on Windows, so disable it. - if [ "$err" -ne 0 ]; then - printf 'History does not work.\n' - if [ $force -eq 0 ]; then - printf 'Disabling history...\n\n' - hist=0 - else - printf 'Forcing history...\n\n' - fi - else - printf 'History works.\n\n' - fi - - set -e - -fi - -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="" -fi - -GEN="strgen" -GEN_EXEC_TARGET="\$(HOSTCC) \$(HOSTCFLAGS) -o \$(GEN_EXEC) \$(GEN_C)" -CLEAN_PREREQS=" clean_gen" - -if [ -z "${GEN_HOST+set}" ]; then - GEN_HOST=1 -else - if [ "$GEN_HOST" -eq 0 ]; then - GEN="strgen.sh" - GEN_EXEC_TARGET="@printf 'Do not need to build gen/strgen.c\\\\n'" - CLEAN_PREREQS="" - fi -fi - -manpage_args="" -unneeded="" -headers="\$(HEADERS)" - -if [ "$extra_math" -eq 0 ]; then - manpage_args="E" - unneeded="$unneeded rand.c" -else - headers="$headers \$(EXTRA_MATH_HEADERS)" -fi - -if [ "$hist" -eq 0 ]; then - manpage_args="${manpage_args}H" - unneeded="$unneeded history.c" -else - headers="$headers \$(HISTORY_HEADERS)" -fi - -if [ "$nls" -eq 0 ]; then - manpage_args="${manpage_args}N" -fi - -if [ "$prompt" -eq 0 ]; then - manpage_args="${manpage_args}P" -fi - -if [ "$bc" -eq 0 ]; then - unneeded="$unneeded bc.c bc_lex.c bc_parse.c" -else - headers="$headers \$(BC_HEADERS)" -fi - -if [ "$dc" -eq 0 ]; then - unneeded="$unneeded dc.c dc_lex.c dc_parse.c" -else - headers="$headers \$(DC_HEADERS)" -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" - headers="$headers \$(LIBRARY_HEADERS)" -else - unneeded="$unneeded library.c" -fi - -if [ "$manpage_args" = "" ]; then - manpage_args="A" -fi - -if [ "$vg" -ne 0 ]; then - memcheck=1 -fi - -bc_tests=$(gen_test_targets bc) -bc_script_tests=$(gen_script_test_targets bc) -dc_tests=$(gen_test_targets dc) -dc_script_tests=$(gen_script_test_targets dc) - -# Print out the values; this is for debugging. -if [ "$bc" -ne 0 ]; then - printf 'Building bc\n' -else - printf 'Not building bc\n' -fi -if [ "$dc" -ne 0 ]; then - printf 'Building dc\n' -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" -printf 'BC_ENABLE_PROMPT=%s\n' "$prompt" -printf 'BC_ENABLE_AFL=%s\n' "$fuzz" -printf '\n' -printf 'BC_NUM_KARATSUBA_LEN=%s\n' "$karatsuba_len" -printf '\n' -printf 'CC=%s\n' "$CC" -printf 'CFLAGS=%s\n' "$CFLAGS" -printf 'HOSTCC=%s\n' "$HOSTCC" -printf 'HOSTCFLAGS=%s\n' "$HOSTCFLAGS" -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" -printf 'DESTDIR=%s\n' "$DESTDIR" -printf 'LONG_BIT=%s\n' "$LONG_BIT" -printf 'GEN_HOST=%s\n' "$GEN_HOST" -printf 'GEN_EMU=%s\n' "$GEN_EMU" - -contents=$(cat "$scriptdir/Makefile.in") - -needle="WARNING" -replacement='*** WARNING: Autogenerated from Makefile.in. DO NOT MODIFY ***' - -contents=$(replace "$contents" "$needle" "$replacement") - -if [ "$unneeded" = "" ]; then - unneeded="library.c" -fi - -contents=$(gen_file_list "$contents" $unneeded) - -SRC_TARGETS="" - -src_files=$(find_src_files $unneeded) - -for f in $src_files; do - o=$(replace_ext "$f" "c" "o") - SRC_TARGETS=$(printf '%s\n\n%s: %s %s\n\t$(CC) $(CFLAGS) -o %s -c %s\n' \ - "$SRC_TARGETS" "$o" "$headers" "$f" "$o" "$f") -done - -contents=$(replace "$contents" "HEADERS" "$headers") - -contents=$(replace "$contents" "BC_ENABLED" "$bc") -contents=$(replace "$contents" "DC_ENABLED" "$dc") - -contents=$(replace "$contents" "BC_ALL_TESTS" "$bc_test") -contents=$(replace "$contents" "BC_TESTS" "$bc_tests") -contents=$(replace "$contents" "BC_SCRIPT_TESTS" "$bc_script_tests") -contents=$(replace "$contents" "BC_TEST_EXEC" "$bc_test_exec") -contents=$(replace "$contents" "TIMECONST_ALL_TESTS" "$timeconst") - -contents=$(replace "$contents" "DC_ALL_TESTS" "$dc_test") -contents=$(replace "$contents" "DC_TESTS" "$dc_tests") -contents=$(replace "$contents" "DC_SCRIPT_TESTS" "$dc_script_tests") -contents=$(replace "$contents" "DC_TEST_EXEC" "$dc_test_exec") - -contents=$(replace "$contents" "BUILD_TYPE" "$manpage_args") - -contents=$(replace "$contents" "LIBRARY" "$library") -contents=$(replace "$contents" "HISTORY" "$hist") -contents=$(replace "$contents" "EXTRA_MATH" "$extra_math") -contents=$(replace "$contents" "NLS" "$nls") -contents=$(replace "$contents" "PROMPT" "$prompt") -contents=$(replace "$contents" "FUZZ" "$fuzz") -contents=$(replace "$contents" "MEMCHECK" "$memcheck") - -contents=$(replace "$contents" "BC_LIB_O" "$bc_lib") -contents=$(replace "$contents" "BC_HELP_O" "$bc_help") -contents=$(replace "$contents" "DC_HELP_O" "$dc_help") -contents=$(replace "$contents" "BC_LIB2_O" "$BC_LIB2_O") -contents=$(replace "$contents" "KARATSUBA_LEN" "$karatsuba_len") - -contents=$(replace "$contents" "NLSPATH" "$NLSPATH") -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") -contents=$(replace "$contents" "LDFLAGS" "$LDFLAGS") -contents=$(replace "$contents" "CC" "$CC") -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" "DEFAULT_TARGET" "$default_target") -contents=$(replace "$contents" "DEFAULT_TARGET_PREREQS" "$default_target_prereqs") -contents=$(replace "$contents" "DEFAULT_TARGET_CMD" "$default_target_cmd") -contents=$(replace "$contents" "SECOND_TARGET" "$second_target") -contents=$(replace "$contents" "SECOND_TARGET_PREREQS" "$second_target_prereqs") -contents=$(replace "$contents" "SECOND_TARGET_CMD" "$second_target_cmd") - -contents=$(replace "$contents" "ALL_PREREQ" "$ALL_PREREQ") -contents=$(replace "$contents" "BC_EXEC_PREREQ" "$bc_exec_prereq") -contents=$(replace "$contents" "BC_EXEC_CMD" "$bc_exec_cmd") -contents=$(replace "$contents" "DC_EXEC_PREREQ" "$dc_exec_prereq") -contents=$(replace "$contents" "DC_EXEC_CMD" "$dc_exec_cmd") - -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" "DC_TEST" "$dc_test") - -contents=$(replace "$contents" "VG_BC_TEST" "$vg_bc_test") -contents=$(replace "$contents" "VG_DC_TEST" "$vg_dc_test") - -contents=$(replace "$contents" "TIMECONST" "$timeconst") - -contents=$(replace "$contents" "KARATSUBA" "$karatsuba") -contents=$(replace "$contents" "KARATSUBA_TEST" "$karatsuba_test") - -contents=$(replace "$contents" "LONG_BIT" "$LONG_BIT") -contents=$(replace "$contents" "LONG_BIT_DEFINE" "$LONG_BIT_DEFINE") - -contents=$(replace "$contents" "GEN" "$GEN") -contents=$(replace "$contents" "GEN_EXEC_TARGET" "$GEN_EXEC_TARGET") -contents=$(replace "$contents" "CLEAN_PREREQS" "$CLEAN_PREREQS") -contents=$(replace "$contents" "GEN_EMU" "$GEN_EMU") - -printf '%s\n%s\n\n' "$contents" "$SRC_TARGETS" > "$scriptdir/Makefile" - -if [ "$bc" -ne 0 ]; then - gen_tests bc BC "$extra_math" "$time_tests" $bc_test_exec - gen_script_tests bc "$extra_math" "$generate_tests" "$time_tests" $bc_test_exec -fi - -if [ "$dc" -ne 0 ]; then - gen_tests dc DC "$extra_math" "$time_tests" $dc_test_exec - gen_script_tests dc "$extra_math" "$generate_tests" "$time_tests" $dc_test_exec -fi - -cd "$scriptdir" - -cp -f manuals/bc/$manpage_args.1.md manuals/bc.1.md -cp -f manuals/bc/$manpage_args.1 manuals/bc.1 -cp -f manuals/dc/$manpage_args.1.md manuals/dc.1.md -cp -f manuals/dc/$manpage_args.1 manuals/dc.1 - -make clean > /dev/null diff --git a/contrib/bc/configure b/contrib/bc/configure new file mode 120000 index 000000000000..bd7a56adb6f9 --- /dev/null +++ b/contrib/bc/configure @@ -0,0 +1 @@ +configure.sh \ No newline at end of file diff --git a/contrib/bc/configure.sh b/contrib/bc/configure.sh index af96564e7702..bcc8688e0ec1 100755 --- a/contrib/bc/configure.sh +++ b/contrib/bc/configure.sh @@ -31,10 +31,12 @@ script="$0" scriptdir=$(dirname "$script") script=$(basename "$script") -. "$scriptdir/functions.sh" +. "$scriptdir/scripts/functions.sh" cd "$scriptdir" +# Simply prints the help message and quits based on the argument. +# @param val The value to pass to exit. Must be an integer. usage() { if [ $# -gt 0 ]; then @@ -52,16 +54,16 @@ usage() { printf ' %s --help\n' "$script" printf ' %s [-a|-bD|-dB|-c] [-CEfgGHlmMNPtTvz] [-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 ' [--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 --disable-strip] \\\n' + printf ' [--install-all-locales] [--opt=OPT_LEVEL] \\\n' + printf ' [--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 ' Build the libbcl 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' @@ -72,7 +74,7 @@ usage() { printf ' Disable bc. It is an error if "-b", "--bc-only", "-D", or "--disable-dc"\n' printf ' are specified too.\n' printf ' -c, --coverage\n' - printf ' Generate test coverage code. Requires gcov and regcovr.\n' + printf ' Generate test coverage code. Requires gcov and gcovr.\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 ' -C, --disable-clean\n' @@ -121,10 +123,14 @@ usage() { printf ' Set the optimization level. This can also be included in the CFLAGS,\n' printf ' but it is provided, so maintainers can build optimized debug builds.\n' printf ' This is passed through to the compiler, so it must be supported.\n' - printf ' -P, --disable-prompt\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 ' enabled.\n' + printf ' -s SETTING, --set-default-on SETTING\n' + printf ' Set the default named by SETTING to on. See below for possible values\n' + printf ' for SETTING. For multiple instances of the -s or -S for the the same\n' + printf ' setting, the last one is used.\n' + printf ' -S SETTING, --set-default-off SETTING\n' + printf ' Set the default named by SETTING to off. See below for possible values\n' + printf ' for SETTING. For multiple instances of the -s or -S for the the same\n' + printf ' setting, the last one is used.\n' printf ' -t, --enable-test-timing\n' printf ' Enable the timing of tests. This is for development only.\n' printf ' -T, --disable-strip\n' @@ -239,10 +245,66 @@ usage() { printf '\n' printf 'WARNING: even though `configure.sh` supports both option types, short and\n' printf 'long, it does not support handling both at the same time. Use only one type.\n' + printf '\n' + printf 'Settings\n' + printf '========\n' + printf '\n' + printf 'bc and dc have some settings that, while they cannot be removed by build time\n' + printf 'options, can have their defaults changed at build time by packagers. Users are\n' + printf 'also able to change each setting with environment variables.\n' + printf '\n' + printf 'The following is a table of settings, along with their default values and the\n' + printf 'environment variables users can use to change them. (For the defaults, non-zero\n' + printf 'means on, and zero means off.)\n' + printf '\n' + printf '| Setting | Description | Default | Env Variable |\n' + printf '| =============== | ==================== | ============ | ==================== |\n' + printf '| bc.banner | Whether to display | 0 | BC_BANNER |\n' + printf '| | the bc version | | |\n' + printf '| | banner when in | | |\n' + printf '| | interactive mode. | | |\n' + printf '| --------------- | -------------------- | ------------ | -------------------- |\n' + printf '| bc.sigint_reset | Whether SIGINT will | 1 | BC_SIGINT_RESET |\n' + printf '| | reset bc, instead of | | |\n' + printf '| | exiting, when in | | |\n' + printf '| | interactive mode. | | |\n' + printf '| --------------- | -------------------- | ------------ | -------------------- |\n' + printf '| dc.sigint_reset | Whether SIGINT will | 1 | DC_SIGINT_RESET |\n' + printf '| | reset dc, instead of | | |\n' + printf '| | exiting, when in | | |\n' + printf '| | interactive mode. | | |\n' + printf '| --------------- | -------------------- | ------------ | -------------------- |\n' + printf '| bc.tty_mode | Whether TTY mode for | 1 | BC_TTY_MODE |\n' + printf '| | bc should be on when | | |\n' + printf '| | available. | | |\n' + printf '| --------------- | -------------------- | ------------ | -------------------- |\n' + printf '| dc.tty_mode | Whether TTY mode for | 0 | BC_TTY_MODE |\n' + printf '| | dc should be on when | | |\n' + printf '| | available. | | |\n' + printf '| --------------- | -------------------- | ------------ | -------------------- |\n' + printf '| bc.prompt | Whether the prompt | $BC_TTY_MODE | BC_PROMPT |\n' + printf '| | for bc should be on | | |\n' + printf '| | in tty mode. | | |\n' + printf '| --------------- | -------------------- | ------------ | -------------------- |\n' + printf '| dc.prompt | Whether the prompt | $DC_TTY_MODE | DC_PROMPT |\n' + printf '| | for dc should be on | | |\n' + printf '| | in tty mode. | | |\n' + printf '| --------------- | -------------------- | ------------ | -------------------- |\n' + printf '\n' + printf 'These settings are not meant to be changed on a whim. They are meant to ensure\n' + printf 'that this bc and dc will conform to the expectations of the user on each\n' + printf 'platform.\n' exit "$_usage_val" } +# Replaces a file extension in a filename. This is used mostly to turn filenames +# like `src/num.c` into `src/num.o`. In other words, it helps to link targets to +# the files they depend on. +# +# @param file The filename. +# @param ext1 The extension to replace. +# @param ext2 The new extension. replace_ext() { if [ "$#" -ne 3 ]; then @@ -258,6 +320,13 @@ replace_ext() { printf '%s\n' "$_replace_ext_result" } +# Replaces a file extension in every filename given in a list. The list is just +# a space-separated list of words, so filenames are expected to *not* have +# spaces in them. See the documentation for `replace_ext()`. +# +# @param files The list of space-separated filenames to replace extensions for. +# @param ext1 The extension to replace. +# @param ext2 The new extension. replace_exts() { if [ "$#" -ne 3 ]; then @@ -276,6 +345,17 @@ replace_exts() { printf '%s\n' "$_replace_exts_result" } +# Finds a placeholder in @a str and replaces it. This is the workhorse of +# configure.sh. It's what replaces placeholders in Makefile.in with the data +# needed for the chosen build. Below, you will see a lot of calls to this +# function. +# +# Note that needle can never contain an exclamation point. For more information, +# see substring_replace() in scripts/functions.sh. +# +# @param str The string to find and replace placeholders in. +# @param needle The placeholder name. +# @param replacement The string to use to replace the placeholder. replace() { if [ "$#" -ne 3 ]; then @@ -289,6 +369,9 @@ replace() { substring_replace "$_replace_str" "%%$_replace_needle%%" "$_replace_replacement" } +# This function finds all the source files that need to be built. If there is +# only one argument and it is empty, then all source files are built. Otherwise, +# the arguments are all assumed to be source files that should *not* be built. find_src_files() { if [ "$#" -ge 1 ] && [ "$1" != "" ]; then @@ -306,6 +389,11 @@ find_src_files() { printf '%s\n' $(find src/ -depth -name "*.c" $_find_src_files_args) } +# This function generates a list of files to go into the Makefile. It generates +# the list of object files, as well as the list of test coverage files. +# +# @param contents The contents of the Makefile template to put the list of +# files into. gen_file_list() { if [ "$#" -lt 1 ]; then @@ -351,21 +439,25 @@ gen_file_list() { printf '%s\n' "$_gen_file_list_contents" } +# Generates the proper test targets for each test to have its own target. This +# allows `make test` to run in parallel. +# +# @param name Which calculator to generate tests for. +# @param extra_math An integer that, if non-zero, activates extra math tests. +# @param time_tests An integer that, if non-zero, tells the test suite to time +# the execution of each test. gen_tests() { _gen_tests_name="$1" shift - _gen_tests_uname="$1" - shift - _gen_tests_extra_math="$1" shift _gen_tests_time_tests="$1" shift - _gen_tests_extra_required=$(cat tests/extra_required.txt) + _gen_tests_extra_required=$(cat "$scriptdir/tests/extra_required.txt") for _gen_tests_t in $(cat "$scriptdir/tests/$_gen_tests_name/all.txt"); do @@ -388,6 +480,10 @@ gen_tests() { done } +# Generates a list of test targets that will be used as prerequisites for other +# targets. +# +# @param name The name of the calculator to generate test targets for. gen_test_targets() { _gen_test_targets_name="$1" @@ -402,6 +498,14 @@ gen_test_targets() { printf '\n' } +# Generates the proper script test targets for each script test to have its own +# target. This allows `make test` to run in parallel. +# +# @param name Which calculator to generate tests for. +# @param extra_math An integer that, if non-zero, activates extra math tests. +# @param generate An integer that, if non-zero, activates generated tests. +# @param time_tests An integer that, if non-zero, tells the test suite to time +# the execution of each test. gen_script_tests() { _gen_script_tests_name="$1" @@ -429,6 +533,36 @@ gen_script_tests() { done } +set_default() { + + _set_default_on="$1" + shift + + _set_default_name="$1" + shift + + # The reason that the variables that are being set do not have the same + # non-collision avoidance that the other variables do is that we *do* want + # the settings of these variables to leak out of the function. They adjust + # the settings outside of the function. + case "$_set_default_name" in + + bc.banner) bc_default_banner="$_set_default_on" ;; + bc.sigint_reset) bc_default_sigint_reset="$_set_default_on" ;; + dc.sigint_reset) dc_default_sigint_reset="$_set_default_on" ;; + bc.tty_mode) bc_default_tty_mode="$_set_default_on" ;; + dc.tty_mode) dc_default_tty_mode="$_set_default_on" ;; + bc.prompt) bc_default_prompt="$_set_default_on" ;; + dc.prompt) dc_default_prompt="$_set_default_on" ;; + ?) usage "Invalid setting: $_set_default_name" ;; + + esac +} + +# Generates a list of script test targets that will be used as prerequisites for +# other targets. +# +# @param name The name of the calculator to generate script test targets for. gen_script_test_targets() { _gen_script_test_targets_name="$1" @@ -446,6 +580,12 @@ gen_script_test_targets() { printf '\n' } +# This is a list of defaults, but it is also the list of possible options for +# users to change. +# +# The development options are: force (force options even if they fail), valgrind +# (build in a way suitable for valgrind testing), memcheck (same as valgrind), +# and fuzzing (build in a way suitable for fuzzing). bc_only=0 dc_only=0 coverage=0 @@ -457,7 +597,6 @@ optimization="" generate_tests=1 install_manpages=1 nls=1 -prompt=1 force=0 strip_bin=1 all_locales=0 @@ -468,7 +607,20 @@ vg=0 memcheck=0 clean=1 -while getopts "abBcdDEfgGhHk:lMmNO:PStTvz-" opt; do +# The empty strings are because they depend on TTY mode. If they are directly +# set, though, they will be integers. We test for empty strings later. +bc_default_banner=0 +bc_default_sigint_reset=1 +dc_default_sigint_reset=1 +bc_default_tty_mode=1 +dc_default_tty_mode=0 +bc_default_prompt="" +dc_default_prompt="" + +# getopts is a POSIX utility, but it cannot handle long options. Thus, the +# handling of long options is done by hand, and that's the reason that short and +# long options cannot be mixed. +while getopts "abBcdDEfgGhHk:lMmNO:S:s:tTvz-" opt; do case "$opt" in a) library=1 ;; @@ -490,7 +642,8 @@ while getopts "abBcdDEfgGhHk:lMmNO:PStTvz-" opt; do M) install_manpages=0 ;; N) nls=0 ;; O) optimization="$OPTARG" ;; - P) prompt=0 ;; + S) set_default 0 "$OPTARG" ;; + s) set_default 1 "$OPTARG" ;; t) time_tests=1 ;; T) strip_bin=0 ;; v) vg=1 ;; @@ -591,6 +744,20 @@ while getopts "abBcdDEfgGhHk:lMmNO:PStTvz-" opt; do fi optimization="$1" shift ;; + set-default-on=?*) set_default 1 "$LONG_OPTARG" ;; + set-default-on) + if [ "$#" -lt 2 ]; then + usage "No argument given for '--$arg' option" + fi + set_default 1 "$1" + shift ;; + set-default-off=?*) set_default 0 "$LONG_OPTARG" ;; + set-default-off) + if [ "$#" -lt 2 ]; then + usage "No argument given for '--$arg' option" + fi + set_default 0 "$1" + shift ;; disable-bc) dc_only=1 ;; disable-dc) bc_only=1 ;; disable-clean) clean=0 ;; @@ -599,7 +766,6 @@ while getopts "abBcdDEfgGhHk:lMmNO:PStTvz-" opt; do disable-history) hist=0 ;; disable-man-pages) install_manpages=0 ;; disable-nls) nls=0 ;; - disable-prompt) prompt=0 ;; disable-strip) strip_bin=0 ;; enable-test-timing) time_tests=1 ;; enable-valgrind) vg=1 ;; @@ -625,27 +791,33 @@ while getopts "abBcdDEfgGhHk:lMmNO:PStTvz-" opt; do esac shift OPTIND=1 ;; - ?) usage "Invalid option $opt" ;; + ?) usage "Invalid option: $opt" ;; esac done +# Sometimes, developers don't want configure.sh to do a config clean. But +# sometimes they do. if [ "$clean" -ne 0 ]; then if [ -f ./Makefile ]; then make clean_config > /dev/null fi fi +# It is an error to say that bc only should be built and likewise for dc. if [ "$bc_only" -eq 1 ] && [ "$dc_only" -eq 1 ]; then usage "Can only specify one of -b(-D) or -d(-B)" fi +# The library is mutually exclusive to the calculators, so it's an error to +# give an option for either of them. 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 +# KARATSUBA_LEN must be an integer and must be 16 or greater. case $karatsuba_len in (*[!0-9]*|'') usage "KARATSUBA_LEN is not a number" ;; (*) ;; @@ -668,6 +840,11 @@ fi if [ -z "$CC" ]; then CC="c99" else + + # I had users complain that, if they gave CFLAGS as part of CC, which + # autotools allows in its braindead way, the build would fail with an error. + # I don't like adjusting for autotools, but oh well. These lines puts the + # stuff after the first space into CFLAGS. ccbase=$(basename "$CC") suffix=" *" prefix="* " @@ -693,6 +870,8 @@ elif [ -z "$HOSTCC" ]; then fi if [ "$HOSTCC" != "$CC" ]; then + + # Like above, this splits HOSTCC and HOSTCFLAGS. ccbase=$(basename "$HOSTCC") suffix=" *" prefix="* " @@ -717,14 +896,18 @@ elif [ -z "${HOSTCFLAGS+set}" ]; then HOSTCFLAGS="$HOST_CFLAGS" fi +# Store these for the cross compilation detection later. +OLDCFLAGS="$CFLAGS" +OLDHOSTCFLAGS="$HOSTCFLAGS" + link="@printf 'No link necessary\\\\n'" main_exec="BC" executable="BC_EXEC" -tests="test_bc timeconst test_dc" +tests="test_bc timeconst test_dc test_history" -bc_test="@tests/all.sh bc $extra_math 1 $generate_tests 0 \$(BC_EXEC)" -dc_test="@tests/all.sh dc $extra_math 1 $generate_tests 0 \$(DC_EXEC)" +bc_test="@tests/all.sh bc $extra_math 1 $generate_tests $time_tests \$(BC_EXEC)" +dc_test="@tests/all.sh dc $extra_math 1 $generate_tests $time_tests \$(DC_EXEC)" timeconst="@tests/bc/timeconst.sh tests/bc/scripts/timeconst.bc \$(BC_EXEC)" @@ -739,6 +922,9 @@ else dc_test_exec='$(DC_EXEC)' fi +test_bc_history_prereqs="test_bc_history_all" +test_dc_history_prereqs="test_dc_history_all" + karatsuba="@printf 'karatsuba cannot be run because one of bc or dc is not built\\\\n'" karatsuba_test="@printf 'karatsuba cannot be run because one of bc or dc is not built\\\\n'" @@ -754,12 +940,13 @@ second_target_prereqs="" second_target_cmd="$default_target_cmd" second_target="\$(BC_EXEC)" +# This if/else if chain is for setting the defaults that change based on whether +# the library is being built, bc only, dc only, or both calculators. if [ "$library" -ne 0 ]; then extra_math=1 nls=0 hist=0 - prompt=0 bc=1 dc=1 @@ -767,6 +954,8 @@ if [ "$library" -ne 0 ]; then default_target_cmd="ar -r -cu \$(LIBBC) \$(OBJ)" default_target="\$(LIBBC)" tests="test_library" + test_bc_history_prereqs=" test_bc_history_skip" + test_dc_history_prereqs=" test_dc_history_skip" elif [ "$bc_only" -eq 1 ]; then @@ -778,6 +967,7 @@ elif [ "$bc_only" -eq 1 ]; then executables="bc" dc_test="@printf 'No dc tests to run\\\\n'" + test_dc_history_prereqs=" test_dc_history_skip" install_prereqs=" install_execs" install_man_prereqs=" install_bc_manpage" @@ -786,7 +976,7 @@ elif [ "$bc_only" -eq 1 ]; then default_target="\$(BC_EXEC)" second_target="\$(DC_EXEC)" - tests="test_bc timeconst" + tests="test_bc timeconst test_history" elif [ "$dc_only" -eq 1 ]; then @@ -802,6 +992,7 @@ elif [ "$dc_only" -eq 1 ]; then executable="DC_EXEC" bc_test="@printf 'No bc tests to run\\\\n'" + test_bc_history_prereqs=" test_bc_history_skip" timeconst="@printf 'timeconst cannot be run because bc is not built\\\\n'" @@ -810,7 +1001,7 @@ elif [ "$dc_only" -eq 1 ]; then uninstall_prereqs=" uninstall_dc" uninstall_man_prereqs=" uninstall_dc_manpage" - tests="test_dc" + tests="test_dc test_history" else @@ -841,14 +1032,15 @@ else fi +# We need specific stuff for fuzzing. if [ "$fuzz" -ne 0 ]; then debug=1 hist=0 - prompt=0 nls=0 optimization="3" fi +# This sets some necessary things for debug mode. if [ "$debug" -eq 1 ]; then if [ -z "$CFLAGS" ] && [ -z "$optimization" ]; then @@ -858,16 +1050,20 @@ if [ "$debug" -eq 1 ]; then CFLAGS="-g $CFLAGS" else + CPPFLAGS="-DNDEBUG $CPPFLAGS" + if [ "$strip_bin" -ne 0 ]; then LDFLAGS="-s $LDFLAGS" fi fi +# Set optimization CFLAGS. if [ -n "$optimization" ]; then CFLAGS="-O$optimization $CFLAGS" fi +# Set test coverage defaults. if [ "$coverage" -eq 1 ]; then if [ "$bc_only" -eq 1 ] || [ "$dc_only" -eq 1 ]; then @@ -879,7 +1075,7 @@ if [ "$coverage" -eq 1 ]; then COVERAGE_OUTPUT="@gcov -pabcdf \$(GCDA) \$(BC_GCDA) \$(DC_GCDA) \$(HISTORY_GCDA) \$(RAND_GCDA)" COVERAGE_OUTPUT="$COVERAGE_OUTPUT;\$(RM) -f \$(GEN)*.gc*" - COVERAGE_OUTPUT="$COVERAGE_OUTPUT;gcovr --html-details --output index.html" + COVERAGE_OUTPUT="$COVERAGE_OUTPUT;gcovr --exclude-unreachable-branches --exclude-throw-branches --html-details --output index.html" COVERAGE_PREREQS=" test coverage_output" else @@ -887,6 +1083,8 @@ else COVERAGE_PREREQS="" fi + +# Set some defaults. if [ -z "${DESTDIR+set}" ]; then destdir="" else @@ -909,12 +1107,16 @@ if [ -z "${LIBDIR+set}" ]; then LIBDIR="$PREFIX/lib" fi +# Set a default for the DATAROOTDIR. This is done if either manpages will be +# installed, or locales are enabled because that's probably where NLS_PATH +# points. if [ "$install_manpages" -ne 0 ] || [ "$nls" -ne 0 ]; then if [ -z "${DATAROOTDIR+set}" ]; then DATAROOTDIR="$PREFIX/share" fi fi +# Set defaults for manpage environment variables. if [ "$install_manpages" -ne 0 ]; then if [ -z "${DATADIR+set}" ]; then @@ -938,6 +1140,9 @@ else uninstall_man_prereqs="" fi +# Here is where we test NLS (the locale system). This is done by trying to +# compile src/vm.c, which has the relevant code. If it fails, then it is +# disabled. if [ "$nls" -ne 0 ]; then set +e @@ -945,7 +1150,7 @@ if [ "$nls" -ne 0 ]; then printf 'Testing NLS...\n' flags="-DBC_ENABLE_NLS=1 -DBC_ENABLED=$bc -DDC_ENABLED=$dc" - flags="$flags -DBC_ENABLE_HISTORY=$hist" + flags="$flags -DBC_ENABLE_HISTORY=$hist -DBC_ENABLE_LIBRARY=0 -DBC_ENABLE_AFL=0" flags="$flags -DBC_ENABLE_EXTRA_MATH=$extra_math -I./include/" flags="$flags -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700" @@ -987,7 +1192,10 @@ if [ "$nls" -ne 0 ]; then printf 'gencat works.\n\n' - if [ "$HOSTCC" != "$CC" ]; then + # It turns out that POSIX locales are really terrible, and running + # gencat on one machine is not guaranteed to make those cat files + # portable to another machine, so we had better warn the user here. + if [ "$HOSTCC" != "$CC" ] || [ "$OLDHOSTCFLAGS" != "$OLDCFLAGS" ]; then printf 'Cross-compile detected.\n\n' printf 'WARNING: Catalog files generated with gencat may not be portable\n' printf ' across different architectures.\n\n' @@ -1018,6 +1226,7 @@ else install_locales="\$(LOCALE_INSTALL) \$(NLSPATH) \$(MAIN_EXEC) \$(DESTDIR)" fi +# Like the above tested locale support, this tests history. if [ "$hist" -eq 1 ]; then set +e @@ -1025,7 +1234,7 @@ 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 -DBC_ENABLE_LIBRARY=0" + flags="$flags -DBC_ENABLE_NLS=$nls -DBC_ENABLE_LIBRARY=0 -DBC_ENABLE_AFL=0" flags="$flags -DBC_ENABLE_EXTRA_MATH=$extra_math -I./include/" flags="$flags -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700" @@ -1053,6 +1262,39 @@ if [ "$hist" -eq 1 ]; then fi +# We have to disable the history tests if it is disabled or valgrind is on. +if [ "$hist" -eq 0 ] || [ "$vg" -ne 0 ]; then + test_bc_history_prereqs=" test_bc_history_skip" + test_dc_history_prereqs=" test_dc_history_skip" + history_tests="@printf 'Skipping history tests...\\\\n'" +else + history_tests="@printf '\$(TEST_STARS)\\\\n\\\\nRunning history tests...\\\\n\\\\n' \&\& tests/history.sh bc -a \&\& tests/history.sh dc -a \&\& printf '\\\\nAll history tests passed.\\\\n\\\\n\$(TEST_STARS)\\\\n'" +fi + +# Test OpenBSD. This is not in an if statement because regardless of whatever +# the user says, we need to know if we are on OpenBSD to activate _BSD_SOURCE. +# No, I cannot `#define _BSD_SOURCE` in a header because OpenBSD's patched GCC +# and Clang complain that that is only allowed for system headers. Sigh....So we +# have to check at configure time and set it on the compiler command-line. And +# we have to set it because we also set _POSIX_C_SOURCE, which OpenBSD headers +# detect, and when they detect it, they turn off _BSD_SOURCE unless it is +# specifically requested. +set +e +printf 'Testing for OpenBSD...\n' + +flags="-DBC_TEST_OPENBSD -DBC_ENABLE_AFL=0" +"$CC" $CPPFLAGS $CFLAGS $flags -I./include -E "include/status.h" > /dev/null 2>&1 + +err="$?" + +if [ "$err" -ne 0 ]; then + printf 'On OpenBSD. Using _BSD_SOURCE.\n\n' + bsd="-D_BSD_SOURCE" +else + printf 'Not on OpenBSD.\n\n' + bsd="" +fi + if [ "$library" -eq 1 ]; then bc_lib="" fi @@ -1063,9 +1305,11 @@ else BC_LIB2_O="" fi +# These lines set the appropriate targets based on whether `gen/strgen.c` or +# `gen/strgen.sh` is used. GEN="strgen" GEN_EXEC_TARGET="\$(HOSTCC) \$(HOSTCFLAGS) -o \$(GEN_EXEC) \$(GEN_C)" -CLEAN_PREREQS=" clean_gen" +CLEAN_PREREQS=" clean_gen clean_coverage" if [ -z "${GEN_HOST+set}" ]; then GEN_HOST=1 @@ -1073,7 +1317,7 @@ else if [ "$GEN_HOST" -eq 0 ]; then GEN="strgen.sh" GEN_EXEC_TARGET="@printf 'Do not need to build gen/strgen.c\\\\n'" - CLEAN_PREREQS="" + CLEAN_PREREQS=" clean_coverage" fi fi @@ -1081,6 +1325,7 @@ manpage_args="" unneeded="" headers="\$(HEADERS)" +# This series of if statements figure out what source files are *not* needed. if [ "$extra_math" -eq 0 ]; then manpage_args="E" unneeded="$unneeded rand.c" @@ -1088,6 +1333,9 @@ else headers="$headers \$(EXTRA_MATH_HEADERS)" fi +# All of these next if statements set the build type and mark certain source +# files as unneeded so that they won't have targets generated for them. + if [ "$hist" -eq 0 ]; then manpage_args="${manpage_args}H" unneeded="$unneeded history.c" @@ -1099,10 +1347,6 @@ if [ "$nls" -eq 0 ]; then manpage_args="${manpage_args}N" fi -if [ "$prompt" -eq 0 ]; then - manpage_args="${manpage_args}P" -fi - if [ "$bc" -eq 0 ]; then unneeded="$unneeded bc.c bc_lex.c bc_parse.c" else @@ -1125,6 +1369,12 @@ else unneeded="$unneeded library.c" fi +# library.c is not needed under normal circumstances. +if [ "$unneeded" = "" ]; then + unneeded="library.c" +fi + +# This sets the appropriate manpage for a full build. if [ "$manpage_args" = "" ]; then manpage_args="A" fi @@ -1133,6 +1383,15 @@ if [ "$vg" -ne 0 ]; then memcheck=1 fi +if [ "$bc_default_prompt" = "" ]; then + bc_default_prompt="$bc_default_tty_mode" +fi + +if [ "$dc_default_prompt" = "" ]; then + dc_default_prompt="$dc_default_tty_mode" +fi + +# Generate the test targets and prerequisites. bc_tests=$(gen_test_targets bc) bc_script_tests=$(gen_script_test_targets bc) dc_tests=$(gen_test_targets dc) @@ -1154,7 +1413,6 @@ 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" -printf 'BC_ENABLE_PROMPT=%s\n' "$prompt" printf 'BC_ENABLE_AFL=%s\n' "$fuzz" printf '\n' printf 'BC_NUM_KARATSUBA_LEN=%s\n' "$karatsuba_len" @@ -1181,6 +1439,19 @@ printf 'DESTDIR=%s\n' "$DESTDIR" printf 'LONG_BIT=%s\n' "$LONG_BIT" printf 'GEN_HOST=%s\n' "$GEN_HOST" printf 'GEN_EMU=%s\n' "$GEN_EMU" +printf '\n' +printf 'Setting Defaults\n' +printf '================\n' +printf 'bc.banner=%s\n' "$bc_default_banner" +printf 'bc.sigint_reset=%s\n' "$bc_default_sigint_reset" +printf 'dc.sigint_reset=%s\n' "$dc_default_sigint_reset" +printf 'bc.tty_mode=%s\n' "$bc_default_tty_mode" +printf 'dc.tty_mode=%s\n' "$dc_default_tty_mode" +printf 'bc.prompt=%s\n' "$bc_default_prompt" +printf 'dc.prompt=%s\n' "$dc_default_prompt" + +# This is where the real work begins. This is the point at which the Makefile.in +# template is edited and output to the Makefile. contents=$(cat "$scriptdir/Makefile.in") @@ -1189,14 +1460,14 @@ replacement='*** WARNING: Autogenerated from Makefile.in. DO NOT MODIFY ***' contents=$(replace "$contents" "$needle" "$replacement") -if [ "$unneeded" = "" ]; then - unneeded="library.c" -fi - +# The contents are edited to have the list of files to build. contents=$(gen_file_list "$contents" $unneeded) SRC_TARGETS="" +# This line and loop generates the individual targets for source files. I used +# to just use an implicit target, but that was found to be inadequate when I +# added the library. src_files=$(find_src_files $unneeded) for f in $src_files; do @@ -1205,6 +1476,7 @@ for f in $src_files; do "$SRC_TARGETS" "$o" "$headers" "$f" "$o" "$f") done +# Replace all the placeholders. contents=$(replace "$contents" "HEADERS" "$headers") contents=$(replace "$contents" "BC_ENABLED" "$bc") @@ -1227,7 +1499,6 @@ contents=$(replace "$contents" "LIBRARY" "$library") contents=$(replace "$contents" "HISTORY" "$hist") contents=$(replace "$contents" "EXTRA_MATH" "$extra_math") contents=$(replace "$contents" "NLS" "$nls") -contents=$(replace "$contents" "PROMPT" "$prompt") contents=$(replace "$contents" "FUZZ" "$fuzz") contents=$(replace "$contents" "MEMCHECK" "$memcheck") @@ -1281,7 +1552,10 @@ contents=$(replace "$contents" "EXEC" "$executable") contents=$(replace "$contents" "TESTS" "$tests") contents=$(replace "$contents" "BC_TEST" "$bc_test") +contents=$(replace "$contents" "BC_HISTORY_TEST_PREREQS" "$test_bc_history_prereqs") contents=$(replace "$contents" "DC_TEST" "$dc_test") +contents=$(replace "$contents" "DC_HISTORY_TEST_PREREQS" "$test_dc_history_prereqs") +contents=$(replace "$contents" "HISTORY_TESTS" "$history_tests") contents=$(replace "$contents" "VG_BC_TEST" "$vg_bc_test") contents=$(replace "$contents" "VG_DC_TEST" "$vg_dc_test") @@ -1299,20 +1573,33 @@ contents=$(replace "$contents" "GEN_EXEC_TARGET" "$GEN_EXEC_TARGET") contents=$(replace "$contents" "CLEAN_PREREQS" "$CLEAN_PREREQS") contents=$(replace "$contents" "GEN_EMU" "$GEN_EMU") +contents=$(replace "$contents" "BSD" "$bsd") + +contents=$(replace "$contents" "BC_DEFAULT_BANNER" "$bc_default_banner") +contents=$(replace "$contents" "BC_DEFAULT_SIGINT_RESET" "$bc_default_sigint_reset") +contents=$(replace "$contents" "DC_DEFAULT_SIGINT_RESET" "$dc_default_sigint_reset") +contents=$(replace "$contents" "BC_DEFAULT_TTY_MODE" "$bc_default_tty_mode") +contents=$(replace "$contents" "DC_DEFAULT_TTY_MODE" "$dc_default_tty_mode") +contents=$(replace "$contents" "BC_DEFAULT_PROMPT" "$bc_default_prompt") +contents=$(replace "$contents" "DC_DEFAULT_PROMPT" "$dc_default_prompt") + +# Do the first print to the Makefile. printf '%s\n%s\n\n' "$contents" "$SRC_TARGETS" > "$scriptdir/Makefile" +# Generate the individual test targets. if [ "$bc" -ne 0 ]; then - gen_tests bc BC "$extra_math" "$time_tests" $bc_test_exec + gen_tests bc "$extra_math" "$time_tests" $bc_test_exec gen_script_tests bc "$extra_math" "$generate_tests" "$time_tests" $bc_test_exec fi if [ "$dc" -ne 0 ]; then - gen_tests dc DC "$extra_math" "$time_tests" $dc_test_exec + gen_tests dc "$extra_math" "$time_tests" $dc_test_exec gen_script_tests dc "$extra_math" "$generate_tests" "$time_tests" $dc_test_exec fi cd "$scriptdir" +# Copy the correct manuals to the expected places. cp -f manuals/bc/$manpage_args.1.md manuals/bc.1.md cp -f manuals/bc/$manpage_args.1 manuals/bc.1 cp -f manuals/dc/$manpage_args.1.md manuals/dc.1.md diff --git a/contrib/bc/gen/bc_help.txt b/contrib/bc/gen/bc_help.txt index c9b0482d8c42..50c38ab61314 100644 --- a/contrib/bc/gen/bc_help.txt +++ b/contrib/bc/gen/bc_help.txt @@ -108,6 +108,17 @@ Options: Disable the read prompt in interactive mode. + -r keyword --redefine=keyword + + Redefines "keyword" and allows it to be used as a function, variable, and + array name. This is useful when this bc gives parse errors on scripts + meant for other bc implementations. + + Only keywords that are not in the POSIX bc spec may be redefined. + + It is a fatal error to attempt to redefine a keyword that cannot be + redefined or does not exist. + -q --quiet Don't print version and copyright. @@ -123,3 +134,44 @@ Options: -v --version Print version information and copyright and exit. + +Environment variables: + + POSIXLY_CORRECT + + Error if any non-POSIX extensions are used. + + BC_ENV_ARGS + + Command-line arguments to use on every run. + + BC_LINE_LENGTH + + If an integer, the number of characters to print on a line before + wrapping. + + BC_BANNER + + If an integer and non-zero, display the copyright banner in interactive + mode. + + Overrides the default, which is %s print the banner. + + BC_SIGINT_RESET + + If an integer and non-zero, reset on SIGINT, rather than exit, when in + interactive mode. + + Overrides the default, which is %s. + + BC_TTY_MODE + + If an integer and non-zero, enable TTY mode when it is available. + + Overrides the default, which is TTY mode %s. + + BC_PROMPT + + If an integer and non-zero, enable prompt when TTY mode is possible. + + Overrides the default, which is prompt %s. diff --git a/contrib/bc/gen/dc_help.txt b/contrib/bc/gen/dc_help.txt index c573b96791e7..c0bf34daeb46 100644 --- a/contrib/bc/gen/dc_help.txt +++ b/contrib/bc/gen/dc_help.txt @@ -104,3 +104,33 @@ Options: -x --extended-register Enable extended register mode. + +Environment variables: + + DC_ENV_ARGS + + Command-line arguments to use on every run. + + DC_LINE_LENGTH + + If an integer, the number of characters to print on a line before + wrapping. + + DC_SIGINT_RESET + + If an integer and non-zero, reset on SIGINT, rather than exit, when in + interactive mode. + + Overrides the default, which is %s. + + DC_TTY_MODE + + If an integer and non-zero, enable TTY mode when it is available. + + Overrides the default, which is TTY mode %s. + + DC_PROMPT + + If an integer and non-zero, enable prompt when TTY mode is possible. + + Overrides the default, which is prompt %s. diff --git a/contrib/bc/gen/lib.bc b/contrib/bc/gen/lib.bc index 2cd9256efa53..c0cd7f7dc8d4 100644 --- a/contrib/bc/gen/lib.bc +++ b/contrib/bc/gen/lib.bc @@ -33,7 +33,7 @@ * */ -scale=20 +scale=2*A define e(x){ auto b,s,n,r,d,i,p,f,v b=ibase diff --git a/contrib/bc/gen/lib2.bc b/contrib/bc/gen/lib2.bc index 399c7ad3d313..93df1889eb63 100644 --- a/contrib/bc/gen/lib2.bc +++ b/contrib/bc/gen/lib2.bc @@ -119,7 +119,7 @@ define root(x,n){ m=(x<0) x=abs(x) p=n-1 - q=10^ceil((length(x$)/n)$,0) + q=A^ceil((length(x$)/n)$,0) while(r!=q){ r=q q=(p*r+x/r^p)/n @@ -129,6 +129,37 @@ define root(x,n){ return r@s } define cbrt(x){return root(x,3)} +define gcd(a,b){ + auto g,s + if(!b)return a + s=scale + scale=0 + a=abs(a)$ + b=abs(b)$ + if(a>p + return irand(A^p)>>p } define ifrand(i,p){return irand(abs(i)$)+frand(p)} define srand(x){ @@ -210,28 +241,39 @@ define void output(x,b){ define void hex(x){output(x,G)} define void binary(x){output(x,2)} define ubytes(x){ - auto p,b,i - b=ibase - ibase=A + auto p,i x=abs(x)$ i=2^8 for(p=1;i-1p||(!z&&x==p))n*=2 - ibase=b return n } +define s2un(x,n){ + auto t,u,s + x=x$ + if(x<0){ + x=abs(x) + s=scale + scale=0 + t=n*8 + u=2^(t-1) + if(x==u)return x + else if(x>u)x%=u + scale=s + return 2^(t)-x + } + return x +} +define s2u(x){return s2un(x,sbytes(x))} define void output_byte(x,i){ auto j,p,y,b j=ibase @@ -240,7 +282,7 @@ define void output_byte(x,i){ scale=0 x=abs(x)$ b=x/(2^(i*8)) - b%=2^8 + b%=256 y=log(256,obase) if(b>1)p=log(b,obase)+1 else p=b @@ -250,15 +292,12 @@ define void output_byte(x,i){ ibase=j } define void output_uint(x,n){ - auto i,b - b=ibase - ibase=A + auto i for(i=n-1;i>=0;--i){ output_byte(x,i) if(i)print" " else print"\n" } - ibase=b } define void hex_uint(x,n){ auto o @@ -301,7 +340,7 @@ define void intn(x,n){ print "Error: ",x," cannot fit into ",n," signed byte(s).\n" return } - if(x<0)x=2^(n*8)-(-x) + x=s2un(x,n) binary_uint(x,n) hex_uint(x,n) } @@ -315,3 +354,175 @@ define void uint64(x){uintn(x,8)} define void int64(x){intn(x,8)} define void uint(x){uintn(x,ubytes(x))} define void int(x){intn(x,sbytes(x))} +define bunrev(t){ + auto a,s,m[] + s=scale + scale=0 + t=abs(t)$ + while(t!=1){ + t=divmod(t,2,m[]) + a*=2 + a+=m[0] + } + scale=s + return a +} +define band(a,b){ + auto s,t,m[],n[] + a=abs(a)$ + b=abs(b)$ + if(b>a){ + t=b + b=a + a=t + } + s=scale + scale=0 + t=1 + while(b){ + a=divmod(a,2,m[]) + b=divmod(b,2,n[]) + t*=2 + t+=(m[0]&&n[0]) + } + scale=s + return bunrev(t) +} +define bor(a,b){ + auto s,t,m[],n[] + a=abs(a)$ + b=abs(b)$ + if(b>a){ + t=b + b=a + a=t + } + s=scale + scale=0 + t=1 + while(b){ + a=divmod(a,2,m[]) + b=divmod(b,2,n[]) + t*=2 + t+=(m[0]||n[0]) + } + while(a){ + a=divmod(a,2,m[]) + t*=2 + t+=m[0] + } + scale=s + return bunrev(t) +} +define bxor(a,b){ + auto s,t,m[],n[] + a=abs(a)$ + b=abs(b)$ + if(b>a){ + t=b + b=a + a=t + } + s=scale + scale=0 + t=1 + while(b){ + a=divmod(a,2,m[]) + b=divmod(b,2,n[]) + t*=2 + t+=(m[0]+n[0]==1) + } + while(a){ + a=divmod(a,2,m[]) + t*=2 + t+=m[0] + } + scale=s + return bunrev(t) +} +define bshl(a,b){return abs(a)$*2^abs(b)$} +define bshr(a,b){return (abs(a)$/2^abs(b)$)$} +define bnotn(x,n){ + auto s,t,m[] + s=scale + scale=0 + t=2^(abs(n)$*8) + x=abs(x)$%t+t + t=1 + while(x!=1){ + x=divmod(x,2,m[]) + t*=2 + t+=!m[0] + } + scale=s + return bunrev(t) +} +define bnot8(x){return bnotn(x,1)} +define bnot16(x){return bnotn(x,2)} +define bnot32(x){return bnotn(x,4)} +define bnot64(x){return bnotn(x,8)} +define bnot(x){return bnotn(x,ubytes(x))} +define brevn(x,n){ + auto s,t,m[] + s=scale + scale=0 + t=2^(abs(n)$*8) + x=abs(x)$%t+t + scale=s + return bunrev(x) +} +define brev8(x){return brevn(x,1)} +define brev16(x){return brevn(x,2)} +define brev32(x){return brevn(x,4)} +define brev64(x){return brevn(x,8)} +define brev(x){return brevn(x,ubytes(x))} +define broln(x,p,n){ + auto s,t,m[] + s=scale + scale=0 + n=abs(n)$*8 + p=abs(p)$%n + t=2^n + x=abs(x)$%t + if(!p)return x + x=divmod(x,2^(n-p),m[]) + x+=m[0]*2^p%t + scale=s + return x +} +define brol8(x,p){return broln(x,p,1)} +define brol16(x,p){return broln(x,p,2)} +define brol32(x,p){return broln(x,p,4)} +define brol64(x,p){return broln(x,p,8)} +define brol(x,p){return broln(x,p,ubytes(x))} +define brorn(x,p,n){ + auto s,t,m[] + s=scale + scale=0 + n=abs(n)$*8 + p=abs(p)$%n + t=2^n + x=abs(x)$%t + if(!p)return x + x=divmod(x,2^p,m[]) + x+=m[0]*2^(n-p)%t + scale=s + return x +} +define bror8(x,p){return brorn(x,p,1)} +define bror16(x,p){return brorn(x,p,2)} +define bror32(x,p){return brorn(x,p,4)} +define bror64(x,p){return brorn(x,p,8)} +define brol(x,p){return brorn(x,p,ubytes(x))} +define bmodn(x,n){ + auto s + s=scale + scale=0 + x=abs(x)$%2^(abs(n)$*8) + scale=s + return x +} +define bmod8(x){return bmodn(x,1)} +define bmod16(x){return bmodn(x,2)} +define bmod32(x){return bmodn(x,4)} +define bmod64(x){return bmodn(x,8)} diff --git a/contrib/bc/gen/strgen.c b/contrib/bc/gen/strgen.c index fbc694a37622..63faf1ec3472 100644 --- a/contrib/bc/gen/strgen.c +++ b/contrib/bc/gen/strgen.c @@ -40,15 +40,19 @@ #include +// For some reason, Windows needs this header. #ifndef _WIN32 #include #endif // _WIN32 +// This is exactly what it looks like. It just slaps a simple license header on +// the generated C source file. static const char* const bc_gen_header = "// Copyright (c) 2018-2021 Gavin D. Howard and contributors.\n" "// Licensed under the 2-clause BSD license.\n" "// *** AUTOMATICALLY GENERATED FROM %s. DO NOT MODIFY. ***\n\n"; +// These are just format strings used to generate the C source. 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"; @@ -56,43 +60,86 @@ 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"; +// Error codes. We can't use 0 because these are used as exit statuses, and 0 +// as an exit status is not an error. #define IO_ERR (1) #define INVALID_INPUT_FILE (2) #define INVALID_PARAMS (3) -#define MAX_WIDTH (74) +// This is the max width to print characters to the screen. This is to ensure +// that lines don't go much over 80 characters. +#define MAX_WIDTH (72) +/** + * Open a file. This function is to smooth over differences between POSIX and + * Windows. + * @param f A pointer to the FILE pointer that will be initialized. + * @param filename The name of the file. + * @param mode The mode to open the file in. + */ static void open_file(FILE** f, const char* filename, const char* mode) { #ifndef _WIN32 + *f = fopen(filename, mode); + #else // _WIN32 + + // We want the file pointer to be NULL on failure, but fopen_s() is not + // guaranteed to set it. *f = NULL; fopen_s(f, filename, mode); + #endif // _WIN32 } +/** + * Outputs a label, which is a string literal that the code can use as a name + * for the file that is being turned into a string. This is important for the + * math libraries because the parse and lex code expects a filename. The label + * becomes the filename for the purposes of lexing and parsing. + * + * The label is generated from bc_gen_label (above). It has the form: + * + * const char * =