vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 5e886e69673b913fd12cf7b82e0f1d27326247ac
parent dc35546c39214b3923b67f6c8eae92617dfb9c26
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Thu, 27 Oct 2016 10:31:48 +0200

vis: fix :langmap behavior

The mapped to latin key has typically a shorter UTF-8 representation,
thus explicitly copy the NUL terminator to properly truncate the new
key value.

Diffstat:
Mvis.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/vis.c b/vis.c @@ -875,8 +875,8 @@ static const char *getkey(Vis *vis) { if (key.type == TERMKEY_TYPE_UNICODE && use_keymap) { const char *mapped = map_get(vis->keymap, key.utf8); if (mapped) { - size_t len = strlen(mapped); - if (len < sizeof(key.utf8)) + size_t len = strlen(mapped)+1; + if (len <= sizeof(key.utf8)) memcpy(key.utf8, mapped, len); } }