Skip to content

Commit

Permalink
Update not to rewrite argument
Browse files Browse the repository at this point in the history
  • Loading branch information
shouth committed Mar 6, 2025
1 parent dfc93ae commit 40ca441
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string, std::function<Object(const pugi::xml_node &)>> callees) -> Object
const std::unordered_map<std::string, std::function<Object(const pugi::xml_node &)>> & callees) -> Object
{
std::unordered_map<std::string, pugi::xml_node> specs{};

Expand Down

0 comments on commit 40ca441

Please sign in to comment.