Fix custom menu function not being compared case-insensitive

This commit is contained in:
Jan 2023-12-14 18:22:02 +01:00
parent 2a6318e3ca
commit 00c866c246
No known key found for this signature in database
GPG Key ID: 44B581F78FF5C57C
2 changed files with 7 additions and 2 deletions

View File

@ -36,7 +36,9 @@ namespace menu
std::vector<std::unique_ptr<CommonFunctionDef>> m_functions;
std::vector<std::unique_ptr<CommonMenuDef>> m_menus;
// Function names are case-insensitive, therefore keys are always lowercase
std::map<std::string, CommonFunctionDef*> m_functions_by_name;
std::map<std::string, CommonMenuDef*> m_menus_by_name;
bool m_in_global_scope;

View File

@ -34,10 +34,13 @@ namespace menu::function_scope_sequences
throw ParsingException(result.NextCapture(CAPTURE_TOKEN).GetPos(), ss.str());
}
const auto existingFunction = state->m_functions_by_name.find(state->m_current_function->m_name);
auto lowerCaseName = state->m_current_function->m_name;
utils::MakeStringLowerCase(lowerCaseName);
const auto existingFunction = state->m_functions_by_name.find(lowerCaseName);
if (existingFunction == state->m_functions_by_name.end())
{
state->m_functions_by_name.emplace(std::make_pair(state->m_current_function->m_name, state->m_current_function));
state->m_functions_by_name.emplace(std::make_pair(lowerCaseName, state->m_current_function));
state->m_current_function = nullptr;
}
else if (!state->m_current_function->m_value->Equals(existingFunction->second->m_value.get()))