Improved error messages generated for thrown exceptions.

Suppressed "gcc -Wall -Wextra -pedantic" and "msvc /W4" warnings.
Updated and rebuilt docs.


[SVN r57451]
This commit is contained in:
John Maddock
2009-11-07 15:32:45 +00:00
parent 898b49fa89
commit 6e1f3dcceb
60 changed files with 662 additions and 436 deletions

View File

@ -752,7 +752,7 @@ template <class M>
struct functor1
{
typedef typename M::char_type char_type;
const char_type* operator()(const M& m)
const char_type* operator()(const M&)
{
static const char_type c = static_cast<char_type>(0);
return &c;
@ -762,7 +762,7 @@ template <class M>
struct functor1b
{
typedef typename M::char_type char_type;
std::vector<char_type> operator()(const M& m)
std::vector<char_type> operator()(const M&)
{
static const std::vector<char_type> c;
return c;

View File

@ -73,7 +73,9 @@ boost::shared_ptr<Object const> object_cache<Key, Object>::get(const Key& k, siz
// for now just throw, but we should never really get here...
//
::boost::throw_exception(std::runtime_error("Error in thread safety code: could not acquire a lock"));
#ifdef BOOST_NO_UNREACHABLE_RETURN_DETECTION
return boost::shared_ptr<Object>();
#endif
#else
return do_get(k, max_cache_size);
#endif

View File

@ -787,7 +787,7 @@ void basic_regex_creator<charT, traits>::fixup_recursions(re_syntax_base* state)
//
if(0 == (this->flags() & regex_constants::no_except))
{
std::string message = this->m_pdata->m_ptraits->error_string(boost::regex_constants::error_bad_pattern);
std::string message = "Encountered a forward reference to a marked sub-expression that does not exist.";
boost::regex_error e(message, boost::regex_constants::error_bad_pattern, 0);
e.raise();
}
@ -828,7 +828,7 @@ void basic_regex_creator<charT, traits>::fixup_recursions(re_syntax_base* state)
//
if(0 == (this->flags() & regex_constants::no_except))
{
std::string message = this->m_pdata->m_ptraits->error_string(boost::regex_constants::error_bad_pattern);
std::string message = "Encountered a forward reference to a recursive sub-expression that does not exist.";
boost::regex_error e(message, boost::regex_constants::error_bad_pattern, 0);
e.raise();
}
@ -893,7 +893,7 @@ void basic_regex_creator<charT, traits>::create_startmaps(re_syntax_base* state)
//
if(0 == (this->flags() & regex_constants::no_except))
{
std::string message = this->m_pdata->m_ptraits->error_string(boost::regex_constants::error_bad_pattern);
std::string message = "Invalid lookbehind assertion encountered in the regular expression.";
boost::regex_error e(message, boost::regex_constants::error_bad_pattern, 0);
e.raise();
}

View File

@ -45,6 +45,11 @@ public:
basic_regex_parser(regex_data<charT, traits>* data);
void parse(const charT* p1, const charT* p2, unsigned flags);
void fail(regex_constants::error_type error_code, std::ptrdiff_t position);
void fail(regex_constants::error_type error_code, std::ptrdiff_t position, std::string message, std::ptrdiff_t start_pos);
void fail(regex_constants::error_type error_code, std::ptrdiff_t position, const std::string& message)
{
fail(error_code, position, message, position);
}
bool parse_all();
bool parse_basic();
@ -144,7 +149,7 @@ void basic_regex_parser<charT, traits>::parse(const charT* p1, const charT* p2,
default:
// Ooops, someone has managed to set more than one of the main option flags,
// so this must be an error:
fail(regex_constants::error_unknown, 0);
fail(regex_constants::error_unknown, 0, "An invalid combination of regular expression syntax flags was used.");
return;
}
@ -160,7 +165,7 @@ void basic_regex_parser<charT, traits>::parse(const charT* p1, const charT* p2,
// have had an unexpected ')' :
if(!result)
{
fail(regex_constants::error_paren, ::boost::re_detail::distance(m_base, m_position));
fail(regex_constants::error_paren, ::boost::re_detail::distance(m_base, m_position), "Found a closing ) with no corresponding openening parenthesis.");
return;
}
// if an error has been set then give up now:
@ -173,13 +178,40 @@ void basic_regex_parser<charT, traits>::parse(const charT* p1, const charT* p2,
template <class charT, class traits>
void basic_regex_parser<charT, traits>::fail(regex_constants::error_type error_code, std::ptrdiff_t position)
{
// get the error message:
std::string message = this->m_pdata->m_ptraits->error_string(error_code);
fail(error_code, position, message);
}
template <class charT, class traits>
void basic_regex_parser<charT, traits>::fail(regex_constants::error_type error_code, std::ptrdiff_t position, std::string message, std::ptrdiff_t start_pos)
{
if(0 == this->m_pdata->m_status) // update the error code if not already set
this->m_pdata->m_status = error_code;
m_position = m_end; // don't bother parsing anything else
// get the error message:
std::string message = this->m_pdata->m_ptraits->error_string(error_code);
// and raise the exception, this will do nothing if exceptions are disabled:
//
// Augment error message with the regular expression text:
//
if(start_pos == position)
start_pos = (std::max)(static_cast<std::ptrdiff_t>(0), position - 10);
std::ptrdiff_t end_pos = (std::min)(position + 10, m_end - m_base);
if(error_code != regex_constants::error_empty)
{
if((start_pos != 0) || (end_pos != (m_end - m_base)))
message += " The error occured while parsing the regular expression fragment: '";
else
message += " The error occured while parsing the regular expression: '";
if(start_pos != end_pos)
{
message += std::string(m_base + start_pos, m_base + position);
message += ">>>HERE>>>";
message += std::string(m_base + position, m_base + end_pos);
}
message += "'.";
}
#ifndef BOOST_NO_EXCEPTIONS
if(0 == (this->flags() & regex_constants::no_except))
{
@ -287,7 +319,7 @@ bool basic_regex_parser<charT, traits>::parse_extended()
case regex_constants::syntax_star:
if(m_position == this->m_base)
{
fail(regex_constants::error_badrepeat, 0);
fail(regex_constants::error_badrepeat, 0, "The repeat operator \"*\" cannot start a regular expression.");
return false;
}
++m_position;
@ -295,7 +327,7 @@ bool basic_regex_parser<charT, traits>::parse_extended()
case regex_constants::syntax_question:
if(m_position == this->m_base)
{
fail(regex_constants::error_badrepeat, 0);
fail(regex_constants::error_badrepeat, 0, "The repeat operator \"?\" cannot start a regular expression.");
return false;
}
++m_position;
@ -303,7 +335,7 @@ bool basic_regex_parser<charT, traits>::parse_extended()
case regex_constants::syntax_plus:
if(m_position == this->m_base)
{
fail(regex_constants::error_badrepeat, 0);
fail(regex_constants::error_badrepeat, 0, "The repeat operator \"+\" cannot start a regular expression.");
return false;
}
++m_position;
@ -312,7 +344,7 @@ bool basic_regex_parser<charT, traits>::parse_extended()
++m_position;
return parse_repeat_range(false);
case regex_constants::syntax_close_brace:
fail(regex_constants::error_brace, this->m_position - this->m_end);
fail(regex_constants::error_brace, this->m_position - this->m_base, "Found a closing repetition operator } with no corresponding {.");
return false;
case regex_constants::syntax_or:
return parse_alt();
@ -517,7 +549,7 @@ bool basic_regex_parser<charT, traits>::parse_basic_escape()
case regex_constants::syntax_close_brace:
if(this->flags() & regbase::no_intervals)
return parse_literal();
fail(regex_constants::error_brace, this->m_position - this->m_base);
fail(regex_constants::error_brace, this->m_position - this->m_base, "Found a closing repetition operator } with no corresponding {.");
return false;
case regex_constants::syntax_or:
if(this->flags() & regbase::bk_vbar)
@ -612,7 +644,7 @@ bool basic_regex_parser<charT, traits>::parse_basic_escape()
case 'c':
case 'C':
// not supported yet:
fail(regex_constants::error_escape, m_position - m_base);
fail(regex_constants::error_escape, m_position - m_base, "The \\c and \\C escape sequences are not supported by POSIX basic regular expressions: try the Perl syntax instead.");
return false;
default:
break;
@ -710,7 +742,7 @@ escape_type_class_jump:
char_class_type m;
if(m_position == m_end)
{
fail(regex_constants::error_escape, m_position - m_base);
fail(regex_constants::error_escape, m_position - m_base, "Incomplete property escape found.");
return false;
}
// maybe have \p{ddd}
@ -722,7 +754,7 @@ escape_type_class_jump:
++m_position;
if(m_position == m_end)
{
fail(regex_constants::error_escape, m_position - m_base);
fail(regex_constants::error_escape, m_position - m_base, "Closing } missing from property escape sequence.");
return false;
}
m = this->m_traits.lookup_classname(++base, m_position++);
@ -745,7 +777,7 @@ escape_type_class_jump:
}
return true;
}
fail(regex_constants::error_ctype, m_position - m_base);
fail(regex_constants::error_ctype, m_position - m_base, "Escape sequence was neither a valid property nor a valid character class name.");
return false;
}
case regex_constants::escape_type_reset_start_mark:
@ -781,9 +813,10 @@ escape_type_class_jump:
{
bool have_brace = false;
bool negative = false;
static const char* incomplete_message = "Incomplete \\g escape found.";
if(++m_position == m_end)
{
fail(regex_constants::error_escape, m_position - m_base);
fail(regex_constants::error_escape, m_position - m_base, incomplete_message);
return false;
}
// maybe have \g{ddd}
@ -791,7 +824,7 @@ escape_type_class_jump:
{
if(++m_position == m_end)
{
fail(regex_constants::error_escape, m_position - m_base);
fail(regex_constants::error_escape, m_position - m_base, incomplete_message);
return false;
}
have_brace = true;
@ -799,7 +832,7 @@ escape_type_class_jump:
negative = (*m_position == static_cast<charT>('-'));
if((negative) && (++m_position == m_end))
{
fail(regex_constants::error_escape, m_position - m_base);
fail(regex_constants::error_escape, m_position - m_base, incomplete_message);
return false;
}
const charT* pc = m_position;
@ -824,7 +857,7 @@ escape_type_class_jump:
}
else
{
fail(regex_constants::error_backref, m_position - m_end);
fail(regex_constants::error_backref, m_position - m_base);
return false;
}
m_position = pc;
@ -832,7 +865,7 @@ escape_type_class_jump:
{
if((m_position == m_end) || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_brace))
{
fail(regex_constants::error_escape, m_position - m_base);
fail(regex_constants::error_escape, m_position - m_base, incomplete_message);
return false;
}
++m_position;
@ -899,7 +932,7 @@ bool basic_regex_parser<charT, traits>::parse_repeat(std::size_t low, std::size_
}
if(0 == this->m_last_state)
{
fail(regex_constants::error_badrepeat, ::boost::re_detail::distance(m_base, m_position));
fail(regex_constants::error_badrepeat, ::boost::re_detail::distance(m_base, m_position), "Nothing to repeat.");
return false;
}
if(this->m_last_state->type == syntax_element_endmark)
@ -986,6 +1019,7 @@ bool basic_regex_parser<charT, traits>::parse_repeat(std::size_t low, std::size_
template <class charT, class traits>
bool basic_regex_parser<charT, traits>::parse_repeat_range(bool isbasic)
{
static const char* incomplete_message = "Missing } in quantified repetition.";
//
// parse a repeat-range:
//
@ -997,7 +1031,7 @@ bool basic_regex_parser<charT, traits>::parse_repeat_range(bool isbasic)
// fail if at end:
if(this->m_position == this->m_end)
{
fail(regex_constants::error_brace, this->m_position - this->m_base);
fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message);
return false;
}
// get min:
@ -1012,7 +1046,7 @@ bool basic_regex_parser<charT, traits>::parse_repeat_range(bool isbasic)
}
else if(this->m_position == this->m_end)
{
fail(regex_constants::error_brace, this->m_position - this->m_base);
fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message);
return false;
}
min = v;
@ -1026,7 +1060,7 @@ 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);
fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message);
return false;
}
// get the value if any:
@ -1044,7 +1078,7 @@ 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);
fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message);
return false;
}
if(isbasic)
@ -1054,13 +1088,13 @@ 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);
fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message);
return false;
}
}
else
{
fail(regex_constants::error_badbrace, this->m_position - this->m_base);
fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message);
return false;
}
}
@ -1068,7 +1102,7 @@ bool basic_regex_parser<charT, traits>::parse_repeat_range(bool isbasic)
++m_position;
else
{
fail(regex_constants::error_badbrace, this->m_position - this->m_base);
fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message);
return false;
}
//
@ -1076,7 +1110,11 @@ bool basic_regex_parser<charT, traits>::parse_repeat_range(bool isbasic)
//
if(min > max)
{
fail(regex_constants::error_badbrace, this->m_position - this->m_base);
// Backtrack to error location:
m_position -= 2;
while(this->m_traits.isctype(*m_position, this->m_word_mask)) --m_position;
++m_position;
fail(regex_constants::error_badbrace, m_position - m_base);
return false;
}
return parse_repeat(min, max);
@ -1099,7 +1137,7 @@ bool basic_regex_parser<charT, traits>::parse_alt()
)
)
{
fail(regex_constants::error_empty, this->m_position - this->m_base);
fail(regex_constants::error_empty, this->m_position - this->m_base, "A regular expression can start with the alternation operator |.");
return false;
}
//
@ -1151,10 +1189,11 @@ bool basic_regex_parser<charT, traits>::parse_alt()
template <class charT, class traits>
bool basic_regex_parser<charT, traits>::parse_set()
{
static const char* incomplete_message = "Character set declaration starting with [ terminated prematurely - either no ] was found or the set had no content.";
++m_position;
if(m_position == m_end)
{
fail(regex_constants::error_brack, m_position - m_base);
fail(regex_constants::error_brack, m_position - m_base, incomplete_message);
return false;
}
basic_char_set<charT, traits> char_set;
@ -1187,7 +1226,7 @@ bool basic_regex_parser<charT, traits>::parse_set()
++m_position;
if(0 == this->append_set(char_set))
{
fail(regex_constants::error_range, m_position - m_base);
fail(regex_constants::error_ctype, m_position - m_base);
return false;
}
}
@ -1242,6 +1281,7 @@ bool basic_regex_parser<charT, traits>::parse_set()
template <class charT, class traits>
bool basic_regex_parser<charT, traits>::parse_inner_set(basic_char_set<charT, traits>& char_set)
{
static const char* incomplete_message = "Character class declaration starting with [ terminated prematurely - either no ] was found or the set had no content.";
//
// we have either a character class [:name:]
// a collating element [.name.]
@ -1249,7 +1289,7 @@ bool basic_regex_parser<charT, traits>::parse_inner_set(basic_char_set<charT, tr
//
if(m_end == ++m_position)
{
fail(regex_constants::error_brack, m_position - m_base);
fail(regex_constants::error_brack, m_position - m_base, incomplete_message);
return false;
}
switch(this->m_traits.syntax_type(*m_position))
@ -1274,14 +1314,14 @@ bool basic_regex_parser<charT, traits>::parse_inner_set(basic_char_set<charT, tr
// skip the ':'
if(m_end == ++m_position)
{
fail(regex_constants::error_brack, m_position - m_base);
fail(regex_constants::error_brack, m_position - m_base, incomplete_message);
return false;
}
const charT* name_first = m_position;
// skip at least one character, then find the matching ':]'
if(m_end == ++m_position)
{
fail(regex_constants::error_brack, m_position - m_base);
fail(regex_constants::error_brack, m_position - m_base, incomplete_message);
return false;
}
while((m_position != m_end)
@ -1290,13 +1330,13 @@ bool basic_regex_parser<charT, traits>::parse_inner_set(basic_char_set<charT, tr
const charT* name_last = m_position;
if(m_end == m_position)
{
fail(regex_constants::error_brack, m_position - m_base);
fail(regex_constants::error_brack, m_position - m_base, incomplete_message);
return false;
}
if((m_end == ++m_position)
|| (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_set))
{
fail(regex_constants::error_brack, m_position - m_base);
fail(regex_constants::error_brack, m_position - m_base, incomplete_message);
return false;
}
//
@ -1351,14 +1391,14 @@ bool basic_regex_parser<charT, traits>::parse_inner_set(basic_char_set<charT, tr
// skip the '='
if(m_end == ++m_position)
{
fail(regex_constants::error_brack, m_position - m_base);
fail(regex_constants::error_brack, m_position - m_base, incomplete_message);
return false;
}
const charT* name_first = m_position;
// skip at least one character, then find the matching '=]'
if(m_end == ++m_position)
{
fail(regex_constants::error_brack, m_position - m_base);
fail(regex_constants::error_brack, m_position - m_base, incomplete_message);
return false;
}
while((m_position != m_end)
@ -1367,13 +1407,13 @@ bool basic_regex_parser<charT, traits>::parse_inner_set(basic_char_set<charT, tr
const charT* name_last = m_position;
if(m_end == m_position)
{
fail(regex_constants::error_brack, m_position - m_base);
fail(regex_constants::error_brack, m_position - m_base, incomplete_message);
return false;
}
if((m_end == ++m_position)
|| (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_set))
{
fail(regex_constants::error_brack, m_position - m_base);
fail(regex_constants::error_brack, m_position - m_base, incomplete_message);
return false;
}
string_type m = this->m_traits.lookup_collatename(name_first, name_last);
@ -1563,7 +1603,7 @@ charT basic_regex_parser<charT, traits>::unescape_character()
charT result(0);
if(m_position == m_end)
{
fail(regex_constants::error_escape, m_position - m_base);
fail(regex_constants::error_escape, m_position - m_base, "Escape sequence terminated prematurely.");
return false;
}
switch(this->m_traits.escape_syntax_type(*m_position))
@ -1596,24 +1636,22 @@ charT basic_regex_parser<charT, traits>::unescape_character()
++m_position;
if(m_position == m_end)
{
fail(regex_constants::error_escape, m_position - m_base);
// Rewind to start of escape:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position;
fail(regex_constants::error_escape, m_position - m_base, "ASCII escape sequence terminated prematurely.");
return result;
}
/*
if((*m_position < charT('@'))
|| (*m_position > charT(125)) )
{
fail(regex_constants::error_escape, m_position - m_base);
return result;
}
*/
result = static_cast<charT>(*m_position % 32);
break;
case regex_constants::escape_type_hex:
++m_position;
if(m_position == m_end)
{
fail(regex_constants::error_escape, m_position - m_base);
// Rewind to start of escape:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position;
fail(regex_constants::error_escape, m_position - m_base, "Hexadecimal escape sequence terminated prematurely.");
return result;
}
// maybe have \x{ddd}
@ -1622,7 +1660,10 @@ charT basic_regex_parser<charT, traits>::unescape_character()
++m_position;
if(m_position == m_end)
{
fail(regex_constants::error_escape, m_position - m_base);
// Rewind to start of escape:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position;
fail(regex_constants::error_escape, m_position - m_base, "Missing } in hexadecimal escape sequence.");
return result;
}
int i = this->m_traits.toi(m_position, m_end, 16);
@ -1631,7 +1672,10 @@ charT basic_regex_parser<charT, traits>::unescape_character()
|| ((std::numeric_limits<charT>::is_specialized) && (i > (int)(std::numeric_limits<charT>::max)()))
|| (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_brace))
{
fail(regex_constants::error_badbrace, m_position - m_base);
// Rewind to start of escape:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position;
fail(regex_constants::error_badbrace, m_position - m_base, "Hexadecimal escape sequence was invalid.");
return result;
}
++m_position;
@ -1644,7 +1688,10 @@ charT basic_regex_parser<charT, traits>::unescape_character()
if((i < 0)
|| !valid_value(charT(0), i))
{
fail(regex_constants::error_escape, m_position - m_base);
// Rewind to start of escape:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position;
fail(regex_constants::error_escape, m_position - m_base, "Escape sequence did not encode a valid character.");
return result;
}
result = charT(i);
@ -1659,14 +1706,20 @@ charT basic_regex_parser<charT, traits>::unescape_character()
int val = this->m_traits.toi(bp, bp + 1, 8);
if(val != 0)
{
// Rewind to start of escape:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position;
// Oops not an octal escape after all:
fail(regex_constants::error_escape, m_position - m_base);
fail(regex_constants::error_escape, m_position - m_base, "Invalid octal escape sequence.");
return result;
}
val = this->m_traits.toi(m_position, m_position + len, 8);
if(val < 0)
{
fail(regex_constants::error_escape, m_position - m_base);
// Rewind to start of escape:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position;
fail(regex_constants::error_escape, m_position - m_base, "Octal escape sequence is invalid.");
return result;
}
return static_cast<charT>(val);
@ -1676,6 +1729,9 @@ charT basic_regex_parser<charT, traits>::unescape_character()
++m_position;
if(m_position == m_end)
{
// Rewind to start of escape:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position;
fail(regex_constants::error_escape, m_position - m_base);
return false;
}
@ -1688,12 +1744,18 @@ charT basic_regex_parser<charT, traits>::unescape_character()
++m_position;
if(m_position == m_end)
{
// Rewind to start of escape:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position;
fail(regex_constants::error_escape, m_position - m_base);
return false;
}
string_type s = this->m_traits.lookup_collatename(++base, m_position++);
if(s.empty())
{
// Rewind to start of escape:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position;
fail(regex_constants::error_collate, m_position - m_base);
return false;
}
@ -1703,6 +1765,9 @@ charT basic_regex_parser<charT, traits>::unescape_character()
}
}
// fall through is a failure:
// Rewind to start of escape:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position;
fail(regex_constants::error_escape, m_position - m_base);
return false;
}
@ -1738,7 +1803,10 @@ bool basic_regex_parser<charT, traits>::parse_backref()
}
else
{
fail(regex_constants::error_backref, m_position - m_end);
// Rewind to start of escape:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position;
fail(regex_constants::error_backref, m_position - m_base);
return false;
}
return true;
@ -1770,7 +1838,7 @@ bool basic_regex_parser<charT, traits>::parse_QE()
}
if(++m_position == m_end) // skip the escape
{
fail(regex_constants::error_escape, m_position - m_base);
fail(regex_constants::error_escape, m_position - m_base, "Unterminated \\Q...\\E sequence.");
return false;
}
// check to see if it's a \E:
@ -1801,7 +1869,10 @@ bool basic_regex_parser<charT, traits>::parse_perl_extension()
{
if(++m_position == m_end)
{
fail(regex_constants::error_badrepeat, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
//
@ -1860,7 +1931,10 @@ bool basic_regex_parser<charT, traits>::parse_perl_extension()
v = this->m_traits.toi(m_position, m_end, 10);
if((v < 0) || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark))
{
fail(regex_constants::error_backref, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base, "The recursive sub-expression refers to an invalid marking group, or is unterminated.");
return false;
}
insert_recursion:
@ -1879,7 +1953,10 @@ insert_recursion:
v = this->m_traits.toi(m_position, m_end, 10);
if((v <= 0) || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark))
{
fail(regex_constants::error_backref, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base, "An invalid or unterminated recursive sub-expression.");
return false;
}
v += m_mark_count;
@ -1899,7 +1976,10 @@ insert_recursion:
v = m_mark_count + 1 - v;
if(v <= 0)
{
fail(regex_constants::error_backref, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base, "An invalid or unterminated recursive sub-expression.");
return false;
}
goto insert_recursion;
@ -1922,7 +2002,10 @@ insert_recursion:
// a lookbehind assertion:
if(++m_position == m_end)
{
fail(regex_constants::error_badrepeat, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
regex_constants::syntax_type t = this->m_traits.syntax_type(*m_position);
@ -1960,7 +2043,10 @@ insert_recursion:
pb->index = markid = -4;
if(++m_position == m_end)
{
fail(regex_constants::error_badrepeat, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
int v = this->m_traits.toi(m_position, m_end, 10);
@ -1968,7 +2054,10 @@ insert_recursion:
{
if(++m_position == m_end)
{
fail(regex_constants::error_badrepeat, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
if(*m_position == charT('&'))
@ -1978,7 +2067,10 @@ insert_recursion:
++m_position;
if(m_position == m_end)
{
fail(regex_constants::error_badrepeat, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
v = -static_cast<int>(hash_value_from_capture_name(base, m_position));
@ -1991,12 +2083,18 @@ insert_recursion:
br->index = v < 0 ? (v - 1) : 0;
if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark)
{
fail(regex_constants::error_badrepeat, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
if(++m_position == m_end)
{
fail(regex_constants::error_badrepeat, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
}
@ -2007,7 +2105,10 @@ insert_recursion:
++m_position;
if(m_position == m_end)
{
fail(regex_constants::error_badrepeat, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
v = static_cast<int>(hash_value_from_capture_name(base, m_position));
@ -2015,17 +2116,26 @@ insert_recursion:
br->index = v;
if(((*m_position != charT('>')) && (*m_position != charT('\''))) || (++m_position == m_end))
{
fail(regex_constants::error_badrepeat, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base, "Unterminated named capture.");
return false;
}
if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark)
{
fail(regex_constants::error_badrepeat, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
if(++m_position == m_end)
{
fail(regex_constants::error_badrepeat, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
}
@ -2036,19 +2146,28 @@ insert_recursion:
++m_position, ++def;
if((m_position == m_end) || *def)
{
fail(regex_constants::error_badrepeat, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
re_brace* br = static_cast<re_brace*>(this->append_state(syntax_element_assert_backref, sizeof(re_brace)));
br->index = 9999; // special magic value!
if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark)
{
fail(regex_constants::error_badrepeat, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
if(++m_position == m_end)
{
fail(regex_constants::error_badrepeat, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
}
@ -2058,12 +2177,18 @@ insert_recursion:
br->index = v;
if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark)
{
fail(regex_constants::error_badrepeat, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
if(++m_position == m_end)
{
fail(regex_constants::error_badrepeat, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
}
@ -2072,25 +2197,37 @@ insert_recursion:
// verify that we have a lookahead or lookbehind assert:
if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_question)
{
fail(regex_constants::error_badrepeat, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
if(++m_position == m_end)
{
fail(regex_constants::error_badrepeat, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
if(this->m_traits.syntax_type(*m_position) == regex_constants::escape_type_left_word)
{
if(++m_position == m_end)
{
fail(regex_constants::error_badrepeat, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
if((this->m_traits.syntax_type(*m_position) != regex_constants::syntax_equal)
&& (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_not))
{
fail(regex_constants::error_badrepeat, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
m_position -= 3;
@ -2100,7 +2237,10 @@ insert_recursion:
if((this->m_traits.syntax_type(*m_position) != regex_constants::syntax_equal)
&& (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_not))
{
fail(regex_constants::error_paren, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
m_position -= 2;
@ -2109,7 +2249,10 @@ insert_recursion:
break;
}
case regex_constants::syntax_close_mark:
fail(regex_constants::error_badrepeat, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
case regex_constants::escape_type_end_buffer:
{
@ -2131,14 +2274,20 @@ named_capture_jump:
const charT* base = ++m_position;
if(m_position == m_end)
{
fail(regex_constants::error_paren, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
while((m_position != m_end) && (*m_position != name_delim))
++m_position;
if(m_position == m_end)
{
fail(regex_constants::error_paren, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
this->m_pdata->set_name(base, m_position, markid);
@ -2152,7 +2301,10 @@ named_capture_jump:
v = 0;
if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark)
{
fail(regex_constants::error_backref, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
goto insert_recursion;
@ -2165,7 +2317,10 @@ named_capture_jump:
++m_position;
if(m_position == m_end)
{
fail(regex_constants::error_backref, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
v = static_cast<int>(hash_value_from_capture_name(base, m_position));
@ -2176,7 +2331,10 @@ named_capture_jump:
++m_position;
if(m_position == m_end)
{
fail(regex_constants::error_backref, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
if(*m_position == charT('>'))
@ -2187,7 +2345,10 @@ named_capture_jump:
++m_position;
if(m_position == m_end)
{
fail(regex_constants::error_backref, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
v = static_cast<int>(hash_value_from_capture_name(base, m_position));
@ -2200,7 +2361,13 @@ named_capture_jump:
option_group_jump:
regex_constants::syntax_option_type opts = parse_options();
if(m_position == m_end)
{
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
// make a note of whether we have a case change:
m_has_case_change = ((opts & regbase::icase) != (this->flags() & regbase::icase));
pb->index = markid = 0;
@ -2219,7 +2386,10 @@ option_group_jump:
}
else
{
fail(regex_constants::error_badrepeat, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
@ -2241,12 +2411,21 @@ option_group_jump:
// Unwind alternatives:
//
if(0 == unwind_alts(last_paren_start))
{
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base, "Invalid alternation operators within (?...) block.");
return false;
}
//
// we either have a ')' or we have run out of characters prematurely:
//
if(m_position == m_end)
{
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
this->fail(regex_constants::error_paren, ::boost::re_detail::distance(m_base, m_end));
return false;
}
@ -2277,7 +2456,10 @@ option_group_jump:
if(this->m_last_state == jmp)
{
// Oops... we didn't have anything inside the assertion:
fail(regex_constants::error_empty, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base, "Invalid or empty zero width assertion.");
return false;
}
}
@ -2297,7 +2479,10 @@ option_group_jump:
else if(this->getaddress(static_cast<re_alt*>(b)->alt.i, b)->type == syntax_element_alt)
{
// Can't have seen more than one alternative:
fail(regex_constants::error_bad_pattern, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_bad_pattern, m_position - m_base, "More than one alternation operator | was encountered inside a conditional expression.");
return false;
}
else
@ -2306,7 +2491,10 @@ option_group_jump:
b = this->getaddress(b->next.i, b);
if((b->type == syntax_element_assert_backref) && (static_cast<re_brace*>(b)->index == 9999))
{
fail(regex_constants::error_bad_pattern, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_bad_pattern, m_position - m_base, "Alternation operators are not allowed inside a DEFINE block.");
return false;
}
}
@ -2316,7 +2504,10 @@ option_group_jump:
if((b->type != syntax_element_assert_backref)
&& (b->type != syntax_element_startmark))
{
fail(regex_constants::error_badrepeat, m_position - m_base);
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_badrepeat, m_position - m_base, "A repetition operator cannot be applied to a zero-width assertion.");
return false;
}
}
@ -2371,6 +2562,9 @@ bool basic_regex_parser<charT, traits>::add_emacs_code(bool negate)
//
if(++m_position == m_end)
{
// Rewind to start of sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position;
fail(regex_constants::error_escape, m_position - m_base);
return false;
}
@ -2471,6 +2665,9 @@ regex_constants::syntax_option_type basic_regex_parser<charT, traits>::parse_opt
}
if(++m_position == m_end)
{
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_paren, m_position - m_base);
return false;
}
@ -2481,6 +2678,9 @@ regex_constants::syntax_option_type basic_regex_parser<charT, traits>::parse_opt
{
if(++m_position == m_end)
{
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_paren, m_position - m_base);
return false;
}
@ -2507,6 +2707,9 @@ regex_constants::syntax_option_type basic_regex_parser<charT, traits>::parse_opt
}
if(++m_position == m_end)
{
// Rewind to start of (? sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_paren, m_position - m_base);
return false;
}
@ -2533,7 +2736,7 @@ bool basic_regex_parser<charT, traits>::unwind_alts(std::ptrdiff_t last_paren_st
)
)
{
fail(regex_constants::error_empty, this->m_position - this->m_base);
fail(regex_constants::error_empty, this->m_position - this->m_base, "Can't terminate a sub-expression with an alternation operator |.");
return false;
}
//

View File

@ -124,11 +124,11 @@ typedef enum{
REG_STARTEND = 00004
} reg_exec_flags;
//
// POSIX error codes:
//
/*
* POSIX error codes:
*/
typedef unsigned reg_error_t;
typedef reg_error_t reg_errcode_t; // backwards compatibility
typedef reg_error_t reg_errcode_t; /* backwards compatibility */
static const reg_error_t REG_NOERROR = 0; /* Success. */
static const reg_error_t REG_NOMATCH = 1; /* Didn't find a match (for regexec). */
@ -154,8 +154,9 @@ static const reg_error_t REG_EMPTY = 17; /* empty expression */
static const reg_error_t REG_E_MEMORY = 15; /* = REG_ESIZE : out of memory */
static const reg_error_t REG_ECOMPLEXITY = 18; /* complexity too high */
static const reg_error_t REG_ESTACK = 19; /* out of stack space */
static const reg_error_t REG_E_UNKNOWN = 20; /* unknown error */
static const reg_error_t REG_ENOSYS = 20; /* = REG_E_UNKNOWN : Reserved. */
static const reg_error_t REG_E_PERL = 20; /* Perl (?...) error */
static const reg_error_t REG_E_UNKNOWN = 21; /* unknown error */
static const reg_error_t REG_ENOSYS = 21; /* = REG_E_UNKNOWN : Reserved. */
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA*, const char*, int);
BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int, const regex_tA*, char*, regsize_t);
@ -195,14 +196,14 @@ BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeW(regex_tW*);
#endif
#ifdef __cplusplus
} // extern "C"
} // namespace
} /* extern "C" */
} /* namespace */
#endif
//
// C++ high level wrapper goes here:
//
#if defined(__cplusplus)
/*
* C++ high level wrapper goes here:
*/
#include <string>
#include <vector>
namespace boost{
@ -228,7 +229,7 @@ struct pred2;
struct pred3;
struct pred4;
} // namespace re_detail
} /* namespace re_detail */
#if (defined(BOOST_MSVC) || defined(__BORLANDC__)) && !defined(BOOST_DISABLE_WIN32)
typedef bool (__cdecl *GrepCallback)(const RegEx& expression);
@ -257,9 +258,9 @@ public:
unsigned int SetExpression(const std::string& s, bool icase = false){ return SetExpression(s.c_str(), icase); }
std::string Expression()const;
unsigned int error_code()const;
//
// now matching operators:
//
/*
* now matching operators:
*/
bool Match(const char* p, match_flag_type flags = match_default);
bool Match(const std::string& s, match_flag_type flags = match_default) { return Match(s.c_str(), flags); }
bool Search(const char* p, match_flag_type flags = match_default);
@ -283,9 +284,9 @@ public:
bool copy = true, match_flag_type flags = match_default);
std::size_t Split(std::vector<std::string>& v, std::string& s, match_flag_type flags = match_default, unsigned max_count = ~0);
//
// now operators for returning what matched in more detail:
//
/*
* now operators for returning what matched in more detail:
*/
std::size_t Position(int i = 0)const;
std::size_t Length(int i = 0)const;
bool Matched(int i = 0)const;
@ -312,11 +313,11 @@ public:
#pragma warning(pop)
#endif
} // namespace boost
} /* namespace boost */
#endif
#endif /* __cplusplus */
#endif // include guard
#endif /* include guard */

View File

@ -28,8 +28,8 @@ namespace regex_constants{
enum error_type{
error_ok = 0, // not used
error_no_match = 1, // not used
error_ok = 0, /* not used */
error_no_match = 1, /* not used */
error_bad_pattern = 2,
error_collate = 3,
error_ctype = 4,
@ -42,17 +42,18 @@ enum error_type{
error_range = 11,
error_space = 12,
error_badrepeat = 13,
error_end = 14, // not used
error_end = 14, /* not used */
error_size = 15,
error_right_paren = 16, // not used
error_right_paren = 16, /* not used */
error_empty = 17,
error_complexity = 18,
error_stack = 19,
error_unknown = 20
error_perl_extension = 20,
error_unknown = 21
};
}
}
#endif // __cplusplus
#endif /* __cplusplus */
#endif

View File

@ -31,43 +31,43 @@ namespace boost{
typedef enum _match_flags
{
match_default = 0,
match_not_bol = 1, // first is not start of line
match_not_eol = match_not_bol << 1, // last is not end of line
match_not_bob = match_not_eol << 1, // first is not start of buffer
match_not_eob = match_not_bob << 1, // last is not end of buffer
match_not_bow = match_not_eob << 1, // first is not start of word
match_not_eow = match_not_bow << 1, // last is not end of word
match_not_dot_newline = match_not_eow << 1, // \n is not matched by '.'
match_not_dot_null = match_not_dot_newline << 1, // '\0' is not matched by '.'
match_prev_avail = match_not_dot_null << 1, // *--first is a valid expression
match_init = match_prev_avail << 1, // internal use
match_any = match_init << 1, // don't care what we match
match_not_null = match_any << 1, // string can't be null
match_continuous = match_not_null << 1, // each grep match must continue from
// uninterupted from the previous one
match_partial = match_continuous << 1, // find partial matches
match_not_bol = 1, /* first is not start of line */
match_not_eol = match_not_bol << 1, /* last is not end of line */
match_not_bob = match_not_eol << 1, /* first is not start of buffer */
match_not_eob = match_not_bob << 1, /* last is not end of buffer */
match_not_bow = match_not_eob << 1, /* first is not start of word */
match_not_eow = match_not_bow << 1, /* last is not end of word */
match_not_dot_newline = match_not_eow << 1, /* \n is not matched by '.' */
match_not_dot_null = match_not_dot_newline << 1, /* '\0' is not matched by '.' */
match_prev_avail = match_not_dot_null << 1, /* *--first is a valid expression */
match_init = match_prev_avail << 1, /* internal use */
match_any = match_init << 1, /* don't care what we match */
match_not_null = match_any << 1, /* string can't be null */
match_continuous = match_not_null << 1, /* each grep match must continue from */
/* uninterupted from the previous one */
match_partial = match_continuous << 1, /* find partial matches */
match_stop = match_partial << 1, // stop after first match (grep) V3 only
match_not_initial_null = match_stop, // don't match initial null, V4 only
match_all = match_stop << 1, // must find the whole of input even if match_any is set
match_perl = match_all << 1, // Use perl matching rules
match_posix = match_perl << 1, // Use POSIX matching rules
match_nosubs = match_posix << 1, // don't trap marked subs
match_extra = match_nosubs << 1, // include full capture information for repeated captures
match_single_line = match_extra << 1, // treat text as single line and ignor any \n's when matching ^ and $.
match_unused1 = match_single_line << 1, // unused
match_unused2 = match_unused1 << 1, // unused
match_unused3 = match_unused2 << 1, // unused
match_stop = match_partial << 1, /* stop after first match (grep) V3 only */
match_not_initial_null = match_stop, /* don't match initial null, V4 only */
match_all = match_stop << 1, /* must find the whole of input even if match_any is set */
match_perl = match_all << 1, /* Use perl matching rules */
match_posix = match_perl << 1, /* Use POSIX matching rules */
match_nosubs = match_posix << 1, /* don't trap marked subs */
match_extra = match_nosubs << 1, /* include full capture information for repeated captures */
match_single_line = match_extra << 1, /* treat text as single line and ignor any \n's when matching ^ and $. */
match_unused1 = match_single_line << 1, /* unused */
match_unused2 = match_unused1 << 1, /* unused */
match_unused3 = match_unused2 << 1, /* unused */
match_max = match_unused3,
format_perl = 0, // perl style replacement
format_default = 0, // ditto.
format_sed = match_max << 1, // sed style replacement.
format_all = format_sed << 1, // enable all extentions to sytax.
format_no_copy = format_all << 1, // don't copy non-matching segments.
format_first_only = format_no_copy << 1, // Only replace first occurance.
format_is_if = format_first_only << 1, // internal use only.
format_literal = format_is_if << 1 // treat string as a literal
format_perl = 0, /* perl style replacement */
format_default = 0, /* ditto. */
format_sed = match_max << 1, /* sed style replacement. */
format_all = format_sed << 1, /* enable all extentions to sytax. */
format_no_copy = format_all << 1, /* don't copy non-matching segments. */
format_first_only = format_no_copy << 1, /* Only replace first occurance. */
format_is_if = format_first_only << 1, /* internal use only. */
format_literal = format_is_if << 1 /* treat string as a literal */
} match_flags;
@ -96,10 +96,10 @@ inline match_flags& operator^=(match_flags& m1, match_flags m2)
#endif
#ifdef __cplusplus
} // namespace regex_constants
//
// import names into boost for backwards compatiblity:
//
} /* namespace regex_constants */
/*
* import names into boost for backwards compatiblity:
*/
using regex_constants::match_flag_type;
using regex_constants::match_default;
using regex_constants::match_not_bol;
@ -111,28 +111,28 @@ using regex_constants::match_not_eow;
using regex_constants::match_not_dot_newline;
using regex_constants::match_not_dot_null;
using regex_constants::match_prev_avail;
//using regex_constants::match_init;
/* using regex_constants::match_init; */
using regex_constants::match_any;
using regex_constants::match_not_null;
using regex_constants::match_continuous;
using regex_constants::match_partial;
//using regex_constants::match_stop;
/*using regex_constants::match_stop; */
using regex_constants::match_all;
using regex_constants::match_perl;
using regex_constants::match_posix;
using regex_constants::match_nosubs;
using regex_constants::match_extra;
using regex_constants::match_single_line;
//using regex_constants::match_max;
/*using regex_constants::match_max; */
using regex_constants::format_all;
using regex_constants::format_sed;
using regex_constants::format_perl;
using regex_constants::format_default;
using regex_constants::format_no_copy;
using regex_constants::format_first_only;
//using regex_constants::format_is_if;
/*using regex_constants::format_is_if;*/
} // namespace boost
#endif // __cplusplus
#endif // include guard
} /* namespace boost */
#endif /* __cplusplus */
#endif /* include guard */

View File

@ -188,7 +188,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_all_states()
if(!(this->*proc)())
{
if(state_count > max_state_count)
raise_error(traits_inst, regex_constants::error_space);
raise_error(traits_inst, regex_constants::error_complexity);
if((m_match_flags & match_partial) && (position == last) && (position != search_base))
m_has_partial_match = true;
bool successful_unwind = unwind(false);
@ -219,7 +219,7 @@ void perl_matcher<BidiIterator, Allocator, traits>::extend_stack()
m_backup_state = block;
}
else
raise_error(traits_inst, regex_constants::error_size);
raise_error(traits_inst, regex_constants::error_stack);
}
template <class BidiIterator, class Allocator, class traits>

View File

@ -99,7 +99,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_all_states()
};
if(state_count > max_state_count)
raise_error(traits_inst, regex_constants::error_space);
raise_error(traits_inst, regex_constants::error_complexity);
while(pstate)
{
matcher_proc_type proc = s_match_vtable[pstate->type];

View File

@ -831,7 +831,7 @@ OutputIterator regex_format_imp(OutputIterator out,
#ifndef BOOST_NO_SFINAE
BOOST_MPL_HAS_XXX_TRAIT_DEF(const_iterator);
BOOST_MPL_HAS_XXX_TRAIT_DEF(const_iterator)
struct any_type { any_type(...); };
typedef char no_type;
@ -972,6 +972,8 @@ struct format_functor3
}
private:
Base func;
format_functor3(const format_functor3&);
format_functor3& operator=(const format_functor3&);
};
template <class Base, class Match>
@ -990,6 +992,8 @@ struct format_functor2
}
private:
Base func;
format_functor2(const format_functor2&);
format_functor2& operator=(const format_functor2&);
};
template <class Base, class Match>
@ -1025,6 +1029,8 @@ struct format_functor1
}
private:
Base func;
format_functor1(const format_functor1&);
format_functor1& operator=(const format_functor1&);
};
template <class charT, class Match, class Traits>
@ -1042,6 +1048,8 @@ struct format_functor_c_string
}
private:
const charT* func;
format_functor_c_string(const format_functor_c_string&);
format_functor_c_string& operator=(const format_functor_c_string&);
};
template <class Container, class Match, class Traits>
@ -1057,6 +1065,8 @@ struct format_functor_container
}
private:
const Container& func;
format_functor_container(const format_functor_container&);
format_functor_container& operator=(const format_functor_container&);
};
template <class Func, class Match, class OutputIterator, class Traits = re_detail::trivial_format_traits<typename Match::char_type> >

View File

@ -322,7 +322,7 @@ inline const charT* get_escape_R_string()
{
#ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning(disable:4309)
# pragma warning(disable:4309 4245)
#endif
static const charT e1[] = { '(', '?', '>', '\x0D', '\x0A', '?',
'|', '[', '\x0A', '\x0B', '\x0C', '\x85', '\\', 'x', '{', '2', '0', '2', '8', '}',