mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 04:44:59 +00:00
AK: Make the :hex-dump format specifier print all characters
Previously the final line would be skipped if it was not a multiple of |width|, this makes the character view show up for that line.
This commit is contained in:
parent
1a07205c33
commit
4d1d88aa16
1 changed files with 2 additions and 2 deletions
|
@ -752,7 +752,7 @@ ErrorOr<void> FormatBuilder::put_hexdump(ReadonlyBytes bytes, size_t width, char
|
||||||
{
|
{
|
||||||
auto put_char_view = [&](auto i) -> ErrorOr<void> {
|
auto put_char_view = [&](auto i) -> ErrorOr<void> {
|
||||||
TRY(put_padding(fill, 4));
|
TRY(put_padding(fill, 4));
|
||||||
for (size_t j = i - width; j < i; ++j) {
|
for (size_t j = i - min(i, width); j < i; ++j) {
|
||||||
auto ch = bytes[j];
|
auto ch = bytes[j];
|
||||||
TRY(m_builder.try_append(ch >= 32 && ch <= 127 ? ch : '.')); // silly hack
|
TRY(m_builder.try_append(ch >= 32 && ch <= 127 ? ch : '.')); // silly hack
|
||||||
}
|
}
|
||||||
|
@ -769,7 +769,7 @@ ErrorOr<void> FormatBuilder::put_hexdump(ReadonlyBytes bytes, size_t width, char
|
||||||
TRY(put_u64(bytes[i], 16, false, false, true, false, Align::Right, 2));
|
TRY(put_u64(bytes[i], 16, false, false, true, false, Align::Right, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width > 0 && bytes.size() && bytes.size() % width == 0)
|
if (width > 0)
|
||||||
TRY(put_char_view(bytes.size()));
|
TRY(put_char_view(bytes.size()));
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue