4b402165ef5ae64b80252fd192d6217416665818
[platform/upstream/glibc.git] / locale / programs / charmap-kw.h
1 /* ANSI-C code produced by gperf version 2.7.1 (19981006 egcs) */
2 /* Command-line: gperf -acCgopt -k1,2,5,9,$ -L ANSI-C -N charmap_hash programs/charmap-kw.gperf  */
3 /* Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
4    This file is part of the GNU C Library.
5    Contributed by Ulrich Drepper, <drepper@gnu.org>.
6
7    The GNU C Library is free software; you can redistribute it and/or
8    modify it under the terms of the GNU Library General Public License as
9    published by the Free Software Foundation; either version 2 of the
10    License, or (at your option) any later version.
11
12    The GNU C Library is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    Library General Public License for more details.
16
17    You should have received a copy of the GNU Library General Public
18    License along with the GNU C Library; see the file COPYING.LIB.  If not,
19    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20    Boston, MA 02111-1307, USA.  */
21
22 #include <string.h>
23
24 #include "locfile-token.h"
25 struct keyword_t ;
26
27 #define TOTAL_KEYWORDS 17
28 #define MIN_WORD_LENGTH 3
29 #define MAX_WORD_LENGTH 14
30 #define MIN_HASH_VALUE 3
31 #define MAX_HASH_VALUE 35
32 /* maximum key range = 33, duplicates = 0 */
33
34 #ifdef __GNUC__
35 __inline
36 #endif
37 static unsigned int
38 hash (register const char *str, register unsigned int len)
39 {
40   static const unsigned char asso_values[] =
41     {
42       36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
43       36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
44       36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
45       36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
46       36, 36, 36, 36, 36, 36, 36, 36, 25, 10,
47       15, 20, 36, 36, 36, 36, 36, 36, 36, 36,
48       36, 36, 36, 36, 36, 36, 36, 10,  0,  0,
49        5, 36,  0,  0, 36, 36, 36,  0,  0, 36,
50        0, 36,  0, 36,  0, 36, 36,  0, 36, 36,
51       36, 36, 36, 36, 36,  0, 36,  0,  0,  0,
52       10,  0, 36,  0,  0,  0, 36, 36, 36,  0,
53        0,  0,  0,  0,  0,  0,  0,  0, 36, 36,
54       25, 36, 36, 36, 36, 36, 36, 36, 36, 36,
55       36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
56       36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
57       36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
58       36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
59       36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
60       36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
61       36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
62       36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
63       36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
64       36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
65       36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
66       36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
67       36, 36, 36, 36, 36, 36
68     };
69   register int hval = len;
70
71   switch (hval)
72     {
73       default:
74       case 9:
75         hval += asso_values[(unsigned char)str[8]];
76       case 8:
77       case 7:
78       case 6:
79       case 5:
80         hval += asso_values[(unsigned char)str[4]];
81       case 4:
82       case 3:
83       case 2:
84         hval += asso_values[(unsigned char)str[1]];
85       case 1:
86         hval += asso_values[(unsigned char)str[0]];
87         break;
88     }
89   return hval + asso_values[(unsigned char)str[len - 1]];
90 }
91
92 #ifdef __GNUC__
93 __inline
94 #endif
95 const struct keyword_t *
96 charmap_hash (register const char *str, register unsigned int len)
97 {
98   static const struct keyword_t wordlist[] =
99     {
100       {""}, {""}, {""},
101       {"END",             tok_end,             0},
102       {""},
103       {"WIDTH",           tok_width,           0},
104       {"escseq",          tok_escseq,          1},
105       {"include",         tok_include,         1},
106       {""}, {""},
107       {"mb_cur_min",      tok_mb_cur_min,      1},
108       {"escape_char",     tok_escape_char,     1},
109       {"comment_char",    tok_comment_char,    1},
110       {"code_set_name",   tok_code_set_name,   1},
111       {"WIDTH_VARIABLE",  tok_width_variable,  0},
112       {"g1esc",           tok_g1esc,           1},
113       {"addset",          tok_addset,          1},
114       {"CHARMAP",         tok_charmap,         0},
115       {"WIDTH_DEFAULT",   tok_width_default,   0},
116       {""},
117       {"g2esc",           tok_g2esc,           1},
118       {""}, {""}, {""}, {""},
119       {"g3esc",           tok_g3esc,           1},
120       {""}, {""}, {""}, {""},
121       {"g0esc",           tok_g0esc,           1},
122       {""}, {""}, {""}, {""},
123       {"mb_cur_max",      tok_mb_cur_max,      1}
124     };
125
126   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
127     {
128       register int key = hash (str, len);
129
130       if (key <= MAX_HASH_VALUE && key >= 0)
131         {
132           register const char *s = wordlist[key].name;
133
134           if (*str == *s && !strncmp (str + 1, s + 1, len - 1))
135             return &wordlist[key];
136         }
137     }
138   return 0;
139 }