mirror of
https://github.com/boostorg/regex.git
synced 2025-07-15 21:32:18 +02:00
Updates for better partial match support, and to ensure that that the POSIX API functions are able to return the correct error code.
[SVN r9392]
This commit is contained in:
@ -103,21 +103,21 @@ template <class charT, class traits, class Allocator>
|
||||
CONSTRUCTOR_INLINE reg_expression<charT, traits, Allocator>::reg_expression(const charT* p, flag_type f, const Allocator& a)
|
||||
: data(a), pkmp(0), error_code_(REG_EMPTY)
|
||||
{
|
||||
set_expression(p, f);
|
||||
set_expression(p, f | regbase::use_except);
|
||||
}
|
||||
|
||||
template <class charT, class traits, class Allocator>
|
||||
CONSTRUCTOR_INLINE reg_expression<charT, traits, Allocator>::reg_expression(const charT* p1, const charT* p2, flag_type f, const Allocator& a)
|
||||
: data(a), pkmp(0), error_code_(REG_EMPTY)
|
||||
{
|
||||
set_expression(p1, p2, f);
|
||||
set_expression(p1, p2, f | regbase::use_except);
|
||||
}
|
||||
|
||||
template <class charT, class traits, class Allocator>
|
||||
CONSTRUCTOR_INLINE reg_expression<charT, traits, Allocator>::reg_expression(const charT* p, size_type len, flag_type f, const Allocator& a)
|
||||
: data(a), pkmp(0), error_code_(REG_EMPTY)
|
||||
{
|
||||
set_expression(p, p + len, f);
|
||||
set_expression(p, p + len, f | regbase::use_except);
|
||||
}
|
||||
|
||||
template <class charT, class traits, class Allocator>
|
||||
@ -130,10 +130,13 @@ reg_expression<charT, traits, Allocator>::reg_expression(const reg_expression<ch
|
||||
if(e.error_code() == 0)
|
||||
{
|
||||
const charT* pe = e.expression();
|
||||
set_expression(pe, pe + e._expression_len, e.flags());
|
||||
set_expression(pe, pe + e._expression_len, e.flags() | regbase::use_except);
|
||||
}
|
||||
else
|
||||
{
|
||||
_flags = regbase::use_except;
|
||||
fail(e.error_code());
|
||||
}
|
||||
}
|
||||
|
||||
template <class charT, class traits, class Allocator>
|
||||
@ -153,7 +156,7 @@ reg_expression<charT, traits, Allocator>& BOOST_RE_CALL reg_expression<charT, tr
|
||||
_flags = use_except;
|
||||
fail(e.error_code());
|
||||
if(error_code() == 0)
|
||||
set_expression(e._expression, e._expression + e._expression_len, e.flags());
|
||||
set_expression(e._expression, e._expression + e._expression_len, e.flags() | regbase::use_except);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -2005,7 +2008,15 @@ void BOOST_RE_CALL reg_expression<charT, traits, Allocator>::fail(unsigned int e
|
||||
{
|
||||
error_code_ = err;
|
||||
if(err)
|
||||
throw bad_expression(traits_inst.error_string(err));
|
||||
{
|
||||
_flags |= regbase::failbit;
|
||||
if(_flags & regbase::use_except)
|
||||
{
|
||||
throw bad_expression(traits_inst.error_string(err));
|
||||
}
|
||||
}
|
||||
else
|
||||
_flags &= ~regbase::failbit;
|
||||
}
|
||||
|
||||
|
||||
|
@ -879,6 +879,7 @@ bool query_match_aux(iterator first,
|
||||
&& (first == last)) // end of input has been reached
|
||||
{
|
||||
have_partial_match = true;
|
||||
temp_match.set_second(first, 0, false);
|
||||
m.maybe_assign(temp_match);
|
||||
}
|
||||
|
||||
|
@ -521,7 +521,7 @@ public:
|
||||
|
||||
template <class ST, class SA>
|
||||
explicit reg_expression(const std::basic_string<charT, ST, SA>& p, flag_type f = regbase::normal, const Allocator& a = Allocator())
|
||||
: data(a), pkmp(0) { set_expression(p, f); }
|
||||
: data(a), pkmp(0) { set_expression(p, f | regbase::use_except); }
|
||||
|
||||
template <class I>
|
||||
reg_expression(I first, I last, flag_type f = regbase::normal, const Allocator& al = Allocator())
|
||||
@ -562,10 +562,10 @@ public:
|
||||
}
|
||||
#elif !defined(BOOST_RE_NO_STRING_DEF_ARGS)
|
||||
unsigned int BOOST_RE_CALL set_expression(const std::basic_string<charT>& p, flag_type f = regbase::normal)
|
||||
{ return set_expression(p.data(), p.data() + p.size(), f); }
|
||||
{ return set_expression(p.data(), p.data() + p.size(), f | regbase::use_except); }
|
||||
|
||||
reg_expression(const std::basic_string<charT>& p, flag_type f = regbase::normal, const Allocator& a = Allocator())
|
||||
: data(a), pkmp(0) { set_expression(p, f); }
|
||||
: data(a), pkmp(0) { set_expression(p, f | regbase::use_except); }
|
||||
|
||||
reg_expression& BOOST_RE_CALL operator=(const std::basic_string<charT>& p)
|
||||
{
|
||||
@ -980,11 +980,11 @@ public:
|
||||
ref->tail.matched = (ref->tail.first == ref->tail.second) ? false : true;
|
||||
}
|
||||
|
||||
void BOOST_RE_CALL set_second(iterator i, size_t pos)
|
||||
void BOOST_RE_CALL set_second(iterator i, size_t pos, bool m = true)
|
||||
{
|
||||
cow();
|
||||
((sub_match<iterator>*)((char*)ref + sizeof(c_reference) + sizeof(sub_match<iterator>) * pos))->second = i;
|
||||
((sub_match<iterator>*)((char*)ref + sizeof(c_reference) + sizeof(sub_match<iterator>) * pos))->matched = true;
|
||||
((sub_match<iterator>*)((char*)ref + sizeof(c_reference) + sizeof(sub_match<iterator>) * pos))->matched = m;
|
||||
if(pos == 0)
|
||||
{
|
||||
ref->tail.first = i;
|
||||
|
Reference in New Issue
Block a user