summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui_hexdump.cc15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/gui_hexdump.cc b/src/gui_hexdump.cc
index fbda64d..e7da2d4 100644
--- a/src/gui_hexdump.cc
+++ b/src/gui_hexdump.cc
@@ -73,8 +73,9 @@ void HexDump::write(AttributedText* text, uint8_t flags, std::string const& str,
auto x = tmp2;
for (char c = 0; c < 2; ++c) {
len = snprintf(tmp, sizeof(tmp), "%02x %02x %02x %02x %02x %02x %02x %02x",
- data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6],
- data[i + 7]);
+ data[i] & 0xff, data[i + 1] & 0xff, data[i + 2] & 0xff,
+ data[i + 3] & 0xff, data[i + 4] & 0xff, data[i + 5] & 0xff,
+ data[i + 6] & 0xff, data[i + 7] & 0xff);
if (flags & CHARS) {
x += safe(x, sizeof(tmp2) - (x - tmp2), data + i, 8);
}
@@ -98,8 +99,9 @@ void HexDump::write(AttributedText* text, uint8_t flags, std::string const& str,
auto x = tmp2;
if (i + 8 <= length) {
len = snprintf(tmp, sizeof(tmp), "%02x %02x %02x %02x %02x %02x %02x %02x",
- data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6],
- data[i + 7]);
+ data[i] & 0xff, data[i + 1] & 0xff, data[i + 2] & 0xff,
+ data[i + 3] & 0xff, data[i + 4] & 0xff, data[i + 5] & 0xff,
+ data[i + 6] & 0xff, data[i + 7] & 0xff);
if (flags & CHARS) {
x += safe(x, sizeof(tmp2) - (x - tmp2), data + i, 8);
}
@@ -108,7 +110,7 @@ void HexDump::write(AttributedText* text, uint8_t flags, std::string const& str,
text->append(" ");
}
for (; i < length; ++i) {
- len = snprintf(tmp, sizeof(tmp), "%02x ", data[i]);
+ len = snprintf(tmp, sizeof(tmp), "%02x ", data[i] & 0xff);
if (flags & CHARS) x += safe(x, sizeof(tmp2) - (x - tmp2), data + i, 1);
text->append(tmp, len);
}
@@ -124,7 +126,8 @@ void HexDump::write(AttributedText* text, uint8_t flags, std::string const& str,
text->append("\n", 1);
}
if (flags & ADDRESS) {
- len = snprintf(tmp, sizeof(tmp), "%08lx\n", static_cast<unsigned long>(length));
+ len = snprintf(tmp, sizeof(tmp), "%08lx\n",
+ static_cast<unsigned long>(length));
text->append(tmp, len, addr);
}
}