Skip to content

Commit fe1c05f

Browse files
committed
Remove special cases disabling regex support for old C++ libs
Should not be needed any more.
1 parent 43d0ba5 commit fe1c05f

File tree

2 files changed

+1
-38
lines changed

2 files changed

+1
-38
lines changed

include/osmium/util/string_matcher.hpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -54,30 +54,6 @@ DEALINGS IN THE SOFTWARE.
5454
# include <boost/variant.hpp>
5555
#endif
5656

57-
58-
// std::regex isn't implemented properly in glibc++ (before the version
59-
// delivered with GCC 4.9) and libc++ before the version 3.6, so the use is
60-
// disabled by these checks. Checks for GLIBC were based on
61-
// https://stackoverflow.com/questions/12530406/is-gcc-4-8-or-earlier-buggy-about-regular-expressions
62-
// Checks for libc++ are simply based on compiler defines. This is probably
63-
// not optimal but seems to work for now.
64-
#if defined(__GLIBCXX__)
65-
# if ((__cplusplus >= 201402L) || \
66-
defined(_GLIBCXX_REGEX_DFS_QUANTIFIERS_LIMIT) || \
67-
defined(_GLIBCXX_REGEX_STATE_LIMIT))
68-
# define OSMIUM_WITH_REGEX
69-
# else
70-
# pragma message("Disabling regex functionality. See source code for info.")
71-
# endif
72-
#elif defined(__clang__)
73-
# if ((__clang_major__ > 3) || \
74-
(__clang_minor__ == 3 && __clang_minor__ > 5))
75-
# define OSMIUM_WITH_REGEX
76-
# else
77-
# pragma message("Disabling regex functionality")
78-
# endif
79-
#endif
80-
8157
namespace osmium {
8258

8359
/**
@@ -211,7 +187,6 @@ namespace osmium {
211187

212188
}; // class substring
213189

214-
#ifdef OSMIUM_WITH_REGEX
215190
/**
216191
* Matches if the test string matches the regular expression.
217192
*/
@@ -235,7 +210,6 @@ namespace osmium {
235210
}
236211

237212
}; // class regex
238-
#endif
239213

240214
/**
241215
* Matches if the test string is equal to any of the stored strings.
@@ -293,9 +267,7 @@ namespace osmium {
293267
equal,
294268
prefix,
295269
substring,
296-
#ifdef OSMIUM_WITH_REGEX
297270
regex,
298-
#endif
299271
list>;
300272

301273
matcher_type m_matcher;
@@ -388,7 +360,6 @@ namespace osmium {
388360
m_matcher(equal{str}) {
389361
}
390362

391-
#ifdef OSMIUM_WITH_REGEX
392363
/**
393364
* Create a string matcher that will match the specified regex.
394365
* Shortcut for
@@ -398,7 +369,6 @@ namespace osmium {
398369
StringMatcher(const std::regex& aregex) : // NOLINT(google-explicit-constructor, hicpp-explicit-conversions)
399370
m_matcher(regex{aregex}) {
400371
}
401-
#endif
402372

403373
/**
404374
* Create a string matcher that will match if any of the strings

test/t/util/test_string_matcher.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22

33
#include <osmium/util/string_matcher.hpp>
44

5+
#include <regex>
56
#include <sstream>
67
#include <string>
78
#include <type_traits>
89
#include <utility>
910
#include <vector>
1011

11-
#ifdef OSMIUM_WITH_REGEX
12-
#include <regex>
13-
#endif
14-
1512
static_assert(std::is_default_constructible<osmium::StringMatcher>::value, "StringMatcher should be default constructible");
1613
static_assert(std::is_copy_constructible<osmium::StringMatcher>::value, "StringMatcher should be copy constructible");
1714
static_assert(std::is_move_constructible<osmium::StringMatcher>::value, "StringMatcher should be move constructible");
@@ -90,7 +87,6 @@ TEST_CASE("String matcher: empty prefix") {
9087
REQUIRE(m.match(""));
9188
}
9289

93-
#ifdef OSMIUM_WITH_REGEX
9490
TEST_CASE("String matcher: regex prefix") {
9591
const osmium::StringMatcher::regex m{std::regex{"^foo", std::regex::optimize}};
9692
REQUIRE(m.match("foo"));
@@ -107,7 +103,6 @@ TEST_CASE("String matcher: regex substr") {
107103
REQUIRE(m.match("xfoox"));
108104
REQUIRE_FALSE(m.match(""));
109105
}
110-
#endif
111106

112107
TEST_CASE("String matcher: list") {
113108
const osmium::StringMatcher::list m{{"foo", "bar"}};
@@ -157,14 +152,12 @@ TEST_CASE("Construct StringMatcher from string") {
157152
REQUIRE(print(m) == "equal[foo]");
158153
}
159154

160-
#ifdef OSMIUM_WITH_REGEX
161155
TEST_CASE("Construct StringMatcher from regex") {
162156
const osmium::StringMatcher m{std::regex{"^foo"}};
163157
REQUIRE(m("foo"));
164158
REQUIRE_FALSE(m("bar"));
165159
REQUIRE(print(m) == "regex");
166160
}
167-
#endif
168161

169162
TEST_CASE("Construct StringMatcher from list") {
170163
const std::vector<std::string> v{"foo", "xxx"};

0 commit comments

Comments
 (0)