Skip to content

Commit

Permalink
Fixes for SCN_DISABLE_REGEX
Browse files Browse the repository at this point in the history
  • Loading branch information
eliaskosunen committed Dec 4, 2023
1 parent 5c2fcaa commit b0a9a35
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/arch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ jobs:
working-directory: ${{ runner.workspace }}/build
shell: bash
run: |
cmake -G "${{ matrix.gen }}" -A ${{ matrix.arch }} -DCMAKE_CROSSCOMPILING=ON -DSCN_CI=ON $GITHUB_WORKSPACE
cmake -G "${{ matrix.gen }}" -A ${{ matrix.arch }} -DCMAKE_CROSSCOMPILING=ON \
-DSCN_DISABLE_REGEX=ON \
-DSCN_CI=ON $GITHUB_WORKSPACE
- name: Build
working-directory: ${{ runner.workspace }}/build
Expand Down
19 changes: 17 additions & 2 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ jobs:
- cxx: g++-12
os: 20.04
# FIXME?: simdutf has problems with clang 6 and 7 (_ktestc_mask64_u8 undefined)
#- cxx: clang++-7
#- cxx: clang++-6.0
- cxx: clang++-7
- cxx: clang++-6.0
# FIXME: Locally unreproducible ICE
- cxx: clang++-9
# FIXME: some weird linker issue: undefined reference to range_default_scanner default constructor
Expand Down Expand Up @@ -476,9 +476,24 @@ jobs:
- name: Setup CMake and Ninja
uses: lukka/get-cmake@latest

- name: Install ICU
if: matrix.icu == 'ON'
run: |
sudo apt-get update
sudo apt-get install -yq ibicu-dev
- name: Install Boost
if: matrix.engine == 'Boost'
run: |
sudo apt-get update
sudo apt-get install -yq libboost-all-dev
- name: Install re2
if: matrix.engine == 're2'
run: |
sudo apt-get update
sudo apt-get install -yq abseil
git clone https://github.com/google/re2 -b 2023-11-01 --depth=1
cd re2
mkdir build
Expand Down
4 changes: 2 additions & 2 deletions include/scn/fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ namespace scn {
// detail/regex.h:

template <typename CharT>
struct basic_regex_match;
class basic_regex_match;
template <typename CharT>
struct basic_regex_matches;
class basic_regex_matches;

using regex_match = basic_regex_match<char>;
using wregex_match = basic_regex_match<wchar_t>;
Expand Down
8 changes: 4 additions & 4 deletions src/scn/impl/reader/regex_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

#include <scn/detail/regex.h>

#if !SCN_DISABLE_REGEX

#include <scn/impl/reader/common.h>

#if SCN_REGEX_BACKEND == SCN_REGEX_BACKEND_STD
Expand All @@ -41,6 +39,8 @@ namespace scn {
SCN_BEGIN_NAMESPACE

namespace impl {
#if !SCN_DISABLE_REGEX

#if SCN_REGEX_BACKEND == SCN_REGEX_BACKEND_STD
constexpr auto make_regex_flags(detail::regex_flags flags)
-> scan_expected<std::regex_constants::syntax_option_type>
Expand Down Expand Up @@ -434,6 +434,8 @@ namespace scn {
#endif
}

#endif // !SCN_DISABLE_REGEX

template <typename SourceCharT>
struct regex_matches_reader
: public reader_base<regex_matches_reader<SourceCharT>,
Expand Down Expand Up @@ -499,5 +501,3 @@ namespace scn {

SCN_END_NAMESPACE
} // namespace scn

#endif
4 changes: 4 additions & 0 deletions tests/unittests/regex_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

using namespace std::string_view_literals;

#if !SCN_DISABLE_REGEX

TEST(RegexTest, InvalidRegexString)
{
auto r = scn::scan<std::string>("foobar123", "{:/[a/}");
Expand Down Expand Up @@ -266,3 +268,5 @@ TEST(RegexTest, NoCaseAndNoCaptureFlagMatches)
testing::ElementsAre(testing::Optional(
testing::Property(&scn::regex_match::get, "FooBar123"sv))));
}

#endif // !SCN_DISABLE_REGEX

0 comments on commit b0a9a35

Please sign in to comment.