Hi again Lucas,
On Thu, Apr 03, 2025 at 09:08:57PM +0200, Walter Alejandro Iglesias wrote:
> Hi Lucas,
>
> On Thu, Apr 03, 2025 at 05:17:35PM +0000, Lucas Gabriel Vuotto wrote:
> > Hey Walter,
> >
> > Thanks for the report.
> >
> > On Thu, Apr 03, 2025 at 02:55:11PM +0200, Walter Alejandro Iglesias wrote:
> > > Using vi mode in ksh I noticed that the command endword (vi.c) gets
> > > staked when the last character in a word is a UTF-8 character.
> > >
> > > To reproduce:
> > >
> > > In the line bellow, using vi mode, first move your cursor to the first
> > > character, then hit "e" several times. You'll see the cursor get
> > > stacked in the euro sign.
> > >
> > > $ word word€ word
> > > ^ this is an euro sign.
> >
> > It also happens with E command.
> >
> > > The following diff is one of my intuitive C newbie solutions, some
> > > expert will surely find a better one.
> >
> > The patch isn't correct: you're calling isspace (expects a character)
> > with the result of isu8cont (which is a boolean).
>
This time I paid a little more attention :-). Maybe I'm missing
something, but it seems to me that, in your patch, the skip_utf8_cont
variable is unnecessary.
Anyway, at first I'd also tried doing something similar to what you
suggested, I still think it doesn't require so much fuss. Let's see if
I don't make any stupid mistakes with this new version of mine:
Index: vi.c
===================================================================
RCS file: /cvs/src/bin/ksh/vi.c,v
diff -u -p -r1.60 vi.c
--- vi.c 12 Mar 2021 02:10:25 -0000 1.60
+++ vi.c 5 Apr 2025 07:23:47 -0000
@@ -1195,8 +1195,11 @@ domove(int argcnt, const char *cmd, int
return -1;
ncursor = (*cmd == 'e' ? endword : Endword)(argcnt);
if (!sub)
- while (isu8cont((unsigned char)es->cbuf[--ncursor]))
+ while (isu8cont((unsigned char)es->cbuf[--ncursor])) {
+ if (!isspace(es->cursor + 1))
+ break;
continue;
+ }
break;
case 'f':
--
Walter