From e0b950c73c3a3f643d8d11ae261017f9d9b22884 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 26 Jun 2012 20:45:56 -0500 Subject: Longer usage line and combine ascii[] into a single string. --- toys/od.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'toys') diff --git a/toys/od.c b/toys/od.c index 8f91bece..1f77e140 100644 --- a/toys/od.c +++ b/toys/od.c @@ -12,7 +12,7 @@ config OD bool "od" default y help - usage: od + usage: od [-bdosxv] [-j #] [-N #] [-A arg] [-t arg] */ #include "toys.h" @@ -39,11 +39,8 @@ DEFINE_GLOBALS( #define TT this.od -static const char *ascii[] = { - "nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel", "bs", "ht", - "nl", "vt", "ff", "cr", "so", "si", "dle", "dc1", "dc2", "dc3", "dc4", - "nak", "syn", "etb", "can", "em", "sub", "esc", "fs", "gs", "rs", - "us", "sp"}; +static const char *ascii = "nulsohstxetceotenqackbel bs ht nl vt ff cr so si" + "deldc1dc2dc3dc4naksynetbcan emsubesc fs gs rs us sp"; static void display_line_1(char base, off_t offset, uint8_t *line, int len) { @@ -51,12 +48,9 @@ static void display_line_1(char base, off_t offset, uint8_t *line, int len) switch (base) { case 'a': { int ch = *line & 0x7f; - if (ch < sizeof(ascii)/sizeof(ascii[0])) - printf(" %3s", ascii[ch]); - else if (ch == 127) - printf(" del"); - else - printf(" %c", ch); + if (ch <= 32) printf(" %.3s", ascii+(3*ch)); + else if (ch == 127) printf(" del"); + else printf("%4c", ch); break; } case 'o': printf(" %3.3o", *line); break; -- cgit v1.2.3