forked from boostorg/regex
Fix case-sensitivity change behaviour.
See https://svn.boost.org/trac/boost/ticket/11205. Update docs to match.
This commit is contained in:
@ -18,6 +18,7 @@ All issues including closed ones can be viewed [@https://svn.boost.org/trac/boos
|
||||
[h4 Boost.Regex-5.1.1]
|
||||
|
||||
* Change to lockfree implementation of memory cache, see [@https://github.com/boostorg/regex/pull/23 PR#23].
|
||||
* Fix bug in case sensitivity change, see [@https://svn.boost.org/trac/boost/ticket/11940 #11940].
|
||||
|
||||
[h4 Boost.Regex-5.1.0 (Boost-1.60.0)]
|
||||
|
||||
|
@ -39,9 +39,14 @@
|
||||
<a name="boost_regex.background_information.history.h0"></a>
|
||||
<span class="phrase"><a name="boost_regex.background_information.history.boost_regex_5_1_1"></a></span><a class="link" href="history.html#boost_regex.background_information.history.boost_regex_5_1_1">Boost.Regex-5.1.1</a>
|
||||
</h5>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
Change to lockfree implementation of memory cache, see <a href="https://github.com/boostorg/regex/pull/23" target="_top">PR#23</a>.
|
||||
</li></ul></div>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Fix bug in case sensitivity change, see <a href="https://svn.boost.org/trac/boost/ticket/11940" target="_top">#11940</a>.
|
||||
</li>
|
||||
</ul></div>
|
||||
<h5>
|
||||
<a name="boost_regex.background_information.history.h1"></a>
|
||||
<span class="phrase"><a name="boost_regex.background_information.history.boost_regex_5_1_0_boost_1_60_0"></a></span><a class="link" href="history.html#boost_regex.background_information.history.boost_regex_5_1_0_boost_1_60_0">Boost.Regex-5.1.0
|
||||
|
@ -221,7 +221,7 @@
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"><p><small>Last revised: March 12, 2016 at 19:00:00 GMT</small></p></td>
|
||||
<td align="left"><p><small>Last revised: March 14, 2016 at 19:20:20 GMT</small></p></td>
|
||||
<td align="right"><div class="copyright-footer"></div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
|
@ -537,6 +537,7 @@ private:
|
||||
bool unwind_recursion_pop(bool);
|
||||
bool unwind_commit(bool);
|
||||
bool unwind_then(bool);
|
||||
bool unwind_case(bool);
|
||||
void destroy_single_repeat();
|
||||
void push_matched_paren(int index, const sub_match<BidiIterator>& sub);
|
||||
void push_recursion_stopper();
|
||||
@ -547,6 +548,7 @@ private:
|
||||
void push_non_greedy_repeat(const re_syntax_base* ps);
|
||||
void push_recursion(int idx, const re_syntax_base* p, results_type* presults);
|
||||
void push_recursion_pop();
|
||||
void push_case_change(bool);
|
||||
|
||||
// pointer to base of stack:
|
||||
saved_state* m_stack_base;
|
||||
|
@ -793,15 +793,6 @@ inline bool perl_matcher<BidiIterator, Allocator, traits>::match_assert_backref(
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_toggle_case()
|
||||
{
|
||||
// change our case sensitivity:
|
||||
this->icase = static_cast<const re_case*>(pstate)->icase;
|
||||
pstate = pstate->next.p;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_fail()
|
||||
{
|
||||
|
@ -138,6 +138,12 @@ struct saved_recursion : public saved_state
|
||||
Results results;
|
||||
};
|
||||
|
||||
struct saved_change_case : public saved_state
|
||||
{
|
||||
bool icase;
|
||||
saved_change_case(bool c) : saved_state(18), icase(c) {}
|
||||
};
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_all_states()
|
||||
{
|
||||
@ -242,6 +248,22 @@ inline void perl_matcher<BidiIterator, Allocator, traits>::push_matched_paren(in
|
||||
m_backup_state = pmp;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
inline void perl_matcher<BidiIterator, Allocator, traits>::push_case_change(bool c)
|
||||
{
|
||||
//BOOST_ASSERT(index);
|
||||
saved_change_case* pmp = static_cast<saved_change_case*>(m_backup_state);
|
||||
--pmp;
|
||||
if(pmp < m_stack_base)
|
||||
{
|
||||
extend_stack();
|
||||
pmp = static_cast<saved_change_case*>(m_backup_state);
|
||||
--pmp;
|
||||
}
|
||||
(void) new (pmp)saved_change_case(c);
|
||||
m_backup_state = pmp;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
inline void perl_matcher<BidiIterator, Allocator, traits>::push_recursion_stopper()
|
||||
{
|
||||
@ -347,6 +369,16 @@ inline void perl_matcher<BidiIterator, Allocator, traits>::push_recursion(int id
|
||||
m_backup_state = pmp;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_toggle_case()
|
||||
{
|
||||
// change our case sensitivity:
|
||||
push_case_change(this->icase);
|
||||
this->icase = static_cast<const re_case*>(pstate)->icase;
|
||||
pstate = pstate->next.p;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_startmark()
|
||||
{
|
||||
@ -1142,6 +1174,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::unwind(bool have_match)
|
||||
&perl_matcher<BidiIterator, Allocator, traits>::unwind_recursion_pop,
|
||||
&perl_matcher<BidiIterator, Allocator, traits>::unwind_commit,
|
||||
&perl_matcher<BidiIterator, Allocator, traits>::unwind_then,
|
||||
&perl_matcher<BidiIterator, Allocator, traits>::unwind_case,
|
||||
};
|
||||
|
||||
m_recursive_result = have_match;
|
||||
@ -1170,6 +1203,16 @@ bool perl_matcher<BidiIterator, Allocator, traits>::unwind_end(bool)
|
||||
return false; // end of stack nothing more to search
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::unwind_case(bool)
|
||||
{
|
||||
saved_change_case* pmp = static_cast<saved_change_case*>(m_backup_state);
|
||||
icase = pmp->icase;
|
||||
boost::BOOST_REGEX_DETAIL_NS::inplace_destroy(pmp++);
|
||||
m_backup_state = pmp;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::unwind_paren(bool have_match)
|
||||
{
|
||||
|
@ -289,11 +289,13 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_alt()
|
||||
BidiIterator oldposition(position);
|
||||
const re_syntax_base* old_pstate = jmp->alt.p;
|
||||
pstate = pstate->next.p;
|
||||
bool oldcase = icase;
|
||||
m_have_then = false;
|
||||
if(!match_all_states())
|
||||
{
|
||||
pstate = old_pstate;
|
||||
position = oldposition;
|
||||
icase = oldcase;
|
||||
if(m_have_then)
|
||||
{
|
||||
m_can_backtrack = true;
|
||||
@ -1036,6 +1038,20 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_then()
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_toggle_case()
|
||||
{
|
||||
// change our case sensitivity:
|
||||
bool oldcase = this->icase;
|
||||
this->icase = static_cast<const re_case*>(pstate)->icase;
|
||||
pstate = pstate->next.p;
|
||||
bool result = match_all_states();
|
||||
this->icase = oldcase;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::skip_until_paren(int index, bool have_match)
|
||||
{
|
||||
|
@ -245,6 +245,10 @@ void test_options2()
|
||||
TEST_REGEX_SEARCH("a(?i:b)*c", perl, "aBBc", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(?i:b)*c", perl, "aBC", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("a(?i:b)*c", perl, "aBBC", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?i:j)|h", perl, "J", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?i:j)|h", perl, "j", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?i:j)|h", perl, "h", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?i:j)|h", perl, "H", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("a(?=b(?i)c)\\w\\wd", perl, "abcd", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(?=b(?i)c)\\w\\wd", perl, "abCd", match_default, make_array(0, 4, -2, -2));
|
||||
|
Reference in New Issue
Block a user