diff --git a/openscenario/openscenario_interpreter/src/reader/attribute.cpp b/openscenario/openscenario_interpreter/src/reader/attribute.cpp index 90b91e4b4b4..b98d521d540 100644 --- a/openscenario/openscenario_interpreter/src/reader/attribute.cpp +++ b/openscenario/openscenario_interpreter/src/reader/attribute.cpp @@ -75,15 +75,16 @@ auto substitute(const std::string & attribute, const Scope & scope) -> String static const auto pattern = std::regex(R"((.*)\$\((([\w-]+)\s?([^\)]*))\)(.*))"); - for (std::smatch result; std::regex_match(attribute, result, pattern);) { + auto substituted = attribute; + for (std::smatch result; std::regex_match(substituted, result, pattern);) { if (const auto iter = substitutions.find(result.str(3)); iter != std::end(substitutions)) { - attribute = result.str(1) + std::get<1>(*iter)(result.str(4), scope) + result.str(5); + substituted = result.str(1) + std::get<1>(*iter)(result.str(4), scope) + result.str(5); } else { throw SyntaxError("Unknown substitution ", std::quoted(result.str(3)), " specified"); } } - return attribute; + return substituted; } template auto readAttribute(const std::string &, const pugi::xml_node &, const Scope &) -> Boolean; diff --git a/openscenario/openscenario_interpreter/src/reader/element.cpp b/openscenario/openscenario_interpreter/src/reader/element.cpp index d773084ccc7..2e51163767b 100644 --- a/openscenario/openscenario_interpreter/src/reader/element.cpp +++ b/openscenario/openscenario_interpreter/src/reader/element.cpp @@ -32,7 +32,7 @@ template auto readElement(const std::string &, const pugi::xml_node &, Scope &) auto choice( const pugi::xml_node & node, - std::unordered_map> callees) -> Object + const std::unordered_map> & callees) -> Object { std::unordered_map specs{};