aboutsummaryrefslogtreecommitdiff
path: root/toys/other
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-10-06 01:54:24 -0500
committerRob Landley <rob@landley.net>2012-10-06 01:54:24 -0500
commita54733f76575e6e391da0f4735f847f4bb14efe5 (patch)
tree23b517ace3fcbeca472402e170bb2dd4bd793056 /toys/other
parenta631a3b45b72e54b75758150eba5fc99e85cee7c (diff)
downloadtoybox-a54733f76575e6e391da0f4735f847f4bb14efe5.tar.gz
Fix catv to display byte 255 correctly. (It's both M- and ^?.)
Diffstat (limited to 'toys/other')
-rw-r--r--toys/other/catv.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/toys/other/catv.c b/toys/other/catv.c
index db54b997..221549f3 100644
--- a/toys/other/catv.c
+++ b/toys/other/catv.c
@@ -25,6 +25,10 @@ config CATV
#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 @@ static void do_catv(int fd, char *name)
for (i=0; i<len; i++) {
char c=toybuf[i];
- if (c > 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 @@ static void do_catv(int fd, char *name)
void catv_main(void)
{
- toys.optflags^=4;
+ toys.optflags ^= FLAG_v;
loopfiles(toys.optargs, do_catv);
}