To: vim_dev@googlegroups.com Subject: Patch 9.0.1383 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1383 Problem: xxd: combination of little endian and cols fails. (Aapo Rantalainen) Solution: Round up the space taken by the hex output. (closes #12097) Files: src/xxd/xxd.c, src/testdir/test_xxd.vim *** ../vim-9.0.1382/src/xxd/xxd.c 2022-09-06 16:31:22.380166840 +0100 --- src/xxd/xxd.c 2023-03-05 20:16:43.099191668 +0000 *************** *** 837,843 **** { addrlen = sprintf(l, decimal_offset ? "%08ld:" : "%08lx:", ((unsigned long)(n + seekoff + displayoff))); ! for (c = addrlen; c < LLEN; l[c++] = ' '); } x = hextype == HEX_LITTLEENDIAN ? p ^ (octspergrp-1) : p; c = addrlen + 1 + (grplen * x) / octspergrp; --- 837,844 ---- { addrlen = sprintf(l, decimal_offset ? "%08ld:" : "%08lx:", ((unsigned long)(n + seekoff + displayoff))); ! for (c = addrlen; c < LLEN; l[c++] = ' ') ! ; } x = hextype == HEX_LITTLEENDIAN ? p ^ (octspergrp-1) : p; c = addrlen + 1 + (grplen * x) / octspergrp; *************** *** 857,863 **** if (ebcdic) e = (e < 64) ? '.' : etoa64[e-64]; /* When changing this update definition of LLEN above. */ ! c = addrlen + 3 + (grplen * cols - 1)/octspergrp + p; l[c++] = #ifdef __MVS__ (e >= 64) --- 858,869 ---- if (ebcdic) e = (e < 64) ? '.' : etoa64[e-64]; /* When changing this update definition of LLEN above. */ ! if (hextype == HEX_LITTLEENDIAN) ! /* last group will be fully used, round up */ ! c = grplen * ((cols + octspergrp - 1) / octspergrp); ! else ! c = (grplen * cols - 1) / octspergrp; ! c += addrlen + 3 + p; l[c++] = #ifdef __MVS__ (e >= 64) *** ../vim-9.0.1382/src/testdir/test_xxd.vim 2023-01-28 19:18:56.741720608 +0000 --- src/testdir/test_xxd.vim 2023-03-05 20:14:23.379176859 +0000 *************** *** 401,404 **** --- 401,418 ---- endfor endfunc + 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)) + + enew! + call writefile(["ABCDEFGHI"], 'Xxdin', 'D') + exe 'r! ' .. s:xxd_cmd .. ' -e -c9 ' .. ' Xxdin' + call assert_equal('00000000: 44434241 48474645 49 ABCDEFGHI', getline(2)) + + bwipe! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-9.0.1382/src/version.c 2023-03-05 19:27:43.646982550 +0000 --- src/version.c 2023-03-05 20:15:38.939192193 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1383, /**/ -- hundred-and-one symptoms of being an internet addict: 228. You spend Saturday night making the counter on your home page pass that 2000 mark. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///