diff options
Diffstat (limited to 'tests/permutc2.exp')
-rw-r--r-- | tests/permutc2.exp | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/tests/permutc2.exp b/tests/permutc2.exp new file mode 100644 index 0000000..02632d5 --- /dev/null +++ b/tests/permutc2.exp @@ -0,0 +1,116 @@ +/* C code produced by gperf version 2.7.2 */ +/* Command-line: ../src/gperf -m5 --ignore-case */ +/* Computed positions: -k'1-2' */ + +/* Test of a hash function which has to deal with permutation and + case-independence. Without case-independence, the alpha_inc is 1. + With case-independence, the alpha_inc is 3. */ + +#define TOTAL_KEYWORDS 8 +#define MIN_WORD_LENGTH 2 +#define MAX_WORD_LENGTH 2 +#define MIN_HASH_VALUE 2 +#define MAX_HASH_VALUE 9 +/* maximum key range = 8, duplicates = 0 */ + +#ifndef GPERF_CASE_STRCMP +#define GPERF_CASE_STRCMP 1 +static int +gperf_case_strcmp (s1, s2) + register const char *s1; + register const char *s2; +{ + for (;;) + { + unsigned char c1 = *s1++; + unsigned char c2 = *s2++; + if (c1 >= 'A' && c1 <= 'Z') + c1 += 'a' - 'A'; + if (c2 >= 'A' && c2 <= 'Z') + c2 += 'a' - 'A'; + if (c1 != 0 && c1 == c2) + continue; + return (int)c1 - (int)c2; + } +} +#endif + +#ifdef __GNUC__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static unsigned int +hash (str, len) + register const char *str; + register unsigned int len; +{ + static unsigned char asso_values[] = + { + 10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10, 1,10,10, 3,10, + 10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, 3, 1, + 0, 7, 1, 0, 3,10,10, 1,10,10, + 3,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10, + 3, 1, 0, 0, 1, 0, 2,10,10,10, + 10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10,10 + }; + return len + asso_values[(unsigned char)str[1]+3] + asso_values[(unsigned char)str[0]]; +} + +#ifdef __GNUC__ +__inline +#endif +const char * +in_word_set (str, len) + register const char *str; + register unsigned int len; +{ + static const char * wordlist[] = + { + "", "", + "{w", + "az", + "ay", + "za", + "ya", + "x{", + "x[", + "[w" + }; + + if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) + { + register int key = hash (str, len); + + if (key <= MAX_HASH_VALUE && key >= 0) + { + register const char *s = wordlist[key]; + + if (*str == *s && !gperf_case_strcmp (str + 1, s + 1)) + return s; + } + } + return 0; +} |