print: fix hex padding (and add spaces)

This commit is contained in:
King Kévin 2020-06-24 11:49:52 +02:00
parent 8566a4043b
commit 60279d0a52
1 changed files with 6 additions and 3 deletions

View File

@ -251,6 +251,9 @@ static size_t print_hex(char** str, size_t* size, uint64_t hex, uint32_t padding
} }
} }
if (0 == padding) {
padding = 1; // show at least one hex
}
for (uint32_t zeros = nibbles; zeros < padding; zeros++) { // print padding 0's for (uint32_t zeros = nibbles; zeros < padding; zeros++) { // print padding 0's
print_printed(&length, print_char(str, size, '0')); // print 0 print_printed(&length, print_char(str, size, '0')); // print 0
} }