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.462 < prev    next >
Encoding:
Internet Message Format  |  2004-04-08  |  3.6 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.2.462
  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.462
  11. Problem:    Finding a matching parenthesis does not correctly handle a
  12.         backslash in a trailing byte.
  13. Solution:   Handle multi-byte characters correctly. (Taro Muraoka)
  14. Files:        src/search.c
  15.  
  16.  
  17. *** ../vim-6.2.461/src/search.c    Wed Mar 17 22:18:24 2004
  18. --- src/search.c    Fri Apr  9 11:25:06 2004
  19. ***************
  20. *** 16,21 ****
  21. --- 16,22 ----
  22.   #ifdef FEAT_EVAL
  23.   static int first_submatch __ARGS((regmmatch_T *rp));
  24.   #endif
  25. + static int check_prevcol __ARGS((char_u *linep, int col, int ch, int *prevcol));
  26.   static int inmacro __ARGS((char_u *, char_u *));
  27.   static int check_linecomment __ARGS((char_u *line));
  28.   static int cls __ARGS((void));
  29. ***************
  30. *** 1491,1496 ****
  31. --- 1492,1521 ----
  32.   }
  33.   
  34.   /*
  35. +  * Return TRUE if the character before "linep[col]" equals "ch".
  36. +  * Return FALSE if "col" is zero.
  37. +  * Update "*prevcol" to the column of the previous character, unless "prevcol"
  38. +  * is NULL.
  39. +  * Handles multibyte string correctly.
  40. +  */
  41. +     static int
  42. + check_prevcol(linep, col, ch, prevcol)
  43. +     char_u    *linep;
  44. +     int        col;
  45. +     int        ch;
  46. +     int        *prevcol;
  47. + {
  48. +     --col;
  49. + #ifdef FEAT_MBYTE
  50. +     if (col > 0 && has_mbyte)
  51. +     col -= (*mb_head_off)(linep, linep + col);
  52. + #endif
  53. +     if (prevcol)
  54. +     *prevcol = col;
  55. +     return (col >= 0 && linep[col] == ch) ? TRUE : FALSE;
  56. + }
  57. + /*
  58.    * findmatchlimit -- find the matching paren or brace, if it exists within
  59.    * maxtravel lines of here.  A maxtravel of 0 means search until falling off
  60.    * the edge of the file.
  61. ***************
  62. *** 1708,1715 ****
  63.   
  64.               /* Set "match_escaped" if there are an odd number of
  65.                * backslashes. */
  66. !             for (col = pos.col - 1; col >= 0 && linep[col] == '\\';
  67. !                                     col--)
  68.               bslcnt++;
  69.               match_escaped = (bslcnt & 1);
  70.           }
  71. --- 1733,1739 ----
  72.   
  73.               /* Set "match_escaped" if there are an odd number of
  74.                * backslashes. */
  75. !             for (col = pos.col; check_prevcol(linep, col, '\\', &col);)
  76.               bslcnt++;
  77.               match_escaped = (bslcnt & 1);
  78.           }
  79. ***************
  80. *** 2073,2079 ****
  81.           if (curbuf->b_p_lisp
  82.               && vim_strchr((char_u *)"(){}[]", c) != NULL
  83.               && pos.col > 0
  84. !             && linep[pos.col - 1] == '\\')
  85.           break;
  86.   #endif
  87.   
  88. --- 2097,2103 ----
  89.           if (curbuf->b_p_lisp
  90.               && vim_strchr((char_u *)"(){}[]", c) != NULL
  91.               && pos.col > 0
  92. !             && check_prevcol(linep, pos.col, '\\', NULL))
  93.           break;
  94.   #endif
  95.   
  96. ***************
  97. *** 2086,2093 ****
  98.   
  99.           if (!cpo_bsl)
  100.           {
  101. !             for (col = pos.col - 1; col >= 0 && linep[col] == '\\';
  102. !                                     col--)
  103.               bslcnt++;
  104.           }
  105.           /* Only accept a match when 'M' is in 'cpo' or when ecaping is
  106. --- 2110,2116 ----
  107.   
  108.           if (!cpo_bsl)
  109.           {
  110. !             for (col = pos.col; check_prevcol(linep, col, '\\', &col);)
  111.               bslcnt++;
  112.           }
  113.           /* Only accept a match when 'M' is in 'cpo' or when ecaping is
  114. *** ../vim-6.2.461/src/version.c    Thu Apr  8 12:29:56 2004
  115. --- src/version.c    Fri Apr  9 19:29:27 2004
  116. ***************
  117. *** 639,640 ****
  118. --- 639,642 ----
  119.   {   /* Add new patch number below this line */
  120. + /**/
  121. +     462,
  122.   /**/
  123.  
  124. -- 
  125. Q:   How many hardware engineers does it take to change a lightbulb?
  126. A:   None.  We'll fix it in software.
  127.  
  128.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  129. ///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  130. \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
  131.  \\\  Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
  132.