sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit 5ae2793da60e06b5d804ca71e355e871166abfe8
parent 8ca79a2993e572beb7be56be1b0b95482c3a2431
Author: Michael Forney <mforney@mforney.org>
Date:   Fri,  8 Jul 2016 10:24:07 -0700

od: Add some missing type flags

Diffstat:
Mod.1 | 17++++++++++++++++-
Mod.c | 36++++++++++++++++++++++++++++++------
2 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/od.1 b/od.1 @@ -6,11 +6,11 @@ .Nd octal dump .Sh SYNOPSIS .Nm +.Op Fl bdosvx .Op Fl A Ar addrformat .Op Fl E | e .Op Fl j Ar skip .Op Fl t Ar outputformat... -.Op Fl v .Op Ar file ... .Sh DESCRIPTION .Nm @@ -34,10 +34,22 @@ Force Little Endian or Big Endian .Fl ( E ) system-independently. +.It Fl b +Equivalent to +.Fl t o1 . +.It Fl d +Equivalent to +.Fl t u2 . .It Fl j Ar skip Ignore the first .Ar skip bytes of input. +.It Fl o +Equivalent to +.Fl t o2 . +.It Fl s +Equivalent to +.Fl t d2 . .It Fl t Ar outputformat .Ar outputformat is a list of a|c|d|o|u|x followed by a digit or C|S|I|L and sets @@ -48,6 +60,9 @@ of \fIC\fRhar, \fIS\fRhort, \fII\fRnteger or \fIL\fRong. The default is octal with 4 bytes. .It Fl v Always set. Write all input data, including duplicate lines. +.It Fl x +Equivalent to +.Fl t x2 . .El .Sh STANDARDS The diff --git a/od.c b/od.c @@ -174,10 +174,21 @@ lcm(unsigned int a, unsigned int b) } static void +addtype(char format, int len) +{ + struct type *t; + + t = emalloc(sizeof(*t)); + t->format = format; + t->len = len; + TAILQ_INSERT_TAIL(&head, t, entry); +} + +static void usage(void) { - eprintf("usage: %s [-A addressformat] [-E | -e] [-j skip] " - "[-t outputformat] [-v] [file ...]\n", argv0); + eprintf("usage: %s [-bdosvx] [-A addressformat] [-E | -e] [-j skip] " + "[-t outputformat] [file ...]\n", argv0); } int @@ -197,6 +208,12 @@ main(int argc, char *argv[]) usage(); addr_format = s[0]; break; + case 'b': + addtype('o', 1); + break; + case 'd': + addtype('u', 2); + break; case 'E': case 'e': big_endian = (ARGC() == 'E'); @@ -209,21 +226,25 @@ main(int argc, char *argv[]) if ((max = parseoffset(EARGF(usage()))) < 0) usage(); break; + case 'o': + addtype('o', 2); + break; + case 's': + addtype('d', 2); + break; case 't': s = EARGF(usage()); for (; *s; s++) { - t = emalloc(sizeof(struct type)); switch (*s) { case 'a': case 'c': - t->format = *s; - t->len = 1; - TAILQ_INSERT_TAIL(&head, t, entry); + addtype(*s, 1); break; case 'd': case 'o': case 'u': case 'x': + t = emalloc(sizeof(*t)); t->format = *s; /* todo: allow multiple digits */ if (*(s+1) > '0' && *(s+1) <= '9') { @@ -256,6 +277,9 @@ main(int argc, char *argv[]) case 'v': /* always set - use uniq(1) to handle duplicate lines */ break; + case 'x': + addtype('x', 2); + break; default: usage(); } ARGEND