cabana: accept prefixed hex values in id filters (#38952)

This commit is contained in:
Trey Moen
2026-09-17 21:57:48 -07:00
committed by GitHub
parent bca3b04720
commit 60b3ccf39e
@@ -23,11 +23,12 @@ namespace {
const char *COLUMN_TITLES[MessageList::COLUMN_COUNT] = {"Name", "Bus", "ID", "Node", "Freq", "Count", "Bytes"};
constexpr float DEFAULT_SECTION_SIZE = 100.0f;
// surrounding whitespace is ignored; no sign, no 0x prefix
// surrounding whitespace is ignored; no sign, optional 0x prefix for hex
unsigned int toUInt(const std::string &s, bool *ok, int base) {
const char *b = s.data(), *e = b + s.size();
while (b < e && std::isspace((unsigned char)*b)) ++b;
while (e > b && std::isspace((unsigned char)e[-1])) --e;
if (base == 16 && e - b >= 2 && b[0] == '0' && (b[1] == 'x' || b[1] == 'X')) b += 2;
unsigned int v = 0;
auto [p, ec] = std::from_chars(b, e, v, base);
*ok = b < e && p == e && ec == std::errc();