Fix bug with FindDictionaryEntry return type to int8_t

This commit is contained in:
scawful
2025-04-05 17:25:10 -04:00
parent 3d3a88a9c6
commit d332f45d2a
2 changed files with 7 additions and 7 deletions

View File

@@ -18,7 +18,7 @@ uint8_t FindMatchingCharacter(char value) {
return 0xFF;
}
uint8_t FindDictionaryEntry(uint8_t value) {
int8_t FindDictionaryEntry(uint8_t value) {
if (value < DICTOFF || value == 0xFF) {
return -1;
}
@@ -51,8 +51,8 @@ ParsedElement FindMatchingElement(const std::string &str) {
match = text_element.MatchMe(str);
if (match.size() > 0) {
if (text_element.HasArgument) {
return ParsedElement(text_element,
std::stoi(match[1].str(), nullptr, 16));
std::string arg = match[1].str().substr(1);
return ParsedElement(text_element, std::stoi(arg, nullptr, 16));
} else {
return ParsedElement(text_element, 0);
}
@@ -93,7 +93,7 @@ std::string ParseTextDataByte(uint8_t value) {
// Check for dictionary.
int dictionary = FindDictionaryEntry(value);
if (dictionary >= 0) {
return absl::StrFormat("[%s:%X]", DICTIONARYTOKEN, dictionary);
return absl::StrFormat("[%s:%2X]", DICTIONARYTOKEN, dictionary);
}
return "";

View File

@@ -39,7 +39,7 @@ static const std::unordered_map<uint8_t, wchar_t> CharEncoder = {
};
uint8_t FindMatchingCharacter(char value);
uint8_t FindDictionaryEntry(uint8_t value);
int8_t FindDictionaryEntry(uint8_t value);
std::vector<uint8_t> ParseMessageToData(std::string str);
struct DictionaryEntry {
@@ -52,7 +52,7 @@ struct DictionaryEntry {
DictionaryEntry() = default;
DictionaryEntry(uint8_t i, std::string s)
: Contents(s), ID(i), Length(s.length()) {
Token = absl::StrFormat("[%s:%00X]", DICTIONARYTOKEN, ID);
Token = absl::StrFormat("[%s:%02X]", DICTIONARYTOKEN, ID);
Data = ParseMessageToData(Contents);
}
@@ -73,7 +73,7 @@ struct DictionaryEntry {
constexpr int kTextData = 0xE0000;
constexpr int kTextDataEnd = 0xE7FFF;
constexpr int kNumDictionaryEntries = 97;
constexpr int kNumDictionaryEntries = 0x61;
constexpr int kPointersDictionaries = 0x74703;
constexpr uint8_t kScrollVertical = 0x73;
constexpr uint8_t kLine1 = 0x74;