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 +/* Support for SET_BINARY. */ +#include +#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"); }