nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 0693d6974a86ce8b3eeb4d475bc7556de6a41a71
parent 5129e718d7f2f669bdbf26c81a0ed920940b4a06
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed,  6 Jan 2021 15:02:15 +0100

minibar: represent bytes as 0xNN and valid Unicode code points as U+NNNN

An invalid UTF-8 starter byte should not be represented in the same way
as a valid Unicode character.

This fixes https://savannah.gnu.org/bugs/?59832.

Bug existed since two weeks ago, since the mini-bar code was merged.

Diffstat:
Msrc/winio.c | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/winio.c b/src/winio.c @@ -2138,14 +2138,16 @@ void minibar(void) char *this_position = openfile->current->data + openfile->current_x; if (*this_position == '\0') - sprintf(hexadecimal, openfile->current->next ? "U+000A" : "------"); + sprintf(hexadecimal, openfile->current->next ? " 0x0A" : "------"); else if (*this_position == '\n') - sprintf(hexadecimal, "U+0000"); - else if ((unsigned char)*this_position > 0xC1 && + sprintf(hexadecimal, " 0x00"); +#ifdef ENABLE_UTF8 + else if ((unsigned char)*this_position > 0xC1 && using_utf8() && mbtowc(&widecode, this_position, MAXCHARLEN) >= 0) sprintf(hexadecimal, "U+%04X", widecode); +#endif else - sprintf(hexadecimal, "U+%04X", (unsigned char)*this_position); + sprintf(hexadecimal, " 0x%02X", (unsigned char)*this_position); mvwaddstr(bottomwin, 0, COLS - 23, hexadecimal); }