mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-06 13:37:07 +00:00
Fix hexdump output of radiff2 (#10111)
radiff2 showed wrong output when filesize was not a multiple of the width.
This commit is contained in:
parent
a4370e89c9
commit
7706f2d778
@ -429,6 +429,7 @@ static void dump_cols(ut8 *a, int as, ut8 *b, int bs, int w) {
|
||||
ut32 sz = R_MIN (as, bs);
|
||||
ut32 i, j;
|
||||
int ctx = DUMP_CONTEXT;
|
||||
int pad = 0;
|
||||
switch (w) {
|
||||
case 8:
|
||||
r_cons_printf (" offset 0 1 2 3 4 5 6 7 01234567 0 1 2 3 4 5 6 7 01234567\n");
|
||||
@ -443,6 +444,10 @@ static void dump_cols(ut8 *a, int as, ut8 *b, int bs, int w) {
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < sz; i += w) {
|
||||
if (i + w >= sz) {
|
||||
pad = w - sz + i;
|
||||
w = sz - i;
|
||||
}
|
||||
bool eq = !memcmp (a + i, b + i, w);
|
||||
if (eq) {
|
||||
ctx--;
|
||||
@ -470,6 +475,9 @@ static void dump_cols(ut8 *a, int as, ut8 *b, int bs, int w) {
|
||||
r_cons_printf (Color_RESET);
|
||||
}
|
||||
}
|
||||
for (j = 0; j < pad; j++) {
|
||||
r_cons_printf (" ");
|
||||
}
|
||||
r_cons_printf (" ");
|
||||
for (j = 0; j < w; j++) {
|
||||
bool eq2 = a[i + j] == b[i + j];
|
||||
@ -481,6 +489,9 @@ static void dump_cols(ut8 *a, int as, ut8 *b, int bs, int w) {
|
||||
r_cons_printf (Color_RESET);
|
||||
}
|
||||
}
|
||||
for (j = 0; j < pad; j++) {
|
||||
r_cons_printf (" ");
|
||||
}
|
||||
r_cons_printf (" ");
|
||||
for (j = 0; j < w; j++) {
|
||||
bool eq2 = a[i + j] == b[i + j];
|
||||
@ -492,6 +503,9 @@ static void dump_cols(ut8 *a, int as, ut8 *b, int bs, int w) {
|
||||
r_cons_printf (Color_RESET);
|
||||
}
|
||||
}
|
||||
for (j = 0; j < pad; j++) {
|
||||
r_cons_printf (" ");
|
||||
}
|
||||
r_cons_printf (" ");
|
||||
for (j = 0; j < w; j++) {
|
||||
bool eq2 = a[i + j] == b[i + j];
|
||||
|
Loading…
x
Reference in New Issue
Block a user