diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2014-05-21 16:29:50 +0000 |
---|---|---|
committer | Dan Albert <danalbert@google.com> | 2014-07-29 15:49:17 -0700 |
commit | 0ac811445c369a7b1ee798ec5281557ee6306707 (patch) | |
tree | 94a1ddfe97c987eb99bf5c32c94904e587cf4d73 | |
parent | ab4cbddb646098c4ffeec558ffce3a442169e410 (diff) | |
download | external_libcxx-0ac811445c369a7b1ee798ec5281557ee6306707.tar.gz external_libcxx-0ac811445c369a7b1ee798ec5281557ee6306707.tar.bz2 external_libcxx-0ac811445c369a7b1ee798ec5281557ee6306707.zip |
Fix Bug 19678 - libc++ does not correctly handle the regex: '[^\0]*'
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@209307 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit 21622af9d798be9c56e9da0ec0187adf75fc2d27)
-rw-r--r-- | include/regex | 7 | ||||
-rw-r--r-- | test/re/re.alg/re.alg.match/ecma.pass.cpp | 12 |
2 files changed, 19 insertions, 0 deletions
diff --git a/include/regex b/include/regex index 26ade48ba..bebbaf098 100644 --- a/include/regex +++ b/include/regex @@ -4541,6 +4541,13 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first, __push_char(_CharT(__sum)); ++__first; break; + case '0': + if (__str) + *__str = _CharT(0); + else + __push_char(_CharT(0)); + ++__first; + break; default: if (*__first != '_' && !__traits_.isctype(*__first, ctype_base::alnum)) { diff --git a/test/re/re.alg/re.alg.match/ecma.pass.cpp b/test/re/re.alg/re.alg.match/ecma.pass.cpp index 50c5cc617..162a6a712 100644 --- a/test/re/re.alg/re.alg.match/ecma.pass.cpp +++ b/test/re/re.alg/re.alg.match/ecma.pass.cpp @@ -608,6 +608,18 @@ int main() assert(m.position(0) == 0); assert(m.str(0) == s); } + { + std::cmatch m; + const char s[] = "foobar"; + assert(std::regex_match(s, m, std::regex("[^\\0]*"))); + assert(m.size() == 1); + } + { + std::cmatch m; + const char s[] = "foo\0bar"; + assert(std::regex_match(s, s+7, m, std::regex("[abfor\\0]*"))); + assert(m.size() == 1); + } std::locale::global(std::locale("C")); { std::cmatch m; |