Mercurial > vim
annotate runtime/doc/xxd.1 @ 29208:b8dc0a76911e v8.2.5123
patch 8.2.5123: using invalid index when looking for spell suggestions
Commit: https://github.com/vim/vim/commit/156d3911952d73b03d7420dc3540215247db0fe8
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 18 14:09:08 2022 +0100
patch 8.2.5123: using invalid index when looking for spell suggestions
Problem: Using invalid index when looking for spell suggestions.
Solution: Do not decrement the index when it is zero.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 18 Jun 2022 15:15:04 +0200 |
parents | 2f854597399f |
children | 948c947cb1ed |
rev | line source |
---|---|
7 | 1 .TH XXD 1 "August 1996" "Manual page for xxd" |
2 .\" | |
3 .\" 21st May 1996 | |
4 .\" Man page author: | |
5 .\" Tony Nugent <tony@sctnugen.ppp.gu.edu.au> <T.Nugent@sct.gu.edu.au> | |
6 .\" Changes by Bram Moolenaar <Bram@vim.org> | |
7 .SH NAME | |
8 .I xxd | |
9 \- make a hexdump or do the reverse. | |
10 .SH SYNOPSIS | |
11 .B xxd | |
12 \-h[elp] | |
13 .br | |
14 .B xxd | |
15 [options] [infile [outfile]] | |
16 .br | |
17 .B xxd | |
18 \-r[evert] [options] [infile [outfile]] | |
19 .SH DESCRIPTION | |
20 .I xxd | |
21 creates a hex dump of a given file or standard input. | |
22 It can also convert a hex dump back to its original binary form. | |
23 Like | |
216 | 24 .BR uuencode (1) |
7 | 25 and |
216 | 26 .BR uudecode (1) |
7 | 27 it allows the transmission of binary data in a `mail-safe' ASCII representation, |
28 but has the advantage of decoding to standard output. | |
29 Moreover, it can be used to perform binary file patching. | |
30 .SH OPTIONS | |
31 If no | |
32 .I infile | |
33 is given, standard input is read. | |
34 If | |
35 .I infile | |
36 is specified as a | |
37 .RB \` \- ' | |
38 character, then input is taken from standard input. | |
39 If no | |
40 .I outfile | |
41 is given (or a | |
42 .RB \` \- ' | |
43 character is in its place), results are sent to standard output. | |
44 .PP | |
45 Note that a "lazy" parser is used which does not check for more than the first | |
46 option letter, unless the option is followed by a parameter. | |
47 Spaces between a single option letter and its parameter are optional. | |
48 Parameters to options can be specified in decimal, hexadecimal or octal | |
49 notation. | |
50 Thus | |
51 .BR \-c8 , | |
52 .BR "\-c 8" , | |
53 .B \-c 010 | |
54 and | |
55 .B \-cols 8 | |
56 are all equivalent. | |
57 .PP | |
58 .TP | |
59 .IR \-a " | " \-autoskip | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6655
diff
changeset
|
60 Toggle autoskip: A single '*' replaces nul-lines. Default off. |
7 | 61 .TP |
62 .IR \-b " | " \-bits | |
63 Switch to bits (binary digits) dump, rather than hexdump. | |
64 This option writes octets as eight digits "1"s and "0"s instead of a normal | |
36 | 65 hexadecimal dump. Each line is preceded by a line number in hexadecimal and |
7 | 66 followed by an ascii (or ebcdic) representation. The command line switches |
67 \-r, \-p, \-i do not work with this mode. | |
68 .TP | |
69 .IR "\-c cols " | " \-cols cols" | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6655
diff
changeset
|
70 Format |
7 | 71 .RI < cols > |
72 octets per line. Default 16 (\-i: 12, \-ps: 30, \-b: 6). Max 256. | |
27118
2f854597399f
patch 8.2.4088: xxd cannot output everything in one line
Bram Moolenaar <Bram@vim.org>
parents:
13571
diff
changeset
|
73 No maxmimum for \-ps. With \-ps, 0 results in one long line of output. |
7 | 74 .TP |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6655
diff
changeset
|
75 .IR \-C " | " \-capitalize |
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6655
diff
changeset
|
76 Capitalize variable names in C include file style, when using \-i. |
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6655
diff
changeset
|
77 .TP |
7 | 78 .IR \-E " | " \-EBCDIC |
79 Change the character encoding in the righthand column from ASCII to EBCDIC. | |
80 This does not change the hexadecimal representation. The option is | |
81 meaningless in combinations with \-r, \-p or \-i. | |
82 .TP | |
6655 | 83 .IR \-e |
84 Switch to little-endian hexdump. | |
85 This option treats byte groups as words in little-endian byte order. | |
86 The default grouping of 4 bytes may be changed using | |
87 .RI "" \-g . | |
88 This option only applies to hexdump, leaving the ASCII (or EBCDIC) | |
89 representation unchanged. | |
90 The command line switches | |
91 \-r, \-p, \-i do not work with this mode. | |
92 .TP | |
7 | 93 .IR "\-g bytes " | " \-groupsize bytes" |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6655
diff
changeset
|
94 Separate the output of every |
7 | 95 .RI < bytes > |
96 bytes (two hex characters or eight bit-digits each) by a whitespace. | |
97 Specify | |
98 .I \-g 0 | |
99 to suppress grouping. | |
100 .RI < Bytes "> defaults to " 2 | |
6655 | 101 in normal mode, \fI4\fP in little-endian mode and \fI1\fP in bits mode. |
7 | 102 Grouping does not apply to postscript or include style. |
103 .TP | |
104 .IR \-h " | " \-help | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6655
diff
changeset
|
105 Print a summary of available commands and exit. No hex dumping is performed. |
7 | 106 .TP |
107 .IR \-i " | " \-include | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6655
diff
changeset
|
108 Output in C include file style. A complete static array definition is written |
7 | 109 (named after the input file), unless xxd reads from stdin. |
110 .TP | |
111 .IR "\-l len " | " \-len len" | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6655
diff
changeset
|
112 Stop after writing |
7 | 113 .RI < len > |
114 octets. | |
115 .TP | |
6655 | 116 .I \-o offset |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6655
diff
changeset
|
117 Add |
6655 | 118 .RI < offset > |
119 to the displayed file position. | |
120 .TP | |
7 | 121 .IR \-p " | " \-ps " | " \-postscript " | " \-plain |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6655
diff
changeset
|
122 Output in postscript continuous hexdump style. Also known as plain hexdump |
7 | 123 style. |
124 .TP | |
125 .IR \-r " | " \-revert | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6655
diff
changeset
|
126 Reverse operation: convert (or patch) hexdump into binary. |
7 | 127 If not writing to stdout, xxd writes into its output file without truncating |
128 it. Use the combination | |
129 .I \-r \-p | |
130 to read plain hexadecimal dumps without line number information and without a | |
131 particular column layout. Additional Whitespace and line-breaks are allowed | |
132 anywhere. | |
133 .TP | |
134 .I \-seek offset | |
135 When used after | |
216 | 136 .IR \-r : |
137 revert with | |
7 | 138 .RI < offset > |
139 added to file positions found in hexdump. | |
140 .TP | |
216 | 141 .I \-s [+][\-]seek |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6655
diff
changeset
|
142 Start at |
7 | 143 .RI < seek > |
144 bytes abs. (or rel.) infile offset. | |
1125 | 145 \fI+ \fRindicates that the seek is relative to the current stdin file position |
7 | 146 (meaningless when not reading from stdin). \fI\- \fRindicates that the seek |
147 should be that many characters from the end of the input (or if combined with | |
216 | 148 \fI+\fR: before the current stdin file position). |
7 | 149 Without \-s option, xxd starts at the current file position. |
150 .TP | |
151 .I \-u | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6655
diff
changeset
|
152 Use upper case hex letters. Default is lower case. |
7 | 153 .TP |
154 .IR \-v " | " \-version | |
13571
362b27e3f702
patch 8.0.1658: capitalize argument not available in long form
Christian Brabandt <cb@256bit.org>
parents:
6655
diff
changeset
|
155 Show version string. |
7 | 156 .SH CAVEATS |
157 .PP | |
158 .I xxd \-r | |
159 has some builtin magic while evaluating line number information. | |
36 | 160 If the output file is seekable, then the linenumbers at the start of each |
7 | 161 hexdump line may be out of order, lines may be missing, or overlapping. In |
162 these cases xxd will lseek(2) to the next position. If the output file is not | |
163 seekable, only gaps are allowed, which will be filled by null-bytes. | |
164 .PP | |
165 .I xxd \-r | |
166 never generates parse errors. Garbage is silently skipped. | |
167 .PP | |
168 When editing hexdumps, please note that | |
169 .I xxd \-r | |
170 skips everything on the input line after reading enough columns of hexadecimal | |
171 data (see option \-c). This also means, that changes to the printable ascii (or | |
172 ebcdic) columns are always ignored. Reverting a plain (or postscript) style | |
36 | 173 hexdump with xxd \-r \-p does not depend on the correct number of columns. Here anything that looks like a pair of hex-digits is interpreted. |
7 | 174 .PP |
175 Note the difference between | |
176 .br | |
177 \fI% xxd \-i file\fR | |
178 .br | |
179 and | |
180 .br | |
216 | 181 \fI% xxd \-i < file\fR |
7 | 182 .PP |
810 | 183 .I xxd \-s +seek |
7 | 184 may be different from |
216 | 185 .IR "xxd \-s seek" , |
186 as lseek(2) is used to "rewind" input. A '+' | |
7 | 187 makes a difference if the input source is stdin, and if stdin's file position |
188 is not at the start of the file by the time xxd is started and given its input. | |
189 The following examples may help to clarify (or further confuse!)... | |
190 .PP | |
191 Rewind stdin before reading; needed because the `cat' has already read to the | |
192 end of stdin. | |
193 .br | |
1125 | 194 \fI% sh \-c "cat > plain_copy; xxd \-s 0 > hex_copy" < file\fR |
7 | 195 .PP |
196 Hexdump from file position 0x480 (=1024+128) onwards. | |
197 The `+' sign means "relative to the current position", thus the `128' adds to | |
198 the 1k where dd left off. | |
199 .br | |
1125 | 200 \fI% sh \-c "dd of=plain_snippet bs=1k count=1; xxd \-s +128 > hex_snippet" < file\fR |
7 | 201 .PP |
216 | 202 Hexdump from file position 0x100 ( = 1024\-768) on. |
7 | 203 .br |
1125 | 204 \fI% sh \-c "dd of=plain_snippet bs=1k count=1; xxd \-s +\-768 > hex_snippet" < file\fR |
7 | 205 .PP |
206 However, this is a rare situation and the use of `+' is rarely needed. | |
36 | 207 The author prefers to monitor the effect of xxd with strace(1) or truss(1), whenever \-s is used. |
7 | 208 .SH EXAMPLES |
209 .PP | |
210 .br | |
211 Print everything but the first three lines (hex 0x30 bytes) of | |
810 | 212 .BR file . |
7 | 213 .br |
1125 | 214 \fI% xxd \-s 0x30 file\fR |
7 | 215 .PP |
216 .br | |
217 Print 3 lines (hex 0x30 bytes) from the end of | |
810 | 218 .BR file . |
7 | 219 .br |
1125 | 220 \fI% xxd \-s \-0x30 file\fR |
7 | 221 .PP |
222 .br | |
1125 | 223 Print 120 bytes as continuous hexdump with 20 octets per line. |
7 | 224 .br |
225 \fI% xxd \-l 120 \-ps \-c 20 xxd.1\fR | |
226 .br | |
36 | 227 2e54482058584420312022417567757374203139 |
7 | 228 .br |
36 | 229 39362220224d616e75616c207061676520666f72 |
7 | 230 .br |
36 | 231 20787864220a2e5c220a2e5c222032317374204d |
7 | 232 .br |
36 | 233 617920313939360a2e5c22204d616e2070616765 |
7 | 234 .br |
36 | 235 20617574686f723a0a2e5c2220202020546f6e79 |
7 | 236 .br |
36 | 237 204e7567656e74203c746f6e79407363746e7567 |
7 | 238 .br |
239 | |
240 .br | |
241 Hexdump the first 120 bytes of this man page with 12 octets per line. | |
242 .br | |
243 \fI% xxd \-l 120 \-c 12 xxd.1\fR | |
244 .br | |
36 | 245 0000000: 2e54 4820 5858 4420 3120 2241 .TH XXD 1 "A |
7 | 246 .br |
36 | 247 000000c: 7567 7573 7420 3139 3936 2220 ugust 1996" |
7 | 248 .br |
36 | 249 0000018: 224d 616e 7561 6c20 7061 6765 "Manual page |
7 | 250 .br |
36 | 251 0000024: 2066 6f72 2078 7864 220a 2e5c for xxd"..\\ |
7 | 252 .br |
36 | 253 0000030: 220a 2e5c 2220 3231 7374 204d "..\\" 21st M |
7 | 254 .br |
36 | 255 000003c: 6179 2031 3939 360a 2e5c 2220 ay 1996..\\" |
7 | 256 .br |
36 | 257 0000048: 4d61 6e20 7061 6765 2061 7574 Man page aut |
7 | 258 .br |
36 | 259 0000054: 686f 723a 0a2e 5c22 2020 2020 hor:..\\" |
7 | 260 .br |
36 | 261 0000060: 546f 6e79 204e 7567 656e 7420 Tony Nugent |
7 | 262 .br |
36 | 263 000006c: 3c74 6f6e 7940 7363 746e 7567 <tony@sctnug |
7 | 264 .PP |
265 .br | |
266 Display just the date from the file xxd.1 | |
267 .br | |
36 | 268 \fI% xxd \-s 0x36 \-l 13 \-c 13 xxd.1\fR |
7 | 269 .br |
36 | 270 0000036: 3231 7374 204d 6179 2031 3939 36 21st May 1996 |
7 | 271 .PP |
272 .br | |
273 Copy | |
274 .B input_file | |
275 to | |
276 .B output_file | |
277 and prepend 100 bytes of value 0x00. | |
278 .br | |
810 | 279 \fI% xxd input_file | xxd \-r \-s 100 > output_file\fR |
7 | 280 .br |
281 | |
282 .br | |
283 Patch the date in the file xxd.1 | |
284 .br | |
810 | 285 \fI% echo "0000037: 3574 68" | xxd \-r \- xxd.1\fR |
7 | 286 .br |
36 | 287 \fI% xxd \-s 0x36 \-l 13 \-c 13 xxd.1\fR |
7 | 288 .br |
36 | 289 0000036: 3235 7468 204d 6179 2031 3939 36 25th May 1996 |
7 | 290 .PP |
291 .br | |
292 Create a 65537 byte file with all bytes 0x00, | |
293 except for the last one which is 'A' (hex 0x41). | |
294 .br | |
810 | 295 \fI% echo "010000: 41" | xxd \-r > file\fR |
7 | 296 .PP |
297 .br | |
298 Hexdump this file with autoskip. | |
299 .br | |
300 \fI% xxd \-a \-c 12 file\fR | |
301 .br | |
302 0000000: 0000 0000 0000 0000 0000 0000 ............ | |
303 .br | |
304 * | |
305 .br | |
306 000fffc: 0000 0000 40 ....A | |
307 .PP | |
308 Create a 1 byte file containing a single 'A' character. | |
309 The number after '\-r \-s' adds to the linenumbers found in the file; | |
310 in effect, the leading bytes are suppressed. | |
311 .br | |
810 | 312 \fI% echo "010000: 41" | xxd \-r \-s \-0x10000 > file\fR |
7 | 313 .PP |
314 Use xxd as a filter within an editor such as | |
315 .B vim(1) | |
316 to hexdump a region marked between `a' and `z'. | |
317 .br | |
318 \fI:'a,'z!xxd\fR | |
319 .PP | |
320 Use xxd as a filter within an editor such as | |
321 .B vim(1) | |
322 to recover a binary hexdump marked between `a' and `z'. | |
323 .br | |
324 \fI:'a,'z!xxd \-r\fR | |
325 .PP | |
326 Use xxd as a filter within an editor such as | |
327 .B vim(1) | |
328 to recover one line of a hexdump. Move the cursor over the line and type: | |
329 .br | |
330 \fI!!xxd \-r\fR | |
331 .PP | |
332 Read single characters from a serial line | |
333 .br | |
334 \fI% xxd \-c1 < /dev/term/b &\fR | |
335 .br | |
336 \fI% stty < /dev/term/b \-echo \-opost \-isig \-icanon min 1\fR | |
337 .br | |
338 \fI% echo \-n foo > /dev/term/b\fR | |
339 .PP | |
340 .SH "RETURN VALUES" | |
341 The following error values are returned: | |
342 .TP | |
343 0 | |
344 no errors encountered. | |
345 .TP | |
346 \-1 | |
347 operation not supported ( | |
348 .I xxd \-r \-i | |
349 still impossible). | |
350 .TP | |
351 1 | |
352 error while parsing options. | |
353 .TP | |
354 2 | |
355 problems with input file. | |
356 .TP | |
357 3 | |
358 problems with output file. | |
359 .TP | |
360 4,5 | |
361 desired seek position is unreachable. | |
362 .SH "SEE ALSO" | |
363 uuencode(1), uudecode(1), patch(1) | |
364 .br | |
365 .SH WARNINGS | |
366 The tools weirdness matches its creators brain. | |
367 Use entirely at your own risk. Copy files. Trace it. Become a wizard. | |
368 .br | |
369 .SH VERSION | |
370 This manual page documents xxd version 1.7 | |
371 .SH AUTHOR | |
372 .br | |
373 (c) 1990-1997 by Juergen Weigert | |
374 .br | |
810 | 375 <jnweiger@informatik.uni\-erlangen.de> |
7 | 376 .LP |
377 Distribute freely and credit me, | |
378 .br | |
379 make money and share with me, | |
380 .br | |
381 lose money and don't ask me. | |
382 .PP | |
383 Manual page started by Tony Nugent | |
384 .br | |
385 <tony@sctnugen.ppp.gu.edu.au> <T.Nugent@sct.gu.edu.au> | |
386 .br | |
387 Small changes by Bram Moolenaar. | |
388 Edited by Juergen Weigert. | |
389 .PP |