1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0854
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 8.1.0854
Problem: xxd does not work with more than 32 bit addresses.
Solution: Add support for 64 bit addresses. (Christer Jensen, closes #3791)
Files: src/xxd/xxd.c
*** ../vim-8.1.0853/src/xxd/xxd.c 2019-01-25 21:52:12.190931859 +0100
--- src/xxd/xxd.c 2019-01-30 23:00:28.306174236 +0100
***************
*** 52,57 ****
--- 52,58 ----
* 2011 March Better error handling by Florian Zumbiehl.
* 2011 April Formatting by Bram Moolenaar
* 08.06.2013 Little-endian hexdump (-e) and offset (-o) by Vadim Vygonets.
+ * 11.01.2019 Add full 64/32 bit range to -o and output by Christer Jensen.
*
* (c) 1990-1998 by Juergen Weigert (jnweiger@informatik.uni-erlangen.de)
*
***************
*** 90,95 ****
--- 91,97 ----
#include <stdlib.h>
#include <string.h> /* for strncmp() */
#include <ctype.h> /* for isalnum() */
+ #include <limits.h>
#if __MWERKS__ && !defined(BEBOX)
# include <unix.h> /* for fdopen() on MAC */
#endif
***************
*** 204,210 ****
#define TRY_SEEK /* attempt to use lseek, or skip forward by reading */
#define COLS 256 /* change here, if you ever need more columns */
! #define LLEN (12 + (9*COLS-1) + COLS + 2)
char hexxa[] = "0123456789abcdef0123456789ABCDEF", *hexx = hexxa;
--- 206,212 ----
#define TRY_SEEK /* attempt to use lseek, or skip forward by reading */
#define COLS 256 /* change here, if you ever need more columns */
! #define LLEN ((2*(int)sizeof(unsigned long)) + 4 + (9*COLS-1) + COLS + 2)
char hexxa[] = "0123456789abcdef0123456789ABCDEF", *hexx = hexxa;
***************
*** 466,472 ****
int ebcdic = 0;
int octspergrp = -1; /* number of octets grouped in output */
int grplen; /* total chars per octet group */
! long length = -1, n = 0, seekoff = 0, displayoff = 0;
static char l[LLEN+1]; /* static because it may be too big for stack */
char *pp;
--- 468,475 ----
int ebcdic = 0;
int octspergrp = -1; /* number of octets grouped in output */
int grplen; /* total chars per octet group */
! long length = -1, n = 0, seekoff = 0;
! unsigned long displayoff = 0;
static char l[LLEN+1]; /* static because it may be too big for stack */
char *pp;
***************
*** 536,548 ****
}
else if (!STRNCMP(pp, "-o", 2))
{
if (pp[2] && STRNCMP("ffset", pp + 2, 5))
! displayoff = (int)strtol(pp + 2, NULL, 0);
else
{
if (!argv[2])
exit_with_usage();
! displayoff = (int)strtol(argv[2], NULL, 0);
argv++;
argc--;
}
--- 539,563 ----
}
else if (!STRNCMP(pp, "-o", 2))
{
+ int reloffset = 0;
+ int negoffset = 0;
if (pp[2] && STRNCMP("ffset", pp + 2, 5))
! displayoff = strtoul(pp + 2, NULL, 0);
else
{
if (!argv[2])
exit_with_usage();
!
! if (argv[2][0] == '+')
! reloffset++;
! if (argv[2][reloffset] == '-')
! negoffset++;
!
! if (negoffset)
! displayoff = ULONG_MAX - strtoul(argv[2] + reloffset+negoffset, NULL, 0) + 1;
! else
! displayoff = strtoul(argv[2] + reloffset+negoffset, NULL, 0);
!
argv++;
argc--;
}
***************
*** 805,835 ****
else /* hextype == HEX_BITS */
grplen = 8 * octspergrp + 1;
e = 0;
while ((length < 0 || n < length) && (e = getc(fp)) != EOF)
{
if (p == 0)
{
! sprintf(l, "%08lx:",
! ((unsigned long)(n + seekoff + displayoff)) & 0xffffffff);
! for (c = 9; c < LLEN; l[c++] = ' ');
}
if (hextype == HEX_NORMAL)
{
! l[c = (10 + (grplen * p) / octspergrp)] = hexx[(e >> 4) & 0xf];
l[++c] = hexx[ e & 0xf];
}
else if (hextype == HEX_LITTLEENDIAN)
{
int x = p ^ (octspergrp-1);
! l[c = (10 + (grplen * x) / octspergrp)] = hexx[(e >> 4) & 0xf];
l[++c] = hexx[ e & 0xf];
}
else /* hextype == HEX_BITS */
{
int i;
! c = (10 + (grplen * p) / octspergrp) - 1;
for (i = 7; i >= 0; i--)
l[++c] = (e & (1 << i)) ? '1' : '0';
}
--- 820,851 ----
else /* hextype == HEX_BITS */
grplen = 8 * octspergrp + 1;
+ int addrlen = 9;
e = 0;
while ((length < 0 || n < length) && (e = getc(fp)) != EOF)
{
if (p == 0)
{
! addrlen = sprintf(l, "%08lx:",
! ((unsigned long)(n + seekoff + displayoff)));
! for (c = addrlen; c < LLEN; l[c++] = ' ');
}
if (hextype == HEX_NORMAL)
{
! l[c = (addrlen + 1 + (grplen * p) / octspergrp)] = hexx[(e >> 4) & 0xf];
l[++c] = hexx[ e & 0xf];
}
else if (hextype == HEX_LITTLEENDIAN)
{
int x = p ^ (octspergrp-1);
! l[c = (addrlen + 1 + (grplen * x) / octspergrp)] = hexx[(e >> 4) & 0xf];
l[++c] = hexx[ e & 0xf];
}
else /* hextype == HEX_BITS */
{
int i;
! c = (addrlen + 1 + (grplen * p) / octspergrp) - 1;
for (i = 7; i >= 0; i--)
l[++c] = (e & (1 << i)) ? '1' : '0';
}
***************
*** 838,844 ****
if (ebcdic)
e = (e < 64) ? '.' : etoa64[e-64];
/* When changing this update definition of LLEN above. */
! l[12 + (grplen * cols - 1)/octspergrp + p] =
#ifdef __MVS__
(e >= 64)
#else
--- 854,860 ----
if (ebcdic)
e = (e < 64) ? '.' : etoa64[e-64];
/* When changing this update definition of LLEN above. */
! l[addrlen + 3 + (grplen * cols - 1)/octspergrp + p] =
#ifdef __MVS__
(e >= 64)
#else
***************
*** 848,854 ****
n++;
if (++p == cols)
{
! l[c = (12 + (grplen * cols - 1)/octspergrp + p)] = '\n'; l[++c] = '\0';
xxdline(fpo, l, autoskip ? nonzero : 1);
nonzero = 0;
p = 0;
--- 864,870 ----
n++;
if (++p == cols)
{
! l[c = (addrlen + 3 + (grplen * cols - 1)/octspergrp + p)] = '\n'; l[++c] = '\0';
xxdline(fpo, l, autoskip ? nonzero : 1);
nonzero = 0;
p = 0;
***************
*** 858,864 ****
die(2);
if (p)
{
! l[c = (12 + (grplen * cols - 1)/octspergrp + p)] = '\n'; l[++c] = '\0';
xxdline(fpo, l, 1);
}
else if (autoskip)
--- 874,880 ----
die(2);
if (p)
{
! l[c = (addrlen + 3 + (grplen * cols - 1)/octspergrp + p)] = '\n'; l[++c] = '\0';
xxdline(fpo, l, 1);
}
else if (autoskip)
*** ../vim-8.1.0853/src/version.c 2019-01-30 22:36:14.646981306 +0100
--- src/version.c 2019-01-30 23:01:44.097578546 +0100
***************
*** 785,786 ****
--- 785,788 ----
{ /* Add new patch number below this line */
+ /**/
+ 854,
/**/
--
GUEST: He's killed the best man!
SECOND GUEST: (holding a limp WOMAN) He's killed my auntie.
FATHER: No, please! This is supposed to be a happy occasion! Let's
not bicker and argue about who killed who ...
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|