[libcxx] r185196 - William Fisher: A bug in __lookahead::exec causes /(?=^)b/ to match ab. When makes a recursive call to , it passes true for the value of . This causes a beginning-of-line anchor (^) inside a lookahead assertion to match anywhere in the text. This fixes http://llvm.org/bugs/show_bug.cgi?id=11118
Howard Hinnant
hhinnant at apple.com
Fri Jun 28 12:11:24 PDT 2013
Author: hhinnant
Date: Fri Jun 28 14:11:23 2013
New Revision: 185196
URL: http://llvm.org/viewvc/llvm-project?rev=185196&view=rev
Log:
William Fisher: A bug in __lookahead::exec causes /(?=^)b/ to match ab. When makes a recursive call to , it passes true for the value of . This causes a beginning-of-line anchor (^) inside a lookahead assertion to match anywhere in the text. This fixes http://llvm.org/bugs/show_bug.cgi?id=11118
Added:
libcxx/trunk/test/re/re.alg/re.alg.search/lookahead.pass.cpp
Modified:
libcxx/trunk/include/regex
Modified: libcxx/trunk/include/regex
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/regex?rev=185196&r1=185195&r2=185196&view=diff
==============================================================================
--- libcxx/trunk/include/regex (original)
+++ libcxx/trunk/include/regex Fri Jun 28 14:11:23 2013
@@ -2921,7 +2921,7 @@ __lookahead<_CharT, _Traits>::__exec(__s
bool __matched = __exp_.__match_at_start_ecma(__s.__current_, __s.__last_,
__m,
__s.__flags_ | regex_constants::match_continuous,
- true);
+ __s.__at_first_ && __s.__current_ == __s.__first_);
if (__matched != __invert_)
{
__s.__do_ = __state::__accept_but_not_consume;
Added: libcxx/trunk/test/re/re.alg/re.alg.search/lookahead.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/re/re.alg/re.alg.search/lookahead.pass.cpp?rev=185196&view=auto
==============================================================================
--- libcxx/trunk/test/re/re.alg/re.alg.search/lookahead.pass.cpp (added)
+++ libcxx/trunk/test/re/re.alg/re.alg.search/lookahead.pass.cpp Fri Jun 28 14:11:23 2013
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+// match_results<BidirectionalIterator, Allocator>& m,
+// const basic_regex<charT, traits>& e,
+// regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// http://llvm.org/bugs/show_bug.cgi?id=11118
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+ assert(!std::regex_search("ab", std::regex("(?=^)b")));
+ assert(!std::regex_search("ab", std::regex("a(?=^)b")));
+}
More information about the cfe-commits
mailing list