sbase

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

upperrune.c (5710B)


      1 /* Automatically generated by mkrunetype.awk */
      2 #include <stdlib.h>
      3 
      4 #include "../utf.h"
      5 #include "runetype.h"
      6 
      7 static 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 };
     41 
     42 static Rune upper2[][3] = {
     43 	{ 0x0041, 0x005A, 0x0061 },
     44 	{ 0x00C0, 0x00D6, 0x00E0 },
     45 	{ 0x00D8, 0x00DE, 0x00F8 },
     46 	{ 0x0189, 0x018A, 0x0256 },
     47 	{ 0x01B1, 0x01B2, 0x028A },
     48 	{ 0x0388, 0x038A, 0x03AD },
     49 	{ 0x038E, 0x038F, 0x03CD },
     50 	{ 0x0391, 0x03A1, 0x03B1 },
     51 	{ 0x03A3, 0x03AB, 0x03C3 },
     52 	{ 0x03D2, 0x03D4, 0x03D2 },
     53 	{ 0x03FD, 0x03FF, 0x037B },
     54 	{ 0x0400, 0x040F, 0x0450 },
     55 	{ 0x0410, 0x042F, 0x0430 },
     56 	{ 0x0531, 0x0556, 0x0561 },
     57 	{ 0x10A0, 0x10C5, 0x2D00 },
     58 	{ 0x1F08, 0x1F0F, 0x1F00 },
     59 	{ 0x1F18, 0x1F1D, 0x1F10 },
     60 	{ 0x1F28, 0x1F2F, 0x1F20 },
     61 	{ 0x1F38, 0x1F3F, 0x1F30 },
     62 	{ 0x1F48, 0x1F4D, 0x1F40 },
     63 	{ 0x1F68, 0x1F6F, 0x1F60 },
     64 	{ 0x1FB8, 0x1FB9, 0x1FB0 },
     65 	{ 0x1FBA, 0x1FBB, 0x1F70 },
     66 	{ 0x1FC8, 0x1FCB, 0x1F72 },
     67 	{ 0x1FD8, 0x1FD9, 0x1FD0 },
     68 	{ 0x1FDA, 0x1FDB, 0x1F76 },
     69 	{ 0x1FE8, 0x1FE9, 0x1FE0 },
     70 	{ 0x1FEA, 0x1FEB, 0x1F7A },
     71 	{ 0x1FF8, 0x1FF9, 0x1F78 },
     72 	{ 0x1FFA, 0x1FFB, 0x1F7C },
     73 	{ 0x210B, 0x210D, 0x210B },
     74 	{ 0x2110, 0x2112, 0x2110 },
     75 	{ 0x2119, 0x211D, 0x2119 },
     76 	{ 0x212C, 0x212D, 0x212C },
     77 	{ 0x2130, 0x2131, 0x2130 },
     78 	{ 0x213E, 0x213F, 0x213E },
     79 	{ 0x2C00, 0x2C2E, 0x2C30 },
     80 	{ 0x2C7E, 0x2C7F, 0x023F },
     81 	{ 0xFF21, 0xFF3A, 0xFF41 },
     82 	{ 0x10400, 0x10427, 0x10428 },
     83 	{ 0x118A0, 0x118BF, 0x118C0 },
     84 	{ 0x1D400, 0x1D419, 0x1D400 },
     85 	{ 0x1D434, 0x1D44D, 0x1D434 },
     86 	{ 0x1D468, 0x1D481, 0x1D468 },
     87 	{ 0x1D49E, 0x1D49F, 0x1D49E },
     88 	{ 0x1D4A5, 0x1D4A6, 0x1D4A5 },
     89 	{ 0x1D4A9, 0x1D4AC, 0x1D4A9 },
     90 	{ 0x1D4AE, 0x1D4B5, 0x1D4AE },
     91 	{ 0x1D4D0, 0x1D4E9, 0x1D4D0 },
     92 	{ 0x1D504, 0x1D505, 0x1D504 },
     93 	{ 0x1D507, 0x1D50A, 0x1D507 },
     94 	{ 0x1D50D, 0x1D514, 0x1D50D },
     95 	{ 0x1D516, 0x1D51C, 0x1D516 },
     96 	{ 0x1D538, 0x1D539, 0x1D538 },
     97 	{ 0x1D53B, 0x1D53E, 0x1D53B },
     98 	{ 0x1D540, 0x1D544, 0x1D540 },
     99 	{ 0x1D54A, 0x1D550, 0x1D54A },
    100 	{ 0x1D56C, 0x1D585, 0x1D56C },
    101 	{ 0x1D5A0, 0x1D5B9, 0x1D5A0 },
    102 	{ 0x1D5D4, 0x1D5ED, 0x1D5D4 },
    103 	{ 0x1D608, 0x1D621, 0x1D608 },
    104 	{ 0x1D63C, 0x1D655, 0x1D63C },
    105 	{ 0x1D670, 0x1D689, 0x1D670 },
    106 	{ 0x1D6A8, 0x1D6C0, 0x1D6A8 },
    107 	{ 0x1D6E2, 0x1D6FA, 0x1D6E2 },
    108 	{ 0x1D71C, 0x1D734, 0x1D71C },
    109 	{ 0x1D756, 0x1D76E, 0x1D756 },
    110 	{ 0x1D790, 0x1D7A8, 0x1D790 },
    111 };
    112 
    113 static Rune upper1[][2] = {
    114 	{ 0x0130, 0x0069 },
    115 	{ 0x0178, 0x00FF },
    116 	{ 0x0181, 0x0253 },
    117 	{ 0x0186, 0x0254 },
    118 	{ 0x0187, 0x0188 },
    119 	{ 0x018B, 0x018C },
    120 	{ 0x018E, 0x01DD },
    121 	{ 0x018F, 0x0259 },
    122 	{ 0x0190, 0x025B },
    123 	{ 0x0191, 0x0192 },
    124 	{ 0x0193, 0x0260 },
    125 	{ 0x0194, 0x0263 },
    126 	{ 0x0196, 0x0269 },
    127 	{ 0x0197, 0x0268 },
    128 	{ 0x0198, 0x0199 },
    129 	{ 0x019C, 0x026F },
    130 	{ 0x019D, 0x0272 },
    131 	{ 0x019F, 0x0275 },
    132 	{ 0x01A6, 0x0280 },
    133 	{ 0x01A7, 0x01A8 },
    134 	{ 0x01A9, 0x0283 },
    135 	{ 0x01AC, 0x01AD },
    136 	{ 0x01AE, 0x0288 },
    137 	{ 0x01AF, 0x01B0 },
    138 	{ 0x01B7, 0x0292 },
    139 	{ 0x01B8, 0x01B9 },
    140 	{ 0x01BC, 0x01BD },
    141 	{ 0x01C4, 0x01C6 },
    142 	{ 0x01C7, 0x01C9 },
    143 	{ 0x01CA, 0x01CC },
    144 	{ 0x01F1, 0x01F3 },
    145 	{ 0x01F4, 0x01F5 },
    146 	{ 0x01F6, 0x0195 },
    147 	{ 0x01F7, 0x01BF },
    148 	{ 0x0220, 0x019E },
    149 	{ 0x023A, 0x2C65 },
    150 	{ 0x023B, 0x023C },
    151 	{ 0x023D, 0x019A },
    152 	{ 0x023E, 0x2C66 },
    153 	{ 0x0241, 0x0242 },
    154 	{ 0x0243, 0x0180 },
    155 	{ 0x0244, 0x0289 },
    156 	{ 0x0245, 0x028C },
    157 	{ 0x0376, 0x0377 },
    158 	{ 0x037F, 0x03F3 },
    159 	{ 0x0386, 0x03AC },
    160 	{ 0x038C, 0x03CC },
    161 	{ 0x03CF, 0x03D7 },
    162 	{ 0x03F4, 0x03B8 },
    163 	{ 0x03F7, 0x03F8 },
    164 	{ 0x03F9, 0x03F2 },
    165 	{ 0x03FA, 0x03FB },
    166 	{ 0x04C0, 0x04CF },
    167 	{ 0x10C7, 0x2D27 },
    168 	{ 0x10CD, 0x2D2D },
    169 	{ 0x1E9E, 0x00DF },
    170 	{ 0x1F59, 0x1F51 },
    171 	{ 0x1F5B, 0x1F53 },
    172 	{ 0x1F5D, 0x1F55 },
    173 	{ 0x1F5F, 0x1F57 },
    174 	{ 0x1FEC, 0x1FE5 },
    175 	{ 0x2102, 0x2102 },
    176 	{ 0x2107, 0x2107 },
    177 	{ 0x2115, 0x2115 },
    178 	{ 0x2124, 0x2124 },
    179 	{ 0x2126, 0x03C9 },
    180 	{ 0x2128, 0x2128 },
    181 	{ 0x212A, 0x006B },
    182 	{ 0x212B, 0x00E5 },
    183 	{ 0x2132, 0x214E },
    184 	{ 0x2133, 0x2133 },
    185 	{ 0x2145, 0x2145 },
    186 	{ 0x2183, 0x2184 },
    187 	{ 0x2C60, 0x2C61 },
    188 	{ 0x2C62, 0x026B },
    189 	{ 0x2C63, 0x1D7D },
    190 	{ 0x2C64, 0x027D },
    191 	{ 0x2C6D, 0x0251 },
    192 	{ 0x2C6E, 0x0271 },
    193 	{ 0x2C6F, 0x0250 },
    194 	{ 0x2C70, 0x0252 },
    195 	{ 0x2C72, 0x2C73 },
    196 	{ 0x2C75, 0x2C76 },
    197 	{ 0x2CF2, 0x2CF3 },
    198 	{ 0xA77D, 0x1D79 },
    199 	{ 0xA78B, 0xA78C },
    200 	{ 0xA78D, 0x0265 },
    201 	{ 0xA7AA, 0x0266 },
    202 	{ 0xA7AB, 0x025C },
    203 	{ 0xA7AC, 0x0261 },
    204 	{ 0xA7AD, 0x026C },
    205 	{ 0xA7B0, 0x029E },
    206 	{ 0xA7B1, 0x0287 },
    207 	{ 0x1D49C, 0x1D49C },
    208 	{ 0x1D4A2, 0x1D4A2 },
    209 	{ 0x1D546, 0x1D546 },
    210 	{ 0x1D7CA, 0x1D7CA },
    211 };
    212 
    213 int
    214 isupperrune(Rune r)
    215 {
    216 	Rune *match;
    217 
    218 	if((match = bsearch(&r, upper3, nelem(upper3), sizeof *upper3, &rune2cmp)))
    219 		return !((r - match[0]) % 2);
    220 	if(bsearch(&r, upper2, nelem(upper2), sizeof *upper2, &rune2cmp))
    221 		return 1;
    222 	if(bsearch(&r, upper1, nelem(upper1), sizeof *upper1, &rune1cmp))
    223 		return 1;
    224 	return 0;
    225 }
    226 
    227 int
    228 tolowerrune(Rune r)
    229 {
    230 	Rune *match;
    231 
    232 	match = bsearch(&r, upper3, nelem(upper3), sizeof *upper3, &rune2cmp);
    233 	if (match)
    234 		return ((r - match[0]) % 2) ? r : r + 1;
    235 	match = bsearch(&r, upper2, nelem(upper2), sizeof *upper2, &rune2cmp);
    236 	if (match)
    237 		return match[2] + (r - match[0]);
    238 	match = bsearch(&r, upper1, nelem(upper1), sizeof *upper1, &rune1cmp);
    239 	if (match)
    240 		return match[1];
    241 	return r;
    242 }