This should have been done long ago; it has already found memory leaks
and memory bugs. Whoops.
I found this because I realized that I forgot to free the BcVm on each
thread, and I realized that the release script should have caught that
if it was properly hooked in.
Signed-off-by: Gavin Howard <gavin@yzena.com>
This required a lot because one option does not exist depending on the
build type, so I had to change gen/strgen.c and gen/strgen.sh to filter
out just like scripts/manpage.sh does.
In gen/strgen.sh, I just had it reuse the code in scripts/manpage.sh
(moved to scripts/functions.sh). In gen/strgen.c, I had to use custom
code.
But both work, and both get the job done. I have checked the help texts
for both calculators with every build type.
Signed-off-by: Gavin Howard <gavin@yzena.com>
This requires testing for FreeBSD, like I do with OpenBSD. When on
FreeBSD, I have to *not* use _POSIX_C_SOURCE and _XOPEN_SOURCE.
Signed-off-by: Gavin Howard <gavin@yzena.com>
This took a lot of work, but it would have taken far more if I hadn't
followed good practices from the start.
Signed-off-by: Gavin Howard <gavin@yzena.com>
Turns out, they were never hooked up. It seems no one uses bcl because
no one complained. But they will be fixed in the next release.
Signed-off-by: Gavin Howard <gavin@yzena.com>
This changes it to use a command-line option. This is best because if a
user encounters a problem; they *know* they are using my bc and can add
the command-line option.
This is also better because it allows the keyword to be used as variable
and array names as well as function names, without editing the script.
This has the double advantage that I can undo the change to the parser,
though I need to keep the one line change to the lexer.
The option is `-r` and `--redefine`, and they take an argument, which is
the keyword to redefine.
All docs and tests have been updated.
Signed-off-by: Gavin Howard <gavin@yzena.com>
This was an idea from Stefan Esser of FreeBSD. At first, I did not like
it because it seemed like it would require a deep change to the parser,
to check everywhere a name could be used.
Fortunately, I came up with the idea of using an array of booleans in
BcVm to allow the parser to mark when a keyword has been redefined,
which can only happen in one place: defining functions. This made the
change to the parser simple at the expense of another simple change to
the bc lexer (literally only one line).
Because of the use of this feature in allowing users to make my bc parse
GNU bc-compatible scripts, as well as interoperate with scripts from
other bc's, I am putting this change in.
Signed-off-by: Gavin Howard <gavin@yzena.com>
Yay! I finally figured out how to do it!
The tests use Python 3 and pexpect. There are checks before they are run
to ensure that anyone running the test suite without those items will
not get errors. This is because the test suite must be portable.
I will add more history tests to increase coverage even more later.
Signed-off-by: Gavin Howard <gavin@yzena.com>
This is a big change. First of all, it removes the -P build option, so
prompt is always available now.
Second, it allows the builder to set whether or not certain settings are
on or off by default. These settings are:
* bc.banner (whether bc displays the copyright header in interactive
mode).
* {bc,dc}.sigint_reset (whether or not bc/dc resets on SIGINT or exits).
* {bc,dc}.tty_mode (whether or not TTY mode is on when available).
* {bc,dc}.history (whether or not history is enabled when available).
* {bc,dc}.prompt (whether prompt is enabled when available).
Then, users can influence the settings of these with environment
variables: BC_BANNER, {BC,DC}_SIGINT_RESET, {BC,DC}_TTY_MODE,
{BC,DC}_HISTORY, and {BC,DC}_PROMPT.
I still have documentation to add, but this commit pretty well does all
of the necessary plumbing in code, except for adding the defaults to the
help texts.
Signed-off-by: Gavin Howard <gavin@yzena.com>