forked from boostorg/regex
Merged regex-4 branch.
[SVN r18430]
This commit is contained in:
12
test/Jamfile
12
test/Jamfile
@ -58,6 +58,18 @@ test-suite regex
|
||||
c_compiler_checks/wide_posix_api_check.cpp
|
||||
]
|
||||
|
||||
[ regex-test bad_expression_test
|
||||
: <template>test # sources
|
||||
pathology/bad_expression_test.cpp
|
||||
<lib>../../test/build/boost_test_exec_monitor
|
||||
]
|
||||
|
||||
[ regex-test recursion_test
|
||||
: <template>test # sources
|
||||
pathology/recursion_test.cpp
|
||||
<lib>../../test/build/boost_test_exec_monitor
|
||||
]
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@ CXX= g++ $(INCLUDES) -I../../../../ -I./ $(CXXFLAGS) -L../../build/gcc $(LDFLAGS
|
||||
SOURCES=tests.cpp parse.cpp regress.cpp ../../../test/src/cpp_main.cpp ../../../test/src/execution_monitor.cpp
|
||||
|
||||
total : gcc_regress
|
||||
./gcc_regress tests.txt
|
||||
export LD_LIBRARY_PATH="../../build/gcc:$LD_LIBRARY_PATH" && ./gcc_regress tests.txt
|
||||
|
||||
gcc_regress : $(SOURCES)
|
||||
$(CXX) -O2 -o gcc_regress $(SOURCES) -lboost_regex $(LIBS)
|
||||
@ -59,5 +59,6 @@ debug : $(SOURCES)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -52,22 +52,28 @@ flag_info flag_data[] = {
|
||||
{ BOOST_RE_STR("REG_NOTEOL"), 10, REG_NOTEOL, 1 },
|
||||
{ BOOST_RE_STR("REG_STARTEND"), 12, REG_STARTEND, 1 },
|
||||
|
||||
{ BOOST_RE_STR("basic"), 5, regbase::basic, 2 },
|
||||
{ BOOST_RE_STR("escape_in_lists"), 15, regbase::escape_in_lists, 2 },
|
||||
{ BOOST_RE_STR("char_classes"), 12, regbase::char_classes, 2 },
|
||||
{ BOOST_RE_STR("intervals"), 9, regbase::intervals, 2 },
|
||||
{ BOOST_RE_STR("limited_ops"), 11, regbase::limited_ops, 2 },
|
||||
{ BOOST_RE_STR("newline_alt"), 11, regbase::newline_alt, 2 },
|
||||
{ BOOST_RE_STR("bk_plus_qm"), 10, regbase::bk_plus_qm, 2 },
|
||||
{ BOOST_RE_STR("bk_braces"), 9, regbase::bk_braces, 2 },
|
||||
{ BOOST_RE_STR("bk_parens"), 9, regbase::bk_parens, 2 },
|
||||
{ BOOST_RE_STR("bk_refs"), 7, regbase::bk_refs, 2 },
|
||||
{ BOOST_RE_STR("bk_vbar"), 7, regbase::bk_vbar, 2 },
|
||||
{ BOOST_RE_STR("use_except"), 10, regbase::use_except, 2 },
|
||||
{ BOOST_RE_STR("literal"), 7, regbase::literal, 2 },
|
||||
{ BOOST_RE_STR("normal"), 6, regbase::normal, 2 },
|
||||
{ BOOST_RE_STR("basic"), 5, regbase::basic, 2 },
|
||||
{ BOOST_RE_STR("extended"), 8, regbase::extended, 2 },
|
||||
{ BOOST_RE_STR("basic"), 5, regex_constants::basic, 2 },
|
||||
{ BOOST_RE_STR("escape_in_lists"), 15, regex_constants::escape_in_lists, 2 },
|
||||
{ BOOST_RE_STR("char_classes"), 12, regex_constants::char_classes, 2 },
|
||||
{ BOOST_RE_STR("intervals"), 9, regex_constants::intervals, 2 },
|
||||
{ BOOST_RE_STR("limited_ops"), 11, regex_constants::limited_ops, 2 },
|
||||
{ BOOST_RE_STR("newline_alt"), 11, regex_constants::newline_alt, 2 },
|
||||
{ BOOST_RE_STR("bk_plus_qm"), 10, regex_constants::bk_plus_qm, 2 },
|
||||
{ BOOST_RE_STR("bk_braces"), 9, regex_constants::bk_braces, 2 },
|
||||
{ BOOST_RE_STR("bk_parens"), 9, regex_constants::bk_parens, 2 },
|
||||
{ BOOST_RE_STR("bk_refs"), 7, regex_constants::bk_refs, 2 },
|
||||
{ BOOST_RE_STR("bk_vbar"), 7, regex_constants::bk_vbar, 2 },
|
||||
{ BOOST_RE_STR("use_except"), 10, regex_constants::use_except, 2 },
|
||||
{ BOOST_RE_STR("literal"), 7, regex_constants::literal, 2 },
|
||||
{ BOOST_RE_STR("nosubs"), 6, regex_constants::nosubs, 2 },
|
||||
{ BOOST_RE_STR("optimize"), 8, regex_constants::optimize, 2 },
|
||||
#ifndef BOOST_REGEX_V3
|
||||
{ BOOST_RE_STR("perlex"), 6, regex_constants::perlex, 2 },
|
||||
#endif
|
||||
{ BOOST_RE_STR("normal"), 6, regex_constants::normal, 2 },
|
||||
{ BOOST_RE_STR("basic"), 5, regex_constants::basic, 2 },
|
||||
{ BOOST_RE_STR("extended"), 8, regex_constants::extended, 2 },
|
||||
{ BOOST_RE_STR("perl"), 6, regex_constants::perl, 2 },
|
||||
|
||||
{ BOOST_RE_STR("match_default"), 13, match_default, 3 },
|
||||
{ BOOST_RE_STR("match_not_bol"), 13, match_not_bol, 3 },
|
||||
@ -83,7 +89,9 @@ flag_info flag_data[] = {
|
||||
{ BOOST_RE_STR("match_not_null"), 14, match_not_null, 3 },
|
||||
{ BOOST_RE_STR("match_continuous"), 16, match_continuous, 3 },
|
||||
{ BOOST_RE_STR("match_partial"), 13, match_partial, 3 },
|
||||
{ BOOST_RE_STR("match_nosubs"), 12, match_nosubs, 3 },
|
||||
|
||||
{ BOOST_RE_STR("format_all"), 10, format_all, 3 },
|
||||
{ BOOST_RE_STR("format_sed"), 10, format_sed, 3 },
|
||||
{ BOOST_RE_STR("format_perl"), 11, format_perl, 3 },
|
||||
{ BOOST_RE_STR("format_no_copy"), 14, format_no_copy, 3 },
|
||||
@ -94,6 +102,7 @@ flag_info flag_data[] = {
|
||||
{ BOOST_RE_STR("REG_GREP"), 8, REG_GREP, 4 },
|
||||
{ BOOST_RE_STR("REG_MERGE"), 9, REG_MERGE, 4 },
|
||||
{ BOOST_RE_STR("REG_MERGE_COPY"), 14, REG_MERGE_COPY, 4 },
|
||||
{ BOOST_RE_STR("REG_PARTIAL_MATCH"), 17, REG_PARTIAL_MATCH, 4 },
|
||||
|
||||
{ BOOST_RE_STR(""), 0, 0, 0 },
|
||||
};
|
||||
@ -104,15 +113,14 @@ flag_info flag_data[] = {
|
||||
const char_t* expression_text = BOOST_RE_STR("(;.*)|") // comment
|
||||
BOOST_RE_STR("(^[[:blank:]]*-)|") // -
|
||||
BOOST_RE_STR("([^\"[:space:]][^[:space:]]*)|") // token
|
||||
BOOST_RE_STR("(\"(([^\"]|\\\\\")*)\")") // "token"
|
||||
BOOST_RE_STR("(\"((\\\\\"|[^\"])*)\")") // "token"
|
||||
;
|
||||
|
||||
typedef reg_expression<char_t> re_parse_t;
|
||||
typedef re_parse_t::allocator_type parse_alloc;
|
||||
typedef match_results<string_type::const_iterator, parse_alloc> parse_grep;
|
||||
typedef basic_regex<char_t> re_parse_t;
|
||||
typedef match_results<string_type::const_iterator> parse_grep;
|
||||
typedef string_type::const_iterator parse_iterator;
|
||||
|
||||
re_parse_t parse_expression(expression_text, regbase::normal);
|
||||
re_parse_t parse_expression(expression_text, regex_constants::normal);
|
||||
|
||||
//
|
||||
// now define our grep predicate function object:
|
||||
|
@ -55,16 +55,16 @@ typedef bool (*pred1_type)(const match_results<ra_it>&);
|
||||
typedef bool (*pred2_type)(const match_results<test_string_type::const_iterator>&);
|
||||
|
||||
//check that all the defined flags are available:
|
||||
regbase::flag_type f = regbase::escape_in_lists | regbase::char_classes | regbase::intervals | regbase::limited_ops
|
||||
| regbase::newline_alt | regbase::bk_plus_qm | regbase::bk_braces
|
||||
| regbase::bk_parens | regbase::bk_refs | regbase::bk_vbar | regbase::use_except
|
||||
| regbase::failbit | regbase::literal | regbase::icase | regbase::nocollate | regbase::basic
|
||||
| regbase::extended | regbase::normal | regbase::emacs | regbase::awk | regbase::grep | regbase::egrep | regbase::sed;
|
||||
regex::flag_type f = regex::escape_in_lists | regex::char_classes | regex::intervals | regex::limited_ops
|
||||
| regex::newline_alt | regex::bk_plus_qm | regex::bk_braces
|
||||
| regex::bk_parens | regex::bk_refs | regex::bk_vbar | regex::use_except
|
||||
| regex::failbit | regex::literal | regex::icase | regex::nocollate | regex::basic
|
||||
| regex::extended | regex::normal | regex::emacs | regex::awk | regex::grep | regex::egrep | regex::sed;
|
||||
|
||||
template class reg_expression<test_char_type>;
|
||||
template struct sub_match<ra_it>;
|
||||
template class match_results<ra_it>;
|
||||
|
||||
#if 0
|
||||
template bool regex_match(ra_it,
|
||||
ra_it,
|
||||
match_results<ra_it>& m,
|
||||
@ -92,13 +92,13 @@ template test_char_type* regex_format(test_char_type*,
|
||||
const match_results<ra_it>& m,
|
||||
const test_string_type& fmt,
|
||||
unsigned flags);
|
||||
template test_char_type* regex_merge(test_char_type*,
|
||||
template test_char_type* regex_replace(test_char_type*,
|
||||
ra_it,
|
||||
ra_it,
|
||||
const reg_expression<test_char_type>&,
|
||||
const test_char_type*,
|
||||
unsigned int flags);
|
||||
template test_char_type* regex_merge(test_char_type*,
|
||||
template test_char_type* regex_replace(test_char_type*,
|
||||
ra_it,
|
||||
ra_it,
|
||||
const reg_expression<test_char_type>& e,
|
||||
@ -159,17 +159,17 @@ template test_string_type regex_format
|
||||
(const match_results<test_string_type::const_iterator>&,
|
||||
const test_string_type&,
|
||||
unsigned flags);
|
||||
template test_string_type regex_merge(const test_string_type&,
|
||||
template test_string_type regex_replace(const test_string_type&,
|
||||
const reg_expression<test_char_type>&,
|
||||
const test_char_type*,
|
||||
unsigned int flags);
|
||||
template test_string_type regex_merge(const test_string_type&,
|
||||
template test_string_type regex_replace(const test_string_type&,
|
||||
const reg_expression<test_char_type>&,
|
||||
const test_string_type&,
|
||||
unsigned int flags);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
} // namespace boost
|
||||
|
||||
//
|
||||
|
@ -81,10 +81,10 @@ int cpp_main(int argc, char * argv[])
|
||||
{
|
||||
#if defined(BOOST_MSVC) && defined(_DEBUG)
|
||||
// turn on heap reporting at program exit:
|
||||
int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
|
||||
tmpFlag |= _CRTDBG_LEAK_CHECK_DF;
|
||||
tmpFlag &= ~_CRTDBG_CHECK_CRT_DF;
|
||||
_CrtSetDbgFlag( tmpFlag );
|
||||
//int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
|
||||
//tmpFlag |= _CRTDBG_LEAK_CHECK_DF;
|
||||
//tmpFlag &= ~_CRTDBG_CHECK_CRT_DF;
|
||||
//_CrtSetDbgFlag( tmpFlag );
|
||||
#endif
|
||||
#ifdef TIME_TEST
|
||||
boost::timer tim;
|
||||
|
@ -418,20 +418,22 @@ __iterator_category(const debug_iterator<T>&) {
|
||||
#define BOOST_RE_TEST_LOCALE_W32
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef BOOST_RE_TEST_LOCALE_W32
|
||||
typedef boost::reg_expression<char_t, boost::w32_regex_traits<char_t>, jm_debug_alloc> re_type;
|
||||
#elif defined(BOOST_RE_TEST_LOCALE_CPP)
|
||||
typedef boost::reg_expression<char_t, boost::cpp_regex_traits<char_t>, jm_debug_alloc> re_type;
|
||||
#else
|
||||
typedef boost::reg_expression<char_t, boost::c_regex_traits<char_t>, jm_debug_alloc> re_type;
|
||||
#ifdef BOOST_REGEX_V3
|
||||
# define basic_regex reg_expression
|
||||
#endif
|
||||
#ifdef BOOST_RE_TEST_LOCALE_W32
|
||||
typedef boost::basic_regex<char_t, boost::w32_regex_traits<char_t>, jm_debug_alloc> re_type;
|
||||
#elif defined(BOOST_RE_TEST_LOCALE_CPP)
|
||||
typedef boost::basic_regex<char_t, boost::cpp_regex_traits<char_t>, jm_debug_alloc> re_type;
|
||||
#else
|
||||
typedef boost::basic_regex<char_t, boost::c_regex_traits<char_t>, jm_debug_alloc> re_type;
|
||||
#endif
|
||||
|
||||
#define REG_NO_POSIX_TEST 1
|
||||
#define REG_UNICODE_ONLY 2
|
||||
#define REG_GREP 4
|
||||
#define REG_MERGE 8
|
||||
#define REG_MERGE_COPY 16
|
||||
#define REG_PARTIAL_MATCH 32
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -37,8 +37,10 @@ bool compare_result(const M1& sm, const M2& m)
|
||||
{
|
||||
if(sm.size() != m.size())
|
||||
return false;
|
||||
#ifdef BOOST_REGEX_V3
|
||||
if(sm.line() != m.line())
|
||||
return false;
|
||||
#endif
|
||||
for(unsigned int i = 0; i < sm.size(); ++i)
|
||||
{
|
||||
if(sm.position(i) != m.position(i))
|
||||
@ -57,7 +59,7 @@ bool compare_result(const M1& sm, const M1& m)
|
||||
|
||||
|
||||
template <class C, class T, class A>
|
||||
void cpp_eh_tests(const reg_expression<C, T, A>& )
|
||||
void cpp_eh_tests(const basic_regex<C, T, A>& )
|
||||
{
|
||||
#ifndef __GNUC__
|
||||
bool thrown = false;
|
||||
@ -67,8 +69,8 @@ void cpp_eh_tests(const reg_expression<C, T, A>& )
|
||||
{
|
||||
#endif
|
||||
A a;
|
||||
reg_expression<C, T, A> e(a);
|
||||
e.set_expression(expression.c_str(), flags[2] | regbase::use_except);
|
||||
basic_regex<C, T, A> e(a);
|
||||
e.set_expression(expression.c_str(), flags[2] | regex::use_except);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(const boost::bad_expression&)
|
||||
@ -90,7 +92,7 @@ void cpp_eh_tests(const reg_expression<C, T, A>& )
|
||||
#endif
|
||||
{
|
||||
A a;
|
||||
reg_expression<C, T, A> e(expression.c_str(), flags[2] | regbase::use_except, a);
|
||||
basic_regex<C, T, A> e(expression.c_str(), flags[2] | regex::use_except, a);
|
||||
}
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
catch(const boost::bad_expression&)
|
||||
@ -142,14 +144,20 @@ class grep_test_predicate
|
||||
{
|
||||
int match_id;
|
||||
iterator base, term;
|
||||
// rebind allocator to correct type:
|
||||
#ifdef BOOST_REGEX_V3
|
||||
typedef Alloc alloc_type;
|
||||
#else
|
||||
typedef typename detail::rebind_allocator<boost::sub_match<iterator>, Alloc>::type alloc_type;
|
||||
#endif
|
||||
public:
|
||||
grep_test_predicate(iterator i, iterator j) : base(i), term(j) { match_id = 0; }
|
||||
~grep_test_predicate(){}
|
||||
bool operator()(const boost::match_results< iterator, Alloc >& m);
|
||||
bool operator()(const boost::match_results< iterator, alloc_type >& m);
|
||||
};
|
||||
|
||||
template <class iterator, class Alloc>
|
||||
bool grep_test_predicate<iterator, Alloc>::operator()(const boost::match_results< iterator, Alloc >& m)
|
||||
bool grep_test_predicate<iterator, Alloc>::operator()(const boost::match_results< iterator, alloc_type >& m)
|
||||
{
|
||||
std::ptrdiff_t start, end;
|
||||
start = m[0].first - base;
|
||||
@ -189,6 +197,7 @@ bool grep_test_predicate<iterator, Alloc>::operator()(const boost::match_results
|
||||
|
||||
//
|
||||
// now check line()
|
||||
/* don't check this, it's not supported in the new algorithm....
|
||||
start = m.line();
|
||||
end = count_lines(base, iterator(m[0].first)) + 1;
|
||||
if(start != end)
|
||||
@ -196,9 +205,10 @@ bool grep_test_predicate<iterator, Alloc>::operator()(const boost::match_results
|
||||
begin_error();
|
||||
cout << "regex++ grep error in line(): found " << start << " expected " << end << endl;
|
||||
}
|
||||
|
||||
*/
|
||||
//
|
||||
// now check line_start()
|
||||
/* don't check this, it's not supported in the new algorithm....
|
||||
start = m.line_start() - base;
|
||||
end = find_last_line(base, iterator(m[0].first)) - base;
|
||||
if(start != end)
|
||||
@ -206,22 +216,22 @@ bool grep_test_predicate<iterator, Alloc>::operator()(const boost::match_results
|
||||
begin_error();
|
||||
cout << "regex++ grep error in line_start(): found " << start << " expected " << end << endl;
|
||||
}
|
||||
|
||||
*/
|
||||
match_id += 2;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class C, class T, class A>
|
||||
void cpp_tests(const reg_expression<C, T, A>& e, bool recurse = true)
|
||||
void cpp_tests(const basic_regex<C, T, A>& e, bool recurse = true)
|
||||
{
|
||||
typedef typename reg_expression<C, T, A>::allocator_type allocator_type;
|
||||
typedef typename basic_regex<C, T, A>::allocator_type allocator_type;
|
||||
if(flags[4] & REG_MERGE)
|
||||
{
|
||||
//
|
||||
// test merge code:
|
||||
//
|
||||
string_type s;
|
||||
s = regex_merge(search_text, e, format_string.c_str(), flags[3]);
|
||||
s = regex_merge(search_text, e, format_string.c_str(), static_cast<boost::match_flag_type>(flags[3]));
|
||||
if(s != merge_string)
|
||||
{
|
||||
begin_error();
|
||||
@ -234,10 +244,15 @@ void cpp_tests(const reg_expression<C, T, A>& e, bool recurse = true)
|
||||
if(recurse)
|
||||
{
|
||||
// copy and assign test:
|
||||
reg_expression<C, T, A> e2(e);
|
||||
basic_regex<C, T, A> e2(e);
|
||||
cpp_tests(e2, false);
|
||||
e2 = e;
|
||||
cpp_tests(e2, false);
|
||||
basic_regex<C, T, A> e3;
|
||||
#ifndef BOOST_REGEX_V3
|
||||
e3.swap(e2);
|
||||
cpp_tests(e3, false);
|
||||
#endif
|
||||
}
|
||||
|
||||
if(e.error_code())
|
||||
@ -257,18 +272,18 @@ void cpp_tests(const reg_expression<C, T, A>& e, bool recurse = true)
|
||||
debug_iterator<string_type::iterator> x(search_text.begin(), search_text.begin(), search_text.end());
|
||||
debug_iterator<string_type::iterator> y(search_text.end(), search_text.begin(), search_text.end());
|
||||
grep_test_predicate<debug_iterator<string_type::iterator>, allocator_type> oi(x, y);
|
||||
regex_grep(oi, x, y, e, flags[3]);
|
||||
regex_grep(oi, x, y, e, static_cast<boost::match_flag_type>(flags[3]));
|
||||
#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
|
||||
if(!recurse)
|
||||
{
|
||||
unsigned len = search_text.size();
|
||||
const std::basic_string<char_t>& s = search_text;
|
||||
grep_test_predicate<std::basic_string<char_t>::const_iterator, allocator_type> oi2(s.begin(), s.end());
|
||||
regex_grep(oi2, s, e, flags[3]);
|
||||
regex_grep(oi2, s, e, static_cast<boost::match_flag_type>(flags[3]));
|
||||
grep_test_predicate<const char_t*, allocator_type> oi3(s.c_str(), s.c_str()+s.size());
|
||||
regex_grep(oi3, s.c_str(), e, flags[3]);
|
||||
regex_grep(oi3, s.c_str(), e, static_cast<boost::match_flag_type>(flags[3]));
|
||||
assert(s.size() == len);
|
||||
assert(s.end() - s.begin() == len);
|
||||
assert(s.end() - s.begin() == (std::basic_string<char_t>::difference_type)len);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -278,8 +293,28 @@ void cpp_tests(const reg_expression<C, T, A>& e, bool recurse = true)
|
||||
match_results< debug_iterator<string_type::iterator>, allocator_type> m;
|
||||
debug_iterator<string_type::iterator> x(search_text.begin(), search_text.begin(), search_text.end());
|
||||
debug_iterator<string_type::iterator> y(search_text.end(), search_text.begin(), search_text.end());
|
||||
if(regex_search(x, y, m, e, flags[3]))
|
||||
if(regex_search(x, y, m, e, static_cast<boost::match_flag_type>(flags[3])))
|
||||
{
|
||||
// special case for partial matches:
|
||||
if(flags[4] & REG_PARTIAL_MATCH)
|
||||
{
|
||||
if(m[0].matched)
|
||||
{
|
||||
begin_error();
|
||||
cout << "regex++ API result mismatch, found full match when partial match was expected: found ("
|
||||
<< (m[0].first - x) << "," <<
|
||||
(m[0].second - x) << ")" << endl;
|
||||
}
|
||||
else if(((m[0].first - x) != matches[0]) || ((m[0].second - x) != matches[1]))
|
||||
{
|
||||
begin_error();
|
||||
cout << "regex++ API result mismatch in sub-expression " << 0 <<
|
||||
", found (" << (m[0].first - x) << "," <<
|
||||
(m[0].second - x) << ") expected (" <<
|
||||
matches[0] << "," << matches[1] << ")" << endl;
|
||||
}
|
||||
return; // don't bother testing anything else for partial matches
|
||||
}
|
||||
// match found compare what matched with what we expect:
|
||||
int j = 0;
|
||||
for(unsigned int i = 0; i < m.size(); ++i, j += 2)
|
||||
@ -321,6 +356,34 @@ void cpp_tests(const reg_expression<C, T, A>& e, bool recurse = true)
|
||||
(m[-2].first - x) << "," << (m[-2].second - x) << ") expected (" <<
|
||||
matches[1] << "," << (y-x) << ")" << endl;
|
||||
}
|
||||
#if !(defined(BOOST_MSVC) && (BOOST_MSVC <= 1300)) && !defined(BOOST_REGEX_V3)
|
||||
//
|
||||
// now try comparison operators:
|
||||
string_type s(m[0]);
|
||||
if((s != m[0]) || (m[0] != s)
|
||||
|| !(s == m[0]) || !(m[0] == s)
|
||||
|| (s < m[0]) || (m[0] < s)
|
||||
|| (s > m[0]) || (m[0] > s)
|
||||
|| !(s <= m[0]) || !(m[0] <= s)
|
||||
|| !(s >= m[0]) || !(m[0] >= s))
|
||||
{
|
||||
begin_error();
|
||||
cout << "string comparison failed for result" << std::endl;
|
||||
}
|
||||
if(s.find_first_of((string_type::value_type)0) == string_type::npos)
|
||||
{
|
||||
if((m[0] != s.c_str()) || (s.c_str() != m[0])
|
||||
|| !(m[0] == s.c_str()) || !(s.c_str() == m[0])
|
||||
|| (m[0] > s.c_str()) || (s.c_str() > m[0])
|
||||
|| (m[0] < s.c_str()) || (s.c_str() < m[0])
|
||||
|| !(m[0] >= s.c_str()) || !(s.c_str() >= m[0])
|
||||
|| !(m[0] <= s.c_str()) || !(s.c_str() <= m[0]))
|
||||
{
|
||||
begin_error();
|
||||
cout << "string comparison failed for result" << std::endl;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// now try alternative forms of regex_search if available:
|
||||
@ -329,18 +392,24 @@ void cpp_tests(const reg_expression<C, T, A>& e, bool recurse = true)
|
||||
{
|
||||
std::basic_string<char_t> s(search_text.begin(), search_text.end());
|
||||
match_results<std::basic_string<char_t>::const_iterator> sm;
|
||||
if(regex_search(s, sm, e, flags[3]))
|
||||
if(regex_search(s, sm, e, static_cast<boost::match_flag_type>(flags[3])))
|
||||
{
|
||||
if(compare_result(sm, m) == false)
|
||||
{
|
||||
begin_error();
|
||||
cout << "regex++ API result mismatch in regex_search(const std::string&, match_results&, const reg_expression&, int)" << endl;
|
||||
cout << "regex++ API result mismatch in regex_search(const std::string&, match_results&, const basic_regex&, int)" << endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
begin_error();
|
||||
cout << "regex++ API result mismatch in regex_search(const std::string&, match_results&, const reg_expression&, int)" << endl;
|
||||
cout << "regex++ API result mismatch in regex_search(const std::string&, match_results&, const basic_regex&, int)" << endl;
|
||||
}
|
||||
if(!regex_search(s, e, static_cast<boost::match_flag_type>(flags[3]))
|
||||
|| !regex_search(s.begin(), s.end(), e, static_cast<boost::match_flag_type>(flags[3])))
|
||||
{
|
||||
begin_error();
|
||||
cout << "regex++ API result mismatch in regex_search(const std::string&, const basic_regex&, int)" << endl;
|
||||
}
|
||||
//
|
||||
// partial match should give same result as full match
|
||||
@ -348,7 +417,7 @@ void cpp_tests(const reg_expression<C, T, A>& e, bool recurse = true)
|
||||
//
|
||||
if(matches[0] > 0)
|
||||
{
|
||||
if(regex_search(x, y, m, e, flags[3] | boost::match_partial))
|
||||
if(regex_search(x, y, m, e, static_cast<boost::match_flag_type>(flags[3]) | boost::match_partial))
|
||||
{
|
||||
if(compare_result(sm, m) == false)
|
||||
{
|
||||
@ -365,18 +434,23 @@ void cpp_tests(const reg_expression<C, T, A>& e, bool recurse = true)
|
||||
if(s.find(char_t(0)) == std::basic_string<char_t>::npos)
|
||||
{
|
||||
match_results<const char_t*> ssm;
|
||||
if(regex_search(search_text.c_str(), ssm, e, flags[3]))
|
||||
if(regex_search(search_text.c_str(), ssm, e, static_cast<boost::match_flag_type>(flags[3])))
|
||||
{
|
||||
if(compare_result(ssm, m) == false)
|
||||
{
|
||||
begin_error();
|
||||
cout << "regex++ API result mismatch in regex_search(const char_t*, match_results&, const reg_expression&, int)" << endl;
|
||||
cout << "regex++ API result mismatch in regex_search(const char_t*, match_results&, const basic_regex&, int)" << endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
begin_error();
|
||||
cout << "regex++ API result mismatch in regex_search(const char_t*, match_results&, const reg_expression&, int)" << endl;
|
||||
cout << "regex++ API result mismatch in regex_search(const char_t*, match_results&, const basic_regex&, int)" << endl;
|
||||
}
|
||||
if(!regex_search(search_text.c_str(), e, static_cast<boost::match_flag_type>(flags[3])))
|
||||
{
|
||||
begin_error();
|
||||
cout << "regex++ API result mismatch in regex_search(const char_t*, const basic_regex&, int)" << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -389,49 +463,49 @@ void cpp_tests(const reg_expression<C, T, A>& e, bool recurse = true)
|
||||
match_results< debug_iterator<string_type::iterator>, allocator_type> m1;
|
||||
debug_iterator<string_type::iterator> x1(search_text.begin(), search_text.begin(), search_text.end());
|
||||
debug_iterator<string_type::iterator> y1(search_text.end(), search_text.begin(), search_text.end());
|
||||
if(regex_match(x1, y1, m1, e, flags[3]))
|
||||
if(regex_match(x1, y1, m1, e, static_cast<boost::match_flag_type>(flags[3])))
|
||||
{
|
||||
if(compare_result(m1, m) == false)
|
||||
{
|
||||
begin_error();
|
||||
cout << "regex++ API result mismatch in regex_match(iterator, iterator, match_results&, const reg_expression&, int)" << endl;
|
||||
cout << "regex++ API result mismatch in regex_match(iterator, iterator, match_results&, const basic_regex&, int)" << endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
begin_error();
|
||||
cout << "regex++ API result mismatch in regex_match(iterator, iterator, match_results&, const reg_expression&, int)" << endl;
|
||||
cout << "regex++ API result mismatch in regex_match(iterator, iterator, match_results&, const basic_regex&, int)" << endl;
|
||||
}
|
||||
std::basic_string<char_t> s(search_text.begin(), search_text.end());
|
||||
match_results<std::basic_string<char_t>::const_iterator> sm;
|
||||
if(regex_match(s, sm, e, flags[3]))
|
||||
if(regex_match(s, sm, e, static_cast<boost::match_flag_type>(flags[3])))
|
||||
{
|
||||
if(compare_result(sm, m) == false)
|
||||
{
|
||||
begin_error();
|
||||
cout << "regex++ API result mismatch in regex_match(const std::string&, match_results&, const reg_expression&, int)" << endl;
|
||||
cout << "regex++ API result mismatch in regex_match(const std::string&, match_results&, const basic_regex&, int)" << endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
begin_error();
|
||||
cout << "regex++ API result mismatch in regex_match(const std::string&, match_results&, const reg_expression&, int)" << endl;
|
||||
cout << "regex++ API result mismatch in regex_match(const std::string&, match_results&, const basic_regex&, int)" << endl;
|
||||
}
|
||||
if(s.find(char_t(0)) == std::basic_string<char_t>::npos)
|
||||
{
|
||||
match_results<const char_t*> ssm;
|
||||
if(regex_match(search_text.c_str(), ssm, e, flags[3]))
|
||||
if(regex_match(search_text.c_str(), ssm, e, static_cast<boost::match_flag_type>(flags[3])))
|
||||
{
|
||||
if(compare_result(ssm, m) == false)
|
||||
{
|
||||
begin_error();
|
||||
cout << "regex++ API result mismatch in regex_match(const char_t*, match_results&, const reg_expression&, int)" << endl;
|
||||
cout << "regex++ API result mismatch in regex_match(const char_t*, match_results&, const basic_regex&, int)" << endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
begin_error();
|
||||
cout << "regex++ API result mismatch in regex_match(const char_t*, match_results&, const reg_expression&, int)" << endl;
|
||||
cout << "regex++ API result mismatch in regex_match(const char_t*, match_results&, const basic_regex&, int)" << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -568,11 +642,11 @@ void cpp_hl_tests(RegEx& e, bool recurse = true)
|
||||
// try to do grep:
|
||||
hl_match_id = 0;
|
||||
GrepCallback cb = hl_grep_test_proc;
|
||||
e.Grep(cb, search_text.c_str(), flags[3]);
|
||||
e.Grep(cb, search_text.c_str(), static_cast<boost::match_flag_type>(flags[3]));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(e.Search(search_text.c_str(), flags[3]))
|
||||
if(e.Search(search_text.c_str(), static_cast<boost::match_flag_type>(flags[3])))
|
||||
{
|
||||
unsigned int i = 0;
|
||||
unsigned int j = 0;
|
||||
@ -600,9 +674,9 @@ void cpp_hl_tests(RegEx& e, bool recurse = true)
|
||||
//
|
||||
// test RegEx::Match only if we expect to match all of the input:
|
||||
//
|
||||
if((matches[0] == 0) && (matches[1] == search_text.size()))
|
||||
if((matches[0] == 0) && (matches[1] == (int)search_text.size()))
|
||||
{
|
||||
if(e.Match(search_text.c_str(), flags[3]))
|
||||
if(e.Match(search_text.c_str(), static_cast<boost::match_flag_type>(flags[3])))
|
||||
{
|
||||
unsigned int i = 0;
|
||||
unsigned int j = 0;
|
||||
@ -665,9 +739,9 @@ void run_tests()
|
||||
try
|
||||
{
|
||||
#endif
|
||||
unsigned int f = flags[2] & ~regbase::use_except;
|
||||
unsigned int f = flags[2] & ~regex::use_except;
|
||||
if(flags[0] & REG_ICASE)
|
||||
f |= regbase::icase;
|
||||
f |= regex::icase;
|
||||
re_type e(expression.c_str(), f);
|
||||
cpp_tests(e, true);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
@ -695,7 +769,7 @@ void run_tests()
|
||||
try
|
||||
{
|
||||
#endif
|
||||
if(((flags[3] & match_partial) == 0) && (flags[2] == regbase::normal) && (has_nulls(search_text.begin(), search_text.end()) == false))
|
||||
if(((flags[3] & match_partial) == 0) && (flags[2] == regex::normal) && (has_nulls(search_text.begin(), search_text.end()) == false))
|
||||
{
|
||||
RegEx e;
|
||||
e.SetExpression(expression.c_str(), flags[0] & REG_ICASE);
|
||||
|
@ -293,7 +293,7 @@ ab$ abxx -1 -1
|
||||
ab$ ab\nzz 0 2
|
||||
|
||||
; back references
|
||||
- match_default normal REG_EXTENDED
|
||||
- match_default normal REG_PERL
|
||||
a(b)\2c !
|
||||
a(b\1)c !
|
||||
a(b*)c\1d abbcbbd 0 7 1 3
|
||||
@ -307,7 +307,8 @@ a(([bc])\2)*d abbccd 0 6 3 5 3 4
|
||||
|
||||
a(([bc])\2)*d abbcbd -1 -1
|
||||
a((b)*\2)*d abbbd 0 5 1 4 2 3
|
||||
(ab*)[ab]*\1 ababaaa 0 7 0 1
|
||||
; perl only:
|
||||
(ab*)[ab]*\1 ababaaa 0 4 0 2
|
||||
(a)\1bcd aabcd 0 5 0 1
|
||||
(a)\1bc*d aabcd 0 5 0 1
|
||||
(a)\1bc*d aabd 0 4 0 1
|
||||
@ -315,9 +316,13 @@ a((b)*\2)*d abbbd 0 5 1 4 2 3
|
||||
(a)\1bc*[ce]d aabcccd 0 7 0 1
|
||||
^(a)\1b(c)*cd$ aabcccd 0 7 0 1 4 5
|
||||
|
||||
; posix only:
|
||||
- match_default extended REG_EXTENDED
|
||||
(ab*)[ab]*\1 ababaaa 0 7 0 1
|
||||
|
||||
;
|
||||
; characters by code:
|
||||
- match_default normal REG_EXTENDED REG_STARTEND
|
||||
- match_default normal REG_PERL REG_STARTEND
|
||||
\0101 A 0 1
|
||||
\00 \0 0 1
|
||||
\0 \0 0 1
|
||||
@ -443,6 +448,7 @@ a(bbb+|bb+|b)b abbb 0 4 1 3
|
||||
a(bbb+|bb+|b)bb abbb 0 4 1 2
|
||||
(.*).* abcdef 0 6 0 6
|
||||
(a*)* bc 0 0 0 0
|
||||
xyx*xz xyxxxxyxxxz 5 11
|
||||
|
||||
; do we get the right subexpression when it is used more than once?
|
||||
a(b|c)*d ad 0 2 -1 -1
|
||||
@ -450,7 +456,6 @@ a(b|c)*d abcd 0 4 2 3
|
||||
a(b|c)+d abd 0 3 1 2
|
||||
a(b|c)+d abcd 0 4 2 3
|
||||
a(b|c?)+d ad 0 2 1 1
|
||||
a(b|c?)+d abcd 0 4 2 3
|
||||
a(b|c){0,0}d ad 0 2 -1 -1
|
||||
a(b|c){0,1}d ad 0 2 -1 -1
|
||||
a(b|c){0,1}d abd 0 3 1 2
|
||||
@ -470,13 +475,23 @@ a(b|c){2,4}d abcbd 0 5 3 4
|
||||
a(b|c){2,4}d abcbcd 0 6 4 5
|
||||
a(b|c){2,}d abcd 0 4 2 3
|
||||
a(b|c){2,}d abcbd 0 5 3 4
|
||||
; perl only:
|
||||
a(b|c?)+d abcd 0 4 3 3
|
||||
a(b+|((c)*))+d abd 0 3 2 2 2 2 -1 -1
|
||||
a(b+|((c)*))+d abcd 0 4 3 3 3 3 2 3
|
||||
|
||||
; posix only:
|
||||
- match_default extended REG_EXTENDED REG_STARTEND
|
||||
a(b|c?)+d abcd 0 4 2 3
|
||||
a(b|((c)*))+d abcd 0 4 2 3 2 3 2 3
|
||||
a(b+|((c)*))+d abd 0 3 1 2 -1 -1 -1 -1
|
||||
a(b+|((c)*))+d abcd 0 4 2 3 2 3 2 3
|
||||
|
||||
|
||||
- match_default normal REG_EXTENDED REG_STARTEND REG_NOSPEC literal
|
||||
\**?/{} \\**?/{} 0 7
|
||||
|
||||
- match_default normal REG_EXTENDED REG_NO_POSIX_TEST ; we disable POSIX testing because it can't handle escapes in sets
|
||||
- match_default normal REG_PERL
|
||||
; try to match C++ syntax elements:
|
||||
; line comment:
|
||||
//[^\n]* "++i //here is a line comment\n" 4 28
|
||||
@ -490,7 +505,8 @@ a(b+|((c)*))+d abcd 0 4 2 3 2 3 2 3
|
||||
; preprossor directives:
|
||||
^[[:blank:]]*#([^\n]*\\[[:space:]]+)*[^\n]* "#define some_symbol" 0 19 -1 -1
|
||||
^[[:blank:]]*#([^\n]*\\[[:space:]]+)*[^\n]* "#define some_symbol(x) #x" 0 25 -1 -1
|
||||
^[[:blank:]]*#([^\n]*\\[[:space:]]+)*[^\n]* "#define some_symbol(x) \\ \r\n foo();\\\r\n printf(#x);" 0 53 28 42
|
||||
; perl only:
|
||||
^[[:blank:]]*#([^\n]*\\[[:space:]]+)*[^\n]* "#define some_symbol(x) \\ \r\n foo();\\\r\n printf(#x);" 0 53 30 42
|
||||
; literals:
|
||||
((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)? 0xFF 0 4 0 4 0 4 -1 -1 -1 -1 -1 -1 -1 -1
|
||||
((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)? 35 0 2 0 2 -1 -1 0 2 -1 -1 -1 -1 -1 -1
|
||||
@ -502,6 +518,11 @@ a(b+|((c)*))+d abcd 0 4 2 3 2 3 2 3
|
||||
'([^\\']|\\.)*' '\\'' 0 4 1 3
|
||||
'([^\\']|\\.)*' '\\n' 0 4 1 3
|
||||
|
||||
; posix only:
|
||||
- match_default extended escape_in_lists REG_EXTENDED REG_NO_POSIX_TEST ; we disable POSIX testing because it can't handle escapes in sets
|
||||
^[[:blank:]]*#([^\n]*\\[[:space:]]+)*[^\n]* "#define some_symbol(x) \\ \r\n foo();\\\r\n printf(#x);" 0 53 28 42
|
||||
|
||||
|
||||
; now try and test some unicode specific characters:
|
||||
- match_default normal REG_PERL REG_UNICODE_ONLY
|
||||
[[:unicode:]]+ a\0300\0400z 1 3
|
||||
@ -781,7 +802,6 @@ a+ "...aaa,,," \x{21} "!"
|
||||
a+ "...aaa,,," \c@ \0
|
||||
a+ "...aaa,,," \e \27
|
||||
a+ "...aaa,,," \0101 A
|
||||
a+ "...aaa,,," (\0101) A
|
||||
|
||||
- match_default normal REG_EXTENDED REG_STARTEND REG_MERGE format_sed format_no_copy
|
||||
(a+)(b+) ...aabb,, \0 aabb
|
||||
@ -803,8 +823,9 @@ a+ "...aaa,,," (\0101) A
|
||||
(a+)(b+) ...aabb,, & &
|
||||
(a+)(b+) ...aabb,, \0 \0
|
||||
(a+)(b+) ...aabb,, ()?: ()?:
|
||||
a+ "...aaa,,," \0101 A
|
||||
|
||||
- match_default normal REG_EXTENDED REG_STARTEND REG_MERGE
|
||||
- match_default format_all normal REG_EXTENDED REG_STARTEND REG_MERGE
|
||||
; move to copying unmatched data:
|
||||
a+ "...aaa,,," bbb "...bbb,,,"
|
||||
a+(b+) "...aaabb,,," $1 "...bb,,,"
|
||||
@ -815,7 +836,7 @@ a+(b+) "...aaabb,,,ab*abbb?" $1 "...bb,,,b*bbb?"
|
||||
(a+)|(b+) "...aaabb,,,ab*abbb?" (?1A:B)C "...ACBC,,,ACBC*ACBC?"
|
||||
(a+)|(b+) "...aaabb,,,ab*abbb?" ?1:B "...B,,,B*B?"
|
||||
|
||||
- match_default normal REG_EXTENDED REG_STARTEND REG_MERGE format_first_only
|
||||
- match_default format_all normal REG_EXTENDED REG_STARTEND REG_MERGE format_first_only
|
||||
; move to copying unmatched data, but replace first occurance only:
|
||||
a+ "...aaa,,," bbb "...bbb,,,"
|
||||
a+(b+) "...aaabb,,," $1 "...bb,,,"
|
||||
@ -837,7 +858,7 @@ a+(b+) "...aaabb,,,ab*abbb?" $1 "...bb,,,ab*abbb?"
|
||||
|
||||
;
|
||||
; non-greedy repeats added 21/04/00
|
||||
- match_default normal REG_EXTENDED
|
||||
- match_default normal REG_EXTENDED REG_PERL
|
||||
a** !
|
||||
a*? aa 0 0
|
||||
a?? aa 0 0
|
||||
@ -854,7 +875,7 @@ abc|\w+? abcd 0 3
|
||||
|
||||
;
|
||||
; non-marking parenthesis added 25/04/00
|
||||
- match_default normal REG_EXTENDED
|
||||
- match_default normal REG_EXTENDED REG_PERL
|
||||
(?:abc)+ xxabcabcxx 2 8
|
||||
(?:a+)(b+) xaaabbbx 1 7 4 7
|
||||
(a+)(?:b+) xaaabbba 1 7 1 4
|
||||
@ -867,14 +888,19 @@ a+(?#b+)b+ xaaabbba 1 7
|
||||
|
||||
;
|
||||
; try some partial matches:
|
||||
- match_partial match_default normal REG_EXTENDED REG_NO_POSIX_TEST
|
||||
(xyz)(.*)abc xyzaaab -1 -1 0 3 3 7
|
||||
(xyz)(.*)abc xyz -1 -1 0 3 3 3
|
||||
(xyz)(.*)abc xy -1 -1 -1 -1 -1 -1
|
||||
- match_partial match_default normal REG_EXTENDED REG_NO_POSIX_TEST REG_PARTIAL_MATCH REG_PERL
|
||||
(xyz)(.*)abc xyzaaab 0 7
|
||||
(xyz)(.*)abc xyz 0 3
|
||||
(xyz)(.*)abc xy 0 2
|
||||
(xyz)(.*)abc x 0 1
|
||||
(xyz)(.*)abc "" -1 -1
|
||||
(xyz)(.*)abc aaaa -1 -1
|
||||
.abc aaab 1 4
|
||||
a[_] xxa 2 3
|
||||
|
||||
;
|
||||
; forward lookahead asserts added 21/01/02
|
||||
- match_default normal REG_EXTENDED REG_NO_POSIX_TEST
|
||||
- match_default normal REG_EXTENDED REG_NO_POSIX_TEST REG_PERL
|
||||
((?:(?!a|b)\w)+)(\w+) " xxxabaxxx " 2 11 2 5 5 11
|
||||
|
||||
/\*(?:(?!\*/).)*\*/ " /**/ " 2 6
|
||||
@ -902,6 +928,183 @@ a+(?#b+)b+ xaaabbba 1 7
|
||||
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$ abC3 0 4
|
||||
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$ ABCD3 -1 -1
|
||||
|
||||
; extended repeat checking to exercise new algorithms:
|
||||
ab.*xy abxy_ 0 4
|
||||
ab.*xy ab_xy_ 0 5
|
||||
ab.*xy abxy 0 4
|
||||
ab.*xy ab_xy 0 5
|
||||
ab.* ab 0 2
|
||||
ab.* ab__ 0 4
|
||||
|
||||
ab.{2,5}xy ab__xy_ 0 6
|
||||
ab.{2,5}xy ab____xy_ 0 8
|
||||
ab.{2,5}xy ab_____xy_ 0 9
|
||||
ab.{2,5}xy ab__xy 0 6
|
||||
ab.{2,5}xy ab_____xy 0 9
|
||||
ab.{2,5} ab__ 0 4
|
||||
ab.{2,5} ab_______ 0 7
|
||||
ab.{2,5}xy ab______xy -1 -1
|
||||
ab.{2,5}xy ab_xy -1 -1
|
||||
|
||||
ab.*?xy abxy_ 0 4
|
||||
ab.*?xy ab_xy_ 0 5
|
||||
ab.*?xy abxy 0 4
|
||||
ab.*?xy ab_xy 0 5
|
||||
ab.*? ab 0 2
|
||||
ab.*? ab__ 0 2
|
||||
|
||||
ab.{2,5}?xy ab__xy_ 0 6
|
||||
ab.{2,5}?xy ab____xy_ 0 8
|
||||
ab.{2,5}?xy ab_____xy_ 0 9
|
||||
ab.{2,5}?xy ab__xy 0 6
|
||||
ab.{2,5}?xy ab_____xy 0 9
|
||||
ab.{2,5}? ab__ 0 4
|
||||
ab.{2,5}? ab_______ 0 4
|
||||
ab.{2,5}?xy ab______xy -1 -1
|
||||
ab.{2,5}xy ab_xy -1 -1
|
||||
|
||||
; again but with slower algorithm variant:
|
||||
- match_default normal REG_PERL REG_NO_POSIX_TEST match_not_dot_newline match_not_dot_null
|
||||
ab.*xy abxy_ 0 4
|
||||
ab.*xy ab_xy_ 0 5
|
||||
ab.*xy abxy 0 4
|
||||
ab.*xy ab_xy 0 5
|
||||
ab.* ab 0 2
|
||||
ab.* ab__ 0 4
|
||||
|
||||
ab.{2,5}xy ab__xy_ 0 6
|
||||
ab.{2,5}xy ab____xy_ 0 8
|
||||
ab.{2,5}xy ab_____xy_ 0 9
|
||||
ab.{2,5}xy ab__xy 0 6
|
||||
ab.{2,5}xy ab_____xy 0 9
|
||||
ab.{2,5} ab__ 0 4
|
||||
ab.{2,5} ab_______ 0 7
|
||||
ab.{2,5}xy ab______xy -1 -1
|
||||
ab.{2,5}xy ab_xy -1 -1
|
||||
|
||||
ab.*?xy abxy_ 0 4
|
||||
ab.*?xy ab_xy_ 0 5
|
||||
ab.*?xy abxy 0 4
|
||||
ab.*?xy ab_xy 0 5
|
||||
ab.*? ab 0 2
|
||||
ab.*? ab__ 0 2
|
||||
|
||||
ab.{2,5}?xy ab__xy_ 0 6
|
||||
ab.{2,5}?xy ab____xy_ 0 8
|
||||
ab.{2,5}?xy ab_____xy_ 0 9
|
||||
ab.{2,5}?xy ab__xy 0 6
|
||||
ab.{2,5}?xy ab_____xy 0 9
|
||||
ab.{2,5}? ab__ 0 4
|
||||
ab.{2,5}? ab_______ 0 4
|
||||
ab.{2,5}?xy ab______xy -1 -1
|
||||
ab.{2,5}xy ab_xy -1 -1
|
||||
|
||||
; now again for single character repeats:
|
||||
|
||||
ab_*xy abxy_ 0 4
|
||||
ab_*xy ab_xy_ 0 5
|
||||
ab_*xy abxy 0 4
|
||||
ab_*xy ab_xy 0 5
|
||||
ab_* ab 0 2
|
||||
ab_* ab__ 0 4
|
||||
|
||||
ab_{2,5}xy ab__xy_ 0 6
|
||||
ab_{2,5}xy ab____xy_ 0 8
|
||||
ab_{2,5}xy ab_____xy_ 0 9
|
||||
ab_{2,5}xy ab__xy 0 6
|
||||
ab_{2,5}xy ab_____xy 0 9
|
||||
ab_{2,5} ab__ 0 4
|
||||
ab_{2,5} ab_______ 0 7
|
||||
ab_{2,5}xy ab______xy -1 -1
|
||||
ab_{2,5}xy ab_xy -1 -1
|
||||
|
||||
ab_*?xy abxy_ 0 4
|
||||
ab_*?xy ab_xy_ 0 5
|
||||
ab_*?xy abxy 0 4
|
||||
ab_*?xy ab_xy 0 5
|
||||
ab_*? ab 0 2
|
||||
ab_*? ab__ 0 2
|
||||
|
||||
ab_{2,5}?xy ab__xy_ 0 6
|
||||
ab_{2,5}?xy ab____xy_ 0 8
|
||||
ab_{2,5}?xy ab_____xy_ 0 9
|
||||
ab_{2,5}?xy ab__xy 0 6
|
||||
ab_{2,5}?xy ab_____xy 0 9
|
||||
ab_{2,5}? ab__ 0 4
|
||||
ab_{2,5}? ab_______ 0 4
|
||||
ab_{2,5}?xy ab______xy -1 -1
|
||||
ab_{2,5}xy ab_xy -1 -1
|
||||
|
||||
; and again for sets:
|
||||
ab[_,;]*xy abxy_ 0 4
|
||||
ab[_,;]*xy ab_xy_ 0 5
|
||||
ab[_,;]*xy abxy 0 4
|
||||
ab[_,;]*xy ab_xy 0 5
|
||||
ab[_,;]* ab 0 2
|
||||
ab[_,;]* ab__ 0 4
|
||||
|
||||
ab[_,;]{2,5}xy ab__xy_ 0 6
|
||||
ab[_,;]{2,5}xy ab____xy_ 0 8
|
||||
ab[_,;]{2,5}xy ab_____xy_ 0 9
|
||||
ab[_,;]{2,5}xy ab__xy 0 6
|
||||
ab[_,;]{2,5}xy ab_____xy 0 9
|
||||
ab[_,;]{2,5} ab__ 0 4
|
||||
ab[_,;]{2,5} ab_______ 0 7
|
||||
ab[_,;]{2,5}xy ab______xy -1 -1
|
||||
ab[_,;]{2,5}xy ab_xy -1 -1
|
||||
|
||||
ab[_,;]*?xy abxy_ 0 4
|
||||
ab[_,;]*?xy ab_xy_ 0 5
|
||||
ab[_,;]*?xy abxy 0 4
|
||||
ab[_,;]*?xy ab_xy 0 5
|
||||
ab[_,;]*? ab 0 2
|
||||
ab[_,;]*? ab__ 0 2
|
||||
|
||||
ab[_,;]{2,5}?xy ab__xy_ 0 6
|
||||
ab[_,;]{2,5}?xy ab____xy_ 0 8
|
||||
ab[_,;]{2,5}?xy ab_____xy_ 0 9
|
||||
ab[_,;]{2,5}?xy ab__xy 0 6
|
||||
ab[_,;]{2,5}?xy ab_____xy 0 9
|
||||
ab[_,;]{2,5}? ab__ 0 4
|
||||
ab[_,;]{2,5}? ab_______ 0 4
|
||||
ab[_,;]{2,5}?xy ab______xy -1 -1
|
||||
ab[_,;]{2,5}xy ab_xy -1 -1
|
||||
|
||||
; and again for tricky sets with digraphs:
|
||||
ab[_[.ae.]]*xy abxy_ 0 4
|
||||
ab[_[.ae.]]*xy ab_xy_ 0 5
|
||||
ab[_[.ae.]]*xy abxy 0 4
|
||||
ab[_[.ae.]]*xy ab_xy 0 5
|
||||
ab[_[.ae.]]* ab 0 2
|
||||
ab[_[.ae.]]* ab__ 0 4
|
||||
|
||||
ab[_[.ae.]]{2,5}xy ab__xy_ 0 6
|
||||
ab[_[.ae.]]{2,5}xy ab____xy_ 0 8
|
||||
ab[_[.ae.]]{2,5}xy ab_____xy_ 0 9
|
||||
ab[_[.ae.]]{2,5}xy ab__xy 0 6
|
||||
ab[_[.ae.]]{2,5}xy ab_____xy 0 9
|
||||
ab[_[.ae.]]{2,5} ab__ 0 4
|
||||
ab[_[.ae.]]{2,5} ab_______ 0 7
|
||||
ab[_[.ae.]]{2,5}xy ab______xy -1 -1
|
||||
ab[_[.ae.]]{2,5}xy ab_xy -1 -1
|
||||
|
||||
ab[_[.ae.]]*?xy abxy_ 0 4
|
||||
ab[_[.ae.]]*?xy ab_xy_ 0 5
|
||||
ab[_[.ae.]]*?xy abxy 0 4
|
||||
ab[_[.ae.]]*?xy ab_xy 0 5
|
||||
ab[_[.ae.]]*? ab 0 2
|
||||
ab[_[.ae.]]*? ab__ 0 2
|
||||
|
||||
ab[_[.ae.]]{2,5}?xy ab__xy_ 0 6
|
||||
ab[_[.ae.]]{2,5}?xy ab____xy_ 0 8
|
||||
ab[_[.ae.]]{2,5}?xy ab_____xy_ 0 9
|
||||
ab[_[.ae.]]{2,5}?xy ab__xy 0 6
|
||||
ab[_[.ae.]]{2,5}?xy ab_____xy 0 9
|
||||
ab[_[.ae.]]{2,5}? ab__ 0 4
|
||||
ab[_[.ae.]]{2,5}? ab_______ 0 4
|
||||
ab[_[.ae.]]{2,5}?xy ab______xy -1 -1
|
||||
ab[_[.ae.]]{2,5}xy ab_xy -1 -1
|
||||
|
||||
; new bugs detected in spring 2003:
|
||||
- normal match_continuous REG_NO_POSIX_TEST
|
||||
b abc -1 -1
|
||||
@ -930,4 +1133,99 @@ a()b\1 ab 0 2 1 1
|
||||
|
||||
"(.*\r\n){3}.* abcdefghijklmnopqrstuvwxyz.*\r\n" "00001 01 \r\n00002 02 1 2 3 4 5 6 7 8 9 0\r\n00003 03 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\r\n00004 04 \r\n00005 05 \r\n00006 06 Seite: 0001\r\n00007 07 StartSeitEEnde: 0001\r\n00008 08 StartSeiTe Ende: 0001\r\n00009 09 Start seiteEnde: 0001\r\n00010 10 28.2.03\r\n00011 11 Page: 0001\r\n00012 12 Juhu die Erste: 0001\r\n00013 13 Es war einmal! 0001\r\n00014 14 ABCDEFGHIJKLMNOPQRSTUVWXYZ0001\r\n00015 15 abcdefghijklmnopqrstuvwxyz0001\r\n00016 16 lars.schmeiser@gft.com\r\n00017 17 \r\n00018 18 \r\n00019 19 \r\n00020 20 \r\n00021 21 1 2 3 4 5 6 7 8 9 0\r\n00022 22 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\r\n00023 01 \r\n00024 02 1 2 3 4 5 6 7 8 9 0\r\n00025 03 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\r\n00026 04 \r\n00027 05 \r\n00028 06 Seite: 0002\r\n00029 07 StartSeitEEnde: 0002\r\n00030 08 StartSeiTe Ende: 0002\r\n00031 09 Start seiteEnde: 0002\r\n00032 10 28.02.2003\r\n00033 11 Page: 0002\r\n00034 12 Juhu die Erste: 0002\r\n00035 13 Es war einmal! 0002\r\n00036 14 ABCDEFGHIJKLMNOPQRSTUVWXYZ0002\r\n00037 15 abcdefghijklmnopqrstuvwxyz0002\r\n00038 16 lars.schmeiser@194.1.12.111\r\n00039 17 \r\n00040 18 \r\n00041 19 \r\n00042 20 \r\n00043 21 1 2 3 4 5 6 7 8 9 0\r\n" 753 1076 934 1005
|
||||
|
||||
- normal REG_PERL
|
||||
|
||||
; new (?: construct )
|
||||
(?>^abc) abc 0 3
|
||||
(?>^abc) def\nabc 4 7
|
||||
(?>^abc) defabc -1 -1
|
||||
(?>.*/)foo /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/it/you/see/ -1 -1
|
||||
(?>.*/)foo /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo 0 67
|
||||
(?>(\.\d\d[1-9]?))\d+ 1.230003938 1 11 1 4
|
||||
(?>(\.\d\d[1-9]?))\d+ 1.875000282 1 11 1 5
|
||||
(?>(\.\d\d[1-9]?))\d+ 1.235 -1 -1
|
||||
^((?>\w+)|(?>\s+))*$ "now is the time for all good men to come to the aid of the party" 0 64 59 64
|
||||
^((?>\w+)|(?>\s+))*$ "this is not a line with only words and spaces!" -1 -1
|
||||
((?>\d+))(\w) 12345a 0 6 0 5 5 6
|
||||
((?>\d+))(\w) 12345+ -1 -1
|
||||
((?>\d+))(\d) 12345 -1 -1
|
||||
(?>a+)b aaab 0 4
|
||||
((?>a+)b) aaab 0 4 0 4
|
||||
(?>(a+))b aaab 0 4 0 3
|
||||
(?>b)+ aaabbbccc 3 6
|
||||
(?>a+|b+|c+)*c aaabbbbccccd 0 8
|
||||
((?>[^()]+)|\([^()]*\))+ ((abc(ade)ufh()()x 2 18 17 18
|
||||
\(((?>[^()]+)|\([^()]+\))+\) (abc) 0 5 1 4
|
||||
\(((?>[^()]+)|\([^()]+\))+\) (abc(def)xyz) 0 13 9 12
|
||||
\(((?>[^()]+)|\([^()]+\))+\) ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -1 -1
|
||||
(?>a*)* a 0 1
|
||||
(?>a*)* aa 0 2
|
||||
(?>a*)* aaaa 0 4
|
||||
(?>a*)* a 0 1
|
||||
(?>a*)* aaabcde 0 3
|
||||
((?>a*))* aaaaa 0 5 5 5
|
||||
((?>a*))* aabbaa 0 2 2 2
|
||||
((?>a*?))* aaaaa 0 0 0 0
|
||||
((?>a*?))* aabbaa 0 0 0 0
|
||||
"word (?>(?:(?!otherword)[a-zA-Z0-9]+ ){0,30})otherword" "word cat dog elephant mussel cow horse canary baboon snake shark otherword" 0 74
|
||||
"word (?>(?:(?!otherword)[a-zA-Z0-9]+ ){0,30})otherword" "word cat dog elephant mussel cow horse canary baboon snake shark" -1 -1
|
||||
"word (?>[a-zA-Z0-9]+ ){0,30}otherword" "word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope" -1 -1
|
||||
"word (?>[a-zA-Z0-9]+ ){0,30}otherword" "word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I really really hope otherword" -1 -1
|
||||
((?>Z)+|A)* ZABCDEFG 0 2 1 2
|
||||
((?>)+|A)* !
|
||||
|
||||
; subtleties of matching with no sub-expressions marked
|
||||
- normal match_nosubs REG_NO_POSIX_TEST
|
||||
a(b?c)+d accd 0 4
|
||||
(wee|week)(knights|night) weeknights 0 10
|
||||
.* abc 0 3
|
||||
a(b|(c))d abd 0 3
|
||||
a(b|(c))d acd 0 3
|
||||
a(b*|c|e)d abbd 0 4
|
||||
a(b*|c|e)d acd 0 3
|
||||
a(b*|c|e)d ad 0 2
|
||||
a(b?)c abc 0 3
|
||||
a(b?)c ac 0 2
|
||||
a(b+)c abc 0 3
|
||||
a(b+)c abbbc 0 5
|
||||
a(b*)c ac 0 2
|
||||
(a|ab)(bc([de]+)f|cde) abcdef 0 6
|
||||
a([bc]?)c abc 0 3
|
||||
a([bc]?)c ac 0 2
|
||||
a([bc]+)c abc 0 3
|
||||
a([bc]+)c abcc 0 4
|
||||
a([bc]+)bc abcbc 0 5
|
||||
a(bb+|b)b abb 0 3
|
||||
a(bbb+|bb+|b)b abb 0 3
|
||||
a(bbb+|bb+|b)b abbb 0 4
|
||||
a(bbb+|bb+|b)bb abbb 0 4
|
||||
(.*).* abcdef 0 6
|
||||
(a*)* bc 0 0
|
||||
|
||||
- normal nosubs REG_NO_POSIX_TEST
|
||||
a(b?c)+d accd 0 4
|
||||
(wee|week)(knights|night) weeknights 0 10
|
||||
.* abc 0 3
|
||||
a(b|(c))d abd 0 3
|
||||
a(b|(c))d acd 0 3
|
||||
a(b*|c|e)d abbd 0 4
|
||||
a(b*|c|e)d acd 0 3
|
||||
a(b*|c|e)d ad 0 2
|
||||
a(b?)c abc 0 3
|
||||
a(b?)c ac 0 2
|
||||
a(b+)c abc 0 3
|
||||
a(b+)c abbbc 0 5
|
||||
a(b*)c ac 0 2
|
||||
(a|ab)(bc([de]+)f|cde) abcdef 0 6
|
||||
a([bc]?)c abc 0 3
|
||||
a([bc]?)c ac 0 2
|
||||
a([bc]+)c abc 0 3
|
||||
a([bc]+)c abcc 0 4
|
||||
a([bc]+)bc abcbc 0 5
|
||||
a(bb+|b)b abb 0 3
|
||||
a(bbb+|bb+|b)b abb 0 3
|
||||
a(bbb+|bb+|b)b abbb 0 4
|
||||
a(bbb+|bb+|b)bb abbb 0 4
|
||||
(.*).* abcdef 0 6
|
||||
(a*)* bc 0 0
|
||||
|
||||
|
@ -63,11 +63,11 @@ typedef bool (*pred1_type)(const match_results<ra_it>&);
|
||||
typedef bool (*pred2_type)(const match_results<test_string_type::const_iterator>&);
|
||||
|
||||
//check that all the defined flags are available:
|
||||
regbase::flag_type f = regbase::escape_in_lists | regbase::char_classes | regbase::intervals | regbase::limited_ops
|
||||
| regbase::newline_alt | regbase::bk_plus_qm | regbase::bk_braces
|
||||
| regbase::bk_parens | regbase::bk_refs | regbase::bk_vbar | regbase::use_except
|
||||
| regbase::failbit | regbase::literal | regbase::icase | regbase::nocollate | regbase::basic
|
||||
| regbase::extended | regbase::normal | regbase::emacs | regbase::awk | regbase::grep | regbase::egrep | regbase::sed;
|
||||
wregex::flag_type f = wregex::escape_in_lists | wregex::char_classes | wregex::intervals | wregex::limited_ops
|
||||
| wregex::newline_alt | wregex::bk_plus_qm | wregex::bk_braces
|
||||
| wregex::bk_parens | wregex::bk_refs | wregex::bk_vbar | wregex::use_except
|
||||
| wregex::failbit | wregex::literal | wregex::icase | wregex::nocollate | wregex::basic
|
||||
| wregex::extended | wregex::normal | wregex::emacs | wregex::awk | wregex::grep | wregex::egrep | wregex::sed;
|
||||
|
||||
template class reg_expression<char_type>;
|
||||
template struct sub_match<ra_it>;
|
||||
@ -100,13 +100,13 @@ template char_type* regex_format(char_type*,
|
||||
const match_results<ra_it>& m,
|
||||
const test_string_type& fmt,
|
||||
unsigned flags);
|
||||
template char_type* regex_merge(char_type*,
|
||||
template char_type* regex_replace(char_type*,
|
||||
ra_it,
|
||||
ra_it,
|
||||
const reg_expression<char_type>&,
|
||||
const char_type*,
|
||||
unsigned int flags);
|
||||
template char_type* regex_merge(char_type*,
|
||||
template char_type* regex_replace(char_type*,
|
||||
ra_it,
|
||||
ra_it,
|
||||
const reg_expression<char_type>& e,
|
||||
@ -167,11 +167,11 @@ template test_string_type regex_format
|
||||
(const match_results<test_string_type::const_iterator>&,
|
||||
const test_string_type&,
|
||||
unsigned flags);
|
||||
template test_string_type regex_merge(const test_string_type&,
|
||||
template test_string_type regex_replace(const test_string_type&,
|
||||
const reg_expression<char_type>&,
|
||||
const char_type*,
|
||||
unsigned int flags);
|
||||
template test_string_type regex_merge(const test_string_type&,
|
||||
template test_string_type regex_replace(const test_string_type&,
|
||||
const reg_expression<char_type>&,
|
||||
const test_string_type&,
|
||||
unsigned int flags);
|
||||
|
Reference in New Issue
Block a user