0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

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>
This commit is contained in:
Aapo Rantalainen
2024-10-19 15:54:57 +02:00
committed by Christian Brabandt
parent cc15bbcbc4
commit c73fc86bf8
3 changed files with 18 additions and 26 deletions

View File

@@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
793,
/**/ /**/
792, 792,
/**/ /**/

View File

@@ -64,6 +64,7 @@
* 10.02.2024 fix buffer-overflow when writing color output to buffer, #14003 * 10.02.2024 fix buffer-overflow when writing color output to buffer, #14003
* 10.05.2024 fix another buffer-overflow when writing colored output to buffer, #14738 * 10.05.2024 fix another buffer-overflow when writing colored output to buffer, #14738
* 10.09.2024 Support -b and -i together, #15661 * 10.09.2024 Support -b and -i together, #15661
* 19.10.2024 -e did add an extra space #15899
* *
* (c) 1990-1998 by Juergen Weigert (jnweiger@gmail.com) * (c) 1990-1998 by Juergen Weigert (jnweiger@gmail.com)
* *
@@ -144,7 +145,7 @@ extern void perror __P((char *));
# endif # endif
#endif #endif
char version[] = "xxd 2024-09-15 by Juergen Weigert et al."; char version[] = "xxd 2024-10-19 by Juergen Weigert et al.";
#ifdef WIN32 #ifdef WIN32
char osver[] = " (Win32)"; char osver[] = " (Win32)";
#else #else
@@ -1110,9 +1111,6 @@ main(int argc, char *argv[])
else else
c = addrlen + 3 + (grplen * cols - 1)/octspergrp + p*12; c = addrlen + 3 + (grplen * cols - 1)/octspergrp + p*12;
if (hextype == HEX_LITTLEENDIAN)
c += 1;
COLOR_PROLOGUE COLOR_PROLOGUE
begin_coloring_char(l,&c,e,ebcdic); begin_coloring_char(l,&c,e,ebcdic);
#if defined(__MVS__) && __CHARSET_LIB == 0 #if defined(__MVS__) && __CHARSET_LIB == 0
@@ -1126,21 +1124,15 @@ main(int argc, char *argv[])
l[c++] = (e > 31 && e < 127) ? e : '.'; l[c++] = (e > 31 && e < 127) ? e : '.';
#endif #endif
COLOR_EPILOGUE COLOR_EPILOGUE
n++;
if (++p == cols)
{
l[c++] = '\n';
l[c++] = '\0';
xxdline(fpo, l, autoskip ? nonzero : 1);
nonzero = 0;
p = 0;
}
} }
else /*no colors*/ else /*no colors*/
{ {
if (ebcdic) if (ebcdic)
e = (e < 64) ? '.' : etoa64[e-64]; e = (e < 64) ? '.' : etoa64[e-64];
if (hextype == HEX_LITTLEENDIAN)
c -= 1;
c += addrlen + 3 + p; c += addrlen + 3 + p;
l[c++] = l[c++] =
#if defined(__MVS__) && __CHARSET_LIB == 0 #if defined(__MVS__) && __CHARSET_LIB == 0
@@ -1149,6 +1141,7 @@ main(int argc, char *argv[])
(e > 31 && e < 127) (e > 31 && e < 127)
#endif #endif
? e : '.'; ? e : '.';
}
n++; n++;
if (++p == cols) if (++p == cols)
{ {
@@ -1159,15 +1152,12 @@ main(int argc, char *argv[])
p = 0; p = 0;
} }
} }
}
if (p) if (p)
{ {
l[c++] = '\n'; l[c++] = '\n';
l[c] = '\0'; l[c] = '\0';
if (color) if (color)
{ {
c++;
x = p; x = p;
if (hextype == HEX_LITTLEENDIAN) if (hextype == HEX_LITTLEENDIAN)
{ {