public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hexdump: adjust -s and -n option in the man page [was: hexsyntax.c using strtol on the offset parameter]
@ 2012-03-22 11:58 Bernhard Voelker
  2012-03-23 17:19 ` Karel Zak
  0 siblings, 1 reply; 8+ messages in thread
From: Bernhard Voelker @ 2012-03-22 11:58 UTC (permalink / raw)
  To: Karel Zak, Simon de Vlieger, util-linux@vger.kernel.org

Karel Zak wrote:

> Fixed. The code (as well as -n) was stupid. Now it supports all
> possible suffixes (K,M,G,T,P,E,Y,Z) and the number is parsed as
> uintmax_t.

btw: it should read "...P,E,Z,Y", as Y>Z.

The man page is outdated now:

       -n length
              Interpret only length bytes of input.
       ...
       -s offset
              Skip  offset bytes from the beginning of the input.  By default,
              offset is interpreted as a decimal number.  With a leading 0x or
              0X,  offset  is  interpreted as a hexadecimal number, otherwise,
              with a leading 0, offset is  interpreted  as  an  octal  number.
              Appending  the  character  b,  k, or m to offset causes it to be
              interpreted as a multiple of  512,  1024,  or  1048576,  respec-
              tively.

The variant with 0x or 0X doesn't seem to work anyway:

$ echo 123456789abcdefghijk > /tmp/x
$ text-utils/hexdump -s 0x1 -n 1 -c /tmp/x
0000001   2
0000002

Below follows a proposal for a man page patch.

Have a nice day,
Berny

>From f546c9d7bdd52b2e57761c2c97a701e662d89bc1 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <mail@bernhard-voelker.de>
Date: Thu, 22 Mar 2012 12:53:06 +0100
Subject: [PATCH] hexdump: adjust -s and -n option in the man page

Remove note about hexadecimal and octal interpretation of -s value.
Mention the optional suffix notation for -n and -s  like <x>B or <x>iB
with <x> in K,M,G,T,P,E,Z,Y.

Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
---
 text-utils/hexdump.1 |   33 +++++++++------------------------
 1 files changed, 9 insertions(+), 24 deletions(-)

diff --git a/text-utils/hexdump.1 b/text-utils/hexdump.1
index cbb14fb..4a373de 100644
--- a/text-utils/hexdump.1
+++ b/text-utils/hexdump.1
@@ -80,7 +80,8 @@ are ignored.
 .BI \-n \ length
 Interpret only
 .I length
-bytes of input.
+.B BYTES
+of input.
 .TP
 .B \-o
 \fITwo-byte octal display\fR.  Display the input offset in hexadecimal,
@@ -90,29 +91,8 @@ quantities of input data, in octal, per line.
 .BI \-s \ offset
 Skip
 .I offset
-bytes from the beginning of the input.  By default,
-.I offset
-is interpreted as a decimal number.  With a leading
-.B 0x
-or
-.BR 0X ,
-.I offset
-is interpreted as a hexadecimal number, otherwise, with a leading
-.BR 0 ,
-.I offset
-is interpreted as an octal number.  Appending the character
-.BR b ,
-.BR k ,
-or
-.B m
-to
-.I offset
-causes it to be interpreted as a multiple of
-.IR 512 ,
-.IR 1024 ,
-or
-.IR 1048576 ,
-respectively.
+.B BYTES
+from the beginning of the input.
 .TP
 .B \-v
 The
@@ -138,6 +118,11 @@ according to the format strings specified by the
 and
 .B \-f
 options, in the order that they were specified.
+.PP
+.B BYTES
+is a decimal number and may be followed by the following multiplicative
+suffixes: KB =1000, KiB =1024, MB =1000*1000, MiB =1024*1024,
+GB =1000*1000*1000, GiB =1024*1024*1024, and so on for T, P, E, Z, Y.
 .SH FORMATS
 A format string contains any number of format units, separated by whitespace.
 A format unit contains up to three items: an iteration count, a byte count,
-- 
1.7.7





^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-03-30 13:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-22 11:58 [PATCH] hexdump: adjust -s and -n option in the man page [was: hexsyntax.c using strtol on the offset parameter] Bernhard Voelker
2012-03-23 17:19 ` Karel Zak
2012-03-26  7:20   ` mail
2012-03-26  8:41     ` Karel Zak
2012-03-26  9:39   ` mail
2012-03-26  9:50     ` mail
2012-03-30 13:34       ` Karel Zak
2012-03-30 13:26     ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox