home *** CD-ROM | disk | FTP | other *** search
- To: vim-dev@vim.org
- Subject: Patch 5.6.033
- Fcc: outbox
- From: Bram Moolenaar <Bram@moolenaar.net>
- ------------
-
- Patch 5.6.033
- Problem: Multi-byte: "f " sometimes skips to the second space. (Sung-Hyun
- Nam)
- Solution: Change logic in searchc() to skip trailing byte of a double-byte
- character.
- Also: Ask for second byte when searching for double-byte
- character. (Park Chong-Dae)
- Files: src/search.c
-
-
- *** ../vim-5.6.32/src/search.c Sat Jan 15 21:12:19 2000
- --- src/search.c Sun Mar 26 12:12:30 2000
- ***************
- *** 1060,1065 ****
- --- 1060,1070 ----
- int col;
- char_u *p;
- int len;
- + #ifdef MULTI_BYTE
- + int c2 = NUL; /* 2nd byte for DBCS */
- + static int lastc2 = NUL; /* 2nd last character searched */
- + int char_bytes; /* 1: normal char, 2: DBCS char */
- + #endif
-
- if (c != NUL) /* normal search: remember args for repeat */
- {
- ***************
- *** 1068,1073 ****
- --- 1073,1082 ----
- lastc = c;
- lastcdir = dir;
- lastctype = type;
- + #ifdef MULTI_BYTE
- + if (is_dbcs && IsLeadByte(c))
- + lastc2 = c2 = (char_u)safe_vgetc();
- + #endif
- }
- }
- else /* repeat previous search */
- ***************
- *** 1080,1111 ****
- dir = lastcdir;
- type = lastctype;
- c = lastc;
- }
-
- p = ml_get_curline();
- col = curwin->w_cursor.col;
- len = STRLEN(p);
-
- while (count--)
- {
- for (;;)
- {
- if ((col += dir) < 0 || col >= len)
- return FALSE;
- #ifdef MULTI_BYTE
- if (is_dbcs && dir < 0 && IsTrailByte(p, &p[col]))
- continue; /* skip multibyte's trail byte */
- #endif
- ! if (p[col] == c)
- ! break;
- ! #ifdef MULTI_BYTE
- ! if (is_dbcs && dir > 0 && IsLeadByte(p[col]))
- ! ++col; /* skip multibyte's trail byte */
- ! #endif
- }
- }
- if (type)
- col -= dir;
- curwin->w_cursor.col = col;
- return TRUE;
- }
- --- 1089,1146 ----
- dir = lastcdir;
- type = lastctype;
- c = lastc;
- + #ifdef MULTI_BYTE
- + c2 = lastc2;
- + #endif
- }
-
- p = ml_get_curline();
- col = curwin->w_cursor.col;
- len = STRLEN(p);
-
- + #ifdef MULTI_BYTE
- + if (is_dbcs && IsLeadByte(c))
- + char_bytes = 2;
- + else
- + char_bytes = 1;
- + #endif
- +
- while (count--)
- {
- for (;;)
- {
- + #ifdef MULTI_BYTE
- + if (is_dbcs && dir > 0 && IsLeadByte(p[col]))
- + ++col; /* advance two bytes for multibyte char */
- + #endif
- if ((col += dir) < 0 || col >= len)
- return FALSE;
- #ifdef MULTI_BYTE
- if (is_dbcs && dir < 0 && IsTrailByte(p, &p[col]))
- continue; /* skip multibyte's trail byte */
- +
- + if (is_dbcs && char_bytes == 2)
- + {
- + if (p[col] == c && p[col + 1] == c2)
- + break;
- + }
- + else
- #endif
- ! if (p[col] == c)
- ! break;
- }
- }
- if (type)
- + {
- + /* backup to before the character (possibly double-byte) */
- col -= dir;
- + #ifdef MULTI_BYTE
- + if (is_dbcs
- + && ((dir < 0 && char_bytes == 2)
- + || (dir > 0 && IsTrailByte(p, &p[col]))))
- + col -= dir;
- + #endif
- + }
- curwin->w_cursor.col = col;
- return TRUE;
- }
- *** ../vim-5.6.32/src/version.c Sat Mar 25 21:34:04 2000
- --- src/version.c Sun Mar 26 12:15:34 2000
- ***************
- *** 420,421 ****
- --- 420,423 ----
- { /* Add new patch number below this line */
- + /**/
- + 33,
- /**/
-
- --
- FATHER: Make sure the Prince doesn't leave this room until I come and
- get him.
- FIRST GUARD: Not ... to leave the room ... even if you come and get him.
- FATHER: No. Until I come and get him.
- SECOND GUARD: Hic.
- "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
-
- /-/-- Bram Moolenaar --- Bram@moolenaar.net --- http://www.moolenaar.net --\-\
- \-\-- Vim: http://www.vim.org ---- ICCF Holland: http://www.vim.org/iccf --/-/
-