summaryrefslogtreecommitdiff
path: root/bin/ksh
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2017-05-31 20:18:44 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2017-05-31 20:18:44 +0000
commit7840050ba6aee38a3c2bfe86d74e01e91472a883 (patch)
treee96ae69119dffc6c1d0225a0d1f4843ef9df4fac /bin/ksh
parent1307728ff1f218224c245efb14368f707526c522 (diff)
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 <wai at roquesor dot com>.
Diffstat (limited to 'bin/ksh')
-rw-r--r--bin/ksh/vi.c10
1 files changed, 6 insertions, 4 deletions
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;