diff --git a/ChangeLog b/ChangeLog index da9b42f..bebb329 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-10-03 Bruno Haible + + * tests/Makefile.in: Use gperf option -I, to avoid gcc-3.x warnings. + * tests/test.c: Don't use gets(), to avoid warnings. + 2001-08-02 Bruno Haible * doc/gperf.texi: Change bug report address to . 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 +#include #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");