Skip to content

Commit b58018e

Browse files
author
Felipe Zimmerle
committed
Fix multimatch behavior to match what we have on v2
1 parent a47738a commit b58018e

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/rule.cc

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ inline void Rule::executeTransformation(actions::Action *a,
362362
if (m_containsMultiMatchAction) {
363363
std::shared_ptr<std::string> t(new std::string(a->m_name));
364364
ret->push_back(std::make_pair(u, t));
365+
(*nth)++;
365366
}
366367
*value = u;
367368
}
@@ -378,7 +379,6 @@ inline void Rule::executeTransformation(actions::Action *a,
378379
a->m_name + ": \"" + \
379380
utils::string::limitTo(80, newValue) +"\"");
380381
#endif
381-
(*nth)++;
382382
}
383383

384384

@@ -396,10 +396,7 @@ std::list<std::pair<std::shared_ptr<std::string>,
396396

397397
if (m_containsMultiMatchAction == true) {
398398
ret.push_back(std::make_pair(
399-
std::shared_ptr<std::string>(value),
400-
std::shared_ptr<std::string>(new std::string(path))));
401-
ret.push_back(std::make_pair(
402-
std::shared_ptr<std::string>(value),
399+
std::shared_ptr<std::string>(new std::string(*value)),
403400
std::shared_ptr<std::string>(new std::string(path))));
404401
}
405402

@@ -461,17 +458,16 @@ std::list<std::pair<std::shared_ptr<std::string>,
461458
}
462459

463460
if (m_containsMultiMatchAction == true) {
464-
// v2 checks the last entry twice. Don't know why.
465-
ret.push_back(ret.back());
466-
467461
#ifndef NO_LOGS
468462
trans->debug(9, "multiMatch is enabled. " \
469463
+ std::to_string(ret.size()) + \
470464
" values to be tested.");
471465
#endif
472-
} else {
466+
}
467+
468+
if (!m_containsMultiMatchAction) {
473469
ret.push_back(std::make_pair(
474-
value,
470+
std::shared_ptr<std::string>(new std::string(*value)),
475471
std::shared_ptr<std::string>(new std::string(path))));
476472
}
477473

0 commit comments

Comments
 (0)