mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 13:09:22 +00:00
New option --ignore-case.
This commit is contained in:
@@ -143,6 +143,8 @@ check-test:
|
||||
diff $(srcdir)/permut2.exp permut2.out
|
||||
$(GPERF) -m5 < $(srcdir)/permut3.gperf > permut3.out
|
||||
diff $(srcdir)/permut3.exp permut3.out
|
||||
$(GPERF) -m5 --ignore-case < $(srcdir)/permutc2.gperf > permutc2.out
|
||||
diff $(srcdir)/permutc2.exp permutc2.out
|
||||
$(GPERF) -C -E -G -I -t < $(srcdir)/charsets.gperf > charsets.out
|
||||
diff $(srcdir)/charsets.exp charsets.out
|
||||
$(GPERF) -C -E -G -I -t < $(srcdir)/languages.gperf > languages.out
|
||||
|
||||
116
tests/permutc2.exp
Normal file
116
tests/permutc2.exp
Normal file
@@ -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;
|
||||
}
|
||||
14
tests/permutc2.gperf
Normal file
14
tests/permutc2.gperf
Normal file
@@ -0,0 +1,14 @@
|
||||
%{
|
||||
/* 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. */
|
||||
%}
|
||||
%%
|
||||
az
|
||||
za
|
||||
ay
|
||||
ya
|
||||
x{
|
||||
x[
|
||||
{w
|
||||
[w
|
||||
@@ -20,6 +20,9 @@ Input file interpretation:
|
||||
is considered part of the type declaration. Key
|
||||
words and additional fields may follow this, one
|
||||
group of fields per line.
|
||||
--ignore-case Consider upper and lower case ASCII characters as
|
||||
equivalent. Note that locale dependent case mappings
|
||||
are ignored.
|
||||
|
||||
Language for the output code:
|
||||
-L, --language=LANGUAGE-NAME
|
||||
|
||||
Reference in New Issue
Block a user