These bc and dc programs offer a number of advantages compared to the current version in base:
- Does not depend on external large number functions (i.e. no dependency on OpenSSL or any large number library)
- Implements all features found in GNU bc/dc (with the exception of a function that is considered a security issue) but is BSD licensed
- Is significantly faster than the current code in base (by a factor of 5 in a few large number tests that I have performed)
- Should be fully compatible with all features and the behavior of the current FreeBSD version (not formally verified)
- Supports POSIX message catalogs and comes with localized messages in French and German (more to be expected, this is a recently added feature)
- It comes with a very detailed man-page that provides far more information than the current one
While there is no reason to replace the current code in base from a license point of view, the advantages offered by this version seem significant enough to support this change.
The programs to be imported in base are already available as a port (math/gh-bc) for easy testing.
The attached diff contains an import of the relevant files from upstream version 1.2.7 into contrib/bc, with FreeBSD build infrastructure in usr.bin/gh_bc. There are extensive regression tests that are run by the upstream before each new release is tagged. These tests could be imported into base, but are not included in this review. (They are available in the port.)
This code will only replace the standard versions in base if the world is built and installed with "MK_GH_BC=yes".