git: 78bc019d220e - main - usr.bin/bc: update to version 5.3.1

From: Stefan Eßer <se_at_FreeBSD.org>
Date: Sat, 11 Jun 2022 11:15:31 UTC
The branch main has been updated by se:

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

commit 78bc019d220e05abb5b12f678f9b4a847019bbcc
Merge: 36447829aee5 bd54318046bf
Author:     Stefan Eßer <se@FreeBSD.org>
AuthorDate: 2022-06-11 11:03:06 +0000
Commit:     Stefan Eßer <se@FreeBSD.org>
CommitDate: 2022-06-11 11:14:37 +0000

    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'
    
    PR:             264010
    
    MFC after:      2 weeks

 contrib/bc/Makefile.in          |   15 +-
 contrib/bc/NEWS.md              |   23 +
 contrib/bc/README.md            |   34 +-
 contrib/bc/configure.sh         |   87 ++-
 contrib/bc/gen/bc_help.txt      |   26 +
 contrib/bc/gen/dc_help.txt      |   26 +
 contrib/bc/gen/strgen.c         |  308 ++++++++--
 contrib/bc/gen/strgen.sh        |   31 +-
 contrib/bc/include/args.h       |    4 +-
 contrib/bc/include/bc.h         |   65 ++-
 contrib/bc/include/bcl.h        |  258 ++++++---
 contrib/bc/include/dc.h         |   15 +-
 contrib/bc/include/file.h       |   80 ++-
 contrib/bc/include/history.h    |  177 ++++--
 contrib/bc/include/lang.h       |   95 ++--
 contrib/bc/include/lex.h        |   49 +-
 contrib/bc/include/library.h    |  104 ++--
 contrib/bc/include/num.h        |  161 ++++--
 contrib/bc/include/opt.h        |   24 +-
 contrib/bc/include/parse.h      |   47 +-
 contrib/bc/include/program.h    | 1065 ++++++++++++++++++-----------------
 contrib/bc/include/rand.h       |   48 +-
 contrib/bc/include/read.h       |   12 +-
 contrib/bc/include/status.h     |  113 ++--
 contrib/bc/include/vector.h     |  106 ++--
 contrib/bc/include/version.h    |    2 +-
 contrib/bc/include/vm.h         |  155 +++--
 contrib/bc/locales/en_US.msg    |    4 +-
 contrib/bc/manuals/bc/A.1       |  128 +++--
 contrib/bc/manuals/bc/A.1.md    |  141 +++--
 contrib/bc/manuals/bc/E.1       |  100 +++-
 contrib/bc/manuals/bc/E.1.md    |  121 ++--
 contrib/bc/manuals/bc/EH.1      |  100 +++-
 contrib/bc/manuals/bc/EH.1.md   |  121 ++--
 contrib/bc/manuals/bc/EHN.1     |  100 +++-
 contrib/bc/manuals/bc/EHN.1.md  |  121 ++--
 contrib/bc/manuals/bc/EN.1      |  100 +++-
 contrib/bc/manuals/bc/EN.1.md   |  121 ++--
 contrib/bc/manuals/bc/H.1       |  128 +++--
 contrib/bc/manuals/bc/H.1.md    |  141 +++--
 contrib/bc/manuals/bc/HN.1      |  128 +++--
 contrib/bc/manuals/bc/HN.1.md   |  141 +++--
 contrib/bc/manuals/bc/N.1       |  128 +++--
 contrib/bc/manuals/bc/N.1.md    |  141 +++--
 contrib/bc/manuals/bcl.3        |   16 +-
 contrib/bc/manuals/bcl.3.md     |   10 +-
 contrib/bc/manuals/build.md     |   39 +-
 contrib/bc/manuals/dc/A.1       |   77 ++-
 contrib/bc/manuals/dc/A.1.md    |   59 +-
 contrib/bc/manuals/dc/E.1       |   60 +-
 contrib/bc/manuals/dc/E.1.md    |   48 +-
 contrib/bc/manuals/dc/EH.1      |   60 +-
 contrib/bc/manuals/dc/EH.1.md   |   48 +-
 contrib/bc/manuals/dc/EHN.1     |   60 +-
 contrib/bc/manuals/dc/EHN.1.md  |   48 +-
 contrib/bc/manuals/dc/EN.1      |   60 +-
 contrib/bc/manuals/dc/EN.1.md   |   48 +-
 contrib/bc/manuals/dc/H.1       |   77 ++-
 contrib/bc/manuals/dc/H.1.md    |   59 +-
 contrib/bc/manuals/dc/HN.1      |   77 ++-
 contrib/bc/manuals/dc/HN.1.md   |   59 +-
 contrib/bc/manuals/dc/N.1       |   77 ++-
 contrib/bc/manuals/dc/N.1.md    |   59 +-
 contrib/bc/scripts/format.sh    |   49 ++
 contrib/bc/scripts/functions.sh |   94 ++++
 contrib/bc/scripts/lint.sh      |   63 +++
 contrib/bc/src/args.c           |  157 +++++-
 contrib/bc/src/bc.c             |    5 +-
 contrib/bc/src/bc_lex.c         |   90 +--
 contrib/bc/src/bc_parse.c       |  692 ++++++++++++++---------
 contrib/bc/src/data.c           |  870 ++++++++++++++--------------
 contrib/bc/src/dc.c             |    5 +-
 contrib/bc/src/dc_lex.c         |   70 ++-
 contrib/bc/src/dc_parse.c       |   66 ++-
 contrib/bc/src/file.c           |  214 +++++--
 contrib/bc/src/history.c        |  816 +++++++++++++++++++--------
 contrib/bc/src/lang.c           |  124 ++--
 contrib/bc/src/lex.c            |  145 +++--
 contrib/bc/src/library.c        |  387 ++++++++-----
 contrib/bc/src/main.c           |   11 +-
 contrib/bc/src/num.c            | 1188 +++++++++++++++++++++++++--------------
 contrib/bc/src/opt.c            |  141 +++--
 contrib/bc/src/parse.c          |   85 +--
 contrib/bc/src/program.c        | 1108 +++++++++++++++++++++++-------------
 contrib/bc/src/rand.c           |  196 ++++---
 contrib/bc/src/read.c           |   85 ++-
 contrib/bc/src/vector.c         |  248 +++++---
 contrib/bc/src/vm.c             |  548 +++++++++++-------
 contrib/bc/tests/bcl.c          |   69 +--
 contrib/bc/tests/history.py     |   10 +-
 contrib/bc/tests/other.sh       |   58 +-
 contrib/bc/vs/bc.vcxproj        |   41 +-
 usr.bin/gh-bc/Makefile          |   11 +-
 93 files changed, 9129 insertions(+), 4652 deletions(-)

diff --cc contrib/bc/README.md
index 259ab923bfc4,000000000000..64c58410162c
mode 100644,000000..100644
--- a/contrib/bc/README.md
+++ b/contrib/bc/README.md
@@@ -1,441 -1,0 +1,443 @@@
 +# `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.***
 +
 +This is an implementation of the [POSIX `bc` calculator][12] that implements
 +[GNU `bc`][1] extensions, as well as the period (`.`) extension for the BSD
 +flavor of `bc`.
 +
 +For more information, see this `bc`'s full manual.
 +
 +This `bc` also includes an implementation of `dc` in the same binary, accessible
 +via a symbolic link, which implements all FreeBSD and GNU extensions. (If a
 +standalone `dc` binary is desired, `bc` can be copied and renamed to `dc`.) The
 +`!` command is omitted; I believe this poses security concerns and that such
 +functionality is unnecessary.
 +
 +For more information, see the `dc`'s full manual.
 +
 +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.
 +
 +## Prerequisites
 +
 +This `bc` only requires either:
 +
 +1.	Windows 10 or later, or
 +2.	A C99-compatible compiler and a (mostly) POSIX 2008-compatible system with
 +	the XSI (X/Open System Interfaces) option group.
 +
 +Since POSIX 2008 with XSI requires the existence of a C99 compiler as `c99`, any
 +POSIX and XSI-compatible system will have everything needed.
 +
 +POSIX-compatible systems that are known to work:
 +
 +* Linux
 +* FreeBSD
 +* OpenBSD
 +* NetBSD
 +* Mac OSX
 +* Solaris* (as long as the Solaris version supports POSIX 2008)
 +* AIX
 +* HP-UX* (except for history)
 +
 +In addition, there is compatibility code to make this `bc` work on Windows.
 +
 +Please submit bug reports if this `bc` does not build out of the box on any
 +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
 +than Windows 10 (I cannot test on earlier versions), but it is guaranteed to
 +work on Windows 10 at least.
 +
 +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`
 +
 +To build `bc`, you can open the `vs/bc.sln` file in Visual Studio, select the
 +configuration, and build.
 +
 +You can also build using MSBuild with the following from the root directory:
 +
 +```
 +msbuild -property:Configuration=<config> vs/bc.sln
 +```
 +
 +where `<config>` is either one of `Debug` or `Release`.
 +
 +On Windows, the calculators are built as `vs/bin/<platform>/<config>/bc.exe` and
 +`vs/bin/<Platform>/<Config>/dc.exe`, where `<platform>` can be either `Win32` or
 +`x64`, and `<config>` can be `Debug` or `Release`.
 +
 +**Note**: On Windows, `dc.exe` is just copied from `bc.exe`; it is not linked.
 +Patches are welcome for a way to do that.
 +
 +#### `bcl` (Library)
 +
 +To build the library, you can open the `vs/bcl.sln` file in Visual Studio,
 +select the configuration, and build.
 +
 +You can also build using MSBuild with the following from the root directory:
 +
 +```
 +msbuild -property:Configuration=<config> vs/bcl.sln
 +```
 +
 +where `<config>` is either one of `Debug`, `ReleaseMD`, or `ReleaseMT`.
 +
 +On Windows, the library is built as `vs/lib/<platform>/<config>/bcl.lib`, where
 +`<platform>` can be either `Win32` or `x64`, and `<config>` can be `Debug`,
 +`ReleaseMD`, or `ReleaseMT`.
 +
 +### POSIX-Compatible Systems
 +
 +On POSIX-compatible systems, `bc` is built as `bin/bc` and `dc` is built as
 +`bin/dc` by default.
 +
 +#### Default
 +
 +For the default build with optimization, use the following commands in the root
 +directory:
 +
 +```
 +./configure.sh -O3
 +make
 +```
 +
 +#### One Calculator
 +
 +To only build `bc`, use the following commands:
 +
 +```
 +./configure.sh --disable-dc
 +make
 +```
 +
 +To only build `dc`, use the following commands:
 +
 +```
 +./configure.sh --disable-bc
 +make
 +```
 +
 +#### Debug
 +
 +For debug builds, use the following commands in the root directory:
 +
 +```
 +./configure.sh -g
 +make
 +```
 +
 +#### Install
 +
 +To install, use the following command:
 +
 +```
 +make install
 +```
 +
 +By default, `bc` and `dc` will be installed in `/usr/local`. For installing in
 +other locations, use the `PREFIX` environment variable when running
 +`configure.sh` or pass the `--prefix=<prefix>` option to `configure.sh`. See the
 +[build manual][5], or run `./configure.sh --help`, for more details.
 +
 +#### 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`:
 +
 +```
 +./configure.sh -a
 +```
 +
 +When building the library, the executables are not built. For more information,
 +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.
 +
 +##### Out-of-Source Builds
 +
 +Out-of-source builds are supported; just call `configure.sh` from the directory
 +where the actual build will happen.
 +
 +For example, if the source is in `bc`, the build should happen in `build`, then
 +call `configure.sh` and `make` like so:
 +
 +```
 +../bc/configure.sh
 +make
 +```
 +
 +***WARNING***: The path to `configure.sh` from the build directory must not have
 +spaces because `make` does not support target names with spaces.
 +
 +##### Recommended Compiler
 +
 +When I ran benchmarks with my `bc` compiled under `clang`, it performed much
 +better than when compiled under `gcc`. I recommend compiling this `bc` with
 +`clang`.
 +
 +I also recommend building this `bc` with C11 if you can because `bc` will detect
 +a C11 compiler and add `_Noreturn` to any relevant function(s).
 +
 +##### Recommended Optimizations
 +
 +I wrote this `bc` with Separation of Concerns, which means that there are many
 +small functions that could be inlined. However, they are often called across
 +file boundaries, and the default optimizer can only look at the current file,
 +which means that they are not inlined.
 +
 +Thus, because of the way this `bc` is built, it will automatically be slower
 +than other `bc` implementations when running scripts with no math. (My `bc`'s
 +math is *much* faster, so any non-trivial script should run faster in my `bc`.)
 +
 +Some, or all, of the difference can be made up with the right optimizations. The
 +optimizations I recommend are:
 +
 +1.	`-O3`
 +2.	`-flto` (link-time optimization)
 +
 +in that order.
 +
 +Link-time optimization, in particular, speeds up the `bc` a lot. This is because
 +when link-time optimization is turned on, the optimizer can look across files
 +and inline *much* more heavily.
 +
 +However, I recommend ***NOT*** using `-march=native`. Doing so will reduce this
 +`bc`'s performance, at least when building with link-time optimization. See the
 +[benchmarks][19] for more details.
 +
 +##### Stripping Binaries
 +
 +By default, non-debug binaries are stripped, but stripping can be disabled with
 +the `-T` option to `configure.sh`.
 +
 +##### Using This `bc` as an Alternative
 +
 +If this `bc` is packaged as an alternative to an already existing `bc` package,
 +it is possible to rename it in the build to prevent name collision. To prepend
 +to the name, just run the following:
 +
 +```
 +EXECPREFIX=<some_prefix> ./configure.sh
 +```
 +
 +To append to the name, just run the following:
 +
 +```
 +EXECSUFFIX=<some_suffix> ./configure.sh
 +```
 +
 +If a package maintainer wishes to add both a prefix and a suffix, that is
 +allowed.
 +
 +**Note**: The suggested name (and package name) when `bc` is not available is
 +`bc-gh`.
 +
 +##### Karatsuba Number
 +
 +Package and distro maintainers have one tool at their disposal to build this
 +`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
 +optimal Karatsuba number (see the [algorithms manual][7] for more information)
 +for the machine that it is running on.
 +
 +The easiest way to run this script is with `make karatsuba`.
 +
 +If desired, maintainers can also skip running this script because there is a
 +sane default for the Karatsuba number.
 +
 +## Status
 +
 +This `bc` is robust.
 +
 +It is well-tested, fuzzed, and fully standards-compliant (though not certified)
 +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
 +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`.
 +
 +* This `bc` builds natively on Windows.
 +* It has more extensions, which make this `bc` more useful for scripting.
 +* 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
 +  a new line after a brace can cause GNU `bc` to give a parse error.
 +* This `bc` has fewer crashes.
 +* GNU `bc` calculates the wrong number of significant digits for `length(x)`.
 +* GNU `bc` will sometimes print numbers incorrectly. For example, when running
 +  it on the file `tests/bc/power.txt` in this repo, GNU `bc` gets all the right
 +  answers, but it fails to wrap the numbers at the proper place when outputting
 +  to a file.
 +* This `bc` is faster. (See [Performance](#performance).)
 +
 +### Performance
 +
 +Because this `bc` packs more than `1` decimal digit per hardware integer, this
 +`bc` is faster than GNU `bc` and can be *much* faster. Full benchmarks can be
 +found at [manuals/benchmarks.md][19].
 +
 +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].
 +
 +## Algorithms
 +
 +To see what algorithms this `bc` uses, see the [algorithms manual][7].
 +
 +## Locales
 +
 +Currently, there is no locale support on Windows.
 +
 +Additionally, this `bc` only has support for English (and US English), French,
 +German, Portuguese, Dutch, Polish, Russian, Japanese, and Chinese locales.
 +Patches are welcome for translations; use the existing `*.msg` files in
 +`locales/` as a starting point.
 +
 +In addition, patches for improvements are welcome; the last two messages in
 +Portuguese were made with Google Translate, and the Dutch, Polish, Russian,
 +Japanese, and Chinese locales were all generated with [DeepL][22].
 +
 +The message files provided assume that locales apply to all regions where a
 +language is used, but this might not be true for, e.g., `fr_CA` and `fr_CH`.
 +Any corrections or a confirmation that the current texts are acceptable for
 +those regions would be appreciated, too.
 +
 +## Other Projects
 +
 +Other projects based on this bc are:
 +
 +* [busybox `bc`][8]. The busybox maintainers have made their own changes, so any
 +  bugs in the busybox `bc` should be reported to them.
 +
 +* [toybox `bc`][9]. The maintainer has also made his own changes, so bugs in the
 +  toybox `bc` should be reported there.
 +
 +* [FreeBSD `bc`][23]. While the `bc` in FreeBSD is kept up-to-date, it is better
 +  to [report bugs there][24], as well as [submit patches][25], and the
 +  maintainers of the package will contact me if necessary.
 +
 +## Language
 +
 +This `bc` is written in pure ISO C99, using POSIX 2008 APIs with custom Windows
 +compatibility code.
 +
 +## Commit Messages
 +
 +This `bc` uses the commit message guidelines laid out in [this blog post][10].
 +
 +## Semantic Versioning
 +
 +This `bc` uses [semantic versioning][11].
 +
 +## Contents
 +
 +Items labeled with `(maintainer use only)` are not included in release source
 +tarballs.
 +
 +Files:
 +
 +	.gitignore           The git ignore file (maintainer use only).
 +	.gitattributes       The git attributes file (maintainer use only).
 +	bcl.pc.in            A template pkg-config file for bcl.
 +	configure            A symlink to configure.sh to make packaging easier.
 +	configure.sh         The configure script.
 +	LICENSE.md           A Markdown form of the BSD 2-clause License.
 +	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
 +[5]: ./manuals/build.md
 +[7]: ./manuals/algorithms.md
 +[8]: https://git.busybox.net/busybox/tree/miscutils/bc.c
 +[9]: https://github.com/landley/toybox/blob/master/toys/pending/bc.c
 +[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://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/
 +[22]: https://www.deepl.com/translator
 +[23]: https://cgit.freebsd.org/src/tree/contrib/bc
 +[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
++[29]: https://github.com/gavinhoward/bc
diff --cc contrib/bc/scripts/format.sh
index 000000000000,3e399da5777c..3e399da5777c
mode 000000,100755..100755
--- a/contrib/bc/scripts/format.sh
+++ b/contrib/bc/scripts/format.sh
diff --cc contrib/bc/scripts/lint.sh
index 000000000000,65f81c5f6511..65f81c5f6511
mode 000000,100755..100755
--- a/contrib/bc/scripts/lint.sh
+++ b/contrib/bc/scripts/lint.sh
diff --cc usr.bin/gh-bc/Makefile
index 213559478b88,000000000000..bb44480b631c
mode 100644,000000..100644
--- a/usr.bin/gh-bc/Makefile
+++ b/usr.bin/gh-bc/Makefile
@@@ -1,124 -1,0 +1,127 @@@
 +# $FreeBSD$
 +
 +.include <src.opts.mk>
 +
 +PROG=		gh-bc
 +PROGNAME=	bc
 +
 +BCDIR=		${SRCTOP}/contrib/${PROGNAME}
 +
 +SRCS=		args.c bc.c bc_lex.c bc_parse.c data.c dc.c dc_lex.c dc_parse.c file.c history.c
 +SRCS+=		lang.c lex.c main.c num.c opt.c parse.c program.c rand.c read.c vector.c  vm.c
 +SRCS+=		bc_help.c dc_help.c lib.c lib2.c
 +
++LIBADD=		edit
++
 +MAN=		bc.1 dc.1
 +
 +LINKS=		${BINDIR}/bc ${BINDIR}/dc
 +
 +.PATH:		${BCDIR}/src ${BCDIR}/gen ${BCDIR}/manuals ${.OBJDIR}
 +
 +CATALOGS=	en_US.UTF-8
 +CATALOGS+=	de_DE.UTF-8 de_DE.ISO8859-1
 +CATALOGS+=	es_ES.UTF-8 es_ES.ISO8859-1
 +CATALOGS+=	fr_FR.UTF-8 fr_FR.ISO8859-1
 +CATALOGS+=	ja_JP.UTF-8 ja_JP.eucJP
 +CATALOGS+=	nl_NL.UTF-8 nl_NL.ISO8859-1
 +CATALOGS+=	pl_PL.UTF-8 pl_PL.ISO8859-2
 +CATALOGS+=	pt_PT.UTF-8 pt_PT.ISO8859-1
 +CATALOGS+=	ru_RU.UTF-8 ru_RU.ISO8859-5 ru_RU.CP1251 ru_RU.CP866 ru_RU.KOI8-R
 +CATALOGS+=	zh_CN.UTF-8 zh_CN.eucCN zh_CN.GB18030 zh_CN.GB2312 zh_CN.GBK
 +
 +NLSNAME=	bc
 +NLSSRCDIR=	${BCDIR}/locales
 +
 +CFLAGS+=	-DMAINEXEC=${PROGNAME}
 +CFLAGS+=	-DNLSPATH=/usr/share/nls/%L/%N.cat
 +CFLAGS+=	-DBUILD_TYPE=A
 +CFLAGS+=	-DBC_DEFAULT_BANNER=0
 +CFLAGS+=	-DBC_DEFAULT_PROMPT=0
 +CFLAGS+=	-DBC_DEFAULT_SIGINT_RESET
 +CFLAGS+=	-DBC_DEFAULT_TTY_MODE
 +CFLAGS+=	-DBC_ENABLED
++CFLAGS+=	-DBC_ENABLE_EDITLINE
 +CFLAGS+=	-DBC_ENABLE_EXTRA_MATH
 +CFLAGS+=	-DBC_ENABLE_LIBRARY=0
 +CFLAGS+=	-DBC_ENABLE_LONG_OPTIONS
 +CFLAGS+=	-DBC_ENABLE_HISTORY
 +CFLAGS+=	-DBC_ENABLE_PROMPT
 +CFLAGS+=	-DBC_ENABLE_RAND
 +CFLAGS+=	-DDC_DEFAULT_PROMPT=0
 +CFLAGS+=	-DDC_DEFAULT_SIGINT_RESET
 +CFLAGS+=	-DDC_DEFAULT_TTY_MODE=0
 +CFLAGS+=	-DDC_ENABLED
 +CFLAGS+=	-DNDEBUG
 +CFLAGS+=	-I${BCDIR}/include
 +
 +.if ${MK_NLS_CATALOGS} == "no"
 +CFLAGS+=	-DBC_ENABLE_NLS=0
 +MAN_SRC_BC=	bc/N.1
 +MAN_SRC_DC=	dc/N.1
 +.else
 +CFLAGS+=	-DBC_ENABLE_NLS=1
 +MAN_SRC_BC=	bc/A.1
 +MAN_SRC_DC=	dc/A.1
 +
 +# prevent floating point incompatibilities caused by -flto on some architectures
 +.if ${MACHINE_ARCH:Mmips*} == "" && ${MACHINE_ARCH} != powerpc64 && \
 +	${MACHINE_ARCH} != riscv64
 +CFLAGS+=	-flto
 +.endif
 +
 +HAS_TESTS=
 +SUBDIR.${MK_TESTS}+= tests
 +
 +.for catalog in ${CATALOGS}
 +NLS+=           ${catalog:C/.*://}
 +NLSSRCFILES_${catalog:C/.*://}= ${catalog:C/.*://}.msg
 +.endfor
 +
 +NLSLINKS_en_US.UTF-8+=	en_AU.UTF-8 en_CA.UTF-8 en_GB.UTF-8 en_IE.UTF-8 \
 +			en_NZ.UTF-8 C
 +NLSLINKS_en_US.UTF-8+=	en_AU.US-ASCII en_CA.US-ASCII en_GB.US-ASCII \
 +			en_NZ.US-ASCII
 +NLSLINKS_en_US.UTF-8+=	en_AU.ISO8859-1 en_CA.ISO8859-1 en_GB.ISO8859-1 \
 +			en_NZ.ISO8859-1 en_US.ISO8859-1
 +NLSLINKS_en_US.UTF-8+=	en_AU.ISO8859-15 en_CA.ISO8859-15 en_GB.ISO8859-15 \
 +			en_NZ.ISO8859-15 en_US.ISO8859-15
 +
 +NLSLINKS_de_DE.UTF-8+=	de_AT.UTF-8 de_CH.UTF-8
 +NLSLINKS_de_DE.ISO8859-1+= de_AT.ISO8859-1 de_CH.ISO8859-1
 +NLSLINKS_de_DE.ISO8859-1+= de_AT.ISO8859-15 de_CH.ISO8859-15 de_DE.ISO8859-15
 +
 +NLSLINKS_es_ES.ISO8859-1+= es_ES.ISO8859-15
 +
 +NLSLINKS_fr_FR.UTF-8+=	fr_BE.UTF-8 fr_CA.UTF-8 fr_CH.UTF-8
 +NLSLINKS_fr_FR.ISO8859-1+= fr_BE.ISO8859-1 fr_CA.ISO8859-1 fr_CH.ISO8859-1
 +NLSLINKS_fr_FR.ISO8859-1+= fr_BE.ISO8859-15 fr_CA.ISO8859-15 fr_CH.ISO8859-15 \
 +			fr_FR.ISO8859-15
 +
 +NLSLINKS_nl_NL.ISO8859-1+= nl_BE.ISO8859-1
 +NLSLINKS_nl_NL.ISO8859-1+= nl_BE.ISO8859-15 nl_NL.ISO8859-15
 +
 +NLSLINKS_pt_PT.UTF-8+=	pt_BR.UTF-8
 +NLSLINKS_pt_PT.ISO8859-1+= pt_BR.ISO8859-1
 +NLSLINKS_pt_PT.ISO8859-1+= pt_PT.ISO8859-15
 +.endif
 +
 +lib.c:		lib.bc Makefile
- 		cd ${BCDIR} && sh gen/strgen.sh gen/lib.bc ${.OBJDIR}/lib.c bc_lib bc_lib_name 1 1
++		cd ${BCDIR} && sh gen/strgen.sh gen/lib.bc ${.OBJDIR}/lib.c 0 bc_lib bc_lib_name 1 1
 +
 +lib2.c:		lib2.bc Makefile
- 		cd ${BCDIR} && sh gen/strgen.sh gen/lib2.bc ${.OBJDIR}/lib2.c bc_lib2 bc_lib2_name 1 1
++		cd ${BCDIR} && sh gen/strgen.sh gen/lib2.bc ${.OBJDIR}/lib2.c 0 bc_lib2 bc_lib2_name 1 1
 +
 +bc_help.c:	bc_help.txt Makefile
- 		cd ${BCDIR} && sh gen/strgen.sh gen/bc_help.txt ${.OBJDIR}/bc_help.c bc_help
++		cd ${BCDIR} && sh gen/strgen.sh gen/bc_help.txt ${.OBJDIR}/bc_help.c 0 bc_help
 +
 +dc_help.c:	dc_help.txt Makefile
- 		cd ${BCDIR} && sh gen/strgen.sh gen/dc_help.txt ${.OBJDIR}/dc_help.c dc_help
++		cd ${BCDIR} && sh gen/strgen.sh gen/dc_help.txt ${.OBJDIR}/dc_help.c 0 dc_help
 +
 +bc.1:
 +		${CP} ${BCDIR}/manuals/${MAN_SRC_BC} ${.OBJDIR}/bc.1
 +
 +dc.1:
 +		${CP} ${BCDIR}/manuals/${MAN_SRC_DC} ${.OBJDIR}/dc.1
 +
 +.include <bsd.prog.mk>