From 0bc12dfd955db7825eb674d97d8094043498aec2 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Wed, 28 Nov 2018 10:59:09 +0100 Subject: [PATCH] Use std::regex library instead of boost one Works equally fine for us, and allows for removing a dependency. --- .gitmodules | 3 --- include/linuxdeploy/plugin/base_impl.h | 4 ++-- include/linuxdeploy/plugin/plugin.h | 7 ++----- lib/CMakeLists.txt | 8 -------- lib/boost-regex | 1 - src/CMakeLists.txt | 4 ++-- src/core/elf.cpp | 8 ++++---- src/plugin/plugin.cpp | 6 +++--- 8 files changed, 13 insertions(+), 28 deletions(-) delete mode 160000 lib/boost-regex diff --git a/.gitmodules b/.gitmodules index eaaa619..bb0dd6a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,9 +7,6 @@ [submodule "lib/boost-filesystem"] path = lib/boost-filesystem url = https://github.com/boostorg/filesystem.git -[submodule "lib/boost-regex"] - path = lib/boost-regex - url = https://github.com/boostorg/regex.git [submodule "lib/boost-system"] path = lib/boost-system url = https://github.com/boostorg/system.git diff --git a/include/linuxdeploy/plugin/base_impl.h b/include/linuxdeploy/plugin/base_impl.h index 15a10d0..2307589 100644 --- a/include/linuxdeploy/plugin/base_impl.h +++ b/include/linuxdeploy/plugin/base_impl.h @@ -38,8 +38,8 @@ namespace linuxdeploy { apiLevel = getApiLevelFromExecutable(); pluginType = getPluginTypeFromExecutable(); - boost::cmatch res; - boost::regex_match(path.filename().c_str(), res, PLUGIN_EXPR); + std::smatch res; + std::regex_match(path.filename().string(), res, PLUGIN_EXPR); name = res[1].str(); }; diff --git a/include/linuxdeploy/plugin/plugin.h b/include/linuxdeploy/plugin/plugin.h index b50b67c..1606ea3 100644 --- a/include/linuxdeploy/plugin/plugin.h +++ b/include/linuxdeploy/plugin/plugin.h @@ -1,10 +1,7 @@ // system includes #include #include - -// library includes -#include -#include +#include // local includes #include "linuxdeploy/core/log.h" @@ -22,7 +19,7 @@ namespace linuxdeploy { /* * Official regular expression to check filenames for plugins */ - static const boost::regex PLUGIN_EXPR(R"(^linuxdeploy-plugin-([^\s\.-]+)(?:-[^\.]+)?(?:\..+)?$)"); + static const std::regex PLUGIN_EXPR(R"(^linuxdeploy-plugin-([^\s\.-]+)(?:-[^\.]+)?(?:\..+)?$)"); /* * Plugin interface. diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index a6ed21e..90373eb 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -94,14 +94,6 @@ if(NOT USE_SYSTEM_BOOST) target_include_directories(boost_filesystem PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/boost-filesystem/include) target_link_libraries(boost_filesystem PUBLIC boost_config boost_utility boost_system) - file(GLOB boost_regex_srcs ${CMAKE_CURRENT_SOURCE_DIR}/boost-regex/src/*.cpp) - add_library(boost_regex STATIC ${boost_regex_srcs}) - target_include_directories(boost_regex PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/boost-regex/include) - target_link_libraries(boost_regex PUBLIC - boost_config boost_predef boost_assert boost_throw_exception boost_smart_ptr boost_core boost_mpl - boost_type_traits boost_static_assert boost_integer boost_preprocessor boost_functional boost_detail - ) - add_library(boost_numeric_conversion INTERFACE) set_property(TARGET boost_numeric_conversion PROPERTY INTERFACE_INCLUDE_DIRECTORIES "$") set_property(TARGET boost_numeric_conversion PROPERTY INTERFACE_LINK_LIBRARIES "boost_config") diff --git a/lib/boost-regex b/lib/boost-regex deleted file mode 160000 index a9fc8fb..0000000 --- a/lib/boost-regex +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a9fc8fb5de8262cdf100ff2af06d2c819f251b4e diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e049b05..932128e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,10 +7,10 @@ include_directories(${PROJECT_SOURCE_DIR}/include) if(USE_SYSTEM_BOOST) set(Boost_USE_STATIC_LIBS ON) find_package(Boost REQUIRED COMPONENTS filesystem regex) - set(BOOST_LIBS Boost::filesystem Boost::regex) + set(BOOST_LIBS Boost::filesystem) else() # use custom built libs - set(BOOST_LIBS boost_system boost_filesystem boost_regex boost_lexical_cast) + set(BOOST_LIBS boost_system boost_filesystem boost_lexical_cast) endif() diff --git a/src/core/elf.cpp b/src/core/elf.cpp index 2f9254b..2c25957 100644 --- a/src/core/elf.cpp +++ b/src/core/elf.cpp @@ -1,10 +1,10 @@ // system includes #include #include +#include #include // library includes -#include #include #include @@ -134,11 +134,11 @@ namespace linuxdeploy { auto outputAndError = util::subprocess::check_output_error(lddProc); - const boost::regex expr(R"(\s*(.+)\s+\=>\s+(.+)\s+\((.+)\)\s*)"); - boost::smatch what; + const std::regex expr(R"(\s*(.+)\s+\=>\s+(.+)\s+\((.+)\)\s*)"); + std::smatch what; for (const auto& line : util::splitLines(outputAndError.first)) { - if (boost::regex_search(line, what, expr)) { + if (std::regex_search(line, what, expr)) { auto libraryPath = what[2].str(); util::trim(libraryPath); paths.push_back(bf::absolute(libraryPath)); diff --git a/src/plugin/plugin.cpp b/src/plugin/plugin.cpp index 4b34943..ebae75d 100644 --- a/src/plugin/plugin.cpp +++ b/src/plugin/plugin.cpp @@ -1,11 +1,11 @@ // system headers +#include #include #include #include // library headers #include -#include #include #include @@ -84,9 +84,9 @@ namespace linuxdeploy { } // entry name must match regular expression - boost::cmatch res; + std::smatch res; - if (!boost::regex_match(i->path().filename().string().c_str(), res, PLUGIN_EXPR)) { + if (!std::regex_match(i->path().filename().string(), res, PLUGIN_EXPR)) { ldLog() << LD_DEBUG << "Doesn't match plugin regex, skipping:" << i->path() << std::endl; continue; }