od: -l,I,L indeed depend on sizeof(long), fix this
function old new delta .rodata 105255 105252 -3 od_main 1917 1901 -16 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-19) Total: -19 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
5dcc443dba
commit
6d9427420b
3 changed files with 39 additions and 29 deletions
|
@ -170,12 +170,17 @@ static const char *const add_strings[] ALIGN_PTR = {
|
||||||
"4/4 \" %15.7e\"" "\"\n\"", /* 7: f */
|
"4/4 \" %15.7e\"" "\"\n\"", /* 7: f */
|
||||||
"4/4 \" %08x\"" "\"\n\"", /* 8: H, X */
|
"4/4 \" %08x\"" "\"\n\"", /* 8: H, X */
|
||||||
"8/2 \" %04x\"" "\"\n\"", /* 9: h, x */
|
"8/2 \" %04x\"" "\"\n\"", /* 9: h, x */
|
||||||
/* This probably also depends on word width of the arch (what is "long"?) */
|
"4/4 \" %11d\"" "\"\n\"", /* 10: i */
|
||||||
/* should be "2/8" or "4/4" depending on sizeof(long)? */
|
"4/4 \" %011o\"" "\"\n\"", /* 11: O */
|
||||||
"2/8 \" %20lld\"" "\"\n\"", /* 10: I, L, l */
|
"8/2 \" %6d\"" "\"\n\"", /* 12: s */
|
||||||
"4/4 \" %11d\"" "\"\n\"", /* 11: i */
|
/* -I,L,l: depend on word width of the arch (what is "long"?) */
|
||||||
"4/4 \" %011o\"" "\"\n\"", /* 12: O */
|
#if ULONG_MAX > 0xffffffff
|
||||||
"8/2 \" %6d\"" "\"\n\"", /* 13: s */
|
"2/8 \" %20lld\"" "\"\n\"", /* 13: I, L, l */
|
||||||
|
#define L_ 13
|
||||||
|
#else
|
||||||
|
/* 32-bit arch: -I,L,l are the same as -i */
|
||||||
|
#define L_ 10
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char od_opts[] ALIGN1 = "aBbcDdeFfHhIiLlOoXxsv";
|
static const char od_opts[] ALIGN1 = "aBbcDdeFfHhIiLlOoXxsv";
|
||||||
|
@ -183,8 +188,8 @@ static const char od_opts[] ALIGN1 = "aBbcDdeFfHhIiLlOoXxsv";
|
||||||
static const char od_o2si[] ALIGN1 = {
|
static const char od_o2si[] ALIGN1 = {
|
||||||
0, 1, 2, 3, 5, /* aBbcD */
|
0, 1, 2, 3, 5, /* aBbcD */
|
||||||
4, 6, 6, 7, 8, /* deFfH */
|
4, 6, 6, 7, 8, /* deFfH */
|
||||||
9, 10, 11, 10, 10, /* hIiLl */
|
9, L_, 10, L_, L_, /* hIiLl */
|
||||||
12, 1, 8, 9, 13 /* OoXxs */
|
11, 1, 8, 9, 12 /* OoXxs */
|
||||||
};
|
};
|
||||||
|
|
||||||
int od_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
int od_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||||
|
|
|
@ -1257,11 +1257,15 @@ int od_main(int argc UNUSED_PARAM, char **argv)
|
||||||
if (opt & OPT_f) decode_format_string("fF");
|
if (opt & OPT_f) decode_format_string("fF");
|
||||||
if (opt & (OPT_h|OPT_x)) decode_format_string("x2");
|
if (opt & (OPT_h|OPT_x)) decode_format_string("x2");
|
||||||
if (opt & (OPT_H|OPT_X)) decode_format_string("xI");
|
if (opt & (OPT_H|OPT_X)) decode_format_string("xI");
|
||||||
|
/* -I,L,l: depend on word width of the arch (what is "long"?) */
|
||||||
|
#if ULONG_MAX > 0xffffffff
|
||||||
if (opt & OPT_i) decode_format_string("dI");
|
if (opt & OPT_i) decode_format_string("dI");
|
||||||
|
if (opt & (OPT_I|OPT_l|OPT_L)) decode_format_string("dL");
|
||||||
|
#else
|
||||||
|
/* 32-bit arch: -I,L,l are the same as -i */
|
||||||
|
if (opt & (OPT_i|OPT_I|OPT_l|OPT_L)) decode_format_string("dI");
|
||||||
|
#endif
|
||||||
if (opt & OPT_j) n_bytes_to_skip = xstrtooff_sfx(str_j, 0, bkm_suffixes);
|
if (opt & OPT_j) n_bytes_to_skip = xstrtooff_sfx(str_j, 0, bkm_suffixes);
|
||||||
/* This probably also depends on word width of the arch (what is "long"?) */
|
|
||||||
/* should be "d4" or "d8" depending on sizeof(long)? */
|
|
||||||
if (opt & (OPT_I|OPT_l|OPT_L)) decode_format_string("d8");
|
|
||||||
if (opt & (OPT_o|OPT_B)) decode_format_string("o2");
|
if (opt & (OPT_o|OPT_B)) decode_format_string("o2");
|
||||||
if (opt & OPT_O) decode_format_string("oI");
|
if (opt & OPT_O) decode_format_string("oI");
|
||||||
while (lst_t) {
|
while (lst_t) {
|
||||||
|
|
|
@ -8,11 +8,11 @@
|
||||||
|
|
||||||
input="$(printf '\001\002\003\nABC\xfe')"
|
input="$(printf '\001\002\003\nABC\xfe')"
|
||||||
|
|
||||||
le=false
|
little_endian=false
|
||||||
{ printf '\0\1' | od -s | grep -q 256; } && le=true
|
{ printf '\0\1' | od -s | grep -q 256; } && little_endian=true
|
||||||
readonly le
|
readonly little_endian
|
||||||
|
|
||||||
$le || SKIP=1
|
$little_endian || SKIP=1
|
||||||
testing "od (little-endian)" \
|
testing "od (little-endian)" \
|
||||||
"od" \
|
"od" \
|
||||||
"\
|
"\
|
||||||
|
@ -70,7 +70,7 @@ testing "od -B" \
|
||||||
"" "$input"
|
"" "$input"
|
||||||
SKIP=
|
SKIP=
|
||||||
|
|
||||||
$le || SKIP=1
|
$little_endian || SKIP=1
|
||||||
testing "od -o (little-endian)" \
|
testing "od -o (little-endian)" \
|
||||||
"od -o" \
|
"od -o" \
|
||||||
"\
|
"\
|
||||||
|
@ -98,7 +98,7 @@ testing "od -c" \
|
||||||
"" "$input"
|
"" "$input"
|
||||||
SKIP=
|
SKIP=
|
||||||
|
|
||||||
$le || SKIP=1
|
$little_endian || SKIP=1
|
||||||
testing "od -d (little-endian)" \
|
testing "od -d (little-endian)" \
|
||||||
"od -d" \
|
"od -d" \
|
||||||
"\
|
"\
|
||||||
|
@ -108,7 +108,7 @@ testing "od -d (little-endian)" \
|
||||||
"" "$input"
|
"" "$input"
|
||||||
SKIP=
|
SKIP=
|
||||||
|
|
||||||
$le || SKIP=1
|
$little_endian || SKIP=1
|
||||||
testing "od -D (little-endian)" \
|
testing "od -D (little-endian)" \
|
||||||
"od -D" \
|
"od -D" \
|
||||||
"\
|
"\
|
||||||
|
@ -119,7 +119,7 @@ testing "od -D (little-endian)" \
|
||||||
SKIP=
|
SKIP=
|
||||||
|
|
||||||
optional !DESKTOP #DESKTOP: unrecognized option: e
|
optional !DESKTOP #DESKTOP: unrecognized option: e
|
||||||
$le || SKIP=1
|
$little_endian || SKIP=1
|
||||||
testing "od -e (!DESKTOP little-endian)" \
|
testing "od -e (!DESKTOP little-endian)" \
|
||||||
"od -e" \
|
"od -e" \
|
||||||
"\
|
"\
|
||||||
|
@ -130,7 +130,7 @@ testing "od -e (!DESKTOP little-endian)" \
|
||||||
SKIP=
|
SKIP=
|
||||||
|
|
||||||
optional !DESKTOP #DESKTOP: unrecognized option: F
|
optional !DESKTOP #DESKTOP: unrecognized option: F
|
||||||
$le || SKIP=1
|
$little_endian || SKIP=1
|
||||||
testing "od -F (!DESKTOP little-endian)" \
|
testing "od -F (!DESKTOP little-endian)" \
|
||||||
"od -F" \
|
"od -F" \
|
||||||
"\
|
"\
|
||||||
|
@ -140,7 +140,7 @@ testing "od -F (!DESKTOP little-endian)" \
|
||||||
"" "$input"
|
"" "$input"
|
||||||
SKIP=
|
SKIP=
|
||||||
|
|
||||||
$le || SKIP=1
|
$little_endian || SKIP=1
|
||||||
testing "od -f (little-endian)" \
|
testing "od -f (little-endian)" \
|
||||||
"od -f" \
|
"od -f" \
|
||||||
"\
|
"\
|
||||||
|
@ -150,7 +150,7 @@ testing "od -f (little-endian)" \
|
||||||
"" "$input"
|
"" "$input"
|
||||||
SKIP=
|
SKIP=
|
||||||
|
|
||||||
$le || SKIP=1
|
$little_endian || SKIP=1
|
||||||
testing "od -H (little-endian)" \
|
testing "od -H (little-endian)" \
|
||||||
"od -H" \
|
"od -H" \
|
||||||
"\
|
"\
|
||||||
|
@ -160,7 +160,7 @@ testing "od -H (little-endian)" \
|
||||||
"" "$input"
|
"" "$input"
|
||||||
SKIP=
|
SKIP=
|
||||||
|
|
||||||
$le || SKIP=1
|
$little_endian || SKIP=1
|
||||||
testing "od -X (little-endian)" \
|
testing "od -X (little-endian)" \
|
||||||
"od -X" \
|
"od -X" \
|
||||||
"\
|
"\
|
||||||
|
@ -170,7 +170,7 @@ testing "od -X (little-endian)" \
|
||||||
"" "$input"
|
"" "$input"
|
||||||
SKIP=
|
SKIP=
|
||||||
|
|
||||||
$le || SKIP=1
|
$little_endian || SKIP=1
|
||||||
testing "od -h (little-endian)" \
|
testing "od -h (little-endian)" \
|
||||||
"od -h" \
|
"od -h" \
|
||||||
"\
|
"\
|
||||||
|
@ -180,7 +180,7 @@ testing "od -h (little-endian)" \
|
||||||
"" "$input"
|
"" "$input"
|
||||||
SKIP=
|
SKIP=
|
||||||
|
|
||||||
$le || SKIP=1
|
$little_endian || SKIP=1
|
||||||
testing "od -x (little-endian)" \
|
testing "od -x (little-endian)" \
|
||||||
"od -x" \
|
"od -x" \
|
||||||
"\
|
"\
|
||||||
|
@ -190,7 +190,7 @@ testing "od -x (little-endian)" \
|
||||||
"" "$input"
|
"" "$input"
|
||||||
SKIP=
|
SKIP=
|
||||||
|
|
||||||
$le || SKIP=1
|
$little_endian || SKIP=1
|
||||||
testing "od -i (little-endian)" \
|
testing "od -i (little-endian)" \
|
||||||
"od -i" \
|
"od -i" \
|
||||||
"\
|
"\
|
||||||
|
@ -200,7 +200,7 @@ testing "od -i (little-endian)" \
|
||||||
"" "$input"
|
"" "$input"
|
||||||
SKIP=
|
SKIP=
|
||||||
|
|
||||||
$le || SKIP=1
|
$little_endian || SKIP=1
|
||||||
testing "od -O (little-endian)" \
|
testing "od -O (little-endian)" \
|
||||||
"od -O" \
|
"od -O" \
|
||||||
"\
|
"\
|
||||||
|
@ -210,8 +210,9 @@ testing "od -O (little-endian)" \
|
||||||
"" "$input"
|
"" "$input"
|
||||||
SKIP=
|
SKIP=
|
||||||
|
|
||||||
# This probably also depends on word width of the arch (what is "long"?)
|
# 32-bit?
|
||||||
$le || SKIP=1
|
printf '00000000' | od -l | grep -q '808464432 *808464432' && SKIP=1 #yes, skip
|
||||||
|
$little_endian || SKIP=1
|
||||||
testing "od -I (little-endian)" \
|
testing "od -I (little-endian)" \
|
||||||
"od -I" \
|
"od -I" \
|
||||||
"\
|
"\
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue