From e84a97439b4bcc11e04837b2f130dfff4c755c5f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20E=C3=9Fer?= Date: Tue, 10 Aug 2021 10:42:54 +0200 Subject: [PATCH] usr.bin/gh-bc, contrib/bc: update to version 5.0.0 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 (cherry picked from commit 44d4804d1945435745518cd09eb8ae6ab22ecef4) vendor/bc: update to upstream version 5.0.2 (cherry picked from commit a60ef1802a36f2f2a5611564191440ea1c1e2f17) (cherry picked from commit 662087dfd0668dee82ed20d00ced662aa3595059) contrib/bc: remove files ommitted from the release A number of files have been removed from the release distribution of this bc implementation. They were mostly relevant for pre release testing and benchmarking to identify regressions. The Markdown sources of the man pages are only relevant for combinations of build options not used in FreeBSD and need non-default conversion tools (available as ports in FreeBSD). All the omitted files can be found in the upstream git repository, and they are fetched when building this software as a port. But they have never been used in the FreeBSD base system. (cherry picked from commit ea31d1a5c490193348e0b71fdda6d08a2c80a2eb) Remove files that were checked in with wrong .gitattributes These files will be added back in updated form, but are only relevant for the Windows platform, anyway. (cherry picked from commit d6c323eda215d05091f56d02a8274eb50c244a6f) contrib/bc: merge version 5.1.0 from vendor branch This version adds options and functions that allow to print numbers in the open interval (-1 .. 1) with or without a leading 0 digit. Additionally, an option has been added to prevent line wrap and allows to print arbitrarily long results on a single line. Merge commit '5d58a51571721190681c50d4bd3a1f45e6282d72' (cherry picked from commit d43fa8ef534ac87a16843d45264f56cf11e0fcbc) contrib/bc: update to version 5.1.1 Merge commit '6f49f5cdde1c62c4e5a743e895f3afe592b5c0e5' (cherry picked from commit a30efc5ca7272e446abb71f0d72c76539f267bb6) contrib/bc: temporarily disconnect the tests for 5.0.2 The tests that come with version 5.0.2 have been extended to cover the line editing functions. It has been found that these tests generate false negative results in FreeBSD, most likely due to an issue in the pexpect functionality used. These history tests are skipped on systems that do not have python and py-pexpect installed (and thus are unlikely to cause CI test failures), but in order to not cause irritating failures on systems were these packages are in fact installed, I temporarily disconnect them. I had planned to skip this version due to the issue with the history tests, but some committer has asked me to go ahead since the currently used version 5.0.0 contains a macro name that collides with a project he is working on. No MFC of this version is planned. A version 5.0.3 is expected to be released soon, and that version will allow to reconnect the tests and will be MFCed. (cherry picked from commit f774652b0e837be415abd20935eae3466ea34a20) Add back Windows only VCXProj files (cherry picked from commit ded0d3d486eba766f613070de0ed12029a9a3816) contrib/bc: re-enable tests after the import of version 5.1.0 The tests have been fixed to not write any data outside of the temporary work directory provided by the test framework. MFC after: 3 days (cherry picked from commit b8d895faf47afb8f3b31055e2ec2db8d0df5db23) Revert erroneous commit ded0d3d486eba These files came from a prior commit to contrib/bc and seem to have been placed in the top of the source tree by a failed git rebase. Reported by: markj (cherry picked from commit f902ca97bdbceccf62b4b02b0321af91ea398925) --- contrib/bc/.gitattributes | 2 +- contrib/bc/.gitignore | 8 +- contrib/bc/LICENSE.md | 14 +- contrib/bc/Makefile.in | 233 +- contrib/bc/NEWS.md | 117 +- contrib/bc/README.md | 50 +- contrib/bc/RELEASE.md | 54 - contrib/bc/bc.vcxproj | 278 - contrib/bc/bc.vcxproj.filters | 182 - contrib/bc/bcl.sln | 31 - contrib/bc/bcl.vcxproj | 161 - contrib/bc/bcl.vcxproj.filters | 96 - contrib/bc/configure | 1322 +--- contrib/bc/configure.sh | 467 +- contrib/bc/gen/bc_help.txt | 60 + contrib/bc/gen/dc_help.txt | 38 + contrib/bc/gen/lib.bc | 2 +- contrib/bc/gen/lib2.bc | 283 +- contrib/bc/gen/strgen.c | 112 +- contrib/bc/gen/strgen.sh | 3 + contrib/bc/include/args.h | 11 +- contrib/bc/include/bc.h | 313 +- contrib/bc/include/bcl.h | 142 +- contrib/bc/include/dc.h | 42 +- contrib/bc/include/file.h | 88 + contrib/bc/include/history.h | 108 +- contrib/bc/include/lang.h | 445 +- contrib/bc/include/lex.h | 375 +- contrib/bc/include/library.h | 90 +- contrib/bc/include/num.h | 646 +- contrib/bc/include/opt.h | 61 + contrib/bc/include/parse.h | 182 +- contrib/bc/include/program.h | 828 ++- contrib/bc/include/rand.h | 326 +- contrib/bc/include/read.h | 42 +- contrib/bc/include/status.h | 646 +- contrib/bc/include/vector.h | 378 +- contrib/bc/include/version.h | 5 +- contrib/bc/include/vm.h | 693 ++- 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 | 2660 ++++---- contrib/bc/manuals/bc/A.1.md | 725 ++- contrib/bc/manuals/bc/E.1 | 1332 ++-- contrib/bc/manuals/bc/E.1.md | 354 +- contrib/bc/manuals/bc/EH.1 | 1303 ++-- contrib/bc/manuals/bc/EH.1.md | 326 +- contrib/bc/manuals/bc/EHN.1 | 1303 ++-- contrib/bc/manuals/bc/EHN.1.md | 326 +- 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 | 1332 ++-- contrib/bc/manuals/bc/EN.1.md | 354 +- 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 | 2633 ++++---- contrib/bc/manuals/bc/H.1.md | 702 ++- contrib/bc/manuals/bc/HN.1 | 2633 ++++---- contrib/bc/manuals/bc/HN.1.md | 702 ++- 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 | 2660 ++++---- contrib/bc/manuals/bc/N.1.md | 725 ++- 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 | 1780 +++--- contrib/bc/manuals/bcl.3.md | 275 +- contrib/bc/manuals/benchmarks.md | 673 -- contrib/bc/manuals/build.md | 213 +- contrib/bc/manuals/dc.1.md.in | 1289 ---- contrib/bc/manuals/dc/A.1 | 1651 +++-- contrib/bc/manuals/dc/A.1.md | 277 +- contrib/bc/manuals/dc/E.1 | 1463 +++-- contrib/bc/manuals/dc/E.1.md | 277 +- contrib/bc/manuals/dc/EH.1 | 1432 +++-- contrib/bc/manuals/dc/EH.1.md | 253 +- contrib/bc/manuals/dc/EHN.1 | 1432 +++-- contrib/bc/manuals/dc/EHN.1.md | 251 +- 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 | 1461 +++-- contrib/bc/manuals/dc/EN.1.md | 275 +- 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 | 1620 +++-- contrib/bc/manuals/dc/H.1.md | 253 +- contrib/bc/manuals/dc/HN.1 | 1620 +++-- contrib/bc/manuals/dc/HN.1.md | 251 +- 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 | 1649 +++-- contrib/bc/manuals/dc/N.1.md | 275 +- 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/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/release.sh | 601 -- contrib/bc/{ => scripts}/exec-install.sh | 6 +- contrib/bc/{ => scripts}/functions.sh | 74 +- 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}/safe-install.sh | 0 contrib/bc/src/args.c | 132 +- contrib/bc/src/bc.c | 11 +- contrib/bc/src/bc_lex.c | 84 +- contrib/bc/src/bc_parse.c | 917 ++- contrib/bc/src/data.c | 455 +- contrib/bc/src/dc.c | 11 +- contrib/bc/src/dc_lex.c | 104 +- contrib/bc/src/dc_parse.c | 93 +- contrib/bc/src/file.c | 63 +- contrib/bc/src/history.c | 677 ++- contrib/bc/src/lang.c | 131 +- contrib/bc/src/lex.c | 123 +- contrib/bc/src/library.c | 180 +- contrib/bc/src/main.c | 13 +- contrib/bc/src/num.c | 1593 ++++- contrib/bc/src/opt.c | 129 +- contrib/bc/src/parse.c | 83 +- contrib/bc/src/program.c | 1967 ++++-- contrib/bc/src/rand.c | 185 +- contrib/bc/src/read.c | 99 +- contrib/bc/src/vector.c | 302 +- contrib/bc/src/vm.c | 700 ++- contrib/bc/tests/afl.py | 188 - contrib/bc/tests/all.sh | 124 +- contrib/bc/tests/bc/all.txt | 10 +- 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/leadingzero.txt | 12 + contrib/bc/tests/bc/leadingzero_results.txt | 12 + 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 | 11 +- 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 | 4 + contrib/bc/tests/bc/scripts/ifs.bc | 49 + contrib/bc/tests/bc/scripts/ifs.txt | 18 + contrib/bc/tests/bc/scripts/ifs2.bc | 33 + contrib/bc/tests/bc/scripts/ifs2.txt | 34 + 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/stdin2.txt | 3 + contrib/bc/tests/bc/stdin2_results.txt | 21 + contrib/bc/tests/bc/strings.txt | 61 + contrib/bc/tests/bc/strings_results.txt | 45 + contrib/bc/tests/bc/timeconst.sh | 24 +- contrib/bc/tests/bc/vars_results.txt | 3 +- contrib/bc/tests/bcl.c | 154 +- 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 | 7 + .../dc_inputs/17.txt => dc/errors/32.txt} | 2 +- contrib/bc/tests/dc/errors/33.txt | Bin 0 -> 323 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/{diff.sh => error.sh} | 74 +- contrib/bc/tests/errors.sh | 55 +- contrib/bc/tests/extra_required.txt | 2 + 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 - 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 - 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 | 1153 ++++ .../bc/tests/{fuzzing/bc.dict => history.sh} | 122 +- contrib/bc/tests/other.sh | 142 +- contrib/bc/tests/radamsa.sh | 120 - contrib/bc/tests/radamsa.txt | 17 - contrib/bc/tests/randmath.py | 306 - contrib/bc/tests/read.sh | 25 +- contrib/bc/tests/script.sed | 9 + contrib/bc/tests/script.sh | 22 +- contrib/bc/tests/scripts.sh | 53 +- contrib/bc/tests/stdin.sh | 23 +- contrib/bc/tests/test.sh | 17 +- contrib/bc/{ => vs}/bc.sln | 22 +- contrib/bc/vs/bc.vcxproj | 297 + contrib/bc/vs/bc.vcxproj.filters | 173 + contrib/bc/vs/bcl.sln | 37 + contrib/bc/vs/bcl.vcxproj | 259 + contrib/bc/vs/bcl.vcxproj.filters | 90 + contrib/bc/vs/tests/tests_bc.bat | 104 + contrib/bc/vs/tests/tests_dc.bat | 61 + usr.bin/gh-bc/Makefile | 20 +- usr.bin/gh-bc/tests/Makefile | 4 +- 417 files changed, 50523 insertions(+), 75025 deletions(-) delete mode 100644 contrib/bc/RELEASE.md delete mode 100644 contrib/bc/bc.vcxproj delete mode 100644 contrib/bc/bc.vcxproj.filters delete mode 100644 contrib/bc/bcl.sln delete mode 100644 contrib/bc/bcl.vcxproj delete mode 100644 contrib/bc/bcl.vcxproj.filters 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 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 delete mode 100755 contrib/bc/release.sh rename contrib/bc/{ => scripts}/exec-install.sh (88%) rename contrib/bc/{ => scripts}/functions.sh (68%) 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%) rename contrib/bc/{ => scripts}/safe-install.sh (100%) delete mode 100755 contrib/bc/tests/afl.py 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/leadingzero.txt create mode 100644 contrib/bc/tests/bc/leadingzero_results.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 create mode 100644 contrib/bc/tests/bc/scripts/ifs.bc create mode 100644 contrib/bc/tests/bc/scripts/ifs.txt create mode 100644 contrib/bc/tests/bc/scripts/ifs2.bc create mode 100644 contrib/bc/tests/bc/scripts/ifs2.txt 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 rename contrib/bc/tests/{diff.sh => error.sh} (55%) 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 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 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 rename contrib/bc/tests/{fuzzing/bc.dict => history.sh} (51%) mode change 100644 => 100755 delete mode 100755 contrib/bc/tests/radamsa.sh delete mode 100644 contrib/bc/tests/radamsa.txt delete mode 100755 contrib/bc/tests/randmath.py create mode 100644 contrib/bc/tests/script.sed rename contrib/bc/{ => vs}/bc.sln (53%) create mode 100644 contrib/bc/vs/bc.vcxproj create mode 100644 contrib/bc/vs/bc.vcxproj.filters create mode 100644 contrib/bc/vs/bcl.sln create mode 100644 contrib/bc/vs/bcl.vcxproj create mode 100644 contrib/bc/vs/bcl.vcxproj.filters create mode 100644 contrib/bc/vs/tests/tests_bc.bat create mode 100644 contrib/bc/vs/tests/tests_dc.bat diff --git a/contrib/bc/.gitattributes b/contrib/bc/.gitattributes index 22d6e60bce6..1e2c56dde21 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 b131d581376..31e43aa61ef 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 269e131cc81..8ab2e606988 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 2b50476a79f..3d6780d6ac9 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,33 @@ 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 + +run_all_tests_np: bc_all_tests_np timeconst_all_tests dc_all_tests_np + +bc_all_tests: %%BC_ALL_TESTS%% + +bc_all_tests_np: + %%BC_ALL_TESTS_NP%% + +timeconst_all_tests: %%TIMECONST_ALL_TESTS%% + +dc_all_tests: %%DC_ALL_TESTS%% +dc_all_tests_np: + %%DC_ALL_TESTS_NP%% + +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%% @@ -271,16 +319,18 @@ test_bc_stdin: test_bc_read: @sh tests/read.sh bc %%BC_TEST_EXEC%% -test_bc_errors: +test_bc_errors: test_bc_error_lines%%BC_ERROR_TESTS%% + +test_bc_error_lines: @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%% @@ -293,11 +343,13 @@ test_dc_stdin: test_dc_read: @sh tests/read.sh dc %%DC_TEST_EXEC%% -test_dc_errors: +test_dc_errors: test_dc_error_lines%%DC_ERROR_TESTS%% + +test_dc_error_lines: @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 +357,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 +490,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 +510,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 +542,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 +555,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 c78bddd27e7..5251096d9f2 100644 --- a/contrib/bc/NEWS.md +++ b/contrib/bc/NEWS.md @@ -1,5 +1,111 @@ # News +## 5.1.1 + +This is a production release that completes a bug fix from `5.1.0`. The bug +exists in all versions of `bc`. + +The bug was that `if` statements without `else` statements would not be handled +correctly at the end of files or right before a function definition. + +## 5.1.0 + +This is a production release with some fixes and new features. + +* Fixed a bug where an `if` statement without an `else` before defining a + function caused an error. +* Fixed a bug with the `bc` banner and `-q`. +* Fixed a bug on Windows where files were not read correctly. +* Added a command-line flag (`-z`) to make `bc` and `dc` print leading zeroes on + numbers `-1 < x < 1`. +* Added four functions to `lib2.bc` (`plz()`, `plznl()`, `pnlz()`, and + `pnlznl()`) to allow printing numbers with or without leading zeros, despite + the use of `-z` or not. +* Added builtin functions to query global state like line length, global stacks, + and leading zeroes. +* Added a command-line flag (`-L`) to disable wrapping when printing numbers. +* Improved builds on Windows. + +## 5.0.2 + +This is a production release with one fix for a flaky test. If you have not +experienced problems with the test suite, you do ***NOT*** need to upgrade. + +The test was one that tested whether `bc` fails gracefully when it can't +allocate memory. Unfortunately, there are cases when Linux and FreeBSD lie and +pretend to allocate the memory. + +The reason they do this is because a lot of programs don't use all of the memory +they allocate, so those OS's usually get away with it. + +However, this `bc` uses all of the memory it allocates (at least at page +granularity), so when it tries to use the memory, FreeBSD and Linux kill it. + +This only happens sometimes, however. Other times (on my machine), they do, in +fact, refuse the request. + +So I changed the test to not test for that because I think the graceful failure +code won't really change much. + +## 5.0.1 + +This is a production release with two fixes: + +* Fix for the build on Mac OSX. +* Fix for the build on Android. + +Users that do not use those platforms do ***NOT*** need to update. + +## 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 +416,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 +502,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 +1190,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 +1198,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 +1208,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 f0dcecf15bd..c46d66b7e3e 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 487ef95b051..00000000000 --- 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 deleted file mode 100644 index 2dbbd558618..00000000000 --- a/contrib/bc/bc.vcxproj +++ /dev/null @@ -1,278 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - {D5086CFE-052C-4742-B005-E05DB983BBA2} - Win32Proj - - - - Application - true - v142 - - - Application - false - v142 - - - Application - true - v142 - - - Application - false - v142 - - - - - - - - - - - - - - - - - - - - - Building strgen - CL /Fo:$(Configuration)\$(ProjectName)\ /Fe:$(Configuration)\$(ProjectName)\strgen.exe gen\strgen.c - gen\strgen.c - $(Configuration)\$(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)\$(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)\$(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)\$(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 - - - - ClCompile - - - - true - $(SolutionDir)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)\$(Configuration)\$(ProjectName)\ - - - false - $(SolutionDir)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)\$(Configuration)\$(ProjectName)\ - - - true - $(SolutionDir)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)\$(Configuration)\$(ProjectName)\ - - - false - $(SolutionDir)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)\$(Configuration)\$(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 - $(SolutionDir)\include;%(AdditionalIncludeDirectories) - MultiThreadedDebugDLL - Level3 - ProgramDatabase - Disabled - false - /W3 %(AdditionalOptions) - - - MachineX86 - true - 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" - - - Copying bc to dc... - - - - - 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 - $(SolutionDir)\include;%(AdditionalIncludeDirectories) - MultiThreadedDLL - Level3 - ProgramDatabase - MaxSpeed - false - /W3 %(AdditionalOptions) - - - MachineX86 - false - 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) - true - true - - - copy /b "$(SolutionDir)\$(Configuration)\$(ProjectName)\bc.exe" "$(SolutionDir)\$(Configuration)\$(ProjectName)\dc.exe" - - - Copying bc to dc... - - - - - 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 - $(SolutionDir)\include;%(AdditionalIncludeDirectories) - MultiThreadedDebugDLL - Level3 - ProgramDatabase - Disabled - false - /W3 %(AdditionalOptions) - - - MachineX64 - true - 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" - - - Copying bc to dc... - - - - - 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 - $(SolutionDir)\include;%(AdditionalIncludeDirectories) - MultiThreadedDLL - Level3 - ProgramDatabase - MaxSpeed - false - /W3 %(AdditionalOptions) - Default - - - MachineX64 - false - 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" - - - Copying bc to dc... - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/contrib/bc/bc.vcxproj.filters b/contrib/bc/bc.vcxproj.filters deleted file mode 100644 index 141ecb808d0..00000000000 --- a/contrib/bc/bc.vcxproj.filters +++ /dev/null @@ -1,182 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - - - - - - - - - - - Resource Files - - - Resource Files - - - - - Resource Files - - - Resource Files - - - \ No newline at end of file diff --git a/contrib/bc/bcl.sln b/contrib/bc/bcl.sln deleted file mode 100644 index 77009a439db..00000000000 --- a/contrib/bc/bcl.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31129.286 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bcl", "bcl.vcxproj", "{D2CC3DCF-7919-4DEF-839D-E9B897EC3E8E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D2CC3DCF-7919-4DEF-839D-E9B897EC3E8E}.Debug|x64.ActiveCfg = Debug|x64 - {D2CC3DCF-7919-4DEF-839D-E9B897EC3E8E}.Debug|x64.Build.0 = Debug|x64 - {D2CC3DCF-7919-4DEF-839D-E9B897EC3E8E}.Debug|x86.ActiveCfg = Debug|Win32 - {D2CC3DCF-7919-4DEF-839D-E9B897EC3E8E}.Debug|x86.Build.0 = Debug|Win32 - {D2CC3DCF-7919-4DEF-839D-E9B897EC3E8E}.Release|x64.ActiveCfg = Release|x64 - {D2CC3DCF-7919-4DEF-839D-E9B897EC3E8E}.Release|x64.Build.0 = Release|x64 - {D2CC3DCF-7919-4DEF-839D-E9B897EC3E8E}.Release|x86.ActiveCfg = Release|Win32 - {D2CC3DCF-7919-4DEF-839D-E9B897EC3E8E}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {591735E0-C314-4BFF-A595-E9999B49CB25} - EndGlobalSection -EndGlobal diff --git a/contrib/bc/bcl.vcxproj b/contrib/bc/bcl.vcxproj deleted file mode 100644 index 3b79c8b9ef6..00000000000 --- a/contrib/bc/bcl.vcxproj +++ /dev/null @@ -1,161 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - {D2CC3DCF-7919-4DEF-839D-E9B897EC3E8E} - Win32Proj - 10.0 - - - - StaticLibrary - true - v142 - - - StaticLibrary - false - v142 - - - StaticLibrary - true - v142 - - - StaticLibrary - false - v142 - - - - - - - - - - - - - - - - - - - - - true - $(SolutionDir)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)\$(Configuration)\$(ProjectName)\ - - - true - $(SolutionDir)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)\$(Configuration)\$(ProjectName)\ - - - true - $(SolutionDir)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)\$(Configuration)\$(ProjectName)\ - - - true - $(SolutionDir)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)\$(Configuration)\$(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 - MultiThreadedDebugDLL - Level3 - ProgramDatabase - Disabled - $(SolutionDir)\include - - - MachineX86 - true - Windows - - - - - 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 - MultiThreadedDLL - Level3 - ProgramDatabase - $(SolutionDir)\include - - - MachineX86 - true - Windows - true - true - - - - - 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 - $(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 - $(SolutionDir)\include - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/contrib/bc/bcl.vcxproj.filters b/contrib/bc/bcl.vcxproj.filters deleted file mode 100644 index f75e0331cc8..00000000000 --- a/contrib/bc/bcl.vcxproj.filters +++ /dev/null @@ -1,96 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/contrib/bc/configure b/contrib/bc/configure deleted file mode 100755 index af96564e770..00000000000 --- a/contrib/bc/configure +++ /dev/null @@ -1,1321 +0,0 @@ -#! /bin/sh -# -# 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. -# - -script="$0" -scriptdir=$(dirname "$script") -script=$(basename "$script") - -. "$scriptdir/functions.sh" - -cd "$scriptdir" - -usage() { - - if [ $# -gt 0 ]; then - - _usage_val=1 - - printf "%s\n\n" "$1" - - else - _usage_val=0 - fi - - printf 'usage:\n' - printf ' %s -h\n' "$script" - 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 '\n' - printf ' -a, --library\n' - printf ' Build the libbc instead of the programs. This is meant to be used with\n' - printf ' Other software like programming languages that want to make use of the\n' - printf ' parsing and math capabilities. This option will install headers using\n' - printf ' `make install`.\n' - printf ' -b, --bc-only\n' - printf ' Build bc only. It is an error if "-d", "--dc-only", "-B", or\n' - printf ' "--disable-bc" are specified too.\n' - printf ' -B, --disable-bc\n' - printf ' Disable bc. It is an error if "-b", "--bc-only", "-D", or "--disable-dc"\n' - printf ' are specified too.\n' - printf ' -c, --coverage\n' - printf ' Generate test coverage code. Requires gcov and regcovr.\n' - printf ' It is an error if either "-b" ("-D") or "-d" ("-B") is specified.\n' - printf ' Requires a compiler that use gcc-compatible coverage options\n' - printf ' -C, --disable-clean\n' - printf ' Disable the clean that configure.sh does before configure.\n' - printf ' -d, --dc-only\n' - printf ' Build dc only. It is an error if "-b", "--bc-only", "-D", or\n' - printf ' "--disable-dc" are specified too.\n' - printf ' -D, --disable-dc\n' - printf ' Disable dc. It is an error if "-d", "--dc-only", "-B", or "--disable-bc"\n' - printf ' are specified too.\n' - printf ' -E, --disable-extra-math\n' - printf ' Disable extra math. This includes: "$" operator (truncate to integer),\n' - printf ' "@" operator (set number of decimal places), and r(x, p) (rounding\n' - printf ' function). Additionally, this option disables the extra printing\n' - printf ' functions in the math library.\n' - printf ' -f, --force\n' - printf ' Force use of all enabled options, even if they do not work. This\n' - printf ' option is to allow the maintainer a way to test that certain options\n' - printf ' are not failing invisibly. (Development only.)' - printf ' -g, --debug\n' - printf ' Build in debug mode. Adds the "-g" flag, and if there are no\n' - printf ' other CFLAGS, and "-O" was not given, this also adds the "-O0"\n' - printf ' flag. If this flag is *not* given, "-DNDEBUG" is added to CPPFLAGS\n' - printf ' and a strip flag is added to the link stage.\n' - printf ' -G, --disable-generated-tests\n' - printf ' Disable generating tests. This is for platforms that do not have a\n' - printf ' GNU bc-compatible bc to generate tests.\n' - printf ' -h, --help\n' - printf ' Print this help message and exit.\n' - printf ' -H, --disable-history\n' - printf ' Disable history.\n' - printf ' -k KARATSUBA_LEN, --karatsuba-len KARATSUBA_LEN\n' - printf ' Set the karatsuba length to KARATSUBA_LEN (default is 64).\n' - printf ' It is an error if KARATSUBA_LEN is not a number or is less than 16.\n' - printf ' -l, --install-all-locales\n' - printf ' Installs all locales, regardless of how many are on the system. This\n' - printf ' option is useful for package maintainers who want to make sure that\n' - printf ' a package contains all of the locales that end users might need.\n' - printf ' -m, --enable-memcheck\n' - printf ' Enable memcheck mode, to ensure no memory leaks. For development only.\n' - printf ' -M, --disable-man-pages\n' - printf ' Disable installing manpages.\n' - printf ' -N, --disable-nls\n' - printf ' Disable POSIX locale (NLS) support.\n' - printf ' -O OPT_LEVEL, --opt OPT_LEVEL\n' - 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 ' -t, --enable-test-timing\n' - printf ' Enable the timing of tests. This is for development only.\n' - printf ' -T, --disable-strip\n' - printf ' Disable stripping symbols from the compiled binary or binaries.\n' - printf ' Stripping symbols only happens when debug mode is off.\n' - printf ' -v, --enable-valgrind\n' - printf ' Enable a build appropriate for valgrind. For development only.\n' - printf ' -z, --enable-fuzz-mode\n' - printf ' Enable fuzzing mode. THIS IS FOR DEVELOPMENT ONLY.\n' - printf ' --prefix PREFIX\n' - printf ' The prefix to install to. Overrides "$PREFIX" if it exists.\n' - printf ' If PREFIX is "/usr", install path will be "/usr/bin".\n' - printf ' Default is "/usr/local".\n' - printf ' --bindir BINDIR\n' - printf ' The directory to install binaries in. Overrides "$BINDIR" if it exists.\n' - printf ' Default is "$PREFIX/bin".\n' - printf ' --includedir INCLUDEDIR\n' - printf ' The directory to install headers in. Overrides "$INCLUDEDIR" if it\n' - printf ' exists. Default is "$PREFIX/include".\n' - printf ' --libdir LIBDIR\n' - printf ' The directory to install libraries in. Overrides "$LIBDIR" if it exists.\n' - printf ' Default is "$PREFIX/lib".\n' - printf ' --datarootdir DATAROOTDIR\n' - printf ' The root location for data files. Overrides "$DATAROOTDIR" if it exists.\n' - printf ' Default is "$PREFIX/share".\n' - printf ' --datadir DATADIR\n' - printf ' The location for data files. Overrides "$DATADIR" if it exists.\n' - printf ' Default is "$DATAROOTDIR".\n' - printf ' --mandir MANDIR\n' - printf ' The location to install manpages to. Overrides "$MANDIR" if it exists.\n' - printf ' Default is "$DATADIR/man".\n' - printf ' --man1dir MAN1DIR\n' - printf ' The location to install Section 1 manpages to. Overrides "$MAN1DIR" if\n' - printf ' it exists. Default is "$MANDIR/man1".\n' - printf ' --man3dir MAN3DIR\n' - printf ' The location to install Section 3 manpages to. Overrides "$MAN3DIR" if\n' - printf ' it exists. Default is "$MANDIR/man3".\n' - printf '\n' - printf 'In addition, the following environment variables are used:\n' - printf '\n' - printf ' CC C compiler. Must be compatible with POSIX c99. If there is a\n' - printf ' space in the basename of the compiler, the items after the\n' - printf ' first space are assumed to be compiler flags, and in that case,\n' - printf ' the flags are automatically moved into CFLAGS. Default is\n' - printf ' "c99".\n' - printf ' HOSTCC Host C compiler. Must be compatible with POSIX c99. If there is\n' - printf ' a space in the basename of the compiler, the items after the\n' - printf ' first space are assumed to be compiler flags, and in the case,\n' - printf ' the flags are automatically moved into HOSTCFLAGS. Default is\n' - printf ' "$CC".\n' - printf ' HOST_CC Same as HOSTCC. If HOSTCC also exists, it is used.\n' - printf ' CFLAGS C compiler flags.\n' - printf ' HOSTCFLAGS CFLAGS for HOSTCC. Default is "$CFLAGS".\n' - printf ' HOST_CFLAGS Same as HOST_CFLAGS. If HOST_CFLAGS also exists, it is used.\n' - printf ' CPPFLAGS C preprocessor flags. Default is "".\n' - printf ' LDFLAGS Linker flags. Default is "".\n' - printf ' PREFIX The prefix to install to. Default is "/usr/local".\n' - printf ' If PREFIX is "/usr", install path will be "/usr/bin".\n' - printf ' BINDIR The directory to install binaries in. Default is "$PREFIX/bin".\n' - printf ' INCLUDEDIR The directory to install header files in. Default is\n' - printf ' "$PREFIX/include".\n' - printf ' LIBDIR The directory to install libraries in. Default is\n' - printf ' "$PREFIX/lib".\n' - printf ' DATAROOTDIR The root location for data files. Default is "$PREFIX/share".\n' - printf ' DATADIR The location for data files. Default is "$DATAROOTDIR".\n' - printf ' MANDIR The location to install manpages to. Default is "$DATADIR/man".\n' - printf ' MAN1DIR The location to install Section 1 manpages to. Default is\n' - printf ' "$MANDIR/man1".\n' - printf ' MAN3DIR The location to install Section 3 manpages to. Default is\n' - printf ' "$MANDIR/man3".\n' - printf ' NLSPATH The location to install locale catalogs to. Must be an absolute\n' - printf ' path (or contain one). This is treated the same as the POSIX\n' - printf ' definition of $NLSPATH (see POSIX environment variables for\n' - printf ' more information). Default is "/usr/share/locale/%%L/%%N".\n' - printf ' EXECSUFFIX The suffix to append to the executable names, used to not\n' - printf ' interfere with other installed bc executables. Default is "".\n' - printf ' EXECPREFIX The prefix to append to the executable names, used to not\n' - printf ' interfere with other installed bc executables. Default is "".\n' - printf ' DESTDIR For package creation. Default is "". If it is empty when\n' - printf ' `%s` is run, it can also be passed to `make install`\n' "$script" - printf ' later as an environment variable. If both are specified,\n' - printf ' the one given to `%s` takes precedence.\n' "$script" - printf ' LONG_BIT The number of bits in a C `long` type. This is mostly for the\n' - printf ' embedded space since this `bc` uses `long`s internally for\n' - printf ' overflow checking. In C99, a `long` is required to be 32 bits.\n' - printf ' For most normal desktop systems, setting this is unnecessary,\n' - printf ' except that 32-bit platforms with 64-bit longs may want to set\n' - printf ' it to `32`. Default is the default of `LONG_BIT` for the target\n' - printf ' platform. Minimum allowed is `32`. It is a build time error if\n' - printf ' the specified value of `LONG_BIT` is greater than the default\n' - printf ' value of `LONG_BIT` for the target platform.\n' - printf ' GEN_HOST Whether to use `gen/strgen.c`, instead of `gen/strgen.sh`, to\n' - printf ' produce the C files that contain the help texts as well as the\n' - printf ' math libraries. By default, `gen/strgen.c` is used, compiled by\n' - printf ' "$HOSTCC" and run on the host machine. Using `gen/strgen.sh`\n' - printf ' removes the need to compile and run an executable on the host\n' - printf ' machine since `gen/strgen.sh` is a POSIX shell script. However,\n' - printf ' `gen/lib2.bc` is perilously close to 4095 characters, the max\n' - printf ' supported length of a string literal in C99 (and it could be\n' - printf ' added to in the future), and `gen/strgen.sh` generates a string\n' - printf ' literal instead of an array, as `gen/strgen.c` does. For most\n' - printf ' production-ready compilers, this limit probably is not\n' - printf ' enforced, but it could be. Both options are still available for\n' - printf ' this reason. If you are sure your compiler does not have the\n' - printf ' limit and do not want to compile and run a binary on the host\n' - printf ' machine, set this variable to "0". Any other value, or a\n' - printf ' non-existent value, will cause the build system to compile and\n' - printf ' run `gen/strgen.c`. Default is "".\n' - printf ' GEN_EMU Emulator to run string generator code under (leave empty if not\n' - printf ' necessary). This is not necessary when using `gen/strgen.sh`.\n' - printf ' Default is "".\n' - 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' - - exit "$_usage_val" -} - -replace_ext() { - - if [ "$#" -ne 3 ]; then - err_exit "Invalid number of args to $0" - fi - - _replace_ext_file="$1" - _replace_ext_ext1="$2" - _replace_ext_ext2="$3" - - _replace_ext_result="${_replace_ext_file%.$_replace_ext_ext1}.$_replace_ext_ext2" - - printf '%s\n' "$_replace_ext_result" -} - -replace_exts() { - - if [ "$#" -ne 3 ]; then - err_exit "Invalid number of args to $0" - fi - - _replace_exts_files="$1" - _replace_exts_ext1="$2" - _replace_exts_ext2="$3" - - for _replace_exts_file in $_replace_exts_files; do - _replace_exts_new_name=$(replace_ext "$_replace_exts_file" "$_replace_exts_ext1" "$_replace_exts_ext2") - _replace_exts_result="$_replace_exts_result $_replace_exts_new_name" - done - - printf '%s\n' "$_replace_exts_result" -} - -replace() { - - if [ "$#" -ne 3 ]; then - err_exit "Invalid number of args to $0" - fi - - _replace_str="$1" - _replace_needle="$2" - _replace_replacement="$3" - - substring_replace "$_replace_str" "%%$_replace_needle%%" "$_replace_replacement" -} - -find_src_files() { - - if [ "$#" -ge 1 ] && [ "$1" != "" ]; then - - while [ "$#" -ge 1 ]; do - _find_src_files_a="${1## }" - shift - _find_src_files_args="$_find_src_files_args ! -path src/${_find_src_files_a}" - done - - else - _find_src_files_args="-print" - fi - - printf '%s\n' $(find src/ -depth -name "*.c" $_find_src_files_args) -} - -gen_file_list() { - - if [ "$#" -lt 1 ]; then - err_exit "Invalid number of args to $0" - fi - - _gen_file_list_contents="$1" - shift - - p=$(pwd) - - cd "$scriptdir" - - if [ "$#" -ge 1 ]; then - _gen_file_list_unneeded="$@" - else - _gen_file_list_unneeded="" - fi - - _gen_file_list_needle_src="SRC" - _gen_file_list_needle_obj="OBJ" - _gen_file_list_needle_gcda="GCDA" - _gen_file_list_needle_gcno="GCNO" - - _gen_file_list_replacement=$(find_src_files $_gen_file_list_unneeded | tr '\n' ' ') - _gen_file_list_contents=$(replace "$_gen_file_list_contents" \ - "$_gen_file_list_needle_src" "$_gen_file_list_replacement") - - _gen_file_list_replacement=$(replace_exts "$_gen_file_list_replacement" "c" "o") - _gen_file_list_contents=$(replace "$_gen_file_list_contents" \ - "$_gen_file_list_needle_obj" "$_gen_file_list_replacement") - - _gen_file_list_replacement=$(replace_exts "$_gen_file_list_replacement" "o" "gcda") - _gen_file_list_contents=$(replace "$_gen_file_list_contents" \ - "$_gen_file_list_needle_gcda" "$_gen_file_list_replacement") - - _gen_file_list_replacement=$(replace_exts "$_gen_file_list_replacement" "gcda" "gcno") - _gen_file_list_contents=$(replace "$_gen_file_list_contents" \ - "$_gen_file_list_needle_gcno" "$_gen_file_list_replacement") - - cd "$p" - - printf '%s\n' "$_gen_file_list_contents" -} - -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) - - for _gen_tests_t in $(cat "$scriptdir/tests/$_gen_tests_name/all.txt"); do - - if [ "$_gen_tests_extra_math" -eq 0 ]; then - - if [ -z "${_gen_tests_extra_required##*$_gen_tests_t*}" ]; then - printf 'test_%s_%s:\n\t@printf "Skipping %s %s\\n"\n\n' \ - "$_gen_tests_name" "$_gen_tests_t" "$_gen_tests_name" \ - "$_gen_tests_t" >> "$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 00000000000..bd7a56adb6f --- /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 af96564e770..de133978007 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,57 +439,113 @@ gen_file_list() { printf '%s\n' "$_gen_file_list_contents" } -gen_tests() { - - _gen_tests_name="$1" - shift +# 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_std_tests() { - _gen_tests_uname="$1" + _gen_std_tests_name="$1" shift - _gen_tests_extra_math="$1" + _gen_std_tests_extra_math="$1" shift - _gen_tests_time_tests="$1" + _gen_std_tests_time_tests="$1" shift - _gen_tests_extra_required=$(cat tests/extra_required.txt) + _gen_std_tests_extra_required=$(cat "$scriptdir/tests/extra_required.txt") - for _gen_tests_t in $(cat "$scriptdir/tests/$_gen_tests_name/all.txt"); do + for _gen_std_tests_t in $(cat "$scriptdir/tests/$_gen_std_tests_name/all.txt"); do - if [ "$_gen_tests_extra_math" -eq 0 ]; then + if [ "$_gen_std_tests_extra_math" -eq 0 ]; then - if [ -z "${_gen_tests_extra_required##*$_gen_tests_t*}" ]; then + if [ -z "${_gen_std_tests_extra_required##*$_gen_std_tests_t*}" ]; then printf 'test_%s_%s:\n\t@printf "Skipping %s %s\\n"\n\n' \ - "$_gen_tests_name" "$_gen_tests_t" "$_gen_tests_name" \ - "$_gen_tests_t" >> "$scriptdir/Makefile" + "$_gen_std_tests_name" "$_gen_std_tests_t" "$_gen_std_tests_name" \ + "$_gen_std_tests_t" >> "$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" \ + "$_gen_std_tests_name" "$_gen_std_tests_t" "$_gen_std_tests_name" \ + "$_gen_std_tests_t" "$generate_tests" "$time_tests" \ "$*" >> "$scriptdir/Makefile" done } -gen_test_targets() { +# 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_std_test_targets() { - _gen_test_targets_name="$1" + _gen_std_test_targets_name="$1" shift - _gen_test_targets_tests=$(cat "$scriptdir/tests/${_gen_test_targets_name}/all.txt") + _gen_std_test_targets_tests=$(cat "$scriptdir/tests/${_gen_std_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" + for _gen_std_test_targets_t in $_gen_std_test_targets_tests; do + printf ' test_%s_%s' "$_gen_std_test_targets_name" "$_gen_std_test_targets_t" done printf '\n' } +# Generates the proper test targets for each error test to have its own target. +# This allows `make test_bc_errors` and `make test_dc_errors` to run in +# parallel. +# +# @param name Which calculator to generate tests for. +gen_err_tests() { + + _gen_err_tests_name="$1" + shift + + _gen_err_tests_fs=$(ls "$scriptdir/tests/$_gen_err_tests_name/errors/") + + for _gen_err_tests_t in $_gen_err_tests_fs; do + + printf 'test_%s_error_%s:\n\t@sh tests/error.sh %s %s %s\n\n' \ + "$_gen_err_tests_name" "$_gen_err_tests_t" "$_gen_err_tests_name" \ + "$_gen_err_tests_t" "$*" >> "$scriptdir/Makefile" + + done + +} + +# Generates a list of error test targets that will be used as prerequisites for +# other targets. +# +# @param name The name of the calculator to generate test targets for. +gen_err_test_targets() { + + _gen_err_test_targets_name="$1" + shift + + _gen_err_test_targets_tests=$(ls "$scriptdir/tests/$_gen_err_test_targets_name/errors/") + + for _gen_err_test_targets_t in $_gen_err_test_targets_tests; do + printf ' test_%s_error_%s' "$_gen_err_test_targets_name" "$_gen_err_test_targets_t" + done + + 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 +573,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 +620,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 +637,6 @@ optimization="" generate_tests=1 install_manpages=1 nls=1 -prompt=1 force=0 strip_bin=1 all_locales=0 @@ -468,7 +647,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 +682,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 +784,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 +806,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 +831,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 +880,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 +910,8 @@ elif [ -z "$HOSTCC" ]; then fi if [ "$HOSTCC" != "$CC" ]; then + + # Like above, this splits HOSTCC and HOSTCFLAGS. ccbase=$(basename "$HOSTCC") suffix=" *" prefix="* " @@ -717,14 +936,20 @@ 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" -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)" +bc_test_np="@tests/all.sh -n 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)" +dc_test_np="@tests/all.sh -n dc $extra_math 1 $generate_tests $time_tests \$(DC_EXEC)" timeconst="@tests/bc/timeconst.sh tests/bc/scripts/timeconst.bc \$(BC_EXEC)" @@ -739,6 +964,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 +982,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 +996,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 +1009,8 @@ elif [ "$bc_only" -eq 1 ]; then executables="bc" dc_test="@printf 'No dc tests to run\\\\n'" + dc_test_np="@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" @@ -802,6 +1035,8 @@ elif [ "$dc_only" -eq 1 ]; then executable="DC_EXEC" bc_test="@printf 'No bc tests to run\\\\n'" + bc_test_np="@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'" @@ -841,14 +1076,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 +1094,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 +1119,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 +1127,8 @@ else COVERAGE_PREREQS="" fi + +# Set some defaults. if [ -z "${DESTDIR+set}" ]; then destdir="" else @@ -909,12 +1151,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 +1184,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 +1194,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 +1236,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 +1270,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 +1278,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 +1306,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 +1349,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 +1361,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 +1369,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 +1377,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 +1391,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 +1413,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,10 +1427,21 @@ if [ "$vg" -ne 0 ]; then memcheck=1 fi -bc_tests=$(gen_test_targets bc) +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_std_test_targets bc) bc_script_tests=$(gen_script_test_targets bc) -dc_tests=$(gen_test_targets dc) +bc_err_tests=$(gen_err_test_targets bc) +dc_tests=$(gen_std_test_targets dc) dc_script_tests=$(gen_script_test_targets dc) +dc_err_tests=$(gen_err_test_targets dc) # Print out the values; this is for debugging. if [ "$bc" -ne 0 ]; then @@ -1154,7 +1459,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 +1485,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 +1506,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,20 +1522,25 @@ 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") contents=$(replace "$contents" "DC_ENABLED" "$dc") contents=$(replace "$contents" "BC_ALL_TESTS" "$bc_test") +contents=$(replace "$contents" "BC_ALL_TESTS_NP" "$bc_test_np") contents=$(replace "$contents" "BC_TESTS" "$bc_tests") contents=$(replace "$contents" "BC_SCRIPT_TESTS" "$bc_script_tests") +contents=$(replace "$contents" "BC_ERROR_TESTS" "$bc_err_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_ALL_TESTS_NP" "$dc_test_np") contents=$(replace "$contents" "DC_TESTS" "$dc_tests") contents=$(replace "$contents" "DC_SCRIPT_TESTS" "$dc_script_tests") +contents=$(replace "$contents" "DC_ERROR_TESTS" "$dc_err_tests") contents=$(replace "$contents" "DC_TEST_EXEC" "$dc_test_exec") contents=$(replace "$contents" "BUILD_TYPE" "$manpage_args") @@ -1227,7 +1549,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") @@ -1280,8 +1601,9 @@ 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" "BC_HISTORY_TEST_PREREQS" "$test_bc_history_prereqs") +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 +1621,35 @@ 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_std_tests bc "$extra_math" "$time_tests" $bc_test_exec gen_script_tests bc "$extra_math" "$generate_tests" "$time_tests" $bc_test_exec + gen_err_tests bc $bc_test_exec fi if [ "$dc" -ne 0 ]; then - gen_tests dc DC "$extra_math" "$time_tests" $dc_test_exec + gen_std_tests dc "$extra_math" "$time_tests" $dc_test_exec gen_script_tests dc "$extra_math" "$generate_tests" "$time_tests" $dc_test_exec + gen_err_tests dc $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 c9b0482d8c4..9ba34c60648 100644 --- a/contrib/bc/gen/bc_help.txt +++ b/contrib/bc/gen/bc_help.txt @@ -86,6 +86,10 @@ Options: Force interactive mode. + -L --no-line-length + + Disable line length checking. + -l --mathlib Use predefined math routines: @@ -108,6 +112,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 +138,48 @@ Options: -v --version Print version information and copyright and exit. + + -z --leading-zeroes + + Enable leading zeroes on numbers greater than -1 and less than 1. + +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. Using 0 will disable line length checking. + + 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 c573b96791e..4cf10826cd7 100644 --- a/contrib/bc/gen/dc_help.txt +++ b/contrib/bc/gen/dc_help.txt @@ -89,6 +89,10 @@ Options: Put dc into interactive mode. See the man page for more details. + -L --no-line-length + + Disable line length checking. + -P --no-prompt Disable the prompts in interactive mode. @@ -104,3 +108,37 @@ Options: -x --extended-register Enable extended register mode. + + -z --leading-zeroes + + Enable leading zeroes on numbers greater than -1 and less than 1. + +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. Using 0 will disable line length checking. + + 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 2cd9256efa5..c0cd7f7dc8d 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 399c7ad3d31..23cbec104d0 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,75 @@ 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 plz(x){ + if(leading_zero())print x + else{ + if(x>-1&&x<1&&x!=0){ + if(x<0)print"-" + print 0,abs(x) + } + else print x + } +} +define void plznl(x){ + plz(x) + print"\n" +} +define void pnlz(x){ + auto s,i + if(leading_zero()){ + if(x>-1&&x<1&&x!=0){ + s=scale(x) + if(x<0)print"-" + print"." + x=abs(x) + for(i=0;i1)p=log(b,obase)+1 else p=b @@ -250,15 +328,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 +376,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 +390,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 fbc694a3762..63faf1ec347 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 * =