My S-CText (on sourceforge DOT net SLASH p SLASH s-ctext SLASH
code SLASH) tests all 0x10 code points correct with the
above. Now when i look at the sys/src/libc/port/runetype.c (of
plan9front) then i think this one is generated, but i cannot find
the creating script or program, which would be of interest to me.
And maybe Plan9 would be interested to see the above patched into
that, at some later time. ?
Thank you and ciao,
that's close to the approach taken, except since one needs
a fresh table for each sorting if one hopes to do a binary search,
simple tables of (various width) integers were made. it was also
noted that bursting the tables at the junction of the basic and
extended plans was possible in many cases.
for example, for decompositions if r is a precombined form,
and r is in the basic frame then for r = r' + c, r' and c are both
in the basic plane. thus we can burst this table, and put
basic plane mappings (1000 of them) in a more compact table
that doesn't use vlongs. the extended plane table is tiny
(18 entries). it's only worth using a binary search for symmetry.
static
uint__decompose2[] =
{
0x00c0, 0x00410300, /* À - A 0300 */
[... 998 entries skipped ... ]
0xfb4e, 0x05e405bf, /* פֿ - פ 05bf */
}
static
uvlong __decompose264[] =
{
0x1109a,0x11099110baull, /* ႚ - ႙ + 110ba */
[... 16 entries skipped ...]
0x1d1c0,0x1d1bc1d16full, /* 퇀 - 톼 + 1d16f */
};
static uint*
bsearch32(uint c, uint *t, int n, int ne)
{
uint *p;
int m;
while(n 1) {
m = n/2;
p = t + m*ne;
if(c = p[0]) {
t = p;
n = n-m;
} else
n = m;
}
if(n c == t[0])
return t;
return 0;
}
[bsearch64 omitted]
int
runedecompose(Rune a, Rune *d)
{
uint *p;
uvlong *q;
if(a = 0x){
p = bsearch32(a, __decompose2, nelem(__decompose2)/2, 2);
if(p){
d[0] = p[1] 16;
d[1] = p[1] 0x;
return 0;
}
}else{
q = bsearch64(a, __decompose264, nelem(__decompose264)/2, 2);
if(q){
d[0] = q[1] 32;
d[1] = q[1] 0xfff;
return 0;
}
}
return -1;
}
all the other rune tables work this way. there is one
table per property. having a structure doesn't fit the
current programming interface, nor usage.
- erik