Skip to content

Commit c73fc86

Browse files
aapochrisbra
authored andcommitted
patch 9.1.0793: xxd: -e does add one extra space
Problem: xxd: -e does add one extra space Solution: fix it, refactor and merge some code (Aapo Rantalainen) fixes: #15898 closes: #15899 Signed-off-by: Aapo Rantalainen <aapo.rantalainen@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent cc15bbc commit c73fc86

3 files changed

Lines changed: 18 additions & 26 deletions

File tree

src/testdir/test_xxd.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,12 +485,12 @@ func Test_xxd_little_endian_with_cols()
485485
enew!
486486
call writefile(["ABCDEF"], 'Xxdin', 'D')
487487
exe 'r! ' .. s:xxd_cmd .. ' -e -c6 ' .. ' Xxdin'
488-
call assert_equal('00000000: 44434241 4645 ABCDEF', getline(2))
488+
call assert_equal('00000000: 44434241 4645 ABCDEF', getline(2))
489489

490490
enew!
491491
call writefile(["ABCDEFGHI"], 'Xxdin', 'D')
492492
exe 'r! ' .. s:xxd_cmd .. ' -e -c9 ' .. ' Xxdin'
493-
call assert_equal('00000000: 44434241 48474645 49 ABCDEFGHI', getline(2))
493+
call assert_equal('00000000: 44434241 48474645 49 ABCDEFGHI', getline(2))
494494

495495
bwipe!
496496
endfunc

src/version.c

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

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
793,
707709
/**/
708710
792,
709711
/**/

src/xxd/xxd.c

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
* 10.02.2024 fix buffer-overflow when writing color output to buffer, #14003
6565
* 10.05.2024 fix another buffer-overflow when writing colored output to buffer, #14738
6666
* 10.09.2024 Support -b and -i together, #15661
67+
* 19.10.2024 -e did add an extra space #15899
6768
*
6869
* (c) 1990-1998 by Juergen Weigert (jnweiger@gmail.com)
6970
*
@@ -144,7 +145,7 @@ extern void perror __P((char *));
144145
# endif
145146
#endif
146147

147-
char version[] = "xxd 2024-09-15 by Juergen Weigert et al.";
148+
char version[] = "xxd 2024-10-19 by Juergen Weigert et al.";
148149
#ifdef WIN32
149150
char osver[] = " (Win32)";
150151
#else
@@ -1110,9 +1111,6 @@ main(int argc, char *argv[])
11101111
else
11111112
c = addrlen + 3 + (grplen * cols - 1)/octspergrp + p*12;
11121113

1113-
if (hextype == HEX_LITTLEENDIAN)
1114-
c += 1;
1115-
11161114
COLOR_PROLOGUE
11171115
begin_coloring_char(l,&c,e,ebcdic);
11181116
#if defined(__MVS__) && __CHARSET_LIB == 0
@@ -1126,21 +1124,15 @@ main(int argc, char *argv[])
11261124
l[c++] = (e > 31 && e < 127) ? e : '.';
11271125
#endif
11281126
COLOR_EPILOGUE
1129-
n++;
1130-
if (++p == cols)
1131-
{
1132-
l[c++] = '\n';
1133-
l[c++] = '\0';
1134-
xxdline(fpo, l, autoskip ? nonzero : 1);
1135-
nonzero = 0;
1136-
p = 0;
1137-
}
11381127
}
11391128
else /*no colors*/
11401129
{
11411130
if (ebcdic)
11421131
e = (e < 64) ? '.' : etoa64[e-64];
11431132

1133+
if (hextype == HEX_LITTLEENDIAN)
1134+
c -= 1;
1135+
11441136
c += addrlen + 3 + p;
11451137
l[c++] =
11461138
#if defined(__MVS__) && __CHARSET_LIB == 0
@@ -1149,25 +1141,23 @@ main(int argc, char *argv[])
11491141
(e > 31 && e < 127)
11501142
#endif
11511143
? e : '.';
1152-
n++;
1153-
if (++p == cols)
1154-
{
1155-
l[c++] = '\n';
1156-
l[c] = '\0';
1157-
xxdline(fpo, l, autoskip ? nonzero : 1);
1158-
nonzero = 0;
1159-
p = 0;
1160-
}
11611144
}
1145+
n++;
1146+
if (++p == cols)
1147+
{
1148+
l[c++] = '\n';
1149+
l[c] = '\0';
1150+
xxdline(fpo, l, autoskip ? nonzero : 1);
1151+
nonzero = 0;
1152+
p = 0;
1153+
}
11621154
}
11631155
if (p)
11641156
{
11651157
l[c++] = '\n';
11661158
l[c] = '\0';
11671159
if (color)
11681160
{
1169-
c++;
1170-
11711161
x = p;
11721162
if (hextype == HEX_LITTLEENDIAN)
11731163
{

0 commit comments

Comments
 (0)