oops. the patch have a bug. please check following.

Index: src/term.c
===================================================================
--- src/term.c  (revision 1318)
+++ src/term.c  (working copy)
@@ -5152,7 +5152,7 @@

 #ifdef FEAT_MBYTE
        /* skip multibyte char correctly */
-       for (i = (*mb_ptr2len)(src); i > 0; --i)
+       if ((i = (*mb_ptr2len)(src)) == 1)
 #endif
        {
            /*
@@ -5172,12 +5172,17 @@
                result[dlen++] = K_SPECIAL;
                result[dlen++] = KS_EXTRA;
                result[dlen++] = (int)KE_CSI;
-           }
+           } else
+               result[dlen++] = *src;
 # endif
-           else
-               result[dlen++] = *src;
            ++src;
+#ifdef FEAT_MBYTE
+       } else {
+           mch_memmove(result + dlen, src, i);
+           dlen += i;
+           src += i;
        }
+#endif
     }
     result[dlen] = NUL;
 --

On Tue, Jan 13, 2009 at 8:01 PM, Yasuhiro MATSUMOTO <[email protected]> wrote:
> Hi. bram and all.
>
> I found a bug about treating multi-byte and special characters in command 
> line.
> ex:
>  :set enc=utf-8
>  :command! SubJapanesePeriodToDot %s/。/./g
>
> "。" mean period in japanese utf-8. and it has 0x80 in leading byte.
> but replace_termcodes treat 0x80 as K_SPECIAL and break some
> multi-byte characters in command line above.
> Below is a patch for this problem. Please check and include.
>
> Thanks.
>
> Index: src/term.c
> ===================================================================
> --- src/term.c  (revision 1318)
> +++ src/term.c  (working copy)
> @@ -5155,28 +5155,33 @@
>        for (i = (*mb_ptr2len)(src); i > 0; --i)
>  #endif
>        {
> -           /*
> -            * If the character is K_SPECIAL, replace it with K_SPECIAL
> -            * KS_SPECIAL KE_FILLER.
> -            * If compiled with the GUI replace CSI with K_CSI.
> -            */
> -           if (*src == K_SPECIAL)
> -           {
> -               result[dlen++] = K_SPECIAL;
> -               result[dlen++] = KS_SPECIAL;
> -               result[dlen++] = KE_FILLER;
> -           }
> +           if (i == 1) {
> +               /*
> +                * If the character is K_SPECIAL, replace it with K_SPECIAL
> +                * KS_SPECIAL KE_FILLER.
> +                * If compiled with the GUI replace CSI with K_CSI.
> +                */
> +               if (*src == K_SPECIAL)
> +               {
> +                   result[dlen++] = K_SPECIAL;
> +                   result[dlen++] = KS_SPECIAL;
> +                   result[dlen++] = KE_FILLER;
> +               }
>  # ifdef FEAT_GUI
> -           else if (*src == CSI)
> -           {
> -               result[dlen++] = K_SPECIAL;
> -               result[dlen++] = KS_EXTRA;
> -               result[dlen++] = (int)KE_CSI;
> +               else if (*src == CSI)
> +               {
> +                   result[dlen++] = K_SPECIAL;
> +                   result[dlen++] = KS_EXTRA;
> +                   result[dlen++] = (int)KE_CSI;
> +               } else
> +                   result[dlen++] = *src;
> +# endif
> +               ++src;
> +           } else {
> +               mch_memmove(result + dlen, src, i);
> +               dlen += i;
> +               src += i;
>            }
> -# endif
> -           else
> -               result[dlen++] = *src;
> -           ++src;
>        }
>     }
>     result[dlen] = NUL;
>
>
>
>
> --
> - Yasuhiro Matsumoto
>



-- 
- Yasuhiro Matsumoto

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui