LibPDF: Make Reader::dump_state a bit more readable
This commit is contained in:
parent
8c7ebc7a3f
commit
97cc482087
Notes:
sideshowbarker
2024-07-18 17:26:50 +09:00
Author: https://github.com/mattco98 Commit: https://github.com/SerenityOS/serenity/commit/97cc4820879 Pull-request: https://github.com/SerenityOS/serenity/pull/7436 Reviewed-by: https://github.com/alimpfard
1 changed files with 9 additions and 11 deletions
|
@ -126,23 +126,21 @@ public:
|
|||
#ifdef PDF_DEBUG
|
||||
void dump_state() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append("Reader State Dump\n\n");
|
||||
dbgln("Reader State (offset={} size={})", offset(), bytes().size());
|
||||
|
||||
size_t from = max(0ul, offset() - 10);
|
||||
size_t from = max(0, static_cast<int>(offset()) - 10);
|
||||
size_t to = min(bytes().size() - 1, offset() + 10);
|
||||
|
||||
for (auto i = from; i <= to; i++) {
|
||||
char value = static_cast<char>(bytes().at(i));
|
||||
builder.appendff("{}: '{}' (value={:3d}) ", i, value, static_cast<u8>(value));
|
||||
if (i == offset())
|
||||
builder.appendff(" <<< current location, forwards={}", m_forwards);
|
||||
builder.append('\n');
|
||||
auto line = String::formatted(" {}: '{}' (value={:3d}) ", i, value, static_cast<u8>(value));
|
||||
if (i == offset()) {
|
||||
dbgln("{} <<< current location, forwards={}", line, m_forwards);
|
||||
} else {
|
||||
dbgln("{}", line);
|
||||
}
|
||||
}
|
||||
builder.append('\n');
|
||||
|
||||
auto str = builder.to_string();
|
||||
dbgputstr(str.characters(), str.length());
|
||||
dbgln();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue