From 26b54fbee8fd349b292085c5128c37e82f4f904c Mon Sep 17 00:00:00 2001 From: scawful Date: Sat, 5 Oct 2024 13:29:13 -0400 Subject: [PATCH] Refactor UppercaseHexWord function to include an optional leading parameter --- src/app/core/labeling.cc | 8 ++++++-- src/app/core/labeling.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/app/core/labeling.cc b/src/app/core/labeling.cc index c2c2080a..bd9346ad 100644 --- a/src/app/core/labeling.cc +++ b/src/app/core/labeling.cc @@ -26,8 +26,12 @@ std::string UppercaseHexByte(uint8_t byte, bool leading) { std::string result = absl::StrFormat("%02X", byte); return result; } -std::string UppercaseHexWord(uint16_t word) { - std::string result = absl::StrFormat("0x%04X", word); +std::string UppercaseHexWord(uint16_t word, bool leading) { + if (leading) { + std::string result = absl::StrFormat("0x%04X", word); + return result; + } + std::string result = absl::StrFormat("%04X", word); return result; } std::string UppercaseHexLong(uint32_t dword) { diff --git a/src/app/core/labeling.h b/src/app/core/labeling.h index ef509a76..f238c760 100644 --- a/src/app/core/labeling.h +++ b/src/app/core/labeling.h @@ -18,7 +18,7 @@ namespace app { namespace core { std::string UppercaseHexByte(uint8_t byte, bool leading = false); -std::string UppercaseHexWord(uint16_t word); +std::string UppercaseHexWord(uint16_t word, bool leading = false); std::string UppercaseHexLong(uint32_t dword); std::string UppercaseHexLongLong(uint64_t qword);