aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-06-26 20:45:56 -0500
committerRob Landley <rob@landley.net>2012-06-26 20:45:56 -0500
commite0b950c73c3a3f643d8d11ae261017f9d9b22884 (patch)
tree8ce90509b3752ddbf3cfafd51c9d5dea23d77112 /toys
parent319791b923060182bd9c35747ca79f7a43021a96 (diff)
downloadtoybox-e0b950c73c3a3f643d8d11ae261017f9d9b22884.tar.gz
Longer usage line and combine ascii[] into a single string.
Diffstat (limited to 'toys')
-rw-r--r--toys/od.c18
1 files changed, 6 insertions, 12 deletions
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;