vendor/bc: import version 5.2.4

This update fixes an issue in input line editing: when going left to
the start of the line, the cursor would jump to the end of the line
instead.
This commit is contained in:
Stefan Eßer 2022-04-17 13:20:54 +02:00
parent 3673adf1ee
commit bc75dcc4ce
5 changed files with 60 additions and 5 deletions

10
NEWS.md
View File

@ -1,5 +1,15 @@
# News
## 5.2.4
This is a production release that fixes two bugs in history:
* Without prompt, the cursor could not be placed on the first character in a
line.
* Home and End key handling in `tmux` was fixed.
Any users that do not care about these improvements do not need to upgrade.
## 5.2.3
This is a production release that fixes one bug, a parse error when passing a

View File

@ -37,6 +37,6 @@
#define BC_VERSION_H
/// The current version.
#define VERSION 5.2.3
#define VERSION 5.2.4
#endif // BC_VERSION_H

View File

@ -68,7 +68,7 @@ const uchar dc_sig_msg_len = (uchar) (sizeof(dc_sig_msg) - 1);
/// The copyright banner.
const char bc_copyright[] =
"Copyright (c) 2018-2021 Gavin D. Howard and contributors\n"
"Copyright (c) 2018-2022 Gavin D. Howard and contributors\n"
"Report bugs at: https://git.yzena.com/gavin/bc\n\n"
"This is free software with ABSOLUTELY NO WARRANTY.\n";

View File

@ -781,11 +781,14 @@ static void bc_history_refresh(BcHistory *h) {
if (pos >= h->buf.len - extras_len)
bc_vec_grow(&h->buf, pos + extras_len);
// Move cursor to original position.
// Move cursor to original position. Do NOT move the putchar of '\r' to the
// printf with colpos. That causes a bug where the cursor will go to the end
// of the line when there is no prompt.
bc_file_putchar(&vm.fout, bc_flush_none, '\r');
colpos = bc_history_colPos(h->buf.v, len - extras_len, pos) + h->pcol;
// Set the cursor position again.
if (colpos) bc_file_printf(&vm.fout, "\r\x1b[%zuC", colpos);
if (colpos) bc_file_printf(&vm.fout, "\x1b[%zuC", colpos);
bc_file_flush(&vm.fout, bc_flush_none);
}
@ -1193,7 +1196,34 @@ static void bc_history_escape(BcHistory *h) {
if (BC_ERR(BC_HIST_READ(seq + 2, 1)))
bc_vm_fatalError(BC_ERR_FATAL_IO_ERR);
if (seq[2] == '~' && c == '3') bc_history_edit_delete(h);
if (seq[2] == '~') {
switch(c) {
case '1':
{
bc_history_edit_home(h);
break;
}
case '3':
{
bc_history_edit_delete(h);
break;
}
case '4':
{
bc_history_edit_end(h);
break;
}
default:
{
break;
}
}
}
else if(seq[2] == ';') {
// Read two characters into seq.

View File

@ -154,6 +154,21 @@ elif [ "$generate" -eq 0 ]; then
printf 'Skipping %s script %s\n' "$d" "$f"
exit 0
else
set +e
# This is to check that the command exists. If not, we should not try to
# generate the test. Instead, we should just skip.
command -v "$d"
err="$?"
set -e
if [ "$err" -ne 0 ]; then
printf 'Could not find %s to generate results; skipping %s script %s\n' "$d" "$d" "$f"
exit 0
fi
# This sed, and the script, are to remove an incompatibility with GNU bc,
# where GNU bc is wrong. See the development manual
# (manuals/development.md#script-tests) for more information.