The old test
x if ((len(repr(chr(x))) == 3) and (x < 127)) else ord('.')
went through some contortions to see if the character was printable, and
it got it slightly wrong. The idea was that `repr(chr(97)` is "'a'",
while `repr(chr(167)` is "'\xa7'", which we can distinguish using the
length. But that miscategorised the backslash character, which is
represented as "'\\'", a string of length 4, so it was show as '.'
instead.
Instead we notice that the characters we want to print in a hexdump
are exactly those between 32 and 126, inclusive.
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
BINDIR = os.path.abspath(os.path.join(os.path.dirname(__file__),
"../../../../bin"))
-HEXDUMP_FILTER = bytearray([x if ((len(repr(chr(x))) == 3) and (x < 127)) else ord('.') for x in range(256)])
+# HEXDUMP_FILTER maps ASCII control characters to '.', printables to themselves
+HEXDUMP_FILTER = bytearray(x if (x > 31 and x < 127) else 46 for x in range(256))
LDB_ERR_LUT = {v: k for k, v in vars(ldb).items() if k.startswith('ERR_')}