]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
tty: fix improper backspace behaviour for UTF8 characters when in canonical mode
authorBojan Novković <bojan.novkovic@fer.hr>
Sat, 7 Oct 2023 18:00:11 +0000 (21:00 +0300)
committerChristos Margiolis <christos@FreeBSD.org>
Sat, 7 Oct 2023 18:00:11 +0000 (21:00 +0300)
commit9e589b0938579f3f4d89fa5c051f845bf754184d
tree44162f1d3b2985a3af61e38c504847dc16051416
parent128f63cedc14ae21b35f74e11e2fe1a5659c58e8
tty: fix improper backspace behaviour for UTF8 characters when in canonical mode

This patch adds additional logic in ttydisc_rubchar() to properly handle
backspace behaviour for UTF-8 characters.

Currently, typing in a backspace after a UTF8 character will delete only
one byte from the byte sequence, leaving garbled output in the tty's
output queue. With this change all of the character's bytes are deleted.
This change is only active when the IUTF8 flag is set (see
19054eb6053189144aa962b2ecc1bf5087758a3e "(s)tty: add support for IUTF8
input flag")

The code uses the teken_wcwidth() function to properly handle character
column widths for different code points, and adds the
teken_utf8_bytes_to_codepoint() function that converts a UTF-8 byte
sequence to a codepoint, as specified in RFC3629.

Reported by:    christos
Reviewed by:    christos, imp
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D42067
sys/kern/tty_ttydisc.c
sys/teken/teken_wcwidth.h