Skip to content

Commit

Permalink
Merge pull request #18395 from dcamper/hpcc-31365-boost-regex-always
Browse files Browse the repository at this point in the history
HPCC-31365 Unconditionally use Boost regex
  • Loading branch information
GordonSmith authored Mar 13, 2024
2 parents 8b1d7d1 + bcc57fa commit f1790b7
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 113 deletions.
30 changes: 4 additions & 26 deletions cmake_modules/commonSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -839,32 +839,10 @@ IF ("${COMMONSETUP_DONE}" STREQUAL "")
endif()
endif(USE_URIPARSER)

if(USE_BOOST_REGEX)
if(CENTOS_6_BOOST)
include(${CMAKE_MODULE_PATH}/buildBOOST_REGEX.cmake)
message(STATUS "CENTOS_6_BOOST_REGEX enabled")
add_definitions (-D_USE_BOOST_REGEX)
else()
find_package(Boost COMPONENTS regex)
if (Boost_REGEX_FOUND)
message(STATUS "BOOST_REGEX enabled")
add_definitions (-D_USE_BOOST_REGEX)
else()
message(FATAL_ERROR "BOOST_REGEX requested but package not found")
endif()
endif()
else(USE_BOOST_REGEX)
if (USE_C11_REGEX)
if ((NOT CMAKE_COMPILER_IS_GNUCC) OR (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9.0))
message(STATUS "C11_REGEX enabled")
add_definitions (-D_USE_C11_REGEX)
else()
message(STATUS "C11_REGEX requested but not supported on this platform")
endif()
else(USE_C11_REGEX)
message(STATUS "NO REGEX requested")
endif(USE_C11_REGEX)
endif(USE_BOOST_REGEX)
find_package(Boost COMPONENTS regex)
if (NOT Boost_REGEX_FOUND)
message(FATAL_ERROR "BOOST_REGEX required but package not found")
endif()

if(USE_PARQUET)
message(STATUS "Parquet enabled")
Expand Down
5 changes: 0 additions & 5 deletions cmake_modules/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ option(SIGN_MODULES "Enable signing of ecl standard library modules" OFF)
option(USE_CPPUNIT "Enable unit tests (requires cppunit)" OFF)
option(USE_OPENLDAP "Enable OpenLDAP support (requires OpenLDAP)" ON)
option(USE_ICU "Enable unicode support (requires ICU)" ON)
option(USE_BOOST_REGEX "Configure use of boost regex" ON)
option(CENTOS_6_BOOST "Supply regex library on CentOS 6" OFF)
# USE_C11_REGEX is only checked if USE_BOOST_REGEX is OFF
# to disable REGEX altogether turn both off
option(USE_C11_REGEX "Configure use of c++11 std::regex" ON)
option(Boost_USE_STATIC_LIBS "Use boost_regex static library for RPM BUILD" OFF)
option(USE_OPENSSL "Configure use of OpenSSL" ON)
option(USE_OPENSSLV3 "Configure use of OpenSSL Version 3 or newer" ON)
Expand Down
5 changes: 0 additions & 5 deletions cmake_modules/plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@ if (USE_AZURE)
set(VCPKG_AZURE "${VCPKG_INCLUDE}")
endif()

set(VCPKG_BOOST_REGEX "${VCPKG_SUPPRESS}")
if (USE_BOOST_REGEX)
set(VCPKG_BOOST_REGEX "${VCPKG_INCLUDE}")
endif()

set(VCPKG_CPPUNIT "${VCPKG_SUPPRESS}")
if (USE_CPPUNIT)
set(VCPKG_CPPUNIT "${VCPKG_INCLUDE}")
Expand Down
3 changes: 0 additions & 3 deletions configuration/configmgr/configmgrlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ INCLUDE_DIRECTORIES(

ADD_DEFINITIONS( -D_USRDLL -DCFGMGRLIB_EXPORTS)
HPCC_ADD_LIBRARY( configmgr SHARED ${SRCS} )
if(CENTOS_6_BOOST)
add_dependencies(configmgr generate-boost-regex)
endif()
TARGET_LINK_LIBRARIES( configmgr jlib)

INSTALL ( TARGETS configmgr RUNTIME DESTINATION ${EXEC_DIR} LIBRARY DESTINATION ${LIB_DIR} )
4 changes: 2 additions & 2 deletions lib2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ elseif (WIN32)
find_file (ZLIB_BIN "zlib.dll" "${EXTERNALS_DIRECTORY}/zlib/1.2.8/lib/Win32" NO_DEFAULT_PATH)
endif()
set(DYLIBS "")
if (NOT USE_NATIVE_LIBRARIES AND USE_BOOST_REGEX)
if (NOT USE_NATIVE_LIBRARIES)
list(APPEND DYLIBS ${BOOST_REGEX_BIN})
endif (NOT USE_NATIVE_LIBRARIES AND USE_BOOST_REGEX)
endif (NOT USE_NATIVE_LIBRARIES)
list(APPEND DYLIBS ${ICU_DT_BIN} ${ICU_IN_BIN} ${ICU_UC_BIN})
list(APPEND DYLIBS ${OPENSSL_LIB_BIN} ${OPENSSL_SSL_BIN})
list(APPEND DYLIBS ${XALAN_C_BIN} ${XALAN_MESSAGES_BIN})
Expand Down
7 changes: 1 addition & 6 deletions rtl/eclrtl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,7 @@ endif ()

HPCC_ADD_LIBRARY( eclrtl SHARED ${SRCS} )

if(CENTOS_6_BOOST)
add_dependencies(eclrtl boost-regex)
target_link_libraries( eclrtl boost-regex)
elseif(USE_BOOST_REGEX)
target_link_libraries( eclrtl Boost::boost Boost::regex )
endif()
target_link_libraries( eclrtl Boost::boost Boost::regex )

target_link_libraries ( eclrtl
jlib
Expand Down
62 changes: 0 additions & 62 deletions rtl/eclrtl/eclregex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
############################################################################## */

#include "limits.h"
#if defined(_USE_BOOST_REGEX)
#include "boost/regex.hpp" // must precede platform.h ; n.b. this uses a #pragma comment(lib, ...) to link the appropriate .lib in MSVC
#elif defined(_USE_C11_REGEX)
#include <regex>
#endif
#include "platform.h"
#include "eclrtl.hpp"
#include "eclrtl_imp.hpp"
Expand All @@ -31,23 +27,12 @@
#define UTF8_CODEPAGE "UTF-8"
#define UTF8_MAXSIZE 4

#if defined(_USE_BOOST_REGEX) || defined(_USE_C11_REGEX)

#if defined(_USE_BOOST_REGEX)
using boost::regex;
using boost::regex_search;
using boost::regex_replace;
using boost::regex_iterator;
using boost::cmatch;
using boost::match_results;
#else
using std::regex;
using std::regex_search;
using std::regex_replace;
using std::regex_iterator;
using std::cmatch;
using std::match_results;
#endif

class CStrRegExprFindInstance : implements IStrRegExprFindInstance
{
Expand Down Expand Up @@ -81,11 +66,9 @@ class CStrRegExprFindInstance : implements IStrRegExprFindInstance
{
std::string msg = "Error in regex search: ";
msg += e.what();
#if defined(_USE_BOOST_REGEX)
msg += "(regex: ";
msg += regEx->str();
msg += ")";
#endif
rtlFail(0, msg.c_str());
}

Expand Down Expand Up @@ -145,23 +128,12 @@ class CCompiledStrRegExpr : implements ICompiledStrRegExpr
{
try
{
#if defined(_USE_BOOST_REGEX)
if (_isCaseSensitive)
regEx.assign(_regExp, regex::perl);
else
regEx.assign(_regExp, regex::perl | regex::icase);
#else
if (_isCaseSensitive)
regEx.assign(_regExp, regex::ECMAScript);
else
regEx.assign(_regExp, regex::ECMAScript | regex::icase);
#endif
}
#if defined(_USE_BOOST_REGEX)
catch(const boost::bad_expression & e)
#else
catch(const std::regex_error & e)
#endif
{
std::string msg = "Bad regular expression: ";
msg += e.what();
Expand All @@ -181,21 +153,15 @@ class CCompiledStrRegExpr : implements ICompiledStrRegExpr
try
{
// tgt = boost::regex_merge(src, cre->regEx, fmt, boost::format_perl); //Algorithm regex_merge has been renamed regex_replace, existing code will continue to compile, but new code should use regex_replace instead.
#if defined(_USE_BOOST_REGEX)
tgt = regex_replace(src, regEx, fmt, boost::format_perl);
#else
tgt = regex_replace(src, regEx, fmt);
#endif
}
catch(const std::runtime_error & e)
{
std::string msg = "Error in regex replace: ";
msg += e.what();
#if defined(_USE_BOOST_REGEX)
msg += "(regex: ";
msg += regEx.str();
msg += ")";
#endif
rtlFail(0, msg.c_str());
}
outlen = tgt.length();
Expand Down Expand Up @@ -469,31 +435,3 @@ ECLRTL_API void rtlDestroyUStrRegExprFindInstance(IUStrRegExprFindInstance * fin
{
}
#endif

#else // _USE_BOOST_REGEX or _USE_C11_REGEX not set
ECLRTL_API ICompiledStrRegExpr * rtlCreateCompiledStrRegExpr(const char * regExpr, bool isCaseSensitive)
{
rtlFail(0, "Boost/C++11 regex disabled");
}

ECLRTL_API void rtlDestroyCompiledStrRegExpr(ICompiledStrRegExpr * compiledExpr)
{
}

ECLRTL_API void rtlDestroyStrRegExprFindInstance(IStrRegExprFindInstance * findInst)
{
}

ECLRTL_API ICompiledUStrRegExpr * rtlCreateCompiledUStrRegExpr(const UChar * regExpr, bool isCaseSensitive)
{
rtlFail(0, "Boost/C++11 regex disabled");
}

ECLRTL_API void rtlDestroyCompiledUStrRegExpr(ICompiledUStrRegExpr * compiledExpr)
{
}

ECLRTL_API void rtlDestroyUStrRegExprFindInstance(IUStrRegExprFindInstance * findInst)
{
}
#endif // _USE_BOOST_REGEX or _USE_C11_REGEX
5 changes: 1 addition & 4 deletions vcpkg.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@
"platform": "@VCPKG_AZURE@"
},
"boost-property-tree",
{
"name": "boost-regex",
"platform": "@VCPKG_BOOST_REGEX@"
},
"boost-regex",
{
"name": "cpp-driver",
"platform": "@VCPKG_CASSANDRAEMBED@"
Expand Down

0 comments on commit f1790b7

Please sign in to comment.