sbase

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

lowerrune.c (8538B)


      1 /* Automatically generated by mkrunetype.awk */
      2 #include <stdlib.h>
      3 
      4 #include "../utf.h"
      5 #include "runetype.h"
      6 
      7 static const Rune lower4[][2] = {
      8 	{ 0x0101, 0x012F },
      9 	{ 0x0133, 0x0137 },
     10 	{ 0x013A, 0x0148 },
     11 	{ 0x014B, 0x0177 },
     12 	{ 0x017A, 0x017E },
     13 	{ 0x0183, 0x0185 },
     14 	{ 0x01A1, 0x01A5 },
     15 	{ 0x01B4, 0x01B6 },
     16 	{ 0x01CE, 0x01DC },
     17 	{ 0x01DF, 0x01EF },
     18 	{ 0x01F9, 0x021F },
     19 	{ 0x0223, 0x0233 },
     20 	{ 0x0247, 0x024F },
     21 	{ 0x0371, 0x0373 },
     22 	{ 0x03D9, 0x03EF },
     23 	{ 0x0461, 0x0481 },
     24 	{ 0x048B, 0x04BF },
     25 	{ 0x04C2, 0x04CE },
     26 	{ 0x04D1, 0x052F },
     27 	{ 0x1E01, 0x1E95 },
     28 	{ 0x1EA1, 0x1EFF },
     29 	{ 0x2C68, 0x2C6C },
     30 	{ 0x2C81, 0x2CE3 },
     31 	{ 0x2CEC, 0x2CEE },
     32 	{ 0xA641, 0xA66D },
     33 	{ 0xA681, 0xA69B },
     34 	{ 0xA723, 0xA72F },
     35 	{ 0xA733, 0xA76F },
     36 	{ 0xA77A, 0xA77C },
     37 	{ 0xA77F, 0xA787 },
     38 	{ 0xA791, 0xA793 },
     39 	{ 0xA797, 0xA7A9 },
     40 	{ 0xA7B5, 0xA7C3 },
     41 	{ 0xA7C8, 0xA7CA },
     42 	{ 0xA7D7, 0xA7D9 },
     43 };
     44 
     45 static const Rune lower2[][3] = {
     46 	{ 0x0061, 0x007A, 0x0041 },
     47 	{ 0x00E0, 0x00F6, 0x00C0 },
     48 	{ 0x00F8, 0x00FE, 0x00D8 },
     49 	{ 0x01AA, 0x01AB, 0x01AA },
     50 	{ 0x0234, 0x0239, 0x0234 },
     51 	{ 0x023F, 0x0240, 0x2C7E },
     52 	{ 0x0256, 0x0257, 0x0189 },
     53 	{ 0x025D, 0x025F, 0x025D },
     54 	{ 0x026D, 0x026E, 0x026D },
     55 	{ 0x0273, 0x0274, 0x0273 },
     56 	{ 0x0276, 0x027C, 0x0276 },
     57 	{ 0x027E, 0x027F, 0x027E },
     58 	{ 0x0284, 0x0286, 0x0284 },
     59 	{ 0x028A, 0x028B, 0x01B1 },
     60 	{ 0x028D, 0x0291, 0x028D },
     61 	{ 0x0295, 0x029C, 0x0295 },
     62 	{ 0x029F, 0x02AF, 0x029F },
     63 	{ 0x037B, 0x037D, 0x03FD },
     64 	{ 0x03AD, 0x03AF, 0x0388 },
     65 	{ 0x03B1, 0x03C1, 0x0391 },
     66 	{ 0x03C3, 0x03CB, 0x03A3 },
     67 	{ 0x03CD, 0x03CE, 0x038E },
     68 	{ 0x0430, 0x044F, 0x0410 },
     69 	{ 0x0450, 0x045F, 0x0400 },
     70 	{ 0x0561, 0x0586, 0x0531 },
     71 	{ 0x0587, 0x0588, 0x0587 },
     72 	{ 0x10D0, 0x10FA, 0x1C90 },
     73 	{ 0x10FD, 0x10FF, 0x1CBD },
     74 	{ 0x13F8, 0x13FD, 0x13F0 },
     75 	{ 0x1C83, 0x1C84, 0x0421 },
     76 	{ 0x1D00, 0x1D2B, 0x1D00 },
     77 	{ 0x1D6B, 0x1D77, 0x1D6B },
     78 	{ 0x1D7A, 0x1D7C, 0x1D7A },
     79 	{ 0x1D7E, 0x1D8D, 0x1D7E },
     80 	{ 0x1D8F, 0x1D9A, 0x1D8F },
     81 	{ 0x1E96, 0x1E9A, 0x1E96 },
     82 	{ 0x1E9C, 0x1E9D, 0x1E9C },
     83 	{ 0x1F00, 0x1F07, 0x1F08 },
     84 	{ 0x1F10, 0x1F15, 0x1F18 },
     85 	{ 0x1F20, 0x1F27, 0x1F28 },
     86 	{ 0x1F30, 0x1F37, 0x1F38 },
     87 	{ 0x1F40, 0x1F45, 0x1F48 },
     88 	{ 0x1F60, 0x1F67, 0x1F68 },
     89 	{ 0x1F70, 0x1F71, 0x1FBA },
     90 	{ 0x1F72, 0x1F75, 0x1FC8 },
     91 	{ 0x1F76, 0x1F77, 0x1FDA },
     92 	{ 0x1F78, 0x1F79, 0x1FF8 },
     93 	{ 0x1F7A, 0x1F7B, 0x1FEA },
     94 	{ 0x1F7C, 0x1F7D, 0x1FFA },
     95 	{ 0x1F80, 0x1F87, 0x1F88 },
     96 	{ 0x1F90, 0x1F97, 0x1F98 },
     97 	{ 0x1FA0, 0x1FA7, 0x1FA8 },
     98 	{ 0x1FB0, 0x1FB1, 0x1FB8 },
     99 	{ 0x1FB6, 0x1FB7, 0x1FB6 },
    100 	{ 0x1FC6, 0x1FC7, 0x1FC6 },
    101 	{ 0x1FD0, 0x1FD1, 0x1FD8 },
    102 	{ 0x1FD2, 0x1FD3, 0x1FD2 },
    103 	{ 0x1FD6, 0x1FD7, 0x1FD6 },
    104 	{ 0x1FE0, 0x1FE1, 0x1FE8 },
    105 	{ 0x1FE2, 0x1FE4, 0x1FE2 },
    106 	{ 0x1FE6, 0x1FE7, 0x1FE6 },
    107 	{ 0x1FF6, 0x1FF7, 0x1FF6 },
    108 	{ 0x210E, 0x210F, 0x210E },
    109 	{ 0x213C, 0x213D, 0x213C },
    110 	{ 0x2146, 0x2149, 0x2146 },
    111 	{ 0x2C30, 0x2C5F, 0x2C00 },
    112 	{ 0x2C77, 0x2C7B, 0x2C77 },
    113 	{ 0x2D00, 0x2D25, 0x10A0 },
    114 	{ 0xA730, 0xA731, 0xA730 },
    115 	{ 0xA771, 0xA778, 0xA771 },
    116 	{ 0xAB30, 0xAB52, 0xAB30 },
    117 	{ 0xAB54, 0xAB5A, 0xAB54 },
    118 	{ 0xAB60, 0xAB68, 0xAB60 },
    119 	{ 0xAB70, 0xABBF, 0x13A0 },
    120 	{ 0xFB00, 0xFB06, 0xFB00 },
    121 	{ 0xFB13, 0xFB17, 0xFB13 },
    122 	{ 0xFF41, 0xFF5A, 0xFF21 },
    123 	{ 0x10428, 0x1044F, 0x10400 },
    124 	{ 0x104D8, 0x104FB, 0x104B0 },
    125 	{ 0x10597, 0x105A1, 0x10570 },
    126 	{ 0x105A3, 0x105B1, 0x1057C },
    127 	{ 0x105B3, 0x105B9, 0x1058C },
    128 	{ 0x105BB, 0x105BC, 0x10594 },
    129 	{ 0x10CC0, 0x10CF2, 0x10C80 },
    130 	{ 0x118C0, 0x118DF, 0x118A0 },
    131 	{ 0x16E60, 0x16E7F, 0x16E40 },
    132 	{ 0x1D41A, 0x1D433, 0x1D41A },
    133 	{ 0x1D44E, 0x1D454, 0x1D44E },
    134 	{ 0x1D456, 0x1D467, 0x1D456 },
    135 	{ 0x1D482, 0x1D49B, 0x1D482 },
    136 	{ 0x1D4B6, 0x1D4B9, 0x1D4B6 },
    137 	{ 0x1D4BD, 0x1D4C3, 0x1D4BD },
    138 	{ 0x1D4C5, 0x1D4CF, 0x1D4C5 },
    139 	{ 0x1D4EA, 0x1D503, 0x1D4EA },
    140 	{ 0x1D51E, 0x1D537, 0x1D51E },
    141 	{ 0x1D552, 0x1D56B, 0x1D552 },
    142 	{ 0x1D586, 0x1D59F, 0x1D586 },
    143 	{ 0x1D5BA, 0x1D5D3, 0x1D5BA },
    144 	{ 0x1D5EE, 0x1D607, 0x1D5EE },
    145 	{ 0x1D622, 0x1D63B, 0x1D622 },
    146 	{ 0x1D656, 0x1D66F, 0x1D656 },
    147 	{ 0x1D68A, 0x1D6A5, 0x1D68A },
    148 	{ 0x1D6C2, 0x1D6DA, 0x1D6C2 },
    149 	{ 0x1D6DC, 0x1D6E1, 0x1D6DC },
    150 	{ 0x1D6FC, 0x1D714, 0x1D6FC },
    151 	{ 0x1D716, 0x1D71B, 0x1D716 },
    152 	{ 0x1D736, 0x1D74E, 0x1D736 },
    153 	{ 0x1D750, 0x1D755, 0x1D750 },
    154 	{ 0x1D770, 0x1D788, 0x1D770 },
    155 	{ 0x1D78A, 0x1D78F, 0x1D78A },
    156 	{ 0x1D7AA, 0x1D7C2, 0x1D7AA },
    157 	{ 0x1D7C4, 0x1D7C9, 0x1D7C4 },
    158 	{ 0x1DF00, 0x1DF09, 0x1DF00 },
    159 	{ 0x1DF0B, 0x1DF1E, 0x1DF0B },
    160 	{ 0x1DF25, 0x1DF2A, 0x1DF25 },
    161 	{ 0x1E922, 0x1E943, 0x1E900 },
    162 };
    163 
    164 static const Rune lower1[][2] = {
    165 	{ 0x00B5, 0x039C },
    166 	{ 0x00DF, 0x00DF },
    167 	{ 0x00FF, 0x0178 },
    168 	{ 0x0131, 0x0049 },
    169 	{ 0x0138, 0x0138 },
    170 	{ 0x0149, 0x0149 },
    171 	{ 0x017F, 0x0053 },
    172 	{ 0x0180, 0x0243 },
    173 	{ 0x0188, 0x0187 },
    174 	{ 0x018C, 0x018B },
    175 	{ 0x018D, 0x018D },
    176 	{ 0x0192, 0x0191 },
    177 	{ 0x0195, 0x01F6 },
    178 	{ 0x0199, 0x0198 },
    179 	{ 0x019A, 0x023D },
    180 	{ 0x019B, 0x019B },
    181 	{ 0x019E, 0x0220 },
    182 	{ 0x01A8, 0x01A7 },
    183 	{ 0x01AD, 0x01AC },
    184 	{ 0x01B0, 0x01AF },
    185 	{ 0x01B9, 0x01B8 },
    186 	{ 0x01BA, 0x01BA },
    187 	{ 0x01BD, 0x01BC },
    188 	{ 0x01BE, 0x01BE },
    189 	{ 0x01BF, 0x01F7 },
    190 	{ 0x01C6, 0x01C4 },
    191 	{ 0x01C9, 0x01C7 },
    192 	{ 0x01CC, 0x01CA },
    193 	{ 0x01DD, 0x018E },
    194 	{ 0x01F0, 0x01F0 },
    195 	{ 0x01F3, 0x01F1 },
    196 	{ 0x01F5, 0x01F4 },
    197 	{ 0x0221, 0x0221 },
    198 	{ 0x023C, 0x023B },
    199 	{ 0x0242, 0x0241 },
    200 	{ 0x0250, 0x2C6F },
    201 	{ 0x0251, 0x2C6D },
    202 	{ 0x0252, 0x2C70 },
    203 	{ 0x0253, 0x0181 },
    204 	{ 0x0254, 0x0186 },
    205 	{ 0x0255, 0x0255 },
    206 	{ 0x0258, 0x0258 },
    207 	{ 0x0259, 0x018F },
    208 	{ 0x025A, 0x025A },
    209 	{ 0x025B, 0x0190 },
    210 	{ 0x025C, 0xA7AB },
    211 	{ 0x0260, 0x0193 },
    212 	{ 0x0261, 0xA7AC },
    213 	{ 0x0262, 0x0262 },
    214 	{ 0x0263, 0x0194 },
    215 	{ 0x0264, 0x0264 },
    216 	{ 0x0265, 0xA78D },
    217 	{ 0x0266, 0xA7AA },
    218 	{ 0x0267, 0x0267 },
    219 	{ 0x0268, 0x0197 },
    220 	{ 0x0269, 0x0196 },
    221 	{ 0x026A, 0xA7AE },
    222 	{ 0x026B, 0x2C62 },
    223 	{ 0x026C, 0xA7AD },
    224 	{ 0x026F, 0x019C },
    225 	{ 0x0270, 0x0270 },
    226 	{ 0x0271, 0x2C6E },
    227 	{ 0x0272, 0x019D },
    228 	{ 0x0275, 0x019F },
    229 	{ 0x027D, 0x2C64 },
    230 	{ 0x0280, 0x01A6 },
    231 	{ 0x0281, 0x0281 },
    232 	{ 0x0282, 0xA7C5 },
    233 	{ 0x0283, 0x01A9 },
    234 	{ 0x0287, 0xA7B1 },
    235 	{ 0x0288, 0x01AE },
    236 	{ 0x0289, 0x0244 },
    237 	{ 0x028C, 0x0245 },
    238 	{ 0x0292, 0x01B7 },
    239 	{ 0x0293, 0x0293 },
    240 	{ 0x029D, 0xA7B2 },
    241 	{ 0x029E, 0xA7B0 },
    242 	{ 0x0377, 0x0376 },
    243 	{ 0x0390, 0x0390 },
    244 	{ 0x03AC, 0x0386 },
    245 	{ 0x03B0, 0x03B0 },
    246 	{ 0x03C2, 0x03A3 },
    247 	{ 0x03CC, 0x038C },
    248 	{ 0x03D0, 0x0392 },
    249 	{ 0x03D1, 0x0398 },
    250 	{ 0x03D5, 0x03A6 },
    251 	{ 0x03D6, 0x03A0 },
    252 	{ 0x03D7, 0x03CF },
    253 	{ 0x03F0, 0x039A },
    254 	{ 0x03F1, 0x03A1 },
    255 	{ 0x03F2, 0x03F9 },
    256 	{ 0x03F3, 0x037F },
    257 	{ 0x03F5, 0x0395 },
    258 	{ 0x03F8, 0x03F7 },
    259 	{ 0x03FB, 0x03FA },
    260 	{ 0x03FC, 0x03FC },
    261 	{ 0x04CF, 0x04C0 },
    262 	{ 0x0560, 0x0560 },
    263 	{ 0x1C80, 0x0412 },
    264 	{ 0x1C81, 0x0414 },
    265 	{ 0x1C82, 0x041E },
    266 	{ 0x1C85, 0x0422 },
    267 	{ 0x1C86, 0x042A },
    268 	{ 0x1C87, 0x0462 },
    269 	{ 0x1C88, 0xA64A },
    270 	{ 0x1D79, 0xA77D },
    271 	{ 0x1D7D, 0x2C63 },
    272 	{ 0x1D8E, 0xA7C6 },
    273 	{ 0x1E9B, 0x1E60 },
    274 	{ 0x1E9F, 0x1E9F },
    275 	{ 0x1F50, 0x1F50 },
    276 	{ 0x1F51, 0x1F59 },
    277 	{ 0x1F52, 0x1F52 },
    278 	{ 0x1F53, 0x1F5B },
    279 	{ 0x1F54, 0x1F54 },
    280 	{ 0x1F55, 0x1F5D },
    281 	{ 0x1F56, 0x1F56 },
    282 	{ 0x1F57, 0x1F5F },
    283 	{ 0x1FB2, 0x1FB2 },
    284 	{ 0x1FB3, 0x1FBC },
    285 	{ 0x1FB4, 0x1FB4 },
    286 	{ 0x1FBE, 0x0399 },
    287 	{ 0x1FC2, 0x1FC2 },
    288 	{ 0x1FC3, 0x1FCC },
    289 	{ 0x1FC4, 0x1FC4 },
    290 	{ 0x1FE5, 0x1FEC },
    291 	{ 0x1FF2, 0x1FF2 },
    292 	{ 0x1FF3, 0x1FFC },
    293 	{ 0x1FF4, 0x1FF4 },
    294 	{ 0x210A, 0x210A },
    295 	{ 0x2113, 0x2113 },
    296 	{ 0x212F, 0x212F },
    297 	{ 0x2134, 0x2134 },
    298 	{ 0x2139, 0x2139 },
    299 	{ 0x214E, 0x2132 },
    300 	{ 0x2184, 0x2183 },
    301 	{ 0x2C61, 0x2C60 },
    302 	{ 0x2C65, 0x023A },
    303 	{ 0x2C66, 0x023E },
    304 	{ 0x2C71, 0x2C71 },
    305 	{ 0x2C73, 0x2C72 },
    306 	{ 0x2C74, 0x2C74 },
    307 	{ 0x2C76, 0x2C75 },
    308 	{ 0x2CE4, 0x2CE4 },
    309 	{ 0x2CF3, 0x2CF2 },
    310 	{ 0x2D27, 0x10C7 },
    311 	{ 0x2D2D, 0x10CD },
    312 	{ 0xA78C, 0xA78B },
    313 	{ 0xA78E, 0xA78E },
    314 	{ 0xA794, 0xA7C4 },
    315 	{ 0xA795, 0xA795 },
    316 	{ 0xA7AF, 0xA7AF },
    317 	{ 0xA7D1, 0xA7D0 },
    318 	{ 0xA7D3, 0xA7D3 },
    319 	{ 0xA7D5, 0xA7D5 },
    320 	{ 0xA7F6, 0xA7F5 },
    321 	{ 0xA7FA, 0xA7FA },
    322 	{ 0xAB53, 0xA7B3 },
    323 	{ 0x1D4BB, 0x1D4BB },
    324 	{ 0x1D7CB, 0x1D7CB },
    325 };
    326 
    327 int
    328 islowerrune(Rune r)
    329 {
    330 	const Rune *match;
    331 
    332 	if((match = bsearch(&r, lower4, nelem(lower4), sizeof *lower4, &rune2cmp)))
    333 		return !((r - match[0]) % 2);
    334 	if(bsearch(&r, lower2, nelem(lower2), sizeof *lower2, &rune2cmp))
    335 		return 1;
    336 	if(bsearch(&r, lower1, nelem(lower1), sizeof *lower1, &rune1cmp))
    337 		return 1;
    338 	return 0;
    339 }
    340 
    341 int
    342 toupperrune(Rune r)
    343 {
    344 	Rune *match;
    345 
    346 	match = bsearch(&r, lower4, nelem(lower4), sizeof *lower4, &rune2cmp);
    347 	if (match)
    348 		return ((r - match[0]) % 2) ? r : r - 1;
    349 	match = bsearch(&r, lower2, nelem(lower2), sizeof *lower2, &rune2cmp);
    350 	if (match)
    351 		return match[2] + (r - match[0]);
    352 	match = bsearch(&r, lower1, nelem(lower1), sizeof *lower1, &rune1cmp);
    353 	if (match)
    354 		return match[1];
    355 	return r;
    356 }