]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0793: xxd: -e does add one extra space v9.1.0793
authorAapo Rantalainen <aapo.rantalainen@gmail.com>
Sat, 19 Oct 2024 13:54:57 +0000 (15:54 +0200)
committerChristian Brabandt <cb@256bit.org>
Sat, 19 Oct 2024 13:54:57 +0000 (15:54 +0200)
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>
src/testdir/test_xxd.vim
src/version.c
src/xxd/xxd.c

index 5706871519b7a924d638ba9d4c12bff9abe3aa72..f10c2447dbb0c5a5da12fd6a232d074e30379b89 100644 (file)
@@ -485,12 +485,12 @@ func Test_xxd_little_endian_with_cols()
   enew!
   call writefile(["ABCDEF"], 'Xxdin', 'D')
   exe 'r! ' .. s:xxd_cmd .. ' -e -c6 ' .. ' Xxdin'
-  call assert_equal('00000000: 44434241     4645   ABCDEF', getline(2))
+  call assert_equal('00000000: 44434241     4645  ABCDEF', getline(2))
 
   enew!
   call writefile(["ABCDEFGHI"], 'Xxdin', 'D')
   exe 'r! ' .. s:xxd_cmd .. ' -e -c9 ' .. ' Xxdin'
-  call assert_equal('00000000: 44434241 48474645       49   ABCDEFGHI', getline(2))
+  call assert_equal('00000000: 44434241 48474645       49  ABCDEFGHI', getline(2))
 
   bwipe!
 endfunc
index 93187e847334716cd8331ee46891d5f23b37ce31..8c389ff57eac21015e533eb0c1e5f3c384a6b678 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    793,
 /**/
     792,
 /**/
index 63f516c12b7eeff3e6f488432acd2cb5f3425cdb..b1050e9da4da33622bc8a3f9aa8dbf3575d7a50d 100644 (file)
@@ -64,6 +64,7 @@
  * 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.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)
  *
@@ -144,7 +145,7 @@ extern void perror __P((char *));
 # 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
 char osver[] = " (Win32)";
 #else
@@ -1110,9 +1111,6 @@ main(int argc, char *argv[])
           else
             c = addrlen + 3 + (grplen * cols - 1)/octspergrp + p*12;
 
-          if (hextype == HEX_LITTLEENDIAN)
-            c += 1;
-
           COLOR_PROLOGUE
           begin_coloring_char(l,&c,e,ebcdic);
 #if defined(__MVS__) && __CHARSET_LIB == 0
@@ -1126,21 +1124,15 @@ main(int argc, char *argv[])
           l[c++] = (e > 31 && e < 127) ? e : '.';
 #endif
           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*/
         {
           if (ebcdic)
             e = (e < 64) ? '.' : etoa64[e-64];
 
+          if (hextype == HEX_LITTLEENDIAN)
+            c -= 1;
+
           c += addrlen + 3 + p;
           l[c++] =
 #if defined(__MVS__) && __CHARSET_LIB == 0
@@ -1149,16 +1141,16 @@ main(int argc, char *argv[])
               (e > 31 && e < 127)
 #endif
               ? e : '.';
-          n++;
-          if (++p == cols)
-            {
-              l[c++] = '\n';
-              l[c] = '\0';
-              xxdline(fpo, l, autoskip ? nonzero : 1);
-              nonzero = 0;
-              p = 0;
-            }
         }
+        n++;
+        if (++p == cols)
+          {
+            l[c++] = '\n';
+            l[c] = '\0';
+            xxdline(fpo, l, autoskip ? nonzero : 1);
+            nonzero = 0;
+            p = 0;
+          }
     }
   if (p)
     {
@@ -1166,8 +1158,6 @@ main(int argc, char *argv[])
       l[c] = '\0';
       if (color)
         {
-          c++;
-
           x = p;
           if (hextype == HEX_LITTLEENDIAN)
             {