On Sat, Apr 05, 2025 at 01:33:10PM +0200, Walter Alejandro Iglesias wrote:
> I discovered another issue (in the unpatched ksh).  Given for example:
>  
>   $ word €€€ word €€€
> 
> If you yank the first €€€ (with `ye`), then put your cursor in the last
> character (the last € of the last word) and paste the text (hitting `p`),
> the string gets corrupted.
> 

The following diff corrects both issues, the original and the explained
above:

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        11 Apr 2025 07:51:28 -0000
@@ -835,7 +835,7 @@ vi_cmd(int argcnt, const char *cmd)
                case 'p':
                        modified = 1; hnum = hlast;
                        if (es->linelen != 0)
-                               es->cursor++;
+                               es->cursor = es->linelen;
                        while (putbuf(ybuf, yanklen, 0) == 0 && --argcnt > 0)
                                ;
                        if (es->cursor != 0)
@@ -1195,8 +1195,7 @@ domove(int argcnt, const char *cmd, int 
                        return -1;
                ncursor = (*cmd == 'e' ? endword : Endword)(argcnt);
                if (!sub)
-                       while (isu8cont((unsigned char)es->cbuf[--ncursor]))
-                               continue;
+                       --ncursor;
                break;
 
        case 'f':



-- 
Walter

Reply via email to