summaryrefslogtreecommitdiff
path: root/apps/gperf
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1998-06-06 23:57:57 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1998-06-06 23:57:57 +0000
commitac8c5ebe02f83c6321e2582ab4a28e069e2280b4 (patch)
tree60fcb57af2a579fa09339f193fb8a89992abcc9a /apps/gperf
parentde45428024aa207b28928a0d047de9820a1cc282 (diff)
downloadATCD-ac8c5ebe02f83c6321e2582ab4a28e069e2280b4.tar.gz
*** empty log message ***
Diffstat (limited to 'apps/gperf')
-rw-r--r--apps/gperf/tests/Makefile (renamed from apps/gperf/tests/Makefile.in)44
-rw-r--r--apps/gperf/tests/configure.in26
-rw-r--r--apps/gperf/tests/test-1.exp16
-rw-r--r--apps/gperf/tests/test-2.exp16
-rw-r--r--apps/gperf/tests/test-3.exp12
-rw-r--r--apps/gperf/tests/test-4.exp22
-rw-r--r--apps/gperf/tests/test-5.exp14
-rw-r--r--apps/gperf/tests/test.c28
-rw-r--r--apps/gperf/tests/test.cpp27
9 files changed, 83 insertions, 122 deletions
diff --git a/apps/gperf/tests/Makefile.in b/apps/gperf/tests/Makefile
index f702fc804f2..3a29a573a2d 100644
--- a/apps/gperf/tests/Makefile.in
+++ b/apps/gperf/tests/Makefile
@@ -1,3 +1,4 @@
+# $Id: Makefile 1.1 10/18/96
# Copyright (C) 1989, 1992, 1993 Free Software Foundation, Inc.
# written by Douglas C. Schmidt (schmidt@ics.uci.edu)
#
@@ -17,56 +18,59 @@
# along with GNU GPERF; see the file COPYING. If not, write to the Free
# Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA.
-srcdir = .
+#----------------------------------------------------------------------------
+# Include macros and targets
+#----------------------------------------------------------------------------
-#### package, host, target, and site dependent Makefile fragments come in here.
-##
+include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU
+srcdir = .
GPERF = ../src/gperf
check:
@echo "performing some tests of the perfect hash generator"
- $(CC) -c $(CFLAGS) $(srcdir)/test.c
- $(GPERF) -p -c -l -S1 -o $(srcdir)/c.gperf > cinset.c
- $(CC) $(CFLAGS) -o cout cinset.c test.o
+ $(CXX) -c $(CFLAGS) $(srcdir)/test.cpp
+ $(GPERF) -a -p -c -l -S1 -o $(srcdir)/c.gperf > cinset.cpp
+ $(CXX) $(CFLAGS) -o cout cinset.c test.o
@echo "testing ANSI C reserved words, all items should be found in the set"
./cout -v < $(srcdir)/c.gperf > c.out
-diff -b $(srcdir)/c.exp c.out
- $(GPERF) -k1,4,'$$' $(srcdir)/ada.gperf > adainset.c
+ $(GPERF) -a -k1,4,'$$' $(srcdir)/ada.gperf > adainset.c
# double '$$' is only there since make gets confused; programn wants only 1 '$'
- $(CC) $(CFLAGS) -o aout adainset.c test.o
+ $(CXX) $(CFLAGS) -o aout adainset.c test.o
@echo "testing Ada reserved words, all items should be found in the set"
./aout -v < $(srcdir)/ada.gperf > ada-res.out
-diff -b $(srcdir)/ada-res.exp ada-res.out
- $(GPERF) -p -D -k1,'$$' -s 2 -o $(srcdir)/adadefs.gperf > preinset.c
- $(CC) $(CFLAGS) -o preout preinset.c test.o
+ $(GPERF) -a -p -D -k1,'$$' -s 2 -o $(srcdir)/adadefs.gperf > preinset.c
+ $(CXX) $(CFLAGS) -o preout preinset.c test.o
@echo "testing Ada predefined words, all items should be found in the set"
./preout -v < $(srcdir)/adadefs.gperf > ada-pred.out
-diff -b $(srcdir)/ada-pred.exp ada-pred.out
- $(GPERF) -k1,2,'$$' -o $(srcdir)/modula3.gperf > m3inset.c
- $(CC) $(CFLAGS) -o m3out m3inset.c test.o
+ $(GPERF) -a -k1,2,'$$' -o $(srcdir)/modula3.gperf > m3inset.c
+ $(CXX) $(CFLAGS) -o m3out m3inset.c test.o
@echo "testing Modula3 reserved words, all items should be found in the set"
./m3out -v < $(srcdir)/modula3.gperf > modula.out
-diff -b $(srcdir)/modula.exp modula.out
- $(GPERF) -o -S2 -p < $(srcdir)/pascal.gperf > pinset.c
- $(CC) $(CFLAGS) -o pout pinset.c test.o
+ $(GPERF) -a -o -S2 -p < $(srcdir)/pascal.gperf > pinset.c
+ $(CXX) $(CFLAGS) -o pout pinset.c test.o
@echo "testing Pascal reserved words, all items should be found in the set"
./pout -v < $(srcdir)/pascal.gperf > pascal.out
-diff -b $(srcdir)/pascal.exp pascal.out
# these next 5 are demos that show off the generated code
- $(GPERF) -p -j1 -g -o -t -N is_reserved_word -k1,3,'$$' < $(srcdir)/c-parse.gperf > test-1.out
+ $(GPERF) -a -p -j1 -g -o -t -N is_reserved_word -k1,3,'$$' < $(srcdir)/c-parse.gperf > test-1.out
-diff -b $(srcdir)/test-1.exp test-1.out
- $(GPERF) -n -k1-8 -l <$(srcdir)/modula2.gperf > test-2.out
+ $(GPERF) -a -n -k1-8 -l <$(srcdir)/modula2.gperf > test-2.out
-diff -b $(srcdir)/test-2.exp test-2.out
- $(GPERF) -p -j 1 -o -a -C -g -t -k1,4,$$ < $(srcdir)/gplus.gperf > test-3.out
+ $(GPERF) -a -p -j 1 -o -a -C -g -t -k1,4,$$ < $(srcdir)/gplus.gperf > test-3.out
-diff -b $(srcdir)/test-3.exp test-3.out
- $(GPERF) -D -p -t < $(srcdir)/c-parse.gperf > test-4.out
+ $(GPERF) -a -D -p -t < $(srcdir)/c-parse.gperf > test-4.out
-diff -b $(srcdir)/test-4.exp test-4.out
- $(GPERF) -g -o -j1 -t -p -N is_reserved_word < $(srcdir)/gpc.gperf > test-5.out
+ $(GPERF) -a -g -o -j1 -t -p -N is_reserved_word < $(srcdir)/gpc.gperf > test-5.out
-diff -b $(srcdir)/test-5.exp test-5.out
# prints out the help message
- -$(GPERF) -h > test-6.out 2>&1 || [ a = a ]
+ -$(GPERF) -a -h > test-6.out 2>&1 || [ a = a ]
-diff -b $(srcdir)/test-6.exp test-6.out
@echo "only if, do, for, case, goto, else, while, and return should be found "
./aout -v < $(srcdir)/c.gperf > test-7.out
-diff -b $(srcdir)/test-7.exp test-7.out
+
diff --git a/apps/gperf/tests/configure.in b/apps/gperf/tests/configure.in
deleted file mode 100644
index d93c7bb1840..00000000000
--- a/apps/gperf/tests/configure.in
+++ /dev/null
@@ -1,26 +0,0 @@
-# This file is a shell script fragment that supplies the information
-# necessary to tailor a template configure script into the configure
-# script appropriate for this directory. For more information, check
-# any existing configure script.
-
-configdirs=""
-srctrigger=c-parse.gperf
-srcname="test perfect hash function generator"
-
-target_makefile_frag=../../target-mkfrag
-package_makefile_frag=Make.pack
-
-# per-host:
-
-# per-target:
-
-TOLIBGXX=../../
-ALL='$(NOTHING)'
-CHECK=check
-MOSTLYCLEAN='*.o \#* core *inset.c output.* *.out aout cout m3out pout preout'
-
-(. ${srcdir}/../../config.shared) >${package_makefile_frag}
-
-# post-target:
-
-rm -f ${package_makefile_frag}
diff --git a/apps/gperf/tests/test-1.exp b/apps/gperf/tests/test-1.exp
index 5788cf7dfc3..af77997a6a3 100644
--- a/apps/gperf/tests/test-1.exp
+++ b/apps/gperf/tests/test-1.exp
@@ -1,6 +1,6 @@
/* C code produced by gperf version 2.5 (GNU C++ version) */
/* Command-line: ../src/gperf -p -j1 -g -o -t -N is_reserved_word -k1,3,$ */
-/* Command-line: gperf -p -j1 -i 1 -g -o -t -N is_reserved_word -k1,3,$ c-parse.gperf */
+/* Command-line: gperf -a -p -j1 -i 1 -g -o -t -N is_reserved_word -k1,3,$ c-parse.gperf */
struct resword { char *name; short token; enum rid rid; };
#define TOTAL_KEYWORDS 51
@@ -14,9 +14,7 @@ struct resword { char *name; short token; enum rid rid; };
inline
#endif
static unsigned int
-hash (str, len)
- register char *str;
- register int unsigned len;
+hash (char *str, unsigned int len)
{
static unsigned char asso_values[] =
{
@@ -34,7 +32,7 @@ hash (str, len)
26, 30, 31, 83, 15, 1, 0, 28, 13, 4,
83, 83, 5, 83, 83, 83, 83, 83,
};
- register int hval = len;
+ int hval = len;
switch (hval)
{
@@ -53,9 +51,7 @@ hash (str, len)
inline
#endif
struct resword *
-is_reserved_word (str, len)
- register char *str;
- register unsigned int len;
+is_reserved_word (char *str, unsigned int len)
{
static struct resword wordlist[] =
{
@@ -126,11 +122,11 @@ is_reserved_word (str, len)
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
- register int key = hash (str, len);
+ int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
{
- register char *s = wordlist[key].name;
+ char *s = wordlist[key].name;
if (*s == *str && !strcmp (str + 1, s + 1))
return &wordlist[key];
diff --git a/apps/gperf/tests/test-2.exp b/apps/gperf/tests/test-2.exp
index f74124155eb..967b6d18eea 100644
--- a/apps/gperf/tests/test-2.exp
+++ b/apps/gperf/tests/test-2.exp
@@ -1,5 +1,5 @@
/* C code produced by gperf version 2.5 (GNU C++ version) */
-/* Command-line: ../src/gperf -n -k1-8 -l */
+/* Command-line: ../src/gperf -a -n -k1-8 -l */
#define TOTAL_KEYWORDS 40
#define MIN_WORD_LENGTH 2
@@ -9,9 +9,7 @@
/* maximum key range = 256, duplicates = 0 */
static unsigned int
-hash (str, len)
- register char *str;
- register int unsigned len;
+hash (char *str, unsigned int len)
{
static unsigned short asso_values[] =
{
@@ -29,7 +27,7 @@ hash (str, len)
257, 257, 257, 257, 257, 257, 257, 257, 257, 257,
257, 257, 257, 257, 257, 257, 257, 257,
};
- register int hval = 0;
+ int hval = 0;
switch (len)
{
@@ -56,9 +54,7 @@ hash (str, len)
}
char *
-in_word_set (str, len)
- register char *str;
- register unsigned int len;
+in_word_set (char *str, unsigned int len)
{
static unsigned char lengthtable[] =
@@ -168,11 +164,11 @@ in_word_set (str, len)
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
- register int key = hash (str, len);
+ int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
{
- register char *s = wordlist[key];
+ char *s = wordlist[key];
if (len == lengthtable[key]
&& *s == *str && !strcmp (str + 1, s + 1))
diff --git a/apps/gperf/tests/test-3.exp b/apps/gperf/tests/test-3.exp
index 5e889020657..2706ba19558 100644
--- a/apps/gperf/tests/test-3.exp
+++ b/apps/gperf/tests/test-3.exp
@@ -1,6 +1,6 @@
/* C code produced by gperf version 2.5 (GNU C++ version) */
/* Command-line: ../src/gperf -p -j 1 -o -a -C -g -t -k1,4,$ */
-/* Command-line: gperf -p -j1 -g -o -t -N is_reserved_word -k1,4,$ gplus.gperf */
+/* Command-line: gperf -a -p -j1 -g -o -t -N is_reserved_word -k1,4,$ gplus.gperf */
struct resword { char *name; short token; enum rid rid;};
#define TOTAL_KEYWORDS 71
@@ -14,7 +14,7 @@ struct resword { char *name; short token; enum rid rid;};
inline
#endif
static unsigned int
-hash (register const char *str, register int len)
+hash (const char *str, int len)
{
static const unsigned char asso_values[] =
{
@@ -32,7 +32,7 @@ hash (register const char *str, register int len)
20, 15, 42, 148, 31, 5, 26, 39, 32, 10,
148, 40, 148, 148, 148, 148, 148, 148,
};
- register int hval = len;
+ int hval = len;
switch (hval)
{
@@ -52,7 +52,7 @@ hash (register const char *str, register int len)
inline
#endif
const struct resword *
-in_word_set (register const char *str, register int len)
+in_word_set (const char *str, int len)
{
static const struct resword wordlist[] =
{
@@ -155,11 +155,11 @@ in_word_set (register const char *str, register int len)
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
- register int key = hash (str, len);
+ int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
{
- register const char *s = wordlist[key].name;
+ const char *s = wordlist[key].name;
if (*s == *str && !strcmp (str + 1, s + 1))
return &wordlist[key];
diff --git a/apps/gperf/tests/test-4.exp b/apps/gperf/tests/test-4.exp
index 5238bf94d98..d72a5b69d81 100644
--- a/apps/gperf/tests/test-4.exp
+++ b/apps/gperf/tests/test-4.exp
@@ -1,6 +1,6 @@
/* C code produced by gperf version 2.5 (GNU C++ version) */
/* Command-line: ../src/gperf -D -p -t */
-/* Command-line: gperf -p -j1 -i 1 -g -o -t -N is_reserved_word -k1,3,$ c-parse.gperf */
+/* Command-line: gperf -a -p -j1 -i 1 -g -o -t -N is_reserved_word -k1,3,$ c-parse.gperf */
struct resword { char *name; short token; enum rid rid; };
#define TOTAL_KEYWORDS 51
@@ -11,9 +11,7 @@ struct resword { char *name; short token; enum rid rid; };
/* maximum key range = 79, duplicates = 2 */
static unsigned int
-hash (str, len)
- register char *str;
- register int unsigned len;
+hash (char *str, unsigned int len)
{
static unsigned char asso_values[] =
{
@@ -35,9 +33,7 @@ hash (str, len)
}
struct resword *
-in_word_set (str, len)
- register char *str;
- register unsigned int len;
+in_word_set (char *str, unsigned int len)
{
static struct resword wordlist[] =
{
@@ -107,15 +103,15 @@ in_word_set (str, len)
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
- register int key = hash (str, len);
+ int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
{
- register int index = lookup[key];
+ int index = lookup[key];
if (index >= 0 && index < MAX_HASH_VALUE)
{
- register char *s = wordlist[index].name;
+ char *s = wordlist[index].name;
if (*s == *str && !strcmp (str + 1, s + 1))
return &wordlist[index];
@@ -124,9 +120,9 @@ in_word_set (str, len)
return 0;
else
{
- register int offset = key + index + (index > 0 ? -MAX_HASH_VALUE : MAX_HASH_VALUE);
- register struct resword *base = &wordlist[-lookup[offset]];
- register struct resword *ptr = base + -lookup[offset + 1];
+ int offset = key + index + (index > 0 ? -MAX_HASH_VALUE : MAX_HASH_VALUE);
+ struct resword *base = &wordlist[-lookup[offset]];
+ struct resword *ptr = base + -lookup[offset + 1];
while (--ptr >= base)
if (*str == *ptr->name && !strcmp (str + 1, ptr->name + 1))
diff --git a/apps/gperf/tests/test-5.exp b/apps/gperf/tests/test-5.exp
index 101e2798d40..5fc90576223 100644
--- a/apps/gperf/tests/test-5.exp
+++ b/apps/gperf/tests/test-5.exp
@@ -1,5 +1,5 @@
/* C code produced by gperf version 2.5 (GNU C++ version) */
-/* Command-line: ../src/gperf -g -o -j1 -t -p -N is_reserved_word */
+/* Command-line: ../src/gperf -a -g -o -j1 -t -p -N is_reserved_word */
/* ISO Pascal 7185 reserved words.
*
* For GNU Pascal compiler (GPC) by jtv@hut.fi
@@ -22,9 +22,7 @@ struct resword { char *name; short token; short iclass;};
inline
#endif
static unsigned int
-hash (str, len)
- register char *str;
- register int unsigned len;
+hash (char *str, unsigned int len)
{
static unsigned char asso_values[] =
{
@@ -49,9 +47,7 @@ hash (str, len)
inline
#endif
struct resword *
-is_reserved_word (str, len)
- register char *str;
- register unsigned int len;
+is_reserved_word (char *str, unsigned int len)
{
static struct resword wordlist[] =
{
@@ -97,11 +93,11 @@ is_reserved_word (str, len)
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
- register int key = hash (str, len);
+ int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
{
- register char *s = wordlist[key].name;
+ char *s = wordlist[key].name;
if (*s == *str && !strcmp (str + 1, s + 1))
return &wordlist[key];
diff --git a/apps/gperf/tests/test.c b/apps/gperf/tests/test.c
deleted file mode 100644
index 35d9015bba7..00000000000
--- a/apps/gperf/tests/test.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-// @(#)test.c 1.1 10/18/96
-
- Tests the generated perfect has function.
- The -v option prints diagnostics as to whether a word is in
- the set or not. Without -v the program is useful for timing.
-*/
-
-#include <stdio.h>
-
-#define MAX_LEN 80
-
-int
-main (argc, argv)
- int argc;
- char *argv[];
-{
- int verbose = argc > 1 ? 1 : 0;
- char buf[MAX_LEN];
-
- while (gets (buf))
- if (in_word_set (buf, strlen (buf)) && verbose)
- printf ("in word set %s\n", buf);
- else if (verbose)
- printf ("NOT in word set %s\n", buf);
-
- return 0;
-}
diff --git a/apps/gperf/tests/test.cpp b/apps/gperf/tests/test.cpp
new file mode 100644
index 00000000000..2278306de6d
--- /dev/null
+++ b/apps/gperf/tests/test.cpp
@@ -0,0 +1,27 @@
+// $Id: test.cpp 1.1 10/18/96
+
+// Tests the generated perfect has function.
+// The -v option prints diagnostics as to whether a word is in
+// the set or not. Without -v the program is useful for timing.
+
+#include <stdio.h>
+#include <string.h>
+
+static const int MAX_LEN = 80;
+
+char *in_word_set (char *str, unsigned int len);
+
+int
+main (int argc, char *argv[])
+{
+ int verbose = argc > 1 && strcmp (argv[1], "-v") ? 1 : 0;
+ char buf[MAX_LEN];
+
+ while (fgets (buf, sizeof buf, stdin) != 0)
+ if (in_word_set (buf, strlen (buf)) && verbose)
+ printf ("in word set %s\n", buf);
+ else if (verbose)
+ printf ("NOT in word set %s\n", buf);
+
+ return 0;
+}