The reason I used 8 spaces is because of being able to tell where the
edge of the terminal was. It's not that important.
Signed-off-by: Gavin Howard <gavin@yzena.com>
This required some work because Windows is stupid with injecting
carriage returns in the text of files where it doesn't exist. I hate
Windows.
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>
These have the new features: command-line arguments for builtin
variables. They have also fixed a few problems.
Signed-off-by: Gavin Howard <gavin@yzena.com>
This was requested a long time ago, and I rejected it. I see differently
now because the vast majority of my -e invocations are to set these.
Signed-off-by: Gavin Howard <gavin@yzena.com>
This style fixing is to separate out local variables that are pointers
into separate lines, instead of being mashed together. This is an
artifact of the terrible style that was imposed on bc by toybox, but
since I don't maintain that code, I don't care anymore.
Also, I'm trying again to implement automatic code formatting.
Signed-off-by: Gavin Howard <gavin@yzena.com>
It turns out that I *do* have to manually add to the history. Why? I
register the history function with editline, so why do I have to
explicitly call it?
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>
FreeBSD is a pain about defining things. Apparently, it only defines
SIGWINCH if it is not building in a C99 environment, a C11 environment,
or a C89 environment. Seriously?
Signed-off-by: Gavin Howard <gavin@yzena.com>
This was requested by an important FreeBSD user. This was an exploration
of the idea to just use editline and readline. I wasn't sure it was
possible. Turns out, it is.
What is not working: history in editline does not seem to work.
Everything else seems to work. Tests still pass as well.
Signed-off-by: Gavin Howard <gavin@yzena.com>
The historic gnu bc behavior was to have ^D be delete next character if
there were any characters in the input, or end of file if there
weren't. This matches what emacs users expect for editing the command
line. Implement this by assuming end of file if the input is empty, and
delete forward character if it isn't.
Signed-off-by: Warner Losh <imp@bsdimp.com>
Clang seems to think that BC_C11 is not defined, but if you look in the
include/status.h header, you'll see that it is definitely defined. So,
we need to work around the Clang bug.
Signed-off-by: Gavin Howard <gavin@yzena.com>
The problem was that if a backslash was at the end of the line, it
correctly asked for more, but if it didn't get any, it happily just
quit. No bueno.
So if it requests more and doesn't get it, we should attempt to process
it. This will flush out any errors.
Signed-off-by: Gavin Howard <gavin@yzena.com>
This bug was a little bit of an easy one to find and a doozy to fix. The
reason for that is because reading expressions from the command-line is
kind of its own special case, so I had to do a little bit of a redesign.
The redesign wasn't that big, however; I reused the same technique I
used for fixing a similar problem with stdin. I also reused the same
global buffer in BcVm because stdin won't ever use it at the same time.
I even used kind of the same code.
But the idea is the same: have a function the lexer can call when
there is an unfinished comment or string. In fact, I need to add a test
for both of those cases, as well as a test for a multiline string.
Signed-off-by: Gavin Howard <gavin@yzena.com>
printf'On FreeBSD. Not using _POSIX_C_SOURCE and _XOPEN_SOURCE.\n\n'
else
history_tests="@printf '\$(TEST_STARS)\\\\n\\\\nRunning history tests...\\\\n\\\\n' \&\& \$(TESTSDIR)/history.sh bc -a \&\& \$(TESTSDIR)/history.sh dc -a \&\& printf '\\\\nAll history tests passed.\\\\n\\\\n\$(TEST_STARS)\\\\n'"
printf'Not on FreeBSD. Using _POSIX_C_SOURCE and _XOPEN_SOURCE.\n\n'