Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

od: make float formats accessible with -t #930

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions bin/od
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ elsif ($opt_e || $opt_F) {
$fmt = \&float8;
}
elsif ($opt_f) {
$fmt = \&float;
$fmt = \&float4;
}
elsif ($opt_H || $opt_X) {
$fmt = \&hex4;
Expand Down Expand Up @@ -189,6 +189,10 @@ if (defined $opt_t) {
$fmt = \&udecimal4;
} elsif ($opt_t eq 'u8') {
$fmt = \&udecimal8;
} elsif ($opt_t eq 'f4') {
$fmt = \&float4;
} elsif ($opt_t eq 'f8') {
$fmt = \&float8;
} elsif ($opt_t eq 'a') {
$fmt = \&char7bit;
} elsif ($opt_t eq 'c') {
Expand Down Expand Up @@ -365,7 +369,7 @@ sub udecimal2 {
$strfmt = '%5u ' x (scalar @arr);
}

sub float {
sub float4 {
@arr = unpack 'f*', $data . zeropad(length($data), 4);
$strfmt = '%15.7e ' x (scalar @arr);
}
Expand Down Expand Up @@ -569,6 +573,8 @@ Select output format as one of the following:
x2 2-byte unsigned hexadecimal
x4 4-byte unsigned hexadecimal
x8 8-byte unsigned hexadecimal
f4 4-byte floating point. Same as -f
f8 8-byte floating point. Same as -F

This option overrides other formatting options.

Expand Down
Loading