diff options
author | Bruno Haible <bruno@clisp.org> | 2000-08-20 20:56:37 +0000 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2000-08-20 20:56:37 +0000 |
commit | baf0680111fae139d200a7a3c0aef0a53a6e3494 (patch) | |
tree | 44d15e78f3d418359319a0be758d1ac6e17232fd /tests | |
parent | ac65860e4b27fb1f332e0b5047ceedc1ab3e47b2 (diff) | |
download | gperf-baf0680111fae139d200a7a3c0aef0a53a6e3494.tar.gz |
Use binary mode for input. Produce prettier output.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test2.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/tests/test2.c b/tests/test2.c index 635794b..023a8ea 100644 --- a/tests/test2.c +++ b/tests/test2.c @@ -6,6 +6,20 @@ #include <stdio.h> +/* Support for SET_BINARY. */ +#include <fcntl.h> +#if !defined O_BINARY && defined _O_BINARY +# define O_BINARY _O_BINARY +#endif +#ifdef __BEOS__ +# undef O_BINARY +#endif +#if O_BINARY +# define SET_BINARY(f) setmode (f, O_BINARY) +#else +# define SET_BINARY(f) (void)0 +#endif + #define MAX_LEN 80 int @@ -17,6 +31,9 @@ main (argc, argv) char buf[2*MAX_LEN]; int buflen; + /* We need to read stdin in binary mode. */ + SET_BINARY (0); + for (;;) { /* Simulate gets(buf) with 2 bytes per character. */ @@ -33,11 +50,11 @@ main (argc, argv) break; if (in_word_set (buf, buflen) && verbose) - printf ("in word set "); + printf ("in word set:"); else if (verbose) - printf ("NOT in word set "); - for (p = buf; p < buf + buflen; p++) - printf ("%02X", (unsigned char) *p); + 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"); } |