[libcxx] r209307 - Fix Bug 19678 - libc++ does not correctly handle the regex: '[^\0]*'

Marshall Clow mclow.lists at gmail.com
Wed May 21 09:29:51 PDT 2014


Author: marshall
Date: Wed May 21 11:29:50 2014
New Revision: 209307

URL: http://llvm.org/viewvc/llvm-project?rev=209307&view=rev
Log:
Fix Bug 19678 - libc++ does not correctly handle the regex: '[^\0]*'

Modified:
    libcxx/trunk/include/regex
    libcxx/trunk/test/re/re.alg/re.alg.match/ecma.pass.cpp

Modified: libcxx/trunk/include/regex
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/regex?rev=209307&r1=209306&r2=209307&view=diff
==============================================================================
--- libcxx/trunk/include/regex (original)
+++ libcxx/trunk/include/regex Wed May 21 11:29:50 2014
@@ -4541,6 +4541,13 @@ basic_regex<_CharT, _Traits>::__parse_ch
                 __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))
             {

Modified: libcxx/trunk/test/re/re.alg/re.alg.match/ecma.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/re/re.alg/re.alg.match/ecma.pass.cpp?rev=209307&r1=209306&r2=209307&view=diff
==============================================================================
--- libcxx/trunk/test/re/re.alg/re.alg.match/ecma.pass.cpp (original)
+++ libcxx/trunk/test/re/re.alg/re.alg.match/ecma.pass.cpp Wed May 21 11:29:50 2014
@@ -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;





More information about the cfe-commits mailing list