# HG changeset patch # User Rob Landley # Date 1349506464 18000 # Node ID 0ee40175a3074da6b7e0d94615b00166cb04e7c2 # Parent 40bc0523ae61cd6476f989ea051d11617add50b6 Fix catv to display byte 255 correctly. (It's both M- and ^?.) diff -r 40bc0523ae61 -r 0ee40175a307 toys/other/catv.c --- a/toys/other/catv.c Fri Oct 05 23:33:36 2012 -0500 +++ b/toys/other/catv.c Sat Oct 06 01:54:24 2012 -0500 @@ -25,6 +25,10 @@ #include "toys.h" +#define FLAG_v 4 +#define FLAG_t 2 +#define FLAG_e 1 + // Callback function for loopfiles() static void do_catv(int fd, char *name) @@ -38,19 +42,20 @@ for (i=0; i 126 && (toys.optflags & 4)) { + if (c > 126 && (toys.optflags & FLAG_v)) { + if (c > 127) { + printf("M-"); + c -= 128; + } if (c == 127) { printf("^?"); continue; - } else { - printf("M-"); - c -= 128; } } if (c < 32) { if (c == 10) { - if (toys.optflags & 1) xputc('$'); - } else if (toys.optflags & (c==9 ? 2 : 4)) { + if (toys.optflags & FLAG_e) xputc('$'); + } else if (toys.optflags & (c==9 ? FLAG_t : FLAG_v)) { printf("^%c", c+'@'); continue; } @@ -62,6 +67,6 @@ void catv_main(void) { - toys.optflags^=4; + toys.optflags ^= FLAG_v; loopfiles(toys.optargs, do_catv); }