6 * The code makes two assumptions: strlen(ld) is 1 or 2; latintab[i].ld can be a
7 * prefix of latintab[j].ld only when j<i.
11 char *ld; /* must be seen before using this conversion */
12 char *si; /* options for last input characters */
13 Rune so[60]; /* the corresponding Rune for each si entry */
20 * Given 5 characters k[0]..k[n], find the rune or return -1 for failure.
23 unicode(Rune *k, int n)
28 for(i=0; i<n; i++,k++){
30 if('0'<=*k && *k<='9')
32 else if('a'<=*k && *k<='f')
34 else if('A'<=*k && *k<='F')
45 * Given n characters k[0]..k[n-1], find the corresponding rune or return -1 for
46 * failure, or something < -1 if n is too small. In the latter case, the result
47 * is minus the required n.
50 latin1(Rune *k, int n)
64 if(unicode(k+3, n-3) < 0)
68 return unicode(k+3, 6);
71 if(unicode(k+2, n-2) < 0)
75 return unicode(k+2, 5);
78 if(unicode(k+1, n-1) < 0)
82 return unicode(k+1, 4);
85 for(l=latintab; l->ld!=0; l++)
91 else if(l->ld[1] != k[1])
97 for(p=l->si; *p!=0; p++)
99 return l->so[p - l->si];