diff options
author | Bruno Haible <bruno@clisp.org> | 2002-10-14 20:48:02 +0000 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2002-10-14 20:48:02 +0000 |
commit | 7278ae8eda31ecb492c3b3e591b0514cf219aa93 (patch) | |
tree | abcbb9c1952e2d63f80d59fa644f703ec2e9a023 /tests | |
parent | fe3f53d354826293e14a9e08def8b46c68660656 (diff) | |
download | gperf-7278ae8eda31ecb492c3b3e591b0514cf219aa93.tar.gz |
Avoid gcc warnings.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.in | 10 | ||||
-rw-r--r-- | tests/test.c | 22 | ||||
-rw-r--r-- | tests/test2.c | 15 |
3 files changed, 33 insertions, 14 deletions
diff --git a/tests/Makefile.in b/tests/Makefile.in index 9685ef1..adf92e3 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -64,7 +64,7 @@ extracheck : @CHECK_LANG_SYNTAX@ check-link-c: force @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 + $(GPERF) -p -c -l -S1 -I -o $(srcdir)/c.gperf > cinset.c $(CC) $(CFLAGS) -o cout cinset.c test.o check-link-c++: force @@ -75,27 +75,27 @@ check-c: diff $(srcdir)/c.exp c.out check-ada: - $(GPERF) -k1,4,'$$' $(srcdir)/ada.gperf > adainset.c + $(GPERF) -k1,4,'$$' -I $(srcdir)/ada.gperf > adainset.c # double '$$' is only there since make gets confused; program wants only 1 '$' $(CC) $(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 $(srcdir)/ada-res.exp ada-res.out - $(GPERF) -p -D -k1,'$$' -s 2 -o $(srcdir)/adadefs.gperf > preinset.c + $(GPERF) -p -D -k1,'$$' -s 2 -I -o $(srcdir)/adadefs.gperf > preinset.c $(CC) $(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 $(srcdir)/ada-pred.exp ada-pred.out check-modula3: - $(GPERF) -k1,2,'$$' -o $(srcdir)/modula3.gperf > m3inset.c + $(GPERF) -k1,2,'$$' -I -o $(srcdir)/modula3.gperf > m3inset.c $(CC) $(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 $(srcdir)/modula.exp modula.out check-pascal: - $(GPERF) -o -S2 -p < $(srcdir)/pascal.gperf > pinset.c + $(GPERF) -o -S2 -p -I < $(srcdir)/pascal.gperf > pinset.c $(CC) $(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 --git a/tests/test.c b/tests/test.c index 6ae25cb..fcb120c 100644 --- a/tests/test.c +++ b/tests/test.c @@ -5,6 +5,7 @@ */ #include <stdio.h> +#include <string.h> #define MAX_LEN 80 @@ -16,11 +17,22 @@ main (argc, 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); + while (fgets (buf, MAX_LEN, stdin)) + { + if (strlen (buf) > 0 && buf[strlen (buf) - 1] == '\n') + buf[strlen (buf) - 1] = '\0'; + + if (in_word_set (buf, strlen (buf))) + { + if (verbose) + printf ("in word set %s\n", buf); + } + else + { + if (verbose) + printf ("NOT in word set %s\n", buf); + } + } return 0; } diff --git a/tests/test2.c b/tests/test2.c index 023a8ea..1cc8633 100644 --- a/tests/test2.c +++ b/tests/test2.c @@ -49,10 +49,17 @@ main (argc, argv) if (buflen == 0) break; - if (in_word_set (buf, buflen) && verbose) - printf ("in word set:"); - else if (verbose) - printf ("NOT in word set:"); + if (in_word_set (buf, buflen)) + { + if (verbose) + printf ("in word set:"); + } + else + { + if (verbose) + printf ("NOT in word set:"); + } + for (p = buf; p < buf + buflen; p += 2) printf (" %02X%02X", (unsigned char) p[0], (unsigned char) p[1]); printf("\n"); |