Debian Codegraph @

unicode/precompose.c.tail

raw
1 };
2
3 #define UNICODE_SHIFT 21
4
5 int do_precomposition(int base, int comb) {
6 int min = 0;
7 int max = sizeof(precompositions) / sizeof(precompositions[0]) - 1;
8 unsigned long sought = ((unsigned) base << UNICODE_SHIFT) | (unsigned) comb;
9
10 /* binary search */
11 while (max >= min) {
12 int mid = (min + max) / 2;
13 unsigned long that = ((unsigned long) precompositions[mid].base << UNICODE_SHIFT) | ((unsigned) precompositions[mid].comb);
14 if (that < sought) {
15 min = mid + 1;
16 } else if (that > sought) {
17 max = mid - 1;
18 } else {
19 return precompositions[mid].replacement;
20 }
21 }
22 /* no match */
23 return -1;
24 }