Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-05-26 05:27:43 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2023-05-26 05:27:43 +0300
commitaa4d303a3139107919f73cece4eaf85a7dc75db6 (patch)
tree53aa8df516e1f4783ddc6d020c7e200587359356 /coreutils
parent0c3270f7e55e0ca7b8d664851468511d2c8995cf (diff)
od: fix default format, shrink
function old new delta od_main 556 568 +12 .rodata 104613 104555 -58 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 12/-58) Total: -46 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/od.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/coreutils/od.c b/coreutils/od.c
index abedb40a7..3fd241d51 100644
--- a/coreutils/od.c
+++ b/coreutils/od.c
@@ -144,35 +144,36 @@ odoffset(dumper_t *dumper, int argc, char ***argvp)
}
}
-// A format string contains format units separated by whitespace.
+// bb_dump_add():
+// A format string contains format units separated by [optional] whitespace.
// A format unit contains up to three items: an iteration count, a byte count,
// and a format.
-// The iteration count is an optional integer (default 1)
+// The iteration count is an optional integer (default 1).
// Each format is applied iteration count times.
// The byte count is an optional integer. It defines the number
// of bytes to be interpreted by each iteration of the format.
// If an iteration count and/or a byte count is specified, a slash must be
// placed after the iteration count and/or before the byte count
// to disambiguate them.
-// The format is required and must be surrounded by " "s.
-// It is a printf-style format.
+// The printf-style format is required and must be surrounded by " "s.
+// (Below, each string contains two format units)
static const char *const add_strings[] ALIGN_PTR = {
- "16/1 \" %3_u\" \"\\n\"", /* 0: a */
- "8/2 \" %06o\" \"\\n\"", /* 1: B (undocumented in od), o */
- "16/1 \" %03o\" \"\\n\"", /* 2: b */
- "16/1 \" %3_c\" \"\\n\"", /* 3: c */
- "8/2 \" %5u\" \"\\n\"", /* 4: d */
- "4/4 \" %10u\" \"\\n\"", /* 5: D */
- "2/8 \" %24.14e\" \"\\n\"", /* 6: e (undocumented in od), F */
- "4/4 \" %15.7e\" \"\\n\"", /* 7: f */
- "4/4 \" %08x\" \"\\n\"", /* 8: H, X */
- "8/2 \" %04x\" \"\\n\"", /* 9: h, x */
+ "16/1 \" %3_u\"" "\"\n\"", /* 0: a */
+ "8/2 \" %06o\"" "\"\n\"", /* 1: B (undocumented in od), o */
+ "16/1 \" %03o\"" "\"\n\"", /* 2: b */
+ "16/1 \" %3_c\"" "\"\n\"", /* 3: c */
+ "8/2 \" %5u\"" "\"\n\"", /* 4: d */
+ "4/4 \" %10u\"" "\"\n\"", /* 5: D */
+ "2/8 \" %24.14e\"" "\"\n\"", /* 6: e (undocumented in od), F */
+ "4/4 \" %15.7e\"" "\"\n\"", /* 7: f */
+ "4/4 \" %08x\"" "\"\n\"", /* 8: H, X */
+ "8/2 \" %04x\"" "\"\n\"", /* 9: h, x */
/* This probably also depends on word width of the arch (what is "long"?) */
/* should be "2/8" or "4/4" depending on sizeof(long)? */
- "2/8 \" %20lld\" \"\\n\"", /* 10: I, L, l */
- "4/4 \" %11d\" \"\\n\"", /* 11: i */
- "4/4 \" %011o\" \"\\n\"", /* 12: O */
- "8/2 \" %6d\" \"\\n\"", /* 13: s */
+ "2/8 \" %20lld\"" "\"\n\"", /* 10: I, L, l */
+ "4/4 \" %11d\"" "\"\n\"", /* 11: i */
+ "4/4 \" %011o\"" "\"\n\"", /* 12: O */
+ "8/2 \" %6d\"" "\"\n\"", /* 13: s */
};
static const char od_opts[] ALIGN1 = "aBbcDdeFfHhIiLlOoXxsv";
@@ -204,13 +205,14 @@ int od_main(int argc, char **argv)
bb_dump_add(dumper, "\" \"");
}
bb_dump_add(dumper, add_strings[(int)od_o2si[(p - od_opts)]]);
- } else { /* P, p, s, w, or other unhandled */
+ } else { /* P, p, w, or other unhandled */
bb_show_usage();
}
}
if (!dumper->fshead) {
bb_dump_add(dumper, "\"%07.7_Ao\n\"");
- bb_dump_add(dumper, "\"%07.7_ao \" 8/2 \"%06o \" \"\\n\"");
+ bb_dump_add(dumper, "\"%07.7_ao\"");
+ bb_dump_add(dumper, add_strings[1]); /* -o format is default */
}
dumper->od_eofstring = "\n";