summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-06-08 16:51:09 +0200
committerTyge Løvset <[email protected]>2022-06-08 17:10:33 +0200
commit7bbc74bb5c0778504f098974ba79de122cee7211 (patch)
tree79ab1a9ecb8dac5ac287c3b0d8d554c49d60c693
parentfb438a1f2c4275f815cea2fc4f34d3392630b579 (diff)
downloadSTC-modified-7bbc74bb5c0778504f098974ba79de122cee7211.tar.gz
STC-modified-7bbc74bb5c0778504f098974ba79de122cee7211.zip
Fixed char mappings again, and simplified.
-rw-r--r--src/utf8tabs.inc20
-rw-r--r--src/utf8tabs.py44
2 files changed, 32 insertions, 32 deletions
diff --git a/src/utf8tabs.inc b/src/utf8tabs.inc
index e893fade..28f30978 100644
--- a/src/utf8tabs.inc
+++ b/src/utf8tabs.inc
@@ -225,25 +225,25 @@ static struct CaseMapping casemappings[] = {
enum { casefold_len = 192 };
-static uint8_t upcase_ind[162] = {
+static uint8_t upcase_ind[164] = {
0, 2, 3, 4, 192, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 43, 45, 193, 47, 48, 194, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
63, 65, 66, 67, 68, 69, 70, 71, 72, 73, 75, 80, 83, 85, 86, 87, 88, 89, 90, 91,
92, 93, 94, 95, 96, 97, 98, 99, 195, 196, 109, 110, 111, 113, 114, 115, 116, 117, 118, 119,
- 120, 121, 125, 126, 129, 131, 132, 133, 134, 135, 136, 137, 139, 140, 141, 142, 144, 146, 147, 148,
- 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168,
- 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188,
- 189, 191,
+ 120, 121, 125, 126, 129, 131, 132, 133, 134, 135, 136, 137, 139, 140, 141, 142, 143, 144, 145, 146,
+ 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166,
+ 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186,
+ 187, 188, 189, 191,
};
static uint8_t lowcase_ind[186] = {
0, 197, 113, 2, 3, 8, 4, 198, 5, 6, 7, 9, 199, 60, 12, 14, 16, 20, 50, 25,
- 57, 53, 29, 31, 33, 35, 37, 39, 40, 51, 41, 43, 45, 17, 47, 48, 52, 54, 56, 158,
- 59, 63, 154, 152, 155, 11, 13, 15, 18, 19, 174, 21, 175, 22, 170, 173, 24, 23, 177, 148,
- 176, 26, 153, 27, 28, 150, 30, 184, 32, 179, 34, 61, 36, 62, 38, 180, 178, 65, 66, 88,
- 68, 69, 72, 200, 73, 70, 71, 201, 202, 203, 204, 75, 80, 205, 206, 86, 67, 207, 85, 87,
- 90, 89, 91, 92, 94, 93, 95, 96, 109, 110, 190, 100, 196, 208, 209, 210, 211, 212, 213, 214,
+ 57, 53, 29, 31, 33, 35, 37, 39, 40, 51, 41, 43, 45, 193, 17, 47, 48, 194, 52, 54,
+ 56, 158, 59, 63, 154, 152, 155, 11, 13, 15, 18, 19, 174, 21, 175, 22, 170, 173, 24, 23,
+ 177, 148, 176, 26, 153, 27, 28, 150, 30, 184, 32, 179, 34, 61, 36, 62, 38, 180, 178, 65,
+ 66, 88, 68, 69, 72, 200, 73, 70, 71, 201, 202, 203, 204, 75, 80, 205, 206, 86, 67, 207,
+ 85, 87, 90, 89, 91, 92, 94, 93, 95, 96, 109, 110, 196, 208, 209, 210, 211, 212, 213, 214,
215, 167, 149, 185, 111, 216, 114, 115, 116, 117, 118, 119, 120, 121, 126, 129, 132, 136, 134, 137,
122, 123, 124, 125, 127, 217, 130, 131, 133, 135, 138, 142, 143, 144, 145, 146, 147, 55, 58, 151,
156, 157, 159, 160, 161, 97, 98, 99, 162, 163, 164, 165, 166, 168, 169, 171, 183, 172, 182, 186,
diff --git a/src/utf8tabs.py b/src/utf8tabs.py
index f303795c..dfaec055 100644
--- a/src/utf8tabs.py
+++ b/src/utf8tabs.py
@@ -120,41 +120,41 @@ def main():
casefolding_len = len(casemappings)
- # additional Lu => Ll mappings from UnicodeData.txt
+ # add additional Lu => Ll mappings from UnicodeData.txt
+ # create upcase_ind: lower => upper index list sorted by mapped lowercase values:
+ upcase_ind = []
for v in upcase:
- if v not in casemappings:
+ try:
+ upcase_ind.append(casemappings.index(v))
+ except:
+ upcase_ind.append(len(casemappings))
casemappings.append(v)
- # additional Ll => Lu mappings from UnicodeData.txt
+ # add additional Ll => Lu mappings from UnicodeData.txt
+ # create lowcase_ind: upper => lower index list sorted by uppercase values:
+ lowcase_ind = []
for u in lowcase:
v = (u[2] - (u[1] - u[0]), u[2], u[1], '')
- if not any(x[0]==v[0] and x[1]==v[1] and x[2]==v[2] for x in casemappings):
+ try:
+ j = next(i for i,x in enumerate(casemappings) if x[0]==v[0] and x[1]==v[1] and x[2]==v[2])
+ lowcase_ind.append(j)
+ except:
+ lowcase_ind.append(len(casemappings))
casemappings.append(v)
print_table('casemappings', casemappings, style=1)
print('enum { casefold_len = %d };' % casefolding_len)
- # upper => lower index list sorted by uppercase values:
- upcase_ind = []
- for v in upcase:
- upcase_ind.append(casemappings.index(v))
+ # add "missing" mappings:
+ for c in ('Ⅰ', 'Ⓐ'):
+ upcase_ind.append(next(i for i,x in enumerate(casemappings) if x[0]==ord(c)))
+ for c in ('ẞ', 'Ⅰ', 'Ⓐ'):
+ lowcase_ind.append(next(i for i,x in enumerate(casemappings) if x[0]==ord(c)))
+
upcase_ind.sort(key=lambda i: casemappings[i][0])
print_index_table('upcase_ind', upcase_ind)
- # lower => upper index list sorted by mapped lowercase values:
- lowcase_ind = [i for i in range(len(casemappings))]
- lowcase_ind.sort(key=lambda i: casemappings[i][2] - (casemappings[i][1] - casemappings[i][0]))
- # remove redundant mappings from lower to upper
- for i in range(len(lowcase_ind) - 1, 0, -1):
- c1 = casemappings[lowcase_ind[i]]
- v = c1[2] - (c1[1] - c1[0])
- for j in range(i):
- c2 = casemappings[lowcase_ind[j]]
- r1 = c2[2] - (c2[1] - c2[0])
- r2 = c2[2]
- if r1 <= v <= r2:
- del lowcase_ind[i]
- break
+ lowcase_ind.sort(key=lambda i: casemappings[i][2] - (casemappings[i][1] - casemappings[i][0]))
print_index_table('lowcase_ind', lowcase_ind)