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.033 < prev    next >
Encoding:
Internet Message Format  |  2000-03-25  |  3.7 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 5.6.033
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. ------------
  6.  
  7. Patch 5.6.033
  8. Problem:    Multi-byte: "f " sometimes skips to the second space.  (Sung-Hyun
  9.         Nam)
  10. Solution:   Change logic in searchc() to skip trailing byte of a double-byte
  11.         character.
  12.         Also: Ask for second byte when searching for double-byte
  13.         character. (Park Chong-Dae)
  14. Files:        src/search.c
  15.  
  16.  
  17. *** ../vim-5.6.32/src/search.c    Sat Jan 15 21:12:19 2000
  18. --- src/search.c    Sun Mar 26 12:12:30 2000
  19. ***************
  20. *** 1060,1065 ****
  21. --- 1060,1070 ----
  22.       int            col;
  23.       char_u        *p;
  24.       int            len;
  25. + #ifdef MULTI_BYTE
  26. +     int            c2 = NUL;        /* 2nd byte for DBCS */
  27. +     static int        lastc2 = NUL;   /* 2nd last character searched */
  28. +     int            char_bytes;        /* 1: normal char, 2: DBCS char */
  29. + #endif
  30.   
  31.       if (c != NUL)    /* normal search: remember args for repeat */
  32.       {
  33. ***************
  34. *** 1068,1073 ****
  35. --- 1073,1082 ----
  36.           lastc = c;
  37.           lastcdir = dir;
  38.           lastctype = type;
  39. + #ifdef MULTI_BYTE
  40. +         if (is_dbcs && IsLeadByte(c))
  41. +         lastc2 = c2 = (char_u)safe_vgetc();
  42. + #endif
  43.       }
  44.       }
  45.       else        /* repeat previous search */
  46. ***************
  47. *** 1080,1111 ****
  48.           dir = lastcdir;
  49.       type = lastctype;
  50.       c = lastc;
  51.       }
  52.   
  53.       p = ml_get_curline();
  54.       col = curwin->w_cursor.col;
  55.       len = STRLEN(p);
  56.   
  57.       while (count--)
  58.       {
  59.       for (;;)
  60.       {
  61.           if ((col += dir) < 0 || col >= len)
  62.           return FALSE;
  63.   #ifdef MULTI_BYTE
  64.           if (is_dbcs && dir < 0 && IsTrailByte(p, &p[col]))
  65.           continue;    /* skip multibyte's trail byte */
  66.   #endif
  67. !         if (p[col] == c)
  68. !         break;
  69. ! #ifdef MULTI_BYTE
  70. !         if (is_dbcs && dir > 0 && IsLeadByte(p[col]))
  71. !         ++col;        /* skip multibyte's trail byte */
  72. ! #endif
  73.       }
  74.       }
  75.       if (type)
  76.       col -= dir;
  77.       curwin->w_cursor.col = col;
  78.       return TRUE;
  79.   }
  80. --- 1089,1146 ----
  81.           dir = lastcdir;
  82.       type = lastctype;
  83.       c = lastc;
  84. + #ifdef MULTI_BYTE
  85. +     c2 = lastc2;
  86. + #endif
  87.       }
  88.   
  89.       p = ml_get_curline();
  90.       col = curwin->w_cursor.col;
  91.       len = STRLEN(p);
  92.   
  93. + #ifdef MULTI_BYTE
  94. +     if (is_dbcs && IsLeadByte(c))
  95. +     char_bytes = 2;
  96. +     else
  97. +     char_bytes = 1;
  98. + #endif
  99.       while (count--)
  100.       {
  101.       for (;;)
  102.       {
  103. + #ifdef MULTI_BYTE
  104. +         if (is_dbcs && dir > 0 && IsLeadByte(p[col]))
  105. +         ++col;        /* advance two bytes for multibyte char */
  106. + #endif
  107.           if ((col += dir) < 0 || col >= len)
  108.           return FALSE;
  109.   #ifdef MULTI_BYTE
  110.           if (is_dbcs && dir < 0 && IsTrailByte(p, &p[col]))
  111.           continue;    /* skip multibyte's trail byte */
  112. +         if (is_dbcs && char_bytes == 2)
  113. +         {
  114. +         if (p[col] == c && p[col + 1] == c2)
  115. +             break;
  116. +         }
  117. +         else
  118.   #endif
  119. !         if (p[col] == c)
  120. !             break;
  121.       }
  122.       }
  123.       if (type)
  124. +     {
  125. +     /* backup to before the character (possibly double-byte) */
  126.       col -= dir;
  127. + #ifdef MULTI_BYTE
  128. +     if (is_dbcs
  129. +         && ((dir < 0 && char_bytes == 2)
  130. +             || (dir > 0 && IsTrailByte(p, &p[col]))))
  131. +         col -= dir;
  132. + #endif
  133. +     }
  134.       curwin->w_cursor.col = col;
  135.       return TRUE;
  136.   }
  137. *** ../vim-5.6.32/src/version.c    Sat Mar 25 21:34:04 2000
  138. --- src/version.c    Sun Mar 26 12:15:34 2000
  139. ***************
  140. *** 420,421 ****
  141. --- 420,423 ----
  142.   {   /* Add new patch number below this line */
  143. + /**/
  144. +     33,
  145.   /**/
  146.  
  147. -- 
  148. FATHER:       Make sure the Prince doesn't leave this room until I come and
  149.               get him.
  150. FIRST GUARD:  Not ... to leave the room ... even if you come and get him.
  151. FATHER:       No.  Until I come and get him.
  152. SECOND GUARD: Hic.
  153.                  "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
  154.  
  155. /-/-- Bram Moolenaar --- Bram@moolenaar.net --- http://www.moolenaar.net --\-\
  156. \-\-- Vim: http://www.vim.org ---- ICCF Holland: http://www.vim.org/iccf --/-/
  157.