home *** CD-ROM | disk | FTP | other *** search
- To: vim-dev@vim.org
- Subject: Patch 6.1.245
- Fcc: outbox
- From: Bram Moolenaar <Bram@moolenaar.net>
- Mime-Version: 1.0
- Content-Type: text/plain; charset=ISO-8859-1
- Content-Transfer-Encoding: 8bit
- ------------
-
- Patch 6.1.245
- Problem: Comparing with ignored case does not work properly for Unicode
- with a locale where case folding an ASCII character results in a
- multi-byte character. (Glenn Maynard)
- Solution: Handle ignore-case compare for Unicode differently.
- Files: src/mbyte.c
-
-
- *** ../vim61.244/src/mbyte.c Sun Oct 13 20:08:14 2002
- --- src/mbyte.c Sun Oct 27 21:41:32 2002
- ***************
- *** 1842,1880 ****
- char_u *s1, *s2;
- int n;
- {
- ! int i, l;
- int cdiff;
-
- for (i = 0; i < n; i += l)
- {
- if (enc_utf8)
- - l = utf_ptr2len_check(s1 + i); /* exclude composing chars */
- - else
- - l = (*mb_ptr2len_check)(s1 + i);
- - if (l <= 1)
- {
- ! /* Single byte: first check normally, then with ignore case. */
- ! if (s1[i] != s2[i])
- {
- ! cdiff = TOLOWER_LOC(s1[i]) - TOLOWER_LOC(s2[i]);
- if (cdiff != 0)
- return cdiff;
- }
- - else if (s1[i] == NUL)
- - return 0;
- }
- else
- {
- ! /* For multi-byte only ignore case for Unicode. */
- ! if (l > n - i)
- ! l = n - i;
- ! if (enc_utf8)
- ! cdiff = utf_fold(utf_ptr2char(s1 + i))
- ! - utf_fold(utf_ptr2char(s2 + i));
- else
- ! cdiff = STRNCMP(s1 + i, s2 + i, l);
- ! if (cdiff != 0)
- ! return cdiff;
- }
- }
- return 0;
- --- 1842,1896 ----
- char_u *s1, *s2;
- int n;
- {
- ! int i, j, l;
- int cdiff;
-
- for (i = 0; i < n; i += l)
- {
- + if (s1[i] == NUL && s2[i] == NUL) /* both strings end */
- + return 0;
- if (enc_utf8)
- {
- ! l = utf_byte2len(s1[i]);
- ! if (l > n - i)
- ! l = n - i; /* incomplete character */
- ! /* Check directly first, it's faster. */
- ! for (j = 0; j < l; ++j)
- ! if (s1[i + j] != s2[i + j])
- ! break;
- ! if (j < l)
- {
- ! /* If one of the two characters is incomplete return -1. */
- ! if (i + utf_byte2len(s1[i]) > n || i + utf_byte2len(s2[i]) > n)
- ! return -1;
- ! cdiff = utf_fold(utf_ptr2char(s1 + i))
- ! - utf_fold(utf_ptr2char(s2 + i));
- if (cdiff != 0)
- return cdiff;
- }
- }
- else
- {
- ! l = (*mb_ptr2len_check)(s1 + i);
- ! if (l <= 1)
- ! {
- ! /* Single byte: first check normally, then with ignore case. */
- ! if (s1[i] != s2[i])
- ! {
- ! cdiff = TOLOWER_LOC(s1[i]) - TOLOWER_LOC(s2[i]);
- ! if (cdiff != 0)
- ! return cdiff;
- ! }
- ! }
- else
- ! {
- ! /* For non-Unicode multi-byte don't ignore case. */
- ! if (l > n - i)
- ! l = n - i;
- ! cdiff = STRNCMP(s1 + i, s2 + i, l);
- ! if (cdiff != 0)
- ! return cdiff;
- ! }
- }
- }
- return 0;
- *** ../vim61.244/src/version.c Sun Oct 27 21:46:46 2002
- --- src/version.c Sun Oct 27 22:18:54 2002
- ***************
- *** 608,609 ****
- --- 608,611 ----
- { /* Add new patch number below this line */
- + /**/
- + 245,
- /**/
-
- --
- WOMAN: I didn't know we had a king. I thought we were an autonomous
- collective.
- DENNIS: You're fooling yourself. We're living in a dictatorship. A
- self-perpetuating autocracy in which the working classes--
- WOMAN: Oh there you go, bringing class into it again.
- DENNIS: That's what it's all about if only people would--
- The Quest for the Holy Grail (Monty Python)
-
- /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\
- /// Creator of Vim - Vi IMproved -- http://www.vim.org \\\
- \\\ Project leader for A-A-P -- http://www.a-a-p.org ///
- \\\ Lord Of The Rings helps Uganda - http://iccf-holland.org/lotr.html ///
-