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 / 6.2.517 < prev    next >
Encoding:
Internet Message Format  |  2004-04-29  |  3.9 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.2.517
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 6.2.517
  11. Problem:    Using "r*" in Visual mode on multi-byte characters replaces
  12.         too many characters.  In Visual Block mode replacing with a
  13.         multi-byte character doesn't work.
  14. Solution:   Adjust the operator end for the difference in byte length of the
  15.         original and the replaced character.  Insert all bytes of a
  16.         multi-byte character, take care of double-wide characters.
  17. Files:        src/ops.c
  18.  
  19.  
  20. *** ../vim-6.2.516/src/ops.c    Fri Apr 23 15:19:46 2004
  21. --- src/ops.c    Fri Apr 30 17:21:32 2004
  22. ***************
  23. *** 1925,1930 ****
  24. --- 1925,1933 ----
  25.       int        c;
  26.   {
  27.       int            n, numc;
  28. + #ifdef FEAT_MBYTE
  29. +     int            num_chars;
  30. + #endif
  31.       char_u        *newp, *oldp;
  32.       size_t        oldlen;
  33.       struct block_def    bd;
  34. ***************
  35. *** 1978,1988 ****
  36.   #ifdef FEAT_VIRTUALEDIT
  37.               && !bd.is_oneChar
  38.   #endif
  39. !             && bd.end_char_vcols > 0 ? bd.end_char_vcols - 1 : 0);
  40.           /* Figure out how many characters to replace. */
  41.           numc = oap->end_vcol - oap->start_vcol + 1;
  42.           if (bd.is_short && (!virtual_op || bd.is_MAX))
  43.           numc -= (oap->end_vcol - bd.end_vcol) + 1;
  44.           /* oldlen includes textlen, so don't double count */
  45.           n += numc - bd.textlen;
  46.   
  47. --- 1981,2009 ----
  48.   #ifdef FEAT_VIRTUALEDIT
  49.               && !bd.is_oneChar
  50.   #endif
  51. !             && bd.end_char_vcols > 0) ? bd.end_char_vcols - 1 : 0;
  52.           /* Figure out how many characters to replace. */
  53.           numc = oap->end_vcol - oap->start_vcol + 1;
  54.           if (bd.is_short && (!virtual_op || bd.is_MAX))
  55.           numc -= (oap->end_vcol - bd.end_vcol) + 1;
  56. + #ifdef FEAT_MBYTE
  57. +         /* A double-wide character can be replaced only up to half the
  58. +          * times. */
  59. +         if ((*mb_char2cells)(c) > 1)
  60. +         {
  61. +         if ((numc & 1) && !bd.is_short)
  62. +         {
  63. +             ++bd.endspaces;
  64. +             ++n;
  65. +         }
  66. +         numc = numc / 2;
  67. +         }
  68. +         /* Compute bytes needed, move character count to num_chars. */
  69. +         num_chars = numc;
  70. +         numc *= (*mb_char2len)(c);
  71. + #endif
  72.           /* oldlen includes textlen, so don't double count */
  73.           n += numc - bd.textlen;
  74.   
  75. ***************
  76. *** 1998,2004 ****
  77.           /* insert pre-spaces */
  78.           copy_spaces(newp + bd.textcol, (size_t)bd.startspaces);
  79.           /* insert replacement chars CHECK FOR ALLOCATED SPACE */
  80. !         copy_chars(newp + STRLEN(newp), (size_t)numc, c);
  81.           if (!bd.is_short)
  82.           {
  83.           /* insert post-spaces */
  84. --- 2019,2034 ----
  85.           /* insert pre-spaces */
  86.           copy_spaces(newp + bd.textcol, (size_t)bd.startspaces);
  87.           /* insert replacement chars CHECK FOR ALLOCATED SPACE */
  88. ! #ifdef FEAT_MBYTE
  89. !         if (has_mbyte)
  90. !         {
  91. !         n = STRLEN(newp);
  92. !         while (--num_chars >= 0)
  93. !             n += (*mb_char2bytes)(c, newp + n);
  94. !         }
  95. !         else
  96. ! #endif
  97. !         copy_chars(newp + STRLEN(newp), (size_t)numc, c);
  98.           if (!bd.is_short)
  99.           {
  100.           /* insert post-spaces */
  101. ***************
  102. *** 2036,2041 ****
  103. --- 2066,2072 ----
  104.           {
  105.               /* This is slow, but it handles replacing a single-byte
  106.                * with a multi-byte and the other way around. */
  107. +             oap->end.col += (*mb_char2len)(c) - (*mb_char2len)(n);
  108.               n = State;
  109.               State = REPLACE;
  110.               ins_char(c);
  111. *** ../vim-6.2.516/src/version.c    Thu Apr 29 16:36:50 2004
  112. --- src/version.c    Fri Apr 30 19:38:27 2004
  113. ***************
  114. *** 639,640 ****
  115. --- 639,642 ----
  116.   {   /* Add new patch number below this line */
  117. + /**/
  118. +     517,
  119.   /**/
  120.  
  121. -- 
  122. hundred-and-one symptoms of being an internet addict:
  123. 80. At parties, you introduce your spouse as your "service provider."
  124.  
  125.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  126. ///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  127. \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
  128.  \\\  Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
  129.