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>
diff --git a/src/testdir/test_xxd.vim b/src/testdir/test_xxd.vim
index 5706871..f10c244 100644
--- a/src/testdir/test_xxd.vim
+++ b/src/testdir/test_xxd.vim
@@ -485,12 +485,12 @@
   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