17
17
#include " primops.hh"
18
18
19
19
#include < boost/container/small_vector.hpp>
20
- #include < boost/regex.hpp>
21
20
#include < nlohmann/json.hpp>
22
21
23
22
#include < sys/types.h>
26
25
27
26
#include < algorithm>
28
27
#include < cstring>
28
+ #include < regex>
29
29
#include < dlfcn.h>
30
30
31
31
#include < cmath>
@@ -3886,30 +3886,19 @@ static RegisterPrimOp primop_convertHash({
3886
3886
.fun = prim_convertHash,
3887
3887
});
3888
3888
3889
- // regex aliases, switch between boost and std
3890
- using regex = boost::regex;
3891
- using regex_error = boost::regex_error;
3892
- using cmatch = boost::cmatch;
3893
- using cregex_iterator = boost::cregex_iterator;
3894
- namespace regex_constants = boost::regex_constants;
3895
- // overloaded function alias
3896
- constexpr auto regex_match = [] (auto &&...args) {
3897
- return boost::regex_match (std::forward<decltype (args)>(args)...);
3898
- };
3899
-
3900
3889
struct RegexCache
3901
3890
{
3902
3891
// TODO use C++20 transparent comparison when available
3903
- std::unordered_map<std::string_view, regex> cache;
3892
+ std::unordered_map<std::string_view, std:: regex> cache;
3904
3893
std::list<std::string> keys;
3905
3894
3906
- regex get (std::string_view re)
3895
+ std:: regex get (std::string_view re)
3907
3896
{
3908
3897
auto it = cache.find (re);
3909
3898
if (it != cache.end ())
3910
3899
return it->second ;
3911
3900
keys.emplace_back (re);
3912
- return cache.emplace (keys.back (), regex (keys.back (), regex::extended)).first ->second ;
3901
+ return cache.emplace (keys.back (), std:: regex (keys.back (), std:: regex::extended)).first ->second ;
3913
3902
}
3914
3903
};
3915
3904
@@ -3929,8 +3918,8 @@ void prim_match(EvalState & state, const PosIdx pos, Value * * args, Value & v)
3929
3918
NixStringContext context;
3930
3919
const auto str = state.forceString (*args[1 ], context, pos, " while evaluating the second argument passed to builtins.match" );
3931
3920
3932
- cmatch match;
3933
- if (!regex_match (str.begin (), str.end (), match, regex)) {
3921
+ std:: cmatch match;
3922
+ if (!std:: regex_match (str.begin (), str.end (), match, regex)) {
3934
3923
v.mkNull ();
3935
3924
return ;
3936
3925
}
@@ -3945,8 +3934,8 @@ void prim_match(EvalState & state, const PosIdx pos, Value * * args, Value & v)
3945
3934
(v.listElems ()[i] = state.allocValue ())->mkString (match[i + 1 ].str ());
3946
3935
}
3947
3936
3948
- } catch (regex_error & e) {
3949
- if (e.code () == regex_constants::error_space) {
3937
+ } catch (std:: regex_error & e) {
3938
+ if (e.code () == std:: regex_constants::error_space) {
3950
3939
// limit is _GLIBCXX_REGEX_STATE_LIMIT for libstdc++
3951
3940
state.debugThrowLastTrace (EvalError ({
3952
3941
.msg = hintfmt (" memory limit exceeded by regular expression '%s'" , re),
@@ -4009,8 +3998,8 @@ void prim_split(EvalState & state, const PosIdx pos, Value * * args, Value & v)
4009
3998
NixStringContext context;
4010
3999
const auto str = state.forceString (*args[1 ], context, pos, " while evaluating the second argument passed to builtins.split" );
4011
4000
4012
- auto begin = cregex_iterator (str.begin (), str.end (), regex);
4013
- auto end = cregex_iterator ();
4001
+ auto begin = std:: cregex_iterator (str.begin (), str.end (), regex);
4002
+ auto end = std:: cregex_iterator ();
4014
4003
4015
4004
// Any matches results are surrounded by non-matching results.
4016
4005
const size_t len = std::distance (begin, end);
@@ -4049,8 +4038,8 @@ void prim_split(EvalState & state, const PosIdx pos, Value * * args, Value & v)
4049
4038
4050
4039
assert (idx == 2 * len + 1 );
4051
4040
4052
- } catch (regex_error & e) {
4053
- if (e.code () == regex_constants::error_space) {
4041
+ } catch (std:: regex_error & e) {
4042
+ if (e.code () == std:: regex_constants::error_space) {
4054
4043
// limit is _GLIBCXX_REGEX_STATE_LIMIT for libstdc++
4055
4044
state.debugThrowLastTrace (EvalError ({
4056
4045
.msg = hintfmt (" memory limit exceeded by regular expression '%s'" , re),
0 commit comments