Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Feb 2023 16:35:04 GMT
From:      =?utf-8?Q?Stefan=20E=C3=9Fer?= <se@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 6b05c3fc615b - stable/13 - contrib/bc: update to version 6.2.2
Message-ID:  <202302071635.317GZ4q6017870@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by se:

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

commit 6b05c3fc615bbbb1f28ecd2533711122d7e16fc4
Author:     Stefan Eßer <se@FreeBSD.org>
AuthorDate: 2022-03-07 22:23:56 +0000
Commit:     Stefan Eßer <se@FreeBSD.org>
CommitDate: 2023-02-07 16:34:03 +0000

    contrib/bc: update to version 6.2.2
    
    This is a squashed commit that updates bc from version 5.2.2 to
    version 6.2.2:
    
    contrib/bc: update to version 5.2.3
    
    This version fixes a parse error when passing a file to bc using -f
    if that file has a multiline comment or string in it.
    
    Merge commit '3673adf1ee311d6f83176d3e43cf0efb314764e4'
    
    (cherry picked from commit 23210c9f42af94dc6bcdae3996d8a3d010dd6bfe)
    
    contrib/bc: include assert.h when building with C11 or newer
    
    This chunk should have been committed with the MFV commit
    23210c9f42af94dc but was missing for an unknown reasn.
    
    (cherry picked from commit b66d67d97aa58d0f239056917bbdbab26f41446a)
    
    contrib/bc: import version 5.2.4
    
    This update fixes an issue in input line editing: when going left to
    the start of the line, the cursor would jump to the end of the line
    instead.
    
    Merge commit 'bc75dcc4ce682562390fa32e7cd63c08160e21b9'
    
    (cherry picked from commit b85b9c88eb02298ea7fa3885619f54ac0e930ba4)
    
    vendor/bc: import of version 5.2.5
    
    This is a production release that fixes this bc's behavior on ^D to
    match GNU bc.
    
    (cherry picked from commit ed0603704174b01c25b49efc08c82e1532dc5622)
    (cherry picked from commit f4ff1c300ef4081696bdd6ad34547be9242e419c)
    
    usr.bin/bc: update to version 5.3.1
    
    This version adds support for command line editing and history using
    the libedit or readline libraries in addition to the line editing
    features available in previous versions.
    
    The version in the base system is configured to use libedit.
    
    This allows to choose between emacs and vi line editing commands and
    to use command overrides via a ~/.editrc file.
    
    Merge commit 'bd54318046bfee055b140705a5cfd4148e78da07'
    
    (cherry picked from commit 78bc019d220e05abb5b12f678f9b4a847019bbcc)
    
    contrib/bc: merge from vendor release 5.3.3
    
    This update fixes a build issue of release 5.3.2 on the FreeBSD base
    system.
    
    Merge commit '3f739b0595b7d6ac4bac9aaa1cae0910f11f92e2'
    
    (cherry picked from commit f53b5fe7865f4e4240e40ba0f6345f81d337a823)
    
    vendor/bc: update to upstream commit ca53adf83b7a
    
    The filter_text function in scripts/functions.sh in version 5.3.3 had
    commented out a "rm" command, probably for debugging purposes. This
    caused temporary files to persist in /tmp when the bc program had been
    built.
    
    This commit fixes the build process with no change of the resulting
    artefacts.
    
    (cherry picked from commit 1576f66712876ee8b0fcc8b35fb062e1813b4fc0)
    (cherry picked from commit f6ed05f1233043eb30a7e5a1efcb7247ad2add90)
    
    contrib/bc: merge from vendor release 6.2.2
    
    This update fixes a few issues in history editing and the processing
    of the "quit" function. The "quit" function will no longer cause bc
    to exit when encountered in a script file (before any command from
    the script has been executed).
    
    New functions is_number(), is_string return 1 if the passed argument
    is a number resp. a string. The asciify() function has been extended
    to support the conversion of an array of numbers into a string.
    
    Merge commit '1a63323d17fedb05b6962853e821c9d7c6b9853e'
    
    (cherry picked from commit d101cdd6edd782f6ec56eef63ed91abd77a8b317)
---
 contrib/bc/.gitignore                           |   80 --
 contrib/bc/LICENSE.md                           |    6 +-
 contrib/bc/MEMORY_BUGS.md                       |   53 +
 contrib/bc/Makefile.in                          |   33 +-
 contrib/bc/NEWS.md                              |  193 +++
 contrib/bc/NOTICE.md                            |    2 +-
 contrib/bc/README.md                            |   95 +-
 contrib/bc/configure.sh                         |  421 +++++-
 contrib/bc/gen/bc_help.txt                      |   66 +-
 contrib/bc/gen/dc_help.txt                      |   64 +-
 contrib/bc/gen/lib.bc                           |    3 +-
 contrib/bc/gen/lib2.bc                          |   15 +-
 contrib/bc/gen/strgen.c                         |  310 ++++-
 contrib/bc/gen/strgen.sh                        |   35 +-
 contrib/bc/include/args.h                       |   33 +-
 contrib/bc/include/bc.h                         |   71 +-
 contrib/bc/include/bcl.h                        |  305 ++--
 contrib/bc/include/dc.h                         |   17 +-
 contrib/bc/include/file.h                       |  100 +-
 contrib/bc/include/history.h                    |  165 ++-
 contrib/bc/include/lang.h                       |  129 +-
 contrib/bc/include/lex.h                        |  101 +-
 contrib/bc/include/library.h                    |  198 +--
 contrib/bc/include/num.h                        |  175 ++-
 contrib/bc/include/opt.h                        |   26 +-
 contrib/bc/include/parse.h                      |   83 +-
 contrib/bc/include/program.h                    | 1153 +++++++++-------
 contrib/bc/include/rand.h                       |   50 +-
 contrib/bc/include/read.h                       |   14 +-
 contrib/bc/include/status.h                     |  490 +++++--
 contrib/bc/include/vector.h                     |  120 +-
 contrib/bc/include/version.h                    |    4 +-
 contrib/bc/include/vm.h                         |  450 ++++--
 contrib/bc/locales/de_DE.ISO8859-1.msg          |   17 +-
 contrib/bc/locales/de_DE.UTF-8.msg              |   17 +-
 contrib/bc/locales/en_US.msg                    |   21 +-
 contrib/bc/locales/es_ES.ISO8859-1.msg          |   17 +-
 contrib/bc/locales/es_ES.UTF-8.msg              |   17 +-
 contrib/bc/locales/fr_FR.ISO8859-1.msg          |   17 +-
 contrib/bc/locales/fr_FR.UTF-8.msg              |   17 +-
 contrib/bc/locales/ja_JP.UTF-8.msg              |   17 +-
 contrib/bc/locales/ja_JP.eucJP.msg              |   17 +-
 contrib/bc/locales/nl_NL.ISO8859-1.msg          |   17 +-
 contrib/bc/locales/nl_NL.UTF-8.msg              |   17 +-
 contrib/bc/locales/pl_PL.ISO8859-2.msg          |   17 +-
 contrib/bc/locales/pl_PL.UTF-8.msg              |   17 +-
 contrib/bc/locales/pt_PT.ISO8859-1.msg          |   17 +-
 contrib/bc/locales/pt_PT.UTF-8.msg              |   17 +-
 contrib/bc/locales/ru_RU.CP1251.msg             |   17 +-
 contrib/bc/locales/ru_RU.CP866.msg              |   17 +-
 contrib/bc/locales/ru_RU.ISO8859-5.msg          |   17 +-
 contrib/bc/locales/ru_RU.KOI8-R.msg             |   17 +-
 contrib/bc/locales/ru_RU.UTF-8.msg              |   17 +-
 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              |   17 +-
 contrib/bc/locales/zh_CN.eucCN.msg              |   17 +-
 contrib/bc/manuals/algorithms.md                |    2 +-
 contrib/bc/manuals/bc/A.1                       |  433 ++++--
 contrib/bc/manuals/bc/A.1.md                    |  355 +++--
 contrib/bc/manuals/bc/E.1                       |  404 ++++--
 contrib/bc/manuals/bc/E.1.md                    |  337 +++--
 contrib/bc/manuals/bc/EH.1                      |  404 ++++--
 contrib/bc/manuals/bc/EH.1.md                   |  337 +++--
 contrib/bc/manuals/bc/EHN.1                     |  404 ++++--
 contrib/bc/manuals/bc/EHN.1.md                  |  337 +++--
 contrib/bc/manuals/bc/EN.1                      |  404 ++++--
 contrib/bc/manuals/bc/EN.1.md                   |  337 +++--
 contrib/bc/manuals/bc/H.1                       |  433 ++++--
 contrib/bc/manuals/bc/H.1.md                    |  355 +++--
 contrib/bc/manuals/bc/HN.1                      |  433 ++++--
 contrib/bc/manuals/bc/HN.1.md                   |  355 +++--
 contrib/bc/manuals/bc/N.1                       |  433 ++++--
 contrib/bc/manuals/bc/N.1.md                    |  355 +++--
 contrib/bc/manuals/bcl.3                        |  211 ++-
 contrib/bc/manuals/bcl.3.md                     |  171 ++-
 contrib/bc/manuals/build.md                     |  166 ++-
 contrib/bc/manuals/dc/A.1                       |  323 +++--
 contrib/bc/manuals/dc/A.1.md                    |  245 +++-
 contrib/bc/manuals/dc/E.1                       |  308 +++--
 contrib/bc/manuals/dc/E.1.md                    |  236 +++-
 contrib/bc/manuals/dc/EH.1                      |  308 +++--
 contrib/bc/manuals/dc/EH.1.md                   |  236 +++-
 contrib/bc/manuals/dc/EHN.1                     |  308 +++--
 contrib/bc/manuals/dc/EHN.1.md                  |  236 +++-
 contrib/bc/manuals/dc/EN.1                      |  308 +++--
 contrib/bc/manuals/dc/EN.1.md                   |  236 +++-
 contrib/bc/manuals/dc/H.1                       |  323 +++--
 contrib/bc/manuals/dc/H.1.md                    |  245 +++-
 contrib/bc/manuals/dc/HN.1                      |  323 +++--
 contrib/bc/manuals/dc/HN.1.md                   |  245 +++-
 contrib/bc/manuals/dc/N.1                       |  323 +++--
 contrib/bc/manuals/dc/N.1.md                    |  245 +++-
 contrib/bc/scripts/exec-install.sh              |    2 +-
 contrib/bc/scripts/format.sh                    |   51 +
 contrib/bc/scripts/functions.sh                 |   93 +-
 contrib/bc/scripts/karatsuba.py                 |    2 +-
 contrib/bc/scripts/link.sh                      |    2 +-
 contrib/bc/scripts/lint.sh                      |   63 +
 contrib/bc/scripts/locale_install.sh            |    2 +-
 contrib/bc/scripts/locale_uninstall.sh          |    2 +-
 contrib/bc/src/args.c                           |  209 ++-
 contrib/bc/src/bc.c                             |   21 +-
 contrib/bc/src/bc_lex.c                         |   98 +-
 contrib/bc/src/bc_parse.c                       |  880 ++++++++----
 contrib/bc/src/data.c                           |  908 ++++++------
 contrib/bc/src/dc.c                             |   21 +-
 contrib/bc/src/dc_lex.c                         |   83 +-
 contrib/bc/src/dc_parse.c                       |  181 ++-
 contrib/bc/src/file.c                           |  329 +++--
 contrib/bc/src/history.c                        |  951 +++++++++----
 contrib/bc/src/lang.c                           |  138 +-
 contrib/bc/src/lex.c                            |  191 ++-
 contrib/bc/src/library.c                        |  912 +++++++-----
 contrib/bc/src/main.c                           |   33 +-
 contrib/bc/src/num.c                            | 1659 ++++++++++++++--------
 contrib/bc/src/opt.c                            |  149 +-
 contrib/bc/src/parse.c                          |  136 +-
 contrib/bc/src/program.c                        | 1690 +++++++++++++++--------
 contrib/bc/src/rand.c                           |  198 ++-
 contrib/bc/src/read.c                           |  133 +-
 contrib/bc/src/vector.c                         |  290 ++--
 contrib/bc/src/vm.c                             | 1286 ++++++++++-------
 contrib/bc/tests/all.sh                         |   15 +-
 contrib/bc/tests/bc/all.txt                     |    7 +
 contrib/bc/tests/bc/asciify_array.txt           |   17 +
 contrib/bc/tests/bc/asciify_array_results.txt   |    3 +
 contrib/bc/tests/bc/errors/33.txt               |    2 +
 contrib/bc/tests/bc/errors/34.txt               |  357 +++++
 contrib/bc/tests/bc/errors/35.txt               |    1 +
 contrib/bc/tests/bc/errors/36.txt               |   11 +
 contrib/bc/tests/bc/is_number.txt               |   13 +
 contrib/bc/tests/bc/is_number_results.txt       |   10 +
 contrib/bc/tests/bc/is_string.txt               |   13 +
 contrib/bc/tests/bc/is_string_results.txt       |   10 +
 contrib/bc/tests/bc/line_by_line1.txt           |   10 +
 contrib/bc/tests/bc/line_by_line1_results.txt   |    1 +
 contrib/bc/tests/bc/line_by_line2.txt           |    9 +
 contrib/bc/tests/bc/line_by_line2_results.txt   |    3 +
 contrib/bc/tests/bc/line_loop_quit1.txt         |    2 +
 contrib/bc/tests/bc/line_loop_quit1_results.txt |    4 +
 contrib/bc/tests/bc/line_loop_quit2.txt         |    3 +
 contrib/bc/tests/bc/line_loop_quit2_results.txt |    4 +
 contrib/bc/tests/bc/scripts/afl1.bc             |  261 ++++
 contrib/bc/tests/bc/scripts/afl1.txt            | 1571 +++++++++++++++++++++
 contrib/bc/tests/bc/scripts/all.txt             |    2 +
 contrib/bc/tests/bc/scripts/array2.bc           |   20 +
 contrib/bc/tests/bc/scripts/array2.txt          |    2 +
 contrib/bc/tests/bc/timeconst.sh                |    2 +-
 contrib/bc/tests/bcl.c                          |   76 +-
 contrib/bc/tests/dc/all.txt                     |    3 +
 contrib/bc/tests/dc/errors/15.txt               |  128 +-
 contrib/bc/tests/dc/errors/34.txt               |  117 --
 contrib/bc/tests/dc/is_number.txt               |    9 +
 contrib/bc/tests/dc/is_number_results.txt       |    9 +
 contrib/bc/tests/dc/is_string.txt               |    9 +
 contrib/bc/tests/dc/is_string_results.txt       |    9 +
 contrib/bc/tests/dc/misc1.txt                   |   26 +
 contrib/bc/tests/dc/misc1_results.txt           |   21 +
 contrib/bc/tests/dc/scripts/all.txt             |    1 +
 contrib/bc/tests/dc/scripts/no_clamp.dc         |   29 +
 contrib/bc/tests/dc/scripts/no_clamp.txt        |   29 +
 contrib/bc/tests/error.sh                       |   48 +-
 contrib/bc/tests/errors.sh                      |    2 +-
 contrib/bc/tests/history.py                     |   19 +-
 contrib/bc/tests/history.sh                     |    2 +-
 contrib/bc/tests/other.sh                       |  151 +-
 contrib/bc/tests/read.sh                        |    2 +-
 contrib/bc/tests/script.sh                      |   23 +-
 contrib/bc/tests/scripts.sh                     |    2 +-
 contrib/bc/tests/stdin.sh                       |    2 +-
 contrib/bc/tests/test.sh                        |   10 +-
 contrib/bc/vs/bc.vcxproj                        |   49 +-
 usr.bin/gh-bc/Makefile                          |   11 +-
 175 files changed, 21508 insertions(+), 8948 deletions(-)

diff --git a/contrib/bc/.gitignore b/contrib/bc/.gitignore
deleted file mode 100644
index 31e43aa61efc..000000000000
--- a/contrib/bc/.gitignore
+++ /dev/null
@@ -1,80 +0,0 @@
-*.config
-*.creator
-*.files
-*.includes
-*.creator.user*
-*.cflags
-*.cxxflags
-bin/*bc
-bin/*bc.exe
-bin/*dc
-bin/*dc.exe
-bin/bcl
-bc.old
-*.o
-*.a
-.log_*.txt
-.test.txt
-.math.txt
-.results.txt
-.ops.txt
-manuals/bc.1
-manuals/bc.1.ronn
-manuals/bc.1.md
-manuals/dc.1
-manuals/dc.1.ronn
-manuals/dc.1.md
-gen/strgen
-lib.c
-lib2.c
-lib3.c
-bc_help.c
-dc_help.c
-config.mak
-timeconst.bc
-Makefile
-
-tests/fuzzing/bc_outputs1/*
-tests/fuzzing/bc_outputs2/*
-tests/fuzzing/bc_outputs3/*
-tests/fuzzing/dc_outputs/*
-tests/bc_outputs/*
-tests/dc_outputs/*
-
-.gdb_history
-
-# Ignore the generated test files
-parse.txt
-parse_results.txt
-print.txt
-print_results.txt
-bessel.txt
-bessel_results.txt
-prime.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
-*.gcno
-*.gcov
-*.html
-*.profraw
-
-core.*
-
-cscope*.out
-tags
-
-*.vcxproj.user
-Debug/*
-Release/*
diff --git a/contrib/bc/LICENSE.md b/contrib/bc/LICENSE.md
index 8ab2e6069881..8e6b7e0b9051 100644
--- a/contrib/bc/LICENSE.md
+++ b/contrib/bc/LICENSE.md
@@ -1,6 +1,6 @@
 # License
 
-Copyright (c) 2018-2021 Gavin D. Howard <yzena.tech@gmail.com>
+Copyright (c) 2018-2023 Gavin D. Howard <gavin@yzena.com>
 
 Redistribution and use in source and binary forms, with or without modification,
 are permitted provided that the following conditions are met:
@@ -31,7 +31,7 @@ copyrights and license:
 Copyright (c) 2010-2014, Salvatore Sanfilippo <antirez at gmail dot com><br>
 Copyright (c) 2010-2013, Pieter Noordhuis <pcnoordhuis at gmail dot com><br>
 Copyright (c) 2018 rain-1 <rain1@openmailbox.org><br>
-Copyright (c) 2018-2021, Gavin D. Howard <yzena.tech@gmail.com>
+Copyright (c) 2018-2023, Gavin D. Howard <gavin@yzena.com>
 
 Redistribution and use in source and binary forms, with or without modification,
 are permitted provided that the following conditions are met:
@@ -60,7 +60,7 @@ The files `src/rand.c` and `include/rand.h` are under the following copyrights
 and license:
 
 Copyright (c) 2014-2017 Melissa O'Neill and PCG Project contributors
-Copyright (c) 2018-2021 Gavin D. Howard <yzena.tech@gmail.com>
+Copyright (c) 2018-2023 Gavin D. Howard <gavin@yzena.com>
 
 Permission is hereby granted, free of charge, to any person obtaining a copy of
 this software and associated documentation files (the "Software"), to deal in
diff --git a/contrib/bc/MEMORY_BUGS.md b/contrib/bc/MEMORY_BUGS.md
new file mode 100644
index 000000000000..d675b28b342a
--- /dev/null
+++ b/contrib/bc/MEMORY_BUGS.md
@@ -0,0 +1,53 @@
+# Memory Bugs
+
+This is a list of all of the memory bugs that were found in *released* versions
+of `bc`, `dc`, or `bcl`. (Non-released commits with memory bugs do not count.)
+
+I made this list for two reasons: first, so users can know what versions of
+`bc`, `dc`, and `bcl` have vulnerabilities, and two, I once had a perfect record
+and then found a couple, but forgot and claimed I still had a perfect record
+right after, which was embarrassing.
+
+This list is sorted by the first version a bug exists in, not the last it
+existed in.
+
+* In versions `1.1.0` until `6.2.0` (inclusive) of `bc` and `dc`, there is a
+  out of bounds read and write in history when pressing ctrl+r (or any other
+  unused letter) then inserting two characters.
+
+  The first version without this bug is `6.2.1`.
+
+* In versions `3.0.0` until `6.0.1` (inclusive) of `bc` and `dc`, there is a
+  double-free on `SIGINT` when using command-line expressions with `-e` and
+  `-f`. This was caused by not properly ending a jump series.
+
+  The first version without this bug is `6.0.2`.
+
+* In versions `5.0.0` until `6.0.4` (inclusive) of `bc`, there is an
+  out-of-bounds access if a non-local (non-`auto`) variable is set to a string
+  with `asciify()`, then the function is redefined with a use of the same
+  non-local variable.
+
+  This happened because strings were stored per-function, and the non-local
+  variable now had a reference to the string in the old function, which could be
+  at a higher index than exists in the new function. Strings are stored globally
+  now, and they are *not* freed once not used.
+
+  The first version without this bug is `6.1.0`.
+
+* In versions `5.0.0` until `6.0.4` (inclusive) of `bc`, there is another
+  out-of-bounds access if an array is passed to the `asciify()` built-in
+  function as the only argument. This happened because arrays are allowed as
+  function arguments, which allowed them to be used as arguments to `asciify()`,
+  but they should not have been allowed. However, since they were, the
+  `asciify()` code tried to access an argument that was not there.
+
+  The first version without this bug is `6.1.0`.
+
+* In version `6.0.0` of `bcl`, there are several uses of initialized data that
+  have the same root cause: I forgot to call `memset()` on the per-thread global
+  data. This is because the data used to be *actually* global, which meant that
+  it was initialized to zero by the system. This happened because I thought I
+  had properly hooked Valgrind into my `bcl` tests, but I had not.
+
+  The first version without this bug is `6.0.1`.
diff --git a/contrib/bc/Makefile.in b/contrib/bc/Makefile.in
index b9136a57aa92..83417a333826 100644
--- a/contrib/bc/Makefile.in
+++ b/contrib/bc/Makefile.in
@@ -1,7 +1,7 @@
 #
 # SPDX-License-Identifier: BSD-2-Clause
 #
-# Copyright (c) 2018-2021 Gavin D. Howard and contributors.
+# Copyright (c) 2018-2023 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:
@@ -55,7 +55,7 @@ HISTORY_HEADERS = $(INCDIR)/history.h
 EXTRA_MATH_HEADERS = $(INCDIR)/rand.h
 LIBRARY_HEADERS = $(INCDIR)/bcl.h $(INCDIR)/library.h
 
-GEN_DIR = gen
+GEN_DIR = %%GEN_DIR%%
 GEN = %%GEN%%
 GEN_EXEC = $(GEN_DIR)/$(GEN)
 GEN_C = $(GENDIR)/$(GEN).c
@@ -146,7 +146,7 @@ BC_ENABLE_HISTORY = %%HISTORY%%
 BC_ENABLE_EXTRA_MATH_NAME = BC_ENABLE_EXTRA_MATH
 BC_ENABLE_EXTRA_MATH = %%EXTRA_MATH%%
 BC_ENABLE_NLS = %%NLS%%
-BC_LONG_BIT = %%LONG_BIT%%
+BC_EXCLUDE_EXTRA_MATH = %%EXCLUDE_EXTRA_MATH%%
 
 BC_ENABLE_AFL = %%FUZZ%%
 BC_ENABLE_MEMCHECK = %%MEMCHECK%%
@@ -160,6 +160,8 @@ BC_DEFAULT_PROMPT = %%BC_DEFAULT_PROMPT%%
 DC_DEFAULT_PROMPT = %%DC_DEFAULT_PROMPT%%
 BC_DEFAULT_EXPR_EXIT = %%BC_DEFAULT_EXPR_EXIT%%
 DC_DEFAULT_EXPR_EXIT = %%DC_DEFAULT_EXPR_EXIT%%
+BC_DEFAULT_DIGIT_CLAMP = %%BC_DEFAULT_DIGIT_CLAMP%%
+DC_DEFAULT_DIGIT_CLAMP = %%DC_DEFAULT_DIGIT_CLAMP%%
 
 RM = rm
 MKDIR = mkdir
@@ -191,17 +193,19 @@ 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_DEFS4 = -DBC_DEFAULT_EXPR_EXIT=$(BC_DEFAULT_EXPR_EXIT)
-BC_DEFS = $(BC_DEFS0) $(BC_DEFS1) $(BC_DEFS2) $(BC_DEFS3) $(BC_DEFS4)
+BC_DEFS5 = -DBC_DEFAULT_DIGIT_CLAMP=$(BC_DEFAULT_DIGIT_CLAMP)
+BC_DEFS = $(BC_DEFS0) $(BC_DEFS1) $(BC_DEFS2) $(BC_DEFS3) $(BC_DEFS4) $(BC_DEFS5)
 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_DEFS4 = -DDC_DEFAULT_EXPR_EXIT=$(DC_DEFAULT_EXPR_EXIT)
-DC_DEFS = $(DC_DEFS1) $(DC_DEFS2) $(DC_DEFS3) $(DC_DEFS4)
+DC_DEFS5 = -DDC_DEFAULT_DIGIT_CLAMP=$(DC_DEFAULT_DIGIT_CLAMP)
+DC_DEFS = $(DC_DEFS1) $(DC_DEFS2) $(DC_DEFS3) $(DC_DEFS4) $(DC_DEFS5)
 
 CPPFLAGS1 = -D$(BC_ENABLED_NAME)=$(BC_ENABLED) -D$(DC_ENABLED_NAME)=$(DC_ENABLED)
 CPPFLAGS2 = $(CPPFLAGS1) -I$(INCDIR)/ -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 %%BSD%%
+CPPFLAGS4 = $(CPPFLAGS3) %%BSD%%
 CPPFLAGS5 = $(CPPFLAGS4) -DBC_NUM_KARATSUBA_LEN=$(BC_NUM_KARATSUBA_LEN)
 CPPFLAGS6 = $(CPPFLAGS5) -DBC_ENABLE_NLS=$(BC_ENABLE_NLS)
 CPPFLAGS7 = $(CPPFLAGS6) -D$(BC_ENABLE_EXTRA_MATH_NAME)=$(BC_ENABLE_EXTRA_MATH)
@@ -235,25 +239,25 @@ $(GEN_EXEC): $(GEN_DIR)
 	%%GEN_EXEC_TARGET%%
 
 $(BC_LIB_C): $(GEN_EXEC) $(BC_LIB)
-	$(GEN_EMU) $(GEN_EXEC) $(BC_LIB) $(BC_LIB_C) $(BC_LIB_C_ARGS)
+	$(GEN_EMU) $(GEN_EXEC) $(BC_LIB) $(BC_LIB_C) $(BC_EXCLUDE_EXTRA_MATH) $(BC_LIB_C_ARGS)
 
 $(BC_LIB_O): $(BC_LIB_C)
 	$(CC) $(CFLAGS) -o $@ -c $<
 
 $(BC_LIB2_C): $(GEN_EXEC) $(BC_LIB2)
-	$(GEN_EMU) $(GEN_EXEC) $(BC_LIB2) $(BC_LIB2_C) $(BC_LIB2_C_ARGS)
+	$(GEN_EMU) $(GEN_EXEC) $(BC_LIB2) $(BC_LIB2_C) $(BC_EXCLUDE_EXTRA_MATH) $(BC_LIB2_C_ARGS)
 
 $(BC_LIB2_O): $(BC_LIB2_C)
 	$(CC) $(CFLAGS) -o $@ -c $<
 
 $(BC_HELP_C): $(GEN_EXEC) $(BC_HELP)
-	$(GEN_EMU) $(GEN_EXEC) $(BC_HELP) $(BC_HELP_C) bc_help "" $(BC_ENABLED_NAME)
+	$(GEN_EMU) $(GEN_EXEC) $(BC_HELP) $(BC_HELP_C) $(BC_EXCLUDE_EXTRA_MATH) bc_help "" $(BC_ENABLED_NAME)
 
 $(BC_HELP_O): $(BC_HELP_C)
 	$(CC) $(CFLAGS) -o $@ -c $<
 
 $(DC_HELP_C): $(GEN_EXEC) $(DC_HELP)
-	$(GEN_EMU) $(GEN_EXEC) $(DC_HELP) $(DC_HELP_C) dc_help "" $(DC_ENABLED_NAME)
+	$(GEN_EMU) $(GEN_EXEC) $(DC_HELP) $(DC_HELP_C) $(BC_EXCLUDE_EXTRA_MATH) dc_help "" $(DC_ENABLED_NAME)
 
 $(DC_HELP_O): $(DC_HELP_C)
 	$(CC) $(CFLAGS) -o $@ -c $<
@@ -298,11 +302,6 @@ help:
 	@printf '    time_test_dc    runs the dc test suite, displaying times for some things\n'
 	@printf '    timeconst       runs the test on the Linux timeconst.bc script,\n'
 	@printf '                    if it exists and bc has been built\n'
-	@printf '    valgrind        runs the test suite through valgrind\n'
-	@printf '    valgrind_bc     runs the bc test suite, if bc has been built,\n'
-	@printf '                    through valgrind\n'
-	@printf '    valgrind_dc     runs the dc test suite, if dc has been built,\n'
-	@printf '                    through valgrind\n'
 
 run_all_tests: bc_all_tests timeconst_all_tests dc_all_tests
 
@@ -501,10 +500,10 @@ test_history_header:
 	@printf '$(TEST_STARS)\n\nRunning history tests...\n\n'
 
 library_test: $(LIBBC)
-	$(CC) $(CFLAGS) $(BCL_TEST_C) $(LIBBC) -o $(BCL_TEST)
+	$(CC) $(CFLAGS) -lpthread $(BCL_TEST_C) $(LIBBC) -o $(BCL_TEST)
 
 test_library: library_test
-	$(BCL_TEST)
+	%%BCL_TEST_EXEC%%
 
 karatsuba:
 	%%KARATSUBA%%
diff --git a/contrib/bc/NEWS.md b/contrib/bc/NEWS.md
index 9a354e537d9f..36952fdaf582 100644
--- a/contrib/bc/NEWS.md
+++ b/contrib/bc/NEWS.md
@@ -1,5 +1,198 @@
 # News
 
+## 6.2.2
+
+This is a production release that fixes a bug.
+
+The bug was that if an array element was used as a parameter, and then a later
+parameter had the same name as the array whose element was used, `bc` would grab
+the element from the new array parameter, not the actual element from before the
+function call.
+
+## 6.2.1
+
+This is a production release with one bug fix for a memory bug in history.
+
+## 6.2.0
+
+This is a production release with a new feature and a few bug fixes.
+
+The bug fixes include:
+
+* A crash when `bc` and `dc` are built using editline, but history is not
+  activated.
+* A missing local in the `uint*()` family of functions in the extended math
+  library.
+* A failure to clear the tail call list in `dc` on error.
+* A crash when attempting to swap characters in command-line history when no
+  characters exist.
+* `SIGWINCH` was activated even when history was not.
+
+The new feature is that stack traces are now given for runtime errors. In debug
+mode, the C source file and line of errors are given as well.
+
+## 6.1.1
+
+This is a production release that fixes a build issue with predefined builds and
+generated tests.
+
+## 6.1.0
+
+This is a production release that fixes a discrepancy from the `bc` standard,
+a couple of memory bugs, and adds new features.
+
+The discrepancy from the `bc` standard was with regards to the behavior of the
+`quit` command. This `bc` used to quit whenever it encountered `quit` during
+parsing, even if it was parsing a full file. Now, `bc` only quits when
+encountering `quit` *after* it has executed all executable statements up to that
+point.
+
+This behavior is slightly different from GNU `bc`, but users will only notice
+the difference if they put `quit` on the same line as other statements.
+
+The first memory bug could be reproduced by assigning a string to a non-local
+variable in a function, then redefining the function with use of the same
+non-local variable, which would still refer to a string in the previous version
+of the function.
+
+The second memory bug was caused by passing an array argument to the `asciify()`
+built-in function. In certain cases, that was wrongly allowed, and the
+interpreter just assumed everything was correct and accessed memory. Now that
+arrays are allowed as arguments (see below), this is not an issue.
+
+The first feature was the addition of the `is_number()` built-in function (`u`
+in `dc`) that returns 1 if the runtime argument is a number and 0 otherwise.
+
+The second feature was the addition of the `is_string()` built-in function (`t`
+in `dc`) that returns 1 if the runtime argument is a string and 0 otherwise.
+
+These features were added because I realized that type-checking is necessary now
+that strings can be assigned to variables in `bc` and because they've always
+been assignable to variables in `dc`.
+
+The last added feature is the ability of the `asciify()` built-in function in
+`bc` to convert a full array of numbers into a string. This means that
+character-by-character printing will not be necessary, and more strings than
+just single-character ones will be able to be created.
+
+## 6.0.4
+
+This is a production release that most users will not need to upgrade to.
+
+This fixes a build bug for `bcl` only on OpenBSD. Users that do not need `bcl`
+or have not run into build errors with `bcl` do ***NOT*** need to upgrade.
+
+## 6.0.3
+
+This is a production release that fixes a build bug for cross-compilation.
+
+Users that do not need cross-compilation do ***NOT*** need to upgrade.
+
+## 6.0.2
+
+This is a production release that fixes two bugs:
+
+* The `-l` option overrode the `-S` option.
+* A double-free and crash when sending a `SIGINT` while executing expressions
+  given on the command-line.
+
+## 6.0.1
+
+This is a production release that fixes memory bugs and memory leaks in `bcl`.
+
+Users that do not use `bcl` (use only `bc` and/or `dc`) do ***NOT*** need to
+upgrade.
+
+These happened because I was unaware that the `bcl` test was not hooked into the
+Valgrind test infrastructure. Then, when I ran the release script, which tests
+everything under Valgrind (or so I thought), it caught nothing, and I thought it
+was safe.
+
+But it was not.
+
+Nevertheless, I have now run it under Valgrind and fixed all of the memory bugs
+(caused by not using `memset()` where I should have but previously didn't have
+to) and memory leaks.
+
+## 6.0.0
+
+This is a production release that fixes an oversight in the `bc` parser (that
+sometimes caused the wrong error message) and adds a feature for compatibility
+with the BSD `bc` and `dc`: turning off digit clamping when parsing numbers.
+
+The default for clamping can be set during the build (see the [build
+manual][13]), it can be set with the `BC_DIGIT_CLAMP` and `DC_DIGIT_CLAMP`
+environment variables, and it can be set with the `-c` and `-C` command-line
+options.
+
+Turning off clamping was also added to the `bcl` library.
+
+In addition, signal handling was removed from the `bcl` library in order to add
+the capability for multi-threading. This required a major version bump. I
+apologize to all library users (I don't know of any), but signals and threads do
+not play well together.
+
+To help with building, a convenience option (`-p`) to `configure.sh` was added
+to build a `bc` and `dc` that is by default compatible with either the BSD `bc`
+and `dc` or the GNU `bc` and `dc`.
+
+## 5.3.3
+
+This is a production release that fixes a build problem in the FreeBSD base
+system.
+
+All other users do **NOT** need to upgrade.
+
+## 5.3.2
+
+This is a production release that fixes prompt bugs with editline and readline
+where the `BC_PROMPT` environment variable was not being respected.
+
+This also fixes editline and readline output on `EOF`.
+
+## 5.3.1
+
+This is a production release that fixes a build problem in the FreeBSD base
+system, as well as a problem in the `en_US` locale. If you don't have problems
+with either, you do not need to upgrade.
+
+## 5.3.0
+
+This is a production release that adds features and has a few bug fixes.
+
+First, support for editline and readline history has been added. To use
+editline, pass `-e` to `configure.sh`, and to use readline, pass `-r`.
+
+Second, history support for Windows has been fixed and re-enabled.
+
+Third, command-line options to set `scale`, `ibase`, `obase`, and `seed` were
+added. This was requested long ago, and I originally disagreed with the idea.
+
+Fourth, the manuals had typos and were missing information. That has been fixed.
+
+Fifth, the manuals received different formatting to be more readable as
+manpages.
+
+## 5.2.5
+
+This is a production release that fixes this `bc`'s behavior on `^D` to match
+GNU `bc`.
+
+## 5.2.4
+
+This is a production release that fixes two bugs in history:
+
+* Without prompt, the cursor could not be placed on the first character in a
+  line.
+* Home and End key handling in `tmux` was fixed.
+
+Any users that do not care about these improvements do not need to upgrade.
+
+## 5.2.3
+
+This is a production release that fixes one bug, a parse error when passing a
+file to `bc` using `-f` if that file had a multiline comment or string in it.
+
 ## 5.2.2
 
 This is a production release that fixes one bug, a segmentation fault if
diff --git a/contrib/bc/NOTICE.md b/contrib/bc/NOTICE.md
index 56d2935ab4b3..c0d3ded5797a 100644
--- a/contrib/bc/NOTICE.md
+++ b/contrib/bc/NOTICE.md
@@ -1,6 +1,6 @@
 # Notice
 
-Copyright 2018-2021 Gavin D. Howard and contributors.
+Copyright 2018-2023 Gavin D. Howard and contributors.
 
 ## Contributors
 
diff --git a/contrib/bc/README.md b/contrib/bc/README.md
index 259ab923bfc4..438cab0d1694 100644
--- a/contrib/bc/README.md
+++ b/contrib/bc/README.md
@@ -1,5 +1,10 @@
 # `bc`
 
+***WARNING: New user registration for https://git.yzena.com/ is disabled because
+of spam. If you need to report a bug with `bc`, email gavin at this site minus
+the `git.` part for an account, and I will create one for you. Or you can report
+an issue at [GitHub][29].***
+
 ***WARNING: This project has moved to [https://git.yzena.com/][20] for [these
 reasons][21], though GitHub will remain a mirror.***
 
@@ -71,8 +76,8 @@ Also, if building with MSBuild, the MSBuild bundled with Visual Studio is
 required.
 
 **Note**: Unlike the POSIX-compatible platforms, only one build configuration is
-supported on Windows: extra math and prompt enabled, history and NLS (locale
-support) disabled, with both calculators built.
+supported on Windows: extra math and history enabled, NLS (locale support)
+disabled, with both calculators built.
 
 #### `bc`
 
@@ -166,8 +171,8 @@ other locations, use the `PREFIX` environment variable when running
 
 #### Library
 
-This `bc` does provide a way to build a math library with C bindings. This is
-done by the `-a` or `--library` options to `configure.sh`:
+To build the math library, pass the `-a` or `--library` options to
+`configure.sh`:
 
 ```
 ./configure.sh -a
@@ -179,9 +184,6 @@ see the [build manual][5].
 The library API can be found in [`manuals/bcl.3.md`][26] or `man bcl` once the
 library is installed.
 
-The library is built as `bin/libbcl.a` on POSIX-compatible systems or as
-`Release/bcl/bcl.lib` on Windows.
-
 #### Package and Distro Maintainers
 
 This section is for package and distro maintainers.
@@ -289,8 +291,7 @@ with POSIX `bc`. The math has been tested with 40+ million random problems, so
 it is as correct as I can make it.
 
 This `bc` can be used as a drop-in replacement for any existing `bc`. This `bc`
-is also compatible with MinGW toolchains, though history is not supported on
-Windows.
+is also compatible with MinGW toolchains.
 
 In addition, this `bc` is considered complete; i.e., there will be no more
 releases with additional features. However, it *is* actively maintained, so if
@@ -317,7 +318,8 @@ may prove useful to any serious users.
 This `bc` compares favorably to GNU `bc`.
 
 * This `bc` builds natively on Windows.
-* It has more extensions, which make this `bc` more useful for scripting.
+* It has more extensions, which make this `bc` more useful for scripting. (See
+  [Extensions](#extensions).)
 * This `bc` is a bit more POSIX compliant.
 * It has a much less buggy parser. The GNU `bc` will give parse errors for what
   is actually valid `bc` code, or should be. For example, putting an `else` on
@@ -340,6 +342,58 @@ There is one instance where this `bc` is slower: if scripts are light on math.
 This is because this `bc`'s intepreter is slightly slower than GNU `bc`, but
 that is because it is more robust. See the [benchmarks][19].
 
+### Extensions
+
+Below is a non-comprehensive list of extensions that this `bc` and `dc` have
+that all others do not.
+
+* An extended math library. (See [here][30] for more information.)
+* A command-line prompt.
+* Turning on and off digit clamping. (Digit clamping is about how to treat
+  "invalid" digits for a particular base. GNU `bc` uses it, and the BSD `bc`
+  does not. Mine does both.)
+* A pseudo-random number generator. This includes the ability to set the seed
+  and get reproducible streams of random numbers.
+* The ability to use stacks for the globals `scale`, `ibase`, and `obase`
+  instead of needing to restore them in *every* function.
+* The ability to *not* use non-standard keywords. For example, `abs` is a
+  keyword (a built-in function), but if some script actually defines a function
+  called that, it's possible to tell my `bc` to not treat it as a keyword, which
+  will make the script parses correctly.
+* The ability to turn on and off printing leading zeroes on numbers greater than
+  `-1` and less than `1`.
+* Outputting in scientific and engineering notation.
+* Accepting input in scientific and engineering notation.
+* Passing strings and arrays to the `length()` built-in function. (In `dc`, the
+  `Y` command will do this for arrays, and the `Z` command will do this for both
+  numbers and strings.)
+* The `abs()` built-in function. (This is the `b` command in `dc`.)
+* The `is_number()` and `is_string()` built-in functions. (These tell whether a
+  variable is holding a string or a number, for runtime type checking. The
+  commands are `u` and `t` in `dc`.)
+* For `bc` only, the `divmod()` built-in function for computing a quotient and
+  remainder at the same time.
+* For `bc` only, the `asciify()` built-in function for converting an array to a
+  string.
+* The `$` truncation operator. (It's the same in `bc` and `dc`.)
+* The `@` "set scale" operator. (It's the same in `bc` and `dc`.)
+* The decimal shift operators. (`<<` and `>>` in `bc`, `H` and `h` in `dc`.)
+* Built-in functions or commands to get the max of `scale`, `ibase`, and
+  `obase`.
+* The ability to put strings into variables in `bc`. (This always existed in
+  `dc`.)
+* The `'` command in `dc` for the depth of the execution stack.
+* The `y` command in `dc` for the depth of register stacks.
+* Built-in functions or commands to get the value of certain environment
+  variables that might affect execution.
+* The `stream` keyword to do the same thing as the `P` command in `dc`.
+* Defined order of evaluation.
+* Defined exit statuses.
+* All environment variables other than `POSIXLY_CORRECT`, `BC_ENV_ARGS`, and
+  `BC_LINE_LENGTH`.
+* The ability for users to define their own defaults for various options during
+  build. (See [here][31] for more information.)
+
 ## Algorithms
 
 To see what algorithms this `bc` uses, see the [algorithms manual][7].
@@ -405,18 +459,18 @@ Files:
 	Makefile.in          The Makefile template.
 	NEWS.md              The changelog.
 	NOTICE.md            List of contributors and copyright owners.
-	RELEASE.md           A checklist for making a release (maintainer use only).
 
 Folders:
 
-	gen      The bc math library, help texts, and code to generate C source.
-	include  All header files.
-	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.
-	vs       Files needed for the build on Windows.
+	benchmarks  A folder of benchmarks for various aspects of bc performance.
+	gen         The bc math library, help texts, and code to generate C source.
+	include     All header files.
+	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.
+	vs          Files needed for the build on Windows.
 
 [1]: https://www.gnu.org/software/bc/
 [4]: ./LICENSE.md
@@ -439,3 +493,6 @@ Folders:
 [26]: ./manuals/bcl.3.md
 [27]: https://en.wikipedia.org/wiki/Bus_factor
 [28]: ./manuals/development.md
+[29]: https://github.com/gavinhoward/bc
+[30]: ./manuals/bc/A.1.md#extended-library
+[31]: ./manuals/build.md#settings
diff --git a/contrib/bc/configure.sh b/contrib/bc/configure.sh
index fc66ffc51066..3ada5298e9ed 100755
--- a/contrib/bc/configure.sh
+++ b/contrib/bc/configure.sh
@@ -2,7 +2,7 @@
 #
 # SPDX-License-Identifier: BSD-2-Clause
 #
-# Copyright (c) 2018-2021 Gavin D. Howard and contributors.
+# Copyright (c) 2018-2023 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:
@@ -43,7 +43,7 @@ usage() {
 
 		_usage_val=1
 
-		printf "%s\n\n" "$1"
+		printf '%s\n\n' "$1"
 
 	else
 		_usage_val=0
@@ -52,17 +52,25 @@ usage() {
 	printf 'usage:\n'
 	printf '    %s -h\n' "$script"
 	printf '    %s --help\n' "$script"
-	printf '    %s [-a|-bD|-dB|-c] [-CEfgGHlmMNtTvz] [-O OPT_LEVEL] [-k KARATSUBA_LEN]\\\n' "$script"
-	printf '       [-s SETTING] [-S SETTING]\n'
+	printf '    %s [-a|-bD|-dB|-c] [-CeEfgGHilmMNPrtTvz] [-O OPT_LEVEL] [-k KARATSUBA_LEN]\\\n' "$script"
+	printf '       [-s SETTING] [-S SETTING] [-p TYPE]\n'
 	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 --disable-strip] \\\n'
-	printf '       [--install-all-locales] [--opt=OPT_LEVEL]                             \\\n'
-	printf '       [--karatsuba-len=KARATSUBA_LEN]                                       \\\n'
+	printf '       [--enable-editline] [--enable-readline] [--enable-internal-history]   \\\n'
+	printf '       [--disable-problematic-tests] [--install-all-locales]                 \\\n'
+	printf '       [--opt=OPT_LEVEL] [--karatsuba-len=KARATSUBA_LEN]                     \\\n'
 	printf '       [--set-default-on=SETTING] [--set-default-off=SETTING]                \\\n'
*** 51905 LINES SKIPPED ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202302071635.317GZ4q6017870>