diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-23 13:31:46 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-23 13:31:46 +0000 |
commit | 2dbeaa95ca2c22c5e37f62b01e4324a308f0140f (patch) | |
tree | d2fdc741e672c456fc9dccdc357befa111822045 /util-linux/hexdump.c | |
parent | a36a676923a674e35aae65faaa169fab9d765023 (diff) | |
download | busybox-w32-2dbeaa95ca2c22c5e37f62b01e4324a308f0140f.tar.gz busybox-w32-2dbeaa95ca2c22c5e37f62b01e4324a308f0140f.tar.bz2 busybox-w32-2dbeaa95ca2c22c5e37f62b01e4324a308f0140f.zip |
hexdump: deindent, almost fits into 80 columns now
Diffstat (limited to 'util-linux/hexdump.c')
-rw-r--r-- | util-linux/hexdump.c | 66 |
1 files changed, 32 insertions, 34 deletions
diff --git a/util-linux/hexdump.c b/util-linux/hexdump.c index c2d79da5b..3798ce5d2 100644 --- a/util-linux/hexdump.c +++ b/util-linux/hexdump.c | |||
@@ -33,11 +33,11 @@ static void bb_dump_addfile(char *name) | |||
33 | } | 33 | } |
34 | 34 | ||
35 | static const char * const add_strings[] = { | 35 | static const char * const add_strings[] = { |
36 | "\"%07.7_ax \" 16/1 \"%03o \" \"\\n\"", /* b */ | 36 | "\"%07.7_ax \" 16/1 \"%03o \" \"\\n\"", /* b */ |
37 | "\"%07.7_ax \" 16/1 \"%3_c \" \"\\n\"", /* c */ | 37 | "\"%07.7_ax \" 16/1 \"%3_c \" \"\\n\"", /* c */ |
38 | "\"%07.7_ax \" 8/2 \" %05u \" \"\\n\"", /* d */ | 38 | "\"%07.7_ax \" 8/2 \" %05u \" \"\\n\"", /* d */ |
39 | "\"%07.7_ax \" 8/2 \" %06o \" \"\\n\"", /* o */ | 39 | "\"%07.7_ax \" 8/2 \" %06o \" \"\\n\"", /* o */ |
40 | "\"%07.7_ax \" 8/2 \" %04x \" \"\\n\"", /* x */ | 40 | "\"%07.7_ax \" 8/2 \" %04x \" \"\\n\"", /* x */ |
41 | }; | 41 | }; |
42 | 42 | ||
43 | static const char add_first[] = "\"%07.7_Ax\n\""; | 43 | static const char add_first[] = "\"%07.7_Ax\n\""; |
@@ -53,7 +53,6 @@ static const struct suffix_mult suffixes[] = { | |||
53 | 53 | ||
54 | int hexdump_main(int argc, char **argv) | 54 | int hexdump_main(int argc, char **argv) |
55 | { | 55 | { |
56 | // register FS *tfs; | ||
57 | const char *p; | 56 | const char *p; |
58 | int ch; | 57 | int ch; |
59 | 58 | ||
@@ -61,34 +60,33 @@ int hexdump_main(int argc, char **argv) | |||
61 | bb_dump_length = -1; | 60 | bb_dump_length = -1; |
62 | 61 | ||
63 | while ((ch = getopt(argc, argv, hexdump_opts)) > 0) { | 62 | while ((ch = getopt(argc, argv, hexdump_opts)) > 0) { |
64 | if ((p = strchr(hexdump_opts, ch)) != NULL) { | 63 | p = strchr(hexdump_opts, ch) |
65 | if ((p - hexdump_opts) < 5) { | 64 | if (!p) |
66 | bb_dump_add(add_first); | ||
67 | bb_dump_add(add_strings[(int)(p - hexdump_opts)]); | ||
68 | } else if (ch == 'C') { | ||
69 | bb_dump_add("\"%08.8_Ax\n\""); | ||
70 | bb_dump_add("\"%08.8_ax \" 8/1 \"%02x \" \" \" 8/1 \"%02x \" "); | ||
71 | bb_dump_add("\" |\" 16/1 \"%_p\" \"|\\n\""); | ||
72 | } else { | ||
73 | /* Sae a little bit of space below by omitting the 'else's. */ | ||
74 | if (ch == 'e') { | ||
75 | bb_dump_add(optarg); | ||
76 | } /* else */ | ||
77 | if (ch == 'f') { | ||
78 | bb_dump_addfile(optarg); | ||
79 | } /* else */ | ||
80 | if (ch == 'n') { | ||
81 | bb_dump_length = bb_xgetularg10_bnd(optarg, 0, INT_MAX); | ||
82 | } /* else */ | ||
83 | if (ch == 's') { | ||
84 | bb_dump_skip = bb_xgetularg_bnd_sfx(optarg, 10, 0, LONG_MAX, suffixes); | ||
85 | } /* else */ | ||
86 | if (ch == 'v') { | ||
87 | bb_dump_vflag = ALL; | ||
88 | } | ||
89 | } | ||
90 | } else { | ||
91 | bb_show_usage(); | 65 | bb_show_usage(); |
66 | if ((p - hexdump_opts) < 5) { | ||
67 | bb_dump_add(add_first); | ||
68 | bb_dump_add(add_strings[(int)(p - hexdump_opts)]); | ||
69 | } else if (ch == 'C') { | ||
70 | bb_dump_add("\"%08.8_Ax\n\""); | ||
71 | bb_dump_add("\"%08.8_ax \" 8/1 \"%02x \" \" \" 8/1 \"%02x \" "); | ||
72 | bb_dump_add("\" |\" 16/1 \"%_p\" \"|\\n\""); | ||
73 | } else { | ||
74 | /* Save a little bit of space below by omitting the 'else's. */ | ||
75 | if (ch == 'e') { | ||
76 | bb_dump_add(optarg); | ||
77 | } /* else */ | ||
78 | if (ch == 'f') { | ||
79 | bb_dump_addfile(optarg); | ||
80 | } /* else */ | ||
81 | if (ch == 'n') { | ||
82 | bb_dump_length = bb_xgetularg10_bnd(optarg, 0, INT_MAX); | ||
83 | } /* else */ | ||
84 | if (ch == 's') { | ||
85 | bb_dump_skip = bb_xgetularg_bnd_sfx(optarg, 10, 0, LONG_MAX, suffixes); | ||
86 | } /* else */ | ||
87 | if (ch == 'v') { | ||
88 | bb_dump_vflag = ALL; | ||
89 | } | ||
92 | } | 90 | } |
93 | } | 91 | } |
94 | 92 | ||
@@ -99,5 +97,5 @@ int hexdump_main(int argc, char **argv) | |||
99 | 97 | ||
100 | argv += optind; | 98 | argv += optind; |
101 | 99 | ||
102 | return(bb_dump_dump(argv)); | 100 | return bb_dump_dump(argv); |
103 | } | 101 | } |