Merge regex bug fix.

Refs #8569.

[SVN r84463]
This commit is contained in:
John Maddock
2013-05-24 17:09:40 +00:00
parent f6870ad64a
commit b738a55e0d
96 changed files with 450 additions and 398 deletions

View File

@ -423,7 +423,7 @@ bool do_regex_match(BidiIterator first, BidiIterator last,
{
typedef u16_to_u32_iterator<BidiIterator, UChar32> conv_type;
typedef match_results<conv_type> match_type;
typedef typename match_type::allocator_type alloc_type;
//typedef typename match_type::allocator_type alloc_type;
match_type what;
bool result = ::boost::regex_match(conv_type(first, first, last), conv_type(last, first, last), what, e, flags);
// copy results across to m:
@ -439,7 +439,7 @@ bool do_regex_match(BidiIterator first, BidiIterator last,
{
typedef u8_to_u32_iterator<BidiIterator, UChar32> conv_type;
typedef match_results<conv_type> match_type;
typedef typename match_type::allocator_type alloc_type;
//typedef typename match_type::allocator_type alloc_type;
match_type what;
bool result = ::boost::regex_match(conv_type(first, first, last), conv_type(last, first, last), what, e, flags);
// copy results across to m:
@ -598,7 +598,7 @@ bool do_regex_search(BidiIterator first, BidiIterator last,
{
typedef u16_to_u32_iterator<BidiIterator, UChar32> conv_type;
typedef match_results<conv_type> match_type;
typedef typename match_type::allocator_type alloc_type;
//typedef typename match_type::allocator_type alloc_type;
match_type what;
bool result = ::boost::regex_search(conv_type(first, first, last), conv_type(last, first, last), what, e, flags, conv_type(base));
// copy results across to m:
@ -615,7 +615,7 @@ bool do_regex_search(BidiIterator first, BidiIterator last,
{
typedef u8_to_u32_iterator<BidiIterator, UChar32> conv_type;
typedef match_results<conv_type> match_type;
typedef typename match_type::allocator_type alloc_type;
//typedef typename match_type::allocator_type alloc_type;
match_type what;
bool result = ::boost::regex_search(conv_type(first, first, last), conv_type(last, first, last), what, e, flags, conv_type(base));
// copy results across to m:

View File

@ -36,14 +36,7 @@
//
namespace boost{
class BOOST_REGEX_DECL scoped_static_mutex_lock;
class static_mutex
{
public:
typedef scoped_static_mutex_lock scoped_lock;
pthread_mutex_t m_mutex;
};
class static_mutex;
#define BOOST_STATIC_MUTEX_INIT { PTHREAD_MUTEX_INITIALIZER, }
@ -67,6 +60,12 @@ private:
bool m_have_lock;
};
class static_mutex
{
public:
typedef scoped_static_mutex_lock scoped_lock;
pthread_mutex_t m_mutex;
};
} // namespace boost
#elif defined(BOOST_HAS_WINTHREADS)

View File

@ -738,14 +738,14 @@ void basic_regex_creator<charT, traits>::fixup_pointers(re_syntax_base* state)
case syntax_element_long_set_rep:
// set the state_id of this repeat:
static_cast<re_repeat*>(state)->state_id = m_repeater_id++;
// fall through:
BOOST_FALLTHROUGH;
case syntax_element_alt:
std::memset(static_cast<re_alt*>(state)->_map, 0, sizeof(static_cast<re_alt*>(state)->_map));
static_cast<re_alt*>(state)->can_be_null = 0;
// fall through:
BOOST_FALLTHROUGH;
case syntax_element_jump:
static_cast<re_jump*>(state)->alt.p = getaddress(static_cast<re_jump*>(state)->alt.i, state);
// fall through again:
BOOST_FALLTHROUGH;
default:
if(state->next.i)
state->next.p = getaddress(state->next.i, state);
@ -877,6 +877,7 @@ void basic_regex_creator<charT, traits>::fixup_recursions(re_syntax_base* state)
}
}
}
break;
default:
break;
}
@ -941,7 +942,7 @@ void basic_regex_creator<charT, traits>::create_startmaps(re_syntax_base* state)
e.raise();
}
}
// fall through:
BOOST_FALLTHROUGH;
default:
state = state->next.p;
}
@ -1153,13 +1154,14 @@ void basic_regex_creator<charT, traits>::create_startmap(re_syntax_base* state,
break;
}
m_recursion_checks[recursion_sub] = true;
// fall through, can't handle nested recursion here...
// can't handle nested recursion here...
BOOST_FALLTHROUGH;
}
case syntax_element_backref:
// can be null, and any character can match:
if(pnull)
*pnull |= mask;
// fall through:
BOOST_FALLTHROUGH;
case syntax_element_wild:
{
// can't be null, any character can match:
@ -1359,7 +1361,7 @@ void basic_regex_creator<charT, traits>::create_startmap(re_syntax_base* state,
state = state->next.p->next.p;
break;
}
// otherwise fall through:
BOOST_FALLTHROUGH;
default:
state = state->next.p;
}
@ -1456,6 +1458,7 @@ void basic_regex_creator<charT, traits>::set_bad_repeat(re_syntax_base* pt)
if(state_id <= sizeof(m_bad_repeats) * CHAR_BIT)
m_bad_repeats |= (one << state_id);
}
break;
default:
break;
}
@ -1537,7 +1540,7 @@ void basic_regex_creator<charT, traits>::probe_leading_repeat(re_syntax_base* st
case syntax_element_long_set_rep:
if(this->m_has_backrefs == 0)
static_cast<re_repeat*>(state)->leading = true;
// fall through:
BOOST_FALLTHROUGH;
default:
return;
}

View File

@ -369,7 +369,7 @@ bool basic_regex_parser<charT, traits>::parse_extended()
while((m_position != m_end) && !is_separator(*m_position++)){}
return true;
}
// Otherwise fall through:
BOOST_FALLTHROUGH;
default:
result = parse_literal();
break;
@ -623,7 +623,7 @@ bool basic_regex_parser<charT, traits>::parse_basic_escape()
{
case 'w':
negate = false;
// fall through:
BOOST_FALLTHROUGH;
case 'W':
{
basic_char_set<charT, traits> char_set;
@ -640,7 +640,7 @@ bool basic_regex_parser<charT, traits>::parse_basic_escape()
}
case 's':
negate = false;
// fall through:
BOOST_FALLTHROUGH;
case 'S':
return add_emacs_code(negate);
case 'c':
@ -672,7 +672,7 @@ bool basic_regex_parser<charT, traits>::parse_extended_escape()
{
case regex_constants::escape_type_not_class:
negate = true;
// fall through:
BOOST_FALLTHROUGH;
case regex_constants::escape_type_class:
{
escape_type_class_jump:
@ -742,7 +742,7 @@ escape_type_class_jump:
break;
case regex_constants::escape_type_not_property:
negate = true;
// fall through:
BOOST_FALLTHROUGH;
case regex_constants::escape_type_property:
{
++m_position;
@ -901,7 +901,7 @@ escape_type_class_jump:
case regex_constants::escape_type_control_v:
if(0 == (this->flags() & (regbase::main_option_type | regbase::no_perl_ex)))
goto escape_type_class_jump;
// fallthrough:
BOOST_FALLTHROUGH;
default:
this->append_literal(unescape_character());
break;
@ -1070,26 +1070,46 @@ bool basic_regex_parser<charT, traits>::parse_repeat_range(bool isbasic)
// skip whitespace:
while((m_position != m_end) && this->m_traits.isctype(*m_position, this->m_mask_space))
++m_position;
// fail if at end:
if(this->m_position == this->m_end)
{
fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message);
return false;
if(this->flags() & (regbase::main_option_type | regbase::no_perl_ex))
{
fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message);
return false;
}
// Treat the opening '{' as a literal character, rewind to start of error:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_brace) --m_position;
return parse_literal();
}
// get min:
v = this->m_traits.toi(m_position, m_end, 10);
// skip whitespace:
while((m_position != m_end) && this->m_traits.isctype(*m_position, this->m_mask_space))
++m_position;
if(v < 0)
{
fail(regex_constants::error_badbrace, this->m_position - this->m_base);
return false;
if(this->flags() & (regbase::main_option_type | regbase::no_perl_ex))
{
fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message);
return false;
}
// Treat the opening '{' as a literal character, rewind to start of error:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_brace) --m_position;
return parse_literal();
}
else if(this->m_position == this->m_end)
while((m_position != m_end) && this->m_traits.isctype(*m_position, this->m_mask_space))
++m_position;
if(this->m_position == this->m_end)
{
fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message);
return false;
if(this->flags() & (regbase::main_option_type | regbase::no_perl_ex))
{
fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message);
return false;
}
// Treat the opening '{' as a literal character, rewind to start of error:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_brace) --m_position;
return parse_literal();
}
min = v;
// see if we have a comma:
@ -1102,8 +1122,15 @@ bool basic_regex_parser<charT, traits>::parse_repeat_range(bool isbasic)
++m_position;
if(this->m_position == this->m_end)
{
fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message);
return false;
if(this->flags() & (regbase::main_option_type | regbase::no_perl_ex))
{
fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message);
return false;
}
// Treat the opening '{' as a literal character, rewind to start of error:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_brace) --m_position;
return parse_literal();
}
// get the value if any:
v = this->m_traits.toi(m_position, m_end, 10);
@ -1120,8 +1147,15 @@ bool basic_regex_parser<charT, traits>::parse_repeat_range(bool isbasic)
// OK now check trailing }:
if(this->m_position == this->m_end)
{
fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message);
return false;
if(this->flags() & (regbase::main_option_type | regbase::no_perl_ex))
{
fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message);
return false;
}
// Treat the opening '{' as a literal character, rewind to start of error:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_brace) --m_position;
return parse_literal();
}
if(isbasic)
{
@ -1144,8 +1178,10 @@ bool basic_regex_parser<charT, traits>::parse_repeat_range(bool isbasic)
++m_position;
else
{
fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message);
return false;
// Treat the opening '{' as a literal character, rewind to start of error:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_brace) --m_position;
return parse_literal();
}
//
// finally go and add the repeat, unless error:
@ -1959,7 +1995,7 @@ bool basic_regex_parser<charT, traits>::parse_perl_extension()
{
case regex_constants::syntax_or:
m_mark_reset = m_mark_count;
// fall through:
BOOST_FALLTHROUGH;
case regex_constants::syntax_colon:
//
// a non-capturing mark:

View File

@ -283,7 +283,8 @@ void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::format
format_perl();
break;
}
// fall through, not a special character:
// not a special character:
BOOST_FALLTHROUGH;
default:
put(*m_position);
++m_position;
@ -354,7 +355,7 @@ void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::format
case '{':
have_brace = true;
++m_position;
// fall through....
BOOST_FALLTHROUGH;
default:
// see if we have a number:
{
@ -1064,7 +1065,7 @@ struct format_functor_c_string
template <class OutputIter>
OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f, const Traits& t = Traits())
{
typedef typename Match::char_type char_type;
//typedef typename Match::char_type char_type;
const charT* end = func;
while(*end) ++end;
return regex_format_imp(i, m, func, end, f, t);
@ -1083,7 +1084,7 @@ struct format_functor_container
template <class OutputIter>
OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f, const Traits& t = Traits())
{
typedef typename Match::char_type char_type;
//typedef typename Match::char_type char_type;
return re_detail::regex_format_imp(i, m, func.begin(), func.end(), f, t);
}
private:

View File

@ -107,7 +107,7 @@ std::size_t regex_split(OutputIterator out,
std::size_t max_split)
{
typedef typename std::basic_string<charT, Traits1, Alloc1>::const_iterator ci_t;
typedef typename match_results<ci_t>::allocator_type match_allocator;
//typedef typename match_results<ci_t>::allocator_type match_allocator;
ci_t last = s.begin();
std::size_t init_size = max_split;
re_detail::split_pred<OutputIterator, charT, Traits1, Alloc1> pred(&last, &out, &max_split);