vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 18506aad10c78ad15e93ccdb11ffec4c0c318a29 parent 799a04e34059dd17eabe307430630efd8d301e17 Author: David B. Lamkins <david@lamkins.net> Date: Fri, 3 Jul 2015 09:03:42 +0200 Fix handling of multibyte characters (at start of display area) Previously a sequence of Unicode REPLACEMENT CHARACTER was displayed. Use an explicitly initialized mbstate_t object in the call to mbrtowc(). While this should not strictly be necessary, it works around a bug in certain implementations. Closes #56. Diffstat:
| M | view.c | | | 4 | +++- |
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/view.c b/view.c @@ -374,6 +374,8 @@ void view_draw(View *view) { memset(match, 0, sizeof match); /* default and current curses attributes to use */ int default_attrs = COLOR_PAIR(0) | A_NORMAL, attrs = default_attrs; + /* start from known multibyte state */ + mbstate_t mbstate = { 0 }; while (rem > 0) { @@ -428,7 +430,7 @@ void view_draw(View *view) { } } - size_t len = mbrtowc(&wchar, cur, rem, NULL); + size_t len = mbrtowc(&wchar, cur, rem, &mbstate); if (len == (size_t)-1 && errno == EILSEQ) { /* ok, we encountered an invalid multibyte sequence, * replace it with the Unicode Replacement Character