forked from boostorg/regex
Quickbook: Copy trunk headers into quickbook-dev.
[SVN r75212]
This commit is contained in:
@ -163,8 +163,10 @@
|
|||||||
* with MSVC and the /Zc:wchar_t option we place some extra unsigned short versions
|
* with MSVC and the /Zc:wchar_t option we place some extra unsigned short versions
|
||||||
* of the non-inline functions in the library, so that users can still link to the lib,
|
* of the non-inline functions in the library, so that users can still link to the lib,
|
||||||
* irrespective of whether their own code is built with /Zc:wchar_t.
|
* irrespective of whether their own code is built with /Zc:wchar_t.
|
||||||
|
* Note that this does NOT WORK with VC10 when the C++ locale is in effect as
|
||||||
|
* the locale's <unsigned short> facets simply do not compile in that case.
|
||||||
*/
|
*/
|
||||||
#if defined(__cplusplus) && (defined(BOOST_MSVC) || defined(__ICL)) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) && defined(BOOST_WINDOWS) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) && !defined(BOOST_RWSTD_VER)
|
#if defined(__cplusplus) && (defined(BOOST_MSVC) || defined(__ICL)) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) && defined(BOOST_WINDOWS) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) && !defined(BOOST_RWSTD_VER) && ((_MSC_VER < 1600) || !defined(BOOST_REGEX_USE_CPP_LOCALE))
|
||||||
# define BOOST_REGEX_HAS_OTHER_WCHAR_T
|
# define BOOST_REGEX_HAS_OTHER_WCHAR_T
|
||||||
# ifdef BOOST_MSVC
|
# ifdef BOOST_MSVC
|
||||||
# pragma warning(push)
|
# pragma warning(push)
|
||||||
|
@ -251,7 +251,7 @@ inline u32regex do_make_u32regex(InputIterator i,
|
|||||||
const boost::mpl::int_<1>*)
|
const boost::mpl::int_<1>*)
|
||||||
{
|
{
|
||||||
typedef boost::u8_to_u32_iterator<InputIterator, UChar32> conv_type;
|
typedef boost::u8_to_u32_iterator<InputIterator, UChar32> conv_type;
|
||||||
return u32regex(conv_type(i), conv_type(j), opt);
|
return u32regex(conv_type(i, i, j), conv_type(j, i, j), opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class InputIterator>
|
template <class InputIterator>
|
||||||
@ -261,7 +261,7 @@ inline u32regex do_make_u32regex(InputIterator i,
|
|||||||
const boost::mpl::int_<2>*)
|
const boost::mpl::int_<2>*)
|
||||||
{
|
{
|
||||||
typedef boost::u16_to_u32_iterator<InputIterator, UChar32> conv_type;
|
typedef boost::u16_to_u32_iterator<InputIterator, UChar32> conv_type;
|
||||||
return u32regex(conv_type(i), conv_type(j), opt);
|
return u32regex(conv_type(i, i, j), conv_type(j, i, j), opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class InputIterator>
|
template <class InputIterator>
|
||||||
@ -282,7 +282,7 @@ inline u32regex do_make_u32regex(InputIterator i,
|
|||||||
typedef boost::u8_to_u32_iterator<InputIterator, UChar32> conv_type;
|
typedef boost::u8_to_u32_iterator<InputIterator, UChar32> conv_type;
|
||||||
typedef std::vector<UChar32> vector_type;
|
typedef std::vector<UChar32> vector_type;
|
||||||
vector_type v;
|
vector_type v;
|
||||||
conv_type a(i), b(j);
|
conv_type a(i, i, j), b(j, i, j);
|
||||||
while(a != b)
|
while(a != b)
|
||||||
{
|
{
|
||||||
v.push_back(*a);
|
v.push_back(*a);
|
||||||
@ -302,7 +302,7 @@ inline u32regex do_make_u32regex(InputIterator i,
|
|||||||
typedef boost::u16_to_u32_iterator<InputIterator, UChar32> conv_type;
|
typedef boost::u16_to_u32_iterator<InputIterator, UChar32> conv_type;
|
||||||
typedef std::vector<UChar32> vector_type;
|
typedef std::vector<UChar32> vector_type;
|
||||||
vector_type v;
|
vector_type v;
|
||||||
conv_type a(i), b(j);
|
conv_type a(i, i, j), b(j, i, j);
|
||||||
while(a != b)
|
while(a != b)
|
||||||
{
|
{
|
||||||
v.push_back(*a);
|
v.push_back(*a);
|
||||||
@ -425,7 +425,7 @@ bool do_regex_match(BidiIterator first, BidiIterator last,
|
|||||||
typedef match_results<conv_type> match_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;
|
match_type what;
|
||||||
bool result = ::boost::regex_match(conv_type(first), conv_type(last), what, e, flags);
|
bool result = ::boost::regex_match(conv_type(first, first, last), conv_type(last, first, last), what, e, flags);
|
||||||
// copy results across to m:
|
// copy results across to m:
|
||||||
if(result) copy_results(m, what);
|
if(result) copy_results(m, what);
|
||||||
return result;
|
return result;
|
||||||
@ -441,7 +441,7 @@ bool do_regex_match(BidiIterator first, BidiIterator last,
|
|||||||
typedef match_results<conv_type> match_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;
|
match_type what;
|
||||||
bool result = ::boost::regex_match(conv_type(first), conv_type(last), what, e, flags);
|
bool result = ::boost::regex_match(conv_type(first, first, last), conv_type(last, first, last), what, e, flags);
|
||||||
// copy results across to m:
|
// copy results across to m:
|
||||||
if(result) copy_results(m, what);
|
if(result) copy_results(m, what);
|
||||||
return result;
|
return result;
|
||||||
@ -600,7 +600,7 @@ bool do_regex_search(BidiIterator first, BidiIterator last,
|
|||||||
typedef match_results<conv_type> match_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;
|
match_type what;
|
||||||
bool result = ::boost::regex_search(conv_type(first), conv_type(last), what, e, flags, conv_type(base));
|
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:
|
// copy results across to m:
|
||||||
if(result) copy_results(m, what);
|
if(result) copy_results(m, what);
|
||||||
return result;
|
return result;
|
||||||
@ -617,7 +617,7 @@ bool do_regex_search(BidiIterator first, BidiIterator last,
|
|||||||
typedef match_results<conv_type> match_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;
|
match_type what;
|
||||||
bool result = ::boost::regex_search(conv_type(first), conv_type(last), what, e, flags, conv_type(base));
|
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:
|
// copy results across to m:
|
||||||
if(result) copy_results(m, what);
|
if(result) copy_results(m, what);
|
||||||
return result;
|
return result;
|
||||||
@ -764,13 +764,13 @@ template <class I>
|
|||||||
inline std::pair< boost::u8_to_u32_iterator<I>, boost::u8_to_u32_iterator<I> >
|
inline std::pair< boost::u8_to_u32_iterator<I>, boost::u8_to_u32_iterator<I> >
|
||||||
make_utf32_seq(I i, I j, mpl::int_<1> const*)
|
make_utf32_seq(I i, I j, mpl::int_<1> const*)
|
||||||
{
|
{
|
||||||
return std::pair< boost::u8_to_u32_iterator<I>, boost::u8_to_u32_iterator<I> >(boost::u8_to_u32_iterator<I>(i), boost::u8_to_u32_iterator<I>(j));
|
return std::pair< boost::u8_to_u32_iterator<I>, boost::u8_to_u32_iterator<I> >(boost::u8_to_u32_iterator<I>(i, i, j), boost::u8_to_u32_iterator<I>(j, i, j));
|
||||||
}
|
}
|
||||||
template <class I>
|
template <class I>
|
||||||
inline std::pair< boost::u16_to_u32_iterator<I>, boost::u16_to_u32_iterator<I> >
|
inline std::pair< boost::u16_to_u32_iterator<I>, boost::u16_to_u32_iterator<I> >
|
||||||
make_utf32_seq(I i, I j, mpl::int_<2> const*)
|
make_utf32_seq(I i, I j, mpl::int_<2> const*)
|
||||||
{
|
{
|
||||||
return std::pair< boost::u16_to_u32_iterator<I>, boost::u16_to_u32_iterator<I> >(boost::u16_to_u32_iterator<I>(i), boost::u16_to_u32_iterator<I>(j));
|
return std::pair< boost::u16_to_u32_iterator<I>, boost::u16_to_u32_iterator<I> >(boost::u16_to_u32_iterator<I>(i, i, j), boost::u16_to_u32_iterator<I>(j, i, j));
|
||||||
}
|
}
|
||||||
template <class I>
|
template <class I>
|
||||||
inline std::pair< I, I >
|
inline std::pair< I, I >
|
||||||
@ -782,13 +782,15 @@ template <class charT>
|
|||||||
inline std::pair< boost::u8_to_u32_iterator<const charT*>, boost::u8_to_u32_iterator<const charT*> >
|
inline std::pair< boost::u8_to_u32_iterator<const charT*>, boost::u8_to_u32_iterator<const charT*> >
|
||||||
make_utf32_seq(const charT* p, mpl::int_<1> const*)
|
make_utf32_seq(const charT* p, mpl::int_<1> const*)
|
||||||
{
|
{
|
||||||
return std::pair< boost::u8_to_u32_iterator<const charT*>, boost::u8_to_u32_iterator<const charT*> >(boost::u8_to_u32_iterator<const charT*>(p), boost::u8_to_u32_iterator<const charT*>(p+std::strlen((const char*)p)));
|
std::size_t len = std::strlen((const char*)p);
|
||||||
|
return std::pair< boost::u8_to_u32_iterator<const charT*>, boost::u8_to_u32_iterator<const charT*> >(boost::u8_to_u32_iterator<const charT*>(p, p, p+len), boost::u8_to_u32_iterator<const charT*>(p+len, p, p+len));
|
||||||
}
|
}
|
||||||
template <class charT>
|
template <class charT>
|
||||||
inline std::pair< boost::u16_to_u32_iterator<const charT*>, boost::u16_to_u32_iterator<const charT*> >
|
inline std::pair< boost::u16_to_u32_iterator<const charT*>, boost::u16_to_u32_iterator<const charT*> >
|
||||||
make_utf32_seq(const charT* p, mpl::int_<2> const*)
|
make_utf32_seq(const charT* p, mpl::int_<2> const*)
|
||||||
{
|
{
|
||||||
return std::pair< boost::u16_to_u32_iterator<const charT*>, boost::u16_to_u32_iterator<const charT*> >(boost::u16_to_u32_iterator<const charT*>(p), boost::u16_to_u32_iterator<const charT*>(p+u_strlen((const UChar*)p)));
|
std::size_t len = u_strlen((const UChar*)p);
|
||||||
|
return std::pair< boost::u16_to_u32_iterator<const charT*>, boost::u16_to_u32_iterator<const charT*> >(boost::u16_to_u32_iterator<const charT*>(p, p, p + len), boost::u16_to_u32_iterator<const charT*>(p+len, p, p + len));
|
||||||
}
|
}
|
||||||
template <class charT>
|
template <class charT>
|
||||||
inline std::pair< const charT*, const charT* >
|
inline std::pair< const charT*, const charT* >
|
||||||
|
@ -73,7 +73,7 @@ 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...
|
// 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"));
|
::boost::throw_exception(std::runtime_error("Error in thread safety code: could not acquire a lock"));
|
||||||
#ifdef BOOST_NO_UNREACHABLE_RETURN_DETECTION
|
#if defined(BOOST_NO_UNREACHABLE_RETURN_DETECTION) || defined(BOOST_NO_EXCEPTIONS)
|
||||||
return boost::shared_ptr<Object>();
|
return boost::shared_ptr<Object>();
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
|
@ -82,16 +82,16 @@ static const ::boost::uint32_t ten_bit_mask = 0x3FFu;
|
|||||||
|
|
||||||
inline bool is_high_surrogate(::boost::uint16_t v)
|
inline bool is_high_surrogate(::boost::uint16_t v)
|
||||||
{
|
{
|
||||||
return (v & 0xFC00u) == 0xd800u;
|
return (v & 0xFFFFFC00u) == 0xd800u;
|
||||||
}
|
}
|
||||||
inline bool is_low_surrogate(::boost::uint16_t v)
|
inline bool is_low_surrogate(::boost::uint16_t v)
|
||||||
{
|
{
|
||||||
return (v & 0xFC00u) == 0xdc00u;
|
return (v & 0xFFFFFC00u) == 0xdc00u;
|
||||||
}
|
}
|
||||||
template <class T>
|
template <class T>
|
||||||
inline bool is_surrogate(T v)
|
inline bool is_surrogate(T v)
|
||||||
{
|
{
|
||||||
return (v & 0xF800u) == 0xd800;
|
return (v & 0xFFFFF800u) == 0xd800;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned utf8_byte_count(boost::uint8_t c)
|
inline unsigned utf8_byte_count(boost::uint8_t c)
|
||||||
@ -113,6 +113,10 @@ inline unsigned utf8_trailing_byte_count(boost::uint8_t c)
|
|||||||
return utf8_byte_count(c) - 1;
|
return utf8_byte_count(c) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BOOST_MSVC
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable:4100)
|
||||||
|
#endif
|
||||||
inline void invalid_utf32_code_point(::boost::uint32_t val)
|
inline void invalid_utf32_code_point(::boost::uint32_t val)
|
||||||
{
|
{
|
||||||
#ifndef BOOST_NO_STD_LOCALE
|
#ifndef BOOST_NO_STD_LOCALE
|
||||||
@ -124,6 +128,9 @@ inline void invalid_utf32_code_point(::boost::uint32_t val)
|
|||||||
#endif
|
#endif
|
||||||
boost::throw_exception(e);
|
boost::throw_exception(e);
|
||||||
}
|
}
|
||||||
|
#ifdef BOOST_MSVC
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
@ -296,6 +303,34 @@ public:
|
|||||||
{
|
{
|
||||||
m_value = pending_read;
|
m_value = pending_read;
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
// Range checked version:
|
||||||
|
//
|
||||||
|
u16_to_u32_iterator(BaseIterator b, BaseIterator start, BaseIterator end) : m_position(b)
|
||||||
|
{
|
||||||
|
m_value = pending_read;
|
||||||
|
//
|
||||||
|
// The range must not start with a low surrogate, or end in a high surrogate,
|
||||||
|
// otherwise we run the risk of running outside the underlying input range.
|
||||||
|
// Likewise b must not be located at a low surrogate.
|
||||||
|
//
|
||||||
|
boost::uint16_t val;
|
||||||
|
if(start != end)
|
||||||
|
{
|
||||||
|
if((b != start) && (b != end))
|
||||||
|
{
|
||||||
|
val = *b;
|
||||||
|
if(detail::is_surrogate(val) && ((val & 0xFC00u) == 0xDC00u))
|
||||||
|
invalid_code_point(val);
|
||||||
|
}
|
||||||
|
val = *start;
|
||||||
|
if(detail::is_surrogate(val) && ((val & 0xFC00u) == 0xDC00u))
|
||||||
|
invalid_code_point(val);
|
||||||
|
val = *--end;
|
||||||
|
if(detail::is_high_surrogate(val))
|
||||||
|
invalid_code_point(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
static void invalid_code_point(::boost::uint16_t val)
|
static void invalid_code_point(::boost::uint16_t val)
|
||||||
{
|
{
|
||||||
@ -497,7 +532,7 @@ public:
|
|||||||
while((*--m_position & 0xC0u) == 0x80u) ++count;
|
while((*--m_position & 0xC0u) == 0x80u) ++count;
|
||||||
// now check that the sequence was valid:
|
// now check that the sequence was valid:
|
||||||
if(count != detail::utf8_trailing_byte_count(*m_position))
|
if(count != detail::utf8_trailing_byte_count(*m_position))
|
||||||
invalid_sequnce();
|
invalid_sequence();
|
||||||
m_value = pending_read;
|
m_value = pending_read;
|
||||||
}
|
}
|
||||||
BaseIterator base()const
|
BaseIterator base()const
|
||||||
@ -513,8 +548,37 @@ public:
|
|||||||
{
|
{
|
||||||
m_value = pending_read;
|
m_value = pending_read;
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
// Checked constructor:
|
||||||
|
//
|
||||||
|
u8_to_u32_iterator(BaseIterator b, BaseIterator start, BaseIterator end) : m_position(b)
|
||||||
|
{
|
||||||
|
m_value = pending_read;
|
||||||
|
//
|
||||||
|
// We must not start with a continuation character, or end with a
|
||||||
|
// truncated UTF-8 sequence otherwise we run the risk of going past
|
||||||
|
// the start/end of the underlying sequence:
|
||||||
|
//
|
||||||
|
if(start != end)
|
||||||
|
{
|
||||||
|
unsigned char v = *start;
|
||||||
|
if((v & 0xC0u) == 0x80u)
|
||||||
|
invalid_sequence();
|
||||||
|
if((b != start) && (b != end) && ((*b & 0xC0u) == 0x80u))
|
||||||
|
invalid_sequence();
|
||||||
|
BaseIterator pos = end;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
v = *--pos;
|
||||||
|
}
|
||||||
|
while((start != pos) && ((v & 0xC0u) == 0x80u));
|
||||||
|
std::ptrdiff_t extra = detail::utf8_byte_count(v);
|
||||||
|
if(std::distance(pos, end) < extra)
|
||||||
|
invalid_sequence();
|
||||||
|
}
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
static void invalid_sequnce()
|
static void invalid_sequence()
|
||||||
{
|
{
|
||||||
std::out_of_range e("Invalid UTF-8 sequence encountered while trying to encode UTF-32 character");
|
std::out_of_range e("Invalid UTF-8 sequence encountered while trying to encode UTF-32 character");
|
||||||
boost::throw_exception(e);
|
boost::throw_exception(e);
|
||||||
@ -524,7 +588,7 @@ private:
|
|||||||
m_value = static_cast<U32Type>(static_cast< ::boost::uint8_t>(*m_position));
|
m_value = static_cast<U32Type>(static_cast< ::boost::uint8_t>(*m_position));
|
||||||
// we must not have a continuation character:
|
// we must not have a continuation character:
|
||||||
if((m_value & 0xC0u) == 0x80u)
|
if((m_value & 0xC0u) == 0x80u)
|
||||||
invalid_sequnce();
|
invalid_sequence();
|
||||||
// see how many extra byts we have:
|
// see how many extra byts we have:
|
||||||
unsigned extra = detail::utf8_trailing_byte_count(*m_position);
|
unsigned extra = detail::utf8_trailing_byte_count(*m_position);
|
||||||
// extract the extra bits, 6 from each extra byte:
|
// extract the extra bits, 6 from each extra byte:
|
||||||
@ -547,7 +611,7 @@ private:
|
|||||||
m_value &= masks[extra];
|
m_value &= masks[extra];
|
||||||
// check the result:
|
// check the result:
|
||||||
if(m_value > static_cast<U32Type>(0x10FFFFu))
|
if(m_value > static_cast<U32Type>(0x10FFFFu))
|
||||||
invalid_sequnce();
|
invalid_sequence();
|
||||||
}
|
}
|
||||||
BaseIterator m_position;
|
BaseIterator m_position;
|
||||||
mutable U32Type m_value;
|
mutable U32Type m_value;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998-2004
|
* Copyright (c) 1998-2004 John Maddock
|
||||||
* John Maddock
|
* Copyright 2011 Garmin Ltd. or its subsidiaries
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -234,7 +234,7 @@ public:
|
|||||||
std::pair<const_iterator, const_iterator> BOOST_REGEX_CALL subexpression(std::size_t n)const
|
std::pair<const_iterator, const_iterator> BOOST_REGEX_CALL subexpression(std::size_t n)const
|
||||||
{
|
{
|
||||||
if(n == 0)
|
if(n == 0)
|
||||||
throw std::out_of_range("0 is not a valid subexpression index.");
|
boost::throw_exception(std::out_of_range("0 is not a valid subexpression index."));
|
||||||
const std::pair<std::size_t, std::size_t>& pi = this->m_subs.at(n - 1);
|
const std::pair<std::size_t, std::size_t>& pi = this->m_subs.at(n - 1);
|
||||||
std::pair<const_iterator, const_iterator> p(expression() + pi.first, expression() + pi.second);
|
std::pair<const_iterator, const_iterator> p(expression() + pi.first, expression() + pi.second);
|
||||||
return p;
|
return p;
|
||||||
@ -398,7 +398,7 @@ public:
|
|||||||
typedef typename traits::string_type seq_type;
|
typedef typename traits::string_type seq_type;
|
||||||
seq_type a(arg_first, arg_last);
|
seq_type a(arg_first, arg_last);
|
||||||
if(a.size())
|
if(a.size())
|
||||||
assign(&*a.begin(), &*a.begin() + a.size(), f);
|
assign(static_cast<const charT*>(&*a.begin()), static_cast<const charT*>(&*a.begin() + a.size()), f);
|
||||||
else
|
else
|
||||||
assign(static_cast<const charT*>(0), static_cast<const charT*>(0), f);
|
assign(static_cast<const charT*>(0), static_cast<const charT*>(0), f);
|
||||||
}
|
}
|
||||||
@ -487,7 +487,7 @@ public:
|
|||||||
std::pair<const_iterator, const_iterator> BOOST_REGEX_CALL subexpression(std::size_t n)const
|
std::pair<const_iterator, const_iterator> BOOST_REGEX_CALL subexpression(std::size_t n)const
|
||||||
{
|
{
|
||||||
if(!m_pimpl.get())
|
if(!m_pimpl.get())
|
||||||
throw std::logic_error("Can't access subexpressions in an invalid regex.");
|
boost::throw_exception(std::logic_error("Can't access subexpressions in an invalid regex."));
|
||||||
return m_pimpl->subexpression(n);
|
return m_pimpl->subexpression(n);
|
||||||
}
|
}
|
||||||
const_iterator BOOST_REGEX_CALL begin()const
|
const_iterator BOOST_REGEX_CALL begin()const
|
||||||
|
@ -241,6 +241,7 @@ protected:
|
|||||||
unsigned m_backrefs; // bitmask of permitted backrefs
|
unsigned m_backrefs; // bitmask of permitted backrefs
|
||||||
boost::uintmax_t m_bad_repeats; // bitmask of repeats we can't deduce a startmap for;
|
boost::uintmax_t m_bad_repeats; // bitmask of repeats we can't deduce a startmap for;
|
||||||
bool m_has_recursions; // set when we have recursive expresisons to fixup
|
bool m_has_recursions; // set when we have recursive expresisons to fixup
|
||||||
|
std::vector<bool> m_recursion_checks; // notes which recursions we've followed while analysing this expression
|
||||||
typename traits::char_class_type m_word_mask; // mask used to determine if a character is a word character
|
typename traits::char_class_type m_word_mask; // mask used to determine if a character is a word character
|
||||||
typename traits::char_class_type m_mask_space; // mask used to determine if a character is a word character
|
typename traits::char_class_type m_mask_space; // mask used to determine if a character is a word character
|
||||||
typename traits::char_class_type m_lower_mask; // mask used to determine if a character is a lowercase character
|
typename traits::char_class_type m_lower_mask; // mask used to determine if a character is a lowercase character
|
||||||
@ -712,6 +713,8 @@ void basic_regex_creator<charT, traits>::finalize(const charT* p1, const charT*
|
|||||||
m_pdata->m_can_be_null = 0;
|
m_pdata->m_can_be_null = 0;
|
||||||
|
|
||||||
m_bad_repeats = 0;
|
m_bad_repeats = 0;
|
||||||
|
if(m_has_recursions)
|
||||||
|
m_recursion_checks.assign(1 + m_pdata->m_mark_count, false);
|
||||||
create_startmap(m_pdata->m_first_state, m_pdata->m_startmap, &(m_pdata->m_can_be_null), mask_all);
|
create_startmap(m_pdata->m_first_state, m_pdata->m_startmap, &(m_pdata->m_can_be_null), mask_all);
|
||||||
// get the restart type:
|
// get the restart type:
|
||||||
m_pdata->m_restart_type = get_restart_type(m_pdata->m_first_state);
|
m_pdata->m_restart_type = get_restart_type(m_pdata->m_first_state);
|
||||||
@ -948,9 +951,14 @@ void basic_regex_creator<charT, traits>::create_startmaps(re_syntax_base* state)
|
|||||||
state = state->next.p;
|
state = state->next.p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// now work through our list, building all the maps as we go:
|
// now work through our list, building all the maps as we go:
|
||||||
while(v.size())
|
while(v.size())
|
||||||
{
|
{
|
||||||
|
// Initialize m_recursion_checks if we need it:
|
||||||
|
if(m_has_recursions)
|
||||||
|
m_recursion_checks.assign(1 + m_pdata->m_mark_count, false);
|
||||||
|
|
||||||
const std::pair<bool, re_syntax_base*>& p = v.back();
|
const std::pair<bool, re_syntax_base*>& p = v.back();
|
||||||
m_icase = p.first;
|
m_icase = p.first;
|
||||||
state = p.second;
|
state = p.second;
|
||||||
@ -960,6 +968,9 @@ void basic_regex_creator<charT, traits>::create_startmaps(re_syntax_base* state)
|
|||||||
m_bad_repeats = 0;
|
m_bad_repeats = 0;
|
||||||
create_startmap(state->next.p, static_cast<re_alt*>(state)->_map, &static_cast<re_alt*>(state)->can_be_null, mask_take);
|
create_startmap(state->next.p, static_cast<re_alt*>(state)->_map, &static_cast<re_alt*>(state)->can_be_null, mask_take);
|
||||||
m_bad_repeats = 0;
|
m_bad_repeats = 0;
|
||||||
|
|
||||||
|
if(m_has_recursions)
|
||||||
|
m_recursion_checks.assign(1 + m_pdata->m_mark_count, false);
|
||||||
create_startmap(static_cast<re_alt*>(state)->alt.p, static_cast<re_alt*>(state)->_map, &static_cast<re_alt*>(state)->can_be_null, mask_skip);
|
create_startmap(static_cast<re_alt*>(state)->alt.p, static_cast<re_alt*>(state)->_map, &static_cast<re_alt*>(state)->can_be_null, mask_skip);
|
||||||
// adjust the type of the state to allow for faster matching:
|
// adjust the type of the state to allow for faster matching:
|
||||||
state->type = this->get_repeat_type(state);
|
state->type = this->get_repeat_type(state);
|
||||||
@ -1114,7 +1125,11 @@ void basic_regex_creator<charT, traits>::create_startmap(re_syntax_base* state,
|
|||||||
}
|
}
|
||||||
case syntax_element_recurse:
|
case syntax_element_recurse:
|
||||||
{
|
{
|
||||||
if(recursion_start == state)
|
if(state->type == syntax_element_startmark)
|
||||||
|
recursion_sub = static_cast<re_brace*>(state)->index;
|
||||||
|
else
|
||||||
|
recursion_sub = 0;
|
||||||
|
if(m_recursion_checks[recursion_sub])
|
||||||
{
|
{
|
||||||
// Infinite recursion!!
|
// Infinite recursion!!
|
||||||
if(0 == this->m_pdata->m_status) // update the error code if not already set
|
if(0 == this->m_pdata->m_status) // update the error code if not already set
|
||||||
@ -1139,12 +1154,10 @@ void basic_regex_creator<charT, traits>::create_startmap(re_syntax_base* state,
|
|||||||
recursion_start = state;
|
recursion_start = state;
|
||||||
recursion_restart = state->next.p;
|
recursion_restart = state->next.p;
|
||||||
state = static_cast<re_jump*>(state)->alt.p;
|
state = static_cast<re_jump*>(state)->alt.p;
|
||||||
if(state->type == syntax_element_startmark)
|
m_recursion_checks[recursion_sub] = true;
|
||||||
recursion_sub = static_cast<re_brace*>(state)->index;
|
|
||||||
else
|
|
||||||
recursion_sub = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
m_recursion_checks[recursion_sub] = true;
|
||||||
// fall through, can't handle nested recursion here...
|
// fall through, can't handle nested recursion here...
|
||||||
}
|
}
|
||||||
case syntax_element_backref:
|
case syntax_element_backref:
|
||||||
@ -1213,7 +1226,7 @@ void basic_regex_creator<charT, traits>::create_startmap(re_syntax_base* state,
|
|||||||
for(unsigned int i = 0; i < (1u << CHAR_BIT); ++i)
|
for(unsigned int i = 0; i < (1u << CHAR_BIT); ++i)
|
||||||
{
|
{
|
||||||
charT c = static_cast<charT>(i);
|
charT c = static_cast<charT>(i);
|
||||||
if(&c != re_is_set_member(&c, &c + 1, static_cast<re_set_long<mask_type>*>(state), *m_pdata, m_icase))
|
if(&c != re_is_set_member(&c, &c + 1, static_cast<re_set_long<mask_type>*>(state), *m_pdata, l_icase))
|
||||||
l_map[i] |= mask;
|
l_map[i] |= mask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -941,7 +941,8 @@ bool basic_regex_parser<charT, traits>::parse_repeat(std::size_t low, std::size_
|
|||||||
++m_position;
|
++m_position;
|
||||||
}
|
}
|
||||||
// for perl regexes only check for pocessive ++ repeats.
|
// for perl regexes only check for pocessive ++ repeats.
|
||||||
if((0 == (this->flags() & regbase::main_option_type))
|
if((m_position != m_end)
|
||||||
|
&& (0 == (this->flags() & regbase::main_option_type))
|
||||||
&& (this->m_traits.syntax_type(*m_position) == regex_constants::syntax_plus))
|
&& (this->m_traits.syntax_type(*m_position) == regex_constants::syntax_plus))
|
||||||
{
|
{
|
||||||
pocessive = true;
|
pocessive = true;
|
||||||
@ -1025,13 +1026,14 @@ bool basic_regex_parser<charT, traits>::parse_repeat(std::size_t low, std::size_
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Check for illegal following quantifier, we have to do this here, because
|
// Check for illegal following quantifier, we have to do this here, because
|
||||||
// the extra states we insert below circumvents are usual error checking :-(
|
// the extra states we insert below circumvents our usual error checking :-(
|
||||||
//
|
//
|
||||||
switch(this->m_traits.syntax_type(*m_position))
|
switch(this->m_traits.syntax_type(*m_position))
|
||||||
{
|
{
|
||||||
case regex_constants::syntax_star:
|
case regex_constants::syntax_star:
|
||||||
case regex_constants::syntax_plus:
|
case regex_constants::syntax_plus:
|
||||||
case regex_constants::syntax_question:
|
case regex_constants::syntax_question:
|
||||||
|
case regex_constants::syntax_open_brace:
|
||||||
fail(regex_constants::error_badrepeat, m_position - m_base);
|
fail(regex_constants::error_badrepeat, m_position - m_base);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright (c) 2004
|
* Copyright (c) 2004 John Maddock
|
||||||
* John Maddock
|
* Copyright 2011 Garmin Ltd. or its subsidiaries
|
||||||
*
|
*
|
||||||
* Use, modification and distribution are subject to the
|
* Use, modification and distribution are subject to the
|
||||||
* Boost Software License, Version 1.0. (See accompanying file
|
* Boost Software License, Version 1.0. (See accompanying file
|
||||||
@ -511,7 +511,9 @@ typename cpp_regex_traits_implementation<charT>::string_type
|
|||||||
// however at least one std lib will always throw
|
// however at least one std lib will always throw
|
||||||
// std::bad_alloc for certain arguments...
|
// std::bad_alloc for certain arguments...
|
||||||
//
|
//
|
||||||
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
try{
|
try{
|
||||||
|
#endif
|
||||||
//
|
//
|
||||||
// What we do here depends upon the format of the sort key returned by
|
// What we do here depends upon the format of the sort key returned by
|
||||||
// sort key returned by this->transform:
|
// sort key returned by this->transform:
|
||||||
@ -546,7 +548,9 @@ typename cpp_regex_traits_implementation<charT>::string_type
|
|||||||
result.erase(i);
|
result.erase(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
}catch(...){}
|
}catch(...){}
|
||||||
|
#endif
|
||||||
while(result.size() && (charT(0) == *result.rbegin()))
|
while(result.size() && (charT(0) == *result.rbegin()))
|
||||||
result.erase(result.size() - 1);
|
result.erase(result.size() - 1);
|
||||||
if(result.empty())
|
if(result.empty())
|
||||||
@ -576,7 +580,9 @@ typename cpp_regex_traits_implementation<charT>::string_type
|
|||||||
// std::bad_alloc for certain arguments...
|
// std::bad_alloc for certain arguments...
|
||||||
//
|
//
|
||||||
string_type result;
|
string_type result;
|
||||||
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
try{
|
try{
|
||||||
|
#endif
|
||||||
result = this->m_pcollate->transform(p1, p2);
|
result = this->m_pcollate->transform(p1, p2);
|
||||||
//
|
//
|
||||||
// Borland's STLPort version returns a NULL-terminated
|
// Borland's STLPort version returns a NULL-terminated
|
||||||
@ -593,10 +599,12 @@ typename cpp_regex_traits_implementation<charT>::string_type
|
|||||||
result.erase(result.size() - 1);
|
result.erase(result.size() - 1);
|
||||||
#endif
|
#endif
|
||||||
BOOST_ASSERT(std::find(result.begin(), result.end(), charT(0)) == result.end());
|
BOOST_ASSERT(std::find(result.begin(), result.end(), charT(0)) == result.end());
|
||||||
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -842,7 +842,15 @@ OutputIterator regex_format_imp(OutputIterator out,
|
|||||||
|
|
||||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(const_iterator)
|
BOOST_MPL_HAS_XXX_TRAIT_DEF(const_iterator)
|
||||||
|
|
||||||
struct any_type { any_type(...); };
|
struct any_type
|
||||||
|
{
|
||||||
|
template <class T>
|
||||||
|
any_type(const T&);
|
||||||
|
template <class T, class U>
|
||||||
|
any_type(const T&, const U&);
|
||||||
|
template <class T, class U, class V>
|
||||||
|
any_type(const T&, const U&, const V&);
|
||||||
|
};
|
||||||
typedef char no_type;
|
typedef char no_type;
|
||||||
typedef char (&unary_type)[2];
|
typedef char (&unary_type)[2];
|
||||||
typedef char (&binary_type)[3];
|
typedef char (&binary_type)[3];
|
||||||
|
@ -317,14 +317,14 @@ inline u32regex_token_iterator<const wchar_t*> make_u32regex_token_iterator(cons
|
|||||||
template <std::size_t N>
|
template <std::size_t N>
|
||||||
inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const UChar* p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default)
|
inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const UChar* p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default)
|
||||||
{
|
{
|
||||||
return u32regex_token_iterator<const UChar*>(p, p+u_strlen(p), e, m);
|
return u32regex_token_iterator<const UChar*>(p, p+u_strlen(p), e, submatch, m);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
template <class charT, class Traits, class Alloc, std::size_t N>
|
template <class charT, class Traits, class Alloc, std::size_t N>
|
||||||
inline u32regex_token_iterator<typename std::basic_string<charT, Traits, Alloc>::const_iterator> make_u32regex_token_iterator(const std::basic_string<charT, Traits, Alloc>& p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default)
|
inline u32regex_token_iterator<typename std::basic_string<charT, Traits, Alloc>::const_iterator> make_u32regex_token_iterator(const std::basic_string<charT, Traits, Alloc>& p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default)
|
||||||
{
|
{
|
||||||
typedef typename std::basic_string<charT, Traits, Alloc>::const_iterator iter_type;
|
typedef typename std::basic_string<charT, Traits, Alloc>::const_iterator iter_type;
|
||||||
return u32regex_token_iterator<iter_type>(p.begin(), p.end(), e, m);
|
return u32regex_token_iterator<iter_type>(p.begin(), p.end(), e, submatch, m);
|
||||||
}
|
}
|
||||||
template <std::size_t N>
|
template <std::size_t N>
|
||||||
inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default)
|
inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default)
|
||||||
@ -354,7 +354,7 @@ template <class charT, class Traits, class Alloc>
|
|||||||
inline u32regex_token_iterator<typename std::basic_string<charT, Traits, Alloc>::const_iterator> make_u32regex_token_iterator(const std::basic_string<charT, Traits, Alloc>& p, const u32regex& e, const std::vector<int>& submatch, regex_constants::match_flag_type m = regex_constants::match_default)
|
inline u32regex_token_iterator<typename std::basic_string<charT, Traits, Alloc>::const_iterator> make_u32regex_token_iterator(const std::basic_string<charT, Traits, Alloc>& p, const u32regex& e, const std::vector<int>& submatch, regex_constants::match_flag_type m = regex_constants::match_default)
|
||||||
{
|
{
|
||||||
typedef typename std::basic_string<charT, Traits, Alloc>::const_iterator iter_type;
|
typedef typename std::basic_string<charT, Traits, Alloc>::const_iterator iter_type;
|
||||||
return u32regex_token_iterator<iter_type>(p.begin(), p.end(), e, m);
|
return u32regex_token_iterator<iter_type>(p.begin(), p.end(), e, submatch, m);
|
||||||
}
|
}
|
||||||
inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, const std::vector<int>& submatch, regex_constants::match_flag_type m = regex_constants::match_default)
|
inline u32regex_token_iterator<const UChar*> make_u32regex_token_iterator(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, const std::vector<int>& submatch, regex_constants::match_flag_type m = regex_constants::match_default)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user