Skip to content

Releases: gavinhoward/bc

Release 3.1.3

10 Jul 03:20
Compare
Choose a tag to compare

This is a production release that fixes one minor bug: if bc was invoked like the following, it would error:

echo "if (1 < 3) 1" | bc

Unless users run into this bug, they do not need to upgrade, but it is suggested that they do.

$ sha512sum bc-3.1.3.tar.xz
fb702e45fb994d4f1be55c2b05c4c4b4c67ae838f4f46864ba944890c1810b871fbafaa323d432f0f600f8182b4370757b75de756ae2795b595776e3fe03ba7b  bc-3.1.3.tar.xz

$ sha256sum bc-3.1.3.tar.xz
5e4a2fac5ac9a49bdec7dc3fa06547fdb83629dc7b854fb0ce63d484521f9684  bc-3.1.3.tar.xz

$ stat -c '%s  %n'
210924  bc-3.1.3.tar.xz

$ sha512sum bc-3.1.3.tar.xz.sig
cb6c2d0784c85483c174392ff9bfd148f2a837074d4cd44c25b17e8d0c3d78612bc00c58aea0e7b2b61239cadf68cf0ac68c698e79befc05a1a8614c71753124  bc-3.1.3.tar.xz.sig

$ sha256sum bc-3.1.3.tar.xz.sig
fb63237b8aa0e7f63ce96540531ea2fda7b30250625a6d08cda597d753a3b1e7  bc-3.1.3.tar.xz.sig

$ stat -c '%s  %n'
662  bc-3.1.3.tar.xz.sig

Release 3.1.2

09 Jul 14:29
Compare
Choose a tag to compare

This is a production release that adds a way to install all locales. Users do NOT need to upgrade.

For package maintainers wishing to make use of the change, just pass -l to configure.sh.

$ sha512sum bc-3.1.2.tar.xz
c123a322578e7b2213317db8fd95c5596b45f59f8890ce05d0d25bac983d3038c1bda65c8998b760e15efc0ee3a10241f3ca712442b4f444f691dd6c5065e53d  bc-3.1.2.tar.xz

$ sha256sum bc-3.1.2.tar.xz
61d4833ffddd33b87b528e35a438c1fec4c1ecbb2fe339924fb0947b13663e65  bc-3.1.2.tar.xz

$ stat -c '%s  %n'
209820  bc-3.1.2.tar.xz

$ sha512sum bc-3.1.2.tar.xz.sig
f82933bbfc5cbe595d8e752e7bf92b5d841b2c90aee596b06346eb6fb7279cf6f21489744ea8493c1f76b225a7f295245978802a6c6175d67164b16181c42722  bc-3.1.2.tar.xz.sig

$ sha256sum bc-3.1.2.tar.xz.sig
010af7ba46d133d6d94547f6c885bec549ed39abc8c9c0168154b5182838ebfc  bc-3.1.2.tar.xz.sig

$ stat -c '%s  %n'
662  bc-3.1.2.tar.xz.sig

Release 3.1.1

06 Jul 23:27
Compare
Choose a tag to compare

This is a production release that adds two Spanish locales. Users do NOT need to upgrade, unless they want those locales.

$ sha512sum bc-3.1.1.tar.xz
1f770edf619ade8780d0a494934071bfa82d1298043459cab6e3db6a5617e6aad0d7193635c868ef0d0312b808027ad3734cb92b0c8eff826cd5a860eb3fe6d2  bc-3.1.1.tar.xz

$ sha256sum bc-3.1.1.tar.xz
7401c68baef31622251eac47cabe0e35c973baec6b938b20741f777cf58d2dce  bc-3.1.1.tar.xz

$ stat -c '%s  %n'
209328  bc-3.1.1.tar.xz

$ sha512sum bc-3.1.1.tar.xz.sig
ee6f0d7e3b2120b59373b2d35316da43350c397e7005efa90da181805307d475057ea846f76a2751e57803918381dee08e5e3e1c12df66daedc83ba72b90bcf5  bc-3.1.1.tar.xz.sig

$ sha256sum bc-3.1.1.tar.xz.sig
0067d965d94ff87f8f9cbf8a95ae76f72b72f60607231b4437313e4ae435d13a  bc-3.1.1.tar.xz.sig

$ stat -c '%s  %n'
662  bc-3.1.1.tar.xz.sig

Release 3.1.0

06 Jul 17:55
Compare
Choose a tag to compare

This is a production release that adjusts one behavior, fixes eight bugs, and improves manpages for FreeBSD. Because this release fixes bugs, users and package maintainers should update to this version as soon as possible.

The behavior that was adjusted was how code from the -e and -f arguments (and equivalents) were executed. They used to be executed as one big chunk, but in this release, they are now executed line-by-line.

The first bug fix in how output to stdout was handled in SIGINT. If a SIGINT came in, the stdout buffer was not correctly flushed. In fact, a clean-up function was not getting called. This release fixes that bug.

The second bug is in how dc handled input from stdin. This affected bc as well since it was a mishandling of the stdin buffer.

The third fixed bug was that bc and dc could abort() (in debug mode) when receiving a SIGTERM. This one was a race condition with pushing and popping items onto and out of vectors.

The fourth bug fixed was that bc could leave extra items on the stack and thus, not properly clean up some memory. (The memory would still get free()'ed, but it would not be free()'ed when it could have been.)

The next two bugs were bugs in bc's parser that caused crashes when executing the resulting code.

The last two bugs were crashes in dc that resulted from mishandling of strings.

The manpage improvement was done by switching from ronn to Pandoc to generate manpages. Pandoc generates much cleaner manpages and doesn't leave blank lines where they shouldn't be.

$ sha512sum bc-3.1.0.tar.xz
1858afe0c15bd518637cc7a34d0905042ea424f8398c85d97024ee0a397b15f549c8dfc1b8fe46c6ee9cdd38949de18e927951463cbbde007188809d8acd33cb  bc-3.1.0.tar.xz

$ sha256sum bc-3.1.0.tar.xz
73966d9e8627584f3d3498e12c42a7d3bfa01bfc0b14395a0822205d5611fd27  bc-3.1.0.tar.xz

$ stat -c '%s  %n'
209392  bc-3.1.0.tar.xz

$ sha512sum bc-3.1.0.tar.xz.sig
d0114e0ce0d6fd5379bf9d76d73001ccdc148554351dcc7512c8cbbab504580e5c0316fd7a7110d1a656a9ed98758c48085f61c97830c6e4a251302830670f68  bc-3.1.0.tar.xz.sig

$ sha256sum bc-3.1.0.tar.xz.sig
1a881b897f8039a0f0edfc2732bcd34f3f90ae7c35cf9e28a2edb8280aa343c0  bc-3.1.0.tar.xz.sig

$ stat -c '%s  %n'
662  bc-3.1.0.tar.xz.sig

Release 3.0.3

28 Jun 21:08
Compare
Choose a tag to compare

This is a production release that adds one new feature: specific manpages.

Before this release, bc and dc only used one manpage each that referred to various build options. This release changes it so there is one manpage set per relevant build type. Each manual only has information about its particular build, and configure.sh selects the correct set for install.

$ sha512sum bc-3.0.3.tar.xz
a29ed390f33b9d19d4e5a06037a0c43c9289d7b46e52c5e01ccebbf0c7daf2a022acd35669c25e33492d0c83270bf0611f4959111fd4e5871ae064ae27416d88  bc-3.0.3.tar.xz

$ sha256sum bc-3.0.3.tar.xz
8cf87e994f9f74c19dacdb623c870cbfe7486a64119842add65222c12b48e006  bc-3.0.3.tar.xz

$ stat -c '%s  %n'
202448  bc-3.0.3.tar.xz

$ sha512sum bc-3.0.3.tar.xz.sig
b37d608bf3d8e5bbc594a3b8bf120a265f61d75f009b3806a6155107d4350efa1dfbc7a9e0143442ea7725efde6d07ec3a4687edcfd110448cb1f3c977d7e4ae  bc-3.0.3.tar.xz.sig

$ sha256sum bc-3.0.3.tar.xz.sig
985d208ecac1e7b680c64cfd4def891c747e51e80f4a0aef011d1fd897d6f69b  bc-3.0.3.tar.xz.sig

$ stat -c '%s  %n'
662  bc-3.0.3.tar.xz.sig

Release 3.0.2

24 Jun 15:53
Compare
Choose a tag to compare

This is a production release that adds utf8 locale symlinks and removes an unused auto variable from the ceil() function in the extended math library.

Users do NOT need to update unless they want the locales.

$ sha512sum bc-3.0.2.tar.xz
2b9eb7cd9f3c589c35b4d271c97afd32bac3d8c7e845a3639571dfb26a48d0eb1649035ef0f7c63de5a7d65d31c61b2ac3cf584225237c53aeb9ce3828b8093d  bc-3.0.2.tar.xz

$ sha256sum bc-3.0.2.tar.xz
44975f59d979aefdf3f4735ac1072ef6920342b69003d8942752eb249a9a0e33  bc-3.0.2.tar.xz

$ stat -c '%s  %n'
199484  bc-3.0.2.tar.xz

$ sha512sum bc-3.0.2.tar.xz.sig
d78828e6cedf1a93b4a18d6e816732b8cf0bd41078baa5923406a908fb7a3f44a21539499c05630e42f0f2b2ae76d5c036b9ba0dfdf4efea515e7099d8a7dc2a  bc-3.0.2.tar.xz.sig

$ sha256sum bc-3.0.2.tar.xz.sig
0c504782fcb14b6b6e8705cafd8b375f66dd89aca01f5cd8d17f76872db138b9  bc-3.0.2.tar.xz.sig

$ stat -c '%s  %n'
662  bc-3.0.2.tar.xz.sig

Release 3.0.1

19 Jun 19:21
Compare
Choose a tag to compare

This is a production release with two small changes. Users do NOT need to upgrade to this release; however, if they haven't upgraded to 3.0.0 yet, it may be worthwhile to upgrade to this release instead.

The first change is fixing a compiler warning on FreeBSD with strict warnings on.

The second change is to make the new implementation of ceil() in lib2.bc much more efficient.

$ sha512sum bc-3.0.1.tar.xz
553d14b3439e6f7d5ec370db3a7104808e263692fdae795d5f97fca3bb40d371e75bbab615d81975c87da9c84fbbb39bc148cf12a122b0e0e3c9036abb9b7cd8  bc-3.0.1.tar.xz

$ sha256sum bc-3.0.1.tar.xz
a06a7791030e98b69004ba0f02d7dc625c444ccf0882c04c454e397aeb481283  bc-3.0.1.tar.xz

$ stat -c '%s  %n'
199732  bc-3.0.1.tar.xz

$ sha512sum bc-3.0.1.tar.xz.sig
9f840c5c756a09e24ed8aac3e17639dabf965badc8784fe6495d9a6f2b4b2a03d51ced1b98ae266285fba54124619ea734f9c5d6c52bc33dccef27cb7ffb2f7d  bc-3.0.1.tar.xz.sig

$ sha256sum bc-3.0.1.tar.xz.sig
6851e863f1fe70fa1b41fe29c03aad019b6b454073c6b9e75e99cbb4f8244ba6  bc-3.0.1.tar.xz.sig

$ stat -c '%s  %n'
662  bc-3.0.1.tar.xz.sig

Release 3.0.0

18 Jun 22:57
Compare
Choose a tag to compare

Notes for package maintainers:

First, the 2.7.0 release series saw a change in the option parsing. This made me change one error message and add a few others. The error message that was changed removed one format specifier. This means that printf() will seqfault on old locale files. Unfortunately, bc cannot use any locale files except the global ones that are already installed, so it will use the previous ones while running tests during install. If bc segfaults while running arg tests when updating, it is because the global locale files have not been replaced. Make sure to either prevent the test suite from running on update or remove the old locale files before updating. Once this is done, bc should install without problems.

Second, the option to build without signal support has been removed. See below for the reasons why.

This is a production release with some small bug fixes, a few improvements, three major bug fixes, and a complete redesign of bc's error and signal handling. Users and package maintainers should update to this version as soon as possible.

The first major bug fix was in how bc executed files. Previously, a whole file was parsed before it was executed, but if a function is defined after code, especially if the function definition was actually a redefinition, and the code before the definition referred to the previous function, this bc would replace the function before executing any code. The fix was to make sure that all code that existed before a function definition was executed.

The second major bug fix was in bc's lib2.bc. The ceil() function had a bug where a 0 in the decimal place after the truncation position, caused it to output the wrong numbers if there was any non-zero digit after.

The third major bug is that when passing parameters to functions, if an expression included an array (not an array element) as a parameter, it was accepted, when it should have been rejected. It is now correctly rejected.

Beyond that, this bc got several improvements that both sped it up, improved the handling of signals, and improved the error handling.

First, the requirements for bc were pushed back to POSIX 2008. bc uses one function, strdup(), which is not in POSIX 2001, and it is in the X/Open System Interfaces group 2001. It is, however, in POSIX 2008, and since POSIX 2008 is old enough to be supported anywhere that I care, that should be the requirement.

Second, the BcVm global variable was put into bss. This actually slightly reduces the size of the executable from a massive code shrink, and it will stop bc from allocating a large set of memory when bc starts.

Third, the default Karatsuba length was updated from 64 to 32 after making the optimization changes below, since 32 is going to be better than 64 after the changes.

Fourth, Spanish translations were added.

Fifth, the interpreter received a speedup to make performance on non-math-heavy scripts more competitive with GNU bc. While improvements did, in fact, get it much closer (see the [benchmarks][19]), it isn't quite there.

There were several things done to speed up the interpreter:

First, several small inefficiencies were removed. These inefficiencies included calling the function bc_vec_pop(v) twice instead of calling bc_vec_npop(v, 2). They also included an extra function call for checking the size of the stack and checking the size of the stack more than once on several operations.

Second, since the current bc function is the one that stores constants and strings, the program caches pointers to the current function's vectors of constants and strings to prevent needing to grab the current function in order to grab a constant or a string.

Third, bc tries to reuse BcNum's (the internal representation of arbitary-precision numbers). If a BcNum has the default capacity of BC_NUM_DEF_SIZE (32 on 64-bit and 16 on 32-bit) when it is freed, it is added to a list of available BcNum's. And then, when a BcNum is allocated with a capacity of BC_NUM_DEF_SIZE and any BcNum's exist on the list of reusable ones, one of those ones is grabbed instead.

In order to support these changes, the BC_NUM_DEF_SIZE was changed. It used to be 16 bytes on all systems, but it was changed to more closely align with the minimum allocation size on Linux, which is either 32 bytes (64-bit musl), 24 bytes (64-bit glibc), 16 bytes (32-bit musl), or 12 bytes (32-bit glibc). Since these are the minimum allocation sizes, these are the sizes that would be allocated anyway, making it worth it to just use the whole space, so the value of BC_NUM_DEF_SIZE on 64-bit systems was changed to 32 bytes.

On top of that, at least on 64-bit, BC_NUM_DEF_SIZE supports numbers with either 72 integer digits or 45 integer digits and 27 fractional digits. This should be more than enough for most cases since bc's default scale values are 0 or 20, meaning that, by default, it has at most 20 fractional digits. And 45 integer digits are a lot; it's enough to calculate the amount of mass in the Milky Way galaxy in kilograms. Also, 72 digits is enough to calculate the diameter of the universe in Planck lengths.

(For 32-bit, these numbers are either 32 integer digits or 12 integer digits and 20 fractional digits. These are also quite big, and going much bigger on a 32-bit system seems a little pointless since 12 digits in just under a trillion and 20 fractional digits is still enough for about any use since 10^-20 light years is just under a millimeter.)

All of this together means that for ordinary uses, and even uses in scientific work, the default number size will be all that is needed, which means that nearly all, if not all, numbers will be reused, relieving pressure on the system allocator.

I did several experiments to find the changes that had the most impact, especially with regard to reusing BcNum's. One was putting BcNum's into buckets according to their capacity in powers of 2 up to 512. That performed worse than bc did in 2.7.2. Another was putting any BcNum on the reuse list that had a capacity of BC_NUM_DEF_SIZE * 2 and reusing them for BcNum's that requested BC_NUM_DEF_SIZE. This did reduce the amount of time spent, but it also spent a lot of time in the system allocator for an unknown reason. (When using strace, a bunch more brk calls showed up.) Just reusing BcNum's that had exactly BC_NUM_DEF_SIZE capacity spent the smallest amount of time in both user and system time. This makes sense, especially with the changes to make BC_NUM_DEF_SIZE bigger on 64-bit systems, since the vast majority of numbers will only ever use numbers with a size less than or equal to BC_NUM_DEF_SIZE.

Last of all, bc's signal handling underwent a complete redesign. (This is the reason that this version is 3.0.0 and not 2.8.0.) The change was to move from a polling approach to signal handling to an interrupt-based approach.

Previously, every single loop condition had a check for signals. I suspect that this could be expensive when in tight loops.

Now, the signal handler just uses longjmp() (actually siglongjmp()) to start an unwinding of the stack until it is stopped or the stack is unwound to main(), which just returns. If bc is currently executing code that cannot be safely interrupted (according to POSIX), then signals are "locked." The signal handler checks if the lock is taken, and if it is, it just sets the status to indicate that a signal arrived. Later, when the signal lock is released, the status is checked to see if a signal came in. If so, the stack unwinding starts.

This design eliminates polling in favor of maintaining a stack of jmp_buf's. This has its own performance implications, but it gives better interaction. And the cost of pushing and popping a jmp_buf in a function is paid at most twice. Most functions do not pay that price, and most of the rest only pay it once. (There are only some 3 functions in bc that push and pop a jmp_buf twice.)

As a side effect of this change, I had to eliminate the use of stdio.h in bc because stdio does not play nice with signals and longjmp(). I implemented custom I/O buffer code that takes a fraction of the size. This means that static builds will be smaller, but non-static builds will be bigger, though they will have less linking time.

This change is also good because my history implementation was already bypassing stdio for good reasons, and unifying the architecture was a win.

Another reason for this change is that my bc should always behave correctly in the presence of signals like SIGINT, SIGTERM, and SIGQUIT. With the addition of my own I/O buffering, I needed to also make sure that the buffers were correctly flushed even when such signals happened.

For this reason, I removed the option to build without signal support.

As a nice side effect of this change, the error handling code could be changed to take advantage of the stack unwinding that signals used. This means that signals and error handling use the same code paths, which means that the stack unwinding is well-tested. (Errors are tested heavily in the test suite.)

It also means that functions do not need to return a status code that every caller needs to check. This eliminated over 100 branches that simply checked return codes and then passed that return code up the stack if necessary. The code bloat savings from this is at least 1700 bytes on x86_64, before taking into account the extra code from removing stdio.h.

$ sha512sum bc-3.0.0.tar.xz
4961e030274e763aa02541457aa5aab6cd0d61758861b98d2cdac6acc42c3fb55b6adba72749edd3b663225ab844d7ef60809972478992165b071645fe6af65f  bc-3.0.0.tar.xz

$ sha256sum bc-3.0.0.tar.xz
4a7c5cbd5c7c2d3fea4a898c6ce87ff705756dd362cb2e3b241ae55e514e8280  bc-3.0.0.tar.xz

$ stat -c '%s  %n'
199...
Read more

Version 2.7.2

07 May 01:27
Compare
Choose a tag to compare

This is a production release with one major bug fix.

The length() built-in function can take either a number or an array. If it takes an array, it returns the length of the array. Arrays can be passed by reference. The bug is that the length() function would not properly dereference arrays that were references. This is a bug that affects all users.

ALL USERS SHOULD UPDATE bc.

$ sha512sum bc-2.7.2.tar.xz
c2014b16165bf5f8bdadf42bb60ea967a060753c17e13a7c3569d16d218bb3fb644e6a46950e9e7b3aa5a9f6bee4da9b158694909a0ab1fe390b7bb4dc20b303  bc-2.7.2.tar.xz

$ sha256sum bc-2.7.2.tar.xz
c017a6c0482cf7c4a2b31dae1f406028017a5e939d98dd6c78aa94ce3ecc8d38  bc-2.7.2.tar.xz

$ stat -c '%s  %n'
189020  bc-2.7.2.tar.xz

$ sha512sum bc-2.7.2.tar.xz.sig
076fc464dd6c3825707bf75b413357bfe3ebe340c4ff8350da36ef6b33fdbcba00ffbcb16991d853bd9179a72befc94105241e0384a7d463c5807f2fada5b975  bc-2.7.2.tar.xz.sig

$ sha256sum bc-2.7.2.tar.xz.sig
487152d9585a9d39b7bc845c7b7b50c93ad23e1ffd0169c2a58590c2d1f91105  bc-2.7.2.tar.xz.sig

$ stat -c '%s  %n'
662  bc-2.7.2.tar.xz.sig

Version 2.7.1

04 May 00:41
Compare
Choose a tag to compare

This is a production release with fixes for new locales and fixes for compiler warnings on FreeBSD.

$ sha512sum bc-2.7.1.tar.xz
f4900ccb7ca09b33e663136df12e6b02c1ca69e46f049107f359968921289e85bf3435be835f47b2ad6e4b0d33faefa8920d389e9648734f9daf7d1641389904  bc-2.7.1.tar.xz

$ sha256sum bc-2.7.1.tar.xz
6f1fd8900f0f5d98356730c11214a9adcf99a1d15b94b1991f33a4346533c624  bc-2.7.1.tar.xz

$ stat -c '%s  %n'
188584  bc-2.7.1.tar.xz

$ sha512sum bc-2.7.1.tar.xz.sig
925f308e9316392db01447ca4dceb6fbaaebe60374334a6721dbffa7b58521ecac4ebb8bed47a017627e36c786eaa59b24c894439c717e7155172d2e174d2a08  bc-2.7.1.tar.xz.sig

$ sha256sum bc-2.7.1.tar.xz.sig
fa8b23ab6d895a61a32c15c3feeb1364433c088fd9abcff3f69206ecac7952ef  bc-2.7.1.tar.xz.sig

$ stat -c '%s  %n'
662  bc-2.7.1.tar.xz.sig