From 7b6fa485cd97a1160b2ac12b521f3c87e72749ae Mon Sep 17 00:00:00 2001 From: Luis Michaelis Date: Sun, 6 Nov 2022 10:13:15 +0100 Subject: [PATCH] script: fix case-sensitive symbol lookup Symbols in Daedalus-scripts are case-insensitive. The const version of `script::find_symbol_by_name` did not correctly perform string normalization before accessing the underlying hash map. --- source/script.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/script.cc b/source/script.cc index 50c63de2..33a94e6c 100644 --- a/source/script.cc +++ b/source/script.cc @@ -130,7 +130,10 @@ namespace phoenix { } const symbol* script::find_symbol_by_name(const std::string& name) const { - if (auto it = _m_symbols_by_name.find(name); it != _m_symbols_by_name.end()) { + std::string up {name}; + std::transform(up.begin(), up.end(), up.begin(), ::toupper); + + if (auto it = _m_symbols_by_name.find(up); it != _m_symbols_by_name.end()) { return find_symbol_by_index(it->second); }