summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2003-04-02 09:26:05 +0000
committerBruno Haible <bruno@clisp.org>2003-04-02 09:26:05 +0000
commit7dfd32b7366488cb992d82266b2652bb99e98fdb (patch)
tree1793f77161bf1293814505f0af09f4cf96a18ab4 /tests
parent0093e3316356271066b5df254ff193cdbc74b905 (diff)
downloadgperf-7dfd32b7366488cb992d82266b2652bb99e98fdb.tar.gz
New option --ignore-case.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.in2
-rw-r--r--tests/permutc2.exp116
-rw-r--r--tests/permutc2.gperf14
-rw-r--r--tests/test-6.exp3
4 files changed, 135 insertions, 0 deletions
diff --git a/tests/Makefile.in b/tests/Makefile.in
index c857fc4..c7c3c37 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.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
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;
+}
diff --git a/tests/permutc2.gperf b/tests/permutc2.gperf
new file mode 100644
index 0000000..223a193
--- /dev/null
+++ b/tests/permutc2.gperf
@@ -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
diff --git a/tests/test-6.exp b/tests/test-6.exp
index 14cd1d7..cabbe9c 100644
--- a/tests/test-6.exp
+++ b/tests/test-6.exp
@@ -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