Date: Sun, 21 Feb 2016 13:54:00 +0000 (UTC) From: Dimitry Andric <dim@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r295852 - in vendor/libc++/dist: include test/std/re/re.regex/re.regex.construct test/std/re/re.results/re.results.form Message-ID: <201602211354.u1LDs0Ka051581@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dim Date: Sun Feb 21 13:53:59 2016 New Revision: 295852 URL: https://svnweb.freebsd.org/changeset/base/295852 Log: Vendor import of libc++ release_38 branch r261369: https://llvm.org/svn/llvm-project/libcxx/branches/release_38@261369 Modified: vendor/libc++/dist/include/regex vendor/libc++/dist/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp vendor/libc++/dist/test/std/re/re.results/re.results.form/form1.pass.cpp Modified: vendor/libc++/dist/include/regex ============================================================================== --- vendor/libc++/dist/include/regex Sun Feb 21 13:53:36 2016 (r295851) +++ vendor/libc++/dist/include/regex Sun Feb 21 13:53:59 2016 (r295852) @@ -976,7 +976,12 @@ public: typedef locale locale_type; typedef ctype_base::mask char_class_type; +#if defined(__mips__) && defined(__GLIBC__) + static const char_class_type __regex_word = static_cast<char_class_type>(_ISbit(15)); +#else static const char_class_type __regex_word = 0x80; +#endif + private: locale __loc_; const ctype<char_type>* __ct_; @@ -4265,6 +4270,9 @@ basic_regex<_CharT, _Traits>::__parse_at if (__first != __last && *__first == '\\') { _ForwardIterator __t1 = _VSTD::next(__first); + if (__t1 == __last) + __throw_regex_error<regex_constants::error_escape>(); + _ForwardIterator __t2 = __parse_decimal_escape(__t1, __last); if (__t2 != __t1) __first = __t2; @@ -5384,8 +5392,8 @@ match_results<_BidirectionalIterator, _A if ('0' <= *__fmt_first && *__fmt_first <= '9') { size_t __i = *__fmt_first - '0'; - __out = _VSTD::copy(__matches_[__i].first, - __matches_[__i].second, __out); + __out = _VSTD::copy((*this)[__i].first, + (*this)[__i].second, __out); } else { @@ -5436,8 +5444,8 @@ match_results<_BidirectionalIterator, _A ++__fmt_first; __i = 10 * __i + *__fmt_first - '0'; } - __out = _VSTD::copy(__matches_[__i].first, - __matches_[__i].second, __out); + __out = _VSTD::copy((*this)[__i].first, + (*this)[__i].second, __out); } else { Modified: vendor/libc++/dist/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp ============================================================================== --- vendor/libc++/dist/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp Sun Feb 21 13:53:36 2016 (r295851) +++ vendor/libc++/dist/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp Sun Feb 21 13:53:59 2016 (r295852) @@ -33,6 +33,7 @@ int main() { assert(error_escape_thrown("[\\a]")); assert(error_escape_thrown("\\a")); + assert(error_escape_thrown("\\")); assert(error_escape_thrown("[\\e]")); assert(error_escape_thrown("\\e")); Modified: vendor/libc++/dist/test/std/re/re.results/re.results.form/form1.pass.cpp ============================================================================== --- vendor/libc++/dist/test/std/re/re.results/re.results.form/form1.pass.cpp Sun Feb 21 13:53:36 2016 (r295851) +++ vendor/libc++/dist/test/std/re/re.results/re.results.form/form1.pass.cpp Sun Feb 21 13:53:59 2016 (r295852) @@ -38,6 +38,31 @@ int main() { std::match_results<const char*> m; const char s[] = "abcdefghijk"; + assert(std::regex_search(s, m, std::regex("cd((e)fg)hi", + std::regex_constants::nosubs))); + + char out[100] = {0}; + const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2"; + char* r = m.format(output_iterator<char*>(out), + fmt, fmt + std::char_traits<char>::length(fmt)).base(); + assert(r == out + 54); + assert(std::string(out) == "prefix: ab, match: cdefghi, suffix: jk, m[1]: , m[2]: "); + } + { + std::match_results<const char*> m; + const char s[] = "abcdefghijk"; + assert(std::regex_search(s, m, std::regex("cdefghi"))); + + char out[100] = {0}; + const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2"; + char* r = m.format(output_iterator<char*>(out), + fmt, fmt + std::char_traits<char>::length(fmt)).base(); + assert(r == out + 54); + assert(std::string(out) == "prefix: ab, match: cdefghi, suffix: jk, m[1]: , m[2]: "); + } + { + std::match_results<const char*> m; + const char s[] = "abcdefghijk"; assert(std::regex_search(s, m, std::regex("cd((e)fg)hi"))); char out[100] = {0}; @@ -61,6 +86,33 @@ int main() assert(r == out + 34); assert(std::string(out) == "match: cdefghi, m[1]: efg, m[2]: e"); } + { + std::match_results<const char*> m; + const char s[] = "abcdefghijk"; + assert(std::regex_search(s, m, std::regex("cd((e)fg)hi", + std::regex_constants::nosubs))); + + char out[100] = {0}; + const char fmt[] = "match: &, m[1]: \\1, m[2]: \\2"; + char* r = m.format(output_iterator<char*>(out), + fmt, fmt + std::char_traits<char>::length(fmt), + std::regex_constants::format_sed).base(); + assert(r == out + 30); + assert(std::string(out) == "match: cdefghi, m[1]: , m[2]: "); + } + { + std::match_results<const char*> m; + const char s[] = "abcdefghijk"; + assert(std::regex_search(s, m, std::regex("cdefghi"))); + + char out[100] = {0}; + const char fmt[] = "match: &, m[1]: \\1, m[2]: \\2"; + char* r = m.format(output_iterator<char*>(out), + fmt, fmt + std::char_traits<char>::length(fmt), + std::regex_constants::format_sed).base(); + assert(r == out + 30); + assert(std::string(out) == "match: cdefghi, m[1]: , m[2]: "); + } { std::match_results<const wchar_t*> m;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201602211354.u1LDs0Ka051581>