From 6b7e6921e204ed1e1b8c232872af123facbcad65 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Wed, 21 May 2014 16:29:50 +0000 Subject: [PATCH] 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 --- include/regex | 7 +++++++ test/re/re.alg/re.alg.match/ecma.pass.cpp | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/regex b/include/regex index 26ade48b..bebbaf09 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 50c5cc61..162a6a71 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;