1
0
mirror of https://git.savannah.gnu.org/git/gperf.git synced 2025-12-02 13:09:22 +00:00
Files
gperf/tests/permutc2.exp

117 lines
2.8 KiB
Plaintext

/* 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 ((((unsigned char)*str ^ (unsigned char)*s) & ~32) == 0 && !gperf_case_strcmp (str, s))
return s;
}
}
return 0;
}