home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / old / 5.6.050 < prev    next >
Encoding:
Internet Message Format  |  2000-04-02  |  3.9 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 5.6.050
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. ------------
  6.  
  7. Patch 5.6.050
  8. Problem:    Replacing is wrong when replacing a single-byte char with
  9.         double-byte char or the other way around.
  10. Solution:   Shift the text after the character when it is replaced.
  11.         (Yasuhiro Matsumoto)
  12. Files:        src/normal.c, src/misc1.c
  13.  
  14.  
  15. *** ../vim-5.6.49/src/normal.c    Thu Mar 23 17:46:04 2000
  16. --- src/normal.c    Sun Apr  2 12:30:31 2000
  17. ***************
  18. *** 4522,4531 ****
  19.   #ifdef MULTI_BYTE
  20.           if (is_dbcs)
  21.           {
  22.           if (trailbyte != NUL)
  23. !             ptr[curwin->w_cursor.col++] = trailbyte;
  24.           else if (IsLeadByte(prechar))
  25. !             (void)del_chars((long)1, TRUE);
  26.           }
  27.   #endif
  28.       }
  29. --- 4522,4544 ----
  30.   #ifdef MULTI_BYTE
  31.           if (is_dbcs)
  32.           {
  33. +         /* Handle three situations:
  34. +          * 1. replace double-byte with double-byte: set trailbyte.
  35. +          * 2. replace single-byte with double-byte: insert trailbyte.
  36. +          * 3. replace double-byte with single-bute: delete char.
  37. +          */
  38.           if (trailbyte != NUL)
  39. !         {
  40. !             if (IsLeadByte(prechar))
  41. !             ptr[curwin->w_cursor.col] = trailbyte;
  42. !             else
  43. !             (void)ins_char(trailbyte);
  44. !         }
  45.           else if (IsLeadByte(prechar))
  46. !         {
  47. !             (void)del_char(TRUE);
  48. !             ++curwin->w_cursor.col;
  49. !         }
  50.           }
  51.   #endif
  52.       }
  53. *** ../vim-5.6.49/src/misc1.c    Fri Mar 31 14:23:12 2000
  54. --- src/misc1.c    Sun Apr  2 12:55:38 2000
  55. ***************
  56. *** 1354,1359 ****
  57. --- 1354,1363 ----
  58.       extra = 1;
  59.       else
  60.       extra = 0;
  61. + #ifdef MULTI_BYTE
  62. +     if (is_dbcs && State == REPLACE && IsLeadByte(c))
  63. +     extra = 1;
  64. + #endif
  65.   
  66.       /*
  67.        * A character has to be put on the replace stack if there is a
  68. ***************
  69. *** 1410,1416 ****
  70.       curwin->w_p_list = old_list;
  71.       }
  72.   
  73. !     newp = alloc_check((unsigned)(oldlen + extra));
  74.       if (newp == NULL)
  75.       return;
  76.       if (col > 0)
  77. --- 1414,1431 ----
  78.       curwin->w_p_list = old_list;
  79.       }
  80.   
  81. ! #ifdef MULTI_BYTE
  82. !     if (State == REPLACE && is_dbcs)
  83. !     {
  84. !     /* For multi-byte add one byte when new char is multi-byte, subtract
  85. !      * one byte when old char was multi-byte. */
  86. !     newp = alloc_check((unsigned)(oldlen + extra
  87. !             + (IsLeadByte(c) ? 1 : 0)
  88. !             - (IsLeadByte(oldp[col]) ? 1 : 0)));
  89. !     }
  90. !     else
  91. ! #endif
  92. !     newp = alloc_check((unsigned)(oldlen + extra));
  93.       if (newp == NULL)
  94.       return;
  95.       if (col > 0)
  96. ***************
  97. *** 1422,1438 ****
  98.       mch_memmove(p + 1, oldp + i, (size_t)(oldlen - i));
  99.       }
  100.       else
  101. !     mch_memmove(p + extra, oldp + col, (size_t)(oldlen - col));
  102.   #ifdef MULTI_BYTE
  103. !     /*
  104. !      * We define that "[]" is a multi-byte character.  For example, if
  105. !      * replace(R) is done over "a[]" with "[]".  Finally, "[]]" is
  106. !      * constructed, but the following line replaces "[]]" with "[] ".
  107. !      */
  108. !     if (is_dbcs && State == REPLACE && IsLeadByte(*p) && p[1] != NUL)
  109. !     p[1] = ' ';
  110.   #endif
  111.       *p = c;
  112.       ml_replace(lnum, newp, FALSE);
  113.   
  114. --- 1437,1452 ----
  115.       mch_memmove(p + 1, oldp + i, (size_t)(oldlen - i));
  116.       }
  117.       else
  118. !     {
  119.   #ifdef MULTI_BYTE
  120. !     /* if oldp have multi-byte, don't move old trail byte */
  121. !     if (is_dbcs && State == REPLACE && IsLeadByte(oldp[col]))
  122. !         mch_memmove(p + extra, oldp + col + 1, (size_t)(oldlen - col - 1));
  123. !     else
  124.   #endif
  125. +         mch_memmove(p + extra, oldp + col, (size_t)(oldlen - col));
  126. +     }
  127.       *p = c;
  128.       ml_replace(lnum, newp, FALSE);
  129.   
  130. *** ../vim-5.6.49/src/version.c    Sun Apr  2 12:06:32 2000
  131. --- src/version.c    Sun Apr  2 13:01:09 2000
  132. ***************
  133. *** 420,421 ****
  134. --- 420,423 ----
  135.   {   /* Add new patch number below this line */
  136. + /**/
  137. +     50,
  138.   /**/
  139.  
  140. -- 
  141. Florida:
  142. A special law prohibits unmarried women from parachuting on Sunday or she
  143. shall risk arrest, fine, and/or jailing.
  144.         [real standing law in Florida, United States of America]
  145.  
  146. /-/-- Bram Moolenaar --- Bram@moolenaar.net --- http://www.moolenaar.net --\-\
  147. \-\-- Vim: http://www.vim.org ---- ICCF Holland: http://www.vim.org/iccf --/-/
  148.