Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / dthelp / parser / canon1 / util / trieplk.c
1 /* $XConsortium: trieplk.c /main/3 1995/11/08 09:56:28 rswiston $ */
2 /*
3                    Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
4 */
5
6 /* Trie.c contains procedures for maintaining the tree structure
7    used to store element names, delimiter strings, short reference strings,
8    etc. */
9
10 #include <stdio.h>
11 #include "basic.h"
12 #include "common.h"
13 #include "trie.h"
14
15 extern M_CHARTYPE m_ctarray[M_CHARSETLEN] ;
16
17 int m_packedlook(
18 #if defined(M_PROTO)
19   M_PTRIE *xptrie,
20   M_WCHAR *name
21 #endif
22   ) ;
23
24 /* Look for the string NAME in the packed trie PTRIE */
25 int m_packedlook(xptrie, name)
26 M_PTRIE *xptrie ;
27 M_WCHAR *name ;
28 {
29 int current = 0 ;
30 int i ;
31 int c ;
32
33 for ( ; TRUE ; name++)
34     {
35     c = m_ctupper(*name) ;
36     for (i = current ;
37          (int) ((xptrie + i)->symbol) < c && (xptrie + i)->more ;
38          i++) ;
39     if ((int) ((xptrie + i)->symbol) == c)
40         {
41         if (! c) return((xptrie + i)->index) ;
42         current = (xptrie + i)->index ;
43         }
44     else return(FALSE) ;
45     }
46 }