aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--uxd.117
-rw-r--r--uxd.c3
-rw-r--r--uxd.rst17
3 files changed, 23 insertions, 14 deletions
diff --git a/uxd.1 b/uxd.1
index bf7f8db..35bfc4f 100644
--- a/uxd.1
+++ b/uxd.1
@@ -59,6 +59,12 @@ over the environment.
Options can be bundled: \fB\-ubc1234\fP is the same as \fB\-u\fP \fB\-b\fP \fB\-c
1234\fP\&. The one exception is the \fB\-n\fP option, which should appear
by itself.
+.sp
+The options that accept numbers (\fB\-l\fP, \fB\-o\fP, \fB\-s\fP, and \fB\-S\fP)
+allow decimal, hex (with \fI0x\fP prefix), or octal (with \fI0\fP prefix).
+Also, you can use the suffixes \fIk\fP, \fIm\fP, and \fIg\fP for power\-of\-2 based
+kilobytes, megabytes, or gigabytes (e.g. \fI1k\fP is 1024 bytes), as well
+as \fIK\fP, \fIM\fP, and \fIG\fP for power\-of\-10 based (e.g. \fI1K\fP is 1000 bytes).
.\" the comments are turned into the --help message by mkusage.pl.
.
.INDENT 0.0
@@ -118,8 +124,7 @@ bad sequences.
.BI \-l \ length
Stop dumping after \fIlength\fP bytes (not characters). If the limit is
reached in the middle of a multibyte character, the entire character
-will be dumped. Can be given in decimal, hex (with \fI0x\fP prefix), or
-octal (with \fI0\fP prefix). Negative \fIlength\fP doesn\(aqt make sense, and
+will be dumped. Negative \fIlength\fP doesn\(aqt make sense, and
is an error.
.UNINDENT
.\" stop dumping after <length> bytes (not characters).
@@ -146,8 +151,7 @@ bundled with other options (e.g. use \fB\-n \-u\fP, not \fB\-nu\fP).
.TP
.BI \-o \ offset
Add this amount to the hex offsets (left column). May be negative,
-if you can think of a reason to want it to be. Can be given in
-decimal, hex (with \fI0x\fP prefix), or octal (with \fI0\fP prefix).
+if you can think of a reason to want it to be.
.UNINDENT
.\" added to hex offsets (decimal, 0x hex, 0 octal).
.
@@ -165,15 +169,14 @@ output. Ignored if \fB\-m\fP given.
Seek in input before starting to dump. \fIpos\fP is bytes, not
characters. Positive \fIpos\fP means seek from the start of the
input. Negative \fIpos\fP only works on files (not standard input);
-it means seek backward from EOF. Can be given in decimal, hex (with
-\fI0x\fP prefix), or octal (with \fI0\fP prefix).
+it means seek backward from EOF.
.UNINDENT
.\" seek in input before dumping (-pos = seek back from EOF).
.
.INDENT 0.0
.TP
.BI \-S \ pos
-Same as \fB\-s\fP, but file offsets start at 0 rather than the
+Same as \fB\-s\fP, but the displayed offsets start at 0 rather than the
position after seeking. \fB\-S 100\fP is the same as \fB\-s 100 \-o \-100\fP\&.
Works with negative \fIpos\fP, too.
.UNINDENT
diff --git a/uxd.c b/uxd.c
index 59c16e9..4125909 100644
--- a/uxd.c
+++ b/uxd.c
@@ -205,6 +205,9 @@ long parse_number(int opt, const char *s) {
result = strtol(s, &e, 0);
+ /* buglet here: 100x is correctly rejected, but 100kx is allowed
+ (the x is ignored). not gonna worry about it. some people might
+ even make use of it: 100kb or 100Kb will work. */
switch(*e) {
case 0: break;
case 'k': result *= 1024L; break;
diff --git a/uxd.rst b/uxd.rst
index 57f4455..597084b 100644
--- a/uxd.rst
+++ b/uxd.rst
@@ -50,6 +50,12 @@ Options can be bundled: **-ubc1234** is the same as **-u** **-b** **-c
1234**. The one exception is the **-n** option, which should appear
by itself.
+The options that accept numbers (**-l**, **-o**, **-s**, and **-S**)
+allow decimal, hex (with *0x* prefix), or octal (with *0* prefix).
+Also, you can use the suffixes *k*, *m*, and *g* for power-of-2 based
+kilobytes, megabytes, or gigabytes (e.g. *1k* is 1024 bytes), as well
+as *K*, *M*, and *G* for power-of-10 based (e.g. *1K* is 1000 bytes).
+
.. the comments are turned into the --help message by mkusage.pl.
-1
@@ -95,8 +101,7 @@ by itself.
-l length
Stop dumping after *length* bytes (not characters). If the limit is
reached in the middle of a multibyte character, the entire character
- will be dumped. Can be given in decimal, hex (with *0x* prefix), or
- octal (with *0* prefix). Negative *length* doesn't make sense, and
+ will be dumped. Negative *length* doesn't make sense, and
is an error.
.. stop dumping after <length> bytes (not characters).
@@ -117,8 +122,7 @@ by itself.
-o offset
Add this amount to the hex offsets (left column). May be negative,
- if you can think of a reason to want it to be. Can be given in
- decimal, hex (with *0x* prefix), or octal (with *0* prefix).
+ if you can think of a reason to want it to be.
.. added to hex offsets (decimal, 0x hex, 0 octal).
@@ -132,13 +136,12 @@ by itself.
Seek in input before starting to dump. *pos* is bytes, not
characters. Positive *pos* means seek from the start of the
input. Negative *pos* only works on files (not standard input);
- it means seek backward from EOF. Can be given in decimal, hex (with
- *0x* prefix), or octal (with *0* prefix).
+ it means seek backward from EOF.
.. seek in input before dumping (-pos = seek back from EOF).
-S pos
- Same as **-s**, but file offsets start at 0 rather than the
+ Same as **-s**, but the displayed offsets start at 0 rather than the
position after seeking. **-S 100** is the same as **-s 100 -o -100**.
Works with negative *pos*, too.