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: add -D option #939

Merged
merged 1 commit into from
Jan 31, 2025
Merged
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
21 changes: 14 additions & 7 deletions bin/od
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ use constant EX_FAILURE => 1;
use constant LINESZ => 16;
use constant PRINTMAX => 126;

use vars qw/ $opt_A $opt_a $opt_B $opt_b $opt_c $opt_d $opt_e $opt_F $opt_f
$opt_H $opt_h $opt_i $opt_j $opt_l $opt_N $opt_O $opt_o $opt_s $opt_t
$opt_v $opt_X $opt_x /;
use vars qw/ $opt_A $opt_a $opt_B $opt_b $opt_c $opt_D $opt_d $opt_e $opt_F
$opt_f $opt_H $opt_h $opt_i $opt_j $opt_l $opt_N $opt_O $opt_o $opt_s
$opt_t $opt_v $opt_X $opt_x /;

our $VERSION = '1.3';
our $VERSION = '1.4';

my ($offset1, $radix, $data, @arr, $lim);
my ($lastline, $strfmt, $ml);
Expand Down Expand Up @@ -87,7 +87,7 @@ $lastline = '';

my $Program = basename($0);

getopts('A:aBbcdeFfHhij:lN:Oost:vXx') or help();
getopts('A:aBbcDdeFfHhij:lN:Oost:vXx') or help();
if (defined $opt_A) {
if ($opt_A !~ m/\A[doxn]\z/) {
warn "$Program: unexpected radix: '$opt_A'\n";
Expand Down Expand Up @@ -125,6 +125,9 @@ elsif ($opt_b) {
elsif ($opt_c) {
$fmt = \&char1;
}
elsif ($opt_D) {
$fmt = \&udecimal4;
}
elsif ($opt_d) {
$fmt = \&udecimal2;
}
Expand Down Expand Up @@ -452,7 +455,7 @@ sub diffdata {
}

sub help {
print "usage: od [-aBbcdeFfHhilOosXxv] [-A radix] [-j skip_bytes] ",
print "usage: od [-aBbcDdeFfHhilOosXxv] [-A radix] [-j skip_bytes] ",
"[-N limit_bytes] [-t type] [file]...\n";
exit EX_FAILURE;
}
Expand All @@ -464,7 +467,7 @@ od - dump files in octal and other formats

=head1 SYNOPSIS

B<od> [ I<-aBbcdeFfHhilOosXxv> ] [I<-j skip_bytes>] [I<-N limit_bytes>]
B<od> [ I<-aBbcDdeFfHhilOosXxv> ] [I<-j skip_bytes>] [I<-N limit_bytes>]
[ I<-A radix> ] [ I<-t type> ] [ F<file>... ]

=head1 DESCRIPTION
Expand Down Expand Up @@ -503,6 +506,10 @@ Single-byte octal display.

Display characters literally, with non-printable characters displayed as C escape sequences.

=item -D

Four-byte unsigned decimal display.

=item -d

Two-byte unsigned decimal display.
Expand Down
Loading