diff options
Diffstat (limited to 'boost/regex')
37 files changed, 1121 insertions, 510 deletions
diff --git a/boost/regex/config.hpp b/boost/regex/config.hpp index 7e6cc51969..4fd1fd94a8 100644 --- a/boost/regex/config.hpp +++ b/boost/regex/config.hpp @@ -25,6 +25,7 @@ #if defined(__BORLANDC__) # include <boost/regex/config/borland.hpp> #endif +#include <boost/version.hpp> /***************************************************************************** * @@ -41,6 +42,7 @@ # include BOOST_REGEX_USER_CONFIG # include <boost/config.hpp> +# include <boost/predef.h> #else /* @@ -69,6 +71,13 @@ #define UNICODE #endif + +/* +* Define a macro for the namespace that details are placed in, this includes the Boost +* version number to avoid mismatched header and library versions: +*/ +#define BOOST_REGEX_DETAIL_NS BOOST_JOIN(re_detail_, BOOST_VERSION) + /* * Fix for gcc prior to 3.4: std::ctype<wchar_t> doesn't allow * masks to be combined, for example: @@ -92,7 +101,13 @@ #if defined(_MSC_VER) && !defined(_MSC_EXTENSIONS) # define BOOST_REGEX_NO_EXTERNAL_TEMPLATES #endif -/* + /* + * Oracle compiler in C++11 mode doesn't like external templates for some reason: + */ +#ifdef __SUNPRO_CC +# define BOOST_REGEX_NO_EXTERNAL_TEMPLATES +#endif + /* * Shared regex lib will crash without this, frankly it looks a lot like a gcc bug: */ #if defined(__MINGW32__) @@ -133,8 +148,14 @@ /* disable our own file-iterators and mapfiles if we can't * support them: */ -#if !defined(BOOST_HAS_DIRENT_H) && !(defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)) -# define BOOST_REGEX_NO_FILEITER +#if defined(_WIN32) +# if defined(BOOST_REGEX_NO_W32) || BOOST_PLAT_WINDOWS_STORE +# define BOOST_REGEX_NO_FILEITER +# endif +#else // defined(_WIN32) +# if !defined(BOOST_HAS_DIRENT_H) +# define BOOST_REGEX_NO_FILEITER +# endif #endif /* backwards compatibitity: */ @@ -163,10 +184,20 @@ * 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, * 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 + * Note that this does NOT WORK with VC10 and VC14 when the C++ locale is in effect as * the locale's <unsigned short> facets simply do not compile in that case. + * As we default to the C++ locale when compiling for the windows runtime we + * skip in this case aswell. */ -#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)) +#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)) && \ + !BOOST_PLAT_WINDOWS_RUNTIME # define BOOST_REGEX_HAS_OTHER_WCHAR_T # ifdef BOOST_MSVC # pragma warning(push) @@ -264,8 +295,19 @@ # define BOOST_REGEX_USE_C_LOCALE #endif +/* use C++ locale when targeting windows store */ +#if BOOST_PLAT_WINDOWS_RUNTIME +# define BOOST_REGEX_USE_CPP_LOCALE +# define BOOST_REGEX_NO_WIN32_LOCALE +#endif + /* Win32 defaults to native Win32 locale: */ -#if defined(_WIN32) && !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) && !defined(BOOST_REGEX_NO_W32) +#if defined(_WIN32) && \ + !defined(BOOST_REGEX_USE_WIN32_LOCALE) && \ + !defined(BOOST_REGEX_USE_C_LOCALE) && \ + !defined(BOOST_REGEX_USE_CPP_LOCALE) && \ + !defined(BOOST_REGEX_NO_W32) && \ + !defined(BOOST_REGEX_NO_WIN32_LOCALE) # define BOOST_REGEX_USE_WIN32_LOCALE #endif /* otherwise use C++ locale if supported: */ @@ -334,7 +376,7 @@ if(0 == (x))\ #if defined(__cplusplus) && defined(BOOST_REGEX_HAS_MS_STACK_GUARD) namespace boost{ -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page(); @@ -387,7 +429,7 @@ BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page(); ****************************************************************************/ #if defined(__cplusplus) && defined(BOOST_REGEX_NON_RECURSIVE) -namespace boost{ namespace re_detail{ +namespace boost{ namespace BOOST_REGEX_DETAIL_NS{ BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block(); BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void*); diff --git a/boost/regex/icu.hpp b/boost/regex/icu.hpp index 572172e542..a70aa0da81 100644 --- a/boost/regex/icu.hpp +++ b/boost/regex/icu.hpp @@ -34,7 +34,7 @@ namespace boost{ -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ // // Implementation details: @@ -108,18 +108,18 @@ public: struct boost_extensions_tag{}; icu_regex_traits() - : m_pimpl(re_detail::get_icu_regex_traits_implementation(U_NAMESPACE_QUALIFIER Locale())) + : m_pimpl(BOOST_REGEX_DETAIL_NS::get_icu_regex_traits_implementation(U_NAMESPACE_QUALIFIER Locale())) { } static size_type length(const char_type* p); ::boost::regex_constants::syntax_type syntax_type(char_type c)const { - return ((c < 0x7f) && (c > 0)) ? re_detail::get_default_syntax_type(static_cast<char>(c)) : regex_constants::syntax_char; + return ((c < 0x7f) && (c > 0)) ? BOOST_REGEX_DETAIL_NS::get_default_syntax_type(static_cast<char>(c)) : regex_constants::syntax_char; } ::boost::regex_constants::escape_syntax_type escape_syntax_type(char_type c) const { - return ((c < 0x7f) && (c > 0)) ? re_detail::get_default_escape_syntax_type(static_cast<char>(c)) : regex_constants::syntax_char; + return ((c < 0x7f) && (c > 0)) ? BOOST_REGEX_DETAIL_NS::get_default_escape_syntax_type(static_cast<char>(c)) : regex_constants::syntax_char; } char_type translate(char_type c) const { @@ -154,7 +154,7 @@ public: bool isctype(char_type c, char_class_type f) const; int toi(const char_type*& p1, const char_type* p2, int radix)const { - return re_detail::global_toi(p1, p2, radix, *this); + return BOOST_REGEX_DETAIL_NS::global_toi(p1, p2, radix, *this); } int value(char_type c, int radix)const { @@ -163,7 +163,7 @@ public: locale_type imbue(locale_type l) { locale_type result(m_pimpl->getloc()); - m_pimpl = re_detail::get_icu_regex_traits_implementation(l); + m_pimpl = BOOST_REGEX_DETAIL_NS::get_icu_regex_traits_implementation(l); return result; } locale_type getloc()const @@ -172,7 +172,7 @@ public: } std::string error_string(::boost::regex_constants::error_type n) const { - return re_detail::get_default_error_string(n); + return BOOST_REGEX_DETAIL_NS::get_default_error_string(n); } private: icu_regex_traits(const icu_regex_traits&); @@ -208,7 +208,7 @@ private: static char_class_type lookup_icu_mask(const ::UChar32* p1, const ::UChar32* p2); - boost::shared_ptr< ::boost::re_detail::icu_regex_traits_implementation> m_pimpl; + boost::shared_ptr< ::boost::BOOST_REGEX_DETAIL_NS::icu_regex_traits_implementation> m_pimpl; }; } // namespace boost @@ -241,7 +241,7 @@ typedef match_results<const ::UChar*> u16match; // // Construction of 32-bit regex types from UTF-8 and UTF-16 primitives: // -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ #if !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__) template <class InputIterator> @@ -341,18 +341,18 @@ inline u32regex make_u32regex(InputIterator i, InputIterator j, boost::regex_constants::syntax_option_type opt) { - return re_detail::do_make_u32regex(i, j, opt, static_cast<boost::mpl::int_<sizeof(*i)> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_make_u32regex(i, j, opt, static_cast<boost::mpl::int_<sizeof(*i)> const*>(0)); } // // construction from UTF-8 nul-terminated strings: // inline u32regex make_u32regex(const char* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) { - return re_detail::do_make_u32regex(p, p + std::strlen(p), opt, static_cast<boost::mpl::int_<1> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_make_u32regex(p, p + std::strlen(p), opt, static_cast<boost::mpl::int_<1> const*>(0)); } inline u32regex make_u32regex(const unsigned char* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) { - return re_detail::do_make_u32regex(p, p + std::strlen(reinterpret_cast<const char*>(p)), opt, static_cast<boost::mpl::int_<1> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_make_u32regex(p, p + std::strlen(reinterpret_cast<const char*>(p)), opt, static_cast<boost::mpl::int_<1> const*>(0)); } // // construction from UTF-16 nul-terminated strings: @@ -360,13 +360,13 @@ inline u32regex make_u32regex(const unsigned char* p, boost::regex_constants::sy #ifndef BOOST_NO_WREGEX inline u32regex make_u32regex(const wchar_t* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) { - return re_detail::do_make_u32regex(p, p + std::wcslen(p), opt, static_cast<boost::mpl::int_<sizeof(wchar_t)> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_make_u32regex(p, p + std::wcslen(p), opt, static_cast<boost::mpl::int_<sizeof(wchar_t)> const*>(0)); } #endif #if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) inline u32regex make_u32regex(const UChar* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) { - return re_detail::do_make_u32regex(p, p + u_strlen(p), opt, static_cast<boost::mpl::int_<2> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_make_u32regex(p, p + u_strlen(p), opt, static_cast<boost::mpl::int_<2> const*>(0)); } #endif // @@ -375,20 +375,20 @@ inline u32regex make_u32regex(const UChar* p, boost::regex_constants::syntax_opt template<class C, class T, class A> inline u32regex make_u32regex(const std::basic_string<C, T, A>& s, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) { - return re_detail::do_make_u32regex(s.begin(), s.end(), opt, static_cast<boost::mpl::int_<sizeof(C)> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_make_u32regex(s.begin(), s.end(), opt, static_cast<boost::mpl::int_<sizeof(C)> const*>(0)); } // // Construction from ICU string type: // inline u32regex make_u32regex(const U_NAMESPACE_QUALIFIER UnicodeString& s, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) { - return re_detail::do_make_u32regex(s.getBuffer(), s.getBuffer() + s.length(), opt, static_cast<boost::mpl::int_<2> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_make_u32regex(s.getBuffer(), s.getBuffer() + s.length(), opt, static_cast<boost::mpl::int_<2> const*>(0)); } // // regex_match overloads that widen the character type as appropriate: // -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ template<class MR1, class MR2> void copy_results(MR1& out, MR2 const& in) { @@ -446,7 +446,7 @@ bool do_regex_match(BidiIterator first, BidiIterator last, if(result) copy_results(m, what); return result; } -} // namespace re_detail +} // namespace BOOST_REGEX_DETAIL_NS template <class BidiIterator, class Allocator> inline bool u32regex_match(BidiIterator first, BidiIterator last, @@ -454,14 +454,14 @@ inline bool u32regex_match(BidiIterator first, BidiIterator last, const u32regex& e, match_flag_type flags = match_default) { - return re_detail::do_regex_match(first, last, m, e, flags, static_cast<mpl::int_<sizeof(*first)> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_match(first, last, m, e, flags, static_cast<mpl::int_<sizeof(*first)> const*>(0)); } inline bool u32regex_match(const UChar* p, match_results<const UChar*>& m, const u32regex& e, match_flag_type flags = match_default) { - return re_detail::do_regex_match(p, p+u_strlen(p), m, e, flags, static_cast<mpl::int_<2> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+u_strlen(p), m, e, flags, static_cast<mpl::int_<2> const*>(0)); } #if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) && !defined(BOOST_NO_WREGEX) inline bool u32regex_match(const wchar_t* p, @@ -469,7 +469,7 @@ inline bool u32regex_match(const wchar_t* p, const u32regex& e, match_flag_type flags = match_default) { - return re_detail::do_regex_match(p, p+std::wcslen(p), m, e, flags, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+std::wcslen(p), m, e, flags, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); } #endif inline bool u32regex_match(const char* p, @@ -477,21 +477,21 @@ inline bool u32regex_match(const char* p, const u32regex& e, match_flag_type flags = match_default) { - return re_detail::do_regex_match(p, p+std::strlen(p), m, e, flags, static_cast<mpl::int_<1> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+std::strlen(p), m, e, flags, static_cast<mpl::int_<1> const*>(0)); } inline bool u32regex_match(const unsigned char* p, match_results<const unsigned char*>& m, const u32regex& e, match_flag_type flags = match_default) { - return re_detail::do_regex_match(p, p+std::strlen((const char*)p), m, e, flags, static_cast<mpl::int_<1> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+std::strlen((const char*)p), m, e, flags, static_cast<mpl::int_<1> const*>(0)); } inline bool u32regex_match(const std::string& s, match_results<std::string::const_iterator>& m, const u32regex& e, match_flag_type flags = match_default) { - return re_detail::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<mpl::int_<1> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<mpl::int_<1> const*>(0)); } #ifndef BOOST_NO_STD_WSTRING inline bool u32regex_match(const std::wstring& s, @@ -499,7 +499,7 @@ inline bool u32regex_match(const std::wstring& s, const u32regex& e, match_flag_type flags = match_default) { - return re_detail::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); } #endif inline bool u32regex_match(const U_NAMESPACE_QUALIFIER UnicodeString& s, @@ -507,7 +507,7 @@ inline bool u32regex_match(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, match_flag_type flags = match_default) { - return re_detail::do_regex_match(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_match(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); } // // regex_match overloads that do not return what matched: @@ -518,14 +518,14 @@ inline bool u32regex_match(BidiIterator first, BidiIterator last, match_flag_type flags = match_default) { match_results<BidiIterator> m; - return re_detail::do_regex_match(first, last, m, e, flags, static_cast<mpl::int_<sizeof(*first)> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_match(first, last, m, e, flags, static_cast<mpl::int_<sizeof(*first)> const*>(0)); } inline bool u32regex_match(const UChar* p, const u32regex& e, match_flag_type flags = match_default) { match_results<const UChar*> m; - return re_detail::do_regex_match(p, p+u_strlen(p), m, e, flags, static_cast<mpl::int_<2> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+u_strlen(p), m, e, flags, static_cast<mpl::int_<2> const*>(0)); } #if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) && !defined(BOOST_NO_WREGEX) inline bool u32regex_match(const wchar_t* p, @@ -533,7 +533,7 @@ inline bool u32regex_match(const wchar_t* p, match_flag_type flags = match_default) { match_results<const wchar_t*> m; - return re_detail::do_regex_match(p, p+std::wcslen(p), m, e, flags, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+std::wcslen(p), m, e, flags, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); } #endif inline bool u32regex_match(const char* p, @@ -541,21 +541,21 @@ inline bool u32regex_match(const char* p, match_flag_type flags = match_default) { match_results<const char*> m; - return re_detail::do_regex_match(p, p+std::strlen(p), m, e, flags, static_cast<mpl::int_<1> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+std::strlen(p), m, e, flags, static_cast<mpl::int_<1> const*>(0)); } inline bool u32regex_match(const unsigned char* p, const u32regex& e, match_flag_type flags = match_default) { match_results<const unsigned char*> m; - return re_detail::do_regex_match(p, p+std::strlen((const char*)p), m, e, flags, static_cast<mpl::int_<1> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_match(p, p+std::strlen((const char*)p), m, e, flags, static_cast<mpl::int_<1> const*>(0)); } inline bool u32regex_match(const std::string& s, const u32regex& e, match_flag_type flags = match_default) { match_results<std::string::const_iterator> m; - return re_detail::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<mpl::int_<1> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<mpl::int_<1> const*>(0)); } #ifndef BOOST_NO_STD_WSTRING inline bool u32regex_match(const std::wstring& s, @@ -563,7 +563,7 @@ inline bool u32regex_match(const std::wstring& s, match_flag_type flags = match_default) { match_results<std::wstring::const_iterator> m; - return re_detail::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); } #endif inline bool u32regex_match(const U_NAMESPACE_QUALIFIER UnicodeString& s, @@ -571,13 +571,13 @@ inline bool u32regex_match(const U_NAMESPACE_QUALIFIER UnicodeString& s, match_flag_type flags = match_default) { match_results<const UChar*> m; - return re_detail::do_regex_match(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_match(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); } // // regex_search overloads that widen the character type as appropriate: // -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ template <class BidiIterator, class Allocator> inline bool do_regex_search(BidiIterator first, BidiIterator last, match_results<BidiIterator, Allocator>& m, @@ -630,7 +630,7 @@ inline bool u32regex_search(BidiIterator first, BidiIterator last, const u32regex& e, match_flag_type flags = match_default) { - return re_detail::do_regex_search(first, last, m, e, flags, first, static_cast<mpl::int_<sizeof(*first)> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_search(first, last, m, e, flags, first, static_cast<mpl::int_<sizeof(*first)> const*>(0)); } template <class BidiIterator, class Allocator> inline bool u32regex_search(BidiIterator first, BidiIterator last, @@ -639,14 +639,14 @@ inline bool u32regex_search(BidiIterator first, BidiIterator last, match_flag_type flags, BidiIterator base) { - return re_detail::do_regex_search(first, last, m, e, flags, base, static_cast<mpl::int_<sizeof(*first)> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_search(first, last, m, e, flags, base, static_cast<mpl::int_<sizeof(*first)> const*>(0)); } inline bool u32regex_search(const UChar* p, match_results<const UChar*>& m, const u32regex& e, match_flag_type flags = match_default) { - return re_detail::do_regex_search(p, p+u_strlen(p), m, e, flags, p, static_cast<mpl::int_<2> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+u_strlen(p), m, e, flags, p, static_cast<mpl::int_<2> const*>(0)); } #if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) && !defined(BOOST_NO_WREGEX) inline bool u32regex_search(const wchar_t* p, @@ -654,7 +654,7 @@ inline bool u32regex_search(const wchar_t* p, const u32regex& e, match_flag_type flags = match_default) { - return re_detail::do_regex_search(p, p+std::wcslen(p), m, e, flags, p, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+std::wcslen(p), m, e, flags, p, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); } #endif inline bool u32regex_search(const char* p, @@ -662,21 +662,21 @@ inline bool u32regex_search(const char* p, const u32regex& e, match_flag_type flags = match_default) { - return re_detail::do_regex_search(p, p+std::strlen(p), m, e, flags, p, static_cast<mpl::int_<1> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+std::strlen(p), m, e, flags, p, static_cast<mpl::int_<1> const*>(0)); } inline bool u32regex_search(const unsigned char* p, match_results<const unsigned char*>& m, const u32regex& e, match_flag_type flags = match_default) { - return re_detail::do_regex_search(p, p+std::strlen((const char*)p), m, e, flags, p, static_cast<mpl::int_<1> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+std::strlen((const char*)p), m, e, flags, p, static_cast<mpl::int_<1> const*>(0)); } inline bool u32regex_search(const std::string& s, match_results<std::string::const_iterator>& m, const u32regex& e, match_flag_type flags = match_default) { - return re_detail::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<mpl::int_<1> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<mpl::int_<1> const*>(0)); } #ifndef BOOST_NO_STD_WSTRING inline bool u32regex_search(const std::wstring& s, @@ -684,7 +684,7 @@ inline bool u32regex_search(const std::wstring& s, const u32regex& e, match_flag_type flags = match_default) { - return re_detail::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); } #endif inline bool u32regex_search(const U_NAMESPACE_QUALIFIER UnicodeString& s, @@ -692,7 +692,7 @@ inline bool u32regex_search(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, match_flag_type flags = match_default) { - return re_detail::do_regex_search(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, s.getBuffer(), static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_search(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, s.getBuffer(), static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); } template <class BidiIterator> inline bool u32regex_search(BidiIterator first, BidiIterator last, @@ -700,14 +700,14 @@ inline bool u32regex_search(BidiIterator first, BidiIterator last, match_flag_type flags = match_default) { match_results<BidiIterator> m; - return re_detail::do_regex_search(first, last, m, e, flags, first, static_cast<mpl::int_<sizeof(*first)> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_search(first, last, m, e, flags, first, static_cast<mpl::int_<sizeof(*first)> const*>(0)); } inline bool u32regex_search(const UChar* p, const u32regex& e, match_flag_type flags = match_default) { match_results<const UChar*> m; - return re_detail::do_regex_search(p, p+u_strlen(p), m, e, flags, p, static_cast<mpl::int_<2> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+u_strlen(p), m, e, flags, p, static_cast<mpl::int_<2> const*>(0)); } #if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) && !defined(BOOST_NO_WREGEX) inline bool u32regex_search(const wchar_t* p, @@ -715,7 +715,7 @@ inline bool u32regex_search(const wchar_t* p, match_flag_type flags = match_default) { match_results<const wchar_t*> m; - return re_detail::do_regex_search(p, p+std::wcslen(p), m, e, flags, p, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+std::wcslen(p), m, e, flags, p, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); } #endif inline bool u32regex_search(const char* p, @@ -723,21 +723,21 @@ inline bool u32regex_search(const char* p, match_flag_type flags = match_default) { match_results<const char*> m; - return re_detail::do_regex_search(p, p+std::strlen(p), m, e, flags, p, static_cast<mpl::int_<1> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+std::strlen(p), m, e, flags, p, static_cast<mpl::int_<1> const*>(0)); } inline bool u32regex_search(const unsigned char* p, const u32regex& e, match_flag_type flags = match_default) { match_results<const unsigned char*> m; - return re_detail::do_regex_search(p, p+std::strlen((const char*)p), m, e, flags, p, static_cast<mpl::int_<1> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_search(p, p+std::strlen((const char*)p), m, e, flags, p, static_cast<mpl::int_<1> const*>(0)); } inline bool u32regex_search(const std::string& s, const u32regex& e, match_flag_type flags = match_default) { match_results<std::string::const_iterator> m; - return re_detail::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<mpl::int_<1> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<mpl::int_<1> const*>(0)); } #ifndef BOOST_NO_STD_WSTRING inline bool u32regex_search(const std::wstring& s, @@ -745,7 +745,7 @@ inline bool u32regex_search(const std::wstring& s, match_flag_type flags = match_default) { match_results<std::wstring::const_iterator> m; - return re_detail::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); } #endif inline bool u32regex_search(const U_NAMESPACE_QUALIFIER UnicodeString& s, @@ -753,13 +753,13 @@ inline bool u32regex_search(const U_NAMESPACE_QUALIFIER UnicodeString& s, match_flag_type flags = match_default) { match_results<const UChar*> m; - return re_detail::do_regex_search(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, s.getBuffer(), static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_search(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, s.getBuffer(), static_cast<mpl::int_<sizeof(wchar_t)> const*>(0)); } // // overloads for regex_replace with utf-8 and utf-16 data types: // -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ template <class 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*) @@ -838,7 +838,7 @@ OutputIterator do_regex_replace(OutputIterator out, if(i == j) { if(!(flags & regex_constants::format_no_copy)) - out = re_detail::copy(in.first, in.second, out); + out = BOOST_REGEX_DETAIL_NS::copy(in.first, in.second, out); } else { @@ -846,18 +846,18 @@ OutputIterator do_regex_replace(OutputIterator out, while(i != j) { if(!(flags & regex_constants::format_no_copy)) - out = re_detail::copy(i->prefix().first, i->prefix().second, out); + out = BOOST_REGEX_DETAIL_NS::copy(i->prefix().first, i->prefix().second, out); if(f.size()) - out = ::boost::re_detail::regex_format_imp(out, *i, &*f.begin(), &*f.begin() + f.size(), flags, e.get_traits()); + out = ::boost::BOOST_REGEX_DETAIL_NS::regex_format_imp(out, *i, &*f.begin(), &*f.begin() + f.size(), flags, e.get_traits()); else - out = ::boost::re_detail::regex_format_imp(out, *i, static_cast<UChar32 const*>(0), static_cast<UChar32 const*>(0), flags, e.get_traits()); + out = ::boost::BOOST_REGEX_DETAIL_NS::regex_format_imp(out, *i, static_cast<UChar32 const*>(0), static_cast<UChar32 const*>(0), flags, e.get_traits()); last_m = (*i)[0].second; if(flags & regex_constants::format_first_only) break; ++i; } if(!(flags & regex_constants::format_no_copy)) - out = re_detail::copy(last_m, in.second, out); + out = BOOST_REGEX_DETAIL_NS::copy(last_m, in.second, out); } return out; } @@ -876,7 +876,7 @@ inline BaseIterator extract_output_base(const utf16_output_iterator<BaseIterator { return b.base(); } -} // re_detail +} // BOOST_REGEX_DETAIL_NS template <class OutputIterator, class BidirectionalIterator, class charT> inline OutputIterator u32regex_replace(OutputIterator out, @@ -886,13 +886,13 @@ inline OutputIterator u32regex_replace(OutputIterator out, const charT* fmt, match_flag_type flags = match_default) { - return re_detail::extract_output_base + return BOOST_REGEX_DETAIL_NS::extract_output_base ( - re_detail::do_regex_replace( - re_detail::make_utf32_out(out, static_cast<mpl::int_<sizeof(*first)> const*>(0)), - re_detail::make_utf32_seq(first, last, static_cast<mpl::int_<sizeof(*first)> const*>(0)), + BOOST_REGEX_DETAIL_NS::do_regex_replace( + BOOST_REGEX_DETAIL_NS::make_utf32_out(out, static_cast<mpl::int_<sizeof(*first)> const*>(0)), + BOOST_REGEX_DETAIL_NS::make_utf32_seq(first, last, static_cast<mpl::int_<sizeof(*first)> const*>(0)), e, - re_detail::make_utf32_seq(fmt, static_cast<mpl::int_<sizeof(*fmt)> const*>(0)), + BOOST_REGEX_DETAIL_NS::make_utf32_seq(fmt, static_cast<mpl::int_<sizeof(*fmt)> const*>(0)), flags) ); } @@ -905,13 +905,13 @@ inline OutputIterator u32regex_replace(OutputIterator out, const std::basic_string<charT>& fmt, match_flag_type flags = match_default) { - return re_detail::extract_output_base + return BOOST_REGEX_DETAIL_NS::extract_output_base ( - re_detail::do_regex_replace( - re_detail::make_utf32_out(out, static_cast<mpl::int_<sizeof(*first)> const*>(0)), - re_detail::make_utf32_seq(first, last, static_cast<mpl::int_<sizeof(*first)> const*>(0)), + BOOST_REGEX_DETAIL_NS::do_regex_replace( + BOOST_REGEX_DETAIL_NS::make_utf32_out(out, static_cast<mpl::int_<sizeof(*first)> const*>(0)), + BOOST_REGEX_DETAIL_NS::make_utf32_seq(first, last, static_cast<mpl::int_<sizeof(*first)> const*>(0)), e, - re_detail::make_utf32_seq(fmt.begin(), fmt.end(), static_cast<mpl::int_<sizeof(charT)> const*>(0)), + BOOST_REGEX_DETAIL_NS::make_utf32_seq(fmt.begin(), fmt.end(), static_cast<mpl::int_<sizeof(charT)> const*>(0)), flags) ); } @@ -924,13 +924,13 @@ inline OutputIterator u32regex_replace(OutputIterator out, const U_NAMESPACE_QUALIFIER UnicodeString& fmt, match_flag_type flags = match_default) { - return re_detail::extract_output_base + return BOOST_REGEX_DETAIL_NS::extract_output_base ( - re_detail::do_regex_replace( - re_detail::make_utf32_out(out, static_cast<mpl::int_<sizeof(*first)> const*>(0)), - re_detail::make_utf32_seq(first, last, static_cast<mpl::int_<sizeof(*first)> const*>(0)), + BOOST_REGEX_DETAIL_NS::do_regex_replace( + BOOST_REGEX_DETAIL_NS::make_utf32_out(out, static_cast<mpl::int_<sizeof(*first)> const*>(0)), + BOOST_REGEX_DETAIL_NS::make_utf32_seq(first, last, static_cast<mpl::int_<sizeof(*first)> const*>(0)), e, - re_detail::make_utf32_seq(fmt.getBuffer(), fmt.getBuffer() + fmt.length(), static_cast<mpl::int_<2> const*>(0)), + BOOST_REGEX_DETAIL_NS::make_utf32_seq(fmt.getBuffer(), fmt.getBuffer() + fmt.length(), static_cast<mpl::int_<2> const*>(0)), flags) ); } @@ -942,7 +942,7 @@ std::basic_string<charT> u32regex_replace(const std::basic_string<charT>& s, match_flag_type flags = match_default) { std::basic_string<charT> result; - re_detail::string_out_iterator<std::basic_string<charT> > i(result); + BOOST_REGEX_DETAIL_NS::string_out_iterator<std::basic_string<charT> > i(result); u32regex_replace(i, s.begin(), s.end(), e, fmt, flags); return result; } @@ -954,12 +954,12 @@ std::basic_string<charT> u32regex_replace(const std::basic_string<charT>& s, match_flag_type flags = match_default) { std::basic_string<charT> result; - re_detail::string_out_iterator<std::basic_string<charT> > i(result); + BOOST_REGEX_DETAIL_NS::string_out_iterator<std::basic_string<charT> > i(result); u32regex_replace(i, s.begin(), s.end(), e, fmt.c_str(), flags); return result; } -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ class unicode_string_out_iterator { @@ -989,7 +989,7 @@ inline U_NAMESPACE_QUALIFIER UnicodeString u32regex_replace(const U_NAMESPACE_QU match_flag_type flags = match_default) { U_NAMESPACE_QUALIFIER UnicodeString result; - re_detail::unicode_string_out_iterator i(result); + BOOST_REGEX_DETAIL_NS::unicode_string_out_iterator i(result); u32regex_replace(i, s.getBuffer(), s.getBuffer()+s.length(), e, fmt, flags); return result; } @@ -1000,12 +1000,12 @@ inline U_NAMESPACE_QUALIFIER UnicodeString u32regex_replace(const U_NAMESPACE_QU match_flag_type flags = match_default) { U_NAMESPACE_QUALIFIER UnicodeString result; - re_detail::unicode_string_out_iterator i(result); - re_detail::do_regex_replace( - re_detail::make_utf32_out(i, static_cast<mpl::int_<2> const*>(0)), - re_detail::make_utf32_seq(s.getBuffer(), s.getBuffer()+s.length(), static_cast<mpl::int_<2> const*>(0)), + BOOST_REGEX_DETAIL_NS::unicode_string_out_iterator i(result); + BOOST_REGEX_DETAIL_NS::do_regex_replace( + BOOST_REGEX_DETAIL_NS::make_utf32_out(i, static_cast<mpl::int_<2> const*>(0)), + BOOST_REGEX_DETAIL_NS::make_utf32_seq(s.getBuffer(), s.getBuffer()+s.length(), static_cast<mpl::int_<2> const*>(0)), e, - re_detail::make_utf32_seq(fmt.getBuffer(), fmt.getBuffer() + fmt.length(), static_cast<mpl::int_<2> const*>(0)), + BOOST_REGEX_DETAIL_NS::make_utf32_seq(fmt.getBuffer(), fmt.getBuffer() + fmt.length(), static_cast<mpl::int_<2> const*>(0)), flags); return result; } diff --git a/boost/regex/mfc.hpp b/boost/regex/mfc.hpp index 8ecaf1f5ba..d780673931 100644 --- a/boost/regex/mfc.hpp +++ b/boost/regex/mfc.hpp @@ -144,7 +144,7 @@ OutputIterator regex_replace(OutputIterator out, return ::boost::regex_replace(out, first, last, e, fmt.GetString(), flags); } -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ template <class B, bool b> class mfc_string_out_iterator @@ -176,7 +176,7 @@ ATL::CSimpleStringT<B, b> regex_replace(const ATL::CSimpleStringT<B, b>& s, match_flag_type flags = match_default) { ATL::CSimpleStringT<B, b> result(s.GetManager()); - re_detail::mfc_string_out_iterator<B, b> i(result); + BOOST_REGEX_DETAIL_NS::mfc_string_out_iterator<B, b> i(result); regex_replace(i, s.GetString(), s.GetString() + s.GetLength(), e, fmt.GetString(), flags); return result; } diff --git a/boost/regex/pattern_except.hpp b/boost/regex/pattern_except.hpp index 57ea14c256..004b67f3f2 100644 --- a/boost/regex/pattern_except.hpp +++ b/boost/regex/pattern_except.hpp @@ -63,7 +63,7 @@ private: typedef regex_error bad_pattern; typedef regex_error bad_expression; -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ BOOST_REGEX_DECL void BOOST_REGEX_CALL raise_runtime_error(const std::runtime_error& ex); @@ -72,7 +72,7 @@ void raise_error(const traits& t, regex_constants::error_type code) { (void)t; // warning suppression std::runtime_error e(t.error_string(code)); - ::boost::re_detail::raise_runtime_error(e); + ::boost::BOOST_REGEX_DETAIL_NS::raise_runtime_error(e); } } diff --git a/boost/regex/v4/basic_regex.hpp b/boost/regex/v4/basic_regex.hpp index ae86152286..ac91af2914 100644 --- a/boost/regex/v4/basic_regex.hpp +++ b/boost/regex/v4/basic_regex.hpp @@ -42,7 +42,7 @@ namespace boost{ #endif #endif -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ // // forward declaration, we will need this one later: @@ -164,9 +164,9 @@ struct regex_data : public named_subexpressions regex_data(const ::boost::shared_ptr< ::boost::regex_traits_wrapper<traits> >& t) - : m_ptraits(t), m_expression(0), m_expression_len(0) {} + : m_ptraits(t), m_expression(0), m_expression_len(0), m_disable_match_any(false) {} regex_data() - : m_ptraits(new ::boost::regex_traits_wrapper<traits>()), m_expression(0), m_expression_len(0) {} + : m_ptraits(new ::boost::regex_traits_wrapper<traits>()), m_expression(0), m_expression_len(0), m_disable_match_any(false) {} ::boost::shared_ptr< ::boost::regex_traits_wrapper<traits> @@ -176,16 +176,17 @@ struct regex_data : public named_subexpressions const charT* m_expression; // the original expression std::ptrdiff_t m_expression_len; // the length of the original expression size_type m_mark_count; // the number of marked sub-expressions - re_detail::re_syntax_base* m_first_state; // the first state of the machine + BOOST_REGEX_DETAIL_NS::re_syntax_base* m_first_state; // the first state of the machine unsigned m_restart_type; // search optimisation type unsigned char m_startmap[1 << CHAR_BIT]; // which characters can start a match unsigned int m_can_be_null; // whether we can match a null string - re_detail::raw_storage m_data; // the buffer in which our states are constructed + BOOST_REGEX_DETAIL_NS::raw_storage m_data; // the buffer in which our states are constructed typename traits::char_class_type m_word_mask; // mask used to determine if a character is a word character std::vector< std::pair< std::size_t, std::size_t> > m_subs; // Position of sub-expressions within the *string*. bool m_has_recursions; // whether we have recursive expressions; + bool m_disable_match_any; // when set we need to disable the match_any flag as it causes different/buggy behaviour. }; // // class basic_regex_implementation @@ -266,7 +267,7 @@ public: { return this->m_mark_count - 1; } - const re_detail::re_syntax_base* get_first_state()const + const BOOST_REGEX_DETAIL_NS::re_syntax_base* get_first_state()const { return this->m_first_state; } @@ -293,7 +294,7 @@ public: } }; -} // namespace re_detail +} // namespace BOOST_REGEX_DETAIL_NS // // class basic_regex: // represents the compiled @@ -597,7 +598,7 @@ public: // // private access methods: // - const re_detail::re_syntax_base* get_first_state()const + const BOOST_REGEX_DETAIL_NS::re_syntax_base* get_first_state()const { BOOST_ASSERT(0 != m_pimpl.get()); return m_pimpl->get_first_state(); @@ -622,18 +623,18 @@ public: BOOST_ASSERT(0 != m_pimpl.get()); return m_pimpl->can_be_null(); } - const re_detail::regex_data<charT, traits>& get_data()const + const BOOST_REGEX_DETAIL_NS::regex_data<charT, traits>& get_data()const { BOOST_ASSERT(0 != m_pimpl.get()); return m_pimpl->get_data(); } - boost::shared_ptr<re_detail::named_subexpressions > get_named_subs()const + boost::shared_ptr<BOOST_REGEX_DETAIL_NS::named_subexpressions > get_named_subs()const { return m_pimpl; } private: - shared_ptr<re_detail::basic_regex_implementation<charT, traits> > m_pimpl; + shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits> > m_pimpl; }; // @@ -647,14 +648,14 @@ basic_regex<charT, traits>& basic_regex<charT, traits>::do_assign(const charT* p const charT* p2, flag_type f) { - shared_ptr<re_detail::basic_regex_implementation<charT, traits> > temp; + shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits> > temp; if(!m_pimpl.get()) { - temp = shared_ptr<re_detail::basic_regex_implementation<charT, traits> >(new re_detail::basic_regex_implementation<charT, traits>()); + temp = shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits> >(new BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits>()); } else { - temp = shared_ptr<re_detail::basic_regex_implementation<charT, traits> >(new re_detail::basic_regex_implementation<charT, traits>(m_pimpl->m_ptraits)); + temp = shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits> >(new BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits>(m_pimpl->m_ptraits)); } temp->assign(p1, p2, f); temp.swap(m_pimpl); @@ -664,7 +665,7 @@ basic_regex<charT, traits>& basic_regex<charT, traits>::do_assign(const charT* p template <class charT, class traits> typename basic_regex<charT, traits>::locale_type BOOST_REGEX_CALL basic_regex<charT, traits>::imbue(locale_type l) { - shared_ptr<re_detail::basic_regex_implementation<charT, traits> > temp(new re_detail::basic_regex_implementation<charT, traits>()); + shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits> > temp(new BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits>()); locale_type result = temp->imbue(l); temp.swap(m_pimpl); return result; diff --git a/boost/regex/v4/basic_regex_creator.hpp b/boost/regex/v4/basic_regex_creator.hpp index 821fb8298c..51704a849f 100644 --- a/boost/regex/v4/basic_regex_creator.hpp +++ b/boost/regex/v4/basic_regex_creator.hpp @@ -38,7 +38,7 @@ namespace boost{ -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ template <class charT> struct digraph : public std::pair<charT, charT> @@ -371,9 +371,9 @@ re_syntax_base* basic_regex_creator<charT, traits>::append_set( // // fill in the basics: // - result->csingles = static_cast<unsigned int>(::boost::re_detail::distance(char_set.singles_begin(), char_set.singles_end())); - result->cranges = static_cast<unsigned int>(::boost::re_detail::distance(char_set.ranges_begin(), char_set.ranges_end())) / 2; - result->cequivalents = static_cast<unsigned int>(::boost::re_detail::distance(char_set.equivalents_begin(), char_set.equivalents_end())); + result->csingles = static_cast<unsigned int>(::boost::BOOST_REGEX_DETAIL_NS::distance(char_set.singles_begin(), char_set.singles_end())); + result->cranges = static_cast<unsigned int>(::boost::BOOST_REGEX_DETAIL_NS::distance(char_set.ranges_begin(), char_set.ranges_end())) / 2; + result->cequivalents = static_cast<unsigned int>(::boost::BOOST_REGEX_DETAIL_NS::distance(char_set.equivalents_begin(), char_set.equivalents_end())); result->cclasses = char_set.classes(); result->cnclasses = char_set.negated_classes(); if(flags() & regbase::icase) @@ -463,10 +463,10 @@ re_syntax_base* basic_regex_creator<charT, traits>::append_set( return 0; } charT* p = static_cast<charT*>(this->m_pdata->m_data.extend(sizeof(charT) * (s1.size() + s2.size() + 2) ) ); - re_detail::copy(s1.begin(), s1.end(), p); + BOOST_REGEX_DETAIL_NS::copy(s1.begin(), s1.end(), p); p[s1.size()] = charT(0); p += s1.size() + 1; - re_detail::copy(s2.begin(), s2.end(), p); + BOOST_REGEX_DETAIL_NS::copy(s2.begin(), s2.end(), p); p[s2.size()] = charT(0); } // @@ -487,7 +487,7 @@ re_syntax_base* basic_regex_creator<charT, traits>::append_set( if(s.empty()) return 0; // invalid or unsupported equivalence class charT* p = static_cast<charT*>(this->m_pdata->m_data.extend(sizeof(charT) * (s.size()+1) ) ); - re_detail::copy(s.begin(), s.end(), p); + BOOST_REGEX_DETAIL_NS::copy(s.begin(), s.end(), p); p[s.size()] = charT(0); ++first; } @@ -664,7 +664,7 @@ void basic_regex_creator<charT, traits>::finalize(const charT* p1, const charT* m_pdata->m_expression_len = len; charT* ps = static_cast<charT*>(m_pdata->m_data.extend(sizeof(charT) * (1 + (p2 - p1)))); m_pdata->m_expression = ps; - re_detail::copy(p1, p2, ps); + BOOST_REGEX_DETAIL_NS::copy(p1, p2, ps); ps[p2 - p1] = 0; // fill in our other data... // successful parsing implies a zero status: @@ -1149,6 +1149,7 @@ void basic_regex_creator<charT, traits>::create_startmap(re_syntax_base* state, set_all_masks(l_map, mask); return; } + case syntax_element_accept: case syntax_element_match: { // must be null, any character can match: @@ -1335,6 +1336,11 @@ void basic_regex_creator<charT, traits>::create_startmap(re_syntax_base* state, state = state->next.p; break; + case syntax_element_commit: + set_all_masks(l_map, mask); + // Continue scanning so we can figure out whether we can be null: + state = state->next.p; + break; case syntax_element_startmark: // need to handle independent subs as a special case: if(static_cast<re_brace*>(state)->index == -3) @@ -1456,15 +1462,15 @@ syntax_element_type basic_regex_creator<charT, traits>::get_repeat_type(re_synta { switch(state->next.p->type) { - case re_detail::syntax_element_wild: - return re_detail::syntax_element_dot_rep; - case re_detail::syntax_element_literal: - return re_detail::syntax_element_char_rep; - case re_detail::syntax_element_set: - return re_detail::syntax_element_short_set_rep; - case re_detail::syntax_element_long_set: - if(static_cast<re_detail::re_set_long<m_type>*>(state->next.p)->singleton) - return re_detail::syntax_element_long_set_rep; + case BOOST_REGEX_DETAIL_NS::syntax_element_wild: + return BOOST_REGEX_DETAIL_NS::syntax_element_dot_rep; + case BOOST_REGEX_DETAIL_NS::syntax_element_literal: + return BOOST_REGEX_DETAIL_NS::syntax_element_char_rep; + case BOOST_REGEX_DETAIL_NS::syntax_element_set: + return BOOST_REGEX_DETAIL_NS::syntax_element_short_set_rep; + case BOOST_REGEX_DETAIL_NS::syntax_element_long_set: + if(static_cast<BOOST_REGEX_DETAIL_NS::re_set_long<m_type>*>(state->next.p)->singleton) + return BOOST_REGEX_DETAIL_NS::syntax_element_long_set_rep; break; default: break; @@ -1529,7 +1535,7 @@ void basic_regex_creator<charT, traits>::probe_leading_repeat(re_syntax_base* st } -} // namespace re_detail +} // namespace BOOST_REGEX_DETAIL_NS } // namespace boost diff --git a/boost/regex/v4/basic_regex_parser.hpp b/boost/regex/v4/basic_regex_parser.hpp index 3c331a57c4..4a80ab9c32 100644 --- a/boost/regex/v4/basic_regex_parser.hpp +++ b/boost/regex/v4/basic_regex_parser.hpp @@ -31,7 +31,7 @@ #endif namespace boost{ -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ #ifdef BOOST_MSVC #pragma warning(push) @@ -68,6 +68,8 @@ public: bool parse_inner_set(basic_char_set<charT, traits>& char_set); bool parse_QE(); bool parse_perl_extension(); + bool parse_perl_verb(); + bool match_verb(const char*); bool add_emacs_code(bool negate); bool unwind_alts(std::ptrdiff_t last_paren_start); digraph<charT> get_next_set_literal(basic_char_set<charT, traits>& char_set); @@ -165,7 +167,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), "Found a closing ) with no corresponding openening parenthesis."); + fail(regex_constants::error_paren, ::boost::BOOST_REGEX_DETAIL_NS::distance(m_base, m_position), "Found a closing ) with no corresponding openening parenthesis."); return; } // if an error has been set then give up now: @@ -421,6 +423,8 @@ bool basic_regex_parser<charT, traits>::parse_open_paren() { if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_question) return parse_perl_extension(); + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_star) + return parse_perl_verb(); } // // update our mark count, and append the required state: @@ -489,7 +493,7 @@ bool basic_regex_parser<charT, traits>::parse_open_paren() // if(m_position == m_end) { - this->fail(regex_constants::error_paren, ::boost::re_detail::distance(m_base, m_end)); + this->fail(regex_constants::error_paren, ::boost::BOOST_REGEX_DETAIL_NS::distance(m_base, m_end)); return false; } BOOST_ASSERT(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_mark); @@ -924,9 +928,9 @@ bool basic_regex_parser<charT, traits>::parse_match_any() static_cast<re_dot*>( this->append_state(syntax_element_wild, sizeof(re_dot)) )->mask = static_cast<unsigned char>(this->flags() & regbase::no_mod_s - ? re_detail::force_not_newline + ? BOOST_REGEX_DETAIL_NS::force_not_newline : this->flags() & regbase::mod_s ? - re_detail::force_newline : re_detail::dont_care); + BOOST_REGEX_DETAIL_NS::force_newline : BOOST_REGEX_DETAIL_NS::dont_care); return true; } @@ -963,7 +967,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), "Nothing to repeat."); + fail(regex_constants::error_badrepeat, ::boost::BOOST_REGEX_DETAIL_NS::distance(m_base, m_position), "Nothing to repeat."); return false; } if(this->m_last_state->type == syntax_element_endmark) @@ -1235,7 +1239,7 @@ bool basic_regex_parser<charT, traits>::parse_alt() // // we need to append a trailing jump: // - re_syntax_base* pj = this->append_state(re_detail::syntax_element_jump, sizeof(re_jump)); + re_syntax_base* pj = this->append_state(BOOST_REGEX_DETAIL_NS::syntax_element_jump, sizeof(re_jump)); std::ptrdiff_t jump_offset = this->getoffset(pj); // // now insert the alternative: @@ -1784,7 +1788,7 @@ charT basic_regex_parser<charT, traits>::unescape_character() { // an octal escape sequence, the first character must be a zero // followed by up to 3 octal digits: - std::ptrdiff_t len = (std::min)(::boost::re_detail::distance(m_position, m_end), static_cast<std::ptrdiff_t>(4)); + std::ptrdiff_t len = (std::min)(::boost::BOOST_REGEX_DETAIL_NS::distance(m_position, m_end), static_cast<std::ptrdiff_t>(4)); const charT* bp = m_position; int val = this->m_traits.toi(bp, bp + 1, 8); if(val != 0) @@ -2521,7 +2525,7 @@ option_group_jump: // 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)); + this->fail(regex_constants::error_paren, ::boost::BOOST_REGEX_DETAIL_NS::distance(m_base, m_end)); return false; } BOOST_ASSERT(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_mark); @@ -2653,6 +2657,194 @@ option_group_jump: } template <class charT, class traits> +bool basic_regex_parser<charT, traits>::match_verb(const char* verb) +{ + while(*verb) + { + if(static_cast<charT>(*verb) != *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) + { + --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; + } + ++verb; + } + return true; +} + +template <class charT, class traits> +bool basic_regex_parser<charT, traits>::parse_perl_verb() +{ + 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; + } + switch(*m_position) + { + case 'F': + 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; + } + if((this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_mark) || match_verb("AIL")) + { + if((m_position == m_end) || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark)) + { + // 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; + this->append_state(syntax_element_fail); + return true; + } + break; + case 'A': + 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; + } + if(match_verb("CCEPT")) + { + if((m_position == m_end) || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark)) + { + // 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; + this->append_state(syntax_element_accept); + return true; + } + break; + case 'C': + 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; + } + if(match_verb("OMMIT")) + { + if((m_position == m_end) || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark)) + { + // 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; + static_cast<re_commit*>(this->append_state(syntax_element_commit, sizeof(re_commit)))->action = commit_commit; + this->m_pdata->m_disable_match_any = true; + return true; + } + break; + case 'P': + 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; + } + if(match_verb("RUNE")) + { + if((m_position == m_end) || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark)) + { + // 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; + static_cast<re_commit*>(this->append_state(syntax_element_commit, sizeof(re_commit)))->action = commit_prune; + this->m_pdata->m_disable_match_any = true; + return true; + } + break; + case 'S': + 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; + } + if(match_verb("KIP")) + { + if((m_position == m_end) || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark)) + { + // 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; + static_cast<re_commit*>(this->append_state(syntax_element_commit, sizeof(re_commit)))->action = commit_skip; + this->m_pdata->m_disable_match_any = true; + return true; + } + break; + case 'T': + 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; + } + if(match_verb("HEN")) + { + if((m_position == m_end) || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark)) + { + // 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; + this->append_state(syntax_element_then); + this->m_pdata->m_disable_match_any = true; + return true; + } + break; + } + return false; +} + +template <class charT, class traits> bool basic_regex_parser<charT, traits>::add_emacs_code(bool negate) { // @@ -2862,7 +3054,7 @@ bool basic_regex_parser<charT, traits>::unwind_alts(std::ptrdiff_t last_paren_st #pragma warning(pop) #endif -} // namespace re_detail +} // namespace BOOST_REGEX_DETAIL_NS } // namespace boost #ifdef BOOST_MSVC diff --git a/boost/regex/v4/cpp_regex_traits.hpp b/boost/regex/v4/cpp_regex_traits.hpp index 106ffcbfc2..709663a385 100644 --- a/boost/regex/v4/cpp_regex_traits.hpp +++ b/boost/regex/v4/cpp_regex_traits.hpp @@ -69,7 +69,7 @@ namespace boost{ template <class charT> class cpp_regex_traits; -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ // // class parser_buf: @@ -290,7 +290,7 @@ void cpp_regex_traits_char_layer<charT>::init() { std::string m("Unable to open message catalog: "); std::runtime_error err(m + cat_name); - boost::re_detail::raise_runtime_error(err); + boost::BOOST_REGEX_DETAIL_NS::raise_runtime_error(err); } } // @@ -415,8 +415,9 @@ template <class charT> class cpp_regex_traits_implementation : public cpp_regex_traits_char_layer<charT> { public: - typedef typename cpp_regex_traits<charT>::char_class_type char_class_type; - typedef typename std::ctype<charT>::mask native_mask_type; + typedef typename cpp_regex_traits<charT>::char_class_type char_class_type; + typedef typename std::ctype<charT>::mask native_mask_type; + typedef typename boost::make_unsigned<native_mask_type>::type unsigned_native_mask_type; #ifndef BOOST_REGEX_BUGGY_CTYPE_FACET BOOST_STATIC_CONSTANT(char_class_type, mask_blank = 1u << 24); BOOST_STATIC_CONSTANT(char_class_type, mask_word = 1u << 25); @@ -717,7 +718,7 @@ void cpp_regex_traits_implementation<charT>::init() { std::string m("Unable to open message catalog: "); std::runtime_error err(m + cat_name); - boost::re_detail::raise_runtime_error(err); + boost::BOOST_REGEX_DETAIL_NS::raise_runtime_error(err); } } // @@ -753,19 +754,19 @@ void cpp_regex_traits_implementation<charT>::init() #ifndef BOOST_REGEX_BUGGY_CTYPE_FACET static const char_class_type masks[16] = { - std::ctype<charT>::alnum, - std::ctype<charT>::alpha, - std::ctype<charT>::cntrl, - std::ctype<charT>::digit, - std::ctype<charT>::graph, + static_cast<unsigned_native_mask_type>(std::ctype<charT>::alnum), + static_cast<unsigned_native_mask_type>(std::ctype<charT>::alpha), + static_cast<unsigned_native_mask_type>(std::ctype<charT>::cntrl), + static_cast<unsigned_native_mask_type>(std::ctype<charT>::digit), + static_cast<unsigned_native_mask_type>(std::ctype<charT>::graph), cpp_regex_traits_implementation<charT>::mask_horizontal, - std::ctype<charT>::lower, - std::ctype<charT>::print, - std::ctype<charT>::punct, - std::ctype<charT>::space, - std::ctype<charT>::upper, + static_cast<unsigned_native_mask_type>(std::ctype<charT>::lower), + static_cast<unsigned_native_mask_type>(std::ctype<charT>::print), + static_cast<unsigned_native_mask_type>(std::ctype<charT>::punct), + static_cast<unsigned_native_mask_type>(std::ctype<charT>::space), + static_cast<unsigned_native_mask_type>(std::ctype<charT>::upper), cpp_regex_traits_implementation<charT>::mask_vertical, - std::ctype<charT>::xdigit, + static_cast<unsigned_native_mask_type>(std::ctype<charT>::xdigit), cpp_regex_traits_implementation<charT>::mask_blank, cpp_regex_traits_implementation<charT>::mask_word, cpp_regex_traits_implementation<charT>::mask_unicode, @@ -773,22 +774,22 @@ void cpp_regex_traits_implementation<charT>::init() #else static const char_class_type masks[16] = { - ::boost::re_detail::char_class_alnum, - ::boost::re_detail::char_class_alpha, - ::boost::re_detail::char_class_cntrl, - ::boost::re_detail::char_class_digit, - ::boost::re_detail::char_class_graph, - ::boost::re_detail::char_class_horizontal_space, - ::boost::re_detail::char_class_lower, - ::boost::re_detail::char_class_print, - ::boost::re_detail::char_class_punct, - ::boost::re_detail::char_class_space, - ::boost::re_detail::char_class_upper, - ::boost::re_detail::char_class_vertical_space, - ::boost::re_detail::char_class_xdigit, - ::boost::re_detail::char_class_blank, - ::boost::re_detail::char_class_word, - ::boost::re_detail::char_class_unicode, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_alnum, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_alpha, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_cntrl, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_digit, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_graph, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_horizontal_space, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_lower, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_print, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_punct, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_space, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_upper, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_vertical_space, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_xdigit, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_blank, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_word, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_unicode, }; #endif static const string_type null_string; @@ -803,7 +804,7 @@ void cpp_regex_traits_implementation<charT>::init() // // get the collation format used by m_pcollate: // - m_collate_type = re_detail::find_sort_syntax(this, &m_collate_delim); + m_collate_type = BOOST_REGEX_DETAIL_NS::find_sort_syntax(this, &m_collate_delim); } template <class charT> @@ -814,53 +815,53 @@ typename cpp_regex_traits_implementation<charT>::char_class_type static const char_class_type masks[22] = { 0, - std::ctype<char>::alnum, - std::ctype<char>::alpha, + static_cast<unsigned_native_mask_type>(std::ctype<char>::alnum), + static_cast<unsigned_native_mask_type>(std::ctype<char>::alpha), cpp_regex_traits_implementation<charT>::mask_blank, - std::ctype<char>::cntrl, - std::ctype<char>::digit, - std::ctype<char>::digit, - std::ctype<char>::graph, + static_cast<unsigned_native_mask_type>(std::ctype<char>::cntrl), + static_cast<unsigned_native_mask_type>(std::ctype<char>::digit), + static_cast<unsigned_native_mask_type>(std::ctype<char>::digit), + static_cast<unsigned_native_mask_type>(std::ctype<char>::graph), cpp_regex_traits_implementation<charT>::mask_horizontal, - std::ctype<char>::lower, - std::ctype<char>::lower, - std::ctype<char>::print, - std::ctype<char>::punct, - std::ctype<char>::space, - std::ctype<char>::space, - std::ctype<char>::upper, + static_cast<unsigned_native_mask_type>(std::ctype<char>::lower), + static_cast<unsigned_native_mask_type>(std::ctype<char>::lower), + static_cast<unsigned_native_mask_type>(std::ctype<char>::print), + static_cast<unsigned_native_mask_type>(std::ctype<char>::punct), + static_cast<unsigned_native_mask_type>(std::ctype<char>::space), + static_cast<unsigned_native_mask_type>(std::ctype<char>::space), + static_cast<unsigned_native_mask_type>(std::ctype<char>::upper), cpp_regex_traits_implementation<charT>::mask_unicode, - std::ctype<char>::upper, + static_cast<unsigned_native_mask_type>(std::ctype<char>::upper), cpp_regex_traits_implementation<charT>::mask_vertical, - std::ctype<char>::alnum | cpp_regex_traits_implementation<charT>::mask_word, - std::ctype<char>::alnum | cpp_regex_traits_implementation<charT>::mask_word, - std::ctype<char>::xdigit, + static_cast<unsigned_native_mask_type>(std::ctype<char>::alnum) | cpp_regex_traits_implementation<charT>::mask_word, + static_cast<unsigned_native_mask_type>(std::ctype<char>::alnum) | cpp_regex_traits_implementation<charT>::mask_word, + static_cast<unsigned_native_mask_type>(std::ctype<char>::xdigit), }; #else static const char_class_type masks[22] = { 0, - ::boost::re_detail::char_class_alnum, - ::boost::re_detail::char_class_alpha, - ::boost::re_detail::char_class_blank, - ::boost::re_detail::char_class_cntrl, - ::boost::re_detail::char_class_digit, - ::boost::re_detail::char_class_digit, - ::boost::re_detail::char_class_graph, - ::boost::re_detail::char_class_horizontal_space, - ::boost::re_detail::char_class_lower, - ::boost::re_detail::char_class_lower, - ::boost::re_detail::char_class_print, - ::boost::re_detail::char_class_punct, - ::boost::re_detail::char_class_space, - ::boost::re_detail::char_class_space, - ::boost::re_detail::char_class_upper, - ::boost::re_detail::char_class_unicode, - ::boost::re_detail::char_class_upper, - ::boost::re_detail::char_class_vertical_space, - ::boost::re_detail::char_class_alnum | ::boost::re_detail::char_class_word, - ::boost::re_detail::char_class_alnum | ::boost::re_detail::char_class_word, - ::boost::re_detail::char_class_xdigit, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_alnum, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_alpha, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_blank, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_cntrl, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_digit, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_digit, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_graph, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_horizontal_space, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_lower, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_lower, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_print, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_punct, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_space, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_space, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_upper, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_unicode, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_upper, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_vertical_space, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_alnum | ::boost::BOOST_REGEX_DETAIL_NS::char_class_word, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_alnum | ::boost::BOOST_REGEX_DETAIL_NS::char_class_word, + ::boost::BOOST_REGEX_DETAIL_NS::char_class_xdigit, }; #endif if(m_custom_class_names.size()) @@ -870,7 +871,7 @@ typename cpp_regex_traits_implementation<charT>::char_class_type if(pos != m_custom_class_names.end()) return pos->second; } - std::size_t state_id = 1 + re_detail::get_default_class_id(p1, p2); + std::size_t state_id = 1 + BOOST_REGEX_DETAIL_NS::get_default_class_id(p1, p2); BOOST_ASSERT(state_id < sizeof(masks) / sizeof(masks[0])); return masks[state_id]; } @@ -880,20 +881,20 @@ template <class charT> bool cpp_regex_traits_implementation<charT>::isctype(const charT c, char_class_type mask) const { return - ((mask & ::boost::re_detail::char_class_space) && (this->m_pctype->is(std::ctype<charT>::space, c))) - || ((mask & ::boost::re_detail::char_class_print) && (this->m_pctype->is(std::ctype<charT>::print, c))) - || ((mask & ::boost::re_detail::char_class_cntrl) && (this->m_pctype->is(std::ctype<charT>::cntrl, c))) - || ((mask & ::boost::re_detail::char_class_upper) && (this->m_pctype->is(std::ctype<charT>::upper, c))) - || ((mask & ::boost::re_detail::char_class_lower) && (this->m_pctype->is(std::ctype<charT>::lower, c))) - || ((mask & ::boost::re_detail::char_class_alpha) && (this->m_pctype->is(std::ctype<charT>::alpha, c))) - || ((mask & ::boost::re_detail::char_class_digit) && (this->m_pctype->is(std::ctype<charT>::digit, c))) - || ((mask & ::boost::re_detail::char_class_punct) && (this->m_pctype->is(std::ctype<charT>::punct, c))) - || ((mask & ::boost::re_detail::char_class_xdigit) && (this->m_pctype->is(std::ctype<charT>::xdigit, c))) - || ((mask & ::boost::re_detail::char_class_blank) && (this->m_pctype->is(std::ctype<charT>::space, c)) && !::boost::re_detail::is_separator(c)) - || ((mask & ::boost::re_detail::char_class_word) && (c == '_')) - || ((mask & ::boost::re_detail::char_class_unicode) && ::boost::re_detail::is_extended(c)) - || ((mask & ::boost::re_detail::char_class_vertical_space) && (is_separator(c) || (c == '\v'))) - || ((mask & ::boost::re_detail::char_class_horizontal_space) && this->m_pctype->is(std::ctype<charT>::space, c) && !(is_separator(c) || (c == '\v'))); + ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_space) && (this->m_pctype->is(std::ctype<charT>::space, c))) + || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_print) && (this->m_pctype->is(std::ctype<charT>::print, c))) + || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_cntrl) && (this->m_pctype->is(std::ctype<charT>::cntrl, c))) + || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_upper) && (this->m_pctype->is(std::ctype<charT>::upper, c))) + || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_lower) && (this->m_pctype->is(std::ctype<charT>::lower, c))) + || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_alpha) && (this->m_pctype->is(std::ctype<charT>::alpha, c))) + || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_digit) && (this->m_pctype->is(std::ctype<charT>::digit, c))) + || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_punct) && (this->m_pctype->is(std::ctype<charT>::punct, c))) + || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_xdigit) && (this->m_pctype->is(std::ctype<charT>::xdigit, c))) + || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_blank) && (this->m_pctype->is(std::ctype<charT>::space, c)) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c)) + || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_word) && (c == '_')) + || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_unicode) && ::boost::BOOST_REGEX_DETAIL_NS::is_extended(c)) + || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_vertical_space) && (is_separator(c) || (c == '\v'))) + || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_horizontal_space) && this->m_pctype->is(std::ctype<charT>::space, c) && !(is_separator(c) || (c == '\v'))); } #endif @@ -905,7 +906,7 @@ inline boost::shared_ptr<const cpp_regex_traits_implementation<charT> > create_c return ::boost::object_cache<cpp_regex_traits_base<charT>, cpp_regex_traits_implementation<charT> >::get(key, 5); } -} // re_detail +} // BOOST_REGEX_DETAIL_NS template <class charT> class cpp_regex_traits @@ -922,7 +923,7 @@ public: struct boost_extensions_tag{}; cpp_regex_traits() - : m_pimpl(re_detail::create_cpp_regex_traits<charT>(std::locale())) + : m_pimpl(BOOST_REGEX_DETAIL_NS::create_cpp_regex_traits<charT>(std::locale())) { } static size_type length(const char_type* p) { @@ -995,20 +996,32 @@ public: && (m_pimpl->m_pctype->is( static_cast<ctype_mask>(f & mask_base), c))) return true; - else if((f & re_detail::cpp_regex_traits_implementation<charT>::mask_unicode) && re_detail::is_extended(c)) + else if((f & BOOST_REGEX_DETAIL_NS::cpp_regex_traits_implementation<charT>::mask_unicode) && BOOST_REGEX_DETAIL_NS::is_extended(c)) return true; - else if((f & re_detail::cpp_regex_traits_implementation<charT>::mask_word) && (c == '_')) + else if((f & BOOST_REGEX_DETAIL_NS::cpp_regex_traits_implementation<charT>::mask_word) && (c == '_')) return true; - else if((f & re_detail::cpp_regex_traits_implementation<charT>::mask_blank) + else if((f & BOOST_REGEX_DETAIL_NS::cpp_regex_traits_implementation<charT>::mask_blank) && m_pimpl->m_pctype->is(std::ctype<charT>::space, c) - && !re_detail::is_separator(c)) + && !BOOST_REGEX_DETAIL_NS::is_separator(c)) return true; - else if((f & re_detail::cpp_regex_traits_implementation<charT>::mask_vertical) - && (::boost::re_detail::is_separator(c) || (c == '\v'))) + else if((f & BOOST_REGEX_DETAIL_NS::cpp_regex_traits_implementation<charT>::mask_vertical) + && (::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) || (c == '\v'))) return true; - else if((f & re_detail::cpp_regex_traits_implementation<charT>::mask_horizontal) - && this->isctype(c, std::ctype<charT>::space) && !this->isctype(c, re_detail::cpp_regex_traits_implementation<charT>::mask_vertical)) + else if((f & BOOST_REGEX_DETAIL_NS::cpp_regex_traits_implementation<charT>::mask_horizontal) + && this->isctype(c, std::ctype<charT>::space) && !this->isctype(c, BOOST_REGEX_DETAIL_NS::cpp_regex_traits_implementation<charT>::mask_vertical)) return true; +#ifdef __CYGWIN__ + // + // Cygwin has a buggy ctype facet, see https://www.cygwin.com/ml/cygwin/2012-08/msg00178.html: + // + else if((f & std::ctype<charT>::xdigit) == std::ctype<charT>::xdigit) + { + if((c >= 'a') && (c <= 'f')) + return true; + if((c >= 'A') && (c <= 'F')) + return true; + } +#endif return false; #else return m_pimpl->isctype(c, f); @@ -1023,7 +1036,7 @@ public: locale_type imbue(locale_type l) { std::locale result(getloc()); - m_pimpl = re_detail::create_cpp_regex_traits<charT>(l); + m_pimpl = BOOST_REGEX_DETAIL_NS::create_cpp_regex_traits<charT>(l); return result; } locale_type getloc()const @@ -1043,7 +1056,7 @@ public: static std::string get_catalog_name(); private: - boost::shared_ptr<const re_detail::cpp_regex_traits_implementation<charT> > m_pimpl; + boost::shared_ptr<const BOOST_REGEX_DETAIL_NS::cpp_regex_traits_implementation<charT> > m_pimpl; // // catalog name handler: // @@ -1058,7 +1071,7 @@ private: template <class charT> int cpp_regex_traits<charT>::toi(const charT*& first, const charT* last, int radix)const { - re_detail::parser_buf<charT> sbuf; // buffer for parsing numbers. + BOOST_REGEX_DETAIL_NS::parser_buf<charT> sbuf; // buffer for parsing numbers. std::basic_istream<charT> is(&sbuf); // stream for parsing numbers. // we do NOT want to parse any thousands separators inside the stream: diff --git a/boost/regex/v4/cregex.hpp b/boost/regex/v4/cregex.hpp index 7b3df1e510..67abfbee19 100644 --- a/boost/regex/v4/cregex.hpp +++ b/boost/regex/v4/cregex.hpp @@ -221,7 +221,7 @@ namespace boost{ class RegEx; -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ class RegExData; struct pred1; @@ -229,7 +229,7 @@ struct pred2; struct pred3; struct pred4; -} /* namespace re_detail */ +} /* namespace BOOST_REGEX_DETAIL_NS */ #if (defined(BOOST_MSVC) || defined(__BORLANDC__)) && !defined(BOOST_DISABLE_WIN32) typedef bool (__cdecl *GrepCallback)(const RegEx& expression); @@ -244,7 +244,7 @@ typedef bool (*FindFilesCallback)(const char* file); class BOOST_REGEX_DECL RegEx { private: - re_detail::RegExData* pdata; + BOOST_REGEX_DETAIL_NS::RegExData* pdata; public: RegEx(); RegEx(const RegEx& o); @@ -296,10 +296,10 @@ public: static const std::size_t npos; - friend struct re_detail::pred1; - friend struct re_detail::pred2; - friend struct re_detail::pred3; - friend struct re_detail::pred4; + friend struct BOOST_REGEX_DETAIL_NS::pred1; + friend struct BOOST_REGEX_DETAIL_NS::pred2; + friend struct BOOST_REGEX_DETAIL_NS::pred3; + friend struct BOOST_REGEX_DETAIL_NS::pred4; }; #ifdef BOOST_MSVC diff --git a/boost/regex/v4/fileiter.hpp b/boost/regex/v4/fileiter.hpp index f13c4b2fb7..4873a0a85e 100644 --- a/boost/regex/v4/fileiter.hpp +++ b/boost/regex/v4/fileiter.hpp @@ -49,7 +49,7 @@ #include <cstddef> namespace boost{ - namespace re_detail{ + namespace BOOST_REGEX_DETAIL_NS{ #ifndef BOOST_NO_ANSI_APIS typedef WIN32_FIND_DATAA _fi_find_data; @@ -58,7 +58,7 @@ typedef WIN32_FIND_DATAW _fi_find_data; #endif typedef HANDLE _fi_find_handle; - } // namespace re_detail + } // namespace BOOST_REGEX_DETAIL_NS } // namespace boost @@ -84,7 +84,7 @@ using std::list; #endif namespace boost{ - namespace re_detail{ + namespace BOOST_REGEX_DETAIL_NS{ #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX @@ -110,7 +110,7 @@ bool _fi_FindClose(_fi_find_handle hFindFile); # include BOOST_ABI_SUFFIX #endif - } // namespace re_detail + } // namespace BOOST_REGEX_DETAIL_NS } // namespace boost #ifdef FindFirstFile @@ -130,7 +130,7 @@ bool _fi_FindClose(_fi_find_handle hFindFile); #endif namespace boost{ - namespace re_detail{ + namespace BOOST_REGEX_DETAIL_NS{ #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX @@ -427,10 +427,10 @@ inline bool operator < (const directory_iterator&, const directory_iterator&) #endif -} // namespace re_detail -using boost::re_detail::directory_iterator; -using boost::re_detail::file_iterator; -using boost::re_detail::mapfile; +} // namespace BOOST_REGEX_DETAIL_NS +using boost::BOOST_REGEX_DETAIL_NS::directory_iterator; +using boost::BOOST_REGEX_DETAIL_NS::file_iterator; +using boost::BOOST_REGEX_DETAIL_NS::mapfile; } // namespace boost #endif // BOOST_REGEX_NO_FILEITER diff --git a/boost/regex/v4/instances.hpp b/boost/regex/v4/instances.hpp index 6fa811d232..f66b237cb9 100644 --- a/boost/regex/v4/instances.hpp +++ b/boost/regex/v4/instances.hpp @@ -54,7 +54,7 @@ namespace boost{ template class BOOST_REGEX_DECL basic_regex< BOOST_REGEX_CHAR_T BOOST_REGEX_TRAITS_T >; template class BOOST_REGEX_DECL match_results< const BOOST_REGEX_CHAR_T* >; #ifndef BOOST_NO_STD_ALLOCATOR -template class BOOST_REGEX_DECL ::boost::re_detail::perl_matcher<BOOST_REGEX_CHAR_T const *, match_results< const BOOST_REGEX_CHAR_T* >::allocator_type BOOST_REGEX_TRAITS_T >; +template class BOOST_REGEX_DECL ::boost::BOOST_REGEX_DETAIL_NS::perl_matcher<BOOST_REGEX_CHAR_T const *, match_results< const BOOST_REGEX_CHAR_T* >::allocator_type BOOST_REGEX_TRAITS_T >; #endif # ifndef BOOST_REGEX_INSTANTIATE @@ -94,7 +94,7 @@ template class BOOST_REGEX_TEMPLATE_DECL basic_regex< BOOST_REGEX_CHAR_T BOOST_R template class BOOST_REGEX_TEMPLATE_DECL match_results< const BOOST_REGEX_CHAR_T* >; #ifndef BOOST_NO_STD_ALLOCATOR -template class BOOST_REGEX_TEMPLATE_DECL ::boost::re_detail::perl_matcher<BOOST_REGEX_CHAR_T const *, match_results< const BOOST_REGEX_CHAR_T* >::allocator_type BOOST_REGEX_TRAITS_T >; +template class BOOST_REGEX_TEMPLATE_DECL ::boost::BOOST_REGEX_DETAIL_NS::perl_matcher<BOOST_REGEX_CHAR_T const *, match_results< const BOOST_REGEX_CHAR_T* >::allocator_type BOOST_REGEX_TRAITS_T >; #endif #if !(defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB <= 1))\ && !(defined(BOOST_INTEL_CXX_VERSION) && (BOOST_INTEL_CXX_VERSION <= 800))\ @@ -102,7 +102,7 @@ template class BOOST_REGEX_TEMPLATE_DECL ::boost::re_detail::perl_matcher<BOOST_ && !defined(BOOST_REGEX_ICU_INSTANCES) template class BOOST_REGEX_TEMPLATE_DECL match_results< std::basic_string<BOOST_REGEX_CHAR_T>::const_iterator >; #ifndef BOOST_NO_STD_ALLOCATOR -template class BOOST_REGEX_TEMPLATE_DECL ::boost::re_detail::perl_matcher< std::basic_string<BOOST_REGEX_CHAR_T>::const_iterator, match_results< std::basic_string<BOOST_REGEX_CHAR_T>::const_iterator >::allocator_type, boost::regex_traits<BOOST_REGEX_CHAR_T > >; +template class BOOST_REGEX_TEMPLATE_DECL ::boost::BOOST_REGEX_DETAIL_NS::perl_matcher< std::basic_string<BOOST_REGEX_CHAR_T>::const_iterator, match_results< std::basic_string<BOOST_REGEX_CHAR_T>::const_iterator >::allocator_type, boost::regex_traits<BOOST_REGEX_CHAR_T > >; #endif #endif @@ -119,6 +119,11 @@ template class BOOST_REGEX_TEMPLATE_DECL ::boost::re_detail::perl_matcher< std:: #elif (defined(__GNUC__) && (__GNUC__ >= 3)) || !defined(BOOST_NO_CXX11_EXTERN_TEMPLATE) +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wkeyword-macro" +#endif + # ifndef BOOST_REGEX_INSTANTIATE # ifdef __GNUC__ # define template __extension__ extern template @@ -128,7 +133,7 @@ template class BOOST_REGEX_TEMPLATE_DECL ::boost::re_detail::perl_matcher< std:: # endif #if !defined(BOOST_NO_STD_LOCALE) && !defined(BOOST_REGEX_ICU_INSTANCES) -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ template BOOST_REGEX_DECL std::locale cpp_regex_traits_base<BOOST_REGEX_CHAR_T>::imbue(const std::locale& l); @@ -177,7 +182,7 @@ template BOOST_REGEX_DECL void BOOST_REGEX_CALL match_results<const BOOST_REGEX_CHAR_T*>::maybe_assign( const match_results<const BOOST_REGEX_CHAR_T*>& m); -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ template BOOST_REGEX_DECL void perl_matcher<BOOST_REGEX_CHAR_T const *, match_results< const BOOST_REGEX_CHAR_T* >::allocator_type BOOST_REGEX_TRAITS_T >::construct_init( const basic_regex<BOOST_REGEX_CHAR_T BOOST_REGEX_TRAITS_T >& e, match_flag_type f); template BOOST_REGEX_DECL bool perl_matcher<BOOST_REGEX_CHAR_T const *, match_results< const BOOST_REGEX_CHAR_T* >::allocator_type BOOST_REGEX_TRAITS_T >::match(); @@ -193,7 +198,7 @@ template BOOST_REGEX_DECL void BOOST_REGEX_CALL match_results<std::basic_string<BOOST_REGEX_CHAR_T>::const_iterator>::maybe_assign( const match_results<std::basic_string<BOOST_REGEX_CHAR_T>::const_iterator>& m); -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ template BOOST_REGEX_DECL void perl_matcher<std::basic_string<BOOST_REGEX_CHAR_T>::const_iterator, match_results< std::basic_string<BOOST_REGEX_CHAR_T>::const_iterator >::allocator_type, boost::regex_traits<BOOST_REGEX_CHAR_T > >::construct_init( const basic_regex<BOOST_REGEX_CHAR_T>& e, match_flag_type f); template BOOST_REGEX_DECL bool perl_matcher<std::basic_string<BOOST_REGEX_CHAR_T>::const_iterator, match_results< std::basic_string<BOOST_REGEX_CHAR_T>::const_iterator >::allocator_type, boost::regex_traits<BOOST_REGEX_CHAR_T > >::match(); @@ -205,7 +210,9 @@ template BOOST_REGEX_DECL bool perl_matcher<std::basic_string<BOOST_REGEX_CHAR_T # undef template # endif - +#ifdef __clang__ +#pragma clang diagnostic pop +#endif #endif } // namespace boost diff --git a/boost/regex/v4/iterator_traits.hpp b/boost/regex/v4/iterator_traits.hpp index 53e1376041..ae45ecb80c 100644 --- a/boost/regex/v4/iterator_traits.hpp +++ b/boost/regex/v4/iterator_traits.hpp @@ -31,7 +31,7 @@ #endif namespace boost{ -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ #if defined(BOOST_NO_STD_ITERATOR_TRAITS) @@ -117,7 +117,7 @@ struct regex_iterator_traits : public std::iterator_traits<T> {}; #endif -} // namespace re_detail +} // namespace BOOST_REGEX_DETAIL_NS } // namespace boost #ifdef BOOST_MSVC diff --git a/boost/regex/v4/match_results.hpp b/boost/regex/v4/match_results.hpp index 3e79b7a766..c8233bdd87 100644 --- a/boost/regex/v4/match_results.hpp +++ b/boost/regex/v4/match_results.hpp @@ -39,7 +39,7 @@ namespace boost{ # endif #endif -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ class named_subexpressions; @@ -64,14 +64,14 @@ public: typedef const_reference reference; typedef typename vector_type::const_iterator const_iterator; typedef const_iterator iterator; - typedef typename re_detail::regex_iterator_traits< + typedef typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits< BidiIterator>::difference_type difference_type; typedef typename Allocator::size_type size_type; typedef Allocator allocator_type; - typedef typename re_detail::regex_iterator_traits< + typedef typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits< BidiIterator>::value_type char_type; typedef std::basic_string<char_type> string_type; - typedef re_detail::named_subexpressions named_sub_type; + typedef BOOST_REGEX_DETAIL_NS::named_subexpressions named_sub_type; // construct/copy/destroy: explicit match_results(const Allocator& a = Allocator()) @@ -158,7 +158,7 @@ public: const sub_match<BidiIterator>& s = m_subs[sub]; if(s.matched || (sub == 2)) { - return ::boost::re_detail::distance((BidiIterator)(m_base), (BidiIterator)(s.first)); + return ::boost::BOOST_REGEX_DETAIL_NS::distance((BidiIterator)(m_base), (BidiIterator)(s.first)); } } return ~static_cast<difference_type>(0); @@ -237,7 +237,7 @@ public: // if(m_is_singular) raise_logic_error(); - re_detail::named_subexpressions::range_type r = m_named_subs->equal_range(i, j); + BOOST_REGEX_DETAIL_NS::named_subexpressions::range_type r = m_named_subs->equal_range(i, j); while((r.first != r.second) && ((*this)[r.first->index].matched == false)) ++r.first; return r.first != r.second ? (*this)[r.first->index] : m_null; @@ -262,7 +262,7 @@ public: // if(m_is_singular) raise_logic_error(); - re_detail::named_subexpressions::range_type s, r; + BOOST_REGEX_DETAIL_NS::named_subexpressions::range_type s, r; s = r = m_named_subs->equal_range(i, j); while((r.first != r.second) && ((*this)[r.first->index].matched == false)) ++r.first; @@ -345,7 +345,7 @@ public: { if(m_is_singular) raise_logic_error(); - typedef typename re_detail::compute_functor_type<Functor, match_results<BidiIterator, Allocator>, OutputIterator>::type F; + typedef typename BOOST_REGEX_DETAIL_NS::compute_functor_type<Functor, match_results<BidiIterator, Allocator>, OutputIterator>::type F; F func(fmt); return func(*this, out, flags); } @@ -355,9 +355,9 @@ public: if(m_is_singular) raise_logic_error(); std::basic_string<char_type> result; - re_detail::string_out_iterator<std::basic_string<char_type> > i(result); + BOOST_REGEX_DETAIL_NS::string_out_iterator<std::basic_string<char_type> > i(result); - typedef typename re_detail::compute_functor_type<Functor, match_results<BidiIterator, Allocator>, re_detail::string_out_iterator<std::basic_string<char_type> > >::type F; + typedef typename BOOST_REGEX_DETAIL_NS::compute_functor_type<Functor, match_results<BidiIterator, Allocator>, BOOST_REGEX_DETAIL_NS::string_out_iterator<std::basic_string<char_type> > >::type F; F func(fmt); func(*this, i, flags); @@ -373,7 +373,7 @@ public: if(m_is_singular) raise_logic_error(); typedef ::boost::regex_traits_wrapper<typename RegexT::traits_type> traits_type; - typedef typename re_detail::compute_functor_type<Functor, match_results<BidiIterator, Allocator>, OutputIterator, traits_type>::type F; + typedef typename BOOST_REGEX_DETAIL_NS::compute_functor_type<Functor, match_results<BidiIterator, Allocator>, OutputIterator, traits_type>::type F; F func(fmt); return func(*this, out, flags, re.get_traits()); } @@ -386,9 +386,9 @@ public: raise_logic_error(); typedef ::boost::regex_traits_wrapper<typename RegexT::traits_type> traits_type; std::basic_string<char_type> result; - re_detail::string_out_iterator<std::basic_string<char_type> > i(result); + BOOST_REGEX_DETAIL_NS::string_out_iterator<std::basic_string<char_type> > i(result); - typedef typename re_detail::compute_functor_type<Functor, match_results<BidiIterator, Allocator>, re_detail::string_out_iterator<std::basic_string<char_type> >, traits_type >::type F; + typedef typename BOOST_REGEX_DETAIL_NS::compute_functor_type<Functor, match_results<BidiIterator, Allocator>, BOOST_REGEX_DETAIL_NS::string_out_iterator<std::basic_string<char_type> >, traits_type >::type F; F func(fmt); func(*this, i, flags, re.get_traits()); @@ -639,15 +639,15 @@ void BOOST_REGEX_CALL match_results<BidiIterator, Allocator>::maybe_assign(const // p1 better than p2, and no need to calculate distances: return; } - base1 = ::boost::re_detail::distance(l_base, p1->first); - base2 = ::boost::re_detail::distance(l_base, p2->first); + base1 = ::boost::BOOST_REGEX_DETAIL_NS::distance(l_base, p1->first); + base2 = ::boost::BOOST_REGEX_DETAIL_NS::distance(l_base, p2->first); BOOST_ASSERT(base1 >= 0); BOOST_ASSERT(base2 >= 0); if(base1 < base2) return; if(base2 < base1) break; - len1 = ::boost::re_detail::distance((BidiIterator)p1->first, (BidiIterator)p1->second); - len2 = ::boost::re_detail::distance((BidiIterator)p2->first, (BidiIterator)p2->second); + len1 = ::boost::BOOST_REGEX_DETAIL_NS::distance((BidiIterator)p1->first, (BidiIterator)p1->second); + len2 = ::boost::BOOST_REGEX_DETAIL_NS::distance((BidiIterator)p2->first, (BidiIterator)p2->second); BOOST_ASSERT(len1 >= 0); BOOST_ASSERT(len2 >= 0); if((len1 != len2) || ((p1->matched == false) && (p2->matched == true))) diff --git a/boost/regex/v4/mem_block_cache.hpp b/boost/regex/v4/mem_block_cache.hpp index 222142dd69..dc54915062 100644 --- a/boost/regex/v4/mem_block_cache.hpp +++ b/boost/regex/v4/mem_block_cache.hpp @@ -28,7 +28,7 @@ #endif namespace boost{ -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ struct mem_block_node { diff --git a/boost/regex/v4/perl_matcher.hpp b/boost/regex/v4/perl_matcher.hpp index b7b3b58e62..a7298fbd7a 100644 --- a/boost/regex/v4/perl_matcher.hpp +++ b/boost/regex/v4/perl_matcher.hpp @@ -31,7 +31,7 @@ #endif namespace boost{ -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ // // error checking API: @@ -253,23 +253,40 @@ class repeater_count int state_id; std::size_t count; // the number of iterations so far BidiIterator start_pos; // where the last repeat started + + repeater_count* unwind_until(int n, repeater_count* p, int current_recursion_id) + { + while(p && (p->state_id != n)) + { + if(-2 - current_recursion_id == p->state_id) + return 0; + p = p->next; + if(p && (p->state_id < 0)) + { + p = unwind_until(p->state_id, p, current_recursion_id); + if(!p) + return p; + p = p->next; + } + } + return p; + } public: repeater_count(repeater_count** s) : stack(s), next(0), state_id(-1), count(0), start_pos() {} - - repeater_count(int i, repeater_count** s, BidiIterator start) + + repeater_count(int i, repeater_count** s, BidiIterator start, int current_recursion_id) : start_pos(start) { state_id = i; stack = s; next = *stack; *stack = this; - if(state_id > next->state_id) + if((state_id > next->state_id) && (next->state_id >= 0)) count = 0; else { repeater_count* p = next; - while(p && (p->state_id != state_id)) - p = p->next; + p = unwind_until(state_id, p, current_recursion_id); if(p) { count = p->count; @@ -426,6 +443,11 @@ private: bool backtrack_till_match(std::size_t count); #endif bool match_recursion(); + bool match_fail(); + bool match_accept(); + bool match_commit(); + bool match_then(); + bool skip_until_paren(int index, bool match = true); // find procs stored in s_find_vtable: bool find_restart_any(); @@ -483,7 +505,12 @@ private: unsigned char match_any_mask; // recursion information: std::vector<recursion_info<results_type> > recursion_stack; - +#ifdef BOOST_REGEX_RECURSIVE + // Set to false by a (*COMMIT): + bool m_can_backtrack; + bool m_have_accept; + bool m_have_then; +#endif #ifdef BOOST_REGEX_NON_RECURSIVE // // additional members for non-recursive version: @@ -508,6 +535,8 @@ private: bool unwind_non_greedy_repeat(bool); bool unwind_recursion(bool); bool unwind_recursion_pop(bool); + bool unwind_commit(bool); + bool unwind_then(bool); void destroy_single_repeat(); void push_matched_paren(int index, const sub_match<BidiIterator>& sub); void push_recursion_stopper(); @@ -523,11 +552,17 @@ private: saved_state* m_stack_base; // pointer to current stack position: saved_state* m_backup_state; + // how many memory blocks have we used up?: + unsigned used_block_count; // determines what value to return when unwinding from recursion, // allows for mixed recursive/non-recursive algorithm: bool m_recursive_result; - // how many memory blocks have we used up?: - unsigned used_block_count; + // We have unwound to a lookahead/lookbehind, used by COMMIT/PRUNE/SKIP: + bool m_unwound_lookahead; + // We have unwound to an alternative, used by THEN: + bool m_unwound_alt; + // We are unwinding a commit - used by independent subs to determine whether to stop there or carry on unwinding: + //bool m_unwind_commit; #endif // these operations aren't allowed, so are declared private, @@ -544,7 +579,7 @@ private: #pragma warning(pop) #endif -} // namespace re_detail +} // namespace BOOST_REGEX_DETAIL_NS #ifdef BOOST_MSVC #pragma warning(push) diff --git a/boost/regex/v4/perl_matcher_common.hpp b/boost/regex/v4/perl_matcher_common.hpp index 480d8f145d..f3949ccf93 100644 --- a/boost/regex/v4/perl_matcher_common.hpp +++ b/boost/regex/v4/perl_matcher_common.hpp @@ -40,7 +40,7 @@ #endif namespace boost{ -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ template <class BidiIterator, class Allocator, class traits> void perl_matcher<BidiIterator, Allocator, traits>::construct_init(const basic_regex<char_type, traits>& e, match_flag_type f) @@ -80,11 +80,17 @@ void perl_matcher<BidiIterator, Allocator, traits>::construct_init(const basic_r #ifdef BOOST_REGEX_NON_RECURSIVE m_stack_base = 0; m_backup_state = 0; +#elif defined(BOOST_REGEX_RECURSIVE) + m_can_backtrack = true; + m_have_accept = false; #endif // find the value to use for matching word boundaries: m_word_mask = re.get_data().m_word_mask; // find bitmask to use for matching '.': - match_any_mask = static_cast<unsigned char>((f & match_not_dot_newline) ? re_detail::test_not_newline : re_detail::test_newline); + match_any_mask = static_cast<unsigned char>((f & match_not_dot_newline) ? BOOST_REGEX_DETAIL_NS::test_not_newline : BOOST_REGEX_DETAIL_NS::test_newline); + // Disable match_any if requested in the state machine: + if(e.get_data().m_disable_match_any) + m_match_flags &= ~regex_constants::match_any; } template <class BidiIterator, class Allocator, class traits> @@ -101,7 +107,7 @@ void perl_matcher<BidiIterator, Allocator, traits>::estimate_max_state_count(std // Calculate NS^2 first: // static const std::ptrdiff_t k = 100000; - std::ptrdiff_t dist = boost::re_detail::distance(base, last); + std::ptrdiff_t dist = boost::BOOST_REGEX_DETAIL_NS::distance(base, last); if(dist == 0) dist = 1; std::ptrdiff_t states = re.size(); @@ -165,7 +171,7 @@ template <class BidiIterator, class Allocator, class traits> inline bool perl_matcher<BidiIterator, Allocator, traits>::protected_call( protected_proc_type proc) { - ::boost::re_detail::concrete_protected_call + ::boost::BOOST_REGEX_DETAIL_NS::concrete_protected_call <perl_matcher<BidiIterator, Allocator, traits> > obj(this, proc); return obj.execute(); @@ -348,6 +354,9 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_prefix() #endif if(!m_has_found_match) position = restart; // reset search postion +#ifdef BOOST_REGEX_RECURSIVE + m_can_backtrack = true; // reset for further searches +#endif return m_has_found_match; } @@ -703,7 +712,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_backstep() #endif if( ::boost::is_random_access_iterator<BidiIterator>::value) { - std::ptrdiff_t maxlen = ::boost::re_detail::distance(backstop, position); + std::ptrdiff_t maxlen = ::boost::BOOST_REGEX_DETAIL_NS::distance(backstop, position); if(maxlen < static_cast<const re_brace*>(pstate)->index) return false; std::advance(position, -static_cast<const re_brace*>(pstate)->index); @@ -793,6 +802,25 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_toggle_case() return true; } +template <class BidiIterator, class Allocator, class traits> +bool perl_matcher<BidiIterator, Allocator, traits>::match_fail() +{ + // Just force a backtrack: + return false; +} + +template <class BidiIterator, class Allocator, class traits> +bool perl_matcher<BidiIterator, Allocator, traits>::match_accept() +{ + if(!recursion_stack.empty()) + { + return skip_until_paren(recursion_stack.back().idx); + } + else + { + return skip_until_paren(INT_MAX); + } +} template <class BidiIterator, class Allocator, class traits> bool perl_matcher<BidiIterator, Allocator, traits>::find_restart_any() @@ -966,7 +994,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::find_restart_lit() return false; } -} // namespace re_detail +} // namespace BOOST_REGEX_DETAIL_NS } // namespace boost diff --git a/boost/regex/v4/perl_matcher_non_recursive.hpp b/boost/regex/v4/perl_matcher_non_recursive.hpp index 5c1f7a98b0..bf77eaa57b 100644 --- a/boost/regex/v4/perl_matcher_non_recursive.hpp +++ b/boost/regex/v4/perl_matcher_non_recursive.hpp @@ -34,11 +34,11 @@ #endif #ifdef BOOST_MSVC # pragma warning(push) -# pragma warning(disable: 4800) +# pragma warning(disable: 4800 4706) #endif namespace boost{ -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ template <class T> inline void inplace_destroy(T* p) @@ -87,8 +87,8 @@ template <class BidiIterator> struct saved_repeater : public saved_state { repeater_count<BidiIterator> count; - saved_repeater(int i, repeater_count<BidiIterator>** s, BidiIterator start) - : saved_state(saved_state_repeater_count), count(i,s,start){} + saved_repeater(int i, repeater_count<BidiIterator>** s, BidiIterator start, int current_recursion_id) + : saved_state(saved_state_repeater_count), count(i, s, start, current_recursion_id){} }; struct saved_extra_block : public saved_state @@ -141,7 +141,7 @@ struct saved_recursion : public saved_state template <class BidiIterator, class Allocator, class traits> bool perl_matcher<BidiIterator, Allocator, traits>::match_all_states() { - static matcher_proc_type const s_match_vtable[30] = + static matcher_proc_type const s_match_vtable[34] = { (&perl_matcher<BidiIterator, Allocator, traits>::match_startmark), &perl_matcher<BidiIterator, Allocator, traits>::match_endmark, @@ -177,6 +177,10 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_all_states() &perl_matcher<BidiIterator, Allocator, traits>::match_assert_backref, &perl_matcher<BidiIterator, Allocator, traits>::match_toggle_case, &perl_matcher<BidiIterator, Allocator, traits>::match_recursion, + &perl_matcher<BidiIterator, Allocator, traits>::match_fail, + &perl_matcher<BidiIterator, Allocator, traits>::match_accept, + &perl_matcher<BidiIterator, Allocator, traits>::match_commit, + &perl_matcher<BidiIterator, Allocator, traits>::match_then, }; push_recursion_stopper(); @@ -309,7 +313,7 @@ inline void perl_matcher<BidiIterator, Allocator, traits>::push_repeater_count(i pmp = static_cast<saved_repeater<BidiIterator>*>(m_backup_state); --pmp; } - (void) new (pmp)saved_repeater<BidiIterator>(i, s, position); + (void) new (pmp)saved_repeater<BidiIterator>(i, s, position, this->recursion_stack.size() ? this->recursion_stack.back().idx : (INT_MIN + 3)); m_backup_state = pmp; } @@ -370,6 +374,13 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_startmark() const re_syntax_base* next_pstate = static_cast<const re_jump*>(pstate->next.p)->alt.p->next.p; pstate = pstate->next.p->next.p; bool r = match_all_states(); + if(!r && !m_independent) + { + // Must be unwinding from a COMMIT/SKIP/PRUNE and the independent + // sub failed, need to unwind everything else: + while(unwind(false)); + return false; + } pstate = next_pstate; m_independent = old_independent; #ifdef BOOST_REGEX_MATCH_EXTRA @@ -652,7 +663,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_dot_repeat_fast() const re_repeat* rep = static_cast<const re_repeat*>(pstate); bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); - unsigned count = static_cast<unsigned>((std::min)(static_cast<unsigned>(::boost::re_detail::distance(position, last)), static_cast<unsigned>(greedy ? rep->max : rep->min))); + unsigned count = static_cast<unsigned>((std::min)(static_cast<unsigned>(::boost::BOOST_REGEX_DETAIL_NS::distance(position, last)), static_cast<unsigned>(greedy ? rep->max : rep->min))); if(rep->min > count) { position = last; @@ -705,7 +716,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_char_repeat() BidiIterator end = position; // Move end forward by "desired", preferably without using distance or advance if we can // as these can be slow for some iterator types. - std::size_t len = (desired == (std::numeric_limits<std::size_t>::max)()) ? 0u : ::boost::re_detail::distance(position, last); + std::size_t len = (desired == (std::numeric_limits<std::size_t>::max)()) ? 0u : ::boost::BOOST_REGEX_DETAIL_NS::distance(position, last); if(desired >= len) end = last; else @@ -715,7 +726,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_char_repeat() { ++position; } - count = (unsigned)::boost::re_detail::distance(origin, position); + count = (unsigned)::boost::BOOST_REGEX_DETAIL_NS::distance(origin, position); } else { @@ -779,7 +790,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_set_repeat() BidiIterator end = position; // Move end forward by "desired", preferably without using distance or advance if we can // as these can be slow for some iterator types. - std::size_t len = (desired == (std::numeric_limits<std::size_t>::max)()) ? 0u : ::boost::re_detail::distance(position, last); + std::size_t len = (desired == (std::numeric_limits<std::size_t>::max)()) ? 0u : ::boost::BOOST_REGEX_DETAIL_NS::distance(position, last); if(desired >= len) end = last; else @@ -789,7 +800,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_set_repeat() { ++position; } - count = (unsigned)::boost::re_detail::distance(origin, position); + count = (unsigned)::boost::BOOST_REGEX_DETAIL_NS::distance(origin, position); } else { @@ -854,7 +865,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_long_set_repeat() BidiIterator end = position; // Move end forward by "desired", preferably without using distance or advance if we can // as these can be slow for some iterator types. - std::size_t len = (desired == (std::numeric_limits<std::size_t>::max)()) ? 0u : ::boost::re_detail::distance(position, last); + std::size_t len = (desired == (std::numeric_limits<std::size_t>::max)()) ? 0u : ::boost::BOOST_REGEX_DETAIL_NS::distance(position, last); if(desired >= len) end = last; else @@ -864,7 +875,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_long_set_repeat() { ++position; } - count = (unsigned)::boost::re_detail::distance(origin, position); + count = (unsigned)::boost::BOOST_REGEX_DETAIL_NS::distance(origin, position); } else { @@ -923,12 +934,12 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_recursion() recursion_stack.push_back(recursion_info<results_type>()); recursion_stack.back().preturn_address = pstate->next.p; recursion_stack.back().results = *m_presult; - if(static_cast<const re_recurse*>(pstate)->state_id > 0) - { - push_repeater_count(static_cast<const re_recurse*>(pstate)->state_id, &next_count); - } pstate = static_cast<const re_jump*>(pstate)->alt.p; recursion_stack.back().idx = static_cast<const re_brace*>(pstate)->index; + //if(static_cast<const re_recurse*>(pstate)->state_id > 0) + { + push_repeater_count(-(2 + static_cast<const re_brace*>(pstate)->index), &next_count); + } return true; } @@ -952,6 +963,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_endmark() *m_presult = recursion_stack.back().results; push_recursion(recursion_stack.back().idx, recursion_stack.back().preturn_address, &recursion_stack.back().results); recursion_stack.pop_back(); + push_repeater_count(-(2 + index), &next_count); } } } @@ -1003,6 +1015,103 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_match() return true; } +template <class BidiIterator, class Allocator, class traits> +bool perl_matcher<BidiIterator, Allocator, traits>::match_commit() +{ + // Ideally we would just junk all the states that are on the stack, + // however we might not unwind correctly in that case, so for now, + // just mark that we don't backtrack into whatever is left (or rather + // we'll unwind it unconditionally without pausing to try other matches). + + switch(static_cast<const re_commit*>(pstate)->action) + { + case commit_commit: + restart = last; + break; + case commit_skip: + if(base != position) + { + restart = position; + // Have to decrement restart since it will get incremented again later: + --restart; + } + break; + case commit_prune: + break; + } + + saved_state* pmp = m_backup_state; + --pmp; + if(pmp < m_stack_base) + { + extend_stack(); + pmp = m_backup_state; + --pmp; + } + (void) new (pmp)saved_state(16); + m_backup_state = pmp; + pstate = pstate->next.p; + return true; +} + +template <class BidiIterator, class Allocator, class traits> +bool perl_matcher<BidiIterator, Allocator, traits>::match_then() +{ + // Just leave a mark that we need to skip to next alternative: + saved_state* pmp = m_backup_state; + --pmp; + if(pmp < m_stack_base) + { + extend_stack(); + pmp = m_backup_state; + --pmp; + } + (void) new (pmp)saved_state(17); + m_backup_state = pmp; + pstate = pstate->next.p; + return true; +} + +template <class BidiIterator, class Allocator, class traits> +bool perl_matcher<BidiIterator, Allocator, traits>::skip_until_paren(int index, bool have_match) +{ + while(pstate) + { + if(pstate->type == syntax_element_endmark) + { + if(static_cast<const re_brace*>(pstate)->index == index) + { + if(have_match) + return this->match_endmark(); + pstate = pstate->next.p; + return true; + } + else + { + // Unenclosed closing ), occurs when (*ACCEPT) is inside some other + // parenthesis which may or may not have other side effects associated with it. + match_endmark(); + if(!pstate) + { + unwind(true); + } + } + continue; + } + else if(pstate->type == syntax_element_match) + return true; + else if(pstate->type == syntax_element_startmark) + { + int idx = static_cast<const re_brace*>(pstate)->index; + pstate = pstate->next.p; + skip_until_paren(idx, false); + continue; + } + pstate = pstate->next.p; + } + return true; +} + /**************************************************************************** Unwind and associated proceedures follow, these perform what normal stack @@ -1013,7 +1122,7 @@ unwinding does in the recursive implementation. template <class BidiIterator, class Allocator, class traits> bool perl_matcher<BidiIterator, Allocator, traits>::unwind(bool have_match) { - static unwind_proc_type const s_unwind_table[18] = + static unwind_proc_type const s_unwind_table[19] = { &perl_matcher<BidiIterator, Allocator, traits>::unwind_end, &perl_matcher<BidiIterator, Allocator, traits>::unwind_paren, @@ -1031,9 +1140,13 @@ bool perl_matcher<BidiIterator, Allocator, traits>::unwind(bool have_match) &perl_matcher<BidiIterator, Allocator, traits>::unwind_non_greedy_repeat, &perl_matcher<BidiIterator, Allocator, traits>::unwind_recursion, &perl_matcher<BidiIterator, Allocator, traits>::unwind_recursion_pop, + &perl_matcher<BidiIterator, Allocator, traits>::unwind_commit, + &perl_matcher<BidiIterator, Allocator, traits>::unwind_then, }; m_recursive_result = have_match; + m_unwound_lookahead = false; + m_unwound_alt = false; unwind_proc_type unwinder; bool cont; // @@ -1076,14 +1189,14 @@ bool perl_matcher<BidiIterator, Allocator, traits>::unwind_paren(bool have_match #endif // unwind stack: m_backup_state = pmp+1; - boost::re_detail::inplace_destroy(pmp); + boost::BOOST_REGEX_DETAIL_NS::inplace_destroy(pmp); return true; // keep looking } template <class BidiIterator, class Allocator, class traits> bool perl_matcher<BidiIterator, Allocator, traits>::unwind_recursion_stopper(bool) { - boost::re_detail::inplace_destroy(m_backup_state++); + boost::BOOST_REGEX_DETAIL_NS::inplace_destroy(m_backup_state++); pstate = 0; // nothing left to search return false; // end of stack nothing more to search } @@ -1096,8 +1209,9 @@ bool perl_matcher<BidiIterator, Allocator, traits>::unwind_assertion(bool r) position = pmp->position; bool result = (r == pmp->positive); m_recursive_result = pmp->positive ? r : !r; - boost::re_detail::inplace_destroy(pmp++); + boost::BOOST_REGEX_DETAIL_NS::inplace_destroy(pmp++); m_backup_state = pmp; + m_unwound_lookahead = true; return !result; // return false if the assertion was matched to stop search. } @@ -1110,8 +1224,9 @@ bool perl_matcher<BidiIterator, Allocator, traits>::unwind_alt(bool r) pstate = pmp->pstate; position = pmp->position; } - boost::re_detail::inplace_destroy(pmp++); + boost::BOOST_REGEX_DETAIL_NS::inplace_destroy(pmp++); m_backup_state = pmp; + m_unwound_alt = !r; return r; } @@ -1119,7 +1234,7 @@ template <class BidiIterator, class Allocator, class traits> bool perl_matcher<BidiIterator, Allocator, traits>::unwind_repeater_counter(bool) { saved_repeater<BidiIterator>* pmp = static_cast<saved_repeater<BidiIterator>*>(m_backup_state); - boost::re_detail::inplace_destroy(pmp++); + boost::BOOST_REGEX_DETAIL_NS::inplace_destroy(pmp++); m_backup_state = pmp; return true; // keep looking } @@ -1131,7 +1246,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::unwind_extra_block(bool) void* condemmed = m_stack_base; m_stack_base = pmp->base; m_backup_state = pmp->end; - boost::re_detail::inplace_destroy(pmp); + boost::BOOST_REGEX_DETAIL_NS::inplace_destroy(pmp); put_mem_block(condemmed); return true; // keep looking } @@ -1140,7 +1255,7 @@ template <class BidiIterator, class Allocator, class traits> inline void perl_matcher<BidiIterator, Allocator, traits>::destroy_single_repeat() { saved_single_repeat<BidiIterator>* p = static_cast<saved_single_repeat<BidiIterator>*>(m_backup_state); - boost::re_detail::inplace_destroy(p++); + boost::BOOST_REGEX_DETAIL_NS::inplace_destroy(p++); m_backup_state = p; } @@ -1532,7 +1647,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::unwind_non_greedy_repeat(boo pstate = pmp->pstate; ++(*next_count); } - boost::re_detail::inplace_destroy(pmp++); + boost::BOOST_REGEX_DETAIL_NS::inplace_destroy(pmp++); m_backup_state = pmp; return r; } @@ -1548,7 +1663,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::unwind_recursion(bool r) recursion_stack.back().preturn_address = pmp->preturn_address; recursion_stack.back().results = pmp->results; } - boost::re_detail::inplace_destroy(pmp++); + boost::BOOST_REGEX_DETAIL_NS::inplace_destroy(pmp++); m_backup_state = pmp; return true; } @@ -1561,7 +1676,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::unwind_recursion_pop(bool r) { recursion_stack.pop_back(); } - boost::re_detail::inplace_destroy(pmp++); + boost::BOOST_REGEX_DETAIL_NS::inplace_destroy(pmp++); m_backup_state = pmp; return true; } @@ -1580,6 +1695,48 @@ void perl_matcher<BidiIterator, Allocator, traits>::push_recursion_pop() (void) new (pmp)saved_state(15); m_backup_state = pmp; } + +template <class BidiIterator, class Allocator, class traits> +bool perl_matcher<BidiIterator, Allocator, traits>::unwind_commit(bool b) +{ + boost::BOOST_REGEX_DETAIL_NS::inplace_destroy(m_backup_state++); + while(unwind(b) && !m_unwound_lookahead){} + if(m_unwound_lookahead && pstate) + { + // + // If we stop because we just unwound an assertion, put the + // commit state back on the stack again: + // + saved_state* pmp = m_backup_state; + --pmp; + if(pmp < m_stack_base) + { + extend_stack(); + pmp = m_backup_state; + --pmp; + } + (void) new (pmp)saved_state(16); + m_backup_state = pmp; + } + // This prevents us from stopping when we exit from an independent sub-expression: + m_independent = false; + return false; +} + +template <class BidiIterator, class Allocator, class traits> +bool perl_matcher<BidiIterator, Allocator, traits>::unwind_then(bool b) +{ + // Unwind everything till we hit an alternative: + boost::BOOST_REGEX_DETAIL_NS::inplace_destroy(m_backup_state++); + bool result = false; + while((result = unwind(b)) && !m_unwound_alt){} + // We're now pointing at the next alternative, need one more backtrack + // since *all* the other alternatives must fail once we've reached a THEN clause: + if(result && m_unwound_alt) + unwind(b); + return false; +} + /* template <class BidiIterator, class Allocator, class traits> bool perl_matcher<BidiIterator, Allocator, traits>::unwind_parenthesis_pop(bool r) @@ -1589,7 +1746,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::unwind_parenthesis_pop(bool { --parenthesis_stack_position; } - boost::re_detail::inplace_destroy(pmp++); + boost::BOOST_REGEX_DETAIL_NS::inplace_destroy(pmp++); m_backup_state = pmp; return true; } @@ -1617,7 +1774,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::unwind_parenthesis_push(bool { parenthesis_stack[parenthesis_stack_position++] = pmp->position; } - boost::re_detail::inplace_destroy(pmp++); + boost::BOOST_REGEX_DETAIL_NS::inplace_destroy(pmp++); m_backup_state = pmp; return true; } @@ -1637,7 +1794,7 @@ inline void perl_matcher<BidiIterator, Allocator, traits>::push_parenthesis_push m_backup_state = pmp; } */ -} // namespace re_detail +} // namespace BOOST_REGEX_DETAIL_NS } // namespace boost #ifdef BOOST_MSVC diff --git a/boost/regex/v4/perl_matcher_recursive.hpp b/boost/regex/v4/perl_matcher_recursive.hpp index 8e0e182b56..3893837df3 100644 --- a/boost/regex/v4/perl_matcher_recursive.hpp +++ b/boost/regex/v4/perl_matcher_recursive.hpp @@ -37,7 +37,7 @@ #endif namespace boost{ -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ template <class BidiIterator> class backup_subex @@ -60,7 +60,7 @@ public: template <class BidiIterator, class Allocator, class traits> bool perl_matcher<BidiIterator, Allocator, traits>::match_all_states() { - static matcher_proc_type const s_match_vtable[30] = + static matcher_proc_type const s_match_vtable[34] = { (&perl_matcher<BidiIterator, Allocator, traits>::match_startmark), &perl_matcher<BidiIterator, Allocator, traits>::match_endmark, @@ -96,6 +96,10 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_all_states() &perl_matcher<BidiIterator, Allocator, traits>::match_assert_backref, &perl_matcher<BidiIterator, Allocator, traits>::match_toggle_case, &perl_matcher<BidiIterator, Allocator, traits>::match_recursion, + &perl_matcher<BidiIterator, Allocator, traits>::match_fail, + &perl_matcher<BidiIterator, Allocator, traits>::match_accept, + &perl_matcher<BidiIterator, Allocator, traits>::match_commit, + &perl_matcher<BidiIterator, Allocator, traits>::match_then, }; if(state_count > max_state_count) @@ -139,6 +143,8 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_startmark() r = false; else r = true; + if(r && m_have_accept) + r = skip_until_paren(INT_MAX); break; } case -3: @@ -148,7 +154,10 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_startmark() m_independent = true; const re_syntax_base* next_pstate = static_cast<const re_jump*>(pstate->next.p)->alt.p->next.p; pstate = pstate->next.p->next.p; + bool can_backtrack = m_can_backtrack; r = match_all_states(); + if(r) + m_can_backtrack = can_backtrack; pstate = next_pstate; m_independent = old_independent; #ifdef BOOST_REGEX_MATCH_EXTRA @@ -178,6 +187,8 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_startmark() } } #endif + if(r && m_have_accept) + r = skip_until_paren(INT_MAX); break; } case -4: @@ -278,12 +289,20 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_alt() BidiIterator oldposition(position); const re_syntax_base* old_pstate = jmp->alt.p; pstate = pstate->next.p; + m_have_then = false; if(!match_all_states()) { pstate = old_pstate; position = oldposition; + if(m_have_then) + { + m_can_backtrack = true; + m_have_then = false; + return false; + } } - return true; + m_have_then = false; + return m_can_backtrack; } pstate = pstate->next.p; return true; @@ -308,7 +327,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_rep() // Always copy the repeat count, so that the state is restored // when we exit this scope: // - repeater_count<BidiIterator> r(rep->state_id, &next_count, position); + repeater_count<BidiIterator> r(rep->state_id, &next_count, position, this->recursion_stack.size() ? this->recursion_stack.back().idx : INT_MIN + 3); // // If we've had at least one repeat already, and the last one // matched the NULL string then set the repeat count to @@ -354,6 +373,8 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_rep() pstate = rep->next.p; if(match_all_states()) return true; + if(!m_can_backtrack) + return false; // failed repeat, reset posistion and fall through for alternative: position = pos; } @@ -374,6 +395,8 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_rep() pstate = rep->alt.p; if(match_all_states()) return true; + if(!m_can_backtrack) + return false; // failed alternative, reset posistion and fall through for repeat: position = pos; } @@ -438,7 +461,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_dot_repeat_slow() ++state_count; if(match_all_states()) return true; - if(count >= rep->max) + if((count >= rep->max) || !m_can_backtrack) return false; ++count; pstate = psingle; @@ -472,7 +495,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_dot_repeat_fast() #pragma warning(disable:4267) #endif bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); - std::size_t count = (std::min)(static_cast<std::size_t>(::boost::re_detail::distance(position, last)), static_cast<std::size_t>(greedy ? rep->max : rep->min)); + std::size_t count = (std::min)(static_cast<std::size_t>(::boost::BOOST_REGEX_DETAIL_NS::distance(position, last)), static_cast<std::size_t>(greedy ? rep->max : rep->min)); if(rep->min > count) { position = last; @@ -503,7 +526,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_dot_repeat_fast() ++state_count; if(match_all_states()) return true; - if(count >= rep->max) + if((count >= rep->max) || !m_can_backtrack) return false; if(save_pos == last) return false; @@ -539,7 +562,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_char_repeat() desired = (std::min)( (std::size_t)(greedy ? rep->max : rep->min), - (std::size_t)::boost::re_detail::distance(position, last)); + (std::size_t)::boost::BOOST_REGEX_DETAIL_NS::distance(position, last)); count = desired; ++desired; if(icase) @@ -597,7 +620,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_char_repeat() ++state_count; if(match_all_states()) return true; - if(count >= rep->max) + if((count >= rep->max) || !m_can_backtrack) return false; position = save_pos; if(position == last) @@ -643,7 +666,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_set_repeat() BidiIterator end = position; // Move end forward by "desired", preferably without using distance or advance if we can // as these can be slow for some iterator types. - std::size_t len = (desired == (std::numeric_limits<std::size_t>::max)()) ? 0u : ::boost::re_detail::distance(position, last); + std::size_t len = (desired == (std::numeric_limits<std::size_t>::max)()) ? 0u : ::boost::BOOST_REGEX_DETAIL_NS::distance(position, last); if(desired >= len) end = last; else @@ -653,7 +676,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_set_repeat() { ++position; } - count = (unsigned)::boost::re_detail::distance(origin, position); + count = (unsigned)::boost::BOOST_REGEX_DETAIL_NS::distance(origin, position); } else { @@ -692,7 +715,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_set_repeat() ++state_count; if(match_all_states()) return true; - if(count >= rep->max) + if((count >= rep->max) || !m_can_backtrack) return false; position = save_pos; if(position == last) @@ -739,7 +762,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_long_set_repeat() BidiIterator end = position; // Move end forward by "desired", preferably without using distance or advance if we can // as these can be slow for some iterator types. - std::size_t len = (desired == (std::numeric_limits<std::size_t>::max)()) ? 0u : ::boost::re_detail::distance(position, last); + std::size_t len = (desired == (std::numeric_limits<std::size_t>::max)()) ? 0u : ::boost::BOOST_REGEX_DETAIL_NS::distance(position, last); if(desired >= len) end = last; else @@ -749,7 +772,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_long_set_repeat() { ++position; } - count = (unsigned)::boost::re_detail::distance(origin, position); + count = (unsigned)::boost::BOOST_REGEX_DETAIL_NS::distance(origin, position); } else { @@ -788,7 +811,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_long_set_repeat() ++state_count; if(match_all_states()) return true; - if(count >= rep->max) + if((count >= rep->max) || !m_can_backtrack) return false; position = save_pos; if(position == last) @@ -818,6 +841,8 @@ bool perl_matcher<BidiIterator, Allocator, traits>::backtrack_till_match(std::si #pragma warning(push) #pragma warning(disable:4127) #endif + if(!m_can_backtrack) + return false; if((m_match_flags & match_partial) && (position == last)) m_has_partial_match = true; @@ -883,7 +908,9 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_recursion() repeater_count<BidiIterator>* saved = next_count; repeater_count<BidiIterator> r(&next_count); // resets all repeat counts since we're recursing and starting fresh on those next_count = &r; + bool can_backtrack = m_can_backtrack; bool result = match_all_states(); + m_can_backtrack = can_backtrack; next_count = saved; if(!result) @@ -980,9 +1007,76 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_match() return true; } +template <class BidiIterator, class Allocator, class traits> +bool perl_matcher<BidiIterator, Allocator, traits>::match_commit() +{ + m_can_backtrack = false; + int action = static_cast<const re_commit*>(pstate)->action; + switch(action) + { + case commit_commit: + restart = last; + break; + case commit_skip: + restart = position; + break; + } + pstate = pstate->next.p; + return true; +} + +template <class BidiIterator, class Allocator, class traits> +bool perl_matcher<BidiIterator, Allocator, traits>::match_then() +{ + pstate = pstate->next.p; + if(match_all_states()) + return true; + m_can_backtrack = false; + m_have_then = true; + return false; +} + +template <class BidiIterator, class Allocator, class traits> +bool perl_matcher<BidiIterator, Allocator, traits>::skip_until_paren(int index, bool have_match) +{ + while(pstate) + { + if(pstate->type == syntax_element_endmark) + { + if(static_cast<const re_brace*>(pstate)->index == index) + { + if(have_match) + return this->match_endmark(); + pstate = pstate->next.p; + return true; + } + else + { + // Unenclosed closing ), occurs when (*ACCEPT) is inside some other + // parenthesis which may or may not have other side effects associated with it. + bool r = match_endmark(); + m_have_accept = true; + if(!pstate) + return r; + } + continue; + } + else if(pstate->type == syntax_element_match) + return true; + else if(pstate->type == syntax_element_startmark) + { + int idx = static_cast<const re_brace*>(pstate)->index; + pstate = pstate->next.p; + skip_until_paren(idx, false); + continue; + } + pstate = pstate->next.p; + } + return true; +} -} // namespace re_detail +} // namespace BOOST_REGEX_DETAIL_NS } // namespace boost #ifdef BOOST_MSVC #pragma warning(pop) diff --git a/boost/regex/v4/primary_transform.hpp b/boost/regex/v4/primary_transform.hpp index 989f500c1d..3e7cac549b 100644 --- a/boost/regex/v4/primary_transform.hpp +++ b/boost/regex/v4/primary_transform.hpp @@ -32,7 +32,7 @@ #endif namespace boost{ - namespace re_detail{ + namespace BOOST_REGEX_DETAIL_NS{ enum{ @@ -122,7 +122,7 @@ unsigned find_sort_syntax(const traits* pt, charT* delim) } - } // namespace re_detail + } // namespace BOOST_REGEX_DETAIL_NS } // namespace boost #ifdef BOOST_MSVC diff --git a/boost/regex/v4/protected_call.hpp b/boost/regex/v4/protected_call.hpp index ebf15ba370..9d47514f81 100644 --- a/boost/regex/v4/protected_call.hpp +++ b/boost/regex/v4/protected_call.hpp @@ -32,7 +32,7 @@ #endif namespace boost{ -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ class BOOST_REGEX_DECL abstract_protected_call { diff --git a/boost/regex/v4/regex_format.hpp b/boost/regex/v4/regex_format.hpp index a34c40ad24..e9006a7bd2 100644 --- a/boost/regex/v4/regex_format.hpp +++ b/boost/regex/v4/regex_format.hpp @@ -55,7 +55,7 @@ namespace boost{ template <class BidiIterator, class Allocator = BOOST_DEDUCED_TYPENAME std::vector<sub_match<BidiIterator> >::allocator_type > class match_results; -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ // // struct trivial_format_traits: @@ -73,11 +73,11 @@ struct trivial_format_traits } static charT tolower(charT c) { - return ::boost::re_detail::global_lower(c); + return ::boost::BOOST_REGEX_DETAIL_NS::global_lower(c); } static charT toupper(charT c) { - return ::boost::re_detail::global_upper(c); + return ::boost::BOOST_REGEX_DETAIL_NS::global_upper(c); } static int value(const charT c, int radix) { @@ -359,7 +359,7 @@ void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::format default: // see if we have a number: { - std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end); + std::ptrdiff_t len = ::boost::BOOST_REGEX_DETAIL_NS::distance(m_position, m_end); //len = (std::min)(static_cast<std::ptrdiff_t>(2), len); int v = this->toi(m_position, m_position + len, 10); if((v < 0) || (have_brace && ((m_position == m_end) || (*m_position != '}')))) @@ -570,7 +570,7 @@ void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::format } else { - std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end); + std::ptrdiff_t len = ::boost::BOOST_REGEX_DETAIL_NS::distance(m_position, m_end); len = (std::min)(static_cast<std::ptrdiff_t>(2), len); int val = this->toi(m_position, m_position + len, 16); if(val < 0) @@ -634,7 +634,7 @@ void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::format break; } // see if we have a \n sed style backreference: - std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end); + std::ptrdiff_t len = ::boost::BOOST_REGEX_DETAIL_NS::distance(m_position, m_end); len = (std::min)(static_cast<std::ptrdiff_t>(1), len); int v = this->toi(m_position, m_position+len, 10); if((v > 0) || ((v == 0) && (m_flags & ::boost::regex_constants::format_sed))) @@ -646,7 +646,7 @@ void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::format { // octal ecape sequence: --m_position; - len = ::boost::re_detail::distance(m_position, m_end); + len = ::boost::BOOST_REGEX_DETAIL_NS::distance(m_position, m_end); len = (std::min)(static_cast<std::ptrdiff_t>(4), len); v = this->toi(m_position, m_position + len, 8); BOOST_ASSERT(v >= 0); @@ -693,7 +693,7 @@ void basic_regex_formatter<OutputIterator, Results, traits, ForwardIter>::format } else { - std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end); + std::ptrdiff_t len = ::boost::BOOST_REGEX_DETAIL_NS::distance(m_position, m_end); len = (std::min)(static_cast<std::ptrdiff_t>(2), len); v = this->toi(m_position, m_position + len, 10); } @@ -835,10 +835,10 @@ OutputIterator regex_format_imp(OutputIterator out, { if(flags & regex_constants::format_literal) { - return re_detail::copy(p1, p2, out); + return BOOST_REGEX_DETAIL_NS::copy(p1, p2, out); } - re_detail::basic_regex_formatter< + BOOST_REGEX_DETAIL_NS::basic_regex_formatter< OutputIterator, match_results<Iterator, Alloc>, traits, ForwardIter> f(out, m, t); @@ -1028,7 +1028,7 @@ struct format_functor1 template <class S, class OutputIter> OutputIter do_format_string(const S& s, OutputIter i) { - return re_detail::copy(s.begin(), s.end(), i); + return BOOST_REGEX_DETAIL_NS::copy(s.begin(), s.end(), i); } template <class S, class OutputIter> inline OutputIter do_format_string(const S* s, OutputIter i) @@ -1085,7 +1085,7 @@ struct format_functor_container OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f, const Traits& t = Traits()) { //typedef typename Match::char_type char_type; - return re_detail::regex_format_imp(i, m, func.begin(), func.end(), f, t); + return BOOST_REGEX_DETAIL_NS::regex_format_imp(i, m, func.begin(), func.end(), f, t); } private: const Container& func; @@ -1093,7 +1093,7 @@ private: 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> > +template <class Func, class Match, class OutputIterator, class Traits = BOOST_REGEX_DETAIL_NS::trivial_format_traits<typename Match::char_type> > struct compute_functor_type { typedef typename format_traits<Func, Match, OutputIterator>::type tag; @@ -1114,7 +1114,7 @@ struct compute_functor_type >::type type; }; -} // namespace re_detail +} // namespace BOOST_REGEX_DETAIL_NS template <class OutputIterator, class Iterator, class Allocator, class Functor> inline OutputIterator regex_format(OutputIterator out, diff --git a/boost/regex/v4/regex_grep.hpp b/boost/regex/v4/regex_grep.hpp index 3a3d906ecb..c5cb054e58 100644 --- a/boost/regex/v4/regex_grep.hpp +++ b/boost/regex/v4/regex_grep.hpp @@ -50,7 +50,7 @@ inline unsigned int regex_grep(Predicate foo, typedef typename match_results<BidiIterator>::allocator_type match_allocator_type; match_results<BidiIterator> m; - re_detail::perl_matcher<BidiIterator, match_allocator_type, traits> matcher(first, last, m, e, flags, first); + BOOST_REGEX_DETAIL_NS::perl_matcher<BidiIterator, match_allocator_type, traits> matcher(first, last, m, e, flags, first); unsigned int count = 0; while(matcher.find()) { diff --git a/boost/regex/v4/regex_iterator.hpp b/boost/regex/v4/regex_iterator.hpp index 09e75c697d..0d10a1b98f 100644 --- a/boost/regex/v4/regex_iterator.hpp +++ b/boost/regex/v4/regex_iterator.hpp @@ -82,14 +82,14 @@ private: }; template <class BidirectionalIterator, - class charT = BOOST_DEDUCED_TYPENAME re_detail::regex_iterator_traits<BidirectionalIterator>::value_type, + class charT = BOOST_DEDUCED_TYPENAME BOOST_REGEX_DETAIL_NS::regex_iterator_traits<BidirectionalIterator>::value_type, class traits = regex_traits<charT> > class regex_iterator #ifndef BOOST_NO_STD_ITERATOR : public std::iterator< std::forward_iterator_tag, match_results<BidirectionalIterator>, - typename re_detail::regex_iterator_traits<BidirectionalIterator>::difference_type, + typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<BidirectionalIterator>::difference_type, const match_results<BidirectionalIterator>*, const match_results<BidirectionalIterator>& > #endif @@ -100,7 +100,7 @@ private: public: typedef basic_regex<charT, traits> regex_type; typedef match_results<BidirectionalIterator> value_type; - typedef typename re_detail::regex_iterator_traits<BidirectionalIterator>::difference_type + typedef typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<BidirectionalIterator>::difference_type difference_type; typedef const value_type* pointer; typedef const value_type& reference; diff --git a/boost/regex/v4/regex_match.hpp b/boost/regex/v4/regex_match.hpp index e947a15225..a50daa2aa5 100644 --- a/boost/regex/v4/regex_match.hpp +++ b/boost/regex/v4/regex_match.hpp @@ -46,7 +46,7 @@ bool regex_match(BidiIterator first, BidiIterator last, const basic_regex<charT, traits>& e, match_flag_type flags = match_default) { - re_detail::perl_matcher<BidiIterator, Allocator, traits> matcher(first, last, m, e, flags, first); + BOOST_REGEX_DETAIL_NS::perl_matcher<BidiIterator, Allocator, traits> matcher(first, last, m, e, flags, first); return matcher.match(); } template <class iterator, class charT, class traits> diff --git a/boost/regex/v4/regex_raw_buffer.hpp b/boost/regex/v4/regex_raw_buffer.hpp index c7792e3d2e..fcdb856a55 100644 --- a/boost/regex/v4/regex_raw_buffer.hpp +++ b/boost/regex/v4/regex_raw_buffer.hpp @@ -29,7 +29,7 @@ #include <cstddef> namespace boost{ - namespace re_detail{ + namespace BOOST_REGEX_DETAIL_NS{ #ifdef BOOST_MSVC #pragma warning(push) @@ -198,7 +198,7 @@ inline raw_storage::raw_storage(size_type n) #pragma warning(pop) #endif -} // namespace re_detail +} // namespace BOOST_REGEX_DETAIL_NS } // namespace boost #endif diff --git a/boost/regex/v4/regex_replace.hpp b/boost/regex/v4/regex_replace.hpp index ac8e3c81e2..415c58b634 100644 --- a/boost/regex/v4/regex_replace.hpp +++ b/boost/regex/v4/regex_replace.hpp @@ -48,7 +48,7 @@ OutputIterator regex_replace(OutputIterator out, if(i == j) { if(!(flags & regex_constants::format_no_copy)) - out = re_detail::copy(first, last, out); + out = BOOST_REGEX_DETAIL_NS::copy(first, last, out); } else { @@ -56,7 +56,7 @@ OutputIterator regex_replace(OutputIterator out, while(i != j) { if(!(flags & regex_constants::format_no_copy)) - out = re_detail::copy(i->prefix().first, i->prefix().second, out); + out = BOOST_REGEX_DETAIL_NS::copy(i->prefix().first, i->prefix().second, out); out = i->format(out, fmt, flags, e); last_m = (*i)[0].second; if(flags & regex_constants::format_first_only) @@ -64,7 +64,7 @@ OutputIterator regex_replace(OutputIterator out, ++i; } if(!(flags & regex_constants::format_no_copy)) - out = re_detail::copy(last_m, last, out); + out = BOOST_REGEX_DETAIL_NS::copy(last_m, last, out); } return out; } @@ -76,7 +76,7 @@ std::basic_string<charT> regex_replace(const std::basic_string<charT>& s, match_flag_type flags = match_default) { std::basic_string<charT> result; - re_detail::string_out_iterator<std::basic_string<charT> > i(result); + BOOST_REGEX_DETAIL_NS::string_out_iterator<std::basic_string<charT> > i(result); regex_replace(i, s.begin(), s.end(), e, fmt, flags); return result; } diff --git a/boost/regex/v4/regex_search.hpp b/boost/regex/v4/regex_search.hpp index cf5579d2c7..0725d3ec3f 100644 --- a/boost/regex/v4/regex_search.hpp +++ b/boost/regex/v4/regex_search.hpp @@ -52,7 +52,7 @@ bool regex_search(BidiIterator first, BidiIterator last, if(e.flags() & regex_constants::failbit) return false; - re_detail::perl_matcher<BidiIterator, Allocator, traits> matcher(first, last, m, e, flags, base); + BOOST_REGEX_DETAIL_NS::perl_matcher<BidiIterator, Allocator, traits> matcher(first, last, m, e, flags, base); return matcher.find(); } @@ -141,7 +141,7 @@ bool regex_search(BidiIterator first, BidiIterator last, match_results<BidiIterator> m; typedef typename match_results<BidiIterator>::allocator_type match_alloc_type; - re_detail::perl_matcher<BidiIterator, match_alloc_type, traits> matcher(first, last, m, e, flags | regex_constants::match_any, first); + BOOST_REGEX_DETAIL_NS::perl_matcher<BidiIterator, match_alloc_type, traits> matcher(first, last, m, e, flags | regex_constants::match_any, first); return matcher.find(); } diff --git a/boost/regex/v4/regex_split.hpp b/boost/regex/v4/regex_split.hpp index c12d7baa24..65b2c64abf 100644 --- a/boost/regex/v4/regex_split.hpp +++ b/boost/regex/v4/regex_split.hpp @@ -39,7 +39,7 @@ namespace boost{ # pragma warning(disable: 4800) #endif -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ template <class charT> const basic_regex<charT>& get_default_expression(charT) @@ -97,7 +97,7 @@ bool split_pred<OutputIterator, charT, Traits1, Alloc1>::operator() return true; } -} // namespace re_detail +} // namespace BOOST_REGEX_DETAIL_NS template <class OutputIterator, class charT, class Traits1, class Alloc1, class Traits2> std::size_t regex_split(OutputIterator out, @@ -110,7 +110,7 @@ std::size_t regex_split(OutputIterator out, //typedef typename match_results<ci_t>::allocator_type match_allocator; ci_t last = s.begin(); std::size_t init_size = max_split; - re_detail::split_pred<OutputIterator, charT, Traits1, Alloc1> pred(&last, &out, &max_split); + BOOST_REGEX_DETAIL_NS::split_pred<OutputIterator, charT, Traits1, Alloc1> pred(&last, &out, &max_split); ci_t i, j; i = s.begin(); j = s.end(); @@ -147,7 +147,7 @@ template <class OutputIterator, class charT, class Traits1, class Alloc1> inline std::size_t regex_split(OutputIterator out, std::basic_string<charT, Traits1, Alloc1>& s) { - return regex_split(out, s, re_detail::get_default_expression(charT(0)), match_default, UINT_MAX); + return regex_split(out, s, BOOST_REGEX_DETAIL_NS::get_default_expression(charT(0)), match_default, UINT_MAX); } #ifdef BOOST_MSVC diff --git a/boost/regex/v4/regex_token_iterator.hpp b/boost/regex/v4/regex_token_iterator.hpp index dbb0803742..1d75604bf1 100644 --- a/boost/regex/v4/regex_token_iterator.hpp +++ b/boost/regex/v4/regex_token_iterator.hpp @@ -164,14 +164,14 @@ private: }; template <class BidirectionalIterator, - class charT = BOOST_DEDUCED_TYPENAME re_detail::regex_iterator_traits<BidirectionalIterator>::value_type, + class charT = BOOST_DEDUCED_TYPENAME BOOST_REGEX_DETAIL_NS::regex_iterator_traits<BidirectionalIterator>::value_type, class traits = regex_traits<charT> > class regex_token_iterator #ifndef BOOST_NO_STD_ITERATOR : public std::iterator< std::forward_iterator_tag, sub_match<BidirectionalIterator>, - typename re_detail::regex_iterator_traits<BidirectionalIterator>::difference_type, + typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<BidirectionalIterator>::difference_type, const sub_match<BidirectionalIterator>*, const sub_match<BidirectionalIterator>& > #endif @@ -182,7 +182,7 @@ private: public: typedef basic_regex<charT, traits> regex_type; typedef sub_match<BidirectionalIterator> value_type; - typedef typename re_detail::regex_iterator_traits<BidirectionalIterator>::difference_type + typedef typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<BidirectionalIterator>::difference_type difference_type; typedef const value_type* pointer; typedef const value_type& reference; diff --git a/boost/regex/v4/regex_traits.hpp b/boost/regex/v4/regex_traits.hpp index 8b1cb6ffe1..45a4bdf626 100644 --- a/boost/regex/v4/regex_traits.hpp +++ b/boost/regex/v4/regex_traits.hpp @@ -82,7 +82,7 @@ struct regex_traits : public implementationT // interfaces that we support, in addition to the // required "standard" ones: // -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ #if !BOOST_WORKAROUND(__HP_aCC, < 60000) BOOST_MPL_HAS_XXX_TRAIT_DEF(boost_extensions_tag) #else @@ -99,7 +99,7 @@ struct default_wrapper : public BaseT typedef typename BaseT::char_type char_type; std::string error_string(::boost::regex_constants::error_type e)const { - return ::boost::re_detail::get_default_error_string(e); + return ::boost::BOOST_REGEX_DETAIL_NS::get_default_error_string(e); } ::boost::regex_constants::syntax_type syntax_type(char_type c)const { @@ -111,7 +111,7 @@ struct default_wrapper : public BaseT } int toi(const char_type*& p1, const char_type* p2, int radix)const { - return ::boost::re_detail::global_toi(p1, p2, radix, *this); + return ::boost::BOOST_REGEX_DETAIL_NS::global_toi(p1, p2, radix, *this); } char_type translate(char_type c, bool icase)const { @@ -123,11 +123,11 @@ struct default_wrapper : public BaseT } char_type tolower(char_type c)const { - return ::boost::re_detail::global_lower(c); + return ::boost::BOOST_REGEX_DETAIL_NS::global_lower(c); } char_type toupper(char_type c)const { - return ::boost::re_detail::global_upper(c); + return ::boost::BOOST_REGEX_DETAIL_NS::global_upper(c); } }; @@ -157,13 +157,13 @@ struct compute_wrapper_base<c_regex_traits<wchar_t>, false> #endif #endif -} // namespace re_detail +} // namespace BOOST_REGEX_DETAIL_NS template <class BaseT> struct regex_traits_wrapper - : public ::boost::re_detail::compute_wrapper_base< + : public ::boost::BOOST_REGEX_DETAIL_NS::compute_wrapper_base< BaseT, - ::boost::re_detail::has_boost_extensions_tag<BaseT>::value + ::boost::BOOST_REGEX_DETAIL_NS::has_boost_extensions_tag<BaseT>::value >::type { regex_traits_wrapper(){} diff --git a/boost/regex/v4/regex_traits_defaults.hpp b/boost/regex/v4/regex_traits_defaults.hpp index a087d78449..1821883717 100644 --- a/boost/regex/v4/regex_traits_defaults.hpp +++ b/boost/regex/v4/regex_traits_defaults.hpp @@ -30,12 +30,15 @@ #pragma warning(pop) #endif +#include <boost/regex/config.hpp> + #ifndef BOOST_REGEX_SYNTAX_TYPE_HPP #include <boost/regex/v4/syntax_type.hpp> #endif #ifndef BOOST_REGEX_ERROR_TYPE_HPP #include <boost/regex/v4/error_type.hpp> #endif +#include <boost/type_traits/make_unsigned.hpp> #ifdef BOOST_NO_STDC_NAMESPACE namespace std{ @@ -43,7 +46,7 @@ namespace std{ } #endif -namespace boost{ namespace re_detail{ +namespace boost{ namespace BOOST_REGEX_DETAIL_NS{ // @@ -51,7 +54,10 @@ namespace boost{ namespace re_detail{ // template <class charT> inline bool is_extended(charT c) -{ return c > 256; } +{ + typedef typename make_unsigned<charT>::type unsigned_type; + return (sizeof(charT) > 1) && (static_cast<unsigned_type>(c) >= 256u); +} inline bool is_extended(char) { return false; } @@ -153,7 +159,7 @@ struct character_pointer_range // calling std::equal, but there is no other algorithm available: // not even a non-standard MS one. So forward to unchecked_equal // in the MS case. - return ((p2 - p1) == (r.p2 - r.p1)) && re_detail::equal(p1, p2, r.p1); + return ((p2 - p1) == (r.p2 - r.p1)) && BOOST_REGEX_DETAIL_NS::equal(p1, p2, r.p1); } }; template <class charT> @@ -354,7 +360,7 @@ inline const char* get_escape_R_string<char>() #endif } -} // re_detail +} // BOOST_REGEX_DETAIL_NS } // boost #ifdef BOOST_MSVC diff --git a/boost/regex/v4/regex_workaround.hpp b/boost/regex/v4/regex_workaround.hpp index fc57472a38..821be608c1 100644 --- a/boost/regex/v4/regex_workaround.hpp +++ b/boost/regex/v4/regex_workaround.hpp @@ -42,6 +42,7 @@ #include <boost/scoped_array.hpp> #include <boost/shared_ptr.hpp> #include <boost/mpl/bool_fwd.hpp> +#include <boost/regex/config.hpp> #ifndef BOOST_NO_STD_LOCALE # include <locale> #endif @@ -52,7 +53,7 @@ namespace std{ } #endif -namespace boost{ namespace re_detail{ +namespace boost{ namespace BOOST_REGEX_DETAIL_NS{ #ifdef BOOST_NO_STD_DISTANCE template <class T> std::ptrdiff_t distance(const T& x, const T& y) @@ -94,7 +95,7 @@ namespace std{ ****************************************************************************/ #ifdef __cplusplus -namespace boost{ namespace re_detail{ +namespace boost{ namespace BOOST_REGEX_DETAIL_NS{ #ifdef BOOST_MSVC #pragma warning (push) @@ -123,7 +124,7 @@ inline void pointer_construct(T* p, const T& t) ****************************************************************************/ #ifdef __cplusplus -namespace boost{ namespace re_detail{ +namespace boost{ namespace BOOST_REGEX_DETAIL_NS{ #if BOOST_WORKAROUND(BOOST_MSVC,>=1400) && BOOST_WORKAROUND(BOOST_MSVC, <1600) && defined(_CPPLIB_VER) && defined(BOOST_DINKUMWARE_STDLIB) && !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) // // MSVC 8 will either emit warnings or else refuse to compile diff --git a/boost/regex/v4/states.hpp b/boost/regex/v4/states.hpp index 38690b2299..b56d013476 100644 --- a/boost/regex/v4/states.hpp +++ b/boost/regex/v4/states.hpp @@ -31,7 +31,7 @@ #endif namespace boost{ -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ /*** mask_type ******************************************************* Whenever we have a choice of two alternatives, we use an array of bytes @@ -120,7 +120,12 @@ enum syntax_element_type syntax_element_assert_backref = syntax_element_backstep + 1, syntax_element_toggle_case = syntax_element_assert_backref + 1, // a recursive expression: - syntax_element_recurse = syntax_element_toggle_case + 1 + syntax_element_recurse = syntax_element_toggle_case + 1, + // Verbs: + syntax_element_fail = syntax_element_recurse + 1, + syntax_element_accept = syntax_element_fail + 1, + syntax_element_commit = syntax_element_accept + 1, + syntax_element_then = syntax_element_commit + 1 }; #ifdef BOOST_REGEX_DEBUG @@ -256,6 +261,21 @@ struct re_recurse : public re_jump int state_id; // identifier of first nested repeat within the recursion. }; +/*** struct re_commit ************************************************* +Used for the PRUNE, SKIP and COMMIT verbs which basically differ only in what happens +if no match is found and we start searching forward. +**********************************************************************/ +enum commit_type +{ + commit_prune, + commit_skip, + commit_commit +}; +struct re_commit : public re_syntax_base +{ + commit_type action; +}; + /*** enum re_jump_size_type ******************************************* Provides compiled size of re_jump structure (allowing for trailing alignment). We provide this so we know how manybytes to insert when constructing the machine @@ -281,7 +301,7 @@ iterator BOOST_REGEX_CALL re_is_set_member(iterator next, const re_set_long<char_classT>* set_, const regex_data<charT, traits_type>& e, bool icase); -} // namespace re_detail +} // namespace BOOST_REGEX_DETAIL_NS } // namespace boost diff --git a/boost/regex/v4/sub_match.hpp b/boost/regex/v4/sub_match.hpp index 7ce8d5397e..ff8a8e467b 100644 --- a/boost/regex/v4/sub_match.hpp +++ b/boost/regex/v4/sub_match.hpp @@ -35,11 +35,11 @@ namespace boost{ template <class BidiIterator> struct sub_match : public std::pair<BidiIterator, BidiIterator> { - typedef typename re_detail::regex_iterator_traits<BidiIterator>::value_type value_type; + typedef typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<BidiIterator>::value_type value_type; #if defined(BOOST_NO_STD_ITERATOR_TRAITS) typedef std::ptrdiff_t difference_type; #else - typedef typename re_detail::regex_iterator_traits<BidiIterator>::difference_type difference_type; + typedef typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<BidiIterator>::difference_type difference_type; #endif typedef BidiIterator iterator_type; typedef BidiIterator iterator; @@ -65,7 +65,7 @@ struct sub_match : public std::pair<BidiIterator, BidiIterator> #endif difference_type BOOST_REGEX_CALL length()const { - difference_type n = matched ? ::boost::re_detail::distance((BidiIterator)this->first, (BidiIterator)this->second) : 0; + difference_type n = matched ? ::boost::BOOST_REGEX_DETAIL_NS::distance((BidiIterator)this->first, (BidiIterator)this->second) : 0; return n; } std::basic_string<value_type> str()const @@ -73,7 +73,7 @@ struct sub_match : public std::pair<BidiIterator, BidiIterator> std::basic_string<value_type> result; if(matched) { - std::size_t len = ::boost::re_detail::distance((BidiIterator)this->first, (BidiIterator)this->second); + std::size_t len = ::boost::BOOST_REGEX_DETAIL_NS::distance((BidiIterator)this->first, (BidiIterator)this->second); result.reserve(len); BidiIterator i = this->first; while(i != this->second) @@ -162,6 +162,11 @@ public: #endif return *this; } + // + // Make this type a range, for both Boost.Range, and C++11: + // + BidiIterator begin()const { return this->first; } + BidiIterator end()const { return this->second; } #ifdef BOOST_OLD_REGEX_H @@ -190,235 +195,235 @@ typedef sub_match<std::wstring::const_iterator> wssub_match; // comparison to std::basic_string<> part 1: template <class RandomAccessIterator, class traits, class Allocator> -inline bool operator == (const std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s, +inline bool operator == (const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s, const sub_match<RandomAccessIterator>& m) { return s.compare(m.str()) == 0; } template <class RandomAccessIterator, class traits, class Allocator> -inline bool operator != (const std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s, +inline bool operator != (const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s, const sub_match<RandomAccessIterator>& m) { return s.compare(m.str()) != 0; } template <class RandomAccessIterator, class traits, class Allocator> -inline bool operator < (const std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s, +inline bool operator < (const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s, const sub_match<RandomAccessIterator>& m) { return s.compare(m.str()) < 0; } template <class RandomAccessIterator, class traits, class Allocator> -inline bool operator <= (const std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s, +inline bool operator <= (const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s, const sub_match<RandomAccessIterator>& m) { return s.compare(m.str()) <= 0; } template <class RandomAccessIterator, class traits, class Allocator> -inline bool operator >= (const std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s, +inline bool operator >= (const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s, const sub_match<RandomAccessIterator>& m) { return s.compare(m.str()) >= 0; } template <class RandomAccessIterator, class traits, class Allocator> -inline bool operator > (const std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s, +inline bool operator > (const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s, const sub_match<RandomAccessIterator>& m) { return s.compare(m.str()) > 0; } // comparison to std::basic_string<> part 2: template <class RandomAccessIterator, class traits, class Allocator> inline bool operator == (const sub_match<RandomAccessIterator>& m, - const std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s) + const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s) { return m.str().compare(s) == 0; } template <class RandomAccessIterator, class traits, class Allocator> inline bool operator != (const sub_match<RandomAccessIterator>& m, - const std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s) + const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s) { return m.str().compare(s) != 0; } template <class RandomAccessIterator, class traits, class Allocator> inline bool operator < (const sub_match<RandomAccessIterator>& m, - const std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s) + const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s) { return m.str().compare(s) < 0; } template <class RandomAccessIterator, class traits, class Allocator> inline bool operator > (const sub_match<RandomAccessIterator>& m, - const std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s) + const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s) { return m.str().compare(s) > 0; } template <class RandomAccessIterator, class traits, class Allocator> inline bool operator <= (const sub_match<RandomAccessIterator>& m, - const std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s) + const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s) { return m.str().compare(s) <= 0; } template <class RandomAccessIterator, class traits, class Allocator> inline bool operator >= (const sub_match<RandomAccessIterator>& m, - const std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s) + const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s) { return m.str().compare(s) >= 0; } // comparison to const charT* part 1: template <class RandomAccessIterator> inline bool operator == (const sub_match<RandomAccessIterator>& m, - typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const* s) + typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s) { return m.str().compare(s) == 0; } template <class RandomAccessIterator> inline bool operator != (const sub_match<RandomAccessIterator>& m, - typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const* s) + typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s) { return m.str().compare(s) != 0; } template <class RandomAccessIterator> inline bool operator > (const sub_match<RandomAccessIterator>& m, - typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const* s) + typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s) { return m.str().compare(s) > 0; } template <class RandomAccessIterator> inline bool operator < (const sub_match<RandomAccessIterator>& m, - typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const* s) + typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s) { return m.str().compare(s) < 0; } template <class RandomAccessIterator> inline bool operator >= (const sub_match<RandomAccessIterator>& m, - typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const* s) + typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s) { return m.str().compare(s) >= 0; } template <class RandomAccessIterator> inline bool operator <= (const sub_match<RandomAccessIterator>& m, - typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const* s) + typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s) { return m.str().compare(s) <= 0; } // comparison to const charT* part 2: template <class RandomAccessIterator> -inline bool operator == (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const* s, +inline bool operator == (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s, const sub_match<RandomAccessIterator>& m) { return m.str().compare(s) == 0; } template <class RandomAccessIterator> -inline bool operator != (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const* s, +inline bool operator != (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s, const sub_match<RandomAccessIterator>& m) { return m.str().compare(s) != 0; } template <class RandomAccessIterator> -inline bool operator < (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const* s, +inline bool operator < (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s, const sub_match<RandomAccessIterator>& m) { return m.str().compare(s) > 0; } template <class RandomAccessIterator> -inline bool operator > (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const* s, +inline bool operator > (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s, const sub_match<RandomAccessIterator>& m) { return m.str().compare(s) < 0; } template <class RandomAccessIterator> -inline bool operator <= (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const* s, +inline bool operator <= (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s, const sub_match<RandomAccessIterator>& m) { return m.str().compare(s) >= 0; } template <class RandomAccessIterator> -inline bool operator >= (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const* s, +inline bool operator >= (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s, const sub_match<RandomAccessIterator>& m) { return m.str().compare(s) <= 0; } // comparison to const charT& part 1: template <class RandomAccessIterator> inline bool operator == (const sub_match<RandomAccessIterator>& m, - typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s) + typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s) { return m.str().compare(0, m.length(), &s, 1) == 0; } template <class RandomAccessIterator> inline bool operator != (const sub_match<RandomAccessIterator>& m, - typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s) + typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s) { return m.str().compare(0, m.length(), &s, 1) != 0; } template <class RandomAccessIterator> inline bool operator > (const sub_match<RandomAccessIterator>& m, - typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s) + typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s) { return m.str().compare(0, m.length(), &s, 1) > 0; } template <class RandomAccessIterator> inline bool operator < (const sub_match<RandomAccessIterator>& m, - typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s) + typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s) { return m.str().compare(0, m.length(), &s, 1) < 0; } template <class RandomAccessIterator> inline bool operator >= (const sub_match<RandomAccessIterator>& m, - typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s) + typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s) { return m.str().compare(0, m.length(), &s, 1) >= 0; } template <class RandomAccessIterator> inline bool operator <= (const sub_match<RandomAccessIterator>& m, - typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s) + typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s) { return m.str().compare(0, m.length(), &s, 1) <= 0; } // comparison to const charT* part 2: template <class RandomAccessIterator> -inline bool operator == (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s, +inline bool operator == (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s, const sub_match<RandomAccessIterator>& m) { return m.str().compare(0, m.length(), &s, 1) == 0; } template <class RandomAccessIterator> -inline bool operator != (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s, +inline bool operator != (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s, const sub_match<RandomAccessIterator>& m) { return m.str().compare(0, m.length(), &s, 1) != 0; } template <class RandomAccessIterator> -inline bool operator < (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s, +inline bool operator < (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s, const sub_match<RandomAccessIterator>& m) { return m.str().compare(0, m.length(), &s, 1) > 0; } template <class RandomAccessIterator> -inline bool operator > (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s, +inline bool operator > (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s, const sub_match<RandomAccessIterator>& m) { return m.str().compare(0, m.length(), &s, 1) < 0; } template <class RandomAccessIterator> -inline bool operator <= (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s, +inline bool operator <= (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s, const sub_match<RandomAccessIterator>& m) { return m.str().compare(0, m.length(), &s, 1) >= 0; } template <class RandomAccessIterator> -inline bool operator >= (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s, +inline bool operator >= (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s, const sub_match<RandomAccessIterator>& m) { return m.str().compare(0, m.length(), &s, 1) <= 0; } // addition operators: template <class RandomAccessIterator, class traits, class Allocator> -inline std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator> -operator + (const std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s, +inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator> +operator + (const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s, const sub_match<RandomAccessIterator>& m) { - std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator> result; + std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator> result; result.reserve(s.size() + m.length() + 1); return result.append(s).append(m.first, m.second); } template <class RandomAccessIterator, class traits, class Allocator> -inline std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator> +inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator> operator + (const sub_match<RandomAccessIterator>& m, - const std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s) + const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s) { - std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator> result; + std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator> result; result.reserve(s.size() + m.length() + 1); return result.append(m.first, m.second).append(s); } #if !(defined(__GNUC__) && defined(BOOST_NO_STD_LOCALE)) template <class RandomAccessIterator> -inline std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type> -operator + (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const* s, +inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> +operator + (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s, const sub_match<RandomAccessIterator>& m) { - std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type> result; - result.reserve(std::char_traits<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type>::length(s) + m.length() + 1); + std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> result; + result.reserve(std::char_traits<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type>::length(s) + m.length() + 1); return result.append(s).append(m.first, m.second); } template <class RandomAccessIterator> -inline std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type> +inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> operator + (const sub_match<RandomAccessIterator>& m, - typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const * s) + typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const * s) { - std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type> result; - result.reserve(std::char_traits<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type>::length(s) + m.length() + 1); + std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> result; + result.reserve(std::char_traits<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type>::length(s) + m.length() + 1); return result.append(m.first, m.second).append(s); } #else // worwaround versions: template <class RandomAccessIterator> -inline std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type> -operator + (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const* s, +inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> +operator + (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s, const sub_match<RandomAccessIterator>& m) { return s + m.str(); } template <class RandomAccessIterator> -inline std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type> +inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> operator + (const sub_match<RandomAccessIterator>& m, - typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const * s) + typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const * s) { return m.str() + s; } #endif template <class RandomAccessIterator> -inline std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type> -operator + (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s, +inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> +operator + (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s, const sub_match<RandomAccessIterator>& m) { - std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type> result; + std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> result; result.reserve(m.length() + 2); return result.append(1, s).append(m.first, m.second); } template <class RandomAccessIterator> -inline std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type> +inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> operator + (const sub_match<RandomAccessIterator>& m, - typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s) + typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s) { - std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type> result; + std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> result; result.reserve(m.length() + 2); return result.append(m.first, m.second).append(1, s); } template <class RandomAccessIterator> -inline std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type> +inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> operator + (const sub_match<RandomAccessIterator>& m1, const sub_match<RandomAccessIterator>& m2) { - std::basic_string<typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type> result; + std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> result; result.reserve(m1.length() + m2.length() + 1); return result.append(m1.first, m1.second).append(m2.first, m2.second); } @@ -440,7 +445,7 @@ std::ostream& operator << (std::ostream& os, #endif #ifdef BOOST_OLD_REGEX_H -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ template <class BidiIterator, class charT> int do_toi(BidiIterator i, BidiIterator j, char c, int radix) { @@ -479,7 +484,7 @@ sub_match<BidiIterator>::operator int()const neg = -1; ++i; } - neg *= re_detail::do_toi(i, j, *i); + neg *= BOOST_REGEX_DETAIL_NS::do_toi(i, j, *i); if(i != j)raise_regex_exception("Bad sub-expression"); return neg; } @@ -490,7 +495,7 @@ sub_match<BidiIterator>::operator unsigned int()const BidiIterator j = second; if(i == j) raise_regex_exception("Bad sub-expression"); - return re_detail::do_toi(i, j, *first); + return BOOST_REGEX_DETAIL_NS::do_toi(i, j, *first); } #endif diff --git a/boost/regex/v4/u32regex_iterator.hpp b/boost/regex/v4/u32regex_iterator.hpp index 65ebd7f8ea..701ef3d80e 100644 --- a/boost/regex/v4/u32regex_iterator.hpp +++ b/boost/regex/v4/u32regex_iterator.hpp @@ -76,7 +76,7 @@ class u32regex_iterator : public std::iterator< std::forward_iterator_tag, match_results<BidirectionalIterator>, - typename re_detail::regex_iterator_traits<BidirectionalIterator>::difference_type, + typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<BidirectionalIterator>::difference_type, const match_results<BidirectionalIterator>*, const match_results<BidirectionalIterator>& > #endif @@ -87,7 +87,7 @@ private: public: typedef u32regex regex_type; typedef match_results<BidirectionalIterator> value_type; - typedef typename re_detail::regex_iterator_traits<BidirectionalIterator>::difference_type + typedef typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<BidirectionalIterator>::difference_type difference_type; typedef const value_type* pointer; typedef const value_type& reference; diff --git a/boost/regex/v4/u32regex_token_iterator.hpp b/boost/regex/v4/u32regex_token_iterator.hpp index e8649f323d..9eabbe48a1 100644 --- a/boost/regex/v4/u32regex_token_iterator.hpp +++ b/boost/regex/v4/u32regex_token_iterator.hpp @@ -159,7 +159,7 @@ class u32regex_token_iterator : public std::iterator< std::forward_iterator_tag, sub_match<BidirectionalIterator>, - typename re_detail::regex_iterator_traits<BidirectionalIterator>::difference_type, + typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<BidirectionalIterator>::difference_type, const sub_match<BidirectionalIterator>*, const sub_match<BidirectionalIterator>& > #endif @@ -170,7 +170,7 @@ private: public: typedef u32regex regex_type; typedef sub_match<BidirectionalIterator> value_type; - typedef typename re_detail::regex_iterator_traits<BidirectionalIterator>::difference_type + typedef typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<BidirectionalIterator>::difference_type difference_type; typedef const value_type* pointer; typedef const value_type& reference; diff --git a/boost/regex/v4/w32_regex_traits.hpp b/boost/regex/v4/w32_regex_traits.hpp index ef934b75cc..560cc217bb 100644 --- a/boost/regex/v4/w32_regex_traits.hpp +++ b/boost/regex/v4/w32_regex_traits.hpp @@ -19,6 +19,8 @@ #ifndef BOOST_W32_REGEX_TRAITS_HPP_INCLUDED #define BOOST_W32_REGEX_TRAITS_HPP_INCLUDED +#ifndef BOOST_REGEX_NO_WIN32_LOCALE + #ifndef BOOST_RE_PAT_EXCEPT_HPP #include <boost/regex/pattern_except.hpp> #endif @@ -60,7 +62,7 @@ namespace boost{ template <class charT> class w32_regex_traits; -namespace re_detail{ +namespace BOOST_REGEX_DETAIL_NS{ // // start by typedeffing the types we'll need: @@ -164,19 +166,19 @@ public: map_iterator_type i = m_char_map.find(c); if(i == m_char_map.end()) { - if(::boost::re_detail::w32_is_lower(c, this->m_locale)) return regex_constants::escape_type_class; - if(::boost::re_detail::w32_is_upper(c, this->m_locale)) return regex_constants::escape_type_not_class; + if(::boost::BOOST_REGEX_DETAIL_NS::w32_is_lower(c, this->m_locale)) return regex_constants::escape_type_class; + if(::boost::BOOST_REGEX_DETAIL_NS::w32_is_upper(c, this->m_locale)) return regex_constants::escape_type_not_class; return 0; } return i->second; } charT tolower(charT c)const { - return ::boost::re_detail::w32_tolower(c, this->m_locale); + return ::boost::BOOST_REGEX_DETAIL_NS::w32_tolower(c, this->m_locale); } bool isctype(boost::uint32_t mask, charT c)const { - return ::boost::re_detail::w32_is(this->m_locale, mask, c); + return ::boost::BOOST_REGEX_DETAIL_NS::w32_is(this->m_locale, mask, c); } private: @@ -186,7 +188,7 @@ private: }; template <class charT> -w32_regex_traits_char_layer<charT>::w32_regex_traits_char_layer(::boost::re_detail::lcid_type l) +w32_regex_traits_char_layer<charT>::w32_regex_traits_char_layer(::boost::BOOST_REGEX_DETAIL_NS::lcid_type l) : w32_regex_traits_base<charT>(l) { // we need to start by initialising our syntax map so we know which @@ -195,12 +197,12 @@ w32_regex_traits_char_layer<charT>::w32_regex_traits_char_layer(::boost::re_deta std::string cat_name(w32_regex_traits<charT>::get_catalog_name()); if(cat_name.size()) { - cat = ::boost::re_detail::w32_cat_open(cat_name); + cat = ::boost::BOOST_REGEX_DETAIL_NS::w32_cat_open(cat_name); if(!cat) { std::string m("Unable to open message catalog: "); std::runtime_error err(m + cat_name); - boost::re_detail::raise_runtime_error(err); + boost::BOOST_REGEX_DETAIL_NS::raise_runtime_error(err); } } // @@ -210,7 +212,7 @@ w32_regex_traits_char_layer<charT>::w32_regex_traits_char_layer(::boost::re_deta { for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i) { - string_type mss = ::boost::re_detail::w32_cat_get(cat, this->m_locale, i, get_default_message(i)); + string_type mss = ::boost::BOOST_REGEX_DETAIL_NS::w32_cat_get(cat, this->m_locale, i, get_default_message(i)); for(typename string_type::size_type j = 0; j < mss.size(); ++j) { this->m_char_map[mss[j]] = i; @@ -253,7 +255,7 @@ class BOOST_REGEX_DECL w32_regex_traits_char_layer<char> : public w32_regex_trai { typedef std::string string_type; public: - w32_regex_traits_char_layer(::boost::re_detail::lcid_type l) + w32_regex_traits_char_layer(::boost::BOOST_REGEX_DETAIL_NS::lcid_type l) : w32_regex_traits_base<char>(l) { init(); @@ -300,7 +302,7 @@ public: typedef std::basic_string<charT> string_type; typedef charT char_type; - w32_regex_traits_implementation(::boost::re_detail::lcid_type l); + w32_regex_traits_implementation(::boost::BOOST_REGEX_DETAIL_NS::lcid_type l); std::string error_string(regex_constants::error_type n) const { if(!m_error_strings.empty()) @@ -327,7 +329,7 @@ public: string_type transform_primary(const charT* p1, const charT* p2) const; string_type transform(const charT* p1, const charT* p2) const { - return ::boost::re_detail::w32_transform(this->m_locale, p1, p2); + return ::boost::BOOST_REGEX_DETAIL_NS::w32_transform(this->m_locale, p1, p2); } private: std::map<int, std::string> m_error_strings; // error messages indexed by numberic ID @@ -430,19 +432,19 @@ typename w32_regex_traits_implementation<charT>::string_type } template <class charT> -w32_regex_traits_implementation<charT>::w32_regex_traits_implementation(::boost::re_detail::lcid_type l) +w32_regex_traits_implementation<charT>::w32_regex_traits_implementation(::boost::BOOST_REGEX_DETAIL_NS::lcid_type l) : w32_regex_traits_char_layer<charT>(l) { cat_type cat; std::string cat_name(w32_regex_traits<charT>::get_catalog_name()); if(cat_name.size()) { - cat = ::boost::re_detail::w32_cat_open(cat_name); + cat = ::boost::BOOST_REGEX_DETAIL_NS::w32_cat_open(cat_name); if(!cat) { std::string m("Unable to open message catalog: "); std::runtime_error err(m + cat_name); - boost::re_detail::raise_runtime_error(err); + boost::BOOST_REGEX_DETAIL_NS::raise_runtime_error(err); } } // @@ -464,7 +466,7 @@ w32_regex_traits_implementation<charT>::w32_regex_traits_implementation(::boost: default_message.append(1, static_cast<charT>(*p)); ++p; } - string_type s = ::boost::re_detail::w32_cat_get(cat, this->m_locale, i+200, default_message); + string_type s = ::boost::BOOST_REGEX_DETAIL_NS::w32_cat_get(cat, this->m_locale, i+200, default_message); std::string result; for(std::string::size_type j = 0; j < s.size(); ++j) { @@ -495,7 +497,7 @@ w32_regex_traits_implementation<charT>::w32_regex_traits_implementation(::boost: static const string_type null_string; for(unsigned int j = 0; j <= 13; ++j) { - string_type s(::boost::re_detail::w32_cat_get(cat, this->m_locale, j+300, null_string)); + string_type s(::boost::BOOST_REGEX_DETAIL_NS::w32_cat_get(cat, this->m_locale, j+300, null_string)); if(s.size()) this->m_custom_class_names[s] = masks[j]; } @@ -503,7 +505,7 @@ w32_regex_traits_implementation<charT>::w32_regex_traits_implementation(::boost: // // get the collation format used by m_pcollate: // - m_collate_type = re_detail::find_sort_syntax(this, &m_collate_delim); + m_collate_type = BOOST_REGEX_DETAIL_NS::find_sort_syntax(this, &m_collate_delim); } template <class charT> @@ -542,7 +544,7 @@ typename w32_regex_traits_implementation<charT>::char_class_type if(pos != m_custom_class_names.end()) return pos->second; } - std::size_t state_id = 1 + re_detail::get_default_class_id(p1, p2); + std::size_t state_id = 1 + BOOST_REGEX_DETAIL_NS::get_default_class_id(p1, p2); if(state_id < sizeof(masks) / sizeof(masks[0])) return masks[state_id]; return masks[0]; @@ -550,13 +552,13 @@ typename w32_regex_traits_implementation<charT>::char_class_type template <class charT> -boost::shared_ptr<const w32_regex_traits_implementation<charT> > create_w32_regex_traits(::boost::re_detail::lcid_type l) +boost::shared_ptr<const w32_regex_traits_implementation<charT> > create_w32_regex_traits(::boost::BOOST_REGEX_DETAIL_NS::lcid_type l) { // TODO: create a cache for previously constructed objects. - return boost::object_cache< ::boost::re_detail::lcid_type, w32_regex_traits_implementation<charT> >::get(l, 5); + return boost::object_cache< ::boost::BOOST_REGEX_DETAIL_NS::lcid_type, w32_regex_traits_implementation<charT> >::get(l, 5); } -} // re_detail +} // BOOST_REGEX_DETAIL_NS template <class charT> class w32_regex_traits @@ -565,13 +567,13 @@ public: typedef charT char_type; typedef std::size_t size_type; typedef std::basic_string<char_type> string_type; - typedef ::boost::re_detail::lcid_type locale_type; + typedef ::boost::BOOST_REGEX_DETAIL_NS::lcid_type locale_type; typedef boost::uint_least32_t char_class_type; struct boost_extensions_tag{}; w32_regex_traits() - : m_pimpl(re_detail::create_w32_regex_traits<charT>(::boost::re_detail::w32_get_default_locale())) + : m_pimpl(BOOST_REGEX_DETAIL_NS::create_w32_regex_traits<charT>(::boost::BOOST_REGEX_DETAIL_NS::w32_get_default_locale())) { } static size_type length(const char_type* p) { @@ -603,11 +605,11 @@ public: } charT toupper(charT c) const { - return ::boost::re_detail::w32_toupper(c, this->m_pimpl->m_locale); + return ::boost::BOOST_REGEX_DETAIL_NS::w32_toupper(c, this->m_pimpl->m_locale); } string_type transform(const charT* p1, const charT* p2) const { - return ::boost::re_detail::w32_transform(this->m_pimpl->m_locale, p1, p2); + return ::boost::BOOST_REGEX_DETAIL_NS::w32_transform(this->m_pimpl->m_locale, p1, p2); } string_type transform_primary(const charT* p1, const charT* p2) const { @@ -623,34 +625,34 @@ public: } bool isctype(charT c, char_class_type f) const { - if((f & re_detail::w32_regex_traits_implementation<charT>::mask_base) - && (this->m_pimpl->isctype(f & re_detail::w32_regex_traits_implementation<charT>::mask_base, c))) + if((f & BOOST_REGEX_DETAIL_NS::w32_regex_traits_implementation<charT>::mask_base) + && (this->m_pimpl->isctype(f & BOOST_REGEX_DETAIL_NS::w32_regex_traits_implementation<charT>::mask_base, c))) return true; - else if((f & re_detail::w32_regex_traits_implementation<charT>::mask_unicode) && re_detail::is_extended(c)) + else if((f & BOOST_REGEX_DETAIL_NS::w32_regex_traits_implementation<charT>::mask_unicode) && BOOST_REGEX_DETAIL_NS::is_extended(c)) return true; - else if((f & re_detail::w32_regex_traits_implementation<charT>::mask_word) && (c == '_')) + else if((f & BOOST_REGEX_DETAIL_NS::w32_regex_traits_implementation<charT>::mask_word) && (c == '_')) return true; - else if((f & re_detail::w32_regex_traits_implementation<charT>::mask_vertical) - && (::boost::re_detail::is_separator(c) || (c == '\v'))) + else if((f & BOOST_REGEX_DETAIL_NS::w32_regex_traits_implementation<charT>::mask_vertical) + && (::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) || (c == '\v'))) return true; - else if((f & re_detail::w32_regex_traits_implementation<charT>::mask_horizontal) - && this->isctype(c, 0x0008u) && !this->isctype(c, re_detail::w32_regex_traits_implementation<charT>::mask_vertical)) + else if((f & BOOST_REGEX_DETAIL_NS::w32_regex_traits_implementation<charT>::mask_horizontal) + && this->isctype(c, 0x0008u) && !this->isctype(c, BOOST_REGEX_DETAIL_NS::w32_regex_traits_implementation<charT>::mask_vertical)) return true; return false; } int toi(const charT*& p1, const charT* p2, int radix)const { - return ::boost::re_detail::global_toi(p1, p2, radix, *this); + return ::boost::BOOST_REGEX_DETAIL_NS::global_toi(p1, p2, radix, *this); } int value(charT c, int radix)const { - int result = ::boost::re_detail::global_value(c); + int result = ::boost::BOOST_REGEX_DETAIL_NS::global_value(c); return result < radix ? result : -1; } locale_type imbue(locale_type l) { - ::boost::re_detail::lcid_type result(getloc()); - m_pimpl = re_detail::create_w32_regex_traits<charT>(l); + ::boost::BOOST_REGEX_DETAIL_NS::lcid_type result(getloc()); + m_pimpl = BOOST_REGEX_DETAIL_NS::create_w32_regex_traits<charT>(l); return result; } locale_type getloc()const @@ -670,7 +672,7 @@ public: static std::string get_catalog_name(); private: - boost::shared_ptr<const re_detail::w32_regex_traits_implementation<charT> > m_pimpl; + boost::shared_ptr<const BOOST_REGEX_DETAIL_NS::w32_regex_traits_implementation<charT> > m_pimpl; // // catalog name handler: // @@ -736,4 +738,6 @@ static_mutex& w32_regex_traits<charT>::get_mutex_inst() #pragma warning(pop) #endif +#endif // BOOST_REGEX_NO_WIN32_LOCALE + #endif |