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.491 < prev    next >
Encoding:
Internet Message Format  |  2004-04-21  |  3.9 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.2.491
  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.491
  11. Problem:    Decrementing a position doesn't take care of multi-byte chars.
  12. Solution:   Adjust the column for multi-byte characters.  Remove mb_dec().
  13.         (Yasuhiro Matsumoto)
  14. Files:        src/mbyte.c, src/misc2.c, src/proto/mbyte.pro
  15.  
  16.  
  17. *** ../vim-6.2.490/src/mbyte.c    Mon Apr 19 20:26:43 2004
  18. --- src/mbyte.c    Thu Apr 22 20:24:41 2004
  19. ***************
  20. *** 2563,2591 ****
  21.   }
  22.   
  23.   /*
  24. -  * Decrement position "lp" by one character, taking care of multi-byte chars.
  25. -  */
  26. -     int
  27. - mb_dec(lp)
  28. -     pos_T    *lp;
  29. - {
  30. -     if (lp->col > 0)        /* still within line */
  31. -     {
  32. -     --lp->col;
  33. -     mb_adjustpos(lp);
  34. -     return 0;
  35. -     }
  36. -     if (lp->lnum > 1)        /* there is a prior line */
  37. -     {
  38. -     lp->lnum--;
  39. -     lp->col = (colnr_T)STRLEN(ml_get(lp->lnum));
  40. -     mb_adjustpos(lp);
  41. -     return 1;
  42. -     }
  43. -     return -1;            /* at start of file */
  44. - }
  45. - /*
  46.    * Try to un-escape a multi-byte character.
  47.    * Used for the "to" and "from" part of a mapping.
  48.    * Return the un-escaped string if it is a multi-byte character, and advance
  49. --- 2563,2568 ----
  50. *** ../vim-6.2.490/src/misc2.c    Mon Apr 19 20:26:43 2004
  51. --- src/misc2.c    Wed Apr 21 21:05:31 2004
  52. ***************
  53. *** 412,437 ****
  54.       int
  55.   dec_cursor()
  56.   {
  57. - #ifdef FEAT_MBYTE
  58. -     return (has_mbyte ? mb_dec(&curwin->w_cursor) : dec(&curwin->w_cursor));
  59. - #else
  60.       return dec(&curwin->w_cursor);
  61. - #endif
  62.   }
  63.   
  64.       int
  65.   dec(lp)
  66.       pos_T  *lp;
  67.   {
  68. !     if (lp->col > 0)
  69. !     {        /* still within line */
  70.       lp->col--;
  71.       return 0;
  72.       }
  73. !     if (lp->lnum > 1)
  74. !     {        /* there is a prior line */
  75.       lp->lnum--;
  76. !     lp->col = (colnr_T)STRLEN(ml_get(lp->lnum));
  77.       return 1;
  78.       }
  79.       return -1;            /* at start of file */
  80. --- 412,450 ----
  81.       int
  82.   dec_cursor()
  83.   {
  84.       return dec(&curwin->w_cursor);
  85.   }
  86.   
  87.       int
  88.   dec(lp)
  89.       pos_T  *lp;
  90.   {
  91. !     char_u    *p;
  92. ! #ifdef FEAT_VIRTUALEDIT
  93. !     lp->coladd = 0;
  94. ! #endif
  95. !     if (lp->col > 0)        /* still within line */
  96. !     {
  97.       lp->col--;
  98. + #ifdef FEAT_MBYTE
  99. +     if (has_mbyte)
  100. +     {
  101. +         p = ml_get(lp->lnum);
  102. +         lp->col -= (*mb_head_off)(p, p + lp->col);
  103. +     }
  104. + #endif
  105.       return 0;
  106.       }
  107. !     if (lp->lnum > 1)        /* there is a prior line */
  108. !     {
  109.       lp->lnum--;
  110. !     p = ml_get(lp->lnum);
  111. !     lp->col = (colnr_T)STRLEN(p);
  112. ! #ifdef FEAT_MBYTE
  113. !     if (has_mbyte)
  114. !         lp->col -= (*mb_head_off)(p, p + lp->col);
  115. ! #endif
  116.       return 1;
  117.       }
  118.       return -1;            /* at start of file */
  119. *** ../vim-6.2.490/src/proto/mbyte.pro    Mon Apr  5 20:28:39 2004
  120. --- src/proto/mbyte.pro    Wed Apr 21 21:01:55 2004
  121. ***************
  122. *** 52,58 ****
  123.   void mb_adjustpos __ARGS((pos_T *lp));
  124.   char_u *mb_prevptr __ARGS((char_u *line, char_u *p));
  125.   int mb_charlen __ARGS((char_u *str));
  126. - int mb_dec __ARGS((pos_T *lp));
  127.   char_u *mb_unescape __ARGS((char_u **pp));
  128.   int mb_lefthalve __ARGS((int row, int col));
  129.   int mb_fix_col __ARGS((int col, int row));
  130. --- 52,57 ----
  131. *** ../vim-6.2.490/src/version.c    Tue Apr 20 20:47:07 2004
  132. --- src/version.c    Thu Apr 22 20:26:13 2004
  133. ***************
  134. *** 639,640 ****
  135. --- 639,642 ----
  136.   {   /* Add new patch number below this line */
  137. + /**/
  138. +     491,
  139.   /**/
  140.  
  141. -- 
  142. Engineers are always delighted to share wisdom, even in areas in which they
  143. have no experience whatsoever.  Their logic provides them with inherent
  144. insight into any field of expertise.  This can be a problem when dealing with
  145. the illogical people who believe that knowledge can only be derived through
  146. experience.
  147.                 (Scott Adams - The Dilbert principle)
  148.  
  149.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  150. ///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  151. \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
  152.  \\\  Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
  153.