sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

upperrune.c (6337B)


      1 /* Automatically generated by mkrunetype.awk */
      2 #include <stdlib.h>
      3 
      4 #include "../utf.h"
      5 #include "runetype.h"
      6 
      7 static const Rune upper3[][2] = {
      8 	{ 0x0100, 0x012E },
      9 	{ 0x0132, 0x0136 },
     10 	{ 0x0139, 0x0147 },
     11 	{ 0x014A, 0x0176 },
     12 	{ 0x0179, 0x017D },
     13 	{ 0x0182, 0x0184 },
     14 	{ 0x01A0, 0x01A4 },
     15 	{ 0x01B3, 0x01B5 },
     16 	{ 0x01CD, 0x01DB },
     17 	{ 0x01DE, 0x01EE },
     18 	{ 0x01F8, 0x021E },
     19 	{ 0x0222, 0x0232 },
     20 	{ 0x0246, 0x024E },
     21 	{ 0x0370, 0x0372 },
     22 	{ 0x03D8, 0x03EE },
     23 	{ 0x0460, 0x0480 },
     24 	{ 0x048A, 0x04BE },
     25 	{ 0x04C1, 0x04CD },
     26 	{ 0x04D0, 0x052E },
     27 	{ 0x1E00, 0x1E94 },
     28 	{ 0x1EA0, 0x1EFE },
     29 	{ 0x2C67, 0x2C6B },
     30 	{ 0x2C80, 0x2CE2 },
     31 	{ 0x2CEB, 0x2CED },
     32 	{ 0xA640, 0xA66C },
     33 	{ 0xA680, 0xA69A },
     34 	{ 0xA722, 0xA72E },
     35 	{ 0xA732, 0xA76E },
     36 	{ 0xA779, 0xA77B },
     37 	{ 0xA77E, 0xA786 },
     38 	{ 0xA790, 0xA792 },
     39 	{ 0xA796, 0xA7A8 },
     40 	{ 0xA7B4, 0xA7C2 },
     41 	{ 0xA7C7, 0xA7C9 },
     42 	{ 0xA7D6, 0xA7D8 },
     43 };
     44 
     45 static const Rune upper2[][3] = {
     46 	{ 0x0041, 0x005A, 0x0061 },
     47 	{ 0x00C0, 0x00D6, 0x00E0 },
     48 	{ 0x00D8, 0x00DE, 0x00F8 },
     49 	{ 0x0189, 0x018A, 0x0256 },
     50 	{ 0x01B1, 0x01B2, 0x028A },
     51 	{ 0x0388, 0x038A, 0x03AD },
     52 	{ 0x038E, 0x038F, 0x03CD },
     53 	{ 0x0391, 0x03A1, 0x03B1 },
     54 	{ 0x03A3, 0x03AB, 0x03C3 },
     55 	{ 0x03D2, 0x03D4, 0x03D2 },
     56 	{ 0x03FD, 0x03FF, 0x037B },
     57 	{ 0x0400, 0x040F, 0x0450 },
     58 	{ 0x0410, 0x042F, 0x0430 },
     59 	{ 0x0531, 0x0556, 0x0561 },
     60 	{ 0x10A0, 0x10C5, 0x2D00 },
     61 	{ 0x13A0, 0x13EF, 0xAB70 },
     62 	{ 0x13F0, 0x13F5, 0x13F8 },
     63 	{ 0x1C90, 0x1CBA, 0x10D0 },
     64 	{ 0x1CBD, 0x1CBF, 0x10FD },
     65 	{ 0x1F08, 0x1F0F, 0x1F00 },
     66 	{ 0x1F18, 0x1F1D, 0x1F10 },
     67 	{ 0x1F28, 0x1F2F, 0x1F20 },
     68 	{ 0x1F38, 0x1F3F, 0x1F30 },
     69 	{ 0x1F48, 0x1F4D, 0x1F40 },
     70 	{ 0x1F68, 0x1F6F, 0x1F60 },
     71 	{ 0x1FB8, 0x1FB9, 0x1FB0 },
     72 	{ 0x1FBA, 0x1FBB, 0x1F70 },
     73 	{ 0x1FC8, 0x1FCB, 0x1F72 },
     74 	{ 0x1FD8, 0x1FD9, 0x1FD0 },
     75 	{ 0x1FDA, 0x1FDB, 0x1F76 },
     76 	{ 0x1FE8, 0x1FE9, 0x1FE0 },
     77 	{ 0x1FEA, 0x1FEB, 0x1F7A },
     78 	{ 0x1FF8, 0x1FF9, 0x1F78 },
     79 	{ 0x1FFA, 0x1FFB, 0x1F7C },
     80 	{ 0x210B, 0x210D, 0x210B },
     81 	{ 0x2110, 0x2112, 0x2110 },
     82 	{ 0x2119, 0x211D, 0x2119 },
     83 	{ 0x212C, 0x212D, 0x212C },
     84 	{ 0x2130, 0x2131, 0x2130 },
     85 	{ 0x213E, 0x213F, 0x213E },
     86 	{ 0x2C00, 0x2C2F, 0x2C30 },
     87 	{ 0x2C7E, 0x2C7F, 0x023F },
     88 	{ 0xFF21, 0xFF3A, 0xFF41 },
     89 	{ 0x10400, 0x10427, 0x10428 },
     90 	{ 0x104B0, 0x104D3, 0x104D8 },
     91 	{ 0x10570, 0x1057A, 0x10597 },
     92 	{ 0x1057C, 0x1058A, 0x105A3 },
     93 	{ 0x1058C, 0x10592, 0x105B3 },
     94 	{ 0x10594, 0x10595, 0x105BB },
     95 	{ 0x10C80, 0x10CB2, 0x10CC0 },
     96 	{ 0x118A0, 0x118BF, 0x118C0 },
     97 	{ 0x16E40, 0x16E5F, 0x16E60 },
     98 	{ 0x1D400, 0x1D419, 0x1D400 },
     99 	{ 0x1D434, 0x1D44D, 0x1D434 },
    100 	{ 0x1D468, 0x1D481, 0x1D468 },
    101 	{ 0x1D49E, 0x1D49F, 0x1D49E },
    102 	{ 0x1D4A5, 0x1D4A6, 0x1D4A5 },
    103 	{ 0x1D4A9, 0x1D4AC, 0x1D4A9 },
    104 	{ 0x1D4AE, 0x1D4B5, 0x1D4AE },
    105 	{ 0x1D4D0, 0x1D4E9, 0x1D4D0 },
    106 	{ 0x1D504, 0x1D505, 0x1D504 },
    107 	{ 0x1D507, 0x1D50A, 0x1D507 },
    108 	{ 0x1D50D, 0x1D514, 0x1D50D },
    109 	{ 0x1D516, 0x1D51C, 0x1D516 },
    110 	{ 0x1D538, 0x1D539, 0x1D538 },
    111 	{ 0x1D53B, 0x1D53E, 0x1D53B },
    112 	{ 0x1D540, 0x1D544, 0x1D540 },
    113 	{ 0x1D54A, 0x1D550, 0x1D54A },
    114 	{ 0x1D56C, 0x1D585, 0x1D56C },
    115 	{ 0x1D5A0, 0x1D5B9, 0x1D5A0 },
    116 	{ 0x1D5D4, 0x1D5ED, 0x1D5D4 },
    117 	{ 0x1D608, 0x1D621, 0x1D608 },
    118 	{ 0x1D63C, 0x1D655, 0x1D63C },
    119 	{ 0x1D670, 0x1D689, 0x1D670 },
    120 	{ 0x1D6A8, 0x1D6C0, 0x1D6A8 },
    121 	{ 0x1D6E2, 0x1D6FA, 0x1D6E2 },
    122 	{ 0x1D71C, 0x1D734, 0x1D71C },
    123 	{ 0x1D756, 0x1D76E, 0x1D756 },
    124 	{ 0x1D790, 0x1D7A8, 0x1D790 },
    125 	{ 0x1E900, 0x1E921, 0x1E922 },
    126 };
    127 
    128 static const Rune upper1[][2] = {
    129 	{ 0x0130, 0x0069 },
    130 	{ 0x0178, 0x00FF },
    131 	{ 0x0181, 0x0253 },
    132 	{ 0x0186, 0x0254 },
    133 	{ 0x0187, 0x0188 },
    134 	{ 0x018B, 0x018C },
    135 	{ 0x018E, 0x01DD },
    136 	{ 0x018F, 0x0259 },
    137 	{ 0x0190, 0x025B },
    138 	{ 0x0191, 0x0192 },
    139 	{ 0x0193, 0x0260 },
    140 	{ 0x0194, 0x0263 },
    141 	{ 0x0196, 0x0269 },
    142 	{ 0x0197, 0x0268 },
    143 	{ 0x0198, 0x0199 },
    144 	{ 0x019C, 0x026F },
    145 	{ 0x019D, 0x0272 },
    146 	{ 0x019F, 0x0275 },
    147 	{ 0x01A6, 0x0280 },
    148 	{ 0x01A7, 0x01A8 },
    149 	{ 0x01A9, 0x0283 },
    150 	{ 0x01AC, 0x01AD },
    151 	{ 0x01AE, 0x0288 },
    152 	{ 0x01AF, 0x01B0 },
    153 	{ 0x01B7, 0x0292 },
    154 	{ 0x01B8, 0x01B9 },
    155 	{ 0x01BC, 0x01BD },
    156 	{ 0x01C4, 0x01C6 },
    157 	{ 0x01C7, 0x01C9 },
    158 	{ 0x01CA, 0x01CC },
    159 	{ 0x01F1, 0x01F3 },
    160 	{ 0x01F4, 0x01F5 },
    161 	{ 0x01F6, 0x0195 },
    162 	{ 0x01F7, 0x01BF },
    163 	{ 0x0220, 0x019E },
    164 	{ 0x023A, 0x2C65 },
    165 	{ 0x023B, 0x023C },
    166 	{ 0x023D, 0x019A },
    167 	{ 0x023E, 0x2C66 },
    168 	{ 0x0241, 0x0242 },
    169 	{ 0x0243, 0x0180 },
    170 	{ 0x0244, 0x0289 },
    171 	{ 0x0245, 0x028C },
    172 	{ 0x0376, 0x0377 },
    173 	{ 0x037F, 0x03F3 },
    174 	{ 0x0386, 0x03AC },
    175 	{ 0x038C, 0x03CC },
    176 	{ 0x03CF, 0x03D7 },
    177 	{ 0x03F4, 0x03B8 },
    178 	{ 0x03F7, 0x03F8 },
    179 	{ 0x03F9, 0x03F2 },
    180 	{ 0x03FA, 0x03FB },
    181 	{ 0x04C0, 0x04CF },
    182 	{ 0x10C7, 0x2D27 },
    183 	{ 0x10CD, 0x2D2D },
    184 	{ 0x1E9E, 0x00DF },
    185 	{ 0x1F59, 0x1F51 },
    186 	{ 0x1F5B, 0x1F53 },
    187 	{ 0x1F5D, 0x1F55 },
    188 	{ 0x1F5F, 0x1F57 },
    189 	{ 0x1FEC, 0x1FE5 },
    190 	{ 0x2102, 0x2102 },
    191 	{ 0x2107, 0x2107 },
    192 	{ 0x2115, 0x2115 },
    193 	{ 0x2124, 0x2124 },
    194 	{ 0x2126, 0x03C9 },
    195 	{ 0x2128, 0x2128 },
    196 	{ 0x212A, 0x006B },
    197 	{ 0x212B, 0x00E5 },
    198 	{ 0x2132, 0x214E },
    199 	{ 0x2133, 0x2133 },
    200 	{ 0x2145, 0x2145 },
    201 	{ 0x2183, 0x2184 },
    202 	{ 0x2C60, 0x2C61 },
    203 	{ 0x2C62, 0x026B },
    204 	{ 0x2C63, 0x1D7D },
    205 	{ 0x2C64, 0x027D },
    206 	{ 0x2C6D, 0x0251 },
    207 	{ 0x2C6E, 0x0271 },
    208 	{ 0x2C6F, 0x0250 },
    209 	{ 0x2C70, 0x0252 },
    210 	{ 0x2C72, 0x2C73 },
    211 	{ 0x2C75, 0x2C76 },
    212 	{ 0x2CF2, 0x2CF3 },
    213 	{ 0xA77D, 0x1D79 },
    214 	{ 0xA78B, 0xA78C },
    215 	{ 0xA78D, 0x0265 },
    216 	{ 0xA7AA, 0x0266 },
    217 	{ 0xA7AB, 0x025C },
    218 	{ 0xA7AC, 0x0261 },
    219 	{ 0xA7AD, 0x026C },
    220 	{ 0xA7AE, 0x026A },
    221 	{ 0xA7B0, 0x029E },
    222 	{ 0xA7B1, 0x0287 },
    223 	{ 0xA7B2, 0x029D },
    224 	{ 0xA7B3, 0xAB53 },
    225 	{ 0xA7C4, 0xA794 },
    226 	{ 0xA7C5, 0x0282 },
    227 	{ 0xA7C6, 0x1D8E },
    228 	{ 0xA7D0, 0xA7D1 },
    229 	{ 0xA7F5, 0xA7F6 },
    230 	{ 0x1D49C, 0x1D49C },
    231 	{ 0x1D4A2, 0x1D4A2 },
    232 	{ 0x1D546, 0x1D546 },
    233 	{ 0x1D7CA, 0x1D7CA },
    234 };
    235 
    236 int
    237 isupperrune(Rune r)
    238 {
    239 	const Rune *match;
    240 
    241 	if((match = bsearch(&r, upper3, nelem(upper3), sizeof *upper3, &rune2cmp)))
    242 		return !((r - match[0]) % 2);
    243 	if(bsearch(&r, upper2, nelem(upper2), sizeof *upper2, &rune2cmp))
    244 		return 1;
    245 	if(bsearch(&r, upper1, nelem(upper1), sizeof *upper1, &rune1cmp))
    246 		return 1;
    247 	return 0;
    248 }
    249 
    250 int
    251 tolowerrune(Rune r)
    252 {
    253 	Rune *match;
    254 
    255 	match = bsearch(&r, upper3, nelem(upper3), sizeof *upper3, &rune2cmp);
    256 	if (match)
    257 		return ((r - match[0]) % 2) ? r : r + 1;
    258 	match = bsearch(&r, upper2, nelem(upper2), sizeof *upper2, &rune2cmp);
    259 	if (match)
    260 		return match[2] + (r - match[0]);
    261 	match = bsearch(&r, upper1, nelem(upper1), sizeof *upper1, &rune1cmp);
    262 	if (match)
    263 		return match[1];
    264 	return r;
    265 }