Skip to content

Commit 79cf7c0

Browse files
committed
patch 8.0.1658: capitalize argument not available in long form
Problem: Capitalize argument not available in long form. Solution: Recognize -capitalize. Update man page.
1 parent 9af9778 commit 79cf7c0

File tree

4 files changed

+62
-51
lines changed

4 files changed

+62
-51
lines changed

runtime/doc/xxd.1

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ are all equivalent.
5757
.PP
5858
.TP
5959
.IR \-a " | " \-autoskip
60-
toggle autoskip: A single '*' replaces nul-lines. Default off.
60+
Toggle autoskip: A single '*' replaces nul-lines. Default off.
6161
.TP
6262
.IR \-b " | " \-bits
6363
Switch to bits (binary digits) dump, rather than hexdump.
@@ -67,10 +67,13 @@ followed by an ascii (or ebcdic) representation. The command line switches
6767
\-r, \-p, \-i do not work with this mode.
6868
.TP
6969
.IR "\-c cols " | " \-cols cols"
70-
format
70+
Format
7171
.RI < cols >
7272
octets per line. Default 16 (\-i: 12, \-ps: 30, \-b: 6). Max 256.
7373
.TP
74+
.IR \-C " | " \-capitalize
75+
Capitalize variable names in C include file style, when using \-i.
76+
.TP
7477
.IR \-E " | " \-EBCDIC
7578
Change the character encoding in the righthand column from ASCII to EBCDIC.
7679
This does not change the hexadecimal representation. The option is
@@ -87,7 +90,7 @@ The command line switches
8790
\-r, \-p, \-i do not work with this mode.
8891
.TP
8992
.IR "\-g bytes " | " \-groupsize bytes"
90-
separate the output of every
93+
Separate the output of every
9194
.RI < bytes >
9295
bytes (two hex characters or eight bit-digits each) by a whitespace.
9396
Specify
@@ -98,28 +101,28 @@ in normal mode, \fI4\fP in little-endian mode and \fI1\fP in bits mode.
98101
Grouping does not apply to postscript or include style.
99102
.TP
100103
.IR \-h " | " \-help
101-
print a summary of available commands and exit. No hex dumping is performed.
104+
Print a summary of available commands and exit. No hex dumping is performed.
102105
.TP
103106
.IR \-i " | " \-include
104-
output in C include file style. A complete static array definition is written
107+
Output in C include file style. A complete static array definition is written
105108
(named after the input file), unless xxd reads from stdin.
106109
.TP
107110
.IR "\-l len " | " \-len len"
108-
stop after writing
111+
Stop after writing
109112
.RI < len >
110113
octets.
111114
.TP
112115
.I \-o offset
113-
add
116+
Add
114117
.RI < offset >
115118
to the displayed file position.
116119
.TP
117120
.IR \-p " | " \-ps " | " \-postscript " | " \-plain
118-
output in postscript continuous hexdump style. Also known as plain hexdump
121+
Output in postscript continuous hexdump style. Also known as plain hexdump
119122
style.
120123
.TP
121124
.IR \-r " | " \-revert
122-
reverse operation: convert (or patch) hexdump into binary.
125+
Reverse operation: convert (or patch) hexdump into binary.
123126
If not writing to stdout, xxd writes into its output file without truncating
124127
it. Use the combination
125128
.I \-r \-p
@@ -135,7 +138,7 @@ revert with
135138
added to file positions found in hexdump.
136139
.TP
137140
.I \-s [+][\-]seek
138-
start at
141+
Start at
139142
.RI < seek >
140143
bytes abs. (or rel.) infile offset.
141144
\fI+ \fRindicates that the seek is relative to the current stdin file position
@@ -145,10 +148,10 @@ should be that many characters from the end of the input (or if combined with
145148
Without \-s option, xxd starts at the current file position.
146149
.TP
147150
.I \-u
148-
use upper case hex letters. Default is lower case.
151+
Use upper case hex letters. Default is lower case.
149152
.TP
150153
.IR \-v " | " \-version
151-
show version string.
154+
Show version string.
152155
.SH CAVEATS
153156
.PP
154157
.I xxd \-r

runtime/doc/xxd.man

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ OPTIONS
3030
notation. Thus -c8, -c 8, -c 010 and -cols 8 are all equivalent.
3131

3232
-a | -autoskip
33-
toggle autoskip: A single '*' replaces nul-lines. Default off.
33+
Toggle autoskip: A single '*' replaces nul-lines. Default off.
3434

3535
-b | -bits
3636
Switch to bits (binary digits) dump, rather than hexdump. This
@@ -41,9 +41,13 @@ OPTIONS
4141
mode.
4242

4343
-c cols | -cols cols
44-
format <cols> octets per line. Default 16 (-i: 12, -ps: 30, -b:
44+
Format <cols> octets per line. Default 16 (-i: 12, -ps: 30, -b:
4545
6). Max 256.
4646

47+
-C | -capitalize
48+
Capitalize variable names in C include file style, when using
49+
-i.
50+
4751
-E | -EBCDIC
4852
Change the character encoding in the righthand column from ASCII
4953
to EBCDIC. This does not change the hexadecimal representation.
@@ -52,105 +56,105 @@ OPTIONS
5256
-e Switch to little-endian hexdump. This option treats byte groups
5357
as words in little-endian byte order. The default grouping of 4
5458
bytes may be changed using -g. This option only applies to hex‐
55-
dump, leaving the ASCII (or EBCDIC) representation unchanged.
59+
dump, leaving the ASCII (or EBCDIC) representation unchanged.
5660
The command line switches -r, -p, -i do not work with this mode.
5761

5862
-g bytes | -groupsize bytes
59-
separate the output of every <bytes> bytes (two hex characters
63+
Separate the output of every <bytes> bytes (two hex characters
6064
or eight bit-digits each) by a whitespace. Specify -g 0 to sup‐
6165
press grouping. <Bytes> defaults to 2 in normal mode, 4 in lit‐
62-
tle-endian mode and 1 in bits mode. Grouping does not apply to
66+
tle-endian mode and 1 in bits mode. Grouping does not apply to
6367
postscript or include style.
6468

6569
-h | -help
66-
print a summary of available commands and exit. No hex dumping
70+
Print a summary of available commands and exit. No hex dumping
6771
is performed.
6872

6973
-i | -include
70-
output in C include file style. A complete static array defini‐
71-
tion is written (named after the input file), unless xxd reads
74+
Output in C include file style. A complete static array defini‐
75+
tion is written (named after the input file), unless xxd reads
7276
from stdin.
7377

7478
-l len | -len len
75-
stop after writing <len> octets.
79+
Stop after writing <len> octets.
7680

7781
-o offset
78-
add <offset> to the displayed file position.
82+
Add <offset> to the displayed file position.
7983

8084
-p | -ps | -postscript | -plain
81-
output in postscript continuous hexdump style. Also known as
85+
Output in postscript continuous hexdump style. Also known as
8286
plain hexdump style.
8387

8488
-r | -revert
85-
reverse operation: convert (or patch) hexdump into binary. If
86-
not writing to stdout, xxd writes into its output file without
89+
Reverse operation: convert (or patch) hexdump into binary. If
90+
not writing to stdout, xxd writes into its output file without
8791
truncating it. Use the combination -r -p to read plain hexadeci‐
8892
mal dumps without line number information and without a particu‐
89-
lar column layout. Additional Whitespace and line-breaks are
93+
lar column layout. Additional Whitespace and line-breaks are
9094
allowed anywhere.
9195

9296
-seek offset
9397
When used after -r: revert with <offset> added to file positions
9498
found in hexdump.
9599

96100
-s [+][-]seek
97-
start at <seek> bytes abs. (or rel.) infile offset. + indicates
98-
that the seek is relative to the current stdin file position
101+
Start at <seek> bytes abs. (or rel.) infile offset. + indicates
102+
that the seek is relative to the current stdin file position
99103
(meaningless when not reading from stdin). - indicates that the
100-
seek should be that many characters from the end of the input
104+
seek should be that many characters from the end of the input
101105
(or if combined with +: before the current stdin file position).
102106
Without -s option, xxd starts at the current file position.
103107

104-
-u use upper case hex letters. Default is lower case.
108+
-u Use upper case hex letters. Default is lower case.
105109

106110
-v | -version
107-
show version string.
111+
Show version string.
108112

109113
CAVEATS
110114
xxd -r has some builtin magic while evaluating line number information.
111-
If the output file is seekable, then the linenumbers at the start of
112-
each hexdump line may be out of order, lines may be missing, or over‐
113-
lapping. In these cases xxd will lseek(2) to the next position. If the
114-
output file is not seekable, only gaps are allowed, which will be
115+
If the output file is seekable, then the linenumbers at the start of
116+
each hexdump line may be out of order, lines may be missing, or over‐
117+
lapping. In these cases xxd will lseek(2) to the next position. If the
118+
output file is not seekable, only gaps are allowed, which will be
115119
filled by null-bytes.
116120

117121
xxd -r never generates parse errors. Garbage is silently skipped.
118122

119-
When editing hexdumps, please note that xxd -r skips everything on the
123+
When editing hexdumps, please note that xxd -r skips everything on the
120124
input line after reading enough columns of hexadecimal data (see option
121-
-c). This also means, that changes to the printable ascii (or ebcdic)
122-
columns are always ignored. Reverting a plain (or postscript) style
123-
hexdump with xxd -r -p does not depend on the correct number of col‐
124-
umns. Here anything that looks like a pair of hex-digits is inter‐
125+
-c). This also means, that changes to the printable ascii (or ebcdic)
126+
columns are always ignored. Reverting a plain (or postscript) style
127+
hexdump with xxd -r -p does not depend on the correct number of col‐
128+
umns. Here anything that looks like a pair of hex-digits is inter‐
125129
preted.
126130

127131
Note the difference between
128132
% xxd -i file
129133
and
130134
% xxd -i < file
131135

132-
xxd -s +seek may be different from xxd -s seek, as lseek(2) is used to
136+
xxd -s +seek may be different from xxd -s seek, as lseek(2) is used to
133137
"rewind" input. A '+' makes a difference if the input source is stdin,
134-
and if stdin's file position is not at the start of the file by the
135-
time xxd is started and given its input. The following examples may
138+
and if stdin's file position is not at the start of the file by the
139+
time xxd is started and given its input. The following examples may
136140
help to clarify (or further confuse!)...
137141

138-
Rewind stdin before reading; needed because the `cat' has already read
142+
Rewind stdin before reading; needed because the `cat' has already read
139143
to the end of stdin.
140144
% sh -c "cat > plain_copy; xxd -s 0 > hex_copy" < file
141145

142-
Hexdump from file position 0x480 (=1024+128) onwards. The `+' sign
146+
Hexdump from file position 0x480 (=1024+128) onwards. The `+' sign
143147
means "relative to the current position", thus the `128' adds to the 1k
144148
where dd left off.
145-
% sh -c "dd of=plain_snippet bs=1k count=1; xxd -s +128 > hex_snippet"
149+
% sh -c "dd of=plain_snippet bs=1k count=1; xxd -s +128 > hex_snippet"
146150
< file
147151

148152
Hexdump from file position 0x100 ( = 1024-768) on.
149153
% sh -c "dd of=plain_snippet bs=1k count=1; xxd -s +-768 > hex_snippet"
150154
< file
151155

152-
However, this is a rare situation and the use of `+' is rarely needed.
153-
The author prefers to monitor the effect of xxd with strace(1) or
156+
However, this is a rare situation and the use of `+' is rarely needed.
157+
The author prefers to monitor the effect of xxd with strace(1) or
154158
truss(1), whenever -s is used.
155159

156160
EXAMPLES
@@ -194,7 +198,7 @@ EXAMPLES
194198
% xxd -s 0x36 -l 13 -c 13 xxd.1
195199
0000036: 3235 7468 204d 6179 2031 3939 36 25th May 1996
196200

197-
Create a 65537 byte file with all bytes 0x00, except for the last one
201+
Create a 65537 byte file with all bytes 0x00, except for the last one
198202
which is 'A' (hex 0x41).
199203
% echo "010000: 41" | xxd -r > file
200204

@@ -204,7 +208,7 @@ EXAMPLES
204208
*
205209
000fffc: 0000 0000 40 ....A
206210

207-
Create a 1 byte file containing a single 'A' character. The number
211+
Create a 1 byte file containing a single 'A' character. The number
208212
after '-r -s' adds to the linenumbers found in the file; in effect, the
209213
leading bytes are suppressed.
210214
% echo "010000: 41" | xxd -r -s -0x10000 > file
@@ -245,7 +249,7 @@ SEE ALSO
245249
uuencode(1), uudecode(1), patch(1)
246250

247251
WARNINGS
248-
The tools weirdness matches its creators brain. Use entirely at your
252+
The tools weirdness matches its creators brain. Use entirely at your
249253
own risk. Copy files. Trace it. Become a wizard.
250254

251255
VERSION

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,8 @@ static char *(features[]) =
762762

763763
static int included_patches[] =
764764
{ /* Add new patch number below this line */
765+
/**/
766+
1658,
765767
/**/
766768
1657,
767769
/**/

src/xxd/xxd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,8 @@ main(int argc, char *argv[])
510510
{
511511
if (pp[2] && STRNCMP("ols", pp + 2, 3))
512512
cols = (int)strtol(pp + 2, NULL, 0);
513+
else if (pp[2] && STRNCMP("apitalize", pp + 2, 9))
514+
capitalize = 1;
513515
else
514516
{
515517
if (!argv[2])

0 commit comments

Comments
 (0)