Mercurial > vim
comparison src/xxd/xxd.c @ 32104:5a1113ece237 v9.0.1383
patch 9.0.1383: xxd: combination of little endian and cols fails
Commit: https://github.com/vim/vim/commit/4390d872b6c9498527a43fc7c30a5384f2e1db12
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 5 20:17:39 2023 +0000
patch 9.0.1383: xxd: combination of little endian and cols fails
Problem: xxd: combination of little endian and cols fails. (Aapo
Rantalainen)
Solution: Round up the space taken by the hex output. (closes #12097)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 05 Mar 2023 21:30:03 +0100 |
parents | 53c1fab8081e |
children | 79b2eb83f2df |
comparison
equal
deleted
inserted
replaced
32103:0ec8ebc433fd | 32104:5a1113ece237 |
---|---|
835 | 835 |
836 if (p == 0) | 836 if (p == 0) |
837 { | 837 { |
838 addrlen = sprintf(l, decimal_offset ? "%08ld:" : "%08lx:", | 838 addrlen = sprintf(l, decimal_offset ? "%08ld:" : "%08lx:", |
839 ((unsigned long)(n + seekoff + displayoff))); | 839 ((unsigned long)(n + seekoff + displayoff))); |
840 for (c = addrlen; c < LLEN; l[c++] = ' '); | 840 for (c = addrlen; c < LLEN; l[c++] = ' ') |
841 ; | |
841 } | 842 } |
842 x = hextype == HEX_LITTLEENDIAN ? p ^ (octspergrp-1) : p; | 843 x = hextype == HEX_LITTLEENDIAN ? p ^ (octspergrp-1) : p; |
843 c = addrlen + 1 + (grplen * x) / octspergrp; | 844 c = addrlen + 1 + (grplen * x) / octspergrp; |
844 if (hextype == HEX_NORMAL || hextype == HEX_LITTLEENDIAN) | 845 if (hextype == HEX_NORMAL || hextype == HEX_LITTLEENDIAN) |
845 { | 846 { |
855 if (e) | 856 if (e) |
856 nonzero++; | 857 nonzero++; |
857 if (ebcdic) | 858 if (ebcdic) |
858 e = (e < 64) ? '.' : etoa64[e-64]; | 859 e = (e < 64) ? '.' : etoa64[e-64]; |
859 /* When changing this update definition of LLEN above. */ | 860 /* When changing this update definition of LLEN above. */ |
860 c = addrlen + 3 + (grplen * cols - 1)/octspergrp + p; | 861 if (hextype == HEX_LITTLEENDIAN) |
862 /* last group will be fully used, round up */ | |
863 c = grplen * ((cols + octspergrp - 1) / octspergrp); | |
864 else | |
865 c = (grplen * cols - 1) / octspergrp; | |
866 c += addrlen + 3 + p; | |
861 l[c++] = | 867 l[c++] = |
862 #ifdef __MVS__ | 868 #ifdef __MVS__ |
863 (e >= 64) | 869 (e >= 64) |
864 #else | 870 #else |
865 (e > 31 && e < 127) | 871 (e > 31 && e < 127) |