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

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

Attachment: command-arg-break-multibyte.diff
Description: Binary data

Raspunde prin e-mail lui