7 /* Do case-insensitive lookup of key[0:keylen] in t[0:n] (key part), */
8 /* returning 1 if found, 0 if not. */
9 /* Array t must be sorted in increasing lexicographic order of key. */
10 /* If found, return corresponding val in *pans. */
12 _lookup(StringInt* t, int n, Rune* key, int keylen, int* pans)
23 cmpresult = _Strncmpci(key, keylen, t[try].key);
26 else if(cmpresult < 0)
36 /* Return first key in t[0:n] that corresponds to val, */
39 _revlookup(StringInt* t, int n, int val)
43 for(i = 0; i < n; i++)
49 /* Make a StringInt table out of a[0:n], mapping each string */
50 /* to its index. Check that entries are in alphabetical order. */
52 _makestrinttab(Rune** a, int n)
57 ans = (StringInt*)emalloc(n * sizeof(StringInt));
58 for(i = 0; i < n; i++) {
61 assert(i == 0 || runestrcmp(a[i], a[i - 1]) >= 0);