git: e84a97439b4b - stable/13 - usr.bin/gh-bc, contrib/bc: update to version 5.0.0

From: Stefan Eßer <se_at_FreeBSD.org>
Date: Tue, 12 Oct 2021 14:21:57 UTC
The branch stable/13 has been updated by se:

URL: https://cgit.FreeBSD.org/src/commit/?id=e84a97439b4bcc11e04837b2f130dfff4c755c5f

commit e84a97439b4bcc11e04837b2f130dfff4c755c5f
Author:     Stefan Eßer <se@FreeBSD.org>
AuthorDate: 2021-08-10 08:42:54 +0000
Commit:     Stefan Eßer <se@FreeBSD.org>
CommitDate: 2021-10-12 14:18:26 +0000

    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 ++
 contrib/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 +
 .../{fuzzing/dc_inputs/17.txt => dc/errors/32.txt} |    2 +-
 contrib/bc/tests/dc/errors/33.txt                  |  Bin 0 -> 323 bytes
 .../{fuzzing/dc_inputs/26.txt => dc/errors/34.txt} |  104 +-
 contrib/bc/tests/dc/exec_stack_len.txt             |    6 +
 contrib/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 -
 contrib/bc/tests/fuzzing/bc_inputs1/arctangent.txt |   26 -
 contrib/bc/tests/fuzzing/bc_inputs1/array.bc       |   60 -
 contrib/bc/tests/fuzzing/bc_inputs1/arrays.txt     |   10 -
 .../bc/tests/fuzzing/bc_inputs1/assignments.txt    |  122 -
 contrib/bc/tests/fuzzing/bc_inputs1/basic.txt      |    7 -
 contrib/bc/tests/fuzzing/bc_inputs1/boolean.txt    |  184 -
 contrib/bc/tests/fuzzing/bc_inputs1/cosine.txt     |   44 -
 contrib/bc/tests/fuzzing/bc_inputs1/decimal.txt    |   35 -
 contrib/bc/tests/fuzzing/bc_inputs1/divide.txt     |   31 -
 .../bc/tests/fuzzing/bc_inputs1/engineering.txt    |   19 -
 contrib/bc/tests/fuzzing/bc_inputs1/exponent.txt   |   22 -
 contrib/bc/tests/fuzzing/bc_inputs1/functions.bc   |    7 -
 contrib/bc/tests/fuzzing/bc_inputs1/functions.txt  |   13 -
 contrib/bc/tests/fuzzing/bc_inputs1/globals.txt    |   21 -
 contrib/bc/tests/fuzzing/bc_inputs1/len.bc         |   48 -
 contrib/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 -
 contrib/bc/tests/fuzzing/bc_inputs2/modulus.txt    |   69 -
 contrib/bc/tests/fuzzing/bc_inputs2/multiply.txt   |   40 -
 contrib/bc/tests/fuzzing/bc_inputs2/pi.txt         |    4 -
 contrib/bc/tests/fuzzing/bc_inputs2/places.txt     |   19 -
 contrib/bc/tests/fuzzing/bc_inputs2/power.txt      |   44 -
 contrib/bc/tests/fuzzing/bc_inputs2/print2.txt     |  194 -
 contrib/bc/tests/fuzzing/bc_inputs2/references.bc  |  408 --
 contrib/bc/tests/fuzzing/bc_inputs2/scale.txt      |   57 -
 contrib/bc/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 -
 contrib/bc/tests/fuzzing/bc_inputs3/strings.txt    |   12 -
 contrib/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 -
 contrib/bc/tests/fuzzing/dc_inputs/boolean.txt     |   80 -
 contrib/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 -
 contrib/bc/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 -
 contrib/bc/tests/fuzzing/dc_inputs/modulus.txt     |   70 -
 contrib/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 -
 contrib/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 -
 contrib/bc/tests/fuzzing/dc_inputs/strings.txt     |   50 -
 contrib/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 +++++
 contrib/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(-)

diff --git a/contrib/bc/.gitattributes b/contrib/bc/.gitattributes
index 22d6e60bce68..1e2c56dde215 100644
--- a/contrib/bc/.gitattributes
+++ b/contrib/bc/.gitattributes
@@ -1,3 +1,3 @@
 *.vcxproj eol=crlf
 *.vcxproj.filters eol=crlf
-*.sln eol= crlf
+*.sln eol=crlf
diff --git a/contrib/bc/.gitignore b/contrib/bc/.gitignore
index b131d5813764..31e43aa61efc 100644
--- a/contrib/bc/.gitignore
+++ b/contrib/bc/.gitignore
@@ -51,11 +51,17 @@ print_results.txt
 bessel.txt
 bessel_results.txt
 prime.txt
-stream.txt
+strings2.txt
+strings2_results.txt
 tests/bc/scripts/add.txt
 tests/bc/scripts/divide.txt
 tests/bc/scripts/multiply.txt
 tests/bc/scripts/subtract.txt
+tests/bc/scripts/strings2.txt
+benchmarks/bc/*.txt
+benchmarks/dc/*.txt
+scripts/ministat
+scripts/bitgen
 perf.data
 perf.data.old
 *.gcda
diff --git a/contrib/bc/LICENSE.md b/contrib/bc/LICENSE.md
index 269e131cc81d..8ab2e6069881 100644
--- a/contrib/bc/LICENSE.md
+++ b/contrib/bc/LICENSE.md
@@ -79,9 +79,9 @@ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-## `safe-install.sh`
+## `scripts/safe-install.sh`
 
-The file `safe-install.sh` is under the following copyright and license:
+The file `scripts/safe-install.sh` is under the following copyright and license:
 
 Copyright (c) 2021 Rich Felker
 
@@ -101,3 +101,13 @@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+## `scripts/ministat.c`
+
+The file `scripts/ministat.c` is under the following license:
+
+"THE BEER-WARE LICENSE" (Revision 42):
+
+<phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you
+can do whatever you want with this stuff. If we meet some day, and you think
+this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
diff --git a/contrib/bc/Makefile.in b/contrib/bc/Makefile.in
index 2b50476a79fe..3d6780d6ac95 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 c78bddd27e76..5251096d9f2a 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.
+
*** 152081 LINES SKIPPED ***