Fix multimatch behavior to match what we have on v2

This commit is contained in:
Felipe Zimmerle 2018-10-10 18:01:48 -03:00
parent a47738ab04
commit b58018e778
No known key found for this signature in database
GPG Key ID: E6DFB08CE8B11277

View File

@ -362,6 +362,7 @@ inline void Rule::executeTransformation(actions::Action *a,
if (m_containsMultiMatchAction) { if (m_containsMultiMatchAction) {
std::shared_ptr<std::string> t(new std::string(a->m_name)); std::shared_ptr<std::string> t(new std::string(a->m_name));
ret->push_back(std::make_pair(u, t)); ret->push_back(std::make_pair(u, t));
(*nth)++;
} }
*value = u; *value = u;
} }
@ -378,7 +379,6 @@ inline void Rule::executeTransformation(actions::Action *a,
a->m_name + ": \"" + \ a->m_name + ": \"" + \
utils::string::limitTo(80, newValue) +"\""); utils::string::limitTo(80, newValue) +"\"");
#endif #endif
(*nth)++;
} }
@ -396,10 +396,7 @@ std::list<std::pair<std::shared_ptr<std::string>,
if (m_containsMultiMatchAction == true) { if (m_containsMultiMatchAction == true) {
ret.push_back(std::make_pair( ret.push_back(std::make_pair(
std::shared_ptr<std::string>(value), std::shared_ptr<std::string>(new std::string(*value)),
std::shared_ptr<std::string>(new std::string(path))));
ret.push_back(std::make_pair(
std::shared_ptr<std::string>(value),
std::shared_ptr<std::string>(new std::string(path)))); std::shared_ptr<std::string>(new std::string(path))));
} }
@ -461,17 +458,16 @@ std::list<std::pair<std::shared_ptr<std::string>,
} }
if (m_containsMultiMatchAction == true) { if (m_containsMultiMatchAction == true) {
// v2 checks the last entry twice. Don't know why.
ret.push_back(ret.back());
#ifndef NO_LOGS #ifndef NO_LOGS
trans->debug(9, "multiMatch is enabled. " \ trans->debug(9, "multiMatch is enabled. " \
+ std::to_string(ret.size()) + \ + std::to_string(ret.size()) + \
" values to be tested."); " values to be tested.");
#endif #endif
} else { }
if (!m_containsMultiMatchAction) {
ret.push_back(std::make_pair( ret.push_back(std::make_pair(
value, std::shared_ptr<std::string>(new std::string(*value)),
std::shared_ptr<std::string>(new std::string(path)))); std::shared_ptr<std::string>(new std::string(path))));
} }