You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ab...@apache.org on 2019/11/06 13:06:34 UTC
[nifi-minifi-cpp] branch master updated: MINIFICPP-1073 - Fixed the
suffix computation for Regex matches.
This is an automated email from the ASF dual-hosted git repository.
aboda pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
The following commit(s) were added to refs/heads/master by this push:
new 8bfc29d MINIFICPP-1073 - Fixed the suffix computation for Regex matches.
8bfc29d is described below
commit 8bfc29dd370e12cb882c38a3b0dcbb40bc9fbac1
Author: Andre Araujo <as...@gmail.com>
AuthorDate: Thu Oct 24 06:35:37 2019 +0000
MINIFICPP-1073 - Fixed the suffix computation for Regex matches.
First char of the suffix was being cut-off.
Signed-off-by: Arpad Boda <ab...@apache.org>
This closes #669
---
libminifi/src/utils/RegexUtils.cpp | 2 +-
libminifi/test/unit/RegexUtilsTests.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libminifi/src/utils/RegexUtils.cpp b/libminifi/src/utils/RegexUtils.cpp
index b569cef..9e88280 100644
--- a/libminifi/src/utils/RegexUtils.cpp
+++ b/libminifi/src/utils/RegexUtils.cpp
@@ -146,7 +146,7 @@ bool Regex::match(const std::string &pattern) {
if ((size_t) matches_[0].rm_eo >= pattern.size()) {
suffix_ = "";
} else {
- suffix_ = pattern.substr(matches_[0].rm_eo + 1);
+ suffix_ = pattern.substr(matches_[0].rm_eo);
}
return true;
}
diff --git a/libminifi/test/unit/RegexUtilsTests.cpp b/libminifi/test/unit/RegexUtilsTests.cpp
index 961621a..fff615b 100644
--- a/libminifi/test/unit/RegexUtilsTests.cpp
+++ b/libminifi/test/unit/RegexUtilsTests.cpp
@@ -34,7 +34,7 @@ TEST_CASE("TestRegexUtils::single_match", "[regex1]") {
auto ret = r1.getResult();
std::vector<std::string> ans = {"Speed limit 130", "130"};
REQUIRE(ans == ret);
- REQUIRE("| Speed limit 80" == r1.getSuffix());
+ REQUIRE(" | Speed limit 80" == r1.getSuffix());
}
TEST_CASE("TestRegexUtils::invalid_construction", "[regex2]") {