commit-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[2028] 2009-03-11 Pavel Roskin <address@hidden>


From: Pavel Roskin
Subject: [2028] 2009-03-11 Pavel Roskin <address@hidden>
Date: Wed, 11 Mar 2009 21:51:16 +0000

Revision: 2028
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=2028
Author:   proski
Date:     2009-03-11 21:51:16 +0000 (Wed, 11 Mar 2009)
Log Message:
-----------
2009-03-11  Pavel Roskin  <address@hidden>

        * fs/hfs.c (grub_hfs_strncasecmp): New function.
        (grub_hfs_cmp_catkeys): Use HFS specific string comparison.

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/fs/hfs.c

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog       2009-03-11 21:27:01 UTC (rev 2027)
+++ trunk/grub2/ChangeLog       2009-03-11 21:51:16 UTC (rev 2028)
@@ -1,3 +1,8 @@
+2009-03-11  Pavel Roskin  <address@hidden>
+
+       * fs/hfs.c (grub_hfs_strncasecmp): New function.
+       (grub_hfs_cmp_catkeys): Use HFS specific string comparison.
+
 2009-03-11  Robert Millan  <address@hidden>
 
        * loader/i386/multiboot_elfxx.c

Modified: trunk/grub2/fs/hfs.c
===================================================================
--- trunk/grub2/fs/hfs.c        2009-03-11 21:27:01 UTC (rev 2027)
+++ trunk/grub2/fs/hfs.c        2009-03-11 21:51:16 UTC (rev 2028)
@@ -390,7 +390,246 @@
   return 0;
 }
 
+/* Case insensitive string comparison using HFS character ordering */
+static int
+grub_hfs_strncasecmp (const unsigned char *s1, const unsigned char *s2,
+                     grub_size_t n)
+{
+  /* Taken from hfsutils 3.2.6 and converted to a readable form */
+  static const unsigned char hfs_charorder[256] = {
+    [0x00] = 0,
+    [0x01] = 1,
+    [0x02] = 2,
+    [0x03] = 3,
+    [0x04] = 4,
+    [0x05] = 5,
+    [0x06] = 6,
+    [0x07] = 7,
+    [0x08] = 8,
+    [0x09] = 9,
+    [0x0A] = 10,
+    [0x0B] = 11,
+    [0x0C] = 12,
+    [0x0D] = 13,
+    [0x0E] = 14,
+    [0x0F] = 15,
+    [0x10] = 16,
+    [0x11] = 17,
+    [0x12] = 18,
+    [0x13] = 19,
+    [0x14] = 20,
+    [0x15] = 21,
+    [0x16] = 22,
+    [0x17] = 23,
+    [0x18] = 24,
+    [0x19] = 25,
+    [0x1A] = 26,
+    [0x1B] = 27,
+    [0x1C] = 28,
+    [0x1D] = 29,
+    [0x1E] = 30,
+    [0x1F] = 31,
+    [' '] = 32,                [0xCA] = 32,
+    ['!'] = 33,
+    ['"'] = 34,
+    [0xD2] = 35,
+    [0xD3] = 36,
+    [0xC7] = 37,
+    [0xC8] = 38,
+    ['#'] = 39,
+    ['$'] = 40,
+    ['%'] = 41,
+    ['&'] = 42,
+    ['\''] = 43,
+    [0xD4] = 44,
+    [0xD5] = 45,
+    ['('] = 46,
+    [')'] = 47,
+    ['*'] = 48,
+    ['+'] = 49,
+    [','] = 50,
+    ['-'] = 51,
+    ['.'] = 52,
+    ['/'] = 53,
+    ['0'] = 54,
+    ['1'] = 55,
+    ['2'] = 56,
+    ['3'] = 57,
+    ['4'] = 58,
+    ['5'] = 59,
+    ['6'] = 60,
+    ['7'] = 61,
+    ['8'] = 62,
+    ['9'] = 63,
+    [':'] = 64,
+    [';'] = 65,
+    ['<'] = 66,
+    ['='] = 67,
+    ['>'] = 68,
+    ['?'] = 69,
+    ['@'] = 70,
+    ['A'] = 71,                ['a'] = 71,
+    [0x88] = 72,       [0xCB] = 72,
+    [0x80] = 73,       [0x8A] = 73,
+    [0x8B] = 74,       [0xCC] = 74,
+    [0x81] = 75,       [0x8C] = 75,
+    [0xAE] = 76,       [0xBE] = 76,
+    ['`'] = 77,
+    [0x87] = 78,
+    [0x89] = 79,
+    [0xBB] = 80,
+    ['B'] = 81,                ['b'] = 81,
+    ['C'] = 82,                ['c'] = 82,
+    [0x82] = 83,       [0x8D] = 83,
+    ['D'] = 84,                ['d'] = 84,
+    ['E'] = 85,                ['e'] = 85,
+    [0x83] = 86,       [0x8E] = 86,
+    [0x8F] = 87,
+    [0x90] = 88,
+    [0x91] = 89,
+    ['F'] = 90,                ['f'] = 90,
+    ['G'] = 91,                ['g'] = 91,
+    ['H'] = 92,                ['h'] = 92,
+    ['I'] = 93,                ['i'] = 93,
+    [0x92] = 94,
+    [0x93] = 95,
+    [0x94] = 96,
+    [0x95] = 97,
+    ['J'] = 98,                ['j'] = 98,
+    ['K'] = 99,                ['k'] = 99,
+    ['L'] = 100,       ['l'] = 100,
+    ['M'] = 101,       ['m'] = 101,
+    ['N'] = 102,       ['n'] = 102,
+    [0x84] = 103,      [0x96] = 103,
+    ['O'] = 104,       ['o'] = 104,
+    [0x85] = 105,      [0x9A] = 105,
+    [0x9B] = 106,      [0xCD] = 106,
+    [0xAF] = 107,      [0xBF] = 107,
+    [0xCE] = 108,      [0xCF] = 108,
+    [0x97] = 109,
+    [0x98] = 110,
+    [0x99] = 111,
+    [0xBC] = 112,
+    ['P'] = 113,       ['p'] = 113,
+    ['Q'] = 114,       ['q'] = 114,
+    ['R'] = 115,       ['r'] = 115,
+    ['S'] = 116,       ['s'] = 116,
+    [0xA7] = 117,
+    ['T'] = 118,       ['t'] = 118,
+    ['U'] = 119,       ['u'] = 119,
+    [0x86] = 120,      [0x9F] = 120,
+    [0x9C] = 121,
+    [0x9D] = 122,
+    [0x9E] = 123,
+    ['V'] = 124,       ['v'] = 124,
+    ['W'] = 125,       ['w'] = 125,
+    ['X'] = 126,       ['x'] = 126,
+    ['Y'] = 127,       ['y'] = 127,
+    [0xD8] = 128,
+    ['Z'] = 129,       ['z'] = 129,
+    ['['] = 130,
+    ['\\'] = 131,
+    [']'] = 132,
+    ['^'] = 133,
+    ['_'] = 134,
+    ['{'] = 135,
+    ['|'] = 136,
+    ['}'] = 137,
+    ['~'] = 138,
+    [0x7F] = 139,
+    [0xA0] = 140,
+    [0xA1] = 141,
+    [0xA2] = 142,
+    [0xA3] = 143,
+    [0xA4] = 144,
+    [0xA5] = 145,
+    [0xA6] = 146,
+    [0xA8] = 147,
+    [0xA9] = 148,
+    [0xAA] = 149,
+    [0xAB] = 150,
+    [0xAC] = 151,
+    [0xAD] = 152,
+    [0xB0] = 153,
+    [0xB1] = 154,
+    [0xB2] = 155,
+    [0xB3] = 156,
+    [0xB4] = 157,
+    [0xB5] = 158,
+    [0xB6] = 159,
+    [0xB7] = 160,
+    [0xB8] = 161,
+    [0xB9] = 162,
+    [0xBA] = 163,
+    [0xBD] = 164,
+    [0xC0] = 165,
+    [0xC1] = 166,
+    [0xC2] = 167,
+    [0xC3] = 168,
+    [0xC4] = 169,
+    [0xC5] = 170,
+    [0xC6] = 171,
+    [0xC9] = 172,
+    [0xD0] = 173,
+    [0xD1] = 174,
+    [0xD6] = 175,
+    [0xD7] = 176,
+    [0xD9] = 177,
+    [0xDA] = 178,
+    [0xDB] = 179,
+    [0xDC] = 180,
+    [0xDD] = 181,
+    [0xDE] = 182,
+    [0xDF] = 183,
+    [0xE0] = 184,
+    [0xE1] = 185,
+    [0xE2] = 186,
+    [0xE3] = 187,
+    [0xE4] = 188,
+    [0xE5] = 189,
+    [0xE6] = 190,
+    [0xE7] = 191,
+    [0xE8] = 192,
+    [0xE9] = 193,
+    [0xEA] = 194,
+    [0xEB] = 195,
+    [0xEC] = 196,
+    [0xED] = 197,
+    [0xEE] = 198,
+    [0xEF] = 199,
+    [0xF0] = 200,
+    [0xF1] = 201,
+    [0xF2] = 202,
+    [0xF3] = 203,
+    [0xF4] = 204,
+    [0xF5] = 205,
+    [0xF6] = 206,
+    [0xF7] = 207,
+    [0xF8] = 208,
+    [0xF9] = 209,
+    [0xFA] = 210,
+    [0xFB] = 211,
+    [0xFC] = 212,
+    [0xFD] = 213,
+    [0xFE] = 214,
+    [0xFF] = 215,
+  };
 
+  if (n == 0)
+    return 0;
+
+  while (*s1 && *s2 && --n)
+    {
+      if (hfs_charorder[*s1] != hfs_charorder[*s2])
+       break;
+
+      s1++;
+      s2++;
+    }
+
+  return (int) hfs_charorder[*s1] - (int) hfs_charorder[*s2];
+}
+
 /* Compare the K1 and K2 catalog file keys.  */
 static int
 grub_hfs_cmp_catkeys (struct grub_hfs_catalog_key *k1,
@@ -402,7 +641,7 @@
   if (cmp != 0)
     return cmp;
   
-  cmp = grub_strncasecmp ((char *) (k1->str), (char *) (k2->str), k1->strlen);
+  cmp = grub_hfs_strncasecmp (k1->str, k2->str, k1->strlen);
   
   /* This is required because the compared strings are not of equal
      length.  */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]