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.1.245 < prev    next >
Encoding:
Internet Message Format  |  2002-10-28  |  3.7 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.1.245
  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.1.245
  11. Problem:    Comparing with ignored case does not work properly for Unicode
  12.         with a locale where case folding an ASCII character results in a
  13.         multi-byte character. (Glenn Maynard)
  14. Solution:   Handle ignore-case compare for Unicode differently.
  15. Files:        src/mbyte.c
  16.  
  17.  
  18. *** ../vim61.244/src/mbyte.c    Sun Oct 13 20:08:14 2002
  19. --- src/mbyte.c    Sun Oct 27 21:41:32 2002
  20. ***************
  21. *** 1842,1880 ****
  22.       char_u    *s1, *s2;
  23.       int        n;
  24.   {
  25. !     int        i, l;
  26.       int        cdiff;
  27.   
  28.       for (i = 0; i < n; i += l)
  29.       {
  30.       if (enc_utf8)
  31. -         l = utf_ptr2len_check(s1 + i);  /* exclude composing chars */
  32. -     else
  33. -         l = (*mb_ptr2len_check)(s1 + i);
  34. -     if (l <= 1)
  35.       {
  36. !         /* Single byte: first check normally, then with ignore case. */
  37. !         if (s1[i] != s2[i])
  38.           {
  39. !         cdiff = TOLOWER_LOC(s1[i]) - TOLOWER_LOC(s2[i]);
  40.           if (cdiff != 0)
  41.               return cdiff;
  42.           }
  43. -         else if (s1[i] == NUL)
  44. -         return 0;
  45.       }
  46.       else
  47.       {
  48. !         /* For multi-byte only ignore case for Unicode. */
  49. !         if (l > n - i)
  50. !         l = n - i;
  51. !         if (enc_utf8)
  52. !         cdiff = utf_fold(utf_ptr2char(s1 + i))
  53. !                          - utf_fold(utf_ptr2char(s2 + i));
  54.           else
  55. !         cdiff =  STRNCMP(s1 + i, s2 + i, l);
  56. !         if (cdiff != 0)
  57. !         return cdiff;
  58.       }
  59.       }
  60.       return 0;
  61. --- 1842,1896 ----
  62.       char_u    *s1, *s2;
  63.       int        n;
  64.   {
  65. !     int        i, j, l;
  66.       int        cdiff;
  67.   
  68.       for (i = 0; i < n; i += l)
  69.       {
  70. +     if (s1[i] == NUL && s2[i] == NUL)   /* both strings end */
  71. +         return 0;
  72.       if (enc_utf8)
  73.       {
  74. !         l = utf_byte2len(s1[i]);
  75. !         if (l > n - i)
  76. !         l = n - i;            /* incomplete character */
  77. !         /* Check directly first, it's faster. */
  78. !         for (j = 0; j < l; ++j)
  79. !         if (s1[i + j] != s2[i + j])
  80. !             break;
  81. !         if (j < l)
  82.           {
  83. !         /* If one of the two characters is incomplete return -1. */
  84. !         if (i + utf_byte2len(s1[i]) > n || i + utf_byte2len(s2[i]) > n)
  85. !             return -1;
  86. !         cdiff = utf_fold(utf_ptr2char(s1 + i))
  87. !                          - utf_fold(utf_ptr2char(s2 + i));
  88.           if (cdiff != 0)
  89.               return cdiff;
  90.           }
  91.       }
  92.       else
  93.       {
  94. !         l = (*mb_ptr2len_check)(s1 + i);
  95. !         if (l <= 1)
  96. !         {
  97. !         /* Single byte: first check normally, then with ignore case. */
  98. !         if (s1[i] != s2[i])
  99. !         {
  100. !             cdiff = TOLOWER_LOC(s1[i]) - TOLOWER_LOC(s2[i]);
  101. !             if (cdiff != 0)
  102. !             return cdiff;
  103. !         }
  104. !         }
  105.           else
  106. !         {
  107. !         /* For non-Unicode multi-byte don't ignore case. */
  108. !         if (l > n - i)
  109. !             l = n - i;
  110. !         cdiff = STRNCMP(s1 + i, s2 + i, l);
  111. !         if (cdiff != 0)
  112. !             return cdiff;
  113. !         }
  114.       }
  115.       }
  116.       return 0;
  117. *** ../vim61.244/src/version.c    Sun Oct 27 21:46:46 2002
  118. --- src/version.c    Sun Oct 27 22:18:54 2002
  119. ***************
  120. *** 608,609 ****
  121. --- 608,611 ----
  122.   {   /* Add new patch number below this line */
  123. + /**/
  124. +     245,
  125.   /**/
  126.  
  127. -- 
  128. WOMAN:   I didn't know we had a king. I thought we were an autonomous
  129.          collective.
  130. DENNIS:  You're fooling yourself.  We're living in a dictatorship.  A
  131.          self-perpetuating autocracy in which the working classes--
  132. WOMAN:   Oh there you go, bringing class into it again.
  133. DENNIS:  That's what it's all about if only people would--
  134.                                   The Quest for the Holy Grail (Monty Python)
  135.  
  136.  ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
  137. ///          Creator of Vim - Vi IMproved -- http://www.vim.org          \\\
  138. \\\           Project leader for A-A-P -- http://www.a-a-p.org           ///
  139.  \\\ Lord Of The Rings helps Uganda - http://iccf-holland.org/lotr.html ///
  140.