NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/56926: curses: vi screen corrupted with UTF-8 multicolumn characters



>Number:         56926
>Category:       lib
>Synopsis:       curses: vi screen corrupted with UTF-8 multicolumn characters
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 15 13:50:00 +0000 2022
>Originator:     Rin Okuyama
>Release:        9.99.97 as well as 9.99.98
>Organization:
Department of Physics, Meiji University
>Environment:
NetBSD rp64 9.99.97 NetBSD 9.99.97 (GENERIC64EB) #0: Mon Jun  6 12:27:47 JST 2022  rin@latipes:/build/src/sys/arch/evbarm/compile/GENERIC64EB evbarm
>Description:
As a recent regression, vi(1) screen gets corrupted for files
including UTF-8 multicolumn characters.

For example, edit this file with LC_CTYPE=ja_JP.UTF-8:

http://www.netbsd.org/~rin/curses_20220715/sample.txt

----
% ftp http://www.netbsd.org/~rin/curses_20220715/sample.txt
...snip...
% export LC_CTYPE=ja_JP.UTF-8
% locale
LANG=""
LC_CTYPE="ja_JP.UTF-8"
LC_COLLATE="C"
LC_TIME="C"
LC_NUMERIC="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_ALL=""
% vi sample.txt
----

Then, screen gets corrupted when cursor moves on multicolumn characters,
as observed in this movie:

http://www.netbsd.org/~rin/curses_20220715/vi.mp4

This occurs for all terminal emulators as far as I can see:
- xterm
- pkgsrc/x11/mlterm
- iTerm2 (for macOS)

By bisectioning, it turned out the regression starts with this commit:

http://www.nerv.org/netbsd/?q=id:20220125T030506Z.bcfcf004c0eda8a39471f720b258282e7df9f026

I've found two typos in addbytes.c:

----
Index: addbytes.c
===================================================================
RCS file: /home/netbsd/src/lib/libcurses/addbytes.c,v
retrieving revision 1.64
diff -p -u -r1.64 addbytes.c
--- addbytes.c	19 May 2022 07:41:26 -0000	1.64
+++ addbytes.c	15 Jul 2022 13:39:10 -0000
@@ -301,12 +301,12 @@ _cursesi_addbyte(WINDOW *win, __LINE **l
 	    *(*lp)->lastchp - win->ch_off);
 	if (win->bch != ' ' && c == ' ') {
 		(*lp)->line[*x].ch = win->bch;
-#ifdef HAVE_CHAR
+#ifdef HAVE_WCHAR
 		(*lp)->line[*x].wcols = win->wcols;
 #endif
 	} else {
 		(*lp)->line[*x].ch = c;
-#ifdef HAVE_CHAR
+#ifdef HAVE_WCHAR
 		(*lp)->line[*x].wcols = wcols;
 #endif
 	}
----

But this patch does not improve the situation.
>How-To-Repeat:
Described above.
>Fix:
N/A



Home | Main Index | Thread Index | Old Index