[cfe-commits] [libcxx] r109512 - in /libcxx/trunk: include/regex src/regex.cpp test/re/re.alg/re.alg.search/basic.pass.cpp test/re/re.alg/re.alg.search/ecma.pass.cpp test/re/re.alg/re.alg.search/extended.pass.cpp test/re/re.const/re.synopt/syntax_option_type.pass.cpp
Howard Hinnant
hhinnant at apple.com
Tue Jul 27 10:24:18 PDT 2010
Author: hhinnant
Date: Tue Jul 27 12:24:17 2010
New Revision: 109512
URL: http://llvm.org/viewvc/llvm-project?rev=109512&view=rev
Log:
continued regex development...
Modified:
libcxx/trunk/include/regex
libcxx/trunk/src/regex.cpp
libcxx/trunk/test/re/re.alg/re.alg.search/basic.pass.cpp
libcxx/trunk/test/re/re.alg/re.alg.search/ecma.pass.cpp
libcxx/trunk/test/re/re.alg/re.alg.search/extended.pass.cpp
libcxx/trunk/test/re/re.const/re.synopt/syntax_option_type.pass.cpp
Modified: libcxx/trunk/include/regex
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/regex?rev=109512&r1=109511&r2=109512&view=diff
==============================================================================
--- libcxx/trunk/include/regex (original)
+++ libcxx/trunk/include/regex Tue Jul 27 12:24:17 2010
@@ -747,12 +747,12 @@
nosubs = 1 << 1,
optimize = 1 << 2,
collate = 1 << 3,
- ECMAScript = 1 << 4,
- basic = 1 << 5,
- extended = 1 << 6,
- awk = 1 << 7,
- grep = 1 << 8,
- egrep = 1 << 9
+ ECMAScript = 0,
+ basic = 1 << 4,
+ extended = 1 << 5,
+ awk = 1 << 6,
+ grep = 1 << 7,
+ egrep = 1 << 8
};
inline
@@ -907,7 +907,9 @@
error_badrepeat,
error_complexity,
error_stack,
- error_temp
+ __re_err_grammar,
+ __re_err_empty,
+ __re_err_unknown
};
} // regex_constants
@@ -1538,8 +1540,17 @@
}
else
{
- if (__max_ > 0)
+ __s.__loop_data_[__loop_id_].first = 0;
+ bool __do_repeat = 0 < __max_;
+ bool __do_alt = 0 >= __min_;
+ if (__do_repeat && __do_alt)
__s.__do_ = __state::__split;
+ else if (__do_repeat)
+ {
+ __s.__do_ = __state::__accept_but_not_consume;
+ __s.__node_ = this->first();
+ __init_repeat(__s);
+ }
else
{
__s.__do_ = __state::__accept_but_not_consume;
@@ -2727,7 +2738,6 @@
bool
__match_at_start(const _CharT* __first, const _CharT* __last,
match_results<const _CharT*, _Allocator>& __m,
- vector<size_t>& __lc,
regex_constants::match_flag_type __flags) const;
template <class _Allocator>
bool
@@ -2738,13 +2748,11 @@
bool
__match_at_start_posix_nosubs(const _CharT* __first, const _CharT* __last,
match_results<const _CharT*, _Allocator>& __m,
- vector<size_t>& __lc,
regex_constants::match_flag_type __flags) const;
template <class _Allocator>
bool
__match_at_start_posix_subs(const _CharT* __first, const _CharT* __last,
match_results<const _CharT*, _Allocator>& __m,
- vector<size_t>& __lc,
regex_constants::match_flag_type __flags) const;
template <class _B, class _A, class _C, class _T>
@@ -2810,7 +2818,7 @@
__h.release();
__end_ = __start_.get();
}
- switch (__flags_ & 0x3F0)
+ switch (__flags_ & 0x1F0)
{
case ECMAScript:
__parse_ecma_exp(__first, __last);
@@ -2828,7 +2836,7 @@
case egrep:
break;
default:
- throw regex_error(regex_constants::error_temp);
+ throw regex_error(regex_constants::__re_err_grammar);
}
}
@@ -2859,7 +2867,7 @@
}
}
if (__first != __last)
- throw regex_error(regex_constants::error_temp);
+ throw regex_error(regex_constants::__re_err_empty);
}
return __first;
}
@@ -2873,14 +2881,14 @@
__owns_one_state<_CharT>* __sa = __end_;
_ForwardIterator __temp = __parse_ERE_branch(__first, __last);
if (__temp == __first)
- throw regex_error(regex_constants::error_temp);
+ throw regex_error(regex_constants::__re_err_empty);
__first = __temp;
while (__first != __last && *__first == '|')
{
__owns_one_state<_CharT>* __sb = __end_;
__temp = __parse_ERE_branch(++__first, __last);
if (__temp == __first)
- throw regex_error(regex_constants::error_temp);
+ throw regex_error(regex_constants::__re_err_empty);
__push_alternation(__sa, __sb);
__first = __temp;
}
@@ -2895,7 +2903,7 @@
{
_ForwardIterator __temp = __parse_ERE_expression(__first, __last);
if (__temp == __first)
- throw regex_error(regex_constants::error_temp);
+ throw regex_error(regex_constants::__re_err_empty);
do
{
__first = __temp;
@@ -4879,7 +4887,7 @@
__states.pop_back();
break;
default:
- throw regex_error(regex_constants::error_temp);
+ throw regex_error(regex_constants::__re_err_unknown);
break;
}
} while (!__states.empty());
@@ -4893,7 +4901,6 @@
basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs(
const _CharT* __first, const _CharT* __last,
match_results<const _CharT*, _Allocator>& __m,
- vector<size_t>& __lc,
regex_constants::match_flag_type __flags) const
{
deque<__state> __states;
@@ -4919,11 +4926,9 @@
switch (__s.__do_)
{
case __state::__end_state:
- if (__highest_j < __s.__current_ - __s.__first_)
- {
+ if (!__matched || __highest_j < __s.__current_ - __s.__first_)
__highest_j = __s.__current_ - __s.__first_;
- __matched = true;
- }
+ __matched = true;
if (__highest_j == _N)
__states.clear();
else
@@ -4950,7 +4955,7 @@
__states.pop_back();
break;
default:
- throw regex_error(regex_constants::error_temp);
+ throw regex_error(regex_constants::__re_err_unknown);
break;
}
} while (!__states.empty());
@@ -4971,7 +4976,6 @@
basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(
const _CharT* __first, const _CharT* __last,
match_results<const _CharT*, _Allocator>& __m,
- vector<size_t>& __lc,
regex_constants::match_flag_type __flags) const
{
vector<__state> __states;
@@ -5001,16 +5005,16 @@
switch (__s.__do_)
{
case __state::__end_state:
- if (__j == 0 || __highest_j < __j)
+ if (!__matched || __highest_j < __s.__current_ - __s.__first_)
{
- __matched = true;
- __highest_j = __j;
+ __highest_j = __s.__current_ - __s.__first_;
__best_state = __s;
- if (__highest_j == _N || __highest_j == 0)
- __states.clear();
- else
- __states.pop_back();
}
+ __matched = true;
+ if (__highest_j == _N)
+ __states.clear();
+ else
+ __states.pop_back();
break;
case __state::__accept_and_consume:
__j += __s.__current_ - __current;
@@ -5031,7 +5035,7 @@
__states.pop_back();
break;
default:
- throw regex_error(regex_constants::error_temp);
+ throw regex_error(regex_constants::__re_err_unknown);
break;
}
} while (!__states.empty());
@@ -5054,14 +5058,13 @@
basic_regex<_CharT, _Traits>::__match_at_start(
const _CharT* __first, const _CharT* __last,
match_results<const _CharT*, _Allocator>& __m,
- vector<size_t>& __lc,
regex_constants::match_flag_type __flags) const
{
- if (__flags_ & ECMAScript)
+ if ((__flags_ & 0x1F0) == ECMAScript)
return __match_at_start_ecma(__first, __last, __m, __flags);
if (mark_count() == 0)
- return __match_at_start_posix_nosubs(__first, __last, __m, __lc, __flags);
- return __match_at_start_posix_subs(__first, __last, __m, __lc, __flags);
+ return __match_at_start_posix_nosubs(__first, __last, __m, __flags);
+ return __match_at_start_posix_subs(__first, __last, __m, __flags);
}
template <class _CharT, class _Traits>
@@ -5075,8 +5078,7 @@
if (__left_anchor_)
__flags |= regex_constants::match_continuous;
__m.__init(1 + mark_count(), __first, __last);
- vector<size_t> __lc(__loop_count());
- if (__match_at_start(__first, __last, __m, __lc, __flags))
+ if (__match_at_start(__first, __last, __m, __flags))
{
__m.__prefix_.second = __m[0].first;
__m.__prefix_.matched = __m.__prefix_.first != __m.__prefix_.second;
@@ -5089,7 +5091,7 @@
__m.__matches_.assign(__m.size(), __m.__unmatched_);
for (++__first; __first != __last; ++__first)
{
- if (__match_at_start(__first, __last, __m, __lc, __flags))
+ if (__match_at_start(__first, __last, __m, __flags))
{
__m.__prefix_.second = __m[0].first;
__m.__prefix_.matched = __m.__prefix_.first != __m.__prefix_.second;
Modified: libcxx/trunk/src/regex.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/regex.cpp?rev=109512&r1=109511&r2=109512&view=diff
==============================================================================
--- libcxx/trunk/src/regex.cpp (original)
+++ libcxx/trunk/src/regex.cpp Tue Jul 27 12:24:17 2010
@@ -50,6 +50,10 @@
case regex_constants::error_stack:
return "There was insufficient memory to determine whether the regular "
"expression could match the specified character sequence.";
+ case regex_constants::__re_err_grammar:
+ return "An invalid regex grammar has been requested.";
+ case regex_constants::__re_err_empty:
+ return "An empty regex is not allowed in the POSIX grammar.";
default:
break;
}
Modified: libcxx/trunk/test/re/re.alg/re.alg.search/basic.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/re/re.alg/re.alg.search/basic.pass.cpp?rev=109512&r1=109511&r2=109512&view=diff
==============================================================================
--- libcxx/trunk/test/re/re.alg/re.alg.search/basic.pass.cpp (original)
+++ libcxx/trunk/test/re/re.alg/re.alg.search/basic.pass.cpp Tue Jul 27 12:24:17 2010
@@ -733,6 +733,22 @@
assert(std::regex_search(s, m, std::regex("[ace1-9]*",
std::regex_constants::basic)));
assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]\\{1,\\}",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
assert(m.prefix().matched);
assert(m.prefix().first == s);
assert(m.prefix().second == m[0].first);
@@ -1476,6 +1492,22 @@
assert(std::regex_search(s, m, std::wregex(L"[ace1-9]*",
std::regex_constants::basic)));
assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]\\{1,\\}",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
assert(m.prefix().matched);
assert(m.prefix().first == s);
assert(m.prefix().second == m[0].first);
Modified: libcxx/trunk/test/re/re.alg/re.alg.search/ecma.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/re/re.alg/re.alg.search/ecma.pass.cpp?rev=109512&r1=109511&r2=109512&view=diff
==============================================================================
--- libcxx/trunk/test/re/re.alg/re.alg.search/ecma.pass.cpp (original)
+++ libcxx/trunk/test/re/re.alg/re.alg.search/ecma.pass.cpp Tue Jul 27 12:24:17 2010
@@ -134,8 +134,7 @@
{
std::cmatch m;
const char s[] = "abcdefghijk";
- assert(std::regex_search(s, m, std::regex("cd((e)fg)hi",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
assert(m.size() == 3);
assert(m.prefix().matched);
assert(m.prefix().first == s);
@@ -429,40 +428,38 @@
{
std::cmatch m;
const char s[] = "tournament";
- assert(std::regex_search(s, m, std::regex("tour|to|tournament",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::regex("tour|to|tournament")));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
+ assert(m.suffix().matched);
assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 4);
assert(m.position(0) == 0);
- assert(m.str(0) == s);
+ assert(m.str(0) == "tour");
}
{
std::cmatch m;
const char s[] = "tournamenttotour";
assert(std::regex_search(s, m, std::regex("(tour|to|tournament)+",
- std::regex_constants::extended | std::regex_constants::nosubs)));
+ std::regex_constants::nosubs)));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
+ assert(m.suffix().matched);
assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 4);
assert(m.position(0) == 0);
- assert(m.str(0) == s);
+ assert(m.str(0) == "tour");
}
{
std::cmatch m;
const char s[] = "ttotour";
- assert(std::regex_search(s, m, std::regex("(tour|to|t)+",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::regex("(tour|to|t)+")));
assert(m.size() == 2);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
@@ -501,8 +498,7 @@
{
std::cmatch m;
const char s[] = "a";
- assert(std::regex_search(s, m, std::regex("^[a]$",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::regex("^[a]$")));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
@@ -517,8 +513,7 @@
{
std::cmatch m;
const char s[] = "a";
- assert(std::regex_search(s, m, std::regex("^[ab]$",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::regex("^[ab]$")));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
@@ -533,8 +528,7 @@
{
std::cmatch m;
const char s[] = "c";
- assert(std::regex_search(s, m, std::regex("^[a-f]$",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::regex("^[a-f]$")));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
@@ -549,15 +543,13 @@
{
std::cmatch m;
const char s[] = "g";
- assert(!std::regex_search(s, m, std::regex("^[a-f]$",
- std::regex_constants::extended)));
+ assert(!std::regex_search(s, m, std::regex("^[a-f]$")));
assert(m.size() == 0);
}
{
std::cmatch m;
const char s[] = "Iraqi";
- assert(std::regex_search(s, m, std::regex("q[^u]",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::regex("q[^u]")));
assert(m.size() == 1);
assert(m.prefix().matched);
assert(m.prefix().first == s);
@@ -572,15 +564,13 @@
{
std::cmatch m;
const char s[] = "Iraq";
- assert(!std::regex_search(s, m, std::regex("q[^u]",
- std::regex_constants::extended)));
+ assert(!std::regex_search(s, m, std::regex("q[^u]")));
assert(m.size() == 0);
}
{
std::cmatch m;
const char s[] = "AmB";
- assert(std::regex_search(s, m, std::regex("A[[:lower:]]B",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::regex("A[[:lower:]]B")));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
@@ -595,15 +585,13 @@
{
std::cmatch m;
const char s[] = "AMB";
- assert(!std::regex_search(s, m, std::regex("A[[:lower:]]B",
- std::regex_constants::extended)));
+ assert(!std::regex_search(s, m, std::regex("A[[:lower:]]B")));
assert(m.size() == 0);
}
{
std::cmatch m;
const char s[] = "AMB";
- assert(std::regex_search(s, m, std::regex("A[^[:lower:]]B",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]]B")));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
@@ -618,22 +606,19 @@
{
std::cmatch m;
const char s[] = "AmB";
- assert(!std::regex_search(s, m, std::regex("A[^[:lower:]]B",
- std::regex_constants::extended)));
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]]B")));
assert(m.size() == 0);
}
{
std::cmatch m;
const char s[] = "A5B";
- assert(!std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
- std::regex_constants::extended)));
+ assert(!std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B")));
assert(m.size() == 0);
}
{
std::cmatch m;
const char s[] = "A?B";
- assert(std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B")));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
@@ -648,8 +633,7 @@
{
std::cmatch m;
const char s[] = "-";
- assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]")));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
@@ -664,8 +648,7 @@
{
std::cmatch m;
const char s[] = "z";
- assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]")));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
@@ -680,16 +663,14 @@
{
std::cmatch m;
const char s[] = "m";
- assert(!std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
- std::regex_constants::extended)));
+ assert(!std::regex_search(s, m, std::regex("[a[.hyphen.]z]")));
assert(m.size() == 0);
}
std::locale::global(std::locale("cs_CZ.ISO8859-2"));
{
std::cmatch m;
const char s[] = "m";
- assert(std::regex_search(s, m, std::regex("[a[=M=]z]",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::regex("[a[=M=]z]")));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
@@ -705,7 +686,7 @@
std::cmatch m;
const char s[] = "Ch";
assert(std::regex_search(s, m, std::regex("[a[.ch.]z]",
- std::regex_constants::extended | std::regex_constants::icase)));
+ std::regex_constants::icase)));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
@@ -721,15 +702,28 @@
{
std::cmatch m;
const char s[] = "m";
- assert(!std::regex_search(s, m, std::regex("[a[=M=]z]",
- std::regex_constants::extended)));
+ assert(!std::regex_search(s, m, std::regex("[a[=M=]z]")));
assert(m.size() == 0);
}
{
std::cmatch m;
const char s[] = "01a45cef9";
- assert(std::regex_search(s, m, std::regex("[ace1-9]*",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::regex("[ace1-9]*")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]+")));
assert(m.size() == 1);
assert(m.prefix().matched);
assert(m.prefix().first == s);
@@ -874,8 +868,7 @@
{
std::wcmatch m;
const wchar_t s[] = L"abcdefghijk";
- assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
assert(m.size() == 3);
assert(m.prefix().matched);
assert(m.prefix().first == s);
@@ -1169,40 +1162,38 @@
{
std::wcmatch m;
const wchar_t s[] = L"tournament";
- assert(std::regex_search(s, m, std::wregex(L"tour|to|tournament",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::wregex(L"tour|to|tournament")));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
+ assert(m.suffix().matched);
assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 4);
assert(m.position(0) == 0);
- assert(m.str(0) == s);
+ assert(m.str(0) == L"tour");
}
{
std::wcmatch m;
const wchar_t s[] = L"tournamenttotour";
assert(std::regex_search(s, m, std::wregex(L"(tour|to|tournament)+",
- std::regex_constants::extended | std::regex_constants::nosubs)));
+ std::regex_constants::nosubs)));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
+ assert(m.suffix().matched);
assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 4);
assert(m.position(0) == 0);
- assert(m.str(0) == s);
+ assert(m.str(0) == L"tour");
}
{
std::wcmatch m;
const wchar_t s[] = L"ttotour";
- assert(std::regex_search(s, m, std::wregex(L"(tour|to|t)+",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::wregex(L"(tour|to|t)+")));
assert(m.size() == 2);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
@@ -1241,8 +1232,7 @@
{
std::wcmatch m;
const wchar_t s[] = L"a";
- assert(std::regex_search(s, m, std::wregex(L"^[a]$",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::wregex(L"^[a]$")));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
@@ -1257,8 +1247,7 @@
{
std::wcmatch m;
const wchar_t s[] = L"a";
- assert(std::regex_search(s, m, std::wregex(L"^[ab]$",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::wregex(L"^[ab]$")));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
@@ -1273,8 +1262,7 @@
{
std::wcmatch m;
const wchar_t s[] = L"c";
- assert(std::regex_search(s, m, std::wregex(L"^[a-f]$",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::wregex(L"^[a-f]$")));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
@@ -1289,15 +1277,13 @@
{
std::wcmatch m;
const wchar_t s[] = L"g";
- assert(!std::regex_search(s, m, std::wregex(L"^[a-f]$",
- std::regex_constants::extended)));
+ assert(!std::regex_search(s, m, std::wregex(L"^[a-f]$")));
assert(m.size() == 0);
}
{
std::wcmatch m;
const wchar_t s[] = L"Iraqi";
- assert(std::regex_search(s, m, std::wregex(L"q[^u]",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::wregex(L"q[^u]")));
assert(m.size() == 1);
assert(m.prefix().matched);
assert(m.prefix().first == s);
@@ -1312,15 +1298,13 @@
{
std::wcmatch m;
const wchar_t s[] = L"Iraq";
- assert(!std::regex_search(s, m, std::wregex(L"q[^u]",
- std::regex_constants::extended)));
+ assert(!std::regex_search(s, m, std::wregex(L"q[^u]")));
assert(m.size() == 0);
}
{
std::wcmatch m;
const wchar_t s[] = L"AmB";
- assert(std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::wregex(L"A[[:lower:]]B")));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
@@ -1335,15 +1319,13 @@
{
std::wcmatch m;
const wchar_t s[] = L"AMB";
- assert(!std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
- std::regex_constants::extended)));
+ assert(!std::regex_search(s, m, std::wregex(L"A[[:lower:]]B")));
assert(m.size() == 0);
}
{
std::wcmatch m;
const wchar_t s[] = L"AMB";
- assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B")));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
@@ -1358,22 +1340,19 @@
{
std::wcmatch m;
const wchar_t s[] = L"AmB";
- assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
- std::regex_constants::extended)));
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B")));
assert(m.size() == 0);
}
{
std::wcmatch m;
const wchar_t s[] = L"A5B";
- assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
- std::regex_constants::extended)));
+ assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B")));
assert(m.size() == 0);
}
{
std::wcmatch m;
const wchar_t s[] = L"A?B";
- assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B")));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
@@ -1388,8 +1367,7 @@
{
std::wcmatch m;
const wchar_t s[] = L"-";
- assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]")));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
@@ -1404,8 +1382,7 @@
{
std::wcmatch m;
const wchar_t s[] = L"z";
- assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]")));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
@@ -1420,16 +1397,14 @@
{
std::wcmatch m;
const wchar_t s[] = L"m";
- assert(!std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
- std::regex_constants::extended)));
+ assert(!std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]")));
assert(m.size() == 0);
}
std::locale::global(std::locale("cs_CZ.ISO8859-2"));
{
std::wcmatch m;
const wchar_t s[] = L"m";
- assert(std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::wregex(L"[a[=M=]z]")));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
@@ -1445,7 +1420,7 @@
std::wcmatch m;
const wchar_t s[] = L"Ch";
assert(std::regex_search(s, m, std::wregex(L"[a[.ch.]z]",
- std::regex_constants::extended | std::regex_constants::icase)));
+ std::regex_constants::icase)));
assert(m.size() == 1);
assert(!m.prefix().matched);
assert(m.prefix().first == s);
@@ -1461,15 +1436,28 @@
{
std::wcmatch m;
const wchar_t s[] = L"m";
- assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
- std::regex_constants::extended)));
+ assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]")));
assert(m.size() == 0);
}
{
std::wcmatch m;
const wchar_t s[] = L"01a45cef9";
- assert(std::regex_search(s, m, std::wregex(L"[ace1-9]*",
- std::regex_constants::extended)));
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]*")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]+")));
assert(m.size() == 1);
assert(m.prefix().matched);
assert(m.prefix().first == s);
Modified: libcxx/trunk/test/re/re.alg/re.alg.search/extended.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/re/re.alg/re.alg.search/extended.pass.cpp?rev=109512&r1=109511&r2=109512&view=diff
==============================================================================
--- libcxx/trunk/test/re/re.alg/re.alg.search/extended.pass.cpp (original)
+++ libcxx/trunk/test/re/re.alg/re.alg.search/extended.pass.cpp Tue Jul 27 12:24:17 2010
@@ -731,6 +731,22 @@
assert(std::regex_search(s, m, std::regex("[ace1-9]*",
std::regex_constants::extended)));
assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<char>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == "");
+ }
+ {
+ std::cmatch m;
+ const char s[] = "01a45cef9";
+ assert(std::regex_search(s, m, std::regex("[ace1-9]+",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
assert(m.prefix().matched);
assert(m.prefix().first == s);
assert(m.prefix().second == m[0].first);
@@ -1471,6 +1487,22 @@
assert(std::regex_search(s, m, std::wregex(L"[ace1-9]*",
std::regex_constants::extended)));
assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+ assert(m.length(0) == 0);
+ assert(m.position(0) == 0);
+ assert(m.str(0) == L"");
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"01a45cef9";
+ assert(std::regex_search(s, m, std::wregex(L"[ace1-9]+",
+ std::regex_constants::extended)));
+ assert(m.size() == 1);
assert(m.prefix().matched);
assert(m.prefix().first == s);
assert(m.prefix().second == m[0].first);
Modified: libcxx/trunk/test/re/re.const/re.synopt/syntax_option_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/re/re.const/re.synopt/syntax_option_type.pass.cpp?rev=109512&r1=109511&r2=109512&view=diff
==============================================================================
--- libcxx/trunk/test/re/re.const/re.synopt/syntax_option_type.pass.cpp (original)
+++ libcxx/trunk/test/re/re.const/re.synopt/syntax_option_type.pass.cpp Tue Jul 27 12:24:17 2010
@@ -38,7 +38,7 @@
assert(std::regex_constants::nosubs != 0);
assert(std::regex_constants::optimize != 0);
assert(std::regex_constants::collate != 0);
- assert(std::regex_constants::ECMAScript != 0);
+ assert(std::regex_constants::ECMAScript == 0);
assert(std::regex_constants::basic != 0);
assert(std::regex_constants::extended != 0);
assert(std::regex_constants::awk != 0);
More information about the cfe-commits
mailing list