Bug 115231 - drivers/tty/n_tty.c:eraser does not handle fullwidth character in ICANON mode
Summary: drivers/tty/n_tty.c:eraser does not handle fullwidth character in ICANON mode
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: Serial (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Russell King
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-24 04:25 UTC by Ray Song
Modified: 2016-03-24 08:59 UTC (History)
1 user (show)

See Also:
Kernel Version: *
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Ray Song 2016-03-24 04:25:23 UTC
Start "cat" (to ensure it is in the canonical mode), enter a CJK character (other fullwidth character also applie), then press Backspace and expect the cursor to retreat by 2 columns, however, the cursor retreated by 1 column.

I confirm that the noncanonical mode handles fullwidth characters correctly with the following commands:

vte
strace -e read,write -p $(pgrep -n vte) |& grep 5

# bash (readline) ~ICANON,  two "\b"
write(5, "\177", 1)                     = 1
read(5, "\10\10\33[0m\33[0m \33[0m \10\10", 8176) = 18
...
# cat ICANON,     one "\b"
write(5, "\177", 1)                     = 1
read(5, "\10 \10", 8176)                = 3

It seems that the following lines do not handle fullwidth character correctly:

drivers/tty/n_tty.c:1047
static void eraser(unsigned char c, struct tty_struct *tty)
.......

				if (iscntrl(c) && L_ECHOCTL(tty)) {
					echo_char_raw('\b', ldata);
					echo_char_raw(' ', ldata);
					echo_char_raw('\b', ldata);
				}
				if (!iscntrl(c) || L_ECHOCTL(tty)) {
					echo_char_raw('\b', ldata);
					echo_char_raw(' ', ldata);
					echo_char_raw('\b', ldata);
				}

Note You need to log in before you can comment on or make changes to this bug.