diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2015-09-16 08:47:27 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2015-09-16 08:47:27 +0000 |
commit | 105470812952233563421c73b86898c6d7618322 (patch) | |
tree | d873c1d12787e18d2365b52d0d596b267f729d33 /usr.bin | |
parent | aa40d9fcd10b40f4d3343448eb892a58b93e6353 (diff) |
Fix two bugs (at least 13 year old) of the [+]offset[.][Bb] XSI offset syntax:
Make it work with decimal offsets and with standard input.
Also fix the documentation; it showed the argument in the wrong place.
According to XSI (and our code), it must come *after* the filename,
and it can be used with at most one single filename.
Remove it from the SYNOPSIS; it only provides a subset of -j,
is less standard and contains lots of traps (i counted 7 distinct traps).
Instead, mention it as an alternative below -j where it belongs.
Also fix some markup quirks (that's what originally made me find this mess).
Feedback and OK sobrado@ jmc@.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/hexdump/od.1 | 29 | ||||
-rw-r--r-- | usr.bin/hexdump/odsyntax.c | 8 |
2 files changed, 22 insertions, 15 deletions
diff --git a/usr.bin/hexdump/od.1 b/usr.bin/hexdump/od.1 index b8ba9379b3f..dce74fc0cca 100644 --- a/usr.bin/hexdump/od.1 +++ b/usr.bin/hexdump/od.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: od.1,v 1.30 2014/04/19 09:24:28 sobrado Exp $ +.\" $OpenBSD: od.1,v 1.31 2015/09/16 08:47:26 schwarze Exp $ .\" $NetBSD: od.1,v 1.16 2001/12/07 01:23:42 bjh21 Exp $ .\" .\" Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\"/ -.Dd $Mdocdate: April 19 2014 $ +.Dd $Mdocdate: September 16 2015 $ .Dt OD 1 .Os .Sh NAME @@ -36,22 +36,12 @@ .Nd octal, decimal, hex, ascii dump .Sh SYNOPSIS .Nm od -.Bk -words .Op Fl aBbcDdeFfHhIiLlOosvXx .Op Fl A Ar base .Op Fl j Ar offset .Op Fl N Ar length .Op Fl t Ar type_string -.Sm off -.Oo -.Op Cm \&+ -.Li offset -.Op Cm \&. -.Op Cm Bb -.Sm on -.Oc .Op Ar -.Ek .Sh DESCRIPTION The .Nm @@ -166,6 +156,21 @@ causes it to be interpreted as a multiple of or .Li 1048576 , respectively. +.Pp +As an alternative to +.Nm +.Fl j Ar offset +.Op Ar file , +the X/Open System Interfaces syntax +.Nm +.Op Ar file +.Sm off +.Op Cm \&+ +.Ar offset +.Op Cm \&. +.Op Cm Bb +.Sm on +is also supported. .It Fl L Same as .Fl I . diff --git a/usr.bin/hexdump/odsyntax.c b/usr.bin/hexdump/odsyntax.c index 2854bf00e99..7af2fa5b5d8 100644 --- a/usr.bin/hexdump/odsyntax.c +++ b/usr.bin/hexdump/odsyntax.c @@ -1,4 +1,4 @@ -/* $OpenBSD: odsyntax.c,v 1.25 2014/04/19 09:28:20 sobrado Exp $ */ +/* $OpenBSD: odsyntax.c,v 1.26 2015/09/16 08:47:26 schwarze Exp $ */ /* $NetBSD: odsyntax.c,v 1.15 2001/12/07 15:14:29 bjh21 Exp $ */ /*- @@ -299,7 +299,7 @@ oldusage(void) extern char *__progname; fprintf(stderr, "usage: %s [-aBbcDdeFfHhIiLlOosvXx] [-A base] " "[-j offset] [-N length]\n" - "\t[-t type_string] [[+]offset[.][Bb]] [file ...]\n", __progname); + "\t[-t type_string] [file ...]\n", __progname); exit(1); } @@ -371,6 +371,8 @@ odoffset(int argc, char ***argvp) return; } + if (*p == '.') + ++p; if (*p) { if (*p == 'B') { skip *= 1024; @@ -397,7 +399,7 @@ odoffset(int argc, char ***argvp) } /* Terminate file list. */ - (*argvp)[1] = NULL; + (*argvp)[argc > 1] = NULL; } static void |