From: schwarze Date: Wed, 31 May 2017 20:18:43 +0000 (+0000) Subject: Let the 's' command delete the right number of bytes when UTF-8 X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=79d93e25bb09deb9df812ad69b7aeefc489a1c01;p=openbsd Let the 's' command delete the right number of bytes when UTF-8 characters are involved; similar to what anton@ previously did for 'r'; OK tb@ anton@; also tested by Walter Alejandro Iglesias . --- diff --git a/bin/ksh/vi.c b/bin/ksh/vi.c index ec8aa9964e8..a5f9fb4cb63 100644 --- a/bin/ksh/vi.c +++ b/bin/ksh/vi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vi.c,v 1.46 2017/05/31 06:59:12 anton Exp $ */ +/* $OpenBSD: vi.c,v 1.47 2017/05/31 20:18:43 schwarze Exp $ */ /* * vi command editing @@ -956,9 +956,11 @@ vi_cmd(int argcnt, const char *cmd) if (es->linelen == 0) return -1; modified = 1; hnum = hlast; - if (es->cursor + argcnt > es->linelen) - argcnt = es->linelen - es->cursor; - del_range(es->cursor, es->cursor + argcnt); + for (cur = es->cursor; cur < es->linelen; cur++) + if (!isu8cont(es->cbuf[cur])) + if (argcnt-- == 0) + break; + del_range(es->cursor, cur); insert = INSERT; break;