Skip to content

Commit

Permalink
script: fix case-sensitive symbol lookup
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lmichaelis committed Nov 8, 2022
1 parent 56775ce commit d9357f6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion source/script.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit d9357f6

Please sign in to comment.