summaryrefslogtreecommitdiff
path: root/util/sbase/libutf/upperrune.c
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2025-10-04 09:14:33 +0100
committerLeah Rowe <leah@libreboot.org>2025-10-04 09:20:12 +0100
commite9a910b33c7837b4b868e3abda18eb4810df7f02 (patch)
tree749e1830cb0607952df1a1afc0ae09ec1db54140 /util/sbase/libutf/upperrune.c
parent2cfaba181b3c68761871fa47b32725c934423c14 (diff)
config/git: import suckless sbase
i currently use the output of sha512sum in several places of xbmk, which is a bit unreliable in case output changes. other cases where i use util outputs in variables are probably reliable, because i'm using mostly posix utilities in those. to mitigate this, i now import suckless sbase, which has a reasonable sha512sum implementation. *every* binary it builds is being placed in build.list, because i'll probably start using more of them. for example, i may start modifying the "date" implementation, adding the GNU-specific options that i need as mentioned on init.sh i'm importing it in util/ because the sha512sum util is needed for verifying project sources, so if sbase itself is a "project source", that means we can into a chicken and egg bootstrapping problem. this is sbase at revision: 055cc1ae1b3a13c3d8f25af0a4a3316590efcd48 Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/sbase/libutf/upperrune.c')
-rw-r--r--util/sbase/libutf/upperrune.c265
1 files changed, 265 insertions, 0 deletions
diff --git a/util/sbase/libutf/upperrune.c b/util/sbase/libutf/upperrune.c
new file mode 100644
index 00000000..0c874a85
--- /dev/null
+++ b/util/sbase/libutf/upperrune.c
@@ -0,0 +1,265 @@
+/* Automatically generated by mkrunetype.awk */
+#include <stdlib.h>
+
+#include "../utf.h"
+#include "runetype.h"
+
+static const Rune upper3[][2] = {
+ { 0x0100, 0x012E },
+ { 0x0132, 0x0136 },
+ { 0x0139, 0x0147 },
+ { 0x014A, 0x0176 },
+ { 0x0179, 0x017D },
+ { 0x0182, 0x0184 },
+ { 0x01A0, 0x01A4 },
+ { 0x01B3, 0x01B5 },
+ { 0x01CD, 0x01DB },
+ { 0x01DE, 0x01EE },
+ { 0x01F8, 0x021E },
+ { 0x0222, 0x0232 },
+ { 0x0246, 0x024E },
+ { 0x0370, 0x0372 },
+ { 0x03D8, 0x03EE },
+ { 0x0460, 0x0480 },
+ { 0x048A, 0x04BE },
+ { 0x04C1, 0x04CD },
+ { 0x04D0, 0x052E },
+ { 0x1E00, 0x1E94 },
+ { 0x1EA0, 0x1EFE },
+ { 0x2C67, 0x2C6B },
+ { 0x2C80, 0x2CE2 },
+ { 0x2CEB, 0x2CED },
+ { 0xA640, 0xA66C },
+ { 0xA680, 0xA69A },
+ { 0xA722, 0xA72E },
+ { 0xA732, 0xA76E },
+ { 0xA779, 0xA77B },
+ { 0xA77E, 0xA786 },
+ { 0xA790, 0xA792 },
+ { 0xA796, 0xA7A8 },
+ { 0xA7B4, 0xA7C2 },
+ { 0xA7C7, 0xA7C9 },
+ { 0xA7D6, 0xA7D8 },
+};
+
+static const Rune upper2[][3] = {
+ { 0x0041, 0x005A, 0x0061 },
+ { 0x00C0, 0x00D6, 0x00E0 },
+ { 0x00D8, 0x00DE, 0x00F8 },
+ { 0x0189, 0x018A, 0x0256 },
+ { 0x01B1, 0x01B2, 0x028A },
+ { 0x0388, 0x038A, 0x03AD },
+ { 0x038E, 0x038F, 0x03CD },
+ { 0x0391, 0x03A1, 0x03B1 },
+ { 0x03A3, 0x03AB, 0x03C3 },
+ { 0x03D2, 0x03D4, 0x03D2 },
+ { 0x03FD, 0x03FF, 0x037B },
+ { 0x0400, 0x040F, 0x0450 },
+ { 0x0410, 0x042F, 0x0430 },
+ { 0x0531, 0x0556, 0x0561 },
+ { 0x10A0, 0x10C5, 0x2D00 },
+ { 0x13A0, 0x13EF, 0xAB70 },
+ { 0x13F0, 0x13F5, 0x13F8 },
+ { 0x1C90, 0x1CBA, 0x10D0 },
+ { 0x1CBD, 0x1CBF, 0x10FD },
+ { 0x1F08, 0x1F0F, 0x1F00 },
+ { 0x1F18, 0x1F1D, 0x1F10 },
+ { 0x1F28, 0x1F2F, 0x1F20 },
+ { 0x1F38, 0x1F3F, 0x1F30 },
+ { 0x1F48, 0x1F4D, 0x1F40 },
+ { 0x1F68, 0x1F6F, 0x1F60 },
+ { 0x1FB8, 0x1FB9, 0x1FB0 },
+ { 0x1FBA, 0x1FBB, 0x1F70 },
+ { 0x1FC8, 0x1FCB, 0x1F72 },
+ { 0x1FD8, 0x1FD9, 0x1FD0 },
+ { 0x1FDA, 0x1FDB, 0x1F76 },
+ { 0x1FE8, 0x1FE9, 0x1FE0 },
+ { 0x1FEA, 0x1FEB, 0x1F7A },
+ { 0x1FF8, 0x1FF9, 0x1F78 },
+ { 0x1FFA, 0x1FFB, 0x1F7C },
+ { 0x210B, 0x210D, 0x210B },
+ { 0x2110, 0x2112, 0x2110 },
+ { 0x2119, 0x211D, 0x2119 },
+ { 0x212C, 0x212D, 0x212C },
+ { 0x2130, 0x2131, 0x2130 },
+ { 0x213E, 0x213F, 0x213E },
+ { 0x2C00, 0x2C2F, 0x2C30 },
+ { 0x2C7E, 0x2C7F, 0x023F },
+ { 0xFF21, 0xFF3A, 0xFF41 },
+ { 0x10400, 0x10427, 0x10428 },
+ { 0x104B0, 0x104D3, 0x104D8 },
+ { 0x10570, 0x1057A, 0x10597 },
+ { 0x1057C, 0x1058A, 0x105A3 },
+ { 0x1058C, 0x10592, 0x105B3 },
+ { 0x10594, 0x10595, 0x105BB },
+ { 0x10C80, 0x10CB2, 0x10CC0 },
+ { 0x118A0, 0x118BF, 0x118C0 },
+ { 0x16E40, 0x16E5F, 0x16E60 },
+ { 0x1D400, 0x1D419, 0x1D400 },
+ { 0x1D434, 0x1D44D, 0x1D434 },
+ { 0x1D468, 0x1D481, 0x1D468 },
+ { 0x1D49E, 0x1D49F, 0x1D49E },
+ { 0x1D4A5, 0x1D4A6, 0x1D4A5 },
+ { 0x1D4A9, 0x1D4AC, 0x1D4A9 },
+ { 0x1D4AE, 0x1D4B5, 0x1D4AE },
+ { 0x1D4D0, 0x1D4E9, 0x1D4D0 },
+ { 0x1D504, 0x1D505, 0x1D504 },
+ { 0x1D507, 0x1D50A, 0x1D507 },
+ { 0x1D50D, 0x1D514, 0x1D50D },
+ { 0x1D516, 0x1D51C, 0x1D516 },
+ { 0x1D538, 0x1D539, 0x1D538 },
+ { 0x1D53B, 0x1D53E, 0x1D53B },
+ { 0x1D540, 0x1D544, 0x1D540 },
+ { 0x1D54A, 0x1D550, 0x1D54A },
+ { 0x1D56C, 0x1D585, 0x1D56C },
+ { 0x1D5A0, 0x1D5B9, 0x1D5A0 },
+ { 0x1D5D4, 0x1D5ED, 0x1D5D4 },
+ { 0x1D608, 0x1D621, 0x1D608 },
+ { 0x1D63C, 0x1D655, 0x1D63C },
+ { 0x1D670, 0x1D689, 0x1D670 },
+ { 0x1D6A8, 0x1D6C0, 0x1D6A8 },
+ { 0x1D6E2, 0x1D6FA, 0x1D6E2 },
+ { 0x1D71C, 0x1D734, 0x1D71C },
+ { 0x1D756, 0x1D76E, 0x1D756 },
+ { 0x1D790, 0x1D7A8, 0x1D790 },
+ { 0x1E900, 0x1E921, 0x1E922 },
+};
+
+static const Rune upper1[][2] = {
+ { 0x0130, 0x0069 },
+ { 0x0178, 0x00FF },
+ { 0x0181, 0x0253 },
+ { 0x0186, 0x0254 },
+ { 0x0187, 0x0188 },
+ { 0x018B, 0x018C },
+ { 0x018E, 0x01DD },
+ { 0x018F, 0x0259 },
+ { 0x0190, 0x025B },
+ { 0x0191, 0x0192 },
+ { 0x0193, 0x0260 },
+ { 0x0194, 0x0263 },
+ { 0x0196, 0x0269 },
+ { 0x0197, 0x0268 },
+ { 0x0198, 0x0199 },
+ { 0x019C, 0x026F },
+ { 0x019D, 0x0272 },
+ { 0x019F, 0x0275 },
+ { 0x01A6, 0x0280 },
+ { 0x01A7, 0x01A8 },
+ { 0x01A9, 0x0283 },
+ { 0x01AC, 0x01AD },
+ { 0x01AE, 0x0288 },
+ { 0x01AF, 0x01B0 },
+ { 0x01B7, 0x0292 },
+ { 0x01B8, 0x01B9 },
+ { 0x01BC, 0x01BD },
+ { 0x01C4, 0x01C6 },
+ { 0x01C7, 0x01C9 },
+ { 0x01CA, 0x01CC },
+ { 0x01F1, 0x01F3 },
+ { 0x01F4, 0x01F5 },
+ { 0x01F6, 0x0195 },
+ { 0x01F7, 0x01BF },
+ { 0x0220, 0x019E },
+ { 0x023A, 0x2C65 },
+ { 0x023B, 0x023C },
+ { 0x023D, 0x019A },
+ { 0x023E, 0x2C66 },
+ { 0x0241, 0x0242 },
+ { 0x0243, 0x0180 },
+ { 0x0244, 0x0289 },
+ { 0x0245, 0x028C },
+ { 0x0376, 0x0377 },
+ { 0x037F, 0x03F3 },
+ { 0x0386, 0x03AC },
+ { 0x038C, 0x03CC },
+ { 0x03CF, 0x03D7 },
+ { 0x03F4, 0x03B8 },
+ { 0x03F7, 0x03F8 },
+ { 0x03F9, 0x03F2 },
+ { 0x03FA, 0x03FB },
+ { 0x04C0, 0x04CF },
+ { 0x10C7, 0x2D27 },
+ { 0x10CD, 0x2D2D },
+ { 0x1E9E, 0x00DF },
+ { 0x1F59, 0x1F51 },
+ { 0x1F5B, 0x1F53 },
+ { 0x1F5D, 0x1F55 },
+ { 0x1F5F, 0x1F57 },
+ { 0x1FEC, 0x1FE5 },
+ { 0x2102, 0x2102 },
+ { 0x2107, 0x2107 },
+ { 0x2115, 0x2115 },
+ { 0x2124, 0x2124 },
+ { 0x2126, 0x03C9 },
+ { 0x2128, 0x2128 },
+ { 0x212A, 0x006B },
+ { 0x212B, 0x00E5 },
+ { 0x2132, 0x214E },
+ { 0x2133, 0x2133 },
+ { 0x2145, 0x2145 },
+ { 0x2183, 0x2184 },
+ { 0x2C60, 0x2C61 },
+ { 0x2C62, 0x026B },
+ { 0x2C63, 0x1D7D },
+ { 0x2C64, 0x027D },
+ { 0x2C6D, 0x0251 },
+ { 0x2C6E, 0x0271 },
+ { 0x2C6F, 0x0250 },
+ { 0x2C70, 0x0252 },
+ { 0x2C72, 0x2C73 },
+ { 0x2C75, 0x2C76 },
+ { 0x2CF2, 0x2CF3 },
+ { 0xA77D, 0x1D79 },
+ { 0xA78B, 0xA78C },
+ { 0xA78D, 0x0265 },
+ { 0xA7AA, 0x0266 },
+ { 0xA7AB, 0x025C },
+ { 0xA7AC, 0x0261 },
+ { 0xA7AD, 0x026C },
+ { 0xA7AE, 0x026A },
+ { 0xA7B0, 0x029E },
+ { 0xA7B1, 0x0287 },
+ { 0xA7B2, 0x029D },
+ { 0xA7B3, 0xAB53 },
+ { 0xA7C4, 0xA794 },
+ { 0xA7C5, 0x0282 },
+ { 0xA7C6, 0x1D8E },
+ { 0xA7D0, 0xA7D1 },
+ { 0xA7F5, 0xA7F6 },
+ { 0x1D49C, 0x1D49C },
+ { 0x1D4A2, 0x1D4A2 },
+ { 0x1D546, 0x1D546 },
+ { 0x1D7CA, 0x1D7CA },
+};
+
+int
+isupperrune(Rune r)
+{
+ const Rune *match;
+
+ if((match = bsearch(&r, upper3, nelem(upper3), sizeof *upper3, &rune2cmp)))
+ return !((r - match[0]) % 2);
+ if(bsearch(&r, upper2, nelem(upper2), sizeof *upper2, &rune2cmp))
+ return 1;
+ if(bsearch(&r, upper1, nelem(upper1), sizeof *upper1, &rune1cmp))
+ return 1;
+ return 0;
+}
+
+int
+tolowerrune(Rune r)
+{
+ Rune *match;
+
+ match = bsearch(&r, upper3, nelem(upper3), sizeof *upper3, &rune2cmp);
+ if (match)
+ return ((r - match[0]) % 2) ? r : r + 1;
+ match = bsearch(&r, upper2, nelem(upper2), sizeof *upper2, &rune2cmp);
+ if (match)
+ return match[2] + (r - match[0]);
+ match = bsearch(&r, upper1, nelem(upper1), sizeof *upper1, &rune1cmp);
+ if (match)
+ return match[1];
+ return r;
+}