On Fri, May 19, 2017 at 04:19:57PM +0200, Ingo Schwarze wrote: > Hi Anton, > > Anton Lindqvist wrote on Fri, May 19, 2017 at 02:11:37PM +0200: > > > Hi, > > Another UTF-8 related bug reported by tb@. How to re-produce: > > > > 1. Enable vi mode: > > > > $ set -o vi > > > > 2. Input the following characters: öa > > > > 3. Press escape and then x twice. > > > > 4. An invalid UTF-8 character is displayed. > > > > Similar to one of my previous diffs, looks like the column counter is > > wrong. The diff below fixes the problem and includes a regression test. > > I'm not running vi mode myself so further testing would be appreciated. > > Yes, that is correct, from both testing and code inspection. > > I'd prefer to also delete the condition that becomes obsolete, > see below. > > OK?
What's the status of this diff? I sent my ok to Ingo, but it seems to have been forgotten. Ingo or Anton, are you going to commit it? > Ingo > > > Index: vi.c > =================================================================== > RCS file: /cvs/src/bin/ksh/vi.c,v > retrieving revision 1.44 > diff -u -p -r1.44 vi.c > --- vi.c 17 Oct 2016 18:39:43 -0000 1.44 > +++ vi.c 19 May 2017 14:15:27 -0000 > @@ -1154,8 +1154,10 @@ vi_cmd(int argcnt, const char *cmd) > expand_word(1); > break; > } > - if (insert == 0 && es->cursor != 0 && es->cursor >= es->linelen) > - es->cursor--; > + if (insert == 0 && es->cursor >= es->linelen) > + while (es->cursor > 0) > + if (!isu8cont(es->cbuf[--es->cursor])) > + break; > } > return 0; > } > > > Index: regress/bin/ksh/vi/vi.sh > > =================================================================== > > RCS file: /cvs/src/regress/bin/ksh/vi/vi.sh,v > > retrieving revision 1.1 > > diff -u -p -r1.1 vi.sh > > --- regress/bin/ksh/vi/vi.sh 12 Jan 2016 09:00:39 -0000 1.1 > > +++ regress/bin/ksh/vi/vi.sh 19 May 2017 10:47:44 -0000 > > @@ -168,6 +168,7 @@ testseq "abcd\00332X" " $ abcd\b\b\bd \ > > # x: Delete character. > > # |: Move to column. > > testseq "abcd\00332|2x" " $ abcd\b\b\bd \b\b\b\r\nad" > > +testseq "\0303\0266a\0033xx" " $ \0303\0266a\b \b\b \b\b\r" > > > > # Y: Yank to end of line. > > testseq "abcd\0033hYp" " $ abcd\b\bccdd\b\b\r\nabccdd" > >