Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
# `bc`
|
|
|
|
|
2022-06-11 11:03:06 +00:00
|
|
|
***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].***
|
|
|
|
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
***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`.
|
|
|
|
|
2020-07-07 07:51:09 +00:00
|
|
|
For more information, see this `bc`'s full manual.
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2020-07-07 07:51:09 +00:00
|
|
|
For more information, see the `dc`'s full manual.
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
|
2021-04-25 06:42:31 +00:00
|
|
|
This `bc` also provides `bc`'s math as a library with C bindings, called `bcl`.
|
|
|
|
|
|
|
|
For more information, see the full manual for `bcl`.
|
|
|
|
|
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
2021-08-10 08:42:54 +00:00
|
|
|
## License
|
|
|
|
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
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
|
|
|
|
|
2021-04-06 08:48:09 +00:00
|
|
|
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.
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
|
|
|
|
Since POSIX 2008 with XSI requires the existence of a C99 compiler as `c99`, any
|
|
|
|
POSIX and XSI-compatible system will have everything needed.
|
|
|
|
|
2021-04-06 08:48:09 +00:00
|
|
|
POSIX-compatible systems that are known to work:
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
|
|
|
|
* Linux
|
|
|
|
* FreeBSD
|
|
|
|
* OpenBSD
|
|
|
|
* NetBSD
|
|
|
|
* Mac OSX
|
2020-07-07 07:51:09 +00:00
|
|
|
* Solaris* (as long as the Solaris version supports POSIX 2008)
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
* AIX
|
2021-01-31 20:07:42 +00:00
|
|
|
* HP-UX* (except for history)
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
|
2021-04-06 08:48:09 +00:00
|
|
|
In addition, there is compatibility code to make this `bc` work on Windows.
|
|
|
|
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
Please submit bug reports if this `bc` does not build out of the box on any
|
2021-04-06 08:48:09 +00:00
|
|
|
system.
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
|
|
|
|
## Build
|
|
|
|
|
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
2021-08-10 08:42:54 +00:00
|
|
|
This `bc` should build unmodified on any POSIX-compliant system or on Windows
|
|
|
|
starting with Windows 10 (though earlier versions may work).
|
|
|
|
|
2021-11-30 17:40:32 +00:00
|
|
|
For more complex build requirements than the ones below, see the [build
|
|
|
|
manual][5].
|
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
2021-08-10 08:42:54 +00:00
|
|
|
|
2021-04-06 08:48:09 +00:00
|
|
|
### 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
|
2022-06-11 11:03:06 +00:00
|
|
|
supported on Windows: extra math and history enabled, NLS (locale support)
|
|
|
|
disabled, with both calculators built.
|
2021-04-06 08:48:09 +00:00
|
|
|
|
|
|
|
#### `bc`
|
|
|
|
|
2021-11-30 17:40:32 +00:00
|
|
|
To build `bc`, you can open the `vs/bc.sln` file in Visual Studio, select the
|
2021-04-06 08:48:09 +00:00
|
|
|
configuration, and build.
|
|
|
|
|
|
|
|
You can also build using MSBuild with the following from the root directory:
|
|
|
|
|
|
|
|
```
|
2021-11-30 17:40:32 +00:00
|
|
|
msbuild -property:Configuration=<config> vs/bc.sln
|
2021-04-06 08:48:09 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
where `<config>` is either one of `Debug` or `Release`.
|
|
|
|
|
2021-11-30 17:40:32 +00:00
|
|
|
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.
|
|
|
|
|
2021-04-06 08:48:09 +00:00
|
|
|
#### `bcl` (Library)
|
|
|
|
|
2021-11-30 17:40:32 +00:00
|
|
|
To build the library, you can open the `vs/bcl.sln` file in Visual Studio,
|
|
|
|
select the configuration, and build.
|
2021-04-06 08:48:09 +00:00
|
|
|
|
|
|
|
You can also build using MSBuild with the following from the root directory:
|
|
|
|
|
|
|
|
```
|
2021-11-30 17:40:32 +00:00
|
|
|
msbuild -property:Configuration=<config> vs/bcl.sln
|
2021-04-06 08:48:09 +00:00
|
|
|
```
|
|
|
|
|
2021-11-30 17:40:32 +00:00
|
|
|
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`.
|
2021-04-06 08:48:09 +00:00
|
|
|
|
|
|
|
### POSIX-Compatible Systems
|
|
|
|
|
|
|
|
On POSIX-compatible systems, `bc` is built as `bin/bc` and `dc` is built as
|
2021-11-30 17:40:32 +00:00
|
|
|
`bin/dc` by default.
|
2021-04-06 08:48:09 +00:00
|
|
|
|
|
|
|
#### Default
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
|
|
|
|
For the default build with optimization, use the following commands in the root
|
|
|
|
directory:
|
|
|
|
|
|
|
|
```
|
|
|
|
./configure.sh -O3
|
|
|
|
make
|
|
|
|
```
|
|
|
|
|
2021-04-06 08:48:09 +00:00
|
|
|
#### One Calculator
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
```
|
|
|
|
|
2021-04-06 08:48:09 +00:00
|
|
|
#### Debug
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
|
|
|
|
For debug builds, use the following commands in the root directory:
|
|
|
|
|
|
|
|
```
|
|
|
|
./configure.sh -g
|
|
|
|
make
|
|
|
|
```
|
|
|
|
|
2021-04-06 08:48:09 +00:00
|
|
|
#### Install
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2021-04-06 08:48:09 +00:00
|
|
|
#### Library
|
2020-11-26 17:39:51 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2021-04-06 08:48:09 +00:00
|
|
|
#### Package and Distro Maintainers
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
|
2021-11-30 17:40:32 +00:00
|
|
|
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.
|
|
|
|
|
2021-04-06 08:48:09 +00:00
|
|
|
##### Recommended Compiler
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
|
|
|
|
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).
|
|
|
|
|
2021-04-06 08:48:09 +00:00
|
|
|
##### Recommended Optimizations
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2021-04-06 08:48:09 +00:00
|
|
|
##### Stripping Binaries
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
|
|
|
|
By default, non-debug binaries are stripped, but stripping can be disabled with
|
|
|
|
the `-T` option to `configure.sh`.
|
|
|
|
|
2021-04-06 08:48:09 +00:00
|
|
|
##### Using This `bc` as an Alternative
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
|
|
|
|
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`.
|
|
|
|
|
2021-04-06 08:48:09 +00:00
|
|
|
##### Karatsuba Number
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
|
|
|
|
Package and distro maintainers have one tool at their disposal to build this
|
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
2021-08-10 08:42:54 +00:00
|
|
|
`bc` in the optimal configuration: `scripts/karatsuba.py`.
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
|
|
|
|
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`
|
2022-06-11 11:03:06 +00:00
|
|
|
is also compatible with MinGW toolchains.
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
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
2021-08-10 08:42:54 +00:00
|
|
|
### 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.
|
|
|
|
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
## Comparison to GNU `bc`
|
|
|
|
|
|
|
|
This `bc` compares favorably to GNU `bc`.
|
|
|
|
|
2021-04-06 08:48:09 +00:00
|
|
|
* This `bc` builds natively on Windows.
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
* 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
|
|
|
|
|
2021-04-06 08:48:09 +00:00
|
|
|
Currently, there is no locale support on Windows.
|
|
|
|
|
|
|
|
Additionally, this `bc` only has support for English (and US English), French,
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
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.
|
|
|
|
|
2020-07-07 07:51:09 +00:00
|
|
|
* [FreeBSD `bc`][23]. While the `bc` in FreeBSD is kept up-to-date, it is better
|
2020-08-03 19:20:26 +00:00
|
|
|
to [report bugs there][24], as well as [submit patches][25], and the
|
|
|
|
maintainers of the package will contact me if necessary.
|
2020-07-07 07:51:09 +00:00
|
|
|
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
## Language
|
|
|
|
|
2021-04-06 08:48:09 +00:00
|
|
|
This `bc` is written in pure ISO C99, using POSIX 2008 APIs with custom Windows
|
|
|
|
compatibility code.
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
|
|
|
|
## 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).
|
2021-04-06 08:48:09 +00:00
|
|
|
.gitattributes The git attributes file (maintainer use only).
|
2021-11-30 17:40:32 +00:00
|
|
|
bcl.pc.in A template pkg-config file for bcl.
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
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.
|
2021-11-30 17:40:32 +00:00
|
|
|
NEWS.md The changelog.
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
NOTICE.md List of contributors and copyright owners.
|
|
|
|
|
|
|
|
Folders:
|
|
|
|
|
2022-06-11 11:03:06 +00:00
|
|
|
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.
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
|
|
|
|
[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
|
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
2021-08-10 08:42:54 +00:00
|
|
|
[17]: https://git.yzena.com/gavin/vim-bc
|
|
|
|
[18]: https://git.yzena.com/gavin/bc_libs
|
Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:
- They do not depend on external large number functions (i.e. no dependency
on OpenSSL or any other large number library)
- They implements all features found in GNU bc/dc (with the exception of
the forking of sub-processes, which the author of this version considers
as a security issue).
- They are significantly faster than the current code in base (more than
2 orders of magnitude in some of my tests, e.g. for 12345^100000).
- They should be fully compatible with all features and the behavior of the
current implementations in FreeBSD (not formally verified).
- They support POSIX message catalogs and come with localized messages in
Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
and Russian.
- They offer very detailed man-pages that provide far more information than
the current ones.
The upstream sources contain a large number of tests, which are not
imported with this commit. They could be integrated into our test
framework at a latter time.
Installation of this version is controlled by the option "MK_GH_BC=yes".
This option will be set to yes by default in 13-CURRENT, but will be off
by default in 12-STABLE.
Approved by: imp
Obtained from: https://git.yzena.com/gavin/bc
MFC after: 4 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19982
2020-06-27 12:02:01 +00:00
|
|
|
[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
|
2021-02-17 21:56:16 +00:00
|
|
|
[23]: https://cgit.freebsd.org/src/tree/contrib/bc
|
2020-08-03 19:20:26 +00:00
|
|
|
[24]: https://bugs.freebsd.org/
|
|
|
|
[25]: https://reviews.freebsd.org/
|
2020-11-26 17:39:51 +00:00
|
|
|
[26]: ./manuals/bcl.3.md
|
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
2021-08-10 08:42:54 +00:00
|
|
|
[27]: https://en.wikipedia.org/wiki/Bus_factor
|
|
|
|
[28]: ./manuals/development.md
|
2022-06-11 11:03:06 +00:00
|
|
|
[29]: https://github.com/gavinhoward/bc
|