mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03: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
Notes:
sideshowbarker
2024-07-17 06:20:50 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/4d1d88aa16 Pull-request: https://github.com/SerenityOS/serenity/pull/22873 Issue: https://github.com/SerenityOS/serenity/issues/22838
@ -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…
Reference in New Issue
Block a user