You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bb...@apache.org on 2021/07/20 15:15:57 UTC
[geode-native] branch develop updated: GEODE-9431: Replaced std
regex with Boost due to RHEL8. (#831)
This is an automated email from the ASF dual-hosted git repository.
bbender pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git
The following commit(s) were added to refs/heads/develop by this push:
new 7bcaa9e GEODE-9431: Replaced std regex with Boost due to RHEL8. (#831)
7bcaa9e is described below
commit 7bcaa9ee5806020f5a07c5919c419df6556debf9
Author: Matthew Reddington <mr...@pivotal.io>
AuthorDate: Tue Jul 20 10:15:49 2021 -0500
GEODE-9431: Replaced std regex with Boost due to RHEL8. (#831)
* Replaced std regex with Boost due to RHEL8.
* Fix formatting issues
Co-authored-by: Blake Bender <bb...@vmware.com>
---
cppcache/CMakeLists.txt | 1 +
cppcache/integration-test/CacheHelper.cpp | 26 +++++++++++++-------------
cppcache/integration/framework/CMakeLists.txt | 1 +
cppcache/integration/framework/GfshExecute.cpp | 15 +++++++++------
cppcache/integration/framework/GfshExecute.h | 1 -
cppcache/src/LocalRegion.cpp | 6 +++---
cppcache/src/Log.cpp | 12 ++++++------
cppcache/src/ThinClientRegion.cpp | 8 ++++----
cppcache/src/statistics/HostStatSampler.cpp | 11 +++++------
cppcache/src/statistics/HostStatSampler.hpp | 1 -
cppcache/test/ByteArrayFixture.cpp | 2 +-
cppcache/test/CacheableStringTests.cpp | 1 -
cppcache/test/ClientProxyMembershipIDTest.cpp | 6 +++---
cppcache/test/LoggingTest.cpp | 13 +++++++------
cppcache/test/gtest_extensions.h | 9 +++++----
dependencies/boost/CMakeLists.txt | 1 +
16 files changed, 59 insertions(+), 55 deletions(-)
diff --git a/cppcache/CMakeLists.txt b/cppcache/CMakeLists.txt
index 975f706..5d3a080 100644
--- a/cppcache/CMakeLists.txt
+++ b/cppcache/CMakeLists.txt
@@ -94,6 +94,7 @@ target_link_libraries(_apache-geode INTERFACE
Boost::filesystem
Boost::thread
Boost::stacktrace
+ Boost::regex
XercesC::XercesC
OpenSSL::SSL
OpenSSL::Crypto
diff --git a/cppcache/integration-test/CacheHelper.cpp b/cppcache/integration-test/CacheHelper.cpp
index a7be4fd..f45fa54 100644
--- a/cppcache/integration-test/CacheHelper.cpp
+++ b/cppcache/integration-test/CacheHelper.cpp
@@ -16,13 +16,13 @@
*/
#include <fstream>
-#include <regex>
#include <list>
#include <ace/INET_Addr.h>
#include <ace/SOCK_Acceptor.h>
#include <boost/process.hpp>
+#include <boost/regex.hpp>
#include <geode/SystemProperties.hpp>
#include <geode/PoolManager.hpp>
@@ -1219,18 +1219,18 @@ void CacheHelper::replacePortsInFile(int hostPort1, int hostPort2,
std::istreambuf_iterator<char>());
in.close();
- contents = std::regex_replace(contents, std::regex("HOST_PORT1"),
- std::to_string(hostPort1));
- contents = std::regex_replace(contents, std::regex("HOST_PORT2"),
- std::to_string(hostPort2));
- contents = std::regex_replace(contents, std::regex("HOST_PORT3"),
- std::to_string(hostPort3));
- contents = std::regex_replace(contents, std::regex("HOST_PORT4"),
- std::to_string(hostPort4));
- contents = std::regex_replace(contents, std::regex("LOC_PORT1"),
- std::to_string(locPort1));
- contents = std::regex_replace(contents, std::regex("LOC_PORT2"),
- std::to_string(locPort2));
+ contents = boost::regex_replace(contents, boost::regex("HOST_PORT1"),
+ std::to_string(hostPort1));
+ contents = boost::regex_replace(contents, boost::regex("HOST_PORT2"),
+ std::to_string(hostPort2));
+ contents = boost::regex_replace(contents, boost::regex("HOST_PORT3"),
+ std::to_string(hostPort3));
+ contents = boost::regex_replace(contents, boost::regex("HOST_PORT4"),
+ std::to_string(hostPort4));
+ contents = boost::regex_replace(contents, boost::regex("LOC_PORT1"),
+ std::to_string(locPort1));
+ contents = boost::regex_replace(contents, boost::regex("LOC_PORT2"),
+ std::to_string(locPort2));
std::ofstream out(outFile, std::ios::out);
out << contents;
diff --git a/cppcache/integration/framework/CMakeLists.txt b/cppcache/integration/framework/CMakeLists.txt
index 50d5865..ae69e8b 100644
--- a/cppcache/integration/framework/CMakeLists.txt
+++ b/cppcache/integration/framework/CMakeLists.txt
@@ -51,6 +51,7 @@ target_link_libraries(integration-framework
Boost::filesystem
Boost::process
Boost::asio
+ Boost::regex
PRIVATE
_WarningsAsError
internal
diff --git a/cppcache/integration/framework/GfshExecute.cpp b/cppcache/integration/framework/GfshExecute.cpp
index 7253062..69b71b6 100644
--- a/cppcache/integration/framework/GfshExecute.cpp
+++ b/cppcache/integration/framework/GfshExecute.cpp
@@ -31,6 +31,7 @@
#pragma warning(disable : 4596)
#endif
#include <boost/log/trivial.hpp>
+#include <boost/regex.hpp>
#if defined(_WINDOWS)
std::mutex g_child_mutex;
@@ -128,15 +129,17 @@ void GfshExecute::extractConnectionCommand(
auto jmxManagerHost = std::string("localhost");
auto jmxManagerPort = std::string("1099");
- std::regex jmxManagerHostRegex("bind-address=([^\\s]+)");
- std::smatch jmxManagerHostMatch;
- if (std::regex_search(command, jmxManagerHostMatch, jmxManagerHostRegex)) {
+ boost::regex jmxManagerHostRegex("bind-address=([^\\s]+)");
+ boost::smatch jmxManagerHostMatch;
+ if (boost::regex_search(command, jmxManagerHostMatch,
+ jmxManagerHostRegex)) {
jmxManagerHost = jmxManagerHostMatch[1];
}
- std::regex jmxManagerPortRegex("jmx-manager-port=(\\d+)");
- std::smatch jmxManagerPortMatch;
- if (std::regex_search(command, jmxManagerPortMatch, jmxManagerPortRegex)) {
+ boost::regex jmxManagerPortRegex("jmx-manager-port=(\\d+)");
+ boost::smatch jmxManagerPortMatch;
+ if (boost::regex_search(command, jmxManagerPortMatch,
+ jmxManagerPortRegex)) {
jmxManagerPort = jmxManagerPortMatch[1];
}
diff --git a/cppcache/integration/framework/GfshExecute.h b/cppcache/integration/framework/GfshExecute.h
index fb70617..46b2b52 100644
--- a/cppcache/integration/framework/GfshExecute.h
+++ b/cppcache/integration/framework/GfshExecute.h
@@ -22,7 +22,6 @@
#include <algorithm>
#include <iostream>
-#include <regex>
#include <string>
#include <geode/Exception.hpp>
diff --git a/cppcache/src/LocalRegion.cpp b/cppcache/src/LocalRegion.cpp
index ce73add..4ee67db 100644
--- a/cppcache/src/LocalRegion.cpp
+++ b/cppcache/src/LocalRegion.cpp
@@ -17,9 +17,9 @@
#include "LocalRegion.hpp"
-#include <regex>
#include <vector>
+#include <boost/regex.hpp>
#include <boost/thread/lock_types.hpp>
#include <geode/PoolManager.hpp>
@@ -3251,9 +3251,9 @@ void LocalRegion::clearKeysOfInterestRegex(const std::string& pattern) {
return;
}
- std::regex expression{pattern};
+ boost::regex expression{pattern};
for (const auto& key : keys()) {
- if (std::regex_search(key->toString(), expression)) {
+ if (boost::regex_search(key->toString(), expression)) {
auto err = localDestroyNoCallbacks(key);
if (err != GF_CACHE_ENTRY_NOT_FOUND) {
throwExceptionIfError("LocalRegion::clearKeysOfInterest", err);
diff --git a/cppcache/src/Log.cpp b/cppcache/src/Log.cpp
index 1c3ff8a..82ee5a8 100644
--- a/cppcache/src/Log.cpp
+++ b/cppcache/src/Log.cpp
@@ -24,7 +24,6 @@
#include <ctime>
#include <map>
#include <mutex>
-#include <regex>
#include <sstream>
#include <string>
#include <thread>
@@ -33,6 +32,7 @@
#include <boost/asio/ip/host_name.hpp>
#include <boost/filesystem.hpp>
#include <boost/process/environment.hpp>
+#include <boost/regex.hpp>
#include <geode/ExceptionTypes.hpp>
#include <geode/util/LogLevel.hpp>
@@ -154,7 +154,7 @@ void Log::calculateUsedDiskSpace() {
void Log::buildRollFileMapping() {
const auto filterstring = g_fullpath.stem().string() + "-(\\d+)\\.log$";
- const std::regex my_filter(filterstring);
+ const boost::regex my_filter(filterstring);
g_rollFiles.clear();
@@ -164,10 +164,10 @@ void Log::buildRollFileMapping() {
i != end_itr; ++i) {
if (boost::filesystem::is_regular_file(i->status())) {
std::string filename = i->path().filename().string();
- std::regex testPattern(filterstring);
- std::match_results<std::string::const_iterator> testMatches;
- if (std::regex_search(std::string::const_iterator(filename.begin()),
- filename.cend(), testMatches, testPattern)) {
+ boost::regex testPattern(filterstring);
+ boost::match_results<std::string::const_iterator> testMatches;
+ if (boost::regex_search(std::string::const_iterator(filename.begin()),
+ filename.cend(), testMatches, testPattern)) {
auto index = std::atoi(
std::string(testMatches[1].first, testMatches[1].second).c_str());
g_rollFiles[index] = i->path();
diff --git a/cppcache/src/ThinClientRegion.cpp b/cppcache/src/ThinClientRegion.cpp
index 2d9fb81..1d96cb4 100644
--- a/cppcache/src/ThinClientRegion.cpp
+++ b/cppcache/src/ThinClientRegion.cpp
@@ -18,8 +18,8 @@
#include "ThinClientRegion.hpp"
#include <algorithm>
-#include <regex>
+#include <boost/regex.hpp>
#include <boost/thread/lock_types.hpp>
#include <geode/PoolManager.hpp>
@@ -585,11 +585,11 @@ std::shared_ptr<SelectResults> ThinClientRegion::query(
throw IllegalArgumentException("Region query predicate string is empty");
}
- static const std::regex isFullQueryRegex("^\\s*(?:select|import)\\b",
- std::regex::icase);
+ static const boost::regex isFullQueryRegex("^\\s*(?:select|import)\\b",
+ boost::regex::icase);
std::string squery;
- if (std::regex_search(predicate, isFullQueryRegex)) {
+ if (boost::regex_search(predicate, isFullQueryRegex)) {
squery = predicate;
} else {
squery = "select distinct * from ";
diff --git a/cppcache/src/statistics/HostStatSampler.cpp b/cppcache/src/statistics/HostStatSampler.cpp
index 34510ea..d39f448 100644
--- a/cppcache/src/statistics/HostStatSampler.cpp
+++ b/cppcache/src/statistics/HostStatSampler.cpp
@@ -20,7 +20,6 @@
#include <algorithm>
#include <chrono>
#include <map>
-#include <regex>
#include <thread>
#include <utility>
#include <vector>
@@ -372,9 +371,9 @@ void HostStatSampler::doSample(const boost::filesystem::path& archiveFilename) {
template <typename _Function>
void HostStatSampler::forEachIndexStatFile(_Function function) const {
- const std::regex statsFilter(m_archiveFileName.stem().string() +
- R"(-([\d]+))" +
- m_archiveFileName.extension().string());
+ const boost::regex statsFilter(m_archiveFileName.stem().string() +
+ R"(-([\d]+))" +
+ m_archiveFileName.extension().string());
auto dir = m_archiveFileName.parent_path();
if (dir.empty()) {
@@ -387,11 +386,11 @@ void HostStatSampler::forEachIndexStatFile(_Function function) const {
boost::adaptors::filtered(
static_cast<bool (*)(const boost::filesystem::path&)>(
&boost::filesystem::is_regular_file))) {
- std::smatch match;
+ boost::smatch match;
const auto& file = entry.path();
const auto filename = file.filename();
const auto& filenameStr = filename.string();
- if (std::regex_match(filenameStr, match, statsFilter)) {
+ if (boost::regex_match(filenameStr, match, statsFilter)) {
const auto index = std::stoi(match[1].str());
function(index, file);
}
diff --git a/cppcache/src/statistics/HostStatSampler.hpp b/cppcache/src/statistics/HostStatSampler.hpp
index ad6656e..ba3523a 100644
--- a/cppcache/src/statistics/HostStatSampler.hpp
+++ b/cppcache/src/statistics/HostStatSampler.hpp
@@ -24,7 +24,6 @@
#include <chrono>
#include <memory>
#include <mutex>
-#include <regex>
#include <string>
#include <thread>
#include <vector>
diff --git a/cppcache/test/ByteArrayFixture.cpp b/cppcache/test/ByteArrayFixture.cpp
index 4cb6b3b..a03bc20 100644
--- a/cppcache/test/ByteArrayFixture.cpp
+++ b/cppcache/test/ByteArrayFixture.cpp
@@ -20,7 +20,7 @@
::testing::AssertionResult ByteArrayFixture::assertByteArrayEqual(
const char* /*expectedStr*/, const char* /*bytesStr*/, const char* expected,
const apache::geode::client::ByteArray& bytes) {
- // One would normally just use std::regex but gcc 4.4.7 is lacking.
+ // One would normally just use boost::regex but gcc 4.4.7 is lacking.
const std::string actual(apache::geode::client::ByteArray::toString(bytes));
std::string::size_type actualPos = 0;
const std::string pattern(expected);
diff --git a/cppcache/test/CacheableStringTests.cpp b/cppcache/test/CacheableStringTests.cpp
index c4a15fe..d9624e8 100644
--- a/cppcache/test/CacheableStringTests.cpp
+++ b/cppcache/test/CacheableStringTests.cpp
@@ -18,7 +18,6 @@
#include <stdint.h>
#include <limits>
-#include <regex>
#include <gtest/gtest.h>
diff --git a/cppcache/test/ClientProxyMembershipIDTest.cpp b/cppcache/test/ClientProxyMembershipIDTest.cpp
index fba153e..bcc60df 100644
--- a/cppcache/test/ClientProxyMembershipIDTest.cpp
+++ b/cppcache/test/ClientProxyMembershipIDTest.cpp
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-#include <regex>
#include <vector>
#include <boost/endian/conversion.hpp>
+#include <boost/regex.hpp>
#include <gtest/gtest.h>
@@ -49,8 +49,8 @@ TEST(ClientProxyMembershipIDTest, testCreate) {
cpmID.hashcode(),
apache::geode::client::internal::geode_hash<std::string>{}(":0:0:0:1") +
static_cast<int32_t>(cpmID.getHostPort()));
- EXPECT_TRUE(std::regex_search(
+ EXPECT_TRUE(boost::regex_search(
cpmID.getDSMemberIdForThinClientUse(),
- std::regex(
+ boost::regex(
std::string("localhost(.*):2:").append(uniqueTag).append(":myDs"))));
}
diff --git a/cppcache/test/LoggingTest.cpp b/cppcache/test/LoggingTest.cpp
index 1a8130c..240d097 100644
--- a/cppcache/test/LoggingTest.cpp
+++ b/cppcache/test/LoggingTest.cpp
@@ -16,11 +16,11 @@
*/
#include <map>
-#include <regex>
#include <string>
#include <util/Log.hpp>
#include <boost/filesystem.hpp>
+#include <boost/regex.hpp>
#include <gtest/gtest.h>
@@ -174,7 +174,7 @@ class LoggingTest : public testing::Test {
boost::filesystem::absolute(boost::filesystem::path(logFilePath)) /
filename;
const auto filterstring = basePath.stem().string() + "-(\\d+)\\.log$";
- const std::regex my_filter(filterstring);
+ const boost::regex my_filter(filterstring);
rolledFiles.clear();
@@ -184,10 +184,11 @@ class LoggingTest : public testing::Test {
i != end_itr; ++i) {
if (boost::filesystem::is_regular_file(i->status())) {
std::string rootFilename = i->path().filename().string();
- std::regex testPattern(filterstring);
- std::match_results<std::string::const_iterator> testMatches;
- if (std::regex_search(std::string::const_iterator(rootFilename.begin()),
- rootFilename.cend(), testMatches, testPattern)) {
+ boost::regex testPattern(filterstring);
+ boost::match_results<std::string::const_iterator> testMatches;
+ if (boost::regex_search(
+ std::string::const_iterator(rootFilename.begin()),
+ rootFilename.cend(), testMatches, testPattern)) {
auto index = std::atoi(
std::string(testMatches[1].first, testMatches[1].second).c_str());
rolledFiles[index] = i->path();
diff --git a/cppcache/test/gtest_extensions.h b/cppcache/test/gtest_extensions.h
index 4c29f0d..574adaf 100644
--- a/cppcache/test/gtest_extensions.h
+++ b/cppcache/test/gtest_extensions.h
@@ -22,9 +22,10 @@
#include <iostream>
#include <limits>
-#include <regex>
#include <string>
+#include <boost/regex.hpp>
+
#include <gtest/gtest.h>
#include <geode/internal/chrono/duration.hpp>
@@ -65,9 +66,9 @@ inline std::string squash(const std::string& str, size_t maxLength = 60) {
inline ::testing::AssertionResult regexMatch(const char* s1_expression,
const char* /*s2_expression*/,
- const std::regex& regex,
+ const boost::regex& regex,
const std::string& source) {
- if (!std::regex_match(source, regex)) {
+ if (!boost::regex_match(source, regex)) {
return ::testing::AssertionFailure()
<< squash(source) << " !~ " << s1_expression;
}
@@ -79,7 +80,7 @@ inline ::testing::AssertionResult regexMatch(const char* /*s1_expression*/,
const char* /*s2_expression*/,
const std::string& regex,
const std::string& source) {
- if (!std::regex_match(source, std::regex(regex))) {
+ if (!boost::regex_match(source, boost::regex(regex))) {
return ::testing::AssertionFailure()
<< squash(source) << " !~ /" << regex << "/";
}
diff --git a/dependencies/boost/CMakeLists.txt b/dependencies/boost/CMakeLists.txt
index edde139..78e8068 100644
--- a/dependencies/boost/CMakeLists.txt
+++ b/dependencies/boost/CMakeLists.txt
@@ -145,6 +145,7 @@ add_boost_library(chrono DEPENDENCIES Boost::chrono)
add_boost_library(stacktrace LIBRARIES "" DEPENDENCIES Boost::boost)
add_boost_library(asio LIBRARIES "" DEPENDENCIES Boost::boost)
add_boost_library(process LIBRARIES "" DEPENDENCIES Boost::system)
+add_boost_library(regex DEPENDENCIES Boost::boost)
target_compile_definitions(boost_stacktrace INTERFACE
BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED