forked from boostorg/regex
Compare commits
44 Commits
remove_03
...
backstep_r
Author | SHA1 | Date | |
---|---|---|---|
57ca08240e | |||
0cbaa4ef17 | |||
f0afa5d9b8 | |||
9a8d2b13a3 | |||
bd0e76f42f | |||
bb9f2b1984 | |||
49c4e8cb8f | |||
e61e5e111e | |||
ccfc76570f | |||
cff442b3e7 | |||
65726f3d2f | |||
5243906d23 | |||
bd821cdedf | |||
d3697ab023 | |||
dca0bdcd7e | |||
d4e7ac721c | |||
1144c1dad8 | |||
cd92ca1ed0 | |||
e3840cf3a6 | |||
fdacaf7d6d | |||
fa2d2e1008 | |||
e5a7bbd399 | |||
028935b104 | |||
f9c3c8c461 | |||
126875cac9 | |||
e469b8aae5 | |||
801d83fb4f | |||
8e2a51e905 | |||
72652f7cde | |||
8dc1fd4a3b | |||
e5ac7686cd | |||
1dcd331879 | |||
cb55913293 | |||
3e32c14965 | |||
c82a797230 | |||
260982ea9e | |||
6efa868bfa | |||
b1301061e5 | |||
6b78d0af7f | |||
ecd5c207cf | |||
4ca037c559 | |||
571fbaf80d | |||
85580fd1ea | |||
57ccc945bd |
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
@ -9,6 +9,7 @@ on:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- feature/**
|
||||
pull_request:
|
||||
release:
|
||||
types: [published, created, edited]
|
||||
|
30
build.jam
Normal file
30
build.jam
Normal file
@ -0,0 +1,30 @@
|
||||
# Copyright René Ferdinand Rivera Morell 2023-2024
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
require-b2 5.2 ;
|
||||
|
||||
constant boost_dependencies :
|
||||
/boost/assert//boost_assert
|
||||
/boost/concept_check//boost_concept_check
|
||||
/boost/config//boost_config
|
||||
/boost/predef//boost_predef
|
||||
/boost/static_assert//boost_static_assert
|
||||
/boost/throw_exception//boost_throw_exception
|
||||
/boost/type_traits//boost_type_traits ;
|
||||
|
||||
project /boost/regex
|
||||
: common-requirements
|
||||
<include>include
|
||||
;
|
||||
|
||||
explicit
|
||||
[ alias boost_regex : build//boost_regex ]
|
||||
[ alias all : boost_regex example test ]
|
||||
;
|
||||
|
||||
call-if : boost-library regex
|
||||
: install boost_regex
|
||||
;
|
||||
|
@ -1,15 +1,20 @@
|
||||
# copyright John Maddock 2003
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt.
|
||||
|
||||
import modules ;
|
||||
import testing ;
|
||||
import errors ;
|
||||
|
||||
project : requirements
|
||||
# default to all warnings on:
|
||||
<warnings>all
|
||||
constant boost_dependencies_private :
|
||||
/boost/core//boost_core
|
||||
;
|
||||
|
||||
project
|
||||
: default-build <warnings>all
|
||||
: common-requirements <library>$(boost_dependencies)
|
||||
: requirements <library>$(boost_dependencies_private)
|
||||
;
|
||||
|
||||
local disable-icu = [ MATCH (--disable-icu) : [ modules.peek : ARGV ] ] ;
|
||||
@ -17,13 +22,13 @@ local disable-icu = [ MATCH (--disable-icu) : [ modules.peek : ARGV ] ] ;
|
||||
rule path_options ( properties * )
|
||||
{
|
||||
local result ;
|
||||
if <address-model>64 in $(properties) && <toolset>msvc in $(properties)
|
||||
if <address-model>64 in $(properties) && <toolset>msvc in $(properties)
|
||||
{
|
||||
result = <search>$(ICU_PATH)/bin64 <search>$(ICU_PATH)/lib64 ;
|
||||
result = <search>$(ICU_PATH)/bin64 <search>$(ICU_PATH)/lib64 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = <search>$(ICU_PATH)/bin <search>$(ICU_PATH)/lib ;
|
||||
result = <search>$(ICU_PATH)/bin <search>$(ICU_PATH)/lib ;
|
||||
}
|
||||
return $(result) ;
|
||||
}
|
||||
@ -34,24 +39,24 @@ rule path_options ( properties * )
|
||||
if ! $(disable-icu)
|
||||
{
|
||||
if [ modules.peek : ICU_LINK ]
|
||||
{
|
||||
{
|
||||
errors.user-error : "The ICU_LINK option is no longer supported by the Boost.Regex build - please refer to the documentation for equivalent options" ;
|
||||
}
|
||||
|
||||
if [ modules.peek : ICU_PATH ]
|
||||
{
|
||||
{
|
||||
ICU_PATH = [ modules.peek : ICU_PATH ] ;
|
||||
}
|
||||
if [ modules.peek : ICU_ICUUC_NAME ]
|
||||
{
|
||||
{
|
||||
ICU_ICUUC_NAME = [ modules.peek : ICU_ICUUC_NAME ] ;
|
||||
}
|
||||
if [ modules.peek : ICU_ICUDT_NAME ]
|
||||
{
|
||||
{
|
||||
ICU_ICUDT_NAME = [ modules.peek : ICU_ICUDT_NAME ] ;
|
||||
}
|
||||
if [ modules.peek : ICU_ICUIN_NAME ]
|
||||
{
|
||||
{
|
||||
ICU_ICUIN_NAME = [ modules.peek : ICU_ICUIN_NAME ] ;
|
||||
}
|
||||
|
||||
@ -102,8 +107,8 @@ if ! $(disable-icu)
|
||||
lib icuin : : <name>this_is_an_invalid_library_name ;
|
||||
}
|
||||
|
||||
ICU_OPTS =
|
||||
<include>$(ICU_PATH)/include
|
||||
ICU_OPTS =
|
||||
<include>$(ICU_PATH)/include
|
||||
<runtime-link>shared:<library>icuuc/<link>shared
|
||||
<runtime-link>shared:<library>icudt/<link>shared
|
||||
<runtime-link>shared:<library>icuin/<link>shared
|
||||
@ -111,7 +116,7 @@ if ! $(disable-icu)
|
||||
<runtime-link>static:<library>icudt
|
||||
<runtime-link>static:<library>icuin
|
||||
<target-os>windows,<toolset>clang:<linkflags>"advapi32.lib"
|
||||
<define>BOOST_HAS_ICU=1
|
||||
<define>BOOST_HAS_ICU=1
|
||||
<runtime-link>static:<define>U_STATIC_IMPLEMENTATION=1
|
||||
;
|
||||
|
||||
@ -144,16 +149,15 @@ explicit has_icu ;
|
||||
|
||||
alias icu_options : : : : [ check-target-builds has_icu : $(ICU_OPTS) : ] ;
|
||||
|
||||
SOURCES =
|
||||
SOURCES =
|
||||
posix_api.cpp
|
||||
wide_posix_api.cpp
|
||||
;
|
||||
|
||||
lib boost_regex : ../src/$(SOURCES) icu_options
|
||||
:
|
||||
<link>shared:<define>BOOST_REGEX_DYN_LINK=1
|
||||
<toolset>gcc-cygwin:<link>static
|
||||
:
|
||||
<link>shared:<define>BOOST_REGEX_DYN_LINK=1
|
||||
<toolset>gcc-cygwin:<link>static
|
||||
: :
|
||||
<define>BOOST_REGEX_NO_LIB=1
|
||||
;
|
||||
|
||||
boost-install boost_regex ;
|
||||
|
||||
|
@ -1,32 +1,34 @@
|
||||
# copyright John Maddock 2003
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt.
|
||||
|
||||
project
|
||||
: requirements
|
||||
<threading>multi
|
||||
: requirements
|
||||
<library>/boost/regex//boost_regex
|
||||
<library>/boost/timer//boost_timer
|
||||
<threading>multi
|
||||
<link>shared:<define>BOOST_REGEX_DYN_LINK=1
|
||||
# There are unidentified linker problems on these platforms:
|
||||
<toolset>mipspro-7.4:<link>static
|
||||
<toolset>sun-5.9:<link>static
|
||||
<toolset>msvc:<warnings>all
|
||||
<toolset>gcc:<warnings>all
|
||||
<toolset>gcc:<cxxflags>-Wextra
|
||||
<toolset>gcc:<warnings>extra
|
||||
<define>U_USING_ICU_NAMESPACE=0
|
||||
#<toolset>gcc-mw:<link>static
|
||||
#<toolset>gcc-mingw:<link>static
|
||||
<toolset>gcc-cygwin:<link>static
|
||||
<define>BOOST_TIMER_ENABLE_DEPRECATED
|
||||
;
|
||||
|
||||
rule regex-test-run ( sources + : input * : name * )
|
||||
{
|
||||
return [
|
||||
return [
|
||||
run
|
||||
# sources
|
||||
$(sources)
|
||||
# dependencies
|
||||
../build//boost_regex
|
||||
/boost/regex//boost_regex
|
||||
: # additional args
|
||||
$(input)
|
||||
: # test-files
|
||||
@ -37,32 +39,33 @@ rule regex-test-run ( sources + : input * : name * )
|
||||
] ;
|
||||
}
|
||||
|
||||
path-constant HERE : . ;
|
||||
|
||||
test-suite regex-examples :
|
||||
|
||||
[ regex-test-run timer/regex_timer.cpp : $(BOOST_ROOT)/libs/regex/example/timer/input_script.txt ]
|
||||
[ regex-test-run grep/grep.cpp ../../program_options/build//boost_program_options/<link>static : -n -b $(BOOST_ROOT)/boost/regex.hpp $(BOOST_ROOT)/boost/type_traits.hpp : test_grep ]
|
||||
[ regex-test-run timer/regex_timer.cpp /boost/smart_ptr//boost_smart_ptr : $(HERE)/timer/input_script.txt ]
|
||||
[ regex-test-run grep/grep.cpp /boost/program_options//boost_program_options/<link>static : -n -b -E include $(HERE)/../include/boost/regex.hpp : test_grep ]
|
||||
[ regex-test-run snippets/credit_card_example.cpp ]
|
||||
[ regex-test-run snippets/mfc_example.cpp ]
|
||||
[ regex-test-run snippets/icu_example.cpp ]
|
||||
[ regex-test-run snippets/partial_regex_grep.cpp : $(BOOST_ROOT)/libs/regex/index.htm ]
|
||||
[ regex-test-run snippets/partial_regex_iterate.cpp : $(BOOST_ROOT)/libs/regex/index.htm ]
|
||||
[ regex-test-run snippets/partial_regex_grep.cpp : $(HERE)/../index.htm ]
|
||||
[ regex-test-run snippets/partial_regex_iterate.cpp : $(HERE)/../index.htm ]
|
||||
[ regex-test-run snippets/partial_regex_match.cpp : 1234-5678-8765-4 ]
|
||||
[ regex-test-run snippets/regex_grep_example_1.cpp : $(BOOST_ROOT)/boost/regex/v5/regex_token_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_grep_example_2.cpp : $(BOOST_ROOT)/boost/regex/v5/regex_token_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_grep_example_3.cpp : $(BOOST_ROOT)/boost/regex/v5/regex_token_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_grep_example_4.cpp : $(BOOST_ROOT)/boost/regex/v5/regex_token_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_grep_example_1.cpp : $(HERE)/../include/boost/regex/v5/regex_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_grep_example_2.cpp : $(HERE)/../include/boost/regex/v5/regex_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_grep_example_3.cpp : $(HERE)/../include/boost/regex/v5/regex_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_grep_example_4.cpp : $(HERE)/../include/boost/regex/v5/regex_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_match_example.cpp : -auto ]
|
||||
[ regex-test-run snippets/regex_merge_example.cpp : $(BOOST_ROOT)/boost/regex/v5/regex_token_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_replace_example.cpp : $(BOOST_ROOT)/boost/regex/v5/regex_token_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_search_example.cpp : $(BOOST_ROOT)/boost/regex/v5/regex_token_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_merge_example.cpp : $(HERE)/../include/boost/regex/v5/regex_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_replace_example.cpp : $(HERE)/../include/boost/regex/v5/regex_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_search_example.cpp : $(HERE)/../include/boost/regex/v5/regex_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_split_example_1.cpp : -auto ]
|
||||
[ regex-test-run snippets/regex_split_example_2.cpp : $(BOOST_ROOT)/libs/regex/doc/html/index.html ]
|
||||
[ regex-test-run snippets/regex_split_example_2.cpp : $(HERE)/../doc/html/index.html ]
|
||||
[ regex-test-run snippets/regex_token_iterator_eg_1.cpp : -auto ]
|
||||
[ regex-test-run snippets/regex_token_iterator_eg_2.cpp : $(BOOST_ROOT)/libs/regex/doc/html/index.html ]
|
||||
[ regex-test-run snippets/regex_iterator_example.cpp : $(BOOST_ROOT)/boost/regex/v5/regex_token_iterator.hpp ]
|
||||
[ regex-test-run snippets/regex_token_iterator_eg_2.cpp : $(HERE)/../doc/html/index.html ]
|
||||
[ regex-test-run snippets/regex_iterator_example.cpp : $(HERE)/../include/boost/regex/v5/regex_iterator.hpp ]
|
||||
[ run snippets/captures_example.cpp
|
||||
../test/captures//boost_regex_extra
|
||||
: : : <threading>multi <define>BOOST_REGEX_MATCH_EXTRA=1 ]
|
||||
|
||||
;
|
||||
|
||||
|
@ -76,13 +76,10 @@ inline long hash_value(char_architype val)
|
||||
//
|
||||
} // namespace boost
|
||||
namespace std{
|
||||
template<> struct char_traits<boost::char_architype>
|
||||
{
|
||||
// The intent is that this template is not instantiated,
|
||||
// but this typedef gives us a chance of compilation in
|
||||
// case it is:
|
||||
typedef boost::char_architype char_type;
|
||||
};
|
||||
//
|
||||
// We should never use this, if we do it should be an error:
|
||||
//
|
||||
template<> struct char_traits<boost::char_architype>;
|
||||
}
|
||||
//
|
||||
// Allocator architype:
|
||||
@ -412,6 +409,10 @@ struct BaseRegexConcept
|
||||
Regex e5(in1, in2, m_flags);
|
||||
ignore_unused_variable_warning(e5);
|
||||
|
||||
// equals:
|
||||
e1 == e2;
|
||||
e1 != e2;
|
||||
|
||||
// assign etc:
|
||||
Regex e;
|
||||
e = m_pointer;
|
||||
|
@ -19,6 +19,15 @@
|
||||
#ifndef BOOST_REGEX_V5_BASIC_REGEX_HPP
|
||||
#define BOOST_REGEX_V5_BASIC_REGEX_HPP
|
||||
|
||||
#include <boost/regex/v5/regbase.hpp>
|
||||
#include <boost/regex/v5/syntax_type.hpp>
|
||||
#include <boost/regex/v5/regex_traits.hpp>
|
||||
#include <boost/regex/v5/states.hpp>
|
||||
#include <boost/regex/v5/regex_raw_buffer.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace boost{
|
||||
@ -488,7 +497,7 @@ public:
|
||||
}
|
||||
//
|
||||
// swap:
|
||||
void swap(basic_regex& that)throw()
|
||||
void swap(basic_regex& that)noexcept
|
||||
{
|
||||
m_pimpl.swap(that.m_pimpl);
|
||||
}
|
||||
@ -533,7 +542,21 @@ public:
|
||||
return status() - that.status();
|
||||
if(flags() != that.flags())
|
||||
return flags() - that.flags();
|
||||
return str().compare(that.str());
|
||||
|
||||
const char_type* i = m_pimpl->begin();
|
||||
const char_type* j = that.m_pimpl->begin();
|
||||
while ((i != m_pimpl->end()) && (j != that.m_pimpl->end()))
|
||||
{
|
||||
if (*i != *j)
|
||||
return *i < *j ? -1 : 1;
|
||||
++i;
|
||||
++j;
|
||||
}
|
||||
if (i != m_pimpl->end())
|
||||
return *i > static_cast<char_type>(0) ? 1 : -1;
|
||||
if (j != that.m_pimpl->end())
|
||||
return *j > static_cast<char_type>(0) ? -1 : 1;
|
||||
return 0;
|
||||
}
|
||||
bool operator==(const basic_regex& e)const
|
||||
{
|
||||
|
@ -28,6 +28,9 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <boost/regex/v5/basic_regex.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
namespace boost{
|
||||
@ -971,7 +974,12 @@ template <class charT, class traits>
|
||||
int basic_regex_creator<charT, traits>::calculate_backstep(re_syntax_base* state)
|
||||
{
|
||||
typedef typename traits::char_class_type m_type;
|
||||
|
||||
int result = 0;
|
||||
int last_alternative_result = -1;
|
||||
|
||||
std::vector<std::tuple<int, re_syntax_base*>> stack;
|
||||
|
||||
while(state)
|
||||
{
|
||||
switch(state->type)
|
||||
@ -990,9 +998,28 @@ int basic_regex_creator<charT, traits>::calculate_backstep(re_syntax_base* state
|
||||
}
|
||||
break;
|
||||
case syntax_element_endmark:
|
||||
if((static_cast<re_brace*>(state)->index == -1)
|
||||
if ((static_cast<re_brace*>(state)->index == -1)
|
||||
|| (static_cast<re_brace*>(state)->index == -2))
|
||||
return result;
|
||||
{
|
||||
// We've finished the calculation, check against any previous alternatives:
|
||||
if (last_alternative_result >= 0)
|
||||
{
|
||||
if (last_alternative_result != result)
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
last_alternative_result = result;
|
||||
|
||||
if (stack.size())
|
||||
{
|
||||
// Skip to next alternative and calculate that as well:
|
||||
std::tie(result, state) = stack.back();
|
||||
stack.pop_back();
|
||||
continue;
|
||||
}
|
||||
else
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
case syntax_element_literal:
|
||||
result += static_cast<re_literal*>(state)->length;
|
||||
@ -1048,11 +1075,13 @@ int basic_regex_creator<charT, traits>::calculate_backstep(re_syntax_base* state
|
||||
continue;
|
||||
case syntax_element_alt:
|
||||
{
|
||||
int r1 = calculate_backstep(state->next.p);
|
||||
int r2 = calculate_backstep(static_cast<re_alt*>(state)->alt.p);
|
||||
if((r1 < 0) || (r1 != r2))
|
||||
// Push the alternative if we haven't pushed too many already:
|
||||
if(stack.size() > BOOST_REGEX_MAX_BLOCKS)
|
||||
return -1;
|
||||
return result + r1;
|
||||
stack.push_back(std::make_tuple(result, static_cast<re_alt*>(state)->alt.p));
|
||||
// and take the first one:
|
||||
state = state->next.p;
|
||||
continue;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
@ -19,6 +19,13 @@
|
||||
#ifndef BOOST_REGEX_V5_BASIC_REGEX_PARSER_HPP
|
||||
#define BOOST_REGEX_V5_BASIC_REGEX_PARSER_HPP
|
||||
|
||||
#include <boost/regex/v5/basic_regex_creator.hpp>
|
||||
|
||||
#include <climits>
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost{
|
||||
namespace BOOST_REGEX_DETAIL_NS{
|
||||
|
||||
|
@ -21,7 +21,12 @@
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
#include <boost/regex/v5/regex_workaround.hpp>
|
||||
#include <boost/regex/v5/primary_transform.hpp>
|
||||
#include <boost/regex/v5/regex_traits_defaults.hpp>
|
||||
|
||||
#include <cctype>
|
||||
#include <cstdint>
|
||||
#include <cwctype>
|
||||
|
||||
namespace boost{
|
||||
|
||||
|
@ -20,6 +20,8 @@
|
||||
#ifndef BOOST_REGEX_V5_CHAR_REGEX_TRAITS_HPP
|
||||
#define BOOST_REGEX_V5_CHAR_REGEX_TRAITS_HPP
|
||||
|
||||
#include <boost/regex/v5/regex_traits.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace deprecated{
|
||||
|
@ -19,6 +19,8 @@
|
||||
#ifndef BOOST_REGEX_V5_ITERATOR_TRAITS_HPP
|
||||
#define BOOST_REGEX_V5_ITERATOR_TRAITS_HPP
|
||||
|
||||
#include <iterator>
|
||||
|
||||
namespace boost{
|
||||
namespace BOOST_REGEX_DETAIL_NS{
|
||||
|
||||
|
@ -19,6 +19,14 @@
|
||||
#ifndef BOOST_REGEX_V5_MATCH_RESULTS_HPP
|
||||
#define BOOST_REGEX_V5_MATCH_RESULTS_HPP
|
||||
|
||||
#include <boost/regex/v5/match_flags.hpp>
|
||||
#include <boost/regex/v5/sub_match.hpp>
|
||||
#include <boost/regex/v5/basic_regex.hpp>
|
||||
#include <boost/regex/v5/regex_format.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace boost{
|
||||
#ifdef BOOST_REGEX_MSVC
|
||||
#pragma warning(push)
|
||||
@ -97,15 +105,23 @@ public:
|
||||
bool empty() const
|
||||
{ return m_subs.size() < 2; }
|
||||
// element access:
|
||||
difference_type length(int sub = 0) const
|
||||
private:
|
||||
difference_type do_get_length(int sub = 0) const
|
||||
{
|
||||
if(m_is_singular)
|
||||
if (m_is_singular)
|
||||
raise_logic_error();
|
||||
sub += 2;
|
||||
if((sub < (int)m_subs.size()) && (sub > 0))
|
||||
if ((sub < (int)m_subs.size()) && (sub > 0))
|
||||
return m_subs[sub].length();
|
||||
return 0;
|
||||
}
|
||||
public:
|
||||
template <class Integer>
|
||||
typename std::enable_if<std::is_integral<Integer>::value, difference_type>::type length(Integer sub) const
|
||||
{
|
||||
return do_get_length(static_cast<int>(sub));
|
||||
}
|
||||
difference_type length() const { return do_get_length(0); }
|
||||
difference_type length(const char_type* sub) const
|
||||
{
|
||||
if(m_is_singular)
|
||||
@ -161,7 +177,8 @@ public:
|
||||
{
|
||||
return position(sub.c_str());
|
||||
}
|
||||
string_type str(int sub = 0) const
|
||||
private:
|
||||
string_type do_get_string(int sub = 0) const
|
||||
{
|
||||
if(m_is_singular)
|
||||
raise_logic_error();
|
||||
@ -177,6 +194,13 @@ public:
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public:
|
||||
template <class Integer>
|
||||
typename std::enable_if<std::is_integral<Integer>::value, string_type>::type str(Integer sub) const
|
||||
{
|
||||
return do_get_string(static_cast<int>(sub));
|
||||
}
|
||||
string_type str() const { return do_get_string(0); }
|
||||
string_type str(const char_type* sub) const
|
||||
{
|
||||
return (*this)[sub].str();
|
||||
@ -196,7 +220,8 @@ public:
|
||||
{
|
||||
return (*this)[sub].str();
|
||||
}
|
||||
const_reference operator[](int sub) const
|
||||
private:
|
||||
const_reference get_at(int sub) const
|
||||
{
|
||||
if(m_is_singular && m_subs.empty())
|
||||
raise_logic_error();
|
||||
@ -207,6 +232,12 @@ public:
|
||||
}
|
||||
return m_null;
|
||||
}
|
||||
public:
|
||||
template <class Integer>
|
||||
typename std::enable_if<std::is_integral<Integer>::value, const_reference>::type operator[](Integer sub) const
|
||||
{
|
||||
return get_at(static_cast<int>(sub));
|
||||
}
|
||||
//
|
||||
// Named sub-expressions:
|
||||
//
|
||||
@ -530,7 +561,7 @@ public:
|
||||
|
||||
void set_named_subs(std::shared_ptr<named_sub_type> subs)
|
||||
{
|
||||
m_named_subs = subs;
|
||||
m_named_subs = std::move(subs);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -18,6 +18,8 @@
|
||||
#ifndef BOOST_REGEX_V5_MEM_BLOCK_CACHE_HPP
|
||||
#define BOOST_REGEX_V5_MEM_BLOCK_CACHE_HPP
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
|
||||
#include <new>
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
#include <mutex>
|
||||
@ -31,6 +33,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost{
|
||||
namespace BOOST_REGEX_DETAIL_NS{
|
||||
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
, m_position(0)
|
||||
{
|
||||
}
|
||||
~regex_error() noexcept override {}
|
||||
~regex_error() noexcept override = default;
|
||||
regex_constants::error_type code()const
|
||||
{ return m_error_code; }
|
||||
std::ptrdiff_t position()const
|
||||
|
@ -12,7 +12,18 @@
|
||||
#ifndef BOOST_REGEX_MATCHER_HPP
|
||||
#define BOOST_REGEX_MATCHER_HPP
|
||||
|
||||
#include <boost/regex/v5/match_flags.hpp>
|
||||
#include <boost/regex/v5/match_results.hpp>
|
||||
#include <boost/regex/v5/regbase.hpp>
|
||||
#include <boost/regex/v5/iterator_category.hpp>
|
||||
#include <boost/regex/v5/states.hpp>
|
||||
#include <boost/regex/v5/regex_traits.hpp>
|
||||
|
||||
#ifndef BOOST_REGEX_STANDALONE
|
||||
#include <boost/throw_exception.hpp>
|
||||
#endif
|
||||
|
||||
#include <climits>
|
||||
|
||||
#ifdef BOOST_REGEX_MSVC
|
||||
# pragma warning(push)
|
||||
@ -28,25 +39,34 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_REGEX_STANDALONE
|
||||
# define BOOST_REGEX_DETAIL_THROW(ex) boost::throw_exception(ex)
|
||||
#else
|
||||
# define BOOST_REGEX_DETAIL_THROW(ex) throw ex
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
namespace BOOST_REGEX_DETAIL_NS{
|
||||
|
||||
//
|
||||
// error checking API:
|
||||
//
|
||||
inline void verify_options(boost::regex_constants::syntax_option_type, match_flag_type mf)
|
||||
inline void verify_options(boost::regex_constants::syntax_option_type, match_flag_type mf)
|
||||
{
|
||||
auto is_perl = (mf & match_perl);
|
||||
auto is_posix = (mf & match_posix);
|
||||
|
||||
if (is_perl && is_posix)
|
||||
{
|
||||
BOOST_REGEX_DETAIL_THROW(std::logic_error("Usage Error: Can't mix Perl and POSIX matching rules"));
|
||||
}
|
||||
|
||||
//
|
||||
// can't mix match_extra with POSIX matching rules:
|
||||
//
|
||||
if ((mf & match_extra) && (mf & match_posix))
|
||||
if ((mf & match_extra) && is_posix)
|
||||
{
|
||||
std::logic_error msg("Usage Error: Can't mix regular expression captures with POSIX matching rules");
|
||||
#ifndef BOOST_REGEX_STANDALONE
|
||||
throw_exception(msg);
|
||||
#else
|
||||
throw msg;
|
||||
#endif
|
||||
BOOST_REGEX_DETAIL_THROW(std::logic_error("Usage Error: Can't mix regular expression captures with POSIX matching rules"));
|
||||
}
|
||||
}
|
||||
//
|
||||
|
@ -20,6 +20,22 @@
|
||||
#ifndef BOOST_REGEX_V5_PERL_MATCHER_COMMON_HPP
|
||||
#define BOOST_REGEX_V5_PERL_MATCHER_COMMON_HPP
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
|
||||
#ifndef BOOST_REGEX_STANDALONE
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#include <boost/regex/v5/perl_matcher.hpp>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#include <boost/regex/v5/basic_regex.hpp>
|
||||
#include <boost/regex/v5/match_flags.hpp>
|
||||
#include <boost/regex/v5/match_results.hpp>
|
||||
|
||||
#ifdef BOOST_REGEX_MSVC
|
||||
# pragma warning(push)
|
||||
#pragma warning(disable:4459)
|
||||
@ -44,12 +60,7 @@ void perl_matcher<BidiIterator, Allocator, traits>::construct_init(const basic_r
|
||||
if(e.empty())
|
||||
{
|
||||
// precondition failure: e is not a valid regex.
|
||||
std::invalid_argument ex("Invalid regular expression object");
|
||||
#ifndef BOOST_REGEX_STANDALONE
|
||||
boost::throw_exception(ex);
|
||||
#else
|
||||
throw e;
|
||||
#endif
|
||||
BOOST_REGEX_DETAIL_THROW(std::invalid_argument("Invalid regular expression object"));
|
||||
}
|
||||
pstate = 0;
|
||||
m_match_flags = f;
|
||||
@ -82,7 +93,11 @@ void perl_matcher<BidiIterator, Allocator, traits>::construct_init(const basic_r
|
||||
match_any_mask = static_cast<unsigned char>((f & match_not_dot_newline) ? BOOST_REGEX_DETAIL_NS::test_not_newline : BOOST_REGEX_DETAIL_NS::test_newline);
|
||||
// Disable match_any if requested in the state machine:
|
||||
if(e.get_data().m_disable_match_any)
|
||||
{
|
||||
if (m_match_flags & match_posix)
|
||||
BOOST_REGEX_DETAIL_THROW(std::logic_error("Invalid regex for POSIX-style matching"));
|
||||
m_match_flags &= regex_constants::match_not_any;
|
||||
}
|
||||
}
|
||||
#ifdef BOOST_REGEX_MSVC
|
||||
# pragma warning(pop)
|
||||
|
@ -20,6 +20,18 @@
|
||||
#ifndef BOOST_REGEX_V5_PERL_MATCHER_NON_RECURSIVE_HPP
|
||||
#define BOOST_REGEX_V5_PERL_MATCHER_NON_RECURSIVE_HPP
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
|
||||
#ifndef BOOST_REGEX_STANDALONE
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#include <boost/regex/v5/perl_matcher.hpp>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#include <boost/regex/v5/mem_block_cache.hpp>
|
||||
|
||||
#ifdef BOOST_REGEX_MSVC
|
||||
@ -1204,7 +1216,10 @@ bool perl_matcher<BidiIterator, Allocator, traits>::skip_until_paren(int index,
|
||||
else if(pstate->type == syntax_element_startmark)
|
||||
{
|
||||
int idx = static_cast<const re_brace*>(pstate)->index;
|
||||
pstate = pstate->next.p;
|
||||
if(idx > 0)
|
||||
match_startmark();
|
||||
else
|
||||
pstate = pstate->next.p;
|
||||
skip_until_paren(idx, false);
|
||||
continue;
|
||||
}
|
||||
|
@ -21,6 +21,10 @@
|
||||
#ifndef BOOST_REGEX_FORMAT_HPP
|
||||
#define BOOST_REGEX_FORMAT_HPP
|
||||
|
||||
#include <boost/regex/v5/match_flags.hpp>
|
||||
#include <boost/regex/v5/sub_match.hpp>
|
||||
#include <boost/regex/v5/regex_traits_defaults.hpp>
|
||||
|
||||
#include <type_traits>
|
||||
#include <functional>
|
||||
|
||||
|
@ -19,6 +19,10 @@
|
||||
#ifndef BOOST_REGEX_V5_REGEX_GREP_HPP
|
||||
#define BOOST_REGEX_V5_REGEX_GREP_HPP
|
||||
|
||||
#include <boost/regex/v5/basic_regex.hpp>
|
||||
#include <boost/regex/v5/match_flags.hpp>
|
||||
#include <boost/regex/v5/match_results.hpp>
|
||||
#include <boost/regex/v5/perl_matcher.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
|
@ -19,6 +19,9 @@
|
||||
#ifndef BOOST_REGEX_V5_REGEX_ITERATOR_HPP
|
||||
#define BOOST_REGEX_V5_REGEX_ITERATOR_HPP
|
||||
|
||||
#include <boost/regex/v5/basic_regex.hpp>
|
||||
#include <boost/regex/v5/match_results.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace boost{
|
||||
|
@ -22,6 +22,9 @@
|
||||
#ifndef BOOST_REGEX_MATCH_HPP
|
||||
#define BOOST_REGEX_MATCH_HPP
|
||||
|
||||
#include <boost/regex/v5/match_results.hpp>
|
||||
#include <boost/regex/v5/perl_matcher.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
//
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
|
||||
namespace boost{
|
||||
namespace BOOST_REGEX_DETAIL_NS{
|
||||
|
@ -22,6 +22,10 @@
|
||||
#define BOOST_REGEX_V5_REGEX_REPLACE_HPP
|
||||
|
||||
|
||||
#include <boost/regex/v5/basic_regex.hpp>
|
||||
#include <boost/regex/v5/match_flags.hpp>
|
||||
#include <boost/regex/v5/regex_iterator.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
template <class OutputIterator, class BidirectionalIterator, class traits, class charT, class Formatter>
|
||||
|
@ -20,6 +20,9 @@
|
||||
#define BOOST_REGEX_V5_REGEX_SEARCH_HPP
|
||||
|
||||
|
||||
#include <boost/regex/v5/match_results.hpp>
|
||||
#include <boost/regex/v5/perl_matcher.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
template <class BidiIterator, class Allocator, class charT, class traits>
|
||||
|
@ -21,6 +21,9 @@
|
||||
#ifndef BOOST_REGEX_SPLIT_HPP
|
||||
#define BOOST_REGEX_SPLIT_HPP
|
||||
|
||||
#include <boost/regex/v5/basic_regex.hpp>
|
||||
#include <boost/regex/v5/match_results.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
#ifdef BOOST_REGEX_MSVC
|
||||
|
@ -19,6 +19,10 @@
|
||||
#ifndef BOOST_REGEX_V5_REGEX_TOKEN_ITERATOR_HPP
|
||||
#define BOOST_REGEX_V5_REGEX_TOKEN_ITERATOR_HPP
|
||||
|
||||
#include <boost/regex/v5/basic_regex.hpp>
|
||||
#include <boost/regex/v5/match_results.hpp>
|
||||
#include <boost/regex/v5/sub_match.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace boost{
|
||||
|
@ -19,6 +19,11 @@
|
||||
#ifndef BOOST_REGEX_V5_STATES_HPP
|
||||
#define BOOST_REGEX_V5_STATES_HPP
|
||||
|
||||
#include <boost/regex/v5/regex_raw_buffer.hpp>
|
||||
|
||||
#include <climits>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost{
|
||||
namespace BOOST_REGEX_DETAIL_NS{
|
||||
|
||||
|
@ -19,6 +19,9 @@
|
||||
#ifndef BOOST_REGEX_V5_SUB_MATCH_HPP
|
||||
#define BOOST_REGEX_V5_SUB_MATCH_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <utility>
|
||||
|
||||
namespace boost{
|
||||
|
||||
template <class BidiIterator>
|
||||
|
@ -19,6 +19,21 @@
|
||||
#ifndef BOOST_REGEX_V5_U32REGEX_ITERATOR_HPP
|
||||
#define BOOST_REGEX_V5_U32REGEX_ITERATOR_HPP
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
|
||||
#ifndef BOOST_REGEX_STANDALONE
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#include <boost/regex/v5/icu.hpp>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#include <boost/regex/v5/match_flags.hpp>
|
||||
#include <boost/regex/v5/match_results.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
template <class BidirectionalIterator>
|
||||
|
@ -19,6 +19,18 @@
|
||||
#ifndef BOOST_REGEX_V5_U32REGEX_TOKEN_ITERATOR_HPP
|
||||
#define BOOST_REGEX_V5_U32REGEX_TOKEN_ITERATOR_HPP
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
|
||||
#ifndef BOOST_REGEX_STANDALONE
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#include <boost/regex/v5/icu.hpp>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
||||
#ifdef BOOST_REGEX_MSVC
|
||||
|
@ -16,6 +16,7 @@
|
||||
* DESCRIPTION: Implements the wide character POSIX API wrappers.
|
||||
*/
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS // for std::wcscpy
|
||||
#define BOOST_REGEX_SOURCE
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
@ -169,11 +170,7 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW*
|
||||
{
|
||||
result = std::wcslen(wnames[code]) + 1;
|
||||
if(buf_size >= result)
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
|
||||
::wcscpy_s(buf, buf_size, wnames[code]);
|
||||
#else
|
||||
std::wcscpy(buf, wnames[code]);
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
@ -193,11 +190,7 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW*
|
||||
(boost::core::swprintf)(localbuf, 5, L"%d", i);
|
||||
#endif
|
||||
if(std::wcslen(localbuf) < buf_size)
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
|
||||
::wcscpy_s(buf, buf_size, localbuf);
|
||||
#else
|
||||
std::wcscpy(buf, localbuf);
|
||||
#endif
|
||||
return std::wcslen(localbuf) + 1;
|
||||
}
|
||||
}
|
||||
@ -207,11 +200,7 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW*
|
||||
(boost::core::swprintf)(localbuf, 5, L"%d", 0);
|
||||
#endif
|
||||
if(std::wcslen(localbuf) < buf_size)
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
|
||||
::wcscpy_s(buf, buf_size, localbuf);
|
||||
#else
|
||||
std::wcscpy(buf, localbuf);
|
||||
#endif
|
||||
return std::wcslen(localbuf) + 1;
|
||||
}
|
||||
if(code <= (int)REG_E_UNKNOWN)
|
||||
|
@ -1,15 +1,16 @@
|
||||
# copyright John Maddock 2003
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt.
|
||||
|
||||
project
|
||||
: requirements
|
||||
<threading>multi
|
||||
<link>shared:<define>BOOST_REGEX_DYN_LINK=1
|
||||
<toolset>msvc-7.1:<define>TEST_MFC=1
|
||||
: requirements
|
||||
<library>/boost/regex//boost_regex
|
||||
<library>/boost/detail//boost_detail
|
||||
<threading>multi
|
||||
<link>shared:<define>BOOST_REGEX_DYN_LINK=1
|
||||
<toolset>msvc-7.1:<define>TEST_MFC=1
|
||||
<toolset>msvc-7.0:<define>TEST_MFC=1
|
||||
<toolset>msvc:<asynch-exceptions>on
|
||||
# There are unidentified linker problems on these platforms:
|
||||
<toolset>mipspro-7.4:<link>static
|
||||
<toolset>sun-5.9:<link>static
|
||||
@ -21,6 +22,8 @@ project
|
||||
#<toolset>gcc-mingw:<link>static
|
||||
#<toolset>gcc-cygwin:<link>static
|
||||
<toolset>sun:<link>static
|
||||
<include>../src
|
||||
<include>.
|
||||
;
|
||||
|
||||
#
|
||||
@ -28,14 +31,14 @@ project
|
||||
#
|
||||
rule regex-test ( name : sources + : requirements * : input-files * )
|
||||
{
|
||||
return [ run $(sources) ../build//boost_regex
|
||||
return [ run $(sources) /boost/regex//boost_regex
|
||||
:
|
||||
: $(input-files)
|
||||
: $(requirements)
|
||||
: $(name) ] ;
|
||||
}
|
||||
|
||||
R_SOURCE =
|
||||
R_SOURCE =
|
||||
basic_tests.cpp
|
||||
main.cpp
|
||||
wmain.cpp
|
||||
@ -70,7 +73,7 @@ run regress/$(R_SOURCE) ../build//boost_regex ../build//icu_options
|
||||
: regex_regress ;
|
||||
|
||||
run regress/$(R_SOURCE) ../build//boost_regex
|
||||
../../thread/build//boost_thread ../build//icu_options
|
||||
/boost/thread//boost_thread ../build//icu_options
|
||||
: # command line
|
||||
: # input files
|
||||
: # requirements
|
||||
@ -78,7 +81,7 @@ run regress/$(R_SOURCE) ../build//boost_regex
|
||||
: regex_regress_threaded ;
|
||||
|
||||
run regress/$(R_SOURCE) ../build//boost_regex
|
||||
../../thread/build//boost_thread ../build//icu_options
|
||||
/boost/thread//boost_thread ../build//icu_options
|
||||
: # command line
|
||||
: # input files
|
||||
: # requirements
|
||||
@ -98,15 +101,15 @@ run unicode/unicode_iterator_test.cpp : : : release <define>TEST_UTF16 : unicode
|
||||
run unicode/unicode_casefold_test.cpp ../build//boost_regex ../build//icu_options ;
|
||||
run object_cache/object_cache_test.cpp ;
|
||||
run config_info/regex_config_info.cpp ../build//boost_regex/<link>static : : : <test-info>always_show_run_output ;
|
||||
run config_info/regex_config_info.cpp ../build//boost_regex : : : <test-info>always_show_run_output : regex_dll_config_info ;
|
||||
run config_info/regex_config_info.cpp ../build//boost_regex : : : <test-info>always_show_run_output : regex_dll_config_info ;
|
||||
run collate_info/collate_info.cpp ../build//boost_regex : : : <test-info>always_show_run_output : test_collate_info ;
|
||||
link concepts/concept_check.cpp : <toolset>gcc:<cxxflags>-Wno-deprecated-copy ;
|
||||
link concepts/concept_check.cpp /boost/range//boost_range : <toolset>gcc:<cxxflags>-Wno-deprecated-copy ;
|
||||
link concepts/concept_check.cpp : <define>BOOST_REGEX_STANDALONE <toolset>gcc:<cxxflags>-Wno-deprecated-copy : standalone_concept_check ;
|
||||
link concepts/icu_concept_check.cpp : <define>BOOST_REGEX_STANDALONE <toolset>gcc:<cxxflags>-Wno-deprecated-copy ;
|
||||
link concepts/icu_concept_check.cpp : <toolset>gcc:<cxxflags>-Wno-deprecated-copy : standalone_icu_concept_check ;
|
||||
link concepts/range_concept_check.cpp : <toolset>gcc:<cxxflags>-Wno-deprecated-copy ;
|
||||
run concepts/test_bug_11988.cpp ;
|
||||
run captures/captures_test.cpp ../build//icu_options : : : <threading>multi <define>BOOST_REGEX_MATCH_EXTRA=1 <define>BOOST_REGEX_NO_LIB=1 : captures_test ;
|
||||
link concepts/range_concept_check.cpp : <toolset>gcc:<cxxflags>-Wno-deprecated-copy <library>/boost/range//boost_range ;
|
||||
run concepts/test_bug_11988.cpp ;
|
||||
run captures/captures_test.cpp ../build//icu_options /boost/array//boost_array : : : <threading>multi <define>BOOST_REGEX_MATCH_EXTRA=1 <define>BOOST_REGEX_NO_LIB=1 : captures_test ;
|
||||
run regress/$(R_SOURCE) ./noeh_test//boost_regex_noeh ../build//icu_options : : : <define>BOOST_NO_EXCEPTIONS=1 <exception-handling>off <link>static <runtime-link>shared : regex_regress_noeh ;
|
||||
compile test_consolidated.cpp ;
|
||||
|
||||
@ -114,12 +117,12 @@ build-project ../example ;
|
||||
|
||||
# `quick` target (for CI)
|
||||
run quick.cpp ../build//boost_regex ;
|
||||
compile test_warnings.cpp
|
||||
compile test_warnings.cpp
|
||||
: <toolset>msvc:<warnings>all <toolset>msvc:<warnings-as-errors>on
|
||||
<toolset>gcc:<warnings>all <toolset>gcc:<warnings-as-errors>on
|
||||
<toolset>clang:<warnings>all <toolset>clang:<warnings-as-errors>on ;
|
||||
|
||||
compile test_warnings.cpp
|
||||
compile test_warnings.cpp
|
||||
: <toolset>msvc:<warnings>all <toolset>msvc:<warnings-as-errors>on
|
||||
<toolset>gcc:<warnings>all <toolset>gcc:<warnings-as-errors>on
|
||||
<toolset>clang:<warnings>all <toolset>clang:<warnings-as-errors>on
|
||||
@ -131,4 +134,8 @@ compile test_windows_defs_2.cpp ;
|
||||
compile test_windows_defs_3.cpp ;
|
||||
compile test_windows_defs_4.cpp ;
|
||||
|
||||
run issue153.cpp : : : <toolset>msvc:<linkflags>-STACK:2097152 ;
|
||||
run issue153.cpp : : : "<toolset>msvc:<linkflags>-STACK:2097152" ;
|
||||
run issue227.cpp ;
|
||||
run issue232.cpp ;
|
||||
run lookbehind_recursion_stress_test.cpp ;
|
||||
|
||||
|
@ -15,4 +15,4 @@ target_link_libraries(quick Boost::regex Boost::core)
|
||||
enable_testing()
|
||||
add_test(quick quick)
|
||||
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
|
@ -20,4 +20,4 @@ target_link_libraries(quick Boost::regex Boost::core)
|
||||
enable_testing()
|
||||
add_test(quick quick)
|
||||
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
|
@ -19,4 +19,4 @@ target_link_libraries(quick_icu Boost::regex_icu)
|
||||
enable_testing()
|
||||
add_test(quick_icu quick_icu)
|
||||
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
|
1569
test/config_info.cpp
Normal file
1569
test/config_info.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -19,7 +19,7 @@
|
||||
#endif
|
||||
|
||||
#define main OLD_MAIN
|
||||
#include <libs/config/test/config_info.cpp>
|
||||
#include <config_info.cpp>
|
||||
#undef main
|
||||
#ifndef NEW_MAIN
|
||||
# define NEW_MAIN main
|
||||
|
19
test/issue227.cpp
Normal file
19
test/issue227.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (c) 2024
|
||||
* Christian Mazakas
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
#include <string>
|
||||
|
||||
int main() {
|
||||
boost::regex rx("(*ACCEPT)*+\\1((*ACCEPT)*+\\K)");
|
||||
std::string str = "Z";
|
||||
boost::smatch what;
|
||||
boost::regex_search(str, what, rx, boost::match_default | boost::match_partial);
|
||||
}
|
71
test/issue232.cpp
Normal file
71
test/issue232.cpp
Normal file
@ -0,0 +1,71 @@
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
|
||||
template<std::size_t N0, std::size_t N = N0 - 1>
|
||||
void tester( char const (&str)[ N0 ] )
|
||||
{
|
||||
std::vector<char> s(N, '\0');
|
||||
std::memcpy(s.data(), str, N);
|
||||
boost::regex rx(s.begin(), s.end());
|
||||
|
||||
std::vector<std::string> wheres;
|
||||
wheres.push_back(std::string(15, 'H'));
|
||||
wheres.push_back("");
|
||||
wheres.push_back(" ");
|
||||
|
||||
// Perl-style matching
|
||||
for (auto const& where : wheres) {
|
||||
boost::match_results<std::string::const_iterator> what;
|
||||
bool match = boost::regex_match(where, what, rx, boost::match_default | boost::match_partial | boost::match_any | boost::match_perl);
|
||||
(void) match;
|
||||
}
|
||||
|
||||
// POSIX-style matching
|
||||
for (auto const& where : wheres) {
|
||||
try {
|
||||
boost::match_results<std::string::const_iterator> what;
|
||||
bool match = boost::regex_match(where, what, rx, boost::match_default | boost::match_partial | boost::match_any | boost::match_posix);
|
||||
(void) match;
|
||||
} catch(...) {}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
// test strings derived from fuzzing
|
||||
// we keep a simple human-readable version
|
||||
char const str1[] = "(Y(*COMMIT)|\\K\\D|.)+";
|
||||
char const str2[] = "(Y(*COMMIT){||\\K\\D|||||||||\\K|||ss|||||.|\232*(?(50)\027\0204657|H)\020}\031\000.* 6.'?-i)+[L??.\000\000\000\004\000\000\000\000?..<[\000\024R]*+";
|
||||
char const str3[] = "(Y(*COMMIT)\xFF\x80|\\L\\K||||||||||.|||||\x84|||||\x00\x00\x10||||||.* .'?-i)[L??...-i)[L??...[\x00\x14R]*+";
|
||||
char const str4[] = "(Y(*COMMIT)\x96||.* .* .\\K|||\x9F||||\x9C|.|||||\x84\x99|||\x01\x00\x00\x00|||'?-i#PL\x00\x01.\x86??OMMIT)?...[\x00\x14R]*+";
|
||||
|
||||
tester(str1);
|
||||
tester(str2);
|
||||
tester(str3);
|
||||
tester(str4);
|
||||
|
||||
// prove that we catch certain impossible scenarios
|
||||
|
||||
{
|
||||
char const* str = "abcd";
|
||||
boost::regex rx(str);
|
||||
boost::match_results<std::string::const_iterator> what;
|
||||
std::string where(15, 'H');
|
||||
BOOST_TEST_THROWS(boost::regex_match(where, rx, boost::match_posix | boost::match_perl), std::logic_error);
|
||||
}
|
||||
|
||||
{
|
||||
char const* str = "ab(*COMMIT)cd";
|
||||
boost::regex rx(str);
|
||||
boost::match_results<std::string::const_iterator> what;
|
||||
std::string where(15, 'H');
|
||||
BOOST_TEST_THROWS(boost::regex_match(where, rx, boost::match_posix), std::logic_error);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
28
test/lookbehind_recursion_stress_test.cpp
Normal file
28
test/lookbehind_recursion_stress_test.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2024
|
||||
* John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string s("(?<=(");
|
||||
s.append(1000, '|');
|
||||
s += "))";
|
||||
boost::regex rx(s);
|
||||
|
||||
s = "(?<=(a";
|
||||
for (unsigned i = 0; i < 1000; ++i)
|
||||
{
|
||||
s += "|a";
|
||||
}
|
||||
s += "))";
|
||||
boost::regex rx2(s);
|
||||
}
|
@ -3,12 +3,12 @@
|
||||
* Copyright (c) 2011
|
||||
* John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <libs/regex/src/posix_api.cpp>
|
||||
#include <libs/regex/src/wide_posix_api.cpp>
|
||||
#include <posix_api.cpp>
|
||||
#include <wide_posix_api.cpp>
|
||||
|
Reference in New Issue
Block a user