diff --git a/boost/ChangeLog b/boost/ChangeLog index 26f27b4302..5bbd6f39aa 100644 --- a/boost/ChangeLog +++ b/boost/ChangeLog @@ -1,3 +1,7 @@ +2006-03-05 Lars Gullik Bjonnes + + * Upgrade to version 1.33.1 of boost. + 2006-02-21 Lars Gullik Bjønnes * boost/bind.hpp: include visit_each.hpp to fix a gcc 4.1 compile diff --git a/boost/boost/aligned_storage.hpp b/boost/boost/aligned_storage.hpp new file mode 100644 index 0000000000..9ab94a0835 --- /dev/null +++ b/boost/boost/aligned_storage.hpp @@ -0,0 +1,170 @@ +//----------------------------------------------------------------------------- +// boost aligned_storage.hpp header file +// See http://www.boost.org for updates, documentation, and revision history. +//----------------------------------------------------------------------------- +// +// Copyright (c) 2002-2003 +// Eric Friedman, Itay Maman +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ALIGNED_STORAGE_HPP +#define BOOST_ALIGNED_STORAGE_HPP + +#include // for std::size_t + +#include "boost/config.hpp" +#include "boost/detail/workaround.hpp" +#include "boost/type_traits/alignment_of.hpp" +#include "boost/type_traits/type_with_alignment.hpp" +#include "boost/type_traits/is_pod.hpp" + +#include "boost/mpl/eval_if.hpp" +#include "boost/mpl/identity.hpp" + +#include "boost/type_traits/detail/bool_trait_def.hpp" + +namespace boost { + +namespace detail { namespace aligned_storage { + +BOOST_STATIC_CONSTANT( + std::size_t + , alignment_of_max_align = ::boost::alignment_of::value + ); + +// +// To be TR1 conforming this must be a POD type: +// +template < + std::size_t size_ + , std::size_t alignment_ +> +struct aligned_storage_imp +{ + union data_t + { + char buf[size_]; + + typename mpl::eval_if_c< + alignment_ == std::size_t(-1) + , mpl::identity + , type_with_alignment + >::type align_; + } data_; +}; + +}} // namespace detail::aligned_storage + +template < + std::size_t size_ + , std::size_t alignment_ = std::size_t(-1) +> +class aligned_storage +{ +private: // representation + + detail::aligned_storage::aligned_storage_imp data_; + +public: // constants + + typedef detail::aligned_storage::aligned_storage_imp type; + + BOOST_STATIC_CONSTANT( + std::size_t + , size = size_ + ); + BOOST_STATIC_CONSTANT( + std::size_t + , alignment = ( + alignment_ == std::size_t(-1) + ? ::boost::detail::aligned_storage::alignment_of_max_align + : alignment_ + ) + ); + +#if defined(__GNUC__) &&\ + (__GNUC__ > 3) ||\ + (__GNUC__ == 3 && (__GNUC_MINOR__ > 2 ||\ + (__GNUC_MINOR__ == 2 && __GNUC_PATCHLEVEL__ >=3))) + +private: // noncopyable + + aligned_storage(const aligned_storage&); + aligned_storage& operator=(const aligned_storage&); + +#else // gcc less than 3.2.3 + +public: // _should_ be noncopyable, but GCC compiler emits error + + aligned_storage(const aligned_storage&); + aligned_storage& operator=(const aligned_storage&); + +#endif // gcc < 3.2.3 workaround + +public: // structors + + aligned_storage() + { + } + + ~aligned_storage() + { + } + +public: // accessors + + void* address() + { + return this; + } + +#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1200) + + const void* address() const + { + return this; + } + +#else // MSVC6 + + const void* address() const; + +#endif // MSVC6 workaround + +}; + +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200) + +// MSVC6 seems not to like inline functions with const void* returns, so we +// declare the following here: + +template +const void* aligned_storage::address() const +{ + return const_cast< aligned_storage* >(this)->address(); +} + +#endif // MSVC6 workaround + +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +// +// Make sure that is_pod recognises aligned_storage<>::type +// as a POD (Note that aligned_storage<> itself is not a POD): +// +template +struct is_pod > + BOOST_TT_AUX_BOOL_C_BASE(true) +{ + BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(true) +}; +#endif + + +} // namespace boost + +#include "boost/type_traits/detail/bool_trait_undef.hpp" + +#endif // BOOST_ALIGNED_STORAGE_HPP diff --git a/boost/boost/any.hpp b/boost/boost/any.hpp index 704479d9d7..fe8553201b 100644 --- a/boost/boost/any.hpp +++ b/boost/boost/any.hpp @@ -14,7 +14,10 @@ #include #include "boost/config.hpp" +#include +#include #include +#include namespace boost { @@ -85,7 +88,7 @@ namespace boost class placeholder { public: // structors - + virtual ~placeholder() { } @@ -95,7 +98,7 @@ namespace boost virtual const std::type_info & type() const = 0; virtual placeholder * clone() const = 0; - + }; template @@ -133,6 +136,9 @@ namespace boost template friend ValueType * any_cast(any *); + template + friend ValueType * unsafe_any_cast(any *); + #else public: // representation (public so any_cast can be non-friend) @@ -170,12 +176,57 @@ namespace boost template ValueType any_cast(const any & operand) { - const ValueType * result = any_cast(&operand); + typedef BOOST_DEDUCED_TYPENAME remove_reference::type nonref; + +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + // If 'nonref' is still reference type, it means the user has not + // specialized 'remove_reference'. + + // Please use BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION macro + // to generate specialization of remove_reference for your class + // See type traits library documentation for details + BOOST_STATIC_ASSERT(!is_reference::value); +#endif + + const nonref * result = any_cast(&operand); if(!result) boost::throw_exception(bad_any_cast()); return *result; } + template + ValueType any_cast(any & operand) + { + typedef BOOST_DEDUCED_TYPENAME remove_reference::type nonref; + +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + // The comment in the above version of 'any_cast' explains when this + // assert is fired and what to do. + BOOST_STATIC_ASSERT(!is_reference::value); +#endif + + nonref * result = any_cast(&operand); + if(!result) + boost::throw_exception(bad_any_cast()); + return *result; + } + + // Note: The "unsafe" versions of any_cast are not part of the + // public interface and may be removed at any time. They are + // required where we know what type is stored in the any and can't + // use typeid() comparison, e.g., when our types may travel across + // different shared libraries. + template + ValueType * unsafe_any_cast(any * operand) + { + return &static_cast *>(operand->content)->held; + } + + template + const ValueType * unsafe_any_cast(const any * operand) + { + return any_cast(const_cast(operand)); + } } // Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved. diff --git a/boost/boost/assert.hpp b/boost/boost/assert.hpp index 3428efb7d5..5619f29898 100644 --- a/boost/boost/assert.hpp +++ b/boost/boost/assert.hpp @@ -32,6 +32,6 @@ void assertion_failed(char const * expr, char const * function, char const * fil #define BOOST_ASSERT(expr) ((expr)? ((void)0): ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)) #else -# include +# include // .h to support old libraries w/o - effect is the same # define BOOST_ASSERT(expr) assert(expr) #endif diff --git a/boost/boost/bind.hpp b/boost/boost/bind.hpp index 0525e60666..b91bc77f28 100644 --- a/boost/boost/bind.hpp +++ b/boost/boost/bind.hpp @@ -12,6 +12,7 @@ // // Copyright (c) 2001-2004 Peter Dimov and Multi Media Ltd. // Copyright (c) 2001 David Abrahams +// Copyright (c) 2005 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -128,7 +129,7 @@ template inline F & unwrap(reference_wrapper const * f, int) return f->get(); } -#if !( defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, <= 0x3003) ) +#if !( defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, <= 0x3004) ) template inline _mfi::dm unwrap(R T::* * pm, int) { @@ -154,9 +155,9 @@ public: list0() {} - template T & operator[] (value & v) const { return v.get(); } + template T & operator[] (_bi::value & v) const { return v.get(); } - template T const & operator[] (value const & v) const { return v.get(); } + template T const & operator[] (_bi::value const & v) const { return v.get(); } template T & operator[] (reference_wrapper const & v) const { return v.get(); } @@ -204,9 +205,9 @@ public: A1 operator[] (boost::arg<1> (*) ()) const { return a1_; } - template T & operator[] (value & v) const { return v.get(); } + template T & operator[] ( _bi::value & v ) const { return v.get(); } - template T const & operator[] (value const & v) const { return v.get(); } + template T const & operator[] ( _bi::value const & v ) const { return v.get(); } template T & operator[] (reference_wrapper const & v) const { return v.get(); } @@ -261,9 +262,9 @@ public: A1 operator[] (boost::arg<1> (*) ()) const { return a1_; } A2 operator[] (boost::arg<2> (*) ()) const { return a2_; } - template T & operator[] (value & v) const { return v.get(); } + template T & operator[] (_bi::value & v) const { return v.get(); } - template T const & operator[] (value const & v) const { return v.get(); } + template T const & operator[] (_bi::value const & v) const { return v.get(); } template T & operator[] (reference_wrapper const & v) const { return v.get(); } @@ -322,9 +323,9 @@ public: A2 operator[] (boost::arg<2> (*) ()) const { return a2_; } A3 operator[] (boost::arg<3> (*) ()) const { return a3_; } - template T & operator[] (value & v) const { return v.get(); } + template T & operator[] (_bi::value & v) const { return v.get(); } - template T const & operator[] (value const & v) const { return v.get(); } + template T const & operator[] (_bi::value const & v) const { return v.get(); } template T & operator[] (reference_wrapper const & v) const { return v.get(); } @@ -387,9 +388,9 @@ public: A3 operator[] (boost::arg<3> (*) ()) const { return a3_; } A4 operator[] (boost::arg<4> (*) ()) const { return a4_; } - template T & operator[] (value & v) const { return v.get(); } + template T & operator[] (_bi::value & v) const { return v.get(); } - template T const & operator[] (value const & v) const { return v.get(); } + template T const & operator[] (_bi::value const & v) const { return v.get(); } template T & operator[] (reference_wrapper const & v) const { return v.get(); } @@ -458,9 +459,9 @@ public: A4 operator[] (boost::arg<4> (*) ()) const { return a4_; } A5 operator[] (boost::arg<5> (*) ()) const { return a5_; } - template T & operator[] (value & v) const { return v.get(); } + template T & operator[] (_bi::value & v) const { return v.get(); } - template T const & operator[] (value const & v) const { return v.get(); } + template T const & operator[] (_bi::value const & v) const { return v.get(); } template T & operator[] (reference_wrapper const & v) const { return v.get(); } @@ -533,9 +534,9 @@ public: A5 operator[] (boost::arg<5> (*) ()) const { return a5_; } A6 operator[] (boost::arg<6> (*) ()) const { return a6_; } - template T & operator[] (value & v) const { return v.get(); } + template T & operator[] (_bi::value & v) const { return v.get(); } - template T const & operator[] (value const & v) const { return v.get(); } + template T const & operator[] (_bi::value const & v) const { return v.get(); } template T & operator[] (reference_wrapper const & v) const { return v.get(); } @@ -612,9 +613,9 @@ public: A6 operator[] (boost::arg<6> (*) ()) const { return a6_; } A7 operator[] (boost::arg<7> (*) ()) const { return a7_; } - template T & operator[] (value & v) const { return v.get(); } + template T & operator[] (_bi::value & v) const { return v.get(); } - template T const & operator[] (value const & v) const { return v.get(); } + template T const & operator[] (_bi::value const & v) const { return v.get(); } template T & operator[] (reference_wrapper const & v) const { return v.get(); } @@ -696,9 +697,9 @@ public: A7 operator[] (boost::arg<7> (*) ()) const { return a7_; } A8 operator[] (boost::arg<8> (*) ()) const { return a8_; } - template T & operator[] (value & v) const { return v.get(); } + template T & operator[] (_bi::value & v) const { return v.get(); } - template T const & operator[] (value const & v) const { return v.get(); } + template T const & operator[] (_bi::value const & v) const { return v.get(); } template T & operator[] (reference_wrapper const & v) const { return v.get(); } @@ -784,9 +785,9 @@ public: A8 operator[] (boost::arg<8> (*) ()) const { return a8_; } A9 operator[] (boost::arg<9> (*) ()) const { return a9_; } - template T & operator[] (value & v) const { return v.get(); } + template T & operator[] (_bi::value & v) const { return v.get(); } - template T const & operator[] (value const & v) const { return v.get(); } + template T const & operator[] (_bi::value const & v) const { return v.get(); } template T & operator[] (reference_wrapper const & v) const { return v.get(); } @@ -920,30 +921,67 @@ public: #endif -// bind_t::operator== +// function_equal -template bool operator==(bind_t const & a, bind_t const & b) +#ifndef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP + +// put overloads in _bi, rely on ADL + +# ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + +template bool function_equal( bind_t const & a, bind_t const & b ) { return a.compare(b); } -template bool operator!=(bind_t const & a, bind_t const & b) +# else + +template bool function_equal_impl( bind_t const & a, bind_t const & b, int ) { - return !a.compare(b); + return a.compare(b); } +# endif // #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + +#else // BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP + +// put overloads in boost + +} // namespace _bi + +# ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + +template bool function_equal( _bi::bind_t const & a, _bi::bind_t const & b ) +{ + return a.compare(b); +} + +# else + +template bool function_equal_impl( _bi::bind_t const & a, _bi::bind_t const & b, int ) +{ + return a.compare(b); +} + +# endif // #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + +namespace _bi +{ + +#endif // BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP + // add_value #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || (__SUNPRO_CC >= 0x530) template struct add_value { - typedef value type; + typedef _bi::value type; }; template struct add_value< value > { - typedef value type; + typedef _bi::value type; }; template struct add_value< reference_wrapper > @@ -1097,6 +1135,71 @@ template type; }; +// operator! + +struct logical_not +{ + template bool operator()(V const & v) const { return !v; } +}; + +template + bind_t< bool, logical_not, list1< bind_t > > + operator! (bind_t const & f) +{ + typedef list1< bind_t > list_type; + return bind_t ( logical_not(), list_type(f) ); +} + +// relational operators + +#define BOOST_BIND_OPERATOR( op, name ) \ +\ +struct name \ +{ \ + template bool operator()(V const & v, W const & w) const { return v op w; } \ +}; \ + \ +template \ + bind_t< bool, name, list2< bind_t, typename add_value::type > > \ + operator op (bind_t const & f, A2 a2) \ +{ \ + typedef typename add_value::type B2; \ + typedef list2< bind_t, B2> list_type; \ + return bind_t ( name(), list_type(f, a2) ); \ +} + +BOOST_BIND_OPERATOR( ==, equal ) +BOOST_BIND_OPERATOR( !=, not_equal ) + +BOOST_BIND_OPERATOR( <, less ) +BOOST_BIND_OPERATOR( <=, less_equal ) + +BOOST_BIND_OPERATOR( >, greater ) +BOOST_BIND_OPERATOR( >=, greater_equal ) + +#undef BOOST_BIND_OPERATOR + +#if defined(__GNUC__) && BOOST_WORKAROUND(__GNUC__, < 3) + +// resolve ambiguity with rel_ops + +#define BOOST_BIND_OPERATOR( op, name ) \ +\ +template \ + bind_t< bool, name, list2< bind_t, bind_t > > \ + operator op (bind_t const & f, bind_t const & g) \ +{ \ + typedef list2< bind_t, bind_t > list_type; \ + return bind_t ( name(), list_type(f, g) ); \ +} + +BOOST_BIND_OPERATOR( !=, not_equal ) +BOOST_BIND_OPERATOR( <=, less_equal ) +BOOST_BIND_OPERATOR( >, greater ) +BOOST_BIND_OPERATOR( >=, greater_equal ) + +#endif + } // namespace _bi // visit_each @@ -1423,6 +1526,18 @@ template + +#undef BOOST_BIND_MF_NAME +#undef BOOST_BIND_MF_CC + +#endif + #ifdef BOOST_MEM_FN_ENABLE_STDCALL #define BOOST_BIND_MF_NAME(X) X##_stdcall diff --git a/boost/boost/cast.hpp b/boost/boost/cast.hpp index 267b9d0305..c4ce8d3c08 100644 --- a/boost/boost/cast.hpp +++ b/boost/boost/cast.hpp @@ -1,6 +1,6 @@ // boost cast.hpp header file ----------------------------------------------// -// (C) Copyright Kevlin Henney and Dave Abrahams 1999. +// (C) Copyright Kevlin Henney and Dave Abrahams 1999. // Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -8,9 +8,10 @@ // See http://www.boost.org/libs/conversion for Documentation. // Revision History -// 02 Apr 01 Removed BOOST_NO_LIMITS workarounds and included -// instead (the workaround did not -// actually compile when BOOST_NO_LIMITS was defined in +// 23 JUn 05 numeric_cast removed and redirected to the new verion (Fernando Cacciola) +// 02 Apr 01 Removed BOOST_NO_LIMITS workarounds and included +// instead (the workaround did not +// actually compile when BOOST_NO_LIMITS was defined in // any case, so we loose nothing). (John Maddock) // 21 Jan 01 Undid a bug I introduced yesterday. numeric_cast<> never // worked with stock GCC; trying to get it to do that broke @@ -26,14 +27,14 @@ // (Dave Abrahams) // 30 Jun 00 More MSVC6 wordarounds. See comments below. (Dave Abrahams) // 28 Jun 00 Removed implicit_cast<>. See comment below. (Beman Dawes) -// 27 Jun 00 More MSVC6 workarounds +// 27 Jun 00 More MSVC6 workarounds // 15 Jun 00 Add workarounds for MSVC6 // 2 Feb 00 Remove bad_numeric_cast ";" syntax error (Doncho Angelov) // 26 Jan 00 Add missing throw() to bad_numeric_cast::what(0 (Adam Levar) // 29 Dec 99 Change using declarations so usages in other namespaces work // correctly (Dave Abrahams) // 23 Sep 99 Change polymorphic_downcast assert to also detect M.I. errors -// as suggested Darin Adler and improved by Valentin Bonnard. +// as suggested Darin Adler and improved by Valentin Bonnard. // 2 Sep 99 Remove controversial asserts, simplify, rename. // 30 Aug 99 Move to cast.hpp, replace value_cast with numeric_cast, // place in nested namespace. @@ -68,7 +69,7 @@ namespace boost // polymorphic_cast --------------------------------------------------------// // Runtime checked polymorphic downcasts and crosscasts. - // Suggested in The C++ Programming Language, 3rd Ed, Bjarne Stroustrup, + // Suggested in The C++ Programming Language, 3rd Ed, Bjarne Stroustrup, // section 15.8 exercise 1, page 425. template @@ -95,290 +96,10 @@ namespace boost return static_cast(x); } -// implicit_cast -----------------------------------------------------------// -// -// Removed due to uncertain purpose. Use either numeric_cast (see below) -// or static_cast according to the need. - -// numeric_cast and related exception --------------------------------------// - -// Contributed by Kevlin Henney - -// bad_numeric_cast --------------------------------------------------------// - - // exception used to indicate runtime numeric_cast failure - class bad_numeric_cast : public std::bad_cast - { - public: - // constructors, destructors and assignment operator defaulted - - // function inlined for brevity and consistency with rest of library - virtual const char *what() const throw() - { - return "bad numeric cast: loss of range in numeric_cast"; - } - }; - -// numeric_cast ------------------------------------------------------------// - -#if !defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) || defined(BOOST_SGI_CPP_LIMITS) - - namespace detail - { - template - struct signed_numeric_limits : std::numeric_limits - { - static inline T min BOOST_PREVENT_MACRO_SUBSTITUTION () - { - return (std::numeric_limits::min)() >= 0 - // unary minus causes integral promotion, thus the static_cast<> - ? static_cast(-(std::numeric_limits::max)()) - : (std::numeric_limits::min)(); - }; - }; - - // Move to namespace boost in utility.hpp? - template - struct fixed_numeric_limits_base - : public if_true< std::numeric_limits::is_signed > - ::BOOST_NESTED_TEMPLATE then< signed_numeric_limits, - std::numeric_limits - >::type - {}; - - template - struct fixed_numeric_limits - : fixed_numeric_limits_base::is_specialized)> - {}; - -# ifdef BOOST_HAS_LONG_LONG - // cover implementations which supply no specialization for long - // long / unsigned long long. Not intended to be full - // numeric_limits replacements, but good enough for numeric_cast<> - template <> - struct fixed_numeric_limits_base< ::boost::long_long_type, false> - { - BOOST_STATIC_CONSTANT(bool, is_specialized = true); - BOOST_STATIC_CONSTANT(bool, is_signed = true); - static ::boost::long_long_type max BOOST_PREVENT_MACRO_SUBSTITUTION () - { -# ifdef LONGLONG_MAX - return LONGLONG_MAX; -# else - return 9223372036854775807LL; // hope this is portable -# endif - } - - static ::boost::long_long_type min BOOST_PREVENT_MACRO_SUBSTITUTION () - { -# ifdef LONGLONG_MIN - return LONGLONG_MIN; -# else - return -( 9223372036854775807LL )-1; // hope this is portable -# endif - } - }; - - template <> - struct fixed_numeric_limits_base< ::boost::ulong_long_type, false> - { - BOOST_STATIC_CONSTANT(bool, is_specialized = true); - BOOST_STATIC_CONSTANT(bool, is_signed = false); - static ::boost::ulong_long_type max BOOST_PREVENT_MACRO_SUBSTITUTION () - { -# ifdef ULONGLONG_MAX - return ULONGLONG_MAX; -# else - return 0xffffffffffffffffULL; // hope this is portable -# endif - } - - static ::boost::ulong_long_type min BOOST_PREVENT_MACRO_SUBSTITUTION () { return 0; } - }; -# endif - } // namespace detail - -// less_than_type_min - - // x_is_signed should be numeric_limits::is_signed - // y_is_signed should be numeric_limits::is_signed - // y_min should be numeric_limits::min() - // - // check(x, y_min) returns true iff x < y_min without invoking comparisons - // between signed and unsigned values. - // - // "poor man's partial specialization" is in use here. - template - struct less_than_type_min - { - template - static bool check(X x, Y y_min) - { return x < y_min; } - }; - - template <> - struct less_than_type_min - { - template - static bool check(X, Y) - { return false; } - }; - - template <> - struct less_than_type_min - { - template - static bool check(X x, Y) - { return x < 0; } - }; - - // greater_than_type_max - - // same_sign should be: - // numeric_limits::is_signed == numeric_limits::is_signed - // y_max should be numeric_limits::max() - // - // check(x, y_max) returns true iff x > y_max without invoking comparisons - // between signed and unsigned values. - // - // "poor man's partial specialization" is in use here. - template - struct greater_than_type_max; - - template<> - struct greater_than_type_max - { - template - static inline bool check(X x, Y y_max) - { return x > y_max; } - }; - - template <> - struct greater_than_type_max - { - // What does the standard say about this? I think it's right, and it - // will work with every compiler I know of. - template - static inline bool check(X x, Y) - { return x >= 0 && static_cast(static_cast(x)) != x; } - -# if defined(BOOST_MSVC) && BOOST_MSVC <= 1200 - // MSVC6 can't static_cast unsigned __int64 -> floating types -# define BOOST_UINT64_CAST(src_type) \ - static inline bool check(src_type x, unsigned __int64) \ - { \ - if (x < 0) return false; \ - unsigned __int64 y = static_cast(x); \ - bool odd = y & 0x1; \ - __int64 div2 = static_cast<__int64>(y >> 1); \ - return ((static_cast(div2) * 2.0) + odd) != x; \ - } - - BOOST_UINT64_CAST(long double); - BOOST_UINT64_CAST(double); - BOOST_UINT64_CAST(float); -# undef BOOST_UINT64_CAST -# endif - }; - - template<> - struct greater_than_type_max - { - template - static inline bool check(X x, Y y_max) - { return x > y_max; } - }; - - template <> - struct greater_than_type_max - { - // What does the standard say about this? I think it's right, and it - // will work with every compiler I know of. - template - static inline bool check(X x, Y) - { return static_cast(static_cast(x)) != x; } - }; - -#else // use #pragma hacks if available - - namespace detail - { -# if BOOST_MSVC -# pragma warning(push) -# pragma warning(disable : 4018) -# pragma warning(disable : 4146) -#elif defined(__BORLANDC__) -# pragma option push -w-8041 -# endif - - // Move to namespace boost in utility.hpp? - template - struct fixed_numeric_limits : public std::numeric_limits - { - static inline T min BOOST_PREVENT_MACRO_SUBSTITUTION () - { - return std::numeric_limits::is_signed && (std::numeric_limits::min)() >= 0 - ? T(-(std::numeric_limits::max)()) : (std::numeric_limits::min)(); - } - }; - -# if BOOST_MSVC -# pragma warning(pop) -#elif defined(__BORLANDC__) -# pragma option pop -# endif - } // namespace detail - -#endif - - template - inline Target numeric_cast(Source arg BOOST_EXPLICIT_DEFAULT_TARGET) - { - // typedefs abbreviating respective trait classes - typedef detail::fixed_numeric_limits arg_traits; - typedef detail::fixed_numeric_limits result_traits; - -#if defined(BOOST_STRICT_CONFIG) \ - || (!defined(__HP_aCC) || __HP_aCC > 33900) \ - && (!defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) \ - || defined(BOOST_SGI_CPP_LIMITS)) - // typedefs that act as compile time assertions - // (to be replaced by boost compile time assertions - // as and when they become available and are stable) - typedef bool argument_must_be_numeric[arg_traits::is_specialized]; - typedef bool result_must_be_numeric[result_traits::is_specialized]; - - const bool arg_is_signed = arg_traits::is_signed; - const bool result_is_signed = result_traits::is_signed; - const bool same_sign = arg_is_signed == result_is_signed; - - if (less_than_type_min::check(arg, (result_traits::min)()) - || greater_than_type_max::check(arg, (result_traits::max)()) - ) - -#else // We need to use #pragma hacks if available - -# if BOOST_MSVC -# pragma warning(push) -# pragma warning(disable : 4018) -#elif defined(__BORLANDC__) -#pragma option push -w-8012 -# endif - if ((arg < 0 && !result_traits::is_signed) // loss of negative range - || (arg_traits::is_signed && arg < (result_traits::min)()) // underflow - || arg > (result_traits::max)()) // overflow -# if BOOST_MSVC -# pragma warning(pop) -#elif defined(__BORLANDC__) -#pragma option pop -# endif -#endif - { - throw bad_numeric_cast(); - } - return static_cast(arg); - } // numeric_cast - # undef BOOST_EXPLICIT_DEFAULT_TARGET } // namespace boost +# include + #endif // BOOST_CAST_HPP diff --git a/boost/boost/concept_check.hpp b/boost/boost/concept_check.hpp index 4ac5ee63e3..8b090d0232 100644 --- a/boost/boost/concept_check.hpp +++ b/boost/boost/concept_check.hpp @@ -688,12 +688,12 @@ struct require_same { typedef T type; }; function_requires< AssignableConcept >(); const_constraints(c); } - void const_constraints(const Container& c) { - i = c.begin(); - i = c.end(); - n = c.size(); - n = c.max_size(); - b = c.empty(); + void const_constraints(const Container& cc) { + i = cc.begin(); + i = cc.end(); + n = cc.size(); + n = cc.max_size(); + b = cc.empty(); } Container c; bool b; @@ -757,9 +757,9 @@ struct require_same { typedef T type; }; BidirectionalIteratorConcept >(); const_constraints(c); } - void const_constraints(const ReversibleContainer& c) { - const_reverse_iterator i = c.rbegin(); - i = c.rend(); + void const_constraints(const ReversibleContainer& cc) { + const_reverse_iterator i = cc.rbegin(); + i = cc.rend(); } ReversibleContainer c; }; @@ -801,8 +801,8 @@ struct require_same { typedef T type; }; const_constraints(c); } - void const_constraints(const RandomAccessContainer& c) { - const_reference r = c[n]; + void const_constraints(const RandomAccessContainer& cc) { + const_reference r = cc[n]; ignore_unused_variable_warning(r); } RandomAccessContainer c; @@ -905,8 +905,8 @@ struct require_same { typedef T type; }; reference r = c.back(); ignore_unused_variable_warning(r); } - void const_constraints(const BackInsertionSequence& c) { - const_reference r = c.back(); + void const_constraints(const BackInsertionSequence& cc) { + const_reference r = cc.back(); ignore_unused_variable_warning(r); }; BackInsertionSequence c; @@ -927,10 +927,10 @@ struct require_same { typedef T type; }; c.erase(r.first, r.second); const_constraints(c); } - void const_constraints(const AssociativeContainer& c) { - ci = c.find(k); - n = c.count(k); - cr = c.equal_range(k); + void const_constraints(const AssociativeContainer& cc) { + ci = cc.find(k); + n = cc.count(k); + cr = cc.equal_range(k); } typedef typename AssociativeContainer::iterator iterator; typedef typename AssociativeContainer::const_iterator const_iterator; diff --git a/boost/boost/config/auto_link.hpp b/boost/boost/config/auto_link.hpp index b4e580ffa3..3fbe4173bb 100644 --- a/boost/boost/config/auto_link.hpp +++ b/boost/boost/config/auto_link.hpp @@ -17,11 +17,14 @@ USAGE: Before including this header you must define one or more of define the following macros: -BOOST_LIB_NAME: Required: A string containing the basename of the library, - for example boost_regex. -BOOST_DYN_LINK: Optional: when set link to dll rather than static library. -BOOST_LIB_DIAGNOSTIC: Optional: when set the header will print out the name - of the library selected (useful for debugging). +BOOST_LIB_NAME: Required: A string containing the basename of the library, + for example boost_regex. +BOOST_LIB_TOOLSET: Optional: the base name of the toolset. +BOOST_DYN_LINK: Optional: when set link to dll rather than static library. +BOOST_LIB_DIAGNOSTIC: Optional: when set the header will print out the name + of the library selected (useful for debugging). +BOOST_AUTO_LINK_NOMANGLE: Specifies that we should link to BOOST_LIB_NAME.lib, + rather than a mangled-name version. These macros will be undef'ed at the end of the header, further this header has no include guards - so be sure to include it only once from your library! @@ -103,8 +106,9 @@ BOOST_LIB_VERSION: The Boost version, in the form x_y, for Boost version x.y. # error "Incompatible build options" #endif // -// select toolset: +// select toolset if not defined already: // +#ifndef BOOST_LIB_TOOLSET #if defined(BOOST_MSVC) && (BOOST_MSVC == 1200) // vc6: @@ -146,6 +150,7 @@ BOOST_LIB_VERSION: The Boost version, in the form x_y, for Boost version x.y. # define BOOST_LIB_TOOLSET "cw9" #endif +#endif // BOOST_LIB_TOOLSET // // select thread opt: @@ -237,7 +242,9 @@ BOOST_LIB_VERSION: The Boost version, in the form x_y, for Boost version x.y. // // figure out whether we want the debug builds or not: // +#if __BORLANDC__ > 0x561 #pragma defineonoption BOOST_BORLAND_DEBUG -v +#endif // // sanity check: // @@ -286,9 +293,16 @@ BOOST_LIB_VERSION: The Boost version, in the form x_y, for Boost version x.y. && defined(BOOST_LIB_RT_OPT) \ && defined(BOOST_LIB_VERSION) +#ifndef BOOST_AUTO_LINK_NOMANGLE # pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT "-" BOOST_LIB_VERSION ".lib") -#ifdef BOOST_LIB_DIAGNOSTIC -# pragma message ("Linking to lib file: " BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT "-" BOOST_LIB_VERSION ".lib") +# ifdef BOOST_LIB_DIAGNOSTIC +# pragma message ("Linking to lib file: " BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT "-" BOOST_LIB_VERSION ".lib") +# endif +#else +# pragma comment(lib, BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib") +# ifdef BOOST_LIB_DIAGNOSTIC +# pragma message ("Linking to lib file: " BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib") +# endif #endif #else @@ -307,9 +321,11 @@ BOOST_LIB_VERSION: The Boost version, in the form x_y, for Boost version x.y. #if defined(BOOST_LIB_NAME) # undef BOOST_LIB_NAME #endif -#if defined(BOOST_LIB_TOOLSET) -# undef BOOST_LIB_TOOLSET -#endif +// Don't undef this one: it can be set by the user and should be the +// same for all libraries: +//#if defined(BOOST_LIB_TOOLSET) +//# undef BOOST_LIB_TOOLSET +//#endif #if defined(BOOST_LIB_THREAD_OPT) # undef BOOST_LIB_THREAD_OPT #endif @@ -325,6 +341,11 @@ BOOST_LIB_VERSION: The Boost version, in the form x_y, for Boost version x.y. #if defined(BOOST_DYN_LINK) # undef BOOST_DYN_LINK #endif +#if defined(BOOST_AUTO_LINK_NOMANGLE) +# undef BOOST_AUTO_LINK_NOMANGLE +#endif + + diff --git a/boost/boost/config/compiler/borland.hpp b/boost/boost/config/compiler/borland.hpp index 531691eff7..66769bec54 100644 --- a/boost/boost/config/compiler/borland.hpp +++ b/boost/boost/config/compiler/borland.hpp @@ -36,12 +36,9 @@ #endif #endif -#if (__BORLANDC__ <= 0x564) -# define BOOST_NO_SFINAE -#endif - // Version 7.0 (Kylix) and below: #if (__BORLANDC__ <= 0x570) +# define BOOST_NO_SFINAE # define BOOST_NO_INTEGRAL_INT64_T # define BOOST_NO_DEPENDENT_NESTED_DERIVATIONS # define BOOST_NO_PRIVATE_IN_AGGREGATE @@ -54,6 +51,7 @@ // without it, this needs more investigation: # define BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS # define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL +# define BOOST_NO_IS_ABSTRACT # ifdef NDEBUG // fix broken so that Boost.test works: # include diff --git a/boost/boost/config/compiler/comeau.hpp b/boost/boost/config/compiler/comeau.hpp index 16a1b93cb6..1b71008e0f 100644 --- a/boost/boost/config/compiler/comeau.hpp +++ b/boost/boost/config/compiler/comeau.hpp @@ -16,8 +16,6 @@ #if (__COMO_VERSION__ <= 4245) -# define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL - # if defined(_MSC_VER) && _MSC_VER <= 1300 # if _MSC_VER > 100 // only set this in non-strict mode: diff --git a/boost/boost/config/compiler/common_edg.hpp b/boost/boost/config/compiler/common_edg.hpp index c7c0b56ee2..0443be1aea 100644 --- a/boost/boost/config/compiler/common_edg.hpp +++ b/boost/boost/config/compiler/common_edg.hpp @@ -2,6 +2,7 @@ // (C) Copyright Jens Maurer 2001. // (C) Copyright David Abrahams 2002. // (C) Copyright Aleksey Gurtovoy 2002. +// (C) Copyright Markus Schoepflin 2005. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -34,6 +35,14 @@ # define BOOST_NO_TEMPLATE_TEMPLATES #endif +#if (__EDG_VERSION__ < 300) && !defined(BOOST_NO_IS_ABSTRACT) +# define BOOST_NO_IS_ABSTRACT +#endif + +#if (__EDG_VERSION__ <= 303) && !defined(BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL) +# define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL +#endif + // See also kai.hpp which checks a Kai-specific symbol for EH # if !defined(__KCC) && !defined(__EXCEPTIONS) # define BOOST_NO_EXCEPTIONS diff --git a/boost/boost/config/compiler/compaq_cxx.hpp b/boost/boost/config/compiler/compaq_cxx.hpp index 3c0c6b7ff9..a52e66a29c 100644 --- a/boost/boost/config/compiler/compaq_cxx.hpp +++ b/boost/boost/config/compiler/compaq_cxx.hpp @@ -15,6 +15,5 @@ // versions check: // Nothing to do here? -# define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL diff --git a/boost/boost/config/compiler/gcc.hpp b/boost/boost/config/compiler/gcc.hpp index 328f139726..d94b16b761 100644 --- a/boost/boost/config/compiler/gcc.hpp +++ b/boost/boost/config/compiler/gcc.hpp @@ -13,11 +13,12 @@ // GNU C++ compiler setup: -# if __GNUC__ == 2 && __GNUC_MINOR__ == 91 +#if __GNUC__ < 3 +# if __GNUC_MINOR__ == 91 // egcs 1.1 won't parse shared_ptr.hpp without this: # define BOOST_NO_AUTO_PTR # endif -# if __GNUC__ == 2 && __GNUC_MINOR__ < 95 +# if __GNUC_MINOR__ < 95 // // Prior to gcc 2.95 member templates only partly // work - define BOOST_MSVC6_MEMBER_TEMPLATES @@ -29,30 +30,36 @@ # endif # endif -# if __GNUC__ == 2 && __GNUC_MINOR__ < 96 +# if __GNUC_MINOR__ < 96 # define BOOST_NO_SFINAE # endif -# if __GNUC__ == 2 && __GNUC_MINOR__ <= 97 +# if __GNUC_MINOR__ <= 97 # define BOOST_NO_MEMBER_TEMPLATE_FRIENDS # define BOOST_NO_OPERATORS_IN_NAMESPACE # endif -# if __GNUC__ < 3 -# define BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE -# define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL -# endif +# define BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE +# define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL +# define BOOST_NO_IS_ABSTRACT +#elif __GNUC__ == 3 + // + // gcc-3.x problems: + // + // Bug specific to gcc 3.1 and 3.2: + // +# if ((__GNUC_MINOR__ == 1) || (__GNUC_MINOR__ == 2)) +# define BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS +# endif +# if __GNUC_MINOR__ < 4 +# define BOOST_NO_IS_ABSTRACT +# endif +#endif #ifndef __EXCEPTIONS # define BOOST_NO_EXCEPTIONS #endif -// -// Bug specific to gcc 3.1 and 3.2: -// -#if (__GNUC__ == 3) && ((__GNUC_MINOR__ == 1) || (__GNUC_MINOR__ == 2)) -# define BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS -#endif // // Threading support: Turn this on unconditionally here (except for @@ -84,12 +91,14 @@ # error "Compiler not configured - please reconfigure" #endif // -// last known and checked version is 3.4: +// last known and checked version is 4.0 (Pre-release): #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 0)) # if defined(BOOST_ASSERT_CONFIG) # error "Unknown compiler version - please run the configure tests and report the results" # else -# warning "Unknown compiler version - please run the configure tests and report the results" +// we don't emit warnings here anymore since there are no defect macros defined for +// gcc post 3.4, so any failures are gcc regressions... +//# warning "Unknown compiler version - please run the configure tests and report the results" # endif #endif diff --git a/boost/boost/config/compiler/hp_acc.hpp b/boost/boost/config/compiler/hp_acc.hpp index b5c587ab71..3d05ba5635 100644 --- a/boost/boost/config/compiler/hp_acc.hpp +++ b/boost/boost/config/compiler/hp_acc.hpp @@ -32,6 +32,7 @@ # define BOOST_NO_TEMPLATE_TEMPLATES # define BOOST_NO_SWPRINTF # define BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS +# define BOOST_NO_IS_ABSTRACT // std lib config should set this one already: //# define BOOST_NO_STD_ALLOCATOR #endif diff --git a/boost/boost/config/compiler/intel.hpp b/boost/boost/config/compiler/intel.hpp index 060338bcf1..d47c345a5e 100644 --- a/boost/boost/config/compiler/intel.hpp +++ b/boost/boost/config/compiler/intel.hpp @@ -88,6 +88,15 @@ # endif #endif +#if defined(__GNUC__) && !defined(BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL) +// +// Figure out when Intel is emulating this gcc bug: +// +# if ((__GNUC__ == 3) && (__GNUC_MINOR__ <= 2)) || (BOOST_INTEL <= 900) +# define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL +# endif +#endif + // // Verify that we have actually got BOOST_NO_INTRINSIC_WCHAR_T // set correctly, if we don't do this now, we will get errors later @@ -108,11 +117,6 @@ template<> struct assert_intrinsic_wchar_t {}; template<> struct assert_intrinsic_wchar_t {}; #endif - -#if (BOOST_INTEL_CXX_VERSION <= 800) || !defined(BOOST_STRICT_CONFIG) -# define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL -#endif - #if _MSC_VER+0 >= 1000 # if _MSC_VER >= 1200 # define BOOST_HAS_MS_INT64 @@ -137,7 +141,7 @@ template<> struct assert_intrinsic_wchar_t {}; #endif // // last known and checked version: -#if (BOOST_INTEL_CXX_VERSION > 810) +#if (BOOST_INTEL_CXX_VERSION > 900) # if defined(BOOST_ASSERT_CONFIG) # error "Unknown compiler version - please run the configure tests and report the results" # elif defined(_MSC_VER) diff --git a/boost/boost/config/compiler/metrowerks.hpp b/boost/boost/config/compiler/metrowerks.hpp index a74cadef18..f173295eb8 100644 --- a/boost/boost/config/compiler/metrowerks.hpp +++ b/boost/boost/config/compiler/metrowerks.hpp @@ -37,8 +37,11 @@ # define BOOST_NO_SFINAE # endif -# if(__MWERKS__ <= 0x3204) // 9.3 +// the "|| !defined(BOOST_STRICT_CONFIG)" part should apply to the last +// tested version *only*: +# if(__MWERKS__ <= 0x3206) || !defined(BOOST_STRICT_CONFIG) // 9.5 # define BOOST_NO_MEMBER_TEMPLATE_FRIENDS +# define BOOST_NO_IS_ABSTRACT # endif #if !__option(wchar_type) @@ -66,6 +69,10 @@ # define BOOST_COMPILER_VERSION 9.2 # elif __MWERKS__ == 0x3204 # define BOOST_COMPILER_VERSION 9.3 +# elif __MWERKS__ == 0x3205 +# define BOOST_COMPILER_VERSION 9.4 +# elif __MWERKS__ == 0x3206 +# define BOOST_COMPILER_VERSION 9.5 # else # define BOOST_COMPILER_VERSION __MWERKS__ # endif @@ -83,7 +90,7 @@ #endif // // last known and checked version: -#if (__MWERKS__ > 0x3204) +#if (__MWERKS__ > 0x3205) # if defined(BOOST_ASSERT_CONFIG) # error "Unknown compiler version - please run the configure tests and report the results" # endif diff --git a/boost/boost/config/compiler/sunpro_cc.hpp b/boost/boost/config/compiler/sunpro_cc.hpp index 8a61199f8b..eca19feb0b 100644 --- a/boost/boost/config/compiler/sunpro_cc.hpp +++ b/boost/boost/config/compiler/sunpro_cc.hpp @@ -34,7 +34,7 @@ # define BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION # endif -# if (__SUNPRO_CC <= 0x530) || !defined(BOOST_STRICT_CONFIG) +# if (__SUNPRO_CC <= 0x530) // Requesting debug info (-g) with Boost.Python results // in an internal compiler error for "static const" // initialized in-class. @@ -57,13 +57,14 @@ # define BOOST_NO_INTEGRAL_INT64_T # endif -# if (__SUNPRO_CC <= 0x540) || !defined(BOOST_STRICT_CONFIG) +# if (__SUNPRO_CC < 0x570) # define BOOST_NO_TEMPLATE_TEMPLATES // see http://lists.boost.org/MailArchives/boost/msg47184.php // and http://lists.boost.org/MailArchives/boost/msg47220.php # define BOOST_NO_INCLASS_MEMBER_INITIALIZATION # define BOOST_NO_SFINAE # define BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS +# define BOOST_NO_IS_ABSTRACT # endif #define BOOST_COMPILER "Sun compiler version " BOOST_STRINGIZE(__SUNPRO_CC) @@ -75,8 +76,8 @@ #error "Compiler not supported or configured - please reconfigure" #endif // -// last known and checked version is 0x530: -#if (__SUNPRO_CC > 0x530) +// last known and checked version is 0x570: +#if (__SUNPRO_CC > 0x570) # if defined(BOOST_ASSERT_CONFIG) # error "Unknown compiler version - please run the configure tests and report the results" # endif diff --git a/boost/boost/config/compiler/visualc.hpp b/boost/boost/config/compiler/visualc.hpp index 3235326039..aa8ce21046 100644 --- a/boost/boost/config/compiler/visualc.hpp +++ b/boost/boost/config/compiler/visualc.hpp @@ -17,8 +17,8 @@ // turn off the warnings before we #include anything #pragma warning( disable : 4503 ) // warning: decorated name length exceeded -#if _MSC_VER < 1300 // 1200 == VC++ 6.0, 1201 == EVC4.2 -#pragma warning( disable : 4786 ) // ident trunc to '255' chars in debug info +#if _MSC_VER < 1300 // 1200 == VC++ 6.0, 1200-1202 == eVC++4 +# pragma warning( disable : 4786 ) // ident trunc to '255' chars in debug info # define BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS # define BOOST_NO_VOID_RETURNS # define BOOST_NO_EXCEPTION_STD_NAMESPACE @@ -28,9 +28,9 @@ #if (_MSC_VER <= 1300) // 1300 == VC++ 7.0 -#if !defined(_MSC_EXTENSIONS) && !defined(BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS) // VC7 bug with /Za -# define BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS -#endif +# if !defined(_MSC_EXTENSIONS) && !defined(BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS) // VC7 bug with /Za +# define BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS +# endif # define BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS # define BOOST_NO_INCLASS_MEMBER_INITIALIZATION @@ -55,6 +55,8 @@ # define BOOST_NO_TEMPLATE_TEMPLATES # define BOOST_NO_SFINAE # define BOOST_NO_POINTER_TO_MEMBER_TEMPLATE_PARAMETERS +# define BOOST_NO_IS_ABSTRACT +// TODO: what version is meant here? Have there really been any fixes in cl 12.01 (as e.g. shipped with eVC4)? # if (_MSC_VER > 1200) # define BOOST_NO_MEMBER_FUNCTION_SPECIALIZATIONS # endif @@ -115,16 +117,36 @@ # define BOOST_ABI_SUFFIX "boost/config/abi/msvc_suffix.hpp" #endif -# if _MSC_VER == 1200 -# define BOOST_COMPILER_VERSION 6.0 -# elif _MSC_VER == 1300 -# define BOOST_COMPILER_VERSION 7.0 -# elif _MSC_VER == 1310 -# define BOOST_COMPILER_VERSION 7.1 -# elif _MSC_VER == 1400 -# define BOOST_COMPILER_VERSION 8.0 +// TODO: +// these things are mostly bogus. 1200 means version 12.0 of the compiler. The +// artificial versions assigned to them only refer to the versions of some IDE +// these compilers have been shipped with, and even that is not all of it. Some +// were shipped with freely downloadable SDKs, others as crosscompilers in eVC. +// IOW, you can't use these 'versions' in any sensible way. Sorry. +# if defined(UNDER_CE) +# if _MSC_VER < 1200 + // Note: these are so far off, they are not really supported +# elif _MSC_VER < 1300 // eVC++ 4 comes with 1200-1202 +# define BOOST_COMPILER_VERSION evc4.0 +# error unknown CE compiler +# else +# error unknown CE compiler +# endif # else -# define BOOST_COMPILER_VERSION _MSC_VER +# if _MSC_VER < 1200 + // Note: these are so far off, they are not really supported +# define BOOST_COMPILER_VERSION 5.0 +# elif _MSC_VER < 1300 +# define BOOST_COMPILER_VERSION 6.0 +# elif _MSC_VER == 1300 +# define BOOST_COMPILER_VERSION 7.0 +# elif _MSC_VER == 1310 +# define BOOST_COMPILER_VERSION 7.1 +# elif _MSC_VER == 1400 +# define BOOST_COMPILER_VERSION 8.0 +# else +# define BOOST_COMPILER_VERSION _MSC_VER +# endif # endif #define BOOST_COMPILER "Microsoft Visual C++ version " BOOST_STRINGIZE(BOOST_COMPILER_VERSION) @@ -136,7 +158,7 @@ #error "Compiler not supported or configured - please reconfigure" #endif // -// last known and checked version is 1310: +// last known and checked version is 1400 (VC8): #if (_MSC_VER > 1400) # if defined(BOOST_ASSERT_CONFIG) # error "Unknown compiler version - please run the configure tests and report the results" diff --git a/boost/boost/config/platform/bsd.hpp b/boost/boost/config/platform/bsd.hpp index 38017c99bf..17496d85bb 100644 --- a/boost/boost/config/platform/bsd.hpp +++ b/boost/boost/config/platform/bsd.hpp @@ -43,8 +43,9 @@ // // No wide character support in the BSD header files: // -#define BOOST_NO_CWCHAR - +#if !(defined(__FreeBSD__) && (__FreeBSD__ >= 5)) +# define BOOST_NO_CWCHAR +#endif // // The BSD has macros only, no functions: // diff --git a/boost/boost/config/platform/hpux.hpp b/boost/boost/config/platform/hpux.hpp index 21049059e3..fa773aa79e 100644 --- a/boost/boost/config/platform/hpux.hpp +++ b/boost/boost/config/platform/hpux.hpp @@ -21,9 +21,15 @@ #define BOOST_NO_SWPRINTF #define BOOST_NO_CWCTYPE -#ifdef __GNUC__ - // GNU C on HP-UX does not support threads (checked up to gcc 3.3) -# define BOOST_DISABLE_THREADS +#if defined(__GNUC__) +# if (__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 3)) + // GNU C on HP-UX does not support threads (checked up to gcc 3.3) +# define BOOST_DISABLE_THREADS +# elif !defined(BOOST_DISABLE_THREADS) + // threads supported from gcc-3.3 onwards: +# define BOOST_HAS_THREADS +# define BOOST_HAS_PTHREADS +# endif #endif // boilerplate code: diff --git a/boost/boost/config/platform/macos.hpp b/boost/boost/config/platform/macos.hpp index 3a5f41303f..d6877d3112 100644 --- a/boost/boost/config/platform/macos.hpp +++ b/boost/boost/config/platform/macos.hpp @@ -18,10 +18,14 @@ # ifndef BOOST_HAS_UNISTD_H # define BOOST_HAS_UNISTD_H # endif -// boilerplate code: -# ifndef TARGET_CARBON -# include -# endif +// +// Begin by including our boilerplate code for POSIX +// feature detection, this is safe even when using +// the MSL as Metrowerks supply their own +// to replace the platform-native BSD one. G++ users +// should also always be able to do this on MaxOS X. +// +# include # ifndef BOOST_HAS_STDINT_H # define BOOST_HAS_STDINT_H # endif @@ -49,9 +53,15 @@ // We will eventually support threads in non-Carbon builds, but we do // not support this yet. -# if TARGET_CARBON +# if ( defined(TARGET_API_MAC_CARBON) && TARGET_API_MAC_CARBON ) || ( defined(TARGET_CARBON) && TARGET_CARBON ) +# if !defined(BOOST_HAS_PTHREADS) # define BOOST_HAS_MPTASKS +# elif ( __dest_os == __mac_os_x ) +// We are doing a Carbon/Mach-O/MSL build which has pthreads, but only the +// gettimeofday and no posix. +# define BOOST_HAS_GETTIMEOFDAY +# endif // The MP task implementation of Boost Threads aims to replace MP-unsafe // parts of the MSL, so we turn on threads unconditionally. diff --git a/boost/boost/config/platform/win32.hpp b/boost/boost/config/platform/win32.hpp index 548bff280b..9344818f87 100644 --- a/boost/boost/config/platform/win32.hpp +++ b/boost/boost/config/platform/win32.hpp @@ -1,6 +1,7 @@ // (C) Copyright John Maddock 2001 - 2003. // (C) Copyright Bill Kempf 2001. // (C) Copyright Aleksey Gurtovoy 2003. +// (C) Copyright Rene Rivera 2005. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -11,6 +12,11 @@ #define BOOST_PLATFORM "Win32" +// Get the information about the MinGW runtime, i.e. __MINGW32_*VERSION. +#if defined(__MINGW32__) +# include <_mingw.h> +#endif + #if defined(__GNUC__) && !defined(BOOST_NO_SWPRINTF) # define BOOST_NO_SWPRINTF #endif @@ -19,9 +25,11 @@ # define BOOST_HAS_DECLSPEC #endif -#if defined(__MINGW32__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2))) +#if defined(__MINGW32__) && ((__MINGW32_MAJOR_VERSION > 2) || ((__MINGW32_MAJOR_VERSION == 2) && (__MINGW32_MINOR_VERSION >= 0))) # define BOOST_HAS_STDINT_H # define __STDC_LIMIT_MACROS +# define BOOST_HAS_DIRENT_H +# define BOOST_HAS_UNISTD_H #endif // diff --git a/boost/boost/config/select_platform_config.hpp b/boost/boost/config/select_platform_config.hpp index c8540c035c..2101ed431d 100644 --- a/boost/boost/config/select_platform_config.hpp +++ b/boost/boost/config/select_platform_config.hpp @@ -49,7 +49,7 @@ // MacOS # define BOOST_PLATFORM_CONFIG "boost/config/platform/macos.hpp" -#elif defined(__IBMCPP__) +#elif defined(__IBMCPP__) || defined(_AIX) // IBM # define BOOST_PLATFORM_CONFIG "boost/config/platform/aix.hpp" diff --git a/boost/boost/config/stdlib/libstdcpp3.hpp b/boost/boost/config/stdlib/libstdcpp3.hpp index 9774e8761d..5cf5ef773f 100644 --- a/boost/boost/config/stdlib/libstdcpp3.hpp +++ b/boost/boost/config/stdlib/libstdcpp3.hpp @@ -1,7 +1,7 @@ -// (C) Copyright John Maddock 2001. -// (C) Copyright Jens Maurer 2001. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file +// (C) Copyright John Maddock 2001. +// (C) Copyright Jens Maurer 2001. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org for most recent version. @@ -22,26 +22,39 @@ # define BOOST_NO_STD_WSTREAMBUF #endif -#if defined(__osf__) && !defined(_REENTRANT) && defined(_GLIBCXX_HAVE_GTHR_DEFAULT) -// GCC 3.4 on Tru64 forces the definition of _REENTRANT when any std lib header +#if defined(__osf__) && !defined(_REENTRANT) \ + && ( defined(_GLIBCXX_HAVE_GTHR_DEFAULT) || defined(_GLIBCPP_HAVE_GTHR_DEFAULT) ) +// GCC 3 on Tru64 forces the definition of _REENTRANT when any std lib header // file is included, therefore for consistency we define it here as well. # define _REENTRANT #endif #ifdef __GLIBCXX__ // gcc 3.4 and greater: -# ifdef _GLIBCXX_HAVE_GTHR_DEFAULT - // +# if defined(_GLIBCXX_HAVE_GTHR_DEFAULT) \ + || defined(_GLIBCXX__PTHREADS) + // // If the std lib has thread support turned on, then turn it on in Boost // as well. We do this because some gcc-3.4 std lib headers define _REENTANT // while others do not... - // + // # define BOOST_HAS_THREADS # else # define BOOST_DISABLE_THREADS # endif +#elif defined(__GLIBCPP__) \ + && !defined(_GLIBCPP_HAVE_GTHR_DEFAULT) \ + && !defined(_GLIBCPP__PTHREADS) + // disable thread support if the std lib was built single threaded: +# define BOOST_DISABLE_THREADS #endif - +#if (defined(linux) || defined(__linux) || defined(__linux__)) && defined(__arm__) && defined(_GLIBCPP_HAVE_GTHR_DEFAULT) +// linux on arm apparently doesn't define _REENTRANT +// so just turn on threading support whenever the std lib is thread safe: +# define BOOST_HAS_THREADS +#endif + + #if !defined(_GLIBCPP_USE_LONG_LONG) \ && !defined(_GLIBCXX_USE_LONG_LONG)\ && defined(BOOST_HAS_LONG_LONG) diff --git a/boost/boost/config/stdlib/msl.hpp b/boost/boost/config/stdlib/msl.hpp index f8ad3d9adb..0df8e0e3bc 100644 --- a/boost/boost/config/stdlib/msl.hpp +++ b/boost/boost/config/stdlib/msl.hpp @@ -41,6 +41,11 @@ # define BOOST_HAS_THREADS #endif +#ifdef _MSL_NO_EXPLICIT_FUNC_TEMPLATE_ARG +# define BOOST_NO_STD_USE_FACET +# define BOOST_HAS_TWO_ARG_USE_FACET +#endif + #define BOOST_STDLIB "Metrowerks Standard Library version " BOOST_STRINGIZE(__MSL_CPP__) diff --git a/boost/boost/config/stdlib/roguewave.hpp b/boost/boost/config/stdlib/roguewave.hpp index ec3d881b58..b331f6538b 100644 --- a/boost/boost/config/stdlib/roguewave.hpp +++ b/boost/boost/config/stdlib/roguewave.hpp @@ -119,5 +119,9 @@ # define BOOST_NO_STD_OUTPUT_ITERATOR_ASSIGN #endif - - +// +// Disable BOOST_HAS_LONG_LONG when the library has no support for it. +// +#if !defined(_RWSTD_LONG_LONG) && defined(BOOST_HAS_LONG_LONG) +# undef BOOST_HAS_LONG_LONG +#endif diff --git a/boost/boost/config/stdlib/stlport.hpp b/boost/boost/config/stdlib/stlport.hpp index 4843ea59bc..294f96ed6f 100644 --- a/boost/boost/config/stdlib/stlport.hpp +++ b/boost/boost/config/stdlib/stlport.hpp @@ -52,7 +52,7 @@ // then the io stream facets are not available in namespace std:: // #ifdef _STLPORT_VERSION -# if !defined(_STLP_OWN_IOSTREAMS) && defined(_STLP_USE_NAMESPACES) && defined(BOOST_NO_USING_TEMPLATE) && !defined(__BORLANDC__) +# if !(_STLPORT_VERSION >= 0x500) && !defined(_STLP_OWN_IOSTREAMS) && defined(_STLP_USE_NAMESPACES) && defined(BOOST_NO_USING_TEMPLATE) && !defined(__BORLANDC__) # define BOOST_NO_STD_LOCALE # endif #else @@ -74,7 +74,7 @@ // #define BOOST_HAS_PARTIAL_STD_ALLOCATOR -#if !defined(_STLP_MEMBER_TEMPLATE_CLASSES) +#if !defined(_STLP_MEMBER_TEMPLATE_CLASSES) || defined(_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE) # define BOOST_NO_STD_ALLOCATOR #endif diff --git a/boost/boost/config/suffix.hpp b/boost/boost/config/suffix.hpp index 77d9decac1..d4d9502d4a 100644 --- a/boost/boost/config/suffix.hpp +++ b/boost/boost/config/suffix.hpp @@ -1,15 +1,15 @@ // Boost config.hpp configuration header file ------------------------------// -// (C) Copyright John Maddock 2001 - 2003. -// (C) Copyright Darin Adler 2001. -// (C) Copyright Peter Dimov 2001. -// (C) Copyright Bill Kempf 2002. -// (C) Copyright Jens Maurer 2002. -// (C) Copyright David Abrahams 2002 - 2003. -// (C) Copyright Gennaro Prota 2003. -// (C) Copyright Eric Friedman 2003. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file +// (C) Copyright John Maddock 2001 - 2003. +// (C) Copyright Darin Adler 2001. +// (C) Copyright Peter Dimov 2001. +// (C) Copyright Bill Kempf 2002. +// (C) Copyright Jens Maurer 2002. +// (C) Copyright David Abrahams 2002 - 2003. +// (C) Copyright Gennaro Prota 2003. +// (C) Copyright Eric Friedman 2003. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org for most recent version. @@ -32,11 +32,15 @@ // #include # if !defined(BOOST_HAS_LONG_LONG) \ - && !(defined(BOOST_MSVC) && BOOST_MSVC <=1300) && !defined(__BORLANDC__) \ + && !defined(BOOST_MSVC) && !defined(__BORLANDC__) \ && (defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX)) # define BOOST_HAS_LONG_LONG #endif -#if !defined(BOOST_HAS_LONG_LONG) && !defined(BOOST_NO_INTEGRAL_INT64_T) + +// TODO: Remove the following lines after the 1.33 release because the presence +// of an integral 64 bit type has nothing to do with support for long long. + +#if !defined(BOOST_HAS_LONG_LONG) && !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(__DECCXX_VER) # define BOOST_NO_INTEGRAL_INT64_T #endif @@ -275,7 +279,7 @@ // Because std::size_t usage is so common, even in boost headers which do not // otherwise use the C library, the workaround is included here so // that ugly workaround code need not appear in many other boost headers. -// NOTE WELL: This is a workaround for non-conforming compilers; +// NOTE WELL: This is a workaround for non-conforming compilers; // must still be #included in the usual places so that inclusion // works as expected with standard conforming compilers. The resulting // double inclusion of is harmless. @@ -395,7 +399,7 @@ namespace std { #ifndef BOOST_NO_DEDUCED_TYPENAME # define BOOST_DEDUCED_TYPENAME typename -#else +#else # define BOOST_DEDUCED_TYPENAME #endif @@ -508,7 +512,7 @@ namespace boost{ // // Helper macro BOOST_JOIN: -// The following piece of macro magic joins the two +// The following piece of macro magic joins the two // arguments together, even when one of the arguments is // itself a macro (see 16.3.1 in C++ standard). The key // is that macro expansion of macro arguments does not diff --git a/boost/boost/crc.hpp b/boost/boost/crc.hpp index 640b3cf45f..e70c834033 100644 --- a/boost/boost/crc.hpp +++ b/boost/boost/crc.hpp @@ -349,8 +349,12 @@ namespace detail #else BOOST_STATIC_CONSTANT( least, sig_bits = (~( ~(least( 0u )) << Bits )) ); #endif +#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 0 && __GNUC_PATCHLEVEL__ == 2 + // Work around a weird bug that ICEs the compiler in build_c_cast + BOOST_STATIC_CONSTANT( fast, sig_bits_fast = static_cast(sig_bits) ); +#else BOOST_STATIC_CONSTANT( fast, sig_bits_fast = fast(sig_bits) ); - +#endif }; // boost::detail::mask_uint_t template < > @@ -458,7 +462,7 @@ namespace detail typedef typename masking_type::fast value_type; #if defined(__BORLANDC__) && defined(_M_IX86) && (__BORLANDC__ == 0x560) // for some reason Borland's command line compiler (version 0x560) - // chokes over this unless we do the calculation for it: + // chokes over this unless we do the calculation for it: typedef value_type table_type[ 0x100 ]; #else typedef value_type table_type[ byte_combos ]; @@ -732,7 +736,7 @@ crc_basic::process_bit // a full polynominal division step is done when the highest bit is one bool const do_poly_div = static_cast( rem_ & high_bit_mask ); - // shift out the highest bit + // shift out the highest bit rem_ <<= 1; // carry out the division, if needed diff --git a/boost/boost/cregex.hpp b/boost/boost/cregex.hpp index 661a5ca25f..b7a918eb8e 100644 --- a/boost/boost/cregex.hpp +++ b/boost/boost/cregex.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -24,11 +24,7 @@ #include #endif -#ifdef BOOST_REGEX_V3 -#include -#else #include -#endif #endif /* include guard */ diff --git a/boost/boost/cstdint.hpp b/boost/boost/cstdint.hpp index 40ad844351..698c149f58 100644 --- a/boost/boost/cstdint.hpp +++ b/boost/boost/cstdint.hpp @@ -40,8 +40,48 @@ # include # else # include + +// There is a bug in Cygwin two _C macros +# if defined(__STDC_CONSTANT_MACROS) && defined(__CYGWIN__) +# undef INTMAX_C +# undef UINTMAX_C +# define INTMAX_C(c) c##LL +# define UINTMAX_C(c) c##ULL +# endif + # endif +#ifdef __QNX__ + +// QNX (Dinkumware stdlib) defines these as non-standard names. +// Reflect to the standard names. + +typedef ::intleast8_t int_least8_t; +typedef ::intfast8_t int_fast8_t; +typedef ::uintleast8_t uint_least8_t; +typedef ::uintfast8_t uint_fast8_t; + +typedef ::intleast16_t int_least16_t; +typedef ::intfast16_t int_fast16_t; +typedef ::uintleast16_t uint_least16_t; +typedef ::uintfast16_t uint_fast16_t; + +typedef ::intleast32_t int_least32_t; +typedef ::intfast32_t int_fast32_t; +typedef ::uintleast32_t uint_least32_t; +typedef ::uintfast32_t uint_fast32_t; + +# ifndef BOOST_NO_INT64_T + +typedef ::intleast64_t int_least64_t; +typedef ::intfast64_t int_fast64_t; +typedef ::uintleast64_t uint_least64_t; +typedef ::uintfast64_t uint_fast64_t; + +# endif + +#endif + namespace boost { diff --git a/boost/boost/detail/atomic_count.hpp b/boost/boost/detail/atomic_count.hpp index 3ad92b1c32..9985b2cede 100644 --- a/boost/boost/detail/atomic_count.hpp +++ b/boost/boost/detail/atomic_count.hpp @@ -73,9 +73,6 @@ // are called driven by smart_ptr interface... // -// Note: atomic_count_linux.hpp has been disabled by default; see the -// comments inside for more info. - #include #ifndef BOOST_HAS_THREADS @@ -92,13 +89,11 @@ typedef long atomic_count; } -#elif defined(BOOST_USE_ASM_ATOMIC_H) -# include #elif defined(BOOST_AC_USE_PTHREADS) # include #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) # include -#elif defined(__GLIBCPP__) +#elif defined(__GLIBCPP__) || defined(__GLIBCXX__) # include #elif defined(BOOST_HAS_PTHREADS) # define BOOST_AC_USE_PTHREADS diff --git a/boost/boost/detail/atomic_count_gcc.hpp b/boost/boost/detail/atomic_count_gcc.hpp index 9fa661f3c4..1160e44dff 100644 --- a/boost/boost/detail/atomic_count_gcc.hpp +++ b/boost/boost/detail/atomic_count_gcc.hpp @@ -10,6 +10,7 @@ // // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. // Copyright (c) 2002 Lars Gullik Bjnnes +// Copyright 2003-2005 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -24,6 +25,13 @@ namespace boost namespace detail { +#if defined(__GLIBCXX__) // g++ 3.4+ + +using __gnu_cxx::__atomic_add; +using __gnu_cxx::__exchange_and_add; + +#endif + class atomic_count { public: diff --git a/boost/boost/detail/atomic_count_linux.hpp b/boost/boost/detail/atomic_count_linux.hpp deleted file mode 100644 index e0b0dda36b..0000000000 --- a/boost/boost/detail/atomic_count_linux.hpp +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef BOOST_DETAIL_ATOMIC_COUNT_LINUX_HPP_INCLUDED -#define BOOST_DETAIL_ATOMIC_COUNT_LINUX_HPP_INCLUDED - -// -// boost/detail/atomic_count_linux.hpp -// -// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// - -// -// This implementation uses . This is a kernel header; -// using kernel headers in a user program may cause a number of problems, -// and not all flavors of Linux provide the atomic instructions. -// -// This file is only provided because the performance of this implementation -// is significantly higher than the pthreads version. Use at your own risk -// (by defining BOOST_USE_ASM_ATOMIC_H.) -// - -#include - -namespace boost -{ - -namespace detail -{ - -class atomic_count -{ -public: - - explicit atomic_count(long v) - { - atomic_t init = ATOMIC_INIT(v); - value_ = init; - } - - void operator++() - { - atomic_inc(&value_); - } - - long operator--() - { - return !atomic_dec_and_test(&value_); - } - - operator long() const - { - return atomic_read(&value_); - } - -private: - - atomic_count(atomic_count const &); - atomic_count & operator=(atomic_count const &); - - atomic_t value_; -}; - -} // namespace detail - -} // namespace boost - -#endif // #ifndef BOOST_DETAIL_ATOMIC_COUNT_LINUX_HPP_INCLUDED diff --git a/boost/boost/detail/atomic_count_win32.hpp b/boost/boost/detail/atomic_count_win32.hpp index 0dfa3f3ba7..0de25377fa 100644 --- a/boost/boost/detail/atomic_count_win32.hpp +++ b/boost/boost/detail/atomic_count_win32.hpp @@ -10,16 +10,14 @@ // // boost/detail/atomic_count_win32.hpp // -// Copyright (c) 2001, 2002, 2003 Peter Dimov +// Copyright (c) 2001-2005 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // -#ifdef BOOST_USE_WINDOWS_H -# include -#endif +#include namespace boost { @@ -27,67 +25,35 @@ namespace boost namespace detail { -#ifndef BOOST_USE_WINDOWS_H - -#ifdef _WIN64 - -// Intel 6.0 on Win64 version, posted by Tim Fenders to [boost-users] - -extern "C" long_type __cdecl _InterlockedIncrement(long volatile *); -extern "C" long_type __cdecl _InterlockedDecrement(long volatile *); - -#pragma intrinsic(_InterlockedIncrement) -#pragma intrinsic(_InterlockedDecrement) - -inline long InterlockedIncrement(long volatile * lp) -{ - return _InterlockedIncrement(lp); -} - -inline long InterlockedDecrement(long volatile* lp) -{ - return _InterlockedDecrement(lp); -} - -#else // _WIN64 - -extern "C" __declspec(dllimport) long __stdcall InterlockedIncrement(long volatile *); -extern "C" __declspec(dllimport) long __stdcall InterlockedDecrement(long volatile *); - -#endif // _WIN64 - -#endif // #ifndef BOOST_USE_WINDOWS_H - class atomic_count { public: - explicit atomic_count(long v): value_(v) + explicit atomic_count( long v ): value_( v ) { } long operator++() { - // Some older versions do not accept volatile - return InterlockedIncrement(const_cast(&value_)); + return BOOST_INTERLOCKED_INCREMENT( &value_ ); } long operator--() { - return InterlockedDecrement(const_cast(&value_)); + return BOOST_INTERLOCKED_DECREMENT( &value_ ); } operator long() const { - return value_; + return static_cast( value_ ); } private: - atomic_count(atomic_count const &); - atomic_count & operator=(atomic_count const &); + atomic_count( atomic_count const & ); + atomic_count & operator=( atomic_count const & ); - volatile long value_; + long value_; }; } // namespace detail diff --git a/boost/boost/detail/bad_weak_ptr.hpp b/boost/boost/detail/bad_weak_ptr.hpp new file mode 100644 index 0000000000..a08d7b1700 --- /dev/null +++ b/boost/boost/detail/bad_weak_ptr.hpp @@ -0,0 +1,59 @@ +#ifndef BOOST_BAD_WEAK_PTR_HPP_INCLUDED +#define BOOST_BAD_WEAK_PTR_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// detail/bad_weak_ptr.hpp +// +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#include + +#ifdef __BORLANDC__ +# pragma warn -8026 // Functions with excep. spec. are not expanded inline +#endif + +namespace boost +{ + +// The standard library that comes with Borland C++ 5.5.1, 5.6.4 +// defines std::exception and its members as having C calling +// convention (-pc). When the definition of bad_weak_ptr +// is compiled with -ps, the compiler issues an error. +// Hence, the temporary #pragma option -pc below. + +#if defined(__BORLANDC__) && __BORLANDC__ <= 0x564 +# pragma option push -pc +#endif + +class bad_weak_ptr: public std::exception +{ +public: + + virtual char const * what() const throw() + { + return "boost::bad_weak_ptr"; + } +}; + +#if defined(__BORLANDC__) && __BORLANDC__ <= 0x564 +# pragma option pop +#endif + +} // namespace boost + +#ifdef __BORLANDC__ +# pragma warn .8026 // Functions with excep. spec. are not expanded inline +#endif + +#endif // #ifndef BOOST_BAD_WEAK_PTR_HPP_INCLUDED diff --git a/boost/boost/detail/call_traits.hpp b/boost/boost/detail/call_traits.hpp index a2c2ba3d1e..0d9e99febf 100644 --- a/boost/boost/detail/call_traits.hpp +++ b/boost/boost/detail/call_traits.hpp @@ -25,6 +25,7 @@ #include #include +#include namespace boost{ @@ -91,7 +92,7 @@ struct call_traits typedef T& param_type; // hh removed const }; -#if defined(__BORLANDC__) && (__BORLANDC__ <= 0x560) +#if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x570 ) ) // these are illegal specialisations; cv-qualifies applied to // references have no effect according to [8.3.2p1], // C++ Builder requires them though as it treats cv-qualified diff --git a/boost/boost/detail/compressed_pair.hpp b/boost/boost/detail/compressed_pair.hpp index af1e9bd758..c45d20c599 100644 --- a/boost/boost/detail/compressed_pair.hpp +++ b/boost/boost/detail/compressed_pair.hpp @@ -132,7 +132,7 @@ namespace details template class compressed_pair_imp - : private T1 + : private ::boost::remove_cv::type { public: typedef T1 first_type; @@ -174,7 +174,7 @@ namespace details template class compressed_pair_imp - : private T2 + : private ::boost::remove_cv::type { public: typedef T1 first_type; @@ -217,8 +217,8 @@ namespace details template class compressed_pair_imp - : private T1, - private T2 + : private ::boost::remove_cv::type, + private ::boost::remove_cv::type { public: typedef T1 first_type; @@ -257,7 +257,7 @@ namespace details // but reuses T1 base class for both first() and second(). template class compressed_pair_imp - : private T1 + : private ::boost::remove_cv::type { public: typedef T1 first_type; @@ -430,5 +430,3 @@ swap(compressed_pair& x, compressed_pair& y) #endif // BOOST_DETAIL_COMPRESSED_PAIR_HPP - - diff --git a/boost/boost/detail/indirect_traits.hpp b/boost/boost/detail/indirect_traits.hpp index 57f5af6b47..6ee8a10a49 100755 --- a/boost/boost/detail/indirect_traits.hpp +++ b/boost/boost/detail/indirect_traits.hpp @@ -11,6 +11,7 @@ # include # include # include +# include # include # include # include @@ -18,6 +19,7 @@ # include # include +# include # include # include # include @@ -251,6 +253,7 @@ struct is_reference_to_function_aux static T t; BOOST_STATIC_CONSTANT( bool, value = sizeof(detail::is_function_ref_tester(t,0)) == sizeof(::boost::type_traits::yes_type)); + typedef mpl::bool_ type; }; template @@ -330,6 +333,8 @@ struct is_reference_to_non_const_helper1 BOOST_STATIC_CONSTANT( bool, value = sizeof(reference_to_const_helper(t)) == sizeof(inner_no_type)); + + typedef mpl::bool_ type; }; }; @@ -343,6 +348,7 @@ template struct is_reference_to_non_const : is_reference_to_non_const_helper1::value>::template apply { + BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_non_const,(T)) }; @@ -361,6 +367,7 @@ struct is_reference_to_volatile_helper1 BOOST_STATIC_CONSTANT( bool, value = sizeof(reference_to_volatile_helper(t)) == sizeof(inner_yes_type)); + typedef mpl::bool_ type; }; }; @@ -389,12 +396,16 @@ struct is_reference_to_pointer = (is_reference::value && sizeof((reference_to_pointer_helper)(t)) == sizeof(inner_yes_type)) ); + + typedef mpl::bool_ type; + + BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_pointer,(T)) }; template struct is_reference_to_function_pointer : mpl::if_< - is_reference + is_reference , is_pointer_to_function_aux , mpl::bool_ >::type @@ -463,6 +474,7 @@ struct is_pointer_to_class = (is_pointer::value && sizeof(pointer_to_class_helper(t)) == sizeof(inner_yes_type)) ); + typedef mpl::bool_ type; }; # endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION diff --git a/boost/boost/detail/is_incrementable.hpp b/boost/boost/detail/is_incrementable.hpp index 110d16e671..0ae4eca84f 100755 --- a/boost/boost/detail/is_incrementable.hpp +++ b/boost/boost/detail/is_incrementable.hpp @@ -4,7 +4,10 @@ #ifndef IS_INCREMENTABLE_DWA200415_HPP # define IS_INCREMENTABLE_DWA200415_HPP +# include +# include # include +# include # include # include @@ -29,8 +32,26 @@ namespace is_incrementable_ struct any { template any(T const&); }; // This is a last-resort operator++ for when none other is found +# if BOOST_WORKAROUND(__GNUC__, == 4) && __GNUC_MINOR__ == 0 && __GNUC_PATCHLEVEL__ == 2 + +} + +namespace is_incrementable_2 +{ + is_incrementable_::tag operator++(is_incrementable_::any const&); + is_incrementable_::tag operator++(is_incrementable_::any const&,int); +} +using namespace is_incrementable_2; + +namespace is_incrementable_ +{ + +# else + tag operator++(any const&); tag operator++(any const&,int); + +# endif # if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202)) \ || BOOST_WORKAROUND(BOOST_MSVC, <= 1300) @@ -51,7 +72,7 @@ namespace is_incrementable_ template struct impl { - static typename remove_cv::type& x; + static typename boost::remove_cv::type& x; BOOST_STATIC_CONSTANT( bool @@ -62,7 +83,7 @@ namespace is_incrementable_ template struct postfix_impl { - static typename remove_cv::type& x; + static typename boost::remove_cv::type& x; BOOST_STATIC_CONSTANT( bool @@ -73,18 +94,28 @@ namespace is_incrementable_ # undef BOOST_comma -template -struct is_incrementable - : mpl::bool_< ::boost::detail::is_incrementable_::impl::value> -{ +template +struct is_incrementable +BOOST_TT_AUX_BOOL_C_BASE(::boost::detail::is_incrementable_::impl::value) +{ + BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(::boost::detail::is_incrementable_::impl::value) + BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_incrementable,(T)) }; -template -struct is_postfix_incrementable - : mpl::bool_< ::boost::detail::is_incrementable_::postfix_impl::value> -{ +template +struct is_postfix_incrementable +BOOST_TT_AUX_BOOL_C_BASE(::boost::detail::is_incrementable_::impl::value) +{ + BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(::boost::detail::is_incrementable_::postfix_impl::value) + BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_postfix_incrementable,(T)) }; -}} // namespace boost::detail +} // namespace detail + +BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1, ::boost::detail::is_incrementable) +BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1, ::boost::detail::is_postfix_incrementable) + +} // namespace boost + #endif // IS_INCREMENTABLE_DWA200415_HPP diff --git a/boost/boost/detail/lightweight_mutex.hpp b/boost/boost/detail/lightweight_mutex.hpp index 22e0f54085..a0936cbb95 100644 --- a/boost/boost/detail/lightweight_mutex.hpp +++ b/boost/boost/detail/lightweight_mutex.hpp @@ -18,77 +18,21 @@ // // typedef boost::detail::lightweight_mutex; // -// boost::detail::lightweight_mutex meets a subset of the Mutex concept -// requirements: http://www.boost.org/libs/thread/doc/mutex_concept.html#Mutex +// boost::detail::lightweight_mutex is a header-only implementation of +// a subset of the Mutex concept requirements: // -// * Used by the smart pointer library -// * Performance oriented -// * Header-only implementation -// * Small memory footprint -// * Not a general purpose mutex, use boost::mutex, CRITICAL_SECTION or -// pthread_mutex instead. -// * Never spin in a tight lock/do-something/unlock loop, since -// lightweight_mutex does not guarantee fairness. -// * Never keep a lightweight_mutex locked for long periods. +// http://www.boost.org/doc/html/threads/concepts.html#threads.concepts.Mutex // -// The current implementation can use a pthread_mutex, a CRITICAL_SECTION, -// or a platform-specific spinlock. +// It maps to a CRITICAL_SECTION on Windows or a pthread_mutex on POSIX. // -// You can force a particular implementation by defining BOOST_LWM_USE_PTHREADS, -// BOOST_LWM_USE_CRITICAL_SECTION, or BOOST_LWM_USE_SPINLOCK. -// -// If neither macro has been defined, the default is to use a spinlock on Win32, -// and a pthread_mutex otherwise. -// -// Note that a spinlock is not a general synchronization primitive. In particular, -// it is not guaranteed to be a memory barrier, and it is possible to "livelock" -// if a lower-priority thread has acquired the spinlock but a higher-priority -// thread is spinning trying to acquire the same lock. -// -// For these reasons, spinlocks have been disabled by default except on Windows, -// where a spinlock can be several orders of magnitude faster than a CRITICAL_SECTION. - - -// Note: lwm_linux.hpp has been disabled by default; see the comments -// inside for more info. - #include -// Note to implementors: if you write a platform-specific spinlock -// for a platform that supports pthreads, be sure to test its performance -// against the pthreads-based version using shared_ptr_timing_test.cpp and -// shared_ptr_mt_test.cpp. Custom versions are usually not worth the trouble -// _unless_ the performance gains are substantial. -// -// Be sure to compare against a "real" pthreads library; -// shared_ptr_timing_test.cpp will compile succesfully with a stub do-nothing -// pthreads library, since it doesn't create any threads. - -#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) && !defined(BOOST_LWM_USE_CRITICAL_SECTION) && !defined(BOOST_LWM_USE_PTHREADS) -# define BOOST_LWM_WIN32 -#endif - #if !defined(BOOST_HAS_THREADS) -# if defined(BOOST_LWM_WIN32) -# include -# else -# include -# endif -#elif defined(BOOST_LWM_USE_SPINLOCK) && defined(BOOST_USE_ASM_ATOMIC_H) -# include -#elif defined(BOOST_LWM_USE_CRITICAL_SECTION) +# include +#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) # include -#elif defined(BOOST_LWM_USE_PTHREADS) -# include -#elif defined(BOOST_LWM_WIN32) -# include -#elif defined(BOOST_LWM_USE_SPINLOCK) && defined(__sgi) -# include -#elif defined(BOOST_LWM_USE_SPINLOCK) && defined(__GLIBCPP__) -# include #elif defined(BOOST_HAS_PTHREADS) -# define BOOST_LWM_USE_PTHREADS # include #else // Use #define BOOST_DISABLE_THREADS to avoid the error diff --git a/boost/boost/detail/limits.hpp b/boost/boost/detail/limits.hpp index 035244037d..414ca97590 100644 --- a/boost/boost/detail/limits.hpp +++ b/boost/boost/detail/limits.hpp @@ -42,21 +42,12 @@ #include #include #include +#include #ifndef BOOST_NO_CWCHAR #include // for WCHAR_MIN and WCHAR_MAX #endif -// The macros are not named appropriately. We don't care about integer -// bit layout, but about floating-point NaN (etc.) bit patterns. -#if defined(__sparc) || defined(__sparc__) || defined(__powerpc__) || defined(__ppc__) || defined(__hppa) || defined(_MIPSEB) || defined(_POWER) -#define BOOST_BIG_ENDIAN -#elif defined(__i386__) || defined(__alpha__) || defined(__ia64) || defined(__ia64__) -#define BOOST_LITTLE_ENDIAN -#else -#error The file boost/detail/limits.hpp needs to be set up for your CPU type. -#endif - namespace std { enum float_round_style { diff --git a/boost/boost/detail/lwm_gcc.hpp b/boost/boost/detail/lwm_gcc.hpp deleted file mode 100644 index e64ef7d7b2..0000000000 --- a/boost/boost/detail/lwm_gcc.hpp +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef BOOST_DETAIL_LWM_GCC_HPP_INCLUDED -#define BOOST_DETAIL_LWM_GCC_HPP_INCLUDED - -// -// boost/detail/lwm_gcc.hpp -// -// lightweight_mutex for GNU libstdc++ v3 -// -// http://gcc.gnu.org/onlinedocs/porting/Thread-safety.html -// -// Copyright (c) 2002 Peter Dimov and Multi Media Ltd. -// Copyright (c) 2002 Lars Gullik Bjnnes -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// - -#include -#include - -namespace boost -{ - -namespace detail -{ - -class lightweight_mutex -{ -private: - - _Atomic_word a_; - - lightweight_mutex(lightweight_mutex const &); - lightweight_mutex & operator=(lightweight_mutex const &); - -public: - - lightweight_mutex(): a_(0) - { - } - - class scoped_lock; - friend class scoped_lock; - - class scoped_lock - { - private: - - lightweight_mutex & m_; - - scoped_lock(scoped_lock const &); - scoped_lock & operator=(scoped_lock const &); - - public: - - explicit scoped_lock(lightweight_mutex & m): m_(m) - { - while( __exchange_and_add(&m_.a_, 1) ) - { - __atomic_add(&m_.a_, -1); - sched_yield(); - } - } - - ~scoped_lock() - { - __atomic_add(&m_.a_, -1); - } - }; -}; - -} // namespace detail - -} // namespace boost - -#endif // #ifndef BOOST_DETAIL_LWM_GCC_HPP_INCLUDED diff --git a/boost/boost/detail/lwm_irix.hpp b/boost/boost/detail/lwm_irix.hpp deleted file mode 100644 index cfc304b74a..0000000000 --- a/boost/boost/detail/lwm_irix.hpp +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef BOOST_DETAIL_LWM_IRIX_HPP_INCLUDED -#define BOOST_DETAIL_LWM_IRIX_HPP_INCLUDED - -// -// boost/detail/lwm_irix.hpp -// -// Copyright (c) 2002 Peter Dimov and Multi Media Ltd. -// Copyright (c) 2002 Dan Gohman -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// - -#include -#include -#include - -namespace boost -{ - -namespace detail -{ - -class lightweight_mutex -{ -private: - - __uint32_t l_; - - lightweight_mutex(lightweight_mutex const &); - lightweight_mutex & operator=(lightweight_mutex const &); - -public: - - lightweight_mutex(): l_(0) - { - } - - class scoped_lock; - friend class scoped_lock; - - class scoped_lock - { - private: - - lightweight_mutex & m_; - - scoped_lock(scoped_lock const &); - scoped_lock & operator=(scoped_lock const &); - - public: - - explicit scoped_lock(lightweight_mutex & m): m_(m) - { - while( test_and_set32(&m_.l_, 1) ) - { - sched_yield(); - } - } - - ~scoped_lock() - { - m_.l_ = 0; - } - }; -}; - -} // namespace detail - -} // namespace boost - -#endif // #ifndef BOOST_DETAIL_LWM_IRIX_HPP_INCLUDED diff --git a/boost/boost/detail/lwm_linux.hpp b/boost/boost/detail/lwm_linux.hpp deleted file mode 100644 index f0cfb7fb86..0000000000 --- a/boost/boost/detail/lwm_linux.hpp +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef BOOST_DETAIL_LWM_LINUX_HPP_INCLUDED -#define BOOST_DETAIL_LWM_LINUX_HPP_INCLUDED - -// -// boost/detail/lwm_linux.hpp -// -// Copyright (c) 2002 Peter Dimov and Multi Media Ltd. -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// - -// -// This implementation uses . This is a kernel header; -// using kernel headers in a user program may cause a number of problems, -// and not all flavors of Linux provide the atomic instructions. -// -// This file is only provided because the performance of this implementation -// is about 3.5 times higher than the pthreads version. Use at your own risk -// (by defining BOOST_USE_ASM_ATOMIC_H.) -// - -#include -#include - -namespace boost -{ - -namespace detail -{ - -class lightweight_mutex -{ -private: - - atomic_t a_; - - lightweight_mutex(lightweight_mutex const &); - lightweight_mutex & operator=(lightweight_mutex const &); - -public: - - lightweight_mutex() - { - atomic_t a = ATOMIC_INIT(1); - a_ = a; - } - - class scoped_lock; - friend class scoped_lock; - - class scoped_lock - { - private: - - lightweight_mutex & m_; - - scoped_lock(scoped_lock const &); - scoped_lock & operator=(scoped_lock const &); - - public: - - explicit scoped_lock(lightweight_mutex & m): m_(m) - { - while( !atomic_dec_and_test(&m_.a_) ) - { - atomic_inc(&m_.a_); - sched_yield(); - } - } - - ~scoped_lock() - { - atomic_inc(&m_.a_); - } - }; -}; - -} // namespace detail - -} // namespace boost - -#endif // #ifndef BOOST_DETAIL_LWM_LINUX_HPP_INCLUDED diff --git a/boost/boost/detail/lwm_win32.hpp b/boost/boost/detail/lwm_win32.hpp deleted file mode 100644 index 8496ed8dc5..0000000000 --- a/boost/boost/detail/lwm_win32.hpp +++ /dev/null @@ -1,122 +0,0 @@ -#ifndef BOOST_DETAIL_LWM_WIN32_HPP_INCLUDED -#define BOOST_DETAIL_LWM_WIN32_HPP_INCLUDED - -// MS compatible compilers support #pragma once - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -// -// boost/detail/lwm_win32.hpp -// -// Copyright (c) 2002, 2003 Peter Dimov -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// - -#ifdef BOOST_USE_WINDOWS_H -# include -#endif - -#ifdef __BORLANDC__ -# pragma warn -8027 // Functions containing while are not expanded inline -#endif - -namespace boost -{ - -namespace detail -{ - -#ifndef BOOST_USE_WINDOWS_H - -#ifdef _WIN64 - -// Intel 6.0 on Win64 version, posted by Tim Fenders to [boost-users] - -extern "C" long_type __cdecl _InterlockedExchange(long volatile *, long); - -#pragma intrinsic(_InterlockedExchange) - -inline long InterlockedExchange(long volatile* lp, long l) -{ - return _InterlockedExchange(lp, l); -} - -#else // _WIN64 - -extern "C" __declspec(dllimport) long __stdcall InterlockedExchange(long volatile *, long); - -#endif // _WIN64 - -extern "C" __declspec(dllimport) void __stdcall Sleep(unsigned long); - -#endif // #ifndef BOOST_USE_WINDOWS_H - -class lightweight_mutex -{ -private: - - long l_; - - lightweight_mutex(lightweight_mutex const &); - lightweight_mutex & operator=(lightweight_mutex const &); - -public: - - lightweight_mutex(): l_(0) - { - } - - class scoped_lock; - friend class scoped_lock; - - class scoped_lock - { - private: - - lightweight_mutex & m_; - - scoped_lock(scoped_lock const &); - scoped_lock & operator=(scoped_lock const &); - - public: - - explicit scoped_lock(lightweight_mutex & m): m_(m) - { - while( InterlockedExchange(&m_.l_, 1) ) - { - // Note: changed to Sleep(1) from Sleep(0). - // According to MSDN, Sleep(0) will never yield - // to a lower-priority thread, whereas Sleep(1) - // will. Performance seems not to be affected. - - Sleep(1); - } - } - - ~scoped_lock() - { - InterlockedExchange(&m_.l_, 0); - - // Note: adding a yield here will make - // the spinlock more fair and will increase the overall - // performance of some applications substantially in - // high contention situations, but will penalize the - // low contention / single thread case up to 5x - } - }; -}; - -} // namespace detail - -} // namespace boost - -#ifdef __BORLANDC__ -# pragma warn .8027 // Functions containing while are not expanded inline -#endif - -#endif // #ifndef BOOST_DETAIL_LWM_WIN32_HPP_INCLUDED diff --git a/boost/boost/detail/lwm_win32_nt.hpp b/boost/boost/detail/lwm_win32_nt.hpp deleted file mode 100644 index 216e63640a..0000000000 --- a/boost/boost/detail/lwm_win32_nt.hpp +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef BOOST_DETAIL_LWM_WIN32_NT_HPP_INCLUDED -#define BOOST_DETAIL_LWM_WIN32_NT_HPP_INCLUDED - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -// -// boost/detail/lwm_win32_nt.hpp -// -// Copyright (c) 2002, 2003 Peter Dimov -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// "No threads" version of lwm_win32.hpp; binary compatible but no-op. -// - -namespace boost -{ - -namespace detail -{ - -class lightweight_mutex -{ -private: - - long l_; - - lightweight_mutex(lightweight_mutex const &); - lightweight_mutex & operator=(lightweight_mutex const &); - -public: - - lightweight_mutex(): l_(0) - { - } - - class scoped_lock; - friend class scoped_lock; - - class scoped_lock - { - private: - - scoped_lock(scoped_lock const &); - scoped_lock & operator=(scoped_lock const &); - - public: - - explicit scoped_lock(lightweight_mutex &) - { - } - }; -}; - -} // namespace detail - -} // namespace boost - -#endif // #ifndef BOOST_DETAIL_LWM_WIN32_NT_HPP_INCLUDED diff --git a/boost/boost/detail/no_exceptions_support.hpp b/boost/boost/detail/no_exceptions_support.hpp new file mode 100644 index 0000000000..d94e35834f --- /dev/null +++ b/boost/boost/detail/no_exceptions_support.hpp @@ -0,0 +1,87 @@ +#ifndef BOOST_DETAIL_NO_EXCEPTIONS_SUPPORT_HPP_ +#define BOOST_DETAIL_NO_EXCEPTIONS_SUPPORT_HPP_ + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +//---------------------------------------------------------------------- +// (C) Copyright 2004 Pavel Vozenilek. +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// +// This file contains helper macros used when exception support may be +// disabled (as indicated by macro BOOST_NO_EXCEPTIONS). +// +// Before picking up these macros you may consider using RAII techniques +// to deal with exceptions - their syntax can be always the same with +// or without exception support enabled. +// + +/* Example of use: + +void foo() { + BOOST_TRY { + ... + } BOOST_CATCH(const std::bad_alloc&) { + ... + BOOST_RETHROW + } BOOST_CATCH(const std::exception& e) { + ... + } + BOOST_CATCH_END +} + +With exception support enabled it will expand into: + +void foo() { + { try { + ... + } catch (const std::bad_alloc&) { + ... + throw; + } catch (const std::exception& e) { + ... + } + } +} + +With exception support disabled it will expand into: + +void foo() { + { if(true) { + ... + } else if (false) { + ... + } else if (false) { + ... + } + } +} +*/ +//---------------------------------------------------------------------- + +#include +#include + +#if !(defined BOOST_NO_EXCEPTIONS) +# define BOOST_TRY { try +# define BOOST_CATCH(x) catch(x) +# define BOOST_RETHROW throw; +# define BOOST_CATCH_END } +#else +# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) +# define BOOST_TRY { if ("") +# define BOOST_CATCH(x) else if (!"") +# else +# define BOOST_TRY { if (true) +# define BOOST_CATCH(x) else if (false) +# endif +# define BOOST_RETHROW +# define BOOST_CATCH_END } +#endif + + +#endif diff --git a/boost/boost/detail/shared_count.hpp b/boost/boost/detail/shared_count.hpp index 86d8e4b7c5..49aca857f7 100644 --- a/boost/boost/detail/shared_count.hpp +++ b/boost/boost/detail/shared_count.hpp @@ -11,293 +11,35 @@ // detail/shared_count.hpp // // Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. +// Copyright 2004-2005 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // -#include - -#if defined(BOOST_SP_USE_STD_ALLOCATOR) && defined(BOOST_SP_USE_QUICK_ALLOCATOR) -# error BOOST_SP_USE_STD_ALLOCATOR and BOOST_SP_USE_QUICK_ALLOCATOR are incompatible. +#ifdef __BORLANDC__ +# pragma warn -8027 // Functions containing try are not expanded inline #endif +#include #include #include -#include - -#if defined(BOOST_SP_USE_QUICK_ALLOCATOR) -#include -#endif +#include +#include +#include #include // std::auto_ptr, std::allocator #include // std::less -#include // std::exception #include // std::bad_alloc #include // std::type_info in get_deleter -#include // std::size_t - -#ifdef __BORLANDC__ -# pragma warn -8026 // Functions with excep. spec. are not expanded inline -# pragma warn -8027 // Functions containing try are not expanded inline -#endif namespace boost { -// Debug hooks - -#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) - -void sp_scalar_constructor_hook(void * px, std::size_t size, void * pn); -void sp_array_constructor_hook(void * px); -void sp_scalar_destructor_hook(void * px, std::size_t size, void * pn); -void sp_array_destructor_hook(void * px); - -#endif - - -// The standard library that comes with Borland C++ 5.5.1 -// defines std::exception and its members as having C calling -// convention (-pc). When the definition of bad_weak_ptr -// is compiled with -ps, the compiler issues an error. -// Hence, the temporary #pragma option -pc below. The version -// check is deliberately conservative. - -#if defined(__BORLANDC__) && __BORLANDC__ == 0x551 -# pragma option push -pc -#endif - -class bad_weak_ptr: public std::exception -{ -public: - - virtual char const * what() const throw() - { - return "boost::bad_weak_ptr"; - } -}; - -#if defined(__BORLANDC__) && __BORLANDC__ == 0x551 -# pragma option pop -#endif - namespace detail { -class sp_counted_base -{ -private: - - typedef detail::lightweight_mutex mutex_type; - -public: - - sp_counted_base(): use_count_(1), weak_count_(1) - { - } - - virtual ~sp_counted_base() // nothrow - { - } - - // dispose() is called when use_count_ drops to zero, to release - // the resources managed by *this. - - virtual void dispose() = 0; // nothrow - - // destruct() is called when weak_count_ drops to zero. - - virtual void destruct() // nothrow - { - delete this; - } - - virtual void * get_deleter(std::type_info const & ti) = 0; - - void add_ref_copy() - { -#if defined(BOOST_HAS_THREADS) - mutex_type::scoped_lock lock(mtx_); -#endif - ++use_count_; - } - - void add_ref_lock() - { -#if defined(BOOST_HAS_THREADS) - mutex_type::scoped_lock lock(mtx_); -#endif - if(use_count_ == 0) boost::throw_exception(boost::bad_weak_ptr()); - ++use_count_; - } - - void release() // nothrow - { - { -#if defined(BOOST_HAS_THREADS) - mutex_type::scoped_lock lock(mtx_); -#endif - long new_use_count = --use_count_; - - if(new_use_count != 0) return; - } - - dispose(); - weak_release(); - } - - void weak_add_ref() // nothrow - { -#if defined(BOOST_HAS_THREADS) - mutex_type::scoped_lock lock(mtx_); -#endif - ++weak_count_; - } - - void weak_release() // nothrow - { - long new_weak_count; - - { -#if defined(BOOST_HAS_THREADS) - mutex_type::scoped_lock lock(mtx_); -#endif - new_weak_count = --weak_count_; - } - - if(new_weak_count == 0) - { - destruct(); - } - } - - long use_count() const // nothrow - { -#if defined(BOOST_HAS_THREADS) - mutex_type::scoped_lock lock(mtx_); -#endif - return use_count_; - } - -private: - - sp_counted_base(sp_counted_base const &); - sp_counted_base & operator= (sp_counted_base const &); - - long use_count_; // #shared - long weak_count_; // #weak + (#shared != 0) - -#if defined(BOOST_HAS_THREADS) || defined(BOOST_LWM_WIN32) - mutable mutex_type mtx_; -#endif -}; - -#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) - -template void cbi_call_constructor_hook(sp_counted_base * pn, T * px, checked_deleter const &, int) -{ - boost::sp_scalar_constructor_hook(px, sizeof(T), pn); -} - -template void cbi_call_constructor_hook(sp_counted_base *, T * px, checked_array_deleter const &, int) -{ - boost::sp_array_constructor_hook(px); -} - -template void cbi_call_constructor_hook(sp_counted_base *, P const &, D const &, long) -{ -} - -template void cbi_call_destructor_hook(sp_counted_base * pn, T * px, checked_deleter const &, int) -{ - boost::sp_scalar_destructor_hook(px, sizeof(T), pn); -} - -template void cbi_call_destructor_hook(sp_counted_base *, T * px, checked_array_deleter const &, int) -{ - boost::sp_array_destructor_hook(px); -} - -template void cbi_call_destructor_hook(sp_counted_base *, P const &, D const &, long) -{ -} - -#endif - -// -// Borland's Codeguard trips up over the -Vx- option here: -// -#ifdef __CODEGUARD__ -# pragma option push -Vx- -#endif - -template class sp_counted_base_impl: public sp_counted_base -{ -private: - - P ptr; // copy constructor must not throw - D del; // copy constructor must not throw - - sp_counted_base_impl(sp_counted_base_impl const &); - sp_counted_base_impl & operator= (sp_counted_base_impl const &); - - typedef sp_counted_base_impl this_type; - -public: - - // pre: initial_use_count <= initial_weak_count, d(p) must not throw - - sp_counted_base_impl(P p, D d): ptr(p), del(d) - { -#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) - detail::cbi_call_constructor_hook(this, p, d, 0); -#endif - } - - virtual void dispose() // nothrow - { -#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) - detail::cbi_call_destructor_hook(this, ptr, del, 0); -#endif - del(ptr); - } - - virtual void * get_deleter(std::type_info const & ti) - { - return ti == typeid(D)? &del: 0; - } - -#if defined(BOOST_SP_USE_STD_ALLOCATOR) - - void * operator new(std::size_t) - { - return std::allocator().allocate(1, static_cast(0)); - } - - void operator delete(void * p) - { - std::allocator().deallocate(static_cast(p), 1); - } - -#endif - -#if defined(BOOST_SP_USE_QUICK_ALLOCATOR) - - void * operator new(std::size_t) - { - return quick_allocator::alloc(); - } - - void operator delete(void * p) - { - quick_allocator::dealloc(p); - } - -#endif -}; - #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) int const shared_count_id = 0x2C35F101; @@ -328,6 +70,36 @@ public: { } + template explicit shared_count( Y * p ): pi_( 0 ) +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + , id_(shared_count_id) +#endif + { +#ifndef BOOST_NO_EXCEPTIONS + + try + { + pi_ = new sp_counted_impl_p( p ); + } + catch(...) + { + boost::checked_delete( p ); + throw; + } + +#else + + pi_ = new sp_counted_impl_p( p ); + + if( pi_ == 0 ) + { + boost::checked_delete( p ); + boost::throw_exception( std::bad_alloc() ); + } + +#endif + } + template shared_count(P p, D d): pi_(0) #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) , id_(shared_count_id) @@ -337,7 +109,7 @@ public: try { - pi_ = new sp_counted_base_impl(p, d); + pi_ = new sp_counted_impl_pd(p, d); } catch(...) { @@ -347,7 +119,7 @@ public: #else - pi_ = new sp_counted_base_impl(p, d); + pi_ = new sp_counted_impl_pd(p, d); if(pi_ == 0) { @@ -363,11 +135,20 @@ public: // auto_ptr is special cased to provide the strong guarantee template - explicit shared_count(std::auto_ptr & r): pi_(new sp_counted_base_impl< Y *, checked_deleter >(r.get(), checked_deleter())) + explicit shared_count( std::auto_ptr & r ): pi_( new sp_counted_impl_p( r.get() ) ) #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) , id_(shared_count_id) #endif { +#ifdef BOOST_NO_EXCEPTIONS + + if( pi_ == 0 ) + { + boost::throw_exception(std::bad_alloc()); + } + +#endif + r.release(); } @@ -375,7 +156,7 @@ public: ~shared_count() // nothrow { - if(pi_ != 0) pi_->release(); + if( pi_ != 0 ) pi_->release(); #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) id_ = 0; #endif @@ -386,7 +167,7 @@ public: , id_(shared_count_id) #endif { - if(pi_ != 0) pi_->add_ref_copy(); + if( pi_ != 0 ) pi_->add_ref_copy(); } explicit shared_count(weak_count const & r); // throws bad_weak_ptr when r.use_count() == 0 @@ -395,10 +176,10 @@ public: { sp_counted_base * tmp = r.pi_; - if(tmp != pi_) + if( tmp != pi_ ) { - if(tmp != 0) tmp->add_ref_copy(); - if(pi_ != 0) pi_->release(); + if( tmp != 0 ) tmp->add_ref_copy(); + if( pi_ != 0 ) pi_->release(); pi_ = tmp; } @@ -429,19 +210,15 @@ public: friend inline bool operator<(shared_count const & a, shared_count const & b) { - return std::less()(a.pi_, b.pi_); + return std::less()( a.pi_, b.pi_ ); } void * get_deleter(std::type_info const & ti) const { - return pi_? pi_->get_deleter(ti): 0; + return pi_? pi_->get_deleter( ti ): 0; } }; -#ifdef __CODEGUARD__ -# pragma option pop -#endif - class weak_count { @@ -531,18 +308,14 @@ public: } }; -inline shared_count::shared_count(weak_count const & r): pi_(r.pi_) +inline shared_count::shared_count( weak_count const & r ): pi_( r.pi_ ) #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) , id_(shared_count_id) #endif { - if(pi_ != 0) + if( pi_ == 0 || !pi_->add_ref_lock() ) { - pi_->add_ref_lock(); - } - else - { - boost::throw_exception(boost::bad_weak_ptr()); + boost::throw_exception( boost::bad_weak_ptr() ); } } @@ -552,7 +325,6 @@ inline shared_count::shared_count(weak_count const & r): pi_(r.pi_) #ifdef __BORLANDC__ # pragma warn .8027 // Functions containing try are not expanded inline -# pragma warn .8026 // Functions with excep. spec. are not expanded inline #endif #endif // #ifndef BOOST_DETAIL_SHARED_COUNT_HPP_INCLUDED diff --git a/boost/boost/detail/sp_counted_base.hpp b/boost/boost/detail/sp_counted_base.hpp new file mode 100644 index 0000000000..bc170caf03 --- /dev/null +++ b/boost/boost/detail/sp_counted_base.hpp @@ -0,0 +1,69 @@ +#ifndef BOOST_DETAIL_SP_COUNTED_BASE_HPP_INCLUDED +#define BOOST_DETAIL_SP_COUNTED_BASE_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// detail/sp_counted_base.hpp +// +// Copyright 2005 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#include + +#if defined( BOOST_SP_DISABLE_THREADS ) + +# include + +#elif defined( BOOST_SP_USE_PTHREADS ) + +# include + +#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) + +# include + +//~ #elif defined( __MWERKS__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) + +//~ # include + +#elif defined( __GNUC__ ) && defined( __ia64__ ) && !defined( __INTEL_COMPILER ) + +# include + +#elif defined( __MWERKS__ ) && defined( __POWERPC__ ) + +# include + +#elif defined( __GNUC__ ) && ( defined( __powerpc__ ) || defined( __ppc__ ) ) + +# include + +#elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) + +# include + +#elif !defined( BOOST_HAS_THREADS ) + +# include + +#elif defined( BOOST_HAS_PTHREADS ) + +# include + +#else + +// Use #define BOOST_DISABLE_THREADS to avoid the error +# error Unrecognized threading platform + +#endif + +#endif // #ifndef BOOST_DETAIL_SP_COUNTED_BASE_HPP_INCLUDED diff --git a/boost/boost/detail/sp_counted_base_cw_ppc.hpp b/boost/boost/detail/sp_counted_base_cw_ppc.hpp new file mode 100644 index 0000000000..c56a56268a --- /dev/null +++ b/boost/boost/detail/sp_counted_base_cw_ppc.hpp @@ -0,0 +1,170 @@ +#ifndef BOOST_DETAIL_SP_COUNTED_BASE_CW_PPC_HPP_INCLUDED +#define BOOST_DETAIL_SP_COUNTED_BASE_CW_PPC_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// detail/sp_counted_base_cw_ppc.hpp - CodeWarrior on PowerPC +// +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. +// Copyright 2004-2005 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// +// Lock-free algorithm by Alexander Terekhov +// +// Thanks to Ben Hitchings for the #weak + (#shared != 0) +// formulation +// + +#include + +namespace boost +{ + +namespace detail +{ + +inline void atomic_increment( register long * pw ) +{ + register int a; + + asm + { +loop: + + lwarx a, 0, pw + addi a, a, 1 + stwcx. a, 0, pw + bne- loop + } +} + +inline long atomic_decrement( register long * pw ) +{ + register int a; + + asm + { + sync + +loop: + + lwarx a, 0, pw + addi a, a, -1 + stwcx. a, 0, pw + bne- loop + + isync + } + + return a; +} + +inline long atomic_conditional_increment( register long * pw ) +{ + register int a; + + asm + { +loop: + + lwarx a, 0, pw + cmpwi a, 0 + beq store + + addi a, a, 1 + +store: + + stwcx. a, 0, pw + bne- loop + } + + return a; +} + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + long use_count_; // #shared + long weak_count_; // #weak + (#shared != 0) + +public: + + sp_counted_base(): use_count_( 1 ), weak_count_( 1 ) + { + } + + virtual ~sp_counted_base() // nothrow + { + } + + // dispose() is called when use_count_ drops to zero, to release + // the resources managed by *this. + + virtual void dispose() = 0; // nothrow + + // destroy() is called when weak_count_ drops to zero. + + virtual void destroy() // nothrow + { + delete this; + } + + virtual void * get_deleter( std::type_info const & ti ) = 0; + + void add_ref_copy() + { + atomic_increment( &use_count_ ); + } + + bool add_ref_lock() // true on success + { + return atomic_conditional_increment( &use_count_ ) != 0; + } + + void release() // nothrow + { + if( atomic_decrement( &use_count_ ) == 0 ) + { + dispose(); + weak_release(); + } + } + + void weak_add_ref() // nothrow + { + atomic_increment( &weak_count_ ); + } + + void weak_release() // nothrow + { + if( atomic_decrement( &weak_count_ ) == 0 ) + { + destroy(); + } + } + + long use_count() const // nothrow + { + return static_cast( use_count_ ); + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_DETAIL_SP_COUNTED_BASE_CW_PPC_HPP_INCLUDED diff --git a/boost/boost/detail/sp_counted_base_gcc_ppc.hpp b/boost/boost/detail/sp_counted_base_gcc_ppc.hpp new file mode 100644 index 0000000000..fc2925e628 --- /dev/null +++ b/boost/boost/detail/sp_counted_base_gcc_ppc.hpp @@ -0,0 +1,181 @@ +#ifndef BOOST_DETAIL_SP_COUNTED_BASE_GCC_PPC_HPP_INCLUDED +#define BOOST_DETAIL_SP_COUNTED_BASE_GCC_PPC_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// detail/sp_counted_base_gcc_ppc.hpp - g++ on PowerPC +// +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. +// Copyright 2004-2005 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// +// Lock-free algorithm by Alexander Terekhov +// +// Thanks to Ben Hitchings for the #weak + (#shared != 0) +// formulation +// + +#include + +namespace boost +{ + +namespace detail +{ + +inline void atomic_increment( int * pw ) +{ + // ++*pw; + + int tmp; + + __asm__ + ( + "0:\n\t" + "lwarx %1, 0, %2\n\t" + "addi %1, %1, 1\n\t" + "stwcx. %1, 0, %2\n\t" + "bne- 0b": + + "=m"( *pw ), "=&b"( tmp ): + "r"( pw ): + "cc" + ); +} + +inline int atomic_decrement( int * pw ) +{ + // return --*pw; + + int rv; + + __asm__ __volatile__ + ( + "sync\n\t" + "0:\n\t" + "lwarx %1, 0, %2\n\t" + "addi %1, %1, -1\n\t" + "stwcx. %1, 0, %2\n\t" + "bne- 0b\n\t" + "isync": + + "=m"( *pw ), "=&b"( rv ): + "r"( pw ): + "memory", "cc" + ); + + return rv; +} + +inline int atomic_conditional_increment( int * pw ) +{ + // if( *pw != 0 ) ++*pw; + // return *pw; + + int rv; + + __asm__ + ( + "0:\n\t" + "lwarx %1, 0, %2\n\t" + "cmpwi %1, 0\n\t" + "beq 1f\n\t" + "addi %1, %1, 1\n\t" + "1:\n\t" + "stwcx. %1, 0, %2\n\t" + "bne- 0b": + + "=m"( *pw ), "=&b"( rv ): + "r"( pw ): + "cc" + ); + + return rv; +} + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + int use_count_; // #shared + int weak_count_; // #weak + (#shared != 0) + +public: + + sp_counted_base(): use_count_( 1 ), weak_count_( 1 ) + { + } + + virtual ~sp_counted_base() // nothrow + { + } + + // dispose() is called when use_count_ drops to zero, to release + // the resources managed by *this. + + virtual void dispose() = 0; // nothrow + + // destroy() is called when weak_count_ drops to zero. + + virtual void destroy() // nothrow + { + delete this; + } + + virtual void * get_deleter( std::type_info const & ti ) = 0; + + void add_ref_copy() + { + atomic_increment( &use_count_ ); + } + + bool add_ref_lock() // true on success + { + return atomic_conditional_increment( &use_count_ ) != 0; + } + + void release() // nothrow + { + if( atomic_decrement( &use_count_ ) == 0 ) + { + dispose(); + weak_release(); + } + } + + void weak_add_ref() // nothrow + { + atomic_increment( &weak_count_ ); + } + + void weak_release() // nothrow + { + if( atomic_decrement( &weak_count_ ) == 0 ) + { + destroy(); + } + } + + long use_count() const // nothrow + { + return static_cast( use_count_ ); + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_DETAIL_SP_COUNTED_BASE_GCC_PPC_HPP_INCLUDED diff --git a/boost/boost/detail/sp_counted_base_gcc_x86.hpp b/boost/boost/detail/sp_counted_base_gcc_x86.hpp new file mode 100644 index 0000000000..0a8e189b58 --- /dev/null +++ b/boost/boost/detail/sp_counted_base_gcc_x86.hpp @@ -0,0 +1,173 @@ +#ifndef BOOST_DETAIL_SP_COUNTED_BASE_GCC_X86_HPP_INCLUDED +#define BOOST_DETAIL_SP_COUNTED_BASE_GCC_X86_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// detail/sp_counted_base_gcc_x86.hpp - g++ on 486+ or AMD64 +// +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. +// Copyright 2004-2005 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// +// Lock-free algorithm by Alexander Terekhov +// +// Thanks to Ben Hitchings for the #weak + (#shared != 0) +// formulation +// + +#include + +namespace boost +{ + +namespace detail +{ + +inline int atomic_exchange_and_add( int * pw, int dv ) +{ + // int r = *pw; + // *pw += dv; + // return r; + + int r; + + __asm__ __volatile__ + ( + "lock\n\t" + "xadd %1, %0": + "=m"( *pw ), "=r"( r ): // outputs (%0, %1) + "m"( *pw ), "1"( dv ): // inputs (%2, %3 == %1) + "memory", "cc" // clobbers + ); + + return r; +} + +inline void atomic_increment( int * pw ) +{ + //atomic_exchange_and_add( pw, 1 ); + + __asm__ + ( + "lock\n\t" + "incl %0": + "=m"( *pw ): // output (%0) + "m"( *pw ): // input (%1) + "cc" // clobbers + ); +} + +inline int atomic_conditional_increment( int * pw ) +{ + // int rv = *pw; + // if( rv != 0 ) ++*pw; + // return rv; + + int rv, tmp; + + __asm__ + ( + "movl %0, %%eax\n\t" + "0:\n\t" + "test %%eax, %%eax\n\t" + "je 1f\n\t" + "movl %%eax, %2\n\t" + "incl %2\n\t" + "lock\n\t" + "cmpxchgl %2, %0\n\t" + "jne 0b\n\t" + "1:": + "=m"( *pw ), "=&a"( rv ), "=&r"( tmp ): // outputs (%0, %1, %2) + "m"( *pw ): // input (%3) + "cc" // clobbers + ); + + return rv; +} + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + int use_count_; // #shared + int weak_count_; // #weak + (#shared != 0) + +public: + + sp_counted_base(): use_count_( 1 ), weak_count_( 1 ) + { + } + + virtual ~sp_counted_base() // nothrow + { + } + + // dispose() is called when use_count_ drops to zero, to release + // the resources managed by *this. + + virtual void dispose() = 0; // nothrow + + // destroy() is called when weak_count_ drops to zero. + + virtual void destroy() // nothrow + { + delete this; + } + + virtual void * get_deleter( std::type_info const & ti ) = 0; + + void add_ref_copy() + { + atomic_increment( &use_count_ ); + } + + bool add_ref_lock() // true on success + { + return atomic_conditional_increment( &use_count_ ) != 0; + } + + void release() // nothrow + { + if( atomic_exchange_and_add( &use_count_, -1 ) == 1 ) + { + dispose(); + weak_release(); + } + } + + void weak_add_ref() // nothrow + { + atomic_increment( &weak_count_ ); + } + + void weak_release() // nothrow + { + if( atomic_exchange_and_add( &weak_count_, -1 ) == 1 ) + { + destroy(); + } + } + + long use_count() const // nothrow + { + return static_cast( use_count_ ); + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_DETAIL_SP_COUNTED_BASE_GCC_X86_HPP_INCLUDED diff --git a/boost/boost/detail/sp_counted_base_nt.hpp b/boost/boost/detail/sp_counted_base_nt.hpp new file mode 100644 index 0000000000..4a4401d7ae --- /dev/null +++ b/boost/boost/detail/sp_counted_base_nt.hpp @@ -0,0 +1,107 @@ +#ifndef BOOST_DETAIL_SP_COUNTED_BASE_NT_HPP_INCLUDED +#define BOOST_DETAIL_SP_COUNTED_BASE_NT_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// detail/sp_counted_base_nt.hpp +// +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. +// Copyright 2004-2005 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#include + +namespace boost +{ + +namespace detail +{ + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + long use_count_; // #shared + long weak_count_; // #weak + (#shared != 0) + +public: + + sp_counted_base(): use_count_( 1 ), weak_count_( 1 ) + { + } + + virtual ~sp_counted_base() // nothrow + { + } + + // dispose() is called when use_count_ drops to zero, to release + // the resources managed by *this. + + virtual void dispose() = 0; // nothrow + + // destroy() is called when weak_count_ drops to zero. + + virtual void destroy() // nothrow + { + delete this; + } + + virtual void * get_deleter( std::type_info const & ti ) = 0; + + void add_ref_copy() + { + ++use_count_; + } + + bool add_ref_lock() // true on success + { + if( use_count_ == 0 ) return false; + ++use_count_; + return true; + } + + void release() // nothrow + { + if( --use_count_ == 0 ) + { + dispose(); + weak_release(); + } + } + + void weak_add_ref() // nothrow + { + ++weak_count_; + } + + void weak_release() // nothrow + { + if( --weak_count_ == 0 ) + { + destroy(); + } + } + + long use_count() const // nothrow + { + return use_count_; + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_DETAIL_SP_COUNTED_BASE_NT_HPP_INCLUDED diff --git a/boost/boost/detail/sp_counted_base_pt.hpp b/boost/boost/detail/sp_counted_base_pt.hpp new file mode 100644 index 0000000000..191064f59f --- /dev/null +++ b/boost/boost/detail/sp_counted_base_pt.hpp @@ -0,0 +1,135 @@ +#ifndef BOOST_DETAIL_SP_COUNTED_BASE_PT_HPP_INCLUDED +#define BOOST_DETAIL_SP_COUNTED_BASE_PT_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// detail/sp_counted_base_pt.hpp +// +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. +// Copyright 2004-2005 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#include +#include + +namespace boost +{ + +namespace detail +{ + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + long use_count_; // #shared + long weak_count_; // #weak + (#shared != 0) + + mutable pthread_mutex_t m_; + +public: + + sp_counted_base(): use_count_( 1 ), weak_count_( 1 ) + { +// HPUX 10.20 / DCE has a nonstandard pthread_mutex_init + +#if defined(__hpux) && defined(_DECTHREADS_) + pthread_mutex_init( &m_, pthread_mutexattr_default ); +#else + pthread_mutex_init( &m_, 0 ); +#endif + } + + virtual ~sp_counted_base() // nothrow + { + pthread_mutex_destroy( &m_ ); + } + + // dispose() is called when use_count_ drops to zero, to release + // the resources managed by *this. + + virtual void dispose() = 0; // nothrow + + // destroy() is called when weak_count_ drops to zero. + + virtual void destroy() // nothrow + { + delete this; + } + + virtual void * get_deleter( std::type_info const & ti ) = 0; + + void add_ref_copy() + { + pthread_mutex_lock( &m_ ); + ++use_count_; + pthread_mutex_unlock( &m_ ); + } + + bool add_ref_lock() // true on success + { + pthread_mutex_lock( &m_ ); + bool r = use_count_ == 0? false: ( ++use_count_, true ); + pthread_mutex_unlock( &m_ ); + return r; + } + + void release() // nothrow + { + pthread_mutex_lock( &m_ ); + long new_use_count = --use_count_; + pthread_mutex_unlock( &m_ ); + + if( new_use_count == 0 ) + { + dispose(); + weak_release(); + } + } + + void weak_add_ref() // nothrow + { + pthread_mutex_lock( &m_ ); + ++weak_count_; + pthread_mutex_unlock( &m_ ); + } + + void weak_release() // nothrow + { + pthread_mutex_lock( &m_ ); + long new_weak_count = --weak_count_; + pthread_mutex_unlock( &m_ ); + + if( new_weak_count == 0 ) + { + destroy(); + } + } + + long use_count() const // nothrow + { + pthread_mutex_lock( &m_ ); + long r = use_count_; + pthread_mutex_unlock( &m_ ); + + return r; + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_DETAIL_SP_COUNTED_BASE_PT_HPP_INCLUDED diff --git a/boost/boost/detail/sp_counted_base_w32.hpp b/boost/boost/detail/sp_counted_base_w32.hpp new file mode 100644 index 0000000000..e84f06e7f2 --- /dev/null +++ b/boost/boost/detail/sp_counted_base_w32.hpp @@ -0,0 +1,117 @@ +#ifndef BOOST_DETAIL_SP_COUNTED_BASE_W32_HPP_INCLUDED +#define BOOST_DETAIL_SP_COUNTED_BASE_W32_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// detail/sp_counted_base_w32.hpp +// +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. +// Copyright 2004-2005 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// +// Lock-free algorithm by Alexander Terekhov +// +// Thanks to Ben Hitchings for the #weak + (#shared != 0) +// formulation +// + +#include +#include + +namespace boost +{ + +namespace detail +{ + +class sp_counted_base +{ +private: + + sp_counted_base( sp_counted_base const & ); + sp_counted_base & operator= ( sp_counted_base const & ); + + long use_count_; // #shared + long weak_count_; // #weak + (#shared != 0) + +public: + + sp_counted_base(): use_count_( 1 ), weak_count_( 1 ) + { + } + + virtual ~sp_counted_base() // nothrow + { + } + + // dispose() is called when use_count_ drops to zero, to release + // the resources managed by *this. + + virtual void dispose() = 0; // nothrow + + // destroy() is called when weak_count_ drops to zero. + + virtual void destroy() // nothrow + { + delete this; + } + + virtual void * get_deleter( std::type_info const & ti ) = 0; + + void add_ref_copy() + { + BOOST_INTERLOCKED_INCREMENT( &use_count_ ); + } + + bool add_ref_lock() // true on success + { + for( ;; ) + { + long tmp = static_cast< long const volatile& >( use_count_ ); + if( tmp == 0 ) return false; + if( BOOST_INTERLOCKED_COMPARE_EXCHANGE( &use_count_, tmp + 1, tmp ) == tmp ) return true; + } + } + + void release() // nothrow + { + if( BOOST_INTERLOCKED_DECREMENT( &use_count_ ) == 0 ) + { + dispose(); + weak_release(); + } + } + + void weak_add_ref() // nothrow + { + BOOST_INTERLOCKED_INCREMENT( &weak_count_ ); + } + + void weak_release() // nothrow + { + if( BOOST_INTERLOCKED_DECREMENT( &weak_count_ ) == 0 ) + { + destroy(); + } + } + + long use_count() const // nothrow + { + return static_cast( use_count_ ); + } +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_DETAIL_SP_COUNTED_BASE_W32_HPP_INCLUDED diff --git a/boost/boost/detail/sp_counted_impl.hpp b/boost/boost/detail/sp_counted_impl.hpp new file mode 100644 index 0000000000..51093b522b --- /dev/null +++ b/boost/boost/detail/sp_counted_impl.hpp @@ -0,0 +1,187 @@ +#ifndef BOOST_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED +#define BOOST_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// +// detail/sp_counted_impl.hpp +// +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. +// Copyright 2004-2005 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#include + +#if defined(BOOST_SP_USE_STD_ALLOCATOR) && defined(BOOST_SP_USE_QUICK_ALLOCATOR) +# error BOOST_SP_USE_STD_ALLOCATOR and BOOST_SP_USE_QUICK_ALLOCATOR are incompatible. +#endif + +#include +#include + +#if defined(BOOST_SP_USE_QUICK_ALLOCATOR) +#include +#endif + +#include // std::allocator +#include // std::type_info in get_deleter +#include // std::size_t + +namespace boost +{ + +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + +void sp_scalar_constructor_hook( void * px, std::size_t size, void * pn ); +void sp_scalar_destructor_hook( void * px, std::size_t size, void * pn ); + +#endif + +namespace detail +{ + +template class sp_counted_impl_p: public sp_counted_base +{ +private: + + X * px_; + + sp_counted_impl_p( sp_counted_impl_p const & ); + sp_counted_impl_p & operator= ( sp_counted_impl_p const & ); + + typedef sp_counted_impl_p this_type; + +public: + + explicit sp_counted_impl_p( X * px ): px_( px ) + { +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + boost::sp_scalar_constructor_hook( px, sizeof(X), this ); +#endif + } + + virtual void dispose() // nothrow + { +#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS) + boost::sp_scalar_destructor_hook( px_, sizeof(X), this ); +#endif + boost::checked_delete( px_ ); + } + + virtual void * get_deleter( std::type_info const & ) + { + return 0; + } + +#if defined(BOOST_SP_USE_STD_ALLOCATOR) + + void * operator new( std::size_t ) + { + return std::allocator().allocate( 1, static_cast(0) ); + } + + void operator delete( void * p ) + { + std::allocator().deallocate( static_cast(p), 1 ); + } + +#endif + +#if defined(BOOST_SP_USE_QUICK_ALLOCATOR) + + void * operator new( std::size_t ) + { + return quick_allocator::alloc(); + } + + void operator delete( void * p ) + { + quick_allocator::dealloc( p ); + } + +#endif +}; + +// +// Borland's Codeguard trips up over the -Vx- option here: +// +#ifdef __CODEGUARD__ +# pragma option push -Vx- +#endif + +template class sp_counted_impl_pd: public sp_counted_base +{ +private: + + P ptr; // copy constructor must not throw + D del; // copy constructor must not throw + + sp_counted_impl_pd( sp_counted_impl_pd const & ); + sp_counted_impl_pd & operator= ( sp_counted_impl_pd const & ); + + typedef sp_counted_impl_pd this_type; + +public: + + // pre: d(p) must not throw + + sp_counted_impl_pd( P p, D d ): ptr(p), del(d) + { + } + + virtual void dispose() // nothrow + { + del( ptr ); + } + + virtual void * get_deleter( std::type_info const & ti ) + { + return ti == typeid(D)? &del: 0; + } + +#if defined(BOOST_SP_USE_STD_ALLOCATOR) + + void * operator new( std::size_t ) + { + return std::allocator().allocate( 1, static_cast(0) ); + } + + void operator delete( void * p ) + { + std::allocator().deallocate( static_cast(p), 1 ); + } + +#endif + +#if defined(BOOST_SP_USE_QUICK_ALLOCATOR) + + void * operator new( std::size_t ) + { + return quick_allocator::alloc(); + } + + void operator delete( void * p ) + { + quick_allocator::dealloc( p ); + } + +#endif +}; + +#ifdef __CODEGUARD__ +# pragma option pop +#endif + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_DETAIL_SP_COUNTED_IMPL_HPP_INCLUDED diff --git a/boost/boost/filesystem/config.hpp b/boost/boost/filesystem/config.hpp index 4c5bf25f11..aed9585ea8 100644 --- a/boost/boost/filesystem/config.hpp +++ b/boost/boost/filesystem/config.hpp @@ -19,6 +19,10 @@ // enable dynamic linking on Windows ---------------------------------------// +# if (defined(BOOST_ALL_DYN_LINK) || defined(BOOST_FILESYSTEM_DYN_LINK)) && defined(__BORLANDC__) && defined(__WIN32__) +# error Dynamic linking Boost.Filesystem does not work for Borland; use static linking instead +# endif + #ifdef BOOST_HAS_DECLSPEC // defined in config system // we need to import/export our code only if the user has specifically // asked for it by defining either BOOST_ALL_DYN_LINK if they want all boost diff --git a/boost/boost/filesystem/path.hpp b/boost/boost/filesystem/path.hpp index 417574c416..fc4d98db4c 100644 --- a/boost/boost/filesystem/path.hpp +++ b/boost/boost/filesystem/path.hpp @@ -91,8 +91,8 @@ namespace boost reference dereference() const { return m_name; } bool equal( const iterator & rhs ) const { return m_path_ptr == rhs.m_path_ptr && m_pos == rhs.m_pos; } - void increment(); - void decrement(); + BOOST_FILESYSTEM_DECL void increment(); + BOOST_FILESYSTEM_DECL void decrement(); std::string m_name; // cache current element. const path * m_path_ptr; // path being iterated over. diff --git a/boost/boost/format/alt_sstream.hpp b/boost/boost/format/alt_sstream.hpp index d42755d55d..e236be3526 100644 --- a/boost/boost/format/alt_sstream.hpp +++ b/boost/boost/format/alt_sstream.hpp @@ -48,6 +48,7 @@ namespace boost { typedef typename compat_traits_type::off_type off_type; typedef Alloc allocator_type; typedef ::std::basic_string string_type; + typedef typename string_type::size_type size_type; typedef ::std::streamsize streamsize; @@ -75,12 +76,12 @@ namespace boost { // 0-copy access : Ch * begin() const; - streamsize size() const; - streamsize cur_size() const; // stop at current pointer + size_type size() const; + size_type cur_size() const; // stop at current pointer Ch * pend() const // the highest position reached by pptr() since creation { return ((putend_ < pptr()) ? pptr() : putend_); } - streamsize pcount() const - { return static_cast( pptr() - pbase()) ;} + size_type pcount() const + { return static_cast( pptr() - pbase()) ;} // copy buffer to string : string_type str() const @@ -131,6 +132,7 @@ namespace boost { basic_altstringbuf > > pbase_type; typedef ::std::basic_string string_type; + typedef typename string_type::size_type size_type; typedef basic_altstringbuf stringbuf_t; public: typedef Alloc allocator_type; @@ -151,9 +153,9 @@ namespace boost { // 0-copy access : Ch * begin() const { return rdbuf()->begin(); } - ::std::streamsize size() const + size_type size() const { return rdbuf()->size(); } - ::std::streamsize cur_size() const // stops at current position + size_type cur_size() const // stops at current position { return rdbuf()->cur_size(); } // copy buffer to string : @@ -161,6 +163,8 @@ namespace boost { { return rdbuf()->str(); } string_type cur_str() const // [pbase, pptr[ { return rdbuf()->cur_str(); } + void str(const string_type& s) + { rdbuf()->str(s); } }; } // N.S. io diff --git a/boost/boost/format/alt_sstream_impl.hpp b/boost/boost/format/alt_sstream_impl.hpp index 9373ed9249..ee9c3abd1e 100644 --- a/boost/boost/format/alt_sstream_impl.hpp +++ b/boost/boost/format/alt_sstream_impl.hpp @@ -35,19 +35,19 @@ namespace boost { template void basic_altstringbuf:: str (const string_type& s) { - std::size_t sz=s.size(); + size_type sz=s.size(); if(sz != 0 && mode_ & (::std::ios_base::in | ::std::ios_base::out) ) { Ch *new_ptr = alloc_.allocate(sz, is_allocated_? eback() : 0); // if this didnt throw, we're safe, update the buffer dealloc(); - sz = s.copy(new_ptr); + sz = s.copy(new_ptr, sz); putend_ = new_ptr + sz; if(mode_ & ::std::ios_base::in) streambuf_t::setg(new_ptr, new_ptr, new_ptr + sz); if(mode_ & ::std::ios_base::out) { streambuf_t::setp(new_ptr, new_ptr + sz); if(mode_ & (::std::ios_base::app | ::std::ios_base::ate)) - streambuf_t::pbump(sz); + streambuf_t::pbump(static_cast(sz)); if(gptr() == NULL) streambuf_t::setg(new_ptr, NULL, new_ptr); } @@ -67,18 +67,20 @@ namespace boost { } template - std::streamsize basic_altstringbuf:: + typename std::basic_string::size_type + basic_altstringbuf:: size () const { if(mode_ & ::std::ios_base::out && pptr()) - return static_cast( pend() - pbase()); + return static_cast(pend() - pbase()); else if(mode_ & ::std::ios_base::in && gptr()) - return static_cast( egptr() - eback()); + return static_cast(egptr() - eback()); else return 0; } template - std::streamsize basic_altstringbuf:: + typename std::basic_string::size_type + basic_altstringbuf:: cur_size () const { if(mode_ & ::std::ios_base::out && pptr()) return static_cast( pptr() - pbase()); @@ -97,17 +99,18 @@ namespace boost { if(which & ::std::ios_base::in && gptr() != NULL) { // get area if(way == ::std::ios_base::end) - off += putend_ - eback(); - else if(way == ::std::ios_base::cur && (which & ::std::ios_base::out) == 0) - off += gptr() - eback(); - else if(way != ::std::ios_base::beg) - off = off_type(-1); - if(0 <= off && off <= putend_ - eback()) { + off += static_cast(putend_ - gptr()); + else if(way == ::std::ios_base::beg) + off += static_cast(eback() - gptr()); + else if(way != ::std::ios_base::cur || (which & ::std::ios_base::out) ) + // (altering in&out is only supported if way is beg or end, not cur) + return pos_type(off_type(-1)); + if(eback() <= off+gptr() && off+gptr() <= putend_ ) { // set gptr - streambuf_t::gbump(off + (eback() - gptr())); + streambuf_t::gbump(off); if(which & ::std::ios_base::out && pptr() != NULL) // update pptr to match gptr - streambuf_t::pbump(gptr()-pptr()); + streambuf_t::pbump(static_cast(gptr()-pptr())); } else off = off_type(-1); @@ -115,15 +118,14 @@ namespace boost { else if(which & ::std::ios_base::out && pptr() != NULL) { // put area if(way == ::std::ios_base::end) - off += putend_ - eback(); - else if(way == ::std::ios_base::cur) - off += pptr() - eback(); + off += static_cast(putend_ - pptr()); + else if(way == ::std::ios_base::beg) + off += static_cast(pbase() - pptr()); else if(way != ::std::ios_base::beg) - off = off_type(-1); - - if(0 <= off && off <= putend_ - eback()) + return pos_type(off_type(-1)); + if(pbase() <= off+pptr() && off+pptr() <= putend_) // set pptr - streambuf_t::pbump((int)(eback() - pptr() + off)); + streambuf_t::pbump(off); else off = off_type(-1); } @@ -145,10 +147,10 @@ namespace boost { if(which & ::std::ios_base::in && gptr() != NULL) { // get area if(0 <= off && off <= putend_ - eback()) { - streambuf_t::gbump((int)(eback() - gptr() + off)); + streambuf_t::gbump(static_cast(eback() - gptr() + off)); if(which & ::std::ios_base::out && pptr() != NULL) { // update pptr to match gptr - streambuf_t::pbump(gptr()-pptr()); + streambuf_t::pbump(static_cast(gptr()-pptr())); } } else @@ -157,7 +159,7 @@ namespace boost { else if(which & ::std::ios_base::out && pptr() != NULL) { // put area if(0 <= off && off <= putend_ - eback()) - streambuf_t::pbump(eback() - pptr() + off); + streambuf_t::pbump(static_cast(eback() - pptr() + off)); else off = off_type(-1); } @@ -262,8 +264,8 @@ namespace boost { } else { // update pointers putend_ = putend_ - oldptr + newptr; - int pptr_count = pptr()-pbase(); - int gptr_count = gptr()-eback(); + int pptr_count = static_cast(pptr()-pbase()); + int gptr_count = static_cast(gptr()-eback()); streambuf_t::setp(pbase() - oldptr + newptr, newptr + new_size); streambuf_t::pbump(pptr_count); if(mode_ & ::std::ios_base::in) diff --git a/boost/boost/format/detail/config_macros.hpp b/boost/boost/format/detail/config_macros.hpp index 5813ad2b90..1f01b1789b 100644 --- a/boost/boost/format/detail/config_macros.hpp +++ b/boost/boost/format/detail/config_macros.hpp @@ -42,7 +42,7 @@ || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT( 0x570 ) ) ) // some future __BORLANDC__ >0x564 versions might not need this // 0x570 is Borland's kylix branch -#define BOOST_NO_LOCALE_ISIDIGIT +#define BOOST_NO_LOCALE_ISDIGIT #endif #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570) ) || BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1300)) diff --git a/boost/boost/format/detail/msvc_disambiguater.hpp b/boost/boost/format/detail/msvc_disambiguater.hpp index d84ff63103..f12e5e97b2 100644 --- a/boost/boost/format/detail/msvc_disambiguater.hpp +++ b/boost/boost/format/detail/msvc_disambiguater.hpp @@ -14,7 +14,8 @@ #ifndef BOOST_MSVC_DISAMBIGUATER_HPP #define BOOST_MSVC_DISAMBIGUATER_HPP -#if BOOST_WORKAROUND( BOOST_MSVC, <= 1300) +#if BOOST_WORKAROUND( BOOST_MSVC, <= 1300) || \ + BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042)) // this whole header is specifically for msvc up to 7.0 #include diff --git a/boost/boost/format/detail/unset_macros.hpp b/boost/boost/format/detail/unset_macros.hpp index 22ecbbd153..b3ac47b42b 100644 --- a/boost/boost/format/detail/unset_macros.hpp +++ b/boost/boost/format/detail/unset_macros.hpp @@ -14,8 +14,8 @@ #ifdef BOOST_NO_OVERLOAD_FOR_NON_CONST #undef BOOST_NO_OVERLOAD_FOR_NON_CONST #endif -#ifdef BOOST_NO_LOCALE_ISIDIGIT -#undef BOOST_NO_LOCALE_ISIDIGIT +#ifdef BOOST_NO_LOCALE_ISDIGIT +#undef BOOST_NO_LOCALE_ISDIGIT #endif #ifdef BOOST_IO_STD #undef BOOST_IO_STD diff --git a/boost/boost/format/feed_args.hpp b/boost/boost/format/feed_args.hpp index 3f1ce749ff..0a1a0fe96f 100644 --- a/boost/boost/format/feed_args.hpp +++ b/boost/boost/format/feed_args.hpp @@ -29,7 +29,7 @@ namespace detail { template void mk_str( std::basic_string & res, const Ch * beg, - std::streamsize size, + typename std::basic_string::size_type size, std::streamsize w, const Ch fill_char, std::ios_base::fmtflags f, @@ -38,14 +38,18 @@ namespace detail { // applies centered/left/right padding to the string [beg, beg+size[ // Effects : the result is placed in res. { + typedef typename std::basic_string::size_type size_type; res.resize(0); - std::streamsize n=w-size-!!prefix_space; - std::streamsize n_after = 0, n_before = 0; - - if(n<=0) { // no need to pad. + if(w<=0 || static_cast(w) <=size) { + // no need to pad. res.reserve(size + !!prefix_space); + if(prefix_space) + res.append(1, prefix_space); + res.append(beg, size); } else { + std::streamsize n=static_cast(w-size-!!prefix_space); + std::streamsize n_after = 0, n_before = 0; res.reserve(w); // allocate once for the 2 inserts if(center) n_after = n/2, n_before = n - n_after; @@ -54,17 +58,18 @@ namespace detail { n_after = n; else n_before = n; + // now make the res string : + if(n_before) res.append(n_before, fill_char); + if(prefix_space) + res.append(1, prefix_space); + res.append(beg, size); + if(n_after) res.append(n_after, fill_char); } - // now make the res string : - if(n_before) res.append(n_before, fill_char); - if(prefix_space) - res.append(1, prefix_space); - res.append(beg, size); - if(n_after) res.append(n_after, fill_char); } // -mk_str(..) -#if BOOST_WORKAROUND( BOOST_MSVC, <= 1300) +#if BOOST_WORKAROUND( BOOST_MSVC, <= 1300) || \ + BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042)) // MSVC needs to be tricked to disambiguate this simple overload.. // the trick is in "boost/format/msvc_disambiguater.hpp" @@ -149,8 +154,8 @@ namespace detail { if(buf.pcount()== 0 || (res_beg[0] !=oss.widen('+') && res_beg[0] !=oss.widen('-') )) prefix_space = oss.widen(' '); - std::streamsize res_size = (std::min)( - static_cast(specs.truncate_ - !!prefix_space), + size_type res_size = (std::min)( + static_cast(specs.truncate_ - !!prefix_space), buf.pcount() ); mk_str(res, res_beg, res_size, w, oss.fill(), fl, prefix_space, (specs.pad_scheme_ & format_item_t::centered) !=0 ); @@ -161,13 +166,13 @@ namespace detail { // but spacepad or truncate might be mixed with internal (using manipulator) put_last( oss, x); // may pad const Ch * res_beg = buf.pbase(); - std::streamsize res_size = buf.pcount(); + size_type res_size = buf.pcount(); bool prefix_space=false; if(specs.pad_scheme_ & format_item_t::spacepad) if(buf.pcount()== 0 || (res_beg[0] !=oss.widen('+') && res_beg[0] !=oss.widen('-') )) prefix_space = true; - if(res_size == w && w<=specs.truncate_ && !prefix_space) { + if(res_size == static_cast(w) && w<=specs.truncate_ && !prefix_space) { // okay, only one thing was printed and padded, so res is fine res.assign(res_beg, res_size); } @@ -194,25 +199,28 @@ namespace detail { } // we now have the minimal-length output const Ch * tmp_beg = buf.pbase(); - std::streamsize tmp_size = (std::min)(static_cast(specs.truncate_), - buf.pcount() ); + size_type tmp_size = (std::min)(static_cast(specs.truncate_), + buf.pcount() ); - std::streamsize d; - if( (d=w - tmp_size) <=0 ) { + + if(static_cast(w) <= tmp_size) { // minimal length is already >= w, so no padding (cool!) res.assign(tmp_beg, tmp_size); } else { // hum.. we need to pad (multi_output, or spacepad present) - std::streamsize i = prefix_space; //find where we should pad - std::streamsize sz = (std::min)(res_size+prefix_space, tmp_size); + size_type sz = (std::min)(res_size+prefix_space, tmp_size); + size_type i = prefix_space; for(; i=tmp_size) i=prefix_space; res.assign(tmp_beg, i); - if(d>0) res.append(static_cast( d ), oss2.fill()); + std::streamsize d = w - static_cast(tmp_size); + BOOST_ASSERT(d>0); + res.append(static_cast( d ), oss2.fill()); res.append(tmp_beg+i, tmp_size-i); - BOOST_ASSERT(i+(tmp_size-i)+(std::max)(d,(std::streamsize)0) == w); - BOOST_ASSERT(res.size() == (std::size_t)w); + BOOST_ASSERT(i+(tmp_size-i)+(std::max)(d,(std::streamsize)0) + == static_cast(w)); + BOOST_ASSERT(res.size() == static_cast(w)); } } } diff --git a/boost/boost/format/format_class.hpp b/boost/boost/format/format_class.hpp index 563926556f..d776d95146 100644 --- a/boost/boost/format/format_class.hpp +++ b/boost/boost/format/format_class.hpp @@ -84,7 +84,7 @@ namespace boost { #if !defined( BOOST_NO_MEMBER_TEMPLATE_FRIENDS ) \ && !BOOST_WORKAROUND(__BORLANDC__, <= 0x570) \ && !BOOST_WORKAROUND( _CRAYC, != 0) \ - && !BOOST_WORKAROUND(__DECCXX_VER, <= 60590041) + && !BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042)) // use friend templates and private members only if supported #ifndef BOOST_NO_TEMPLATE_STD_STREAM diff --git a/boost/boost/format/format_implementation.hpp b/boost/boost/format/format_implementation.hpp index ccaa346c2f..cab24e3cc7 100644 --- a/boost/boost/format/format_implementation.hpp +++ b/boost/boost/format/format_implementation.hpp @@ -190,9 +190,9 @@ namespace boost { res += item.res_; if( item.argN_ == format_item_t::argN_tabulation) { BOOST_ASSERT( item.pad_scheme_ & format_item_t::tabulation); - std::streamsize n = item.fmtstate_.width_ - res.size(); - if( n > 0 ) - res.append( n, item.fmtstate_.fill_ ); + if( static_cast(item.fmtstate_.width_) > res.size() ) + res.append( static_cast(item.fmtstate_.width_) - res.size(), + item.fmtstate_.fill_ ); } res += item.appendix_; } @@ -200,19 +200,20 @@ namespace boost { return res; } template< class Ch, class Tr, class Alloc> - typename basic_format::size_type basic_format:: + typename std::basic_string::size_type basic_format:: size () const { BOOST_USING_STD_MAX(); - std::streamsize sz = prefix_.size(); + size_type sz = prefix_.size(); unsigned long i; for(i=0; i < items_.size(); ++i) { const format_item_t& item = items_[i]; sz += item.res_.size(); if( item.argN_ == format_item_t::argN_tabulation) - sz = max BOOST_PREVENT_MACRO_SUBSTITUTION (sz, item.fmtstate_.width_); - sz += + item.appendix_.size(); + sz = max BOOST_PREVENT_MACRO_SUBSTITUTION (sz, + static_cast(item.fmtstate_.width_) ); + sz += item.appendix_.size(); } - return static_cast (sz); + return sz; } namespace io { diff --git a/boost/boost/format/parsing.hpp b/boost/boost/format/parsing.hpp index bbbf9d4806..0bd15d56f3 100644 --- a/boost/boost/format/parsing.hpp +++ b/boost/boost/format/parsing.hpp @@ -44,7 +44,7 @@ namespace detail { template inline bool wrap_isdigit(const Facet& fac, Ch c) { -#if ! defined( BOOST_NO_LOCALE_ISIDIGIT ) +#if ! defined( BOOST_NO_LOCALE_ISDIGIT ) return fac.is(std::ctype::digit, c); # else using namespace std; diff --git a/boost/boost/function.hpp b/boost/boost/function.hpp index 90336b1b6d..1a5cca2b4e 100644 --- a/boost/boost/function.hpp +++ b/boost/boost/function.hpp @@ -22,7 +22,7 @@ #include // Visual Age C++ doesn't handle the file iteration well -#if BOOST_WORKAROUND(__IBMCPP__, <= 600) +#if BOOST_WORKAROUND(__IBMCPP__, >= 500) # if BOOST_FUNCTION_MAX_ARGS >= 0 # include # endif diff --git a/boost/boost/function/function_base.hpp b/boost/boost/function/function_base.hpp index 23f5f201c7..30f691611d 100644 --- a/boost/boost/function/function_base.hpp +++ b/boost/boost/function/function_base.hpp @@ -63,11 +63,19 @@ namespace boost { namespace python { namespace objects { # define BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX #endif -#define BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor,Type) \ - typename ::boost::enable_if_c<(::boost::type_traits::ice_not< \ - (::boost::is_integral::value)>::value), \ +#if !BOOST_WORKAROUND(__BORLANDC__, < 0x600) +# define BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor,Type) \ + typename ::boost::enable_if_c<(::boost::type_traits::ice_not< \ + (::boost::is_integral::value)>::value), \ + Type>::type +#else +// BCC doesn't recognize this depends on a template argument and complains +// about the use of 'typename' +# define BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor,Type) \ + ::boost::enable_if_c<(::boost::type_traits::ice_not< \ + (::boost::is_integral::value)>::value), \ Type>::type - +#endif #if !defined(BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX) namespace boost { @@ -414,7 +422,12 @@ public: } template + +#if defined(BOOST_MSVC) && BOOST_WORKAROUND(BOOST_MSVC, < 1300) + const Functor* target( Functor * = 0 ) const +#else const Functor* target() const +#endif { if (!manager) return 0; @@ -424,14 +437,23 @@ public: if (!result.obj_ptr) return 0; else { typedef typename detail::function::get_function_tag::type tag; + +#if defined(BOOST_MSVC) && BOOST_WORKAROUND(BOOST_MSVC, < 1300) + return get_functor_pointer(tag(), 0, (Functor*)0); +#else return get_functor_pointer(tag(), 0); +#endif } } template bool contains(const F& f) const { +#if defined(BOOST_MSVC) && BOOST_WORKAROUND(BOOST_MSVC, < 1300) + if (const F* fp = this->target( (F*)0 )) { +#else if (const F* fp = this->template target()) { +#endif return function_equal(*fp, f); } else { return false; @@ -469,20 +491,36 @@ public: // should be protected, but GCC 2.95.3 will fail to allow access private: template +#if defined(BOOST_MSVC) && BOOST_WORKAROUND(BOOST_MSVC, < 1300) + Functor* get_functor_pointer(detail::function::function_ptr_tag, int, Functor * = 0) +#else Functor* get_functor_pointer(detail::function::function_ptr_tag, int) +#endif { return reinterpret_cast(&functor.func_ptr); } template +#if defined(BOOST_MSVC) && BOOST_WORKAROUND(BOOST_MSVC, < 1300) + Functor* get_functor_pointer(Tag, long, Functor * = 0) +#else Functor* get_functor_pointer(Tag, long) +#endif { return static_cast(functor.obj_ptr); } template const Functor* +#if defined(BOOST_MSVC) && BOOST_WORKAROUND(BOOST_MSVC, < 1300) + get_functor_pointer(detail::function::function_ptr_tag, int, Functor * = 0) const +#else get_functor_pointer(detail::function::function_ptr_tag, int) const +#endif { return reinterpret_cast(&functor.func_ptr); } template +#if defined(BOOST_MSVC) && BOOST_WORKAROUND(BOOST_MSVC, < 1300) + const Functor* get_functor_pointer(Tag, long, Functor * = 0) const +#else const Functor* get_functor_pointer(Tag, long) const +#endif { return static_cast(functor.const_obj_ptr); } }; diff --git a/boost/boost/function/function_template.hpp b/boost/boost/function/function_template.hpp index b00238b1a5..3730f421ce 100644 --- a/boost/boost/function/function_template.hpp +++ b/boost/boost/function/function_template.hpp @@ -61,6 +61,14 @@ #define BOOST_FUNCTION_GET_STATELESS_FUNCTION_OBJ_INVOKER \ BOOST_JOIN(get_stateless_function_obj_invoker,BOOST_FUNCTION_NUM_ARGS) +#ifndef BOOST_NO_VOID_RETURNS +# define BOOST_FUNCTION_VOID_RETURN_TYPE void +# define BOOST_FUNCTION_RETURN(X) X +#else +# define BOOST_FUNCTION_VOID_RETURN_TYPE ::boost::detail::function::unusable +# define BOOST_FUNCTION_RETURN(X) X; return BOOST_FUNCTION_VOID_RETURN_TYPE () +#endif + namespace boost { namespace detail { namespace function { @@ -86,13 +94,13 @@ namespace boost { > struct BOOST_FUNCTION_VOID_FUNCTION_INVOKER { - static unusable invoke(any_pointer function_ptr BOOST_FUNCTION_COMMA - BOOST_FUNCTION_PARMS) + static BOOST_FUNCTION_VOID_RETURN_TYPE + invoke(any_pointer function_ptr BOOST_FUNCTION_COMMA + BOOST_FUNCTION_PARMS) { FunctionPtr f = reinterpret_cast(function_ptr.func_ptr); - f(BOOST_FUNCTION_ARGS); - return unusable(); + BOOST_FUNCTION_RETURN(f(BOOST_FUNCTION_ARGS)); } }; @@ -119,14 +127,13 @@ namespace boost { > struct BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER { - static unusable invoke(any_pointer function_obj_ptr - BOOST_FUNCTION_COMMA - BOOST_FUNCTION_PARMS) + static BOOST_FUNCTION_VOID_RETURN_TYPE + invoke(any_pointer function_obj_ptr BOOST_FUNCTION_COMMA + BOOST_FUNCTION_PARMS) { FunctionObj* f = (FunctionObj*)(function_obj_ptr.obj_ptr); - (*f)(BOOST_FUNCTION_ARGS); - return unusable(); + BOOST_FUNCTION_RETURN((*f)(BOOST_FUNCTION_ARGS)); } }; @@ -151,13 +158,12 @@ namespace boost { > struct BOOST_FUNCTION_STATELESS_VOID_FUNCTION_OBJ_INVOKER { - static unusable invoke(any_pointer BOOST_FUNCTION_COMMA - BOOST_FUNCTION_PARMS) + static BOOST_FUNCTION_VOID_RETURN_TYPE + invoke(any_pointer BOOST_FUNCTION_COMMA BOOST_FUNCTION_PARMS) { FunctionObj f = FunctionObj(); - f(BOOST_FUNCTION_ARGS); - return unusable(); + BOOST_FUNCTION_RETURN(f(BOOST_FUNCTION_ARGS)); } }; @@ -235,8 +241,12 @@ namespace boost { class BOOST_FUNCTION_FUNCTION : public function_base { public: - typedef typename detail::function::function_return_type::type - internal_result_type; +#ifndef BOOST_NO_VOID_RETURNS + typedef R result_type; +#else + typedef typename detail::function::function_return_type::type + result_type; +#endif // BOOST_NO_VOID_RETURNS private: struct clear_type {}; @@ -248,7 +258,7 @@ namespace boost { template struct sig { - typedef internal_result_type type; + typedef result_type type; }; #if BOOST_FUNCTION_NUM_ARGS == 1 @@ -261,11 +271,6 @@ namespace boost { BOOST_STATIC_CONSTANT(int, arity = BOOST_FUNCTION_NUM_ARGS); BOOST_FUNCTION_ARG_TYPES -#ifndef BOOST_NO_VOID_RETURNS - typedef R result_type; -#else - typedef internal_result_type result_type; -#endif // BOOST_NO_VOID_RETURNS typedef Allocator allocator_type; typedef BOOST_FUNCTION_FUNCTION self_type; @@ -315,15 +320,7 @@ namespace boost { if (this->empty()) boost::throw_exception(bad_function_call()); - internal_result_type result = invoker(this->functor - BOOST_FUNCTION_COMMA - BOOST_FUNCTION_ARGS); - -#ifndef BOOST_NO_VOID_RETURNS - return static_cast(result); -#else - return result; -#endif // BOOST_NO_VOID_RETURNS + return invoker(this->functor BOOST_FUNCTION_COMMA BOOST_FUNCTION_ARGS); } #else result_type operator()(BOOST_FUNCTION_PARMS) const; @@ -470,7 +467,7 @@ namespace boost { template void assign_to(FunctionObj f, detail::function::function_obj_tag) { - if (!detail::function::has_empty_target(addressof(f))) { + if (!detail::function::has_empty_target(boost::addressof(f))) { typedef typename detail::function::BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER< FunctionObj, @@ -539,9 +536,9 @@ namespace boost { this->functor = detail::function::make_any_pointer(this); } - typedef internal_result_type (*invoker_type)(detail::function::any_pointer - BOOST_FUNCTION_COMMA - BOOST_FUNCTION_TEMPLATE_ARGS); + typedef result_type (*invoker_type)(detail::function::any_pointer + BOOST_FUNCTION_COMMA + BOOST_FUNCTION_TEMPLATE_ARGS); invoker_type invoker; }; @@ -573,19 +570,11 @@ namespace boost { Allocator> ::operator()(BOOST_FUNCTION_PARMS) const { - if (this->empty()) - boost::throw_exception(bad_function_call()); - - internal_result_type result = invoker(this->functor - BOOST_FUNCTION_COMMA - BOOST_FUNCTION_ARGS); - -# ifndef BOOST_NO_VOID_RETURNS - return static_cast(result); -# else - return result; -# endif // BOOST_NO_VOID_RETURNS - } + if (this->empty()) + boost::throw_exception(bad_function_call()); + + return invoker(this->functor BOOST_FUNCTION_COMMA BOOST_FUNCTION_ARGS); + } #endif // Poison comparisons between boost::function objects of the same type. @@ -719,3 +708,5 @@ public: #undef BOOST_FUNCTION_ARGS #undef BOOST_FUNCTION_ARG_TYPE #undef BOOST_FUNCTION_ARG_TYPES +#undef BOOST_FUNCTION_VOID_RETURN_TYPE +#undef BOOST_FUNCTION_RETURN diff --git a/boost/boost/function_equal.hpp b/boost/boost/function_equal.hpp index 8bd06a3bb7..2d76c75bc9 100644 --- a/boost/boost/function_equal.hpp +++ b/boost/boost/function_equal.hpp @@ -1,6 +1,9 @@ -// Copyright Douglas Gregor 2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// Copyright Douglas Gregor 2004. +// Copyright 2005 Peter Dimov + +// Use, modification and distribution is subject to +// the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // For more information, see http://www.boost.org @@ -9,15 +12,16 @@ namespace boost { -namespace detail { - template - bool function_equal_impl(const F& f, const G& g, long) - { return f == g; } -} // end namespace boost::function +template + bool function_equal_impl(const F& f, const G& g, long) + { return f == g; } + +// function_equal_impl needs to be unqualified to pick +// user overloads on two-phase compilers template bool function_equal(const F& f, const G& g) - { return ::boost::detail::function_equal_impl(f, g, 0); } + { return function_equal_impl(f, g, 0); } } // end namespace boost diff --git a/boost/boost/implicit_cast.hpp b/boost/boost/implicit_cast.hpp new file mode 100644 index 0000000000..2593cb4b3d --- /dev/null +++ b/boost/boost/implicit_cast.hpp @@ -0,0 +1,35 @@ +// Copyright David Abrahams 2003. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +#ifndef IMPLICIT_CAST_DWA200356_HPP +# define IMPLICIT_CAST_DWA200356_HPP + +# include + +namespace boost { + +// implementation originally suggested by C. Green in +// http://lists.boost.org/MailArchives/boost/msg00886.php + +// The use of identity creates a non-deduced form, so that the +// explicit template argument must be supplied +template +inline T implicit_cast (typename mpl::identity::type x) { + return x; +} + +// incomplete return type now is here +//template +//void implicit_cast (...); + +// Macro for when you need a constant expression (Gennaro Prota) +#define BOOST_IMPLICIT_CAST(dst_type, expr) \ + ( sizeof( implicit_cast(expr) ) \ + , \ + static_cast(expr) \ + ) + +} // namespace boost + +#endif // IMPLICIT_CAST_DWA200356_HPP diff --git a/boost/boost/indirect_reference.hpp b/boost/boost/indirect_reference.hpp index 2e993d9c05..5fbb342319 100755 --- a/boost/boost/indirect_reference.hpp +++ b/boost/boost/indirect_reference.hpp @@ -1,11 +1,15 @@ -// Copyright David Abrahams 2004. Use, modification and distribution is -// subject to the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef INDIRECT_REFERENCE_DWA200415_HPP # define INDIRECT_REFERENCE_DWA200415_HPP -// dereferenceable_traits provides access to the value_type and -// reference of a Dereferenceable type. +// +// Copyright David Abrahams 2004. Use, modification and distribution is +// subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// typename indirect_reference

::type provides the type of *p. +// +// http://www.boost.org/libs/iterator/doc/pointee.html +// # include # include diff --git a/boost/boost/integer_traits.hpp b/boost/boost/integer_traits.hpp index f21a968979..71761e3e71 100644 --- a/boost/boost/integer_traits.hpp +++ b/boost/boost/integer_traits.hpp @@ -5,7 +5,7 @@ * accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * - * $Id: integer_traits.hpp,v 1.25 2004/09/04 10:34:47 johnmaddock Exp $ + * $Id: integer_traits.hpp,v 1.27.2.1 2005/08/24 15:45:17 johnmaddock Exp $ * * Idea by Beman Dawes, Ed Brey, Steve Cleary, and Nathan Myers */ @@ -21,7 +21,9 @@ // These are an implementation detail and not part of the interface #include -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) && !defined(BOOST_NO_CWCHAR) +// we need wchar.h for WCHAR_MAX/MIN but not all platforms provide it, +// and some may have but not ... +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) && (!defined(BOOST_NO_CWCHAR) || defined(sun) || defined(__sun)) #include #endif @@ -86,7 +88,9 @@ class integer_traits template<> class integer_traits : public std::numeric_limits, -#if defined(WCHAR_MIN) && defined(WCHAR_MAX) + // Don't trust WCHAR_MIN and WCHAR_MAX with Mac OS X's native + // library: they are wrong! +#if defined(WCHAR_MIN) && defined(WCHAR_MAX) && !defined(__APPLE__) public detail::integer_traits_base #elif defined(__BORLANDC__) || defined(__CYGWIN__) || defined(__MINGW32__) || (defined(__BEOS__) && defined(__GNUC__)) // No WCHAR_MIN and WCHAR_MAX, whar_t is short and unsigned: diff --git a/boost/boost/iterator/detail/config_def.hpp b/boost/boost/iterator/detail/config_def.hpp index fcdb9d62b4..82b3b52cb3 100644 --- a/boost/boost/iterator/detail/config_def.hpp +++ b/boost/boost/iterator/detail/config_def.hpp @@ -22,7 +22,11 @@ # define BOOST_ITERATOR_CONFIG_DEF #endif -#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ +// We enable this always now. Otherwise, the simple case in +// libs/iterator/test/constant_iterator_arrow.cpp fails to compile +// because the operator-> return is improperly deduced as a non-const +// pointer. +#if 1 || defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x531)) // Recall that in general, compilers without partial specialization @@ -36,7 +40,7 @@ // end up using a proxy for operator[] when we otherwise shouldn't. // Using reference constness gives it an extra hint that it can // return the value_type from operator[] directly, but is not -// strictly neccessary. Not sure how best to resolve this one. +// strictly necessary. Not sure how best to resolve this one. # define BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY 1 @@ -44,7 +48,8 @@ #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \ || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x531)) \ - || (BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 700) && defined(_MSC_VER)) + || (BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 700) && defined(_MSC_VER)) \ + || BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042)) # define BOOST_NO_LVALUE_RETURN_DETECTION # if 0 // test code diff --git a/boost/boost/iterator/filter_iterator.hpp b/boost/boost/iterator/filter_iterator.hpp index 0edede52ac..96fb84359f 100644 --- a/boost/boost/iterator/filter_iterator.hpp +++ b/boost/boost/iterator/filter_iterator.hpp @@ -31,9 +31,9 @@ namespace boost , typename mpl::if_< is_convertible< typename iterator_traversal::type - , bidirectional_traversal_tag + , random_access_traversal_tag > - , forward_traversal_tag + , bidirectional_traversal_tag , use_default >::type > type; diff --git a/boost/boost/iterator/iterator_adaptor.hpp b/boost/boost/iterator/iterator_adaptor.hpp index eabacde25a..457c439659 100644 --- a/boost/boost/iterator/iterator_adaptor.hpp +++ b/boost/boost/iterator/iterator_adaptor.hpp @@ -278,6 +278,8 @@ namespace boost { } + typedef Base base_type; + Base const& base() const { return m_iterator; } diff --git a/boost/boost/iterator/iterator_facade.hpp b/boost/boost/iterator/iterator_facade.hpp index 3b40db2319..ddb237d324 100644 --- a/boost/boost/iterator/iterator_facade.hpp +++ b/boost/boost/iterator/iterator_facade.hpp @@ -7,8 +7,6 @@ #ifndef BOOST_ITERATOR_FACADE_23022003THW_HPP #define BOOST_ITERATOR_FACADE_23022003THW_HPP -#include - #include #include #include @@ -16,6 +14,9 @@ #include #include +#include +#include + #include #include #include @@ -106,7 +107,7 @@ namespace boost typedef typename mpl::eval_if< detail::iterator_writability_disabled - , add_pointer::type> + , add_pointer , add_pointer >::type pointer; @@ -269,8 +270,8 @@ namespace boost struct postfix_increment_result : mpl::eval_if< mpl::and_< - // A proxy is only needed for readable iterators - is_convertible + // A proxy is only needed for readable iterators + is_convertible // No multipass iterator can have values that disappear // before positions can be re-visited @@ -322,7 +323,7 @@ namespace boost static type make(Reference x) { - return type(&x); + return implicit_cast(&x); } }; diff --git a/boost/boost/lexical_cast.hpp b/boost/boost/lexical_cast.hpp index 079ca68b04..926b95e430 100644 --- a/boost/boost/lexical_cast.hpp +++ b/boost/boost/lexical_cast.hpp @@ -12,8 +12,9 @@ // with additional fixes and suggestions from Gennaro Prota, // Beman Dawes, Dave Abrahams, Daryle Walker, Peter Dimov, // and other Boosters -// when: November 2000, March 2003 +// when: November 2000, March 2003, June 2005 +#include #include #include #include @@ -29,8 +30,7 @@ #if defined(BOOST_NO_STRINGSTREAM) || \ defined(BOOST_NO_STD_WSTRING) || \ - defined(BOOST_NO_STD_LOCALE) || \ - defined(BOOST_NO_INTRINSIC_WCHAR_T) + defined(BOOST_NO_STD_LOCALE) #define DISABLE_WIDE_CHAR_SUPPORT #endif @@ -45,9 +45,9 @@ namespace boost { } bad_lexical_cast( - const std::type_info &s, - const std::type_info &t) : - source(&s), target(&t) + const std::type_info &source_type, + const std::type_info &target_type) : + source(&source_type), target(&target_type) { } const std::type_info &source_type() const @@ -80,11 +80,13 @@ namespace boost }; #ifndef DISABLE_WIDE_CHAR_SUPPORT +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) template<> struct stream_char { typedef wchar_t type; }; +#endif template<> struct stream_char @@ -123,6 +125,11 @@ namespace boost template class lexical_stream { + private: + typedef typename widest_char< + typename stream_char::type, + typename stream_char::type>::type char_type; + public: lexical_stream() { @@ -148,7 +155,16 @@ namespace boost { return !is_pointer::value && stream >> output && - (stream >> std::ws).eof(); + stream.get() == +#if defined(__GNUC__) && (__GNUC__<3) && defined(BOOST_NO_STD_WSTRING) +// GCC 2.9x lacks std::char_traits<>::eof(). +// We use BOOST_NO_STD_WSTRING to filter out STLport and libstdc++-v3 +// configurations, which do provide std::char_traits<>::eof(). + + EOF; +#else + std::char_traits::eof(); +#endif } bool operator>>(std::string &output) { @@ -166,10 +182,6 @@ namespace boost } #endif private: - typedef typename widest_char< - typename stream_char::type, - typename stream_char::type>::type char_type; - #if defined(BOOST_NO_STRINGSTREAM) std::strstream stream; #elif defined(BOOST_NO_STD_LOCALE) @@ -180,6 +192,42 @@ namespace boost }; } + #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + // call-by-const reference version + + namespace detail + { + template + struct array_to_pointer_decay + { + typedef T type; + }; + + template + struct array_to_pointer_decay + { + typedef const T * type; + }; + } + + template + Target lexical_cast(const Source &arg) + { + typedef typename detail::array_to_pointer_decay::type NewSource; + + detail::lexical_stream interpreter; + Target result; + + if(!(interpreter << arg && interpreter >> result)) + throw_exception(bad_lexical_cast(typeid(NewSource), typeid(Target))); + return result; + } + + #else + + // call-by-value fallback version (deprecated) + template Target lexical_cast(Source arg) { @@ -187,12 +235,14 @@ namespace boost Target result; if(!(interpreter << arg && interpreter >> result)) - throw_exception(bad_lexical_cast(typeid(Target), typeid(Source))); + throw_exception(bad_lexical_cast(typeid(Source), typeid(Target))); return result; } + + #endif } -// Copyright Kevlin Henney, 2000-2003. All rights reserved. +// Copyright Kevlin Henney, 2000-2005. All rights reserved. // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -200,4 +250,3 @@ namespace boost #undef DISABLE_WIDE_CHAR_SUPPORT #endif - diff --git a/boost/boost/mem_fn.hpp b/boost/boost/mem_fn.hpp index dd46ef3f3e..7097d43bec 100644 --- a/boost/boost/mem_fn.hpp +++ b/boost/boost/mem_fn.hpp @@ -12,6 +12,7 @@ // // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. // Copyright (c) 2001 David Abrahams +// Copyright (c) 2003-2005 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -48,6 +49,18 @@ template struct mf #undef BOOST_MEM_FN_CC #undef BOOST_MEM_FN_NAME +#ifdef BOOST_MEM_FN_ENABLE_CDECL + +#define BOOST_MEM_FN_NAME(X) inner_##X##_cdecl +#define BOOST_MEM_FN_CC __cdecl + +#include + +#undef BOOST_MEM_FN_CC +#undef BOOST_MEM_FN_NAME + +#endif + #ifdef BOOST_MEM_FN_ENABLE_STDCALL #define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall @@ -89,6 +102,18 @@ template<> struct mf #undef BOOST_MEM_FN_CC #undef BOOST_MEM_FN_NAME +#ifdef BOOST_MEM_FN_ENABLE_CDECL + +#define BOOST_MEM_FN_NAME(X) inner_##X##_cdecl +#define BOOST_MEM_FN_CC __cdecl + +#include + +#undef BOOST_MEM_FN_CC +#undef BOOST_MEM_FN_NAME + +#endif + #ifdef BOOST_MEM_FN_ENABLE_STDCALL #define BOOST_MEM_FN_NAME(X) inner_##X##_stdcall @@ -130,6 +155,20 @@ template<> struct mf #undef BOOST_MEM_FN_NAME2 #undef BOOST_MEM_FN_CC +#ifdef BOOST_MEM_FN_ENABLE_CDECL + +#define BOOST_MEM_FN_NAME(X) X##_cdecl +#define BOOST_MEM_FN_NAME2(X) inner_##X##_cdecl +#define BOOST_MEM_FN_CC __cdecl + +#include + +#undef BOOST_MEM_FN_NAME +#undef BOOST_MEM_FN_NAME2 +#undef BOOST_MEM_FN_CC + +#endif + #ifdef BOOST_MEM_FN_ENABLE_STDCALL #define BOOST_MEM_FN_NAME(X) X##_stdcall @@ -178,6 +217,18 @@ namespace _mfi #undef BOOST_MEM_FN_CC #undef BOOST_MEM_FN_NAME +#ifdef BOOST_MEM_FN_ENABLE_CDECL + +#define BOOST_MEM_FN_NAME(X) X##_cdecl +#define BOOST_MEM_FN_CC __cdecl + +#include + +#undef BOOST_MEM_FN_CC +#undef BOOST_MEM_FN_NAME + +#endif + #ifdef BOOST_MEM_FN_ENABLE_STDCALL #define BOOST_MEM_FN_NAME(X) X##_stdcall @@ -219,6 +270,18 @@ namespace _mfi #undef BOOST_MEM_FN_NAME #undef BOOST_MEM_FN_CC +#ifdef BOOST_MEM_FN_ENABLE_CDECL + +#define BOOST_MEM_FN_NAME(X) X##_cdecl +#define BOOST_MEM_FN_CC __cdecl + +#include + +#undef BOOST_MEM_FN_NAME +#undef BOOST_MEM_FN_CC + +#endif + #ifdef BOOST_MEM_FN_ENABLE_STDCALL #define BOOST_MEM_FN_NAME(X) X##_stdcall @@ -294,7 +357,7 @@ public: return call(u, &u); } -#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) && !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) +#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) && !BOOST_WORKAROUND(__MWERKS__, < 0x3200) R & operator()(T & t) const { diff --git a/boost/boost/mpl/aux_/arity_spec.hpp b/boost/boost/mpl/aux_/arity_spec.hpp index e20a0e578c..3b4fe8c152 100644 --- a/boost/boost/mpl/aux_/arity_spec.hpp +++ b/boost/boost/mpl/aux_/arity_spec.hpp @@ -11,8 +11,8 @@ // See http://www.boost.org/libs/mpl for documentation. // $Source: /cvsroot/boost/boost/boost/mpl/aux_/arity_spec.hpp,v $ -// $Date: 2004/10/30 06:10:35 $ -// $Revision: 1.5.2.2 $ +// $Date: 2004/11/28 02:04:02 $ +// $Revision: 1.7 $ #include #include diff --git a/boost/boost/mpl/aux_/lambda_support.hpp b/boost/boost/mpl/aux_/lambda_support.hpp index e1b9ee2b78..4b9b235906 100644 --- a/boost/boost/mpl/aux_/lambda_support.hpp +++ b/boost/boost/mpl/aux_/lambda_support.hpp @@ -11,8 +11,8 @@ // See http://www.boost.org/libs/mpl for documentation. // $Source: /cvsroot/boost/boost/boost/mpl/aux_/lambda_support.hpp,v $ -// $Date: 2004/10/30 08:21:50 $ -// $Revision: 1.11.2.1 $ +// $Date: 2004/11/28 01:37:05 $ +// $Revision: 1.12 $ #include diff --git a/boost/boost/mpl/aux_/msvc_eti_base.hpp b/boost/boost/mpl/aux_/msvc_eti_base.hpp index 55b612a4dc..ad45c7e45d 100644 --- a/boost/boost/mpl/aux_/msvc_eti_base.hpp +++ b/boost/boost/mpl/aux_/msvc_eti_base.hpp @@ -11,8 +11,8 @@ // See http://www.boost.org/libs/mpl for documentation. // $Source: /cvsroot/boost/boost/boost/mpl/aux_/msvc_eti_base.hpp,v $ -// $Date: 2004/11/10 23:38:09 $ -// $Revision: 1.6.2.1 $ +// $Date: 2004/11/28 01:37:05 $ +// $Revision: 1.7 $ #include #include diff --git a/boost/boost/mpl/aux_/na.hpp b/boost/boost/mpl/aux_/na.hpp index 14a2533640..413a1cd0cc 100644 --- a/boost/boost/mpl/aux_/na.hpp +++ b/boost/boost/mpl/aux_/na.hpp @@ -11,8 +11,8 @@ // See http://www.boost.org/libs/mpl for documentation. // $Source: /cvsroot/boost/boost/boost/mpl/aux_/na.hpp,v $ -// $Date: 2004/10/30 08:21:50 $ -// $Revision: 1.5.2.1 $ +// $Date: 2004/11/28 01:37:30 $ +// $Revision: 1.6 $ #include #include diff --git a/boost/boost/mpl/aux_/na_assert.hpp b/boost/boost/mpl/aux_/na_assert.hpp index de0964f17c..6d8c70d7fd 100644 --- a/boost/boost/mpl/aux_/na_assert.hpp +++ b/boost/boost/mpl/aux_/na_assert.hpp @@ -11,14 +11,15 @@ // See http://www.boost.org/libs/mpl for documentation. // $Source: /cvsroot/boost/boost/boost/mpl/aux_/na_assert.hpp,v $ -// $Date: 2004/09/28 13:56:59 $ -// $Revision: 1.2 $ +// $Date: 2005/07/13 13:13:38 $ +// $Revision: 1.6 $ #include #include #include -#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) +#if !BOOST_WORKAROUND(_MSC_FULL_VER, <= 140050601) \ + && !BOOST_WORKAROUND(__EDG_VERSION__, <= 243) # include # define BOOST_MPL_AUX_ASSERT_NOT_NA(x) \ BOOST_MPL_ASSERT_NOT((boost::mpl::is_na)) \ diff --git a/boost/boost/mpl/aux_/na_fwd.hpp b/boost/boost/mpl/aux_/na_fwd.hpp index 0cdf21e8d1..a82941e8f3 100644 --- a/boost/boost/mpl/aux_/na_fwd.hpp +++ b/boost/boost/mpl/aux_/na_fwd.hpp @@ -10,9 +10,9 @@ // // See http://www.boost.org/libs/mpl for documentation. -// $Source: /cvsroot/boost/boost/boost/mpl/aux_/Attic/na_fwd.hpp,v $ -// $Date: 2004/10/30 08:22:23 $ -// $Revision: 1.1.2.1 $ +// $Source: /cvsroot/boost/boost/boost/mpl/aux_/na_fwd.hpp,v $ +// $Date: 2004/11/28 01:37:30 $ +// $Revision: 1.2 $ #include diff --git a/boost/boost/mpl/aux_/na_spec.hpp b/boost/boost/mpl/aux_/na_spec.hpp index 1c0a33bd08..52c6407389 100644 --- a/boost/boost/mpl/aux_/na_spec.hpp +++ b/boost/boost/mpl/aux_/na_spec.hpp @@ -11,8 +11,8 @@ // See http://www.boost.org/libs/mpl for documentation. // $Source: /cvsroot/boost/boost/boost/mpl/aux_/na_spec.hpp,v $ -// $Date: 2004/11/08 18:23:49 $ -// $Revision: 1.2.2.1 $ +// $Date: 2004/11/28 01:38:15 $ +// $Revision: 1.3 $ #if !defined(BOOST_MPL_PREPROCESSING_MODE) # include diff --git a/boost/boost/mpl/aux_/nttp_decl.hpp b/boost/boost/mpl/aux_/nttp_decl.hpp index bb79ecbd4a..5fba8a8a9c 100644 --- a/boost/boost/mpl/aux_/nttp_decl.hpp +++ b/boost/boost/mpl/aux_/nttp_decl.hpp @@ -11,15 +11,17 @@ // See http://www.boost.org/libs/mpl for documentation. // $Source: /cvsroot/boost/boost/boost/mpl/aux_/nttp_decl.hpp,v $ -// $Date: 2004/09/02 15:40:44 $ -// $Revision: 1.1 $ +// $Date: 2004/12/16 22:43:05 $ +// $Revision: 1.2 $ #include #if defined(BOOST_MPL_CFG_NTTP_BUG) -typedef int _mpl_nttp_int; -typedef long _mpl_nttp_long; +typedef bool _mpl_nttp_bool; +typedef int _mpl_nttp_int; +typedef unsigned _mpl_nttp_unsigned; +typedef long _mpl_nttp_long; # include # define BOOST_MPL_AUX_NTTP_DECL(T, x) BOOST_PP_CAT(_mpl_nttp_,T) x /**/ diff --git a/boost/boost/mpl/aux_/preprocessed/plain/deque.hpp b/boost/boost/mpl/aux_/preprocessed/plain/deque.hpp index 16b20433dc..de67398a37 100644 --- a/boost/boost/mpl/aux_/preprocessed/plain/deque.hpp +++ b/boost/boost/mpl/aux_/preprocessed/plain/deque.hpp @@ -6,7 +6,7 @@ // http://www.boost.org/LICENSE_1_0.txt) // -// Preprocessed version of "boost/mpl/Attic/deque.hpp" header +// Preprocessed version of "boost/mpl/deque.hpp" header // -- DO NOT modify by hand! namespace boost { namespace mpl { diff --git a/boost/boost/mpl/aux_/preprocessed/plain/equal_to.hpp b/boost/boost/mpl/aux_/preprocessed/plain/equal_to.hpp index 8a47494f0c..bbc6bf0dc1 100644 --- a/boost/boost/mpl/aux_/preprocessed/plain/equal_to.hpp +++ b/boost/boost/mpl/aux_/preprocessed/plain/equal_to.hpp @@ -65,6 +65,7 @@ template< , typename BOOST_MPL_AUX_NA_PARAM(N2) > struct equal_to + : equal_to_impl< typename equal_to_tag::type , typename equal_to_tag::type diff --git a/boost/boost/mpl/aux_/preprocessed/plain/greater.hpp b/boost/boost/mpl/aux_/preprocessed/plain/greater.hpp index 94f44c029e..38c8bb3add 100644 --- a/boost/boost/mpl/aux_/preprocessed/plain/greater.hpp +++ b/boost/boost/mpl/aux_/preprocessed/plain/greater.hpp @@ -65,6 +65,7 @@ template< , typename BOOST_MPL_AUX_NA_PARAM(N2) > struct greater + : greater_impl< typename greater_tag::type , typename greater_tag::type diff --git a/boost/boost/mpl/aux_/preprocessed/plain/greater_equal.hpp b/boost/boost/mpl/aux_/preprocessed/plain/greater_equal.hpp index f33ecf5967..2aa8370f0f 100644 --- a/boost/boost/mpl/aux_/preprocessed/plain/greater_equal.hpp +++ b/boost/boost/mpl/aux_/preprocessed/plain/greater_equal.hpp @@ -65,6 +65,7 @@ template< , typename BOOST_MPL_AUX_NA_PARAM(N2) > struct greater_equal + : greater_equal_impl< typename greater_equal_tag::type , typename greater_equal_tag::type diff --git a/boost/boost/mpl/aux_/preprocessed/plain/less.hpp b/boost/boost/mpl/aux_/preprocessed/plain/less.hpp index 291ae10865..928d0e3087 100644 --- a/boost/boost/mpl/aux_/preprocessed/plain/less.hpp +++ b/boost/boost/mpl/aux_/preprocessed/plain/less.hpp @@ -65,6 +65,7 @@ template< , typename BOOST_MPL_AUX_NA_PARAM(N2) > struct less + : less_impl< typename less_tag::type , typename less_tag::type diff --git a/boost/boost/mpl/aux_/preprocessed/plain/less_equal.hpp b/boost/boost/mpl/aux_/preprocessed/plain/less_equal.hpp index 24ac64ed6a..364cd967a7 100644 --- a/boost/boost/mpl/aux_/preprocessed/plain/less_equal.hpp +++ b/boost/boost/mpl/aux_/preprocessed/plain/less_equal.hpp @@ -65,6 +65,7 @@ template< , typename BOOST_MPL_AUX_NA_PARAM(N2) > struct less_equal + : less_equal_impl< typename less_equal_tag::type , typename less_equal_tag::type diff --git a/boost/boost/mpl/aux_/preprocessed/plain/modulus.hpp b/boost/boost/mpl/aux_/preprocessed/plain/modulus.hpp index cb651b64ca..6a64e49a81 100644 --- a/boost/boost/mpl/aux_/preprocessed/plain/modulus.hpp +++ b/boost/boost/mpl/aux_/preprocessed/plain/modulus.hpp @@ -65,6 +65,7 @@ template< , typename BOOST_MPL_AUX_NA_PARAM(N2) > struct modulus + : modulus_impl< typename modulus_tag::type , typename modulus_tag::type diff --git a/boost/boost/mpl/aux_/preprocessed/plain/not_equal_to.hpp b/boost/boost/mpl/aux_/preprocessed/plain/not_equal_to.hpp index 4991367e65..c08d7f06d7 100644 --- a/boost/boost/mpl/aux_/preprocessed/plain/not_equal_to.hpp +++ b/boost/boost/mpl/aux_/preprocessed/plain/not_equal_to.hpp @@ -65,6 +65,7 @@ template< , typename BOOST_MPL_AUX_NA_PARAM(N2) > struct not_equal_to + : not_equal_to_impl< typename not_equal_to_tag::type , typename not_equal_to_tag::type diff --git a/boost/boost/mpl/aux_/preprocessed/plain/set_c.hpp b/boost/boost/mpl/aux_/preprocessed/plain/set_c.hpp index cfdd45abcb..cbeb932c13 100644 --- a/boost/boost/mpl/aux_/preprocessed/plain/set_c.hpp +++ b/boost/boost/mpl/aux_/preprocessed/plain/set_c.hpp @@ -6,7 +6,7 @@ // http://www.boost.org/LICENSE_1_0.txt) // -// Preprocessed version of "boost/mpl/Attic/set_c.hpp" header +// Preprocessed version of "boost/mpl/set_c.hpp" header // -- DO NOT modify by hand! namespace boost { namespace mpl { diff --git a/boost/boost/mpl/aux_/preprocessed/plain/shift_left.hpp b/boost/boost/mpl/aux_/preprocessed/plain/shift_left.hpp index 7c65b639cf..cf9c837d6a 100644 --- a/boost/boost/mpl/aux_/preprocessed/plain/shift_left.hpp +++ b/boost/boost/mpl/aux_/preprocessed/plain/shift_left.hpp @@ -66,6 +66,7 @@ template< , typename BOOST_MPL_AUX_NA_PARAM(N2) > struct shift_left + : shift_left_impl< typename shift_left_tag::type , typename shift_left_tag::type diff --git a/boost/boost/mpl/aux_/preprocessed/plain/shift_right.hpp b/boost/boost/mpl/aux_/preprocessed/plain/shift_right.hpp index 0caabeb829..477229f24e 100644 --- a/boost/boost/mpl/aux_/preprocessed/plain/shift_right.hpp +++ b/boost/boost/mpl/aux_/preprocessed/plain/shift_right.hpp @@ -66,6 +66,7 @@ template< , typename BOOST_MPL_AUX_NA_PARAM(N2) > struct shift_right + : shift_right_impl< typename shift_right_tag::type , typename shift_right_tag::type diff --git a/boost/boost/mpl/aux_/value_wknd.hpp b/boost/boost/mpl/aux_/value_wknd.hpp index 77dc903d27..b94b62486b 100644 --- a/boost/boost/mpl/aux_/value_wknd.hpp +++ b/boost/boost/mpl/aux_/value_wknd.hpp @@ -11,8 +11,8 @@ // See http://www.boost.org/libs/mpl for documentation. // $Source: /cvsroot/boost/boost/boost/mpl/aux_/value_wknd.hpp,v $ -// $Date: 2004/09/28 13:56:59 $ -// $Revision: 1.13 $ +// $Date: 2004/12/20 17:51:57 $ +// $Revision: 1.14 $ #include #include @@ -69,4 +69,21 @@ template<> struct value_wknd /**/ #endif + +namespace boost { namespace mpl { namespace aux { + +template< typename T > struct value_type_wknd +{ + typedef typename T::value_type type; +}; + +#if defined(BOOST_MPL_CFG_MSVC_ETI_BUG) +template<> struct value_type_wknd +{ + typedef int type; +}; +#endif + +}}} + #endif // BOOST_MPL_AUX_VALUE_WKND_HPP_INCLUDED diff --git a/boost/boost/mpl/bind.hpp b/boost/boost/mpl/bind.hpp index 5796a2fbb1..869eb956a4 100644 --- a/boost/boost/mpl/bind.hpp +++ b/boost/boost/mpl/bind.hpp @@ -16,8 +16,8 @@ // See http://www.boost.org/libs/mpl for documentation. // $Source: /cvsroot/boost/boost/boost/mpl/bind.hpp,v $ -// $Date: 2004/10/26 14:57:26 $ -// $Revision: 1.12.2.1 $ +// $Date: 2004/10/26 14:51:04 $ +// $Revision: 1.13 $ #if !defined(BOOST_MPL_PREPROCESSING_MODE) # include diff --git a/boost/boost/mpl/eval_if.hpp b/boost/boost/mpl/eval_if.hpp index b5dd519b59..a15ac72f9d 100755 --- a/boost/boost/mpl/eval_if.hpp +++ b/boost/boost/mpl/eval_if.hpp @@ -11,8 +11,8 @@ // See http://www.boost.org/libs/mpl for documentation. // $Source: /cvsroot/boost/boost/boost/mpl/eval_if.hpp,v $ -// $Date: 2004/11/15 13:12:51 $ -// $Revision: 1.2.2.1 $ +// $Date: 2004/11/28 01:54:10 $ +// $Revision: 1.3 $ #include #include diff --git a/boost/boost/mpl/has_xxx.hpp b/boost/boost/mpl/has_xxx.hpp index 4b5360adb3..9203f33d98 100644 --- a/boost/boost/mpl/has_xxx.hpp +++ b/boost/boost/mpl/has_xxx.hpp @@ -12,8 +12,8 @@ // See http://www.boost.org/libs/mpl for documentation. // $Source: /cvsroot/boost/boost/boost/mpl/has_xxx.hpp,v $ -// $Date: 2004/09/03 15:56:55 $ -// $Revision: 1.3 $ +// $Date: 2005/06/15 10:43:23 $ +// $Revision: 1.4 $ #include #include @@ -148,25 +148,36 @@ template<> struct trait \ // MSVC 7.1+ +// agurt, 15/jun/05: replace overload-based SFINAE implementation with SFINAE +// applied to partial specialization to fix some apparently random failures +// (thanks to Daniel Wallin for researching this!) + +namespace boost { namespace mpl { namespace aux { +template< typename T > struct msvc71_sfinae_helper { typedef void type; }; +}}} + # define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name, default_) \ -template< typename T > struct BOOST_PP_CAT(trait,_wrapper_); \ -template< typename T > \ -boost::mpl::aux::yes_tag BOOST_PP_CAT(trait,_helper_)( \ - BOOST_PP_CAT(trait,_wrapper_) const volatile* \ - , BOOST_PP_CAT(trait,_wrapper_)* = 0 \ - ); \ +template< typename T, typename U = void > \ +struct BOOST_PP_CAT(trait,_impl_) \ +{ \ + BOOST_STATIC_CONSTANT(bool, value = false); \ + typedef boost::mpl::bool_ type; \ +}; \ \ -boost::mpl::aux::no_tag BOOST_PP_CAT(trait,_helper_)(...); \ +template< typename T > \ +struct BOOST_PP_CAT(trait,_impl_)< \ + T \ + , typename boost::mpl::aux::msvc71_sfinae_helper< typename T::name >::type \ + > \ +{ \ + BOOST_STATIC_CONSTANT(bool, value = true); \ + typedef boost::mpl::bool_ type; \ +}; \ \ template< typename T, typename fallback_ = boost::mpl::bool_ > \ struct trait \ + : BOOST_PP_CAT(trait,_impl_) \ { \ - typedef BOOST_PP_CAT(trait,_wrapper_) t_; \ - BOOST_STATIC_CONSTANT(bool, value = \ - sizeof((BOOST_PP_CAT(trait,_helper_))(static_cast(0))) \ - == sizeof(boost::mpl::aux::yes_tag) \ - ); \ - typedef boost::mpl::bool_ type; \ }; \ /**/ diff --git a/boost/boost/mpl/integral_c.hpp b/boost/boost/mpl/integral_c.hpp index e125c98c90..f32b1fe38f 100644 --- a/boost/boost/mpl/integral_c.hpp +++ b/boost/boost/mpl/integral_c.hpp @@ -11,8 +11,8 @@ // See http://www.boost.org/libs/mpl for documentation. // $Source: /cvsroot/boost/boost/boost/mpl/integral_c.hpp,v $ -// $Date: 2004/09/07 08:51:31 $ -// $Revision: 1.21 $ +// $Date: 2005/07/19 04:03:12 $ +// $Revision: 1.22 $ #include #include @@ -40,7 +40,9 @@ template< bool C > struct integral_c { BOOST_STATIC_CONSTANT(bool, value = C); + typedef integral_c_tag tag; typedef integral_c type; + typedef bool value_type; operator bool() const { return this->value; } }; BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE_CLOSE diff --git a/boost/boost/mpl/integral_c_fwd.hpp b/boost/boost/mpl/integral_c_fwd.hpp new file mode 100644 index 0000000000..7f4237cfad --- /dev/null +++ b/boost/boost/mpl/integral_c_fwd.hpp @@ -0,0 +1,32 @@ + +#ifndef BOOST_MPL_INTEGRAL_C_FWD_HPP_INCLUDED +#define BOOST_MPL_INTEGRAL_C_FWD_HPP_INCLUDED + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Source: /cvsroot/boost/boost/boost/mpl/integral_c_fwd.hpp,v $ +// $Date: 2004/09/28 13:56:58 $ +// $Revision: 1.4 $ + +#include +#include + +BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE_OPEN + +#if BOOST_WORKAROUND(__HP_aCC, BOOST_TESTED_AT(53800)) +// the type of non-type template arguments may not depend on template arguments +template< typename T, long N > struct integral_c; +#else +template< typename T, T N > struct integral_c; +#endif + +BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE_CLOSE +BOOST_MPL_AUX_ADL_BARRIER_DECL(integral_c) + +#endif // BOOST_MPL_INTEGRAL_C_FWD_HPP_INCLUDED diff --git a/boost/boost/multi_array.hpp b/boost/boost/multi_array.hpp index ce1b6288e5..1fa737a1d2 100644 --- a/boost/boost/multi_array.hpp +++ b/boost/boost/multi_array.hpp @@ -207,7 +207,7 @@ public: multi_array(const multi_array& rhs) : super_type(rhs), allocator_(rhs.allocator_) { allocate_space(); - boost::copy_n(rhs.base_,rhs.num_elements(),base_); + boost::detail::multi_array::copy_n(rhs.base_,rhs.num_elements(),base_); } diff --git a/boost/boost/multi_array/algorithm.hpp b/boost/boost/multi_array/algorithm.hpp index c8237d4452..c749c3f974 100644 --- a/boost/boost/multi_array/algorithm.hpp +++ b/boost/boost/multi_array/algorithm.hpp @@ -43,7 +43,8 @@ #include "boost/iterator.hpp" namespace boost { - +namespace detail { +namespace multi_array { //-------------------------------------------------- // copy_n (not part of the C++ standard) #if 1 @@ -95,7 +96,8 @@ copy_n(InputIter first, Size count, OutputIter result) { } #endif // 1 - +} // namespace multi_array +} // namespace detail } // namespace boost #endif // BOOST_ALGORITHM_RG071801_HPP diff --git a/boost/boost/multi_array/iterator.hpp b/boost/boost/multi_array/iterator.hpp index 6fd836c9d0..756bb8645c 100644 --- a/boost/boost/multi_array/iterator.hpp +++ b/boost/boost/multi_array/iterator.hpp @@ -98,7 +98,7 @@ public: array_iterator() {} - array_iterator(int idx, TPtr base, const size_type* extents, + array_iterator(index idx, TPtr base, const size_type* extents, const index* strides, const index* index_base) : idx_(idx), base_(base), extents_(extents), diff --git a/boost/boost/multi_array/multi_array_ref.hpp b/boost/boost/multi_array/multi_array_ref.hpp index c8bbc568bd..08cf8668b8 100644 --- a/boost/boost/multi_array/multi_array_ref.hpp +++ b/boost/boost/multi_array/multi_array_ref.hpp @@ -140,7 +140,8 @@ public: void reindex(const BaseList& values) { boost::function_requires< detail::multi_array::CollectionConcept >(); - boost::copy_n(values.begin(),num_dimensions(),index_base_list_.begin()); + boost::detail::multi_array:: + copy_n(values.begin(),num_dimensions(),index_base_list_.begin()); origin_offset_ = this->calculate_origin_offset(stride_list_,extent_list_, storage_,index_base_list_); @@ -242,7 +243,7 @@ public: } const_iterator end() const { - return const_iterator(*index_bases()+*shape(),origin(), + return const_iterator(*index_bases()+(index)*shape(),origin(), shape(),strides(),index_bases()); } @@ -327,7 +328,8 @@ public: // If index_bases or extents is null, then initialize the corresponding // private data to zeroed lists. if(index_bases) { - boost::copy_n(index_bases,NumDims,index_base_list_.begin()); + boost::detail::multi_array:: + copy_n(index_bases,NumDims,index_base_list_.begin()); } else { std::fill_n(index_base_list_.begin(),NumDims,0); } @@ -385,11 +387,12 @@ public: void init_multi_array_ref(InputIterator extents_iter) { boost::function_requires >(); - boost::copy_n(extents_iter,num_dimensions(),extent_list_.begin()); + boost::detail::multi_array:: + copy_n(extents_iter,num_dimensions(),extent_list_.begin()); // Calculate the array size num_elements_ = std::accumulate(extent_list_.begin(),extent_list_.end(), - 1,std::multiplies()); + size_type(1),std::multiplies()); this->compute_strides(stride_list_,extent_list_,storage_); @@ -542,7 +545,7 @@ public: } iterator end() { - return iterator(*this->index_bases()+*this->shape(),origin(), + return iterator(*this->index_bases()+(index)*this->shape(),origin(), this->shape(),this->strides(), this->index_bases()); } diff --git a/boost/boost/multi_array/storage_order.hpp b/boost/boost/multi_array/storage_order.hpp index d63fa3cf7f..3eb71360c1 100644 --- a/boost/boost/multi_array/storage_order.hpp +++ b/boost/boost/multi_array/storage_order.hpp @@ -36,8 +36,8 @@ namespace boost { template general_storage_order(OrderingIter ordering, AscendingIter ascending) { - boost::copy_n(ordering,NumDims,ordering_.begin()); - boost::copy_n(ascending,NumDims,ascending_.begin()); + boost::detail::multi_array::copy_n(ordering,NumDims,ordering_.begin()); + boost::detail::multi_array::copy_n(ascending,NumDims,ascending_.begin()); } // RG - ideally these would not be necessary, but some compilers diff --git a/boost/boost/multi_array/subarray.hpp b/boost/boost/multi_array/subarray.hpp index bc5f6ff5f9..3784f48e3f 100644 --- a/boost/boost/multi_array/subarray.hpp +++ b/boost/boost/multi_array/subarray.hpp @@ -142,7 +142,7 @@ public: } const_iterator end() const { - return const_iterator(*index_bases()+*shape(),origin(), + return const_iterator(*index_bases()+(index)*shape(),origin(), shape(),strides(),index_bases()); } @@ -295,7 +295,7 @@ public: } iterator end() { - return iterator(*this->index_bases()+*this->shape(),origin(), + return iterator(*this->index_bases()+(index)*this->shape(),origin(), this->shape(),this->strides(),this->index_bases()); } diff --git a/boost/boost/multi_array/view.hpp b/boost/boost/multi_array/view.hpp index 5211484f0e..1744cb3b28 100644 --- a/boost/boost/multi_array/view.hpp +++ b/boost/boost/multi_array/view.hpp @@ -73,7 +73,8 @@ public: template void reindex(const BaseList& values) { - boost::copy_n(values.begin(),num_dimensions(),index_base_list_.begin()); + boost::detail::multi_array:: + copy_n(values.begin(),num_dimensions(),index_base_list_.begin()); origin_offset_ = this->calculate_indexing_offset(stride_list_,index_base_list_); } @@ -146,7 +147,7 @@ public: } const_iterator end() const { - return const_iterator(*index_bases()+*shape(),origin(), + return const_iterator(*index_bases()+(index)*shape(),origin(), shape(),strides(),index_bases()); } @@ -225,8 +226,10 @@ public: // should be protected index_base_list_.assign(0); // Get the extents and strides - boost::copy_n(extents.begin(),NumDims,extent_list_.begin()); - boost::copy_n(strides.begin(),NumDims,stride_list_.begin()); + boost::detail::multi_array:: + copy_n(extents.begin(),NumDims,extent_list_.begin()); + boost::detail::multi_array:: + copy_n(strides.begin(),NumDims,stride_list_.begin()); // Calculate the array size num_elements_ = std::accumulate(extent_list_.begin(),extent_list_.end(), @@ -356,7 +359,7 @@ public: } iterator end() { - return iterator(*this->index_bases()+*this->shape(),origin(), + return iterator(*this->index_bases()+(index)*this->shape(),origin(), this->shape(),this->strides(), this->index_bases()); } diff --git a/boost/boost/none_t.hpp b/boost/boost/none_t.hpp new file mode 100644 index 0000000000..4b97e20992 --- /dev/null +++ b/boost/boost/none_t.hpp @@ -0,0 +1,24 @@ +// Copyright (C) 2003, Fernando Luis Cacciola Carballal. +// +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/lib/optional for documentation. +// +// You are welcome to contact the author at: +// fernando_cacciola@hotmail.com +// +#ifndef BOOST_NONE_T_17SEP2003_HPP +#define BOOST_NONE_T_17SEP2003_HPP + +namespace boost { + +namespace detail { struct none_helper{}; } + +typedef int detail::none_helper::*none_t ; + +} // namespace boost + +#endif + diff --git a/boost/boost/operators.hpp b/boost/boost/operators.hpp index 8b5457dd23..fbba602384 100644 --- a/boost/boost/operators.hpp +++ b/boost/boost/operators.hpp @@ -674,7 +674,7 @@ struct random_access_iteratable // Here's where we put it all together, defining the xxxx forms of the templates // in namespace boost. We also define specializations of is_chained_base<> for // the xxxx, xxxx1, and xxxx2 templates, importing them into boost:: as -// neccessary. +// necessary. // #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION @@ -699,7 +699,7 @@ template struct is_chained_base { } // namespace boost -// Import a 4-type-argument operator template into boost (if neccessary) and +// Import a 4-type-argument operator template into boost (if necessary) and // provide a specialization of 'is_chained_base<>' for it. # define BOOST_OPERATOR_TEMPLATE4(template_name4) \ BOOST_IMPORT_TEMPLATE4(template_name4) \ @@ -708,7 +708,7 @@ template struct is_chained_base { typedef ::boost::detail::true_t value; \ }; -// Import a 3-type-argument operator template into boost (if neccessary) and +// Import a 3-type-argument operator template into boost (if necessary) and // provide a specialization of 'is_chained_base<>' for it. # define BOOST_OPERATOR_TEMPLATE3(template_name3) \ BOOST_IMPORT_TEMPLATE3(template_name3) \ @@ -717,7 +717,7 @@ template struct is_chained_base { typedef ::boost::detail::true_t value; \ }; -// Import a 2-type-argument operator template into boost (if neccessary) and +// Import a 2-type-argument operator template into boost (if necessary) and // provide a specialization of 'is_chained_base<>' for it. # define BOOST_OPERATOR_TEMPLATE2(template_name2) \ BOOST_IMPORT_TEMPLATE2(template_name2) \ @@ -726,7 +726,7 @@ template struct is_chained_base { typedef ::boost::detail::true_t value; \ }; -// Import a 1-type-argument operator template into boost (if neccessary) and +// Import a 1-type-argument operator template into boost (if necessary) and // provide a specialization of 'is_chained_base<>' for it. # define BOOST_OPERATOR_TEMPLATE1(template_name1) \ BOOST_IMPORT_TEMPLATE1(template_name1) \ diff --git a/boost/boost/optional/optional.hpp b/boost/boost/optional/optional.hpp index 7379d8045b..8ef2e31f5d 100644 --- a/boost/boost/optional/optional.hpp +++ b/boost/boost/optional/optional.hpp @@ -26,9 +26,11 @@ #include "boost/mpl/bool.hpp" #include "boost/mpl/not.hpp" #include "boost/detail/reference_content.hpp" -#include "boost/detail/none_t.hpp" +#include "boost/none_t.hpp" #include "boost/utility/compare_pointees.hpp" +#include "boost/optional/optional_fwd.hpp" + #if BOOST_WORKAROUND(BOOST_MSVC, == 1200) // VC6.0 has the following bug: // When a templated assignment operator exist, an implicit conversion @@ -167,7 +169,7 @@ class optional_base : public optional_tag // Creates an optional uninitialized. // No-throw - optional_base ( detail::none_t const& ) + optional_base ( none_t const& ) : m_initialized(false) {} @@ -208,32 +210,57 @@ class optional_base : public optional_tag ~optional_base() { destroy() ; } // Assigns from another optional (deep-copies the rhs value) - // Basic Guarantee: If T::T( T const& ) throws, this is left UNINITIALIZED void assign ( optional_base const& rhs ) + { + if (is_initialized()) + { + if ( rhs.is_initialized() ) + assign_value(rhs.get_impl(), is_reference_predicate() ); + else destroy(); + } + else { - destroy(); if ( rhs.is_initialized() ) construct(rhs.get_impl()); } + } + + // Assigns from another _convertible_ optional (deep-copies the rhs value) + template + void assign ( optional const& rhs ) + { + if (is_initialized()) + { + if ( rhs.is_initialized() ) + assign_value(static_cast(rhs.get()), is_reference_predicate() ); + else destroy(); + } + else + { + if ( rhs.is_initialized() ) + construct(static_cast(rhs.get())); + } + } // Assigns from a T (deep-copies the rhs value) - // Basic Guarantee: If T::( T const& ) throws, this is left UNINITIALIZED void assign ( argument_type val ) - { - destroy(); - construct(val); - } + { + if (is_initialized()) + assign_value(val, is_reference_predicate() ); + else construct(val); + } // Assigns from "none", destroying the current value, if any, leaving this UNINITIALIZED // No-throw (assuming T::~T() doesn't) - void assign ( detail::none_t const& ) { destroy(); } + void assign ( none_t const& ) { destroy(); } #ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT template void assign_expr ( Expr const& expr, Expr const* tag ) { - destroy(); - construct(expr,tag); + if (is_initialized()) + assign_expr_to_initialized(expr,tag); + else construct(expr,tag); } #endif @@ -244,7 +271,6 @@ class optional_base : public optional_tag void reset() { destroy(); } // Replaces the current value -if any- with 'val' - // Basic Guarantee: If T::T( T const& ) throws this is left UNINITIALIZED. void reset ( argument_type val ) { assign(val); } // Returns a pointer to the value if this is initialized, otherwise, @@ -281,6 +307,21 @@ class optional_base : public optional_tag factory.apply(m_storage.address()) ; m_initialized = true ; } + + template + void assign_expr_to_initialized ( Expr const& factory, in_place_factory_base const* tag ) + { + destroy(); + construct(factory,tag); + } + + // Constructs in-place using the given typed factory + template + void assign_expr_to_initialized ( Expr const& factory, typed_in_place_factory_base const* tag ) + { + destroy(); + construct(factory,tag); + } #endif // Constructs using any expression implicitely convertible to the single argument @@ -294,6 +335,16 @@ class optional_base : public optional_tag m_initialized = true ; } + // Assigns using a form any expression implicitely convertible to the single argument + // of a T's assignment operator. + // Converting assignments of optional from optional uses this function with + // 'Expr' being of type 'U' and relying on a converting assignment of T from U. + template + void assign_expr_to_initialized ( Expr const& expr, void const* ) + { + assign_value(expr, is_reference_predicate()); + } + #ifdef BOOST_OPTIONAL_WEAK_OVERLOAD_RESOLUTION // BCB5.64 (and probably lower versions) workaround. // The in-place factories are supported by means of catch-all constructors @@ -321,11 +372,14 @@ class optional_base : public optional_tag } #endif + void assign_value ( argument_type val, is_not_reference_tag ) { get_impl() = val; } + void assign_value ( argument_type val, is_reference_tag ) { construct(val); } + void destroy() - { - if ( m_initialized ) - destroy_impl(is_reference_predicate()) ; - } + { + if ( m_initialized ) + destroy_impl(is_reference_predicate()) ; + } unspecified_bool_type safe_bool() const { return m_initialized ? &this_type::is_initialized : 0 ; } @@ -391,7 +445,7 @@ class optional : public optional_detail::optional_base // Creates an optional uninitialized. // No-throw - optional( detail::none_t const& none_ ) : base(none_) {} + optional( none_t const& none_ ) : base(none_) {} // Creates an optional initialized with 'val'. // Can throw if T::T(T const&) does @@ -446,6 +500,7 @@ class optional : public optional_detail::optional_base } #endif + #ifndef BOOST_OPTIONAL_NO_CONVERTING_ASSIGNMENT // Assigns from another convertible optional (converts && deep-copies the rhs value) // Requires a valid conversion from U to T. @@ -453,14 +508,7 @@ class optional : public optional_detail::optional_base template optional& operator= ( optional const& rhs ) { - this->destroy(); // no-throw - - if ( rhs.is_initialized() ) - { - // An exception can be thrown here. - // It it happens, THIS will be left uninitialized. - this->assign(rhs.get()); - } + this->assign(rhs); return *this ; } #endif @@ -485,7 +533,7 @@ class optional : public optional_detail::optional_base // Assigns from a "none" // Which destroys the current value, if any, leaving this UNINITIALIZED // No-throw (assuming T::~T() doesn't) - optional& operator= ( detail::none_t const& none_ ) + optional& operator= ( none_t const& none_ ) { this->assign( none_ ) ; return *this ; @@ -607,62 +655,62 @@ bool operator >= ( optional const& x, optional const& y ) template inline -bool operator == ( optional const& x, detail::none_t const& ) +bool operator == ( optional const& x, none_t const& ) { return equal_pointees(x, optional() ); } template inline -bool operator < ( optional const& x, detail::none_t const& ) +bool operator < ( optional const& x, none_t const& ) { return less_pointees(x,optional() ); } template inline -bool operator != ( optional const& x, detail::none_t const& y ) +bool operator != ( optional const& x, none_t const& y ) { return !( x == y ) ; } template inline -bool operator > ( optional const& x, detail::none_t const& y ) +bool operator > ( optional const& x, none_t const& y ) { return y < x ; } template inline -bool operator <= ( optional const& x, detail::none_t const& y ) +bool operator <= ( optional const& x, none_t const& y ) { return !( y < x ) ; } template inline -bool operator >= ( optional const& x, detail::none_t const& y ) +bool operator >= ( optional const& x, none_t const& y ) { return !( x < y ) ; } template inline -bool operator == ( detail::none_t const& x, optional const& y ) +bool operator == ( none_t const& x, optional const& y ) { return equal_pointees(optional() ,y); } template inline -bool operator < ( detail::none_t const& x, optional const& y ) +bool operator < ( none_t const& x, optional const& y ) { return less_pointees(optional() ,y); } template inline -bool operator != ( detail::none_t const& x, optional const& y ) +bool operator != ( none_t const& x, optional const& y ) { return !( x == y ) ; } template inline -bool operator > ( detail::none_t const& x, optional const& y ) +bool operator > ( none_t const& x, optional const& y ) { return y < x ; } template inline -bool operator <= ( detail::none_t const& x, optional const& y ) +bool operator <= ( none_t const& x, optional const& y ) { return !( y < x ) ; } template inline -bool operator >= ( detail::none_t const& x, optional const& y ) +bool operator >= ( none_t const& x, optional const& y ) { return !( x < y ) ; } // @@ -679,8 +727,9 @@ namespace optional_detail { #endif // optional's swap: -// If both are initialized, calls swap(T&, T&), with whatever exception guarantess are given there. -// If only one is initialized, calls I.reset() and U.reset(*I), with the Basic Guarantee +// If both are initialized, calls swap(T&, T&). If this swap throws, both will remain initialized but their values are now unspecified. +// If only one is initialized, calls U.reset(*I), THEN I.reset(). +// If U.reset(*I) throws, both are left UNCHANGED (U is kept uinitialized and I is never reset) // If both are uninitialized, do nothing (no-throw) template inline @@ -688,12 +737,12 @@ void optional_swap ( optional& x, optional& y ) { if ( !x && !!y ) { - x.reset(*y); // Basic guarantee. + x.reset(*y); y.reset(); } else if ( !!x && !y ) { - y.reset(*x); // Basic guarantee. + y.reset(*x); x.reset(); } else if ( !!x && !!y ) @@ -714,6 +763,11 @@ template inline void swap ( optional& x, optional& y ) optional_detail::optional_swap(x,y); } +template inline optional make_optional ( T const& v ) +{ + return optional(v); +} + } // namespace boost #endif diff --git a/boost/boost/pending/ct_if.hpp b/boost/boost/pending/ct_if.hpp index 29fdbc485d..2f8540d893 100644 --- a/boost/boost/pending/ct_if.hpp +++ b/boost/boost/pending/ct_if.hpp @@ -19,13 +19,12 @@ problem. */ +#include // true_type and false_type + namespace boost { struct ct_if_error { }; - struct true_type { enum { value = true }; }; - struct false_type { enum { value = false }; }; - template struct ct_and { typedef false_type type; }; template <> struct ct_and { typedef true_type type; }; diff --git a/boost/boost/pointee.hpp b/boost/boost/pointee.hpp index bb6d1f7ba9..9794b8e7db 100755 --- a/boost/boost/pointee.hpp +++ b/boost/boost/pointee.hpp @@ -1,11 +1,17 @@ -// Copyright David Abrahams 2004. Use, modification and distribution is -// subject to the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef POINTEE_DWA200415_HPP # define POINTEE_DWA200415_HPP -// dereferenceable_traits provides access to the value_type and -// reference of a Dereferenceable type. +// +// Copyright David Abrahams 2004. Use, modification and distribution is +// subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// typename pointee

::type provides the pointee type of P. +// +// For example, it is T for T* and X for shared_ptr. +// +// http://www.boost.org/libs/iterator/doc/pointee.html +// # include # include diff --git a/boost/boost/preprocessor/stringize.hpp b/boost/boost/preprocessor/stringize.hpp index 3144fa90d4..01f283e852 100644 --- a/boost/boost/preprocessor/stringize.hpp +++ b/boost/boost/preprocessor/stringize.hpp @@ -18,11 +18,15 @@ # # /* BOOST_PP_STRINGIZE */ # -# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() -# define BOOST_PP_STRINGIZE(text) BOOST_PP_STRINGIZE_I(text) -# else +# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() +# define BOOST_PP_STRINGIZE(text) BOOST_PP_STRINGIZE_A((text)) +# define BOOST_PP_STRINGIZE_A(arg) BOOST_PP_STRINGIZE_B ## (arg) +# define BOOST_PP_STRINGIZE_B(arg) BOOST_PP_STRINGIZE_I ## arg +# elif BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() # define BOOST_PP_STRINGIZE(text) BOOST_PP_STRINGIZE_OO((text)) # define BOOST_PP_STRINGIZE_OO(par) BOOST_PP_STRINGIZE_I ## par +# else +# define BOOST_PP_STRINGIZE(text) BOOST_PP_STRINGIZE_I(text) # endif # # define BOOST_PP_STRINGIZE_I(text) #text diff --git a/boost/boost/property_map.hpp b/boost/boost/property_map.hpp index 2eab6d3503..9077ea37cd 100644 --- a/boost/boost/property_map.hpp +++ b/boost/boost/property_map.hpp @@ -397,9 +397,9 @@ namespace boost { inline safe_iterator_property_map( RandomAccessIterator first, - std::size_t n = 0, + std::size_t n_ = 0, const IndexMap& _id = IndexMap() ) - : iter(first), n(n), index(_id) { } + : iter(first), n(n_), index(_id) { } inline safe_iterator_property_map() { } inline R operator[](key_type v) const { assert(get(index, v) < n); diff --git a/boost/boost/rational.hpp b/boost/boost/rational.hpp index 0fa74a86f0..1d969abeda 100644 --- a/boost/boost/rational.hpp +++ b/boost/boost/rational.hpp @@ -128,10 +128,9 @@ class rational : decrementable < rational > > > > > > > > > > > > > > > > { - typedef IntType int_type; typedef typename boost::call_traits::param_type param_type; - public: + typedef IntType int_type; rational() : num(0), den(1) {} rational(param_type n) : num(n), den(1) {} rational(param_type n, param_type d) : num(n), den(d) { normalize(); } diff --git a/boost/boost/regex.hpp b/boost/boost/regex.hpp index 42bf95ea51..6dc3dfbd42 100644 --- a/boost/boost/regex.hpp +++ b/boost/boost/regex.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -13,7 +13,7 @@ * LOCATION: see http://www.boost.org/libs/regex for documentation. * FILE regex.cpp * VERSION see - * DESCRIPTION: Declares boost::reg_expression<> and associated + * DESCRIPTION: Declares boost::basic_regex<> and associated * functions and classes. This header is the main * entry point for the template regex code. */ @@ -28,11 +28,7 @@ #include #endif -#ifdef BOOST_REGEX_V3 -#include -#else #include -#endif #endif // include diff --git a/boost/boost/regex/config.hpp b/boost/boost/regex/config.hpp index b7e4cd6845..3b78bddaa3 100644 --- a/boost/boost/regex/config.hpp +++ b/boost/boost/regex/config.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -19,9 +19,9 @@ #ifndef BOOST_REGEX_CONFIG_HPP #define BOOST_REGEX_CONFIG_HPP /* - Borland C++ Fix/error check - this has to go *before* we include any std lib headers: -*/ + * Borland C++ Fix/error check + * this has to go *before* we include any std lib headers: + */ #if defined(__BORLANDC__) # include #endif @@ -40,31 +40,14 @@ # include BOOST_REGEX_USER_CONFIG -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include # include -# include -# include -# include -# include -# include -# ifndef BOOST_NO_STD_LOCALE -# include -# endif + #else /* - * C build, - * don't include because that may - * do C++ specific things in future... - */ + * C build, + * don't include because that may + * do C++ specific things in future... + */ # include # include # ifdef _MSC_VER @@ -87,9 +70,27 @@ #endif /* -* If there isn't good enough wide character support then there will -* be no wide character regular expressions: -*/ + * Fix for gcc prior to 3.4: std::ctype doesn't allow + * masks to be combined, for example: + * std::use_facet >.is(std::ctype_base::lower|std::ctype_base::upper, L'a'); + * returns *false*. + */ +#ifdef __GLIBCPP__ +# define BOOST_REGEX_BUGGY_CTYPE_FACET +#endif + +/* + * Intel C++ before 8.0 ends up with unresolved externals unless we turn off + * extern template support: + */ +#if defined(BOOST_INTEL) && defined(__cplusplus) && (BOOST_INTEL <= 800) +# define BOOST_REGEX_NO_EXTERNAL_TEMPLATES +#endif + +/* + * If there isn't good enough wide character support then there will + * be no wide character regular expressions: + */ #if (defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_CWCTYPE) || defined(BOOST_NO_STD_WSTRING)) # if !defined(BOOST_NO_WREGEX) # define BOOST_NO_WREGEX @@ -97,8 +98,8 @@ #else # if defined(__sgi) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) /* STLPort on IRIX is misconfigured: does not compile - * as a temporary fix include instead and prevent inclusion - * of STLPort version of */ + * as a temporary fix include instead and prevent inclusion + * of STLPort version of */ # include # define __STLPORT_CWCTYPE # define _STLP_CWCTYPE @@ -111,77 +112,27 @@ #endif /* -* If Win32 support has been disabled for boost in general, then -* it is for regex in particular: -*/ + * If Win32 support has been disabled for boost in general, then + * it is for regex in particular: + */ #if defined(BOOST_DISABLE_WIN32) && !defined(BOOST_REGEX_NO_W32) # define BOOST_REGEX_NO_W32 #endif -/* some versions of gcc can't merge template instances: */ -#if defined(__CYGWIN__) -# define BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE -#endif - -/* fix problems with bool as a macro, -* this probably doesn't affect any current compilers: */ -#if defined(bool) || defined(true) || defined(false) -# define BOOST_REGEX_NO_BOOL -#endif - -/* We don't make our templates external if the compiler - can't handle it: */ -#if (defined(BOOST_NO_MEMBER_FUNCTION_SPECIALIZATIONS) || defined(__HP_aCC) || defined(__MWERKS__) || defined(__COMO__) || defined(BOOST_INTEL))\ - && !defined(BOOST_MSVC) && !defined(__BORLANDC__) -# define BOOST_REGEX_NO_EXTERNAL_TEMPLATES -#endif - /* disable our own file-iterators and mapfiles if we can't - support them: */ + * support them: */ #if !defined(BOOST_HAS_DIRENT_H) && !(defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)) # define BOOST_REGEX_NO_FILEITER #endif -#ifdef __cplusplus -#ifndef MB_CUR_MAX -// yuk! -// better make a conservative guess! -#define MB_CUR_MAX 10 -#endif - -namespace boost{ namespace re_detail{ -#ifdef BOOST_NO_STD_DISTANCE -template -std::ptrdiff_t distance(const T& x, const T& y) -{ return y - x; } -#else -using std::distance; -#endif -}} - - -#ifdef BOOST_REGEX_NO_BOOL -# define BOOST_REGEX_MAKE_BOOL(x) static_cast((x) ? true : false) -#else -# ifdef BOOST_MSVC - // warning suppression with VC6: -# pragma warning(disable: 4800) -# endif -# define BOOST_REGEX_MAKE_BOOL(x) static_cast(x) -#endif -#endif /* __cplusplus */ - /* backwards compatibitity: */ #if defined(BOOST_RE_NO_LIB) # define BOOST_REGEX_NO_LIB #endif #if defined(__GNUC__) && (defined(_WIN32) || defined(__CYGWIN__)) -// gcc on win32 has problems merging switch statements in templates: -# define BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE -// gcc on win32 has problems if you include -// (sporadically generates bad code). -# define BOOST_REGEX_USE_C_LOCALE +/* gcc on win32 has problems if you include + (sporadically generates bad code). */ # define BOOST_REGEX_NO_W32 #endif #if defined(__COMO__) && !defined(BOOST_REGEX_NO_W32) && !defined(_MSC_EXTENSIONS) @@ -194,13 +145,26 @@ using std::distance; * ****************************************************************************/ -#ifdef __cplusplus -#if defined(BOOST_MSVC) && (BOOST_MSVC >= 1300) && !defined(BOOST_REGEX_V3) && !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) -# define BOOST_REGEX_HAS_SHORT_WCHAR_T -namespace boost{ typedef __wchar_t regex_wchar_type; } -#else -namespace boost{ typedef wchar_t regex_wchar_type; } -#endif +/* + * define BOOST_REGEX_HAS_OTHER_WCHAR_T when wchar_t is a native type, but the users + * code may be built with wchar_t as unsigned short: basically when we're building + * 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. + */ +#if defined(__cplusplus) && (defined(BOOST_MSVC) || defined(__ICL)) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) && defined(BOOST_WINDOWS) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) +# define BOOST_REGEX_HAS_OTHER_WCHAR_T +# ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4251 4231 4660) +# endif +# ifdef _DLL +# include + extern template class __declspec(dllimport) std::basic_string; +# endif +# ifdef BOOST_MSVC +# pragma warning(pop) +# endif #endif @@ -228,9 +192,9 @@ namespace boost{ typedef wchar_t regex_wchar_type; } # if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK) # define BOOST_DYN_LINK # endif -#ifdef BOOST_REGEX_DIAG -# define BOOST_LIB_DIAGNOSTIC -#endif +# ifdef BOOST_REGEX_DIAG +# define BOOST_LIB_DIAGNOSTIC +# endif # include #endif @@ -280,25 +244,15 @@ namespace boost{ typedef wchar_t regex_wchar_type; } #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) # define BOOST_REGEX_USE_WIN32_LOCALE #endif -/* otherwise use C locale: */ +/* otherwise use C++ locale if supported: */ +#if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) && !defined(BOOST_NO_STD_LOCALE) +# define BOOST_REGEX_USE_CPP_LOCALE +#endif +/* otherwise use C+ locale: */ #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) # define BOOST_REGEX_USE_C_LOCALE #endif -#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) -# include -#endif - -#ifdef MAXPATH -# define BOOST_REGEX_MAX_PATH MAXPATH -#elif defined(MAX_PATH) -# define BOOST_REGEX_MAX_PATH MAX_PATH -#elif defined(FILENAME_MAX) -# define BOOST_REGEX_MAX_PATH FILENAME_MAX -#else -# define BOOST_REGEX_MAX_PATH 200 -#endif - #ifndef BOOST_REGEX_MAX_STATE_COUNT # define BOOST_REGEX_MAX_STATE_COUNT 100000000 #endif @@ -312,9 +266,13 @@ namespace boost{ typedef wchar_t regex_wchar_type; } #ifdef BOOST_NO_EXCEPTIONS /* -* If there are no exceptions then we must report critical-errors -* the only way we know how; by terminating. -*/ + * If there are no exceptions then we must report critical-errors + * the only way we know how; by terminating. + */ +#include +#include +#include + # define BOOST_REGEX_NOEH_ASSERT(x)\ if(0 == (x))\ {\ @@ -325,69 +283,12 @@ if(0 == (x))\ } #else /* -* With exceptions then error handling is taken care of and -* there is no need for these checks: -*/ + * With exceptions then error handling is taken care of and + * there is no need for these checks: + */ # define BOOST_REGEX_NOEH_ASSERT(x) #endif -/***************************************************************************** - * - * Debugging / tracing support: - * - ****************************************************************************/ - -#if defined(BOOST_REGEX_DEBUG) && defined(__cplusplus) - -# include -using std::cout; -using std::cin; -using std::cerr; -using std::endl; -using std::hex; -using std::dec; - -# ifndef jm_assert -# define jm_assert(x) assert(x) -# endif -# ifndef jm_trace -# define jm_trace(x) cerr << x << endl; -# endif -# ifndef jm_instrument -# define jm_instrument jm_trace(__FILE__<<"#"<<__LINE__) -# endif - -namespace boost{ - namespace re_detail{ -class debug_guard -{ -public: - char g1[32]; - const char* pc; - char* pnc; - const char* file; - int line; - char g2[32]; - debug_guard(const char* f, int l, const char* p1 = 0, char* p2 = 0); - ~debug_guard(); -}; - -# define BOOST_RE_GUARD_STACK boost::re_detail::debug_guard sg(__FILE__, __LINE__); -# define BOOST_RE_GUARD_GLOBAL(x) const char g1##x[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, }; char g2##x[32]; boost::debug_guard g3##x(__FILE__, __LINE__, g1##x, g2##x); - - } // namespace re_detail -} // namespace boost - -#else - -# define jm_assert(x) -# define jm_trace(x) -# define BOOST_RE_GUARD_STACK -# define BOOST_RE_GUARD_GLOBAL(x) -# ifndef jm_instrument -# define jm_instrument -# endif -#endif /***************************************************************************** * @@ -419,31 +320,6 @@ BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page(); #endif -/***************************************************************************** - * - * Error handling: - * - ****************************************************************************/ - -#if defined(__cplusplus) - -namespace boost{ -namespace re_detail{ - -BOOST_REGEX_DECL void BOOST_REGEX_CALL raise_regex_exception(const std::string& s); - -template -void raise_error(const traits& t, unsigned code) -{ - (void)t; // warning suppression - raise_regex_exception(t.error_string(code)); -} - -} -} - -#endif - /***************************************************************************** * * Algorithm selection and configuration: @@ -451,7 +327,7 @@ void raise_error(const traits& t, unsigned code) ****************************************************************************/ #if !defined(BOOST_REGEX_RECURSIVE) && !defined(BOOST_REGEX_NON_RECURSIVE) -# if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && !defined(_STLP_DEBUG) && !defined(__STL_DEBUG) +# if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && !defined(_STLP_DEBUG) && !defined(__STL_DEBUG) && !(defined(BOOST_MSVC) && (BOOST_MSVC >= 1400)) # define BOOST_REGEX_RECURSIVE # else # define BOOST_REGEX_NON_RECURSIVE @@ -480,93 +356,6 @@ void raise_error(const traits& t, unsigned code) #endif -/***************************************************************************** - * - * Fix broken compilers that wrongly #define some symbols: - * - ****************************************************************************/ - -#ifdef __cplusplus - -// the following may be defined as macros; this is -// incompatable with std::something syntax, we have -// no choice but to undef them? - -#ifdef sprintf -#undef sprintf -#endif -#ifdef swprintf -#undef swprintf -#endif -#endif - -/***************************************************************************** - * - * Fix broken broken namespace support: - * - ****************************************************************************/ - -#if defined(BOOST_NO_STDC_NAMESPACE) && defined(__cplusplus) - -namespace std{ - using ::ptrdiff_t; - using ::size_t; - using ::sprintf; - using ::abs; - using ::setlocale; -# ifndef BOOST_NO_WREGEX -# ifndef BOOST_NO_SWPRINTF - using ::swprintf; -# endif - using ::wcstombs; - using ::mbstowcs; -# if !defined(BOOST_NO_STD_LOCALE) && !defined (__STL_NO_NATIVE_MBSTATE_T) && !defined(_STLP_NO_NATIVE_MBSTATE_T) - using ::mbstate_t; -# endif -# endif /* BOOST_NO_WREGEX */ - using ::fseek; - using ::fread; - using ::ftell; - using ::fopen; - using ::fclose; - using ::FILE; -#ifdef BOOST_NO_EXCEPTIONS - using ::fprintf; - using ::abort; -#endif -} - -#endif - -/***************************************************************************** - * - * helper functions pointer_construct/pointer_destroy: - * - ****************************************************************************/ - -#ifdef __cplusplus -namespace boost{ namespace re_detail{ - -#ifdef BOOST_MSVC -#pragma warning (push) -#pragma warning (disable : 4100) -#endif - -template -inline void pointer_destroy(T* p) -{ p->~T(); (void)p; } - -#ifdef BOOST_MSVC -#pragma warning (pop) -#endif - -template -inline void pointer_construct(T* p, const T& t) -{ new (p) T(t); } - -}} // namespaces -#endif - /***************************************************************************** * * helper memory allocation functions: @@ -579,7 +368,7 @@ namespace boost{ namespace re_detail{ BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block(); BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void*); -}} // namespaces +}} /* namespaces */ #endif /***************************************************************************** @@ -593,9 +382,9 @@ BOOST_REGEX_DECL void BOOST_REGEX_CALL print_regex_library_info(); #endif #if defined(BOOST_REGEX_DIAG) -# pragma message ("BOOST_REGEX_DECL set as: " BOOST_STRINGIZE(BOOST_REGEX_DECL)) -# pragma message ("BOOST_REGEX_CALL set as: " BOOST_STRINGIZE(BOOST_REGEX_CALL)) -# pragma message ("BOOST_REGEX_CCALL set as: " BOOST_STRINGIZE(BOOST_REGEX_CCALL)) +# pragma message ("BOOST_REGEX_DECL" BOOST_STRINGIZE(=BOOST_REGEX_DECL)) +# pragma message ("BOOST_REGEX_CALL" BOOST_STRINGIZE(=BOOST_REGEX_CALL)) +# pragma message ("BOOST_REGEX_CCALL" BOOST_STRINGIZE(=BOOST_REGEX_CCALL)) #ifdef BOOST_REGEX_USE_C_LOCALE # pragma message ("Using C locale in regex traits class") #elif BOOST_REGEX_USE_CPP_LOCALE @@ -603,20 +392,15 @@ BOOST_REGEX_DECL void BOOST_REGEX_CALL print_regex_library_info(); #else # pragma message ("Using Win32 locale in regex traits class") #endif -#ifdef BOOST_REGEX_DYN_LINK +#if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK) # pragma message ("Dynamic linking enabled") #endif -#ifdef BOOST_REGEX_NO_LIB +#if defined(BOOST_REGEX_NO_LIB) || defined(BOOST_ALL_NO_LIB) # pragma message ("Auto-linking disabled") #endif #ifdef BOOST_REGEX_NO_EXTERNAL_TEMPLATES # pragma message ("Extern templates disabled") #endif -#ifdef BOOST_REGEX_V3 -# pragma message ("Using Version 3 regex code") -#else -# pragma message ("Using Version 4 regex code") -#endif #endif diff --git a/boost/boost/regex/config/allocator.hpp b/boost/boost/regex/config/allocator.hpp deleted file mode 100644 index 458b6d29ce..0000000000 --- a/boost/boost/regex/config/allocator.hpp +++ /dev/null @@ -1,281 +0,0 @@ -/* - * - * Copyright (c) 2001 - * Dr John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - -#ifndef BOOST_DETAIL_ALLOCATOR_HPP -#define BOOST_DETAIL_ALLOCATOR_HPP - -#include -#include -#include -#include -#if defined(BOOST_NO_STDC_NAMESPACE) -namespace std{ -using ::ptrdiff_t; -using ::size_t; -} -#endif - -// see if we have SGI alloc class: -#if defined(BOOST_NO_STD_ALLOCATOR) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) || defined(__GLIBCPP__) || defined(__STL_CONFIG_H)) -# define BOOST_HAVE_SGI_ALLOCATOR -# include -# if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) -namespace boost{ namespace detail{ - typedef std::__sgi_alloc alloc_type; -}} -# else -namespace boost{ namespace detail{ - typedef std::alloc alloc_type; -}} -# endif -#endif - - -namespace boost{ namespace detail{ - -template -void allocator_construct(T* p, const T& t) -{ new (p) T(t); } - -template -void allocator_destroy(T* p) -{ - (void)p; // warning suppression - p->~T(); -} - -} } - -#if !defined(BOOST_NO_STD_ALLOCATOR) - -#include - -#define BOOST_DEFAULT_ALLOCATOR(T) std::allocator< T > - -namespace boost{ namespace detail{ - -template -struct rebind_allocator -{ - typedef typename A::template rebind binder; - typedef typename binder::other type; -}; - -} // namespace detail -} // namespace boost - -#elif !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__SUNPRO_CC) - -// no std::allocator, but the compiler supports the necessary syntax, -// write our own allocator instead: - -#define BOOST_DEFAULT_ALLOCATOR(T) ::boost::detail::allocator< T > - -namespace boost{ namespace detail{ - -template -class allocator -{ -public: - - typedef T value_type; - typedef value_type * pointer; - typedef const T* const_pointer; - typedef T& reference; - typedef const T& const_reference; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - - template - struct rebind - { - typedef allocator other; - }; - - allocator(){} - - template - allocator(const allocator&){} - - allocator(const allocator&){} - - template - allocator& operator=(const allocator&) - { return *this; } - - ~allocator(){} - - pointer address(reference x) { return &x; } - - const_pointer address(const_reference x) const { return &x; } - - pointer allocate(size_type n, const void* = 0) - { - #ifdef BOOST_HAVE_SGI_ALLOCATOR - return n != 0 ? - reinterpret_cast(alloc_type::allocate(n * sizeof(value_type))) - : 0; - #else - return n != 0 ? - reinterpret_cast(::operator new(n * sizeof(value_type))) - : 0; - #endif - } - - void deallocate(pointer p, size_type n) - { - #ifdef BOOST_HAVE_SGI_ALLOCATOR - assert( (p == 0) == (n == 0) ); - if (p != 0) - alloc_type::deallocate((void*)p, n); - #else - assert( (p == 0) == (n == 0) ); - if (p != 0) - ::operator delete((void*)p); - #endif - } - - size_type max_size() const - { return size_t(-1) / sizeof(value_type); } - - void construct(pointer p, const T& val) const - { allocator_construct(p, val); } - - void destroy(pointer p) const - { allocator_destroy(p); } -}; - -template -struct rebind_allocator -{ - typedef typename A::template rebind binder; - typedef typename binder::other type; -}; - -} // namespace detail -} // namespace boost - -#else - -// no std::allocator, use workaround version instead, -// each allocator class must derive from a base class -// that allocates blocks of bytes: - -#define BOOST_DEFAULT_ALLOCATOR(T) ::boost::detail::allocator_adapter - -namespace boost{ namespace detail{ - -class simple_alloc -{ -public: - - typedef void value_type; - typedef value_type * pointer; - typedef const void* const_pointer; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - - simple_alloc(){} - simple_alloc(const simple_alloc&){} - - ~simple_alloc(){} - - pointer allocate(size_type n, const void* = 0) - { - #ifdef BOOST_HAVE_SGI_ALLOCATOR - return n != 0 ? - reinterpret_cast(alloc_type::allocate(n)) - : 0; - #else - return n != 0 ? - reinterpret_cast(::operator new(n)) - : 0; - #endif - } - - void deallocate(pointer p, size_type n) - { - #ifdef BOOST_HAVE_SGI_ALLOCATOR - assert( (p == 0) == (n == 0) ); - if (p != 0) - alloc_type::deallocate((void*)p, n); - #else - assert( (p == 0) == (n == 0) ); - if (p != 0) - ::operator delete((void*)p); - #endif - } -}; - -template -class allocator_adapter : public Base -{ -public: - - typedef T value_type; - typedef value_type * pointer; - typedef const T* const_pointer; - typedef T& reference; - typedef const T& const_reference; - typedef size_t size_type; - typedef std::ptrdiff_t difference_type; - typedef Base base_type; - - allocator_adapter(){} - allocator_adapter(const base_type& x) : Base(x){} - allocator_adapter& operator=(const base_type& x) - { - *(static_cast(this)) = x; - return *this; - } - - ~allocator_adapter(){} - - pointer address(reference x) { return &x; } - - const_pointer address(const_reference x) const { return &x; } - - pointer allocate(size_type n, const void* = 0) - { - return n != 0 ? - reinterpret_cast(base_type::allocate(n * sizeof(value_type))) - : 0; - } - - void deallocate(pointer p, size_type n) - { - assert( (p == 0) == (n == 0) ); - if (p != 0) - static_cast(this)->deallocate((void*)p, n * sizeof(value_type)); - } - - size_type max_size() const - { return size_t(-1) / sizeof(value_type); } - - void construct(pointer p, const T& val) const - { allocator_construct(p, val); } - - void destroy(pointer p) const - { allocator_destroy(p); } -}; - -template -struct rebind_allocator -{ - typedef allocator_adapter type; -}; - -} // namespace detail -} // namespace boost - -#endif - -#endif // include guard diff --git a/boost/boost/regex/config/borland.hpp b/boost/boost/regex/config/borland.hpp index 372aa0c4ac..51c2126b8e 100644 --- a/boost/boost/regex/config/borland.hpp +++ b/boost/boost/regex/config/borland.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -58,6 +58,15 @@ # endif # endif +#if __BORLANDC__ < 0x600 +// +// string workarounds: +// +#include +#undef strcmp +#undef strcpy +#endif + #endif diff --git a/boost/boost/regex/config/cstring.hpp b/boost/boost/regex/config/cstring.hpp deleted file mode 100644 index 3e09fc3421..0000000000 --- a/boost/boost/regex/config/cstring.hpp +++ /dev/null @@ -1,303 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * Dr John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - - /* - * LOCATION: see http://www.boost.org for most recent version. - * FILE boost/regex/config/cstring.hpp - * VERSION see - * DESCRIPTION: regex narrow character string fixes. - */ - -#ifndef BOOST_REGEX_CONFIG_CSTRING_HPP -#define BOOST_REGEX_CONFIG_CSTRING_HPP - -#include -#include -#ifndef __sgi -#ifdef __KCC -#include -#endif -#include - -namespace std{ - -#ifdef __BORLANDC__ -#pragma option push -w-8008 -w-8066 -w-8004 -#endif - -#ifdef BOOST_NO_STDC_NAMESPACE - -// Any function that is a macro is converted into an inline function: -#ifdef memcmp -inline int boost_memcmp(const void * p1, const void * p2, size_t s) -{ return memcmp(p1, p2, s); } -#undef memcmp -inline int memcmp(const void * p1, const void * p2, size_t s) -{ return boost_memcmp(p1, p2, s); } -#elif defined(BOOST_NO_STDC_NAMESPACE) -using ::memcmp; -#endif - -#ifdef memcpy -inline void *boost_memcpy(void * p1, const void *p2, size_t s) -{ return memcpy(p1, p2, s); } -#undef memcpy -inline void *memcpy(void * p1, const void *p2, size_t s) -{ return boost_memcpy(p1, p2, s); } -#elif defined(BOOST_NO_STDC_NAMESPACE) -using ::memcpy; -#endif - -#ifdef memmove -inline void *(memmove)(void *, const void *, size_t) -{ return memmove(p1,p2,s); } -#undef memmove -#elif defined(BOOST_NO_STDC_NAMESPACE) -using ::memmove; -#endif - -#ifdef memset -inline void *(boost_memset)(void *p, int a, size_t b) -{ return memset(p,a,b); } -#undef memset -inline void *(memset)(void *p, int a, size_t b) -{ return boost_memset(p,a,b); } -#elif defined(BOOST_NO_STDC_NAMESPACE) -using ::memset; -#endif - -#ifdef strcat -inline char *(boost_strcat)(char *p1, const char *p2) -{ return strcat(p1,p2); } -#undef strcat -inline char *(strcat)(char *p1, const char *p2) -{ return boost_strcat(p1,p2); } -#elif defined(BOOST_NO_STDC_NAMESPACE) -using ::strcat; -#endif - -#ifdef strcmp -inline int (boost_strcmp)(const char *p1, const char *p2) -{ return strcmp(p1,p2); } -#undef strcmp -inline int (strcmp)(const char *p1, const char *p2) -{ return boost_strcmp(p1,p2); } -#elif defined(BOOST_NO_STDC_NAMESPACE) -using ::strcmp; -#endif - -#ifdef strcoll -inline int (boost_strcoll) (const char *p1, const char *p2) -{ return strcoll(p1,p2); } -#undef strcoll -inline int (strcoll) (const char *p1, const char *p2) -{ return boost_strcoll(p1,p2); } -#elif defined(BOOST_NO_STDC_NAMESPACE) -using ::strcoll; -#endif - -#ifdef strcpy -inline char *(boost_strcpy)(char *p1, const char *p2) -{ return strcpy(p1,p2); } -#undef strcpy -inline char *(strcpy)(char *p1, const char *p2) -{ return boost_strcpy(p1,p2); } -#elif defined(BOOST_NO_STDC_NAMESPACE) -using ::strcpy; -#endif - -#ifdef strlen -inline size_t (boost_strlen)(const char *p) -{ return strlen(p); } -#undef strlen -inline size_t (strlen)(const char *p) -{ return boost_strlen(p); } -#elif defined(BOOST_NO_STDC_NAMESPACE) -using ::strlen; -#endif - -#ifdef strxfrm -inline size_t (boost_strxfrm)(char *p1, const char *p2, size_t s) -{ return strxfrm(p1,p2,s); } -#undef strxfrm -inline size_t (strxfrm)(char *p1, const char *p2, size_t s) -{ return boost_strxfrm(p1,p2,s); } -#elif defined(BOOST_NO_STDC_NAMESPACE) -using ::strxfrm; -#endif - -#ifdef isalnum -inline int (boost_isalnum)(int i) -{ return isalnum(i); } -#undef isalnum -inline int (isalnum)(int i) -{ return boost_isalnum(i); } -#elif defined(BOOST_NO_STDC_NAMESPACE) -using ::isalnum; -#endif - -#ifdef isalpha -inline int (boost_isalpha)(int i) -{ return isalpha(i); } -#undef isalpha -inline int (isalpha)(int i) -{ return boost_isalpha(i); } -#elif defined(BOOST_NO_STDC_NAMESPACE) -using ::isalpha; -#endif - -#ifdef iscntrl -inline int (boost_iscntrl)(int i) -{ return iscntrl(i); } -#undef iscntrl -inline int (iscntrl)(int i) -{ return boost_iscntrl(i); } -#elif defined(BOOST_NO_STDC_NAMESPACE) -using ::iscntrl; -#endif - -#ifdef isdigit -inline int (boost_isdigit)(int i) -{ return isdigit(i); } -#undef isdigit -inline int (isdigit)(int i) -{ return boost_isdigit(i); } -#elif defined(BOOST_NO_STDC_NAMESPACE) -using ::isdigit; -#endif - -#ifdef isgraph -inline int (boost_isgraph)(int i) -{ return isgraph(i); } -#undef isgraph -inline int (isgraph)(int i) -{ return boost_isgraph(i); } -#elif defined(BOOST_NO_STDC_NAMESPACE) -using ::isgraph; -#endif - -#ifdef islower -inline int (boost_islower)(int i) -{ return islower(i); } -#undef islower -inline int (islower)(int i) -{ return boost_islower(i); } -#elif defined(BOOST_NO_STDC_NAMESPACE) -using ::islower; -#endif - -#ifdef isprint -inline int (boost_isprint)(int i) -{ return isprint(i); } -#undef isprint -inline int (isprint)(int i) -{ return boost_isprint(i); } -#elif defined(BOOST_NO_STDC_NAMESPACE) -using ::isprint; -#endif - -#ifdef ispunct -inline int (boost_ispunct)(int i) -{ return ispunct(i); } -#undef ispunct -inline int (ispunct)(int i) -{ return boost_ispunct(i); } -#elif defined(BOOST_NO_STDC_NAMESPACE) -using ::ispunct; -#endif - -#ifdef isspace -inline int (isspace)(int i) -{ return isspace(i); } -#undef isspace -inline int (boost_isspace)(int i) -{ return boost_isspace(i); } -#elif defined(BOOST_NO_STDC_NAMESPACE) -using ::isspace; -#endif - -#ifdef isupper -inline int (isupper)(int i) -{ return isupper(i); } -#undef isupper -#elif defined(BOOST_NO_STDC_NAMESPACE) -using ::isupper; -#endif - -#ifdef isxdigit -inline int (isxdigit)(int i) -{ return isxdigit(i); } -#undef isxdigit -inline int (boost_isxdigit)(int i) -{ return boost_isxdigit(i); } -#elif defined(BOOST_NO_STDC_NAMESPACE) -using ::isxdigit; -#endif - -#ifdef tolower -inline int (boost_tolower)(int i) -{ return tolower(i); } -#undef tolower -inline int (tolower)(int i) -{ return boost_tolower(i); } -#elif defined(BOOST_NO_STDC_NAMESPACE) -using ::tolower; -#endif - -#ifdef toupper -inline int (boost_toupper)(int i) -{ return toupper(i); } -#undef toupper -inline int (toupper)(int i) -{ return boost_toupper(i); } -#elif defined(BOOST_NO_STDC_NAMESPACE) -using ::toupper; -#endif - -#else - -#undef memcmp -#undef memcpy -#undef memmove -#undef memset -#undef strcat -#undef strcmp -#undef strcoll -#undef strcpy -#undef strlen -#undef strxfrm -#undef isalnum -#undef isalpha -#undef iscntrl -#undef isdigit -#undef isgraph -#undef islower -#undef isprint -#undef ispunct -#undef isspace -#undef isupper -#undef isxdigit -#undef tolower -#undef toupper - -#endif - - -#ifdef __BORLANDC__ -#pragma option pop -#endif - -} // namespace std - -#endif // __sgi - -#endif - diff --git a/boost/boost/regex/config/cwchar.hpp b/boost/boost/regex/config/cwchar.hpp index 970b0d2e81..1d189e6ccd 100644 --- a/boost/boost/regex/config/cwchar.hpp +++ b/boost/boost/regex/config/cwchar.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file diff --git a/boost/boost/regex/config/regex_library_include.hpp b/boost/boost/regex/config/regex_library_include.hpp deleted file mode 100644 index 5769ceef39..0000000000 --- a/boost/boost/regex/config/regex_library_include.hpp +++ /dev/null @@ -1,204 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * Dr John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - - /* - * LOCATION: see http://www.boost.org for most recent version. - * FILE regex_libary_include.hpp - * VERSION see - * DESCRIPTION: Automatic library inclusion for Borland/Microsoft compilers. - * Note this is an internal header file included - * by regex.hpp, do not include on its own. - */ - -/************************************************************************* - -Libraries for Borland and Microsoft compilers are automatically -selected here, the name of the lib is selected according to the following -formula: - -BOOST_LIB_PREFIX - + BOOST_LIB_NAME - + "_" - + BOOST_LIB_TOOLSET - + "_" - + BOOST_LIB_THREAD_OPT - + BOOST_LIB_RT_OPT - + BOOST_LIB_DEBUG_OPT - -These are defined as: - -BOOST_LIB_PREFIX: "lib" for static libraries otherwise "". - -BOOST_LIB_NAME: The base name of the lib (boost_regex). - -BOOST_LIB_TOOLSET: The compiler toolset name (vc6, vc7, bcb5 etc). - -BOOST_LIB_THREAD_OPT: "s" for single thread builds, - "m" for multithread builds. - -BOOST_LIB_RT_OPT: "s" for static runtime, - "d" for dynamic runtime. - -BOOST_LIB_DEBUG_OPT: nothing for release builds, - "d" for debug builds, - "dd" for debug-diagnostic builds (_STLP_DEBUG). - -***************************************************************************/ - -#if !defined(BOOST_REGEX_LIBRARY_INCLUDE_HPP) && !defined(BOOST_REGEX_NO_LIB) -#define BOOST_REGEX_LIBRARY_INCLUDE_HPP - -#define BOOST_LIB_NAME "boost_regex" - -// -// select toolset: -// -#if defined(BOOST_MSVC) && (BOOST_MSVC == 1200) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) - - // vc6-stlport: -# define BOOST_LIB_TOOLSET "vc6-stlport" - -#elif defined(BOOST_MSVC) && (BOOST_MSVC == 1200) - - // vc6: -# define BOOST_LIB_TOOLSET "vc6" - -#elif defined(BOOST_MSVC) && (BOOST_MSVC == 1300) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) - - // vc6-stlport: -# define BOOST_LIB_TOOLSET "vc7-stlport" - -#elif defined(BOOST_MSVC) && (BOOST_MSVC == 1300) - - // vc7: -# define BOOST_LIB_TOOLSET "vc7" - -#elif defined(BOOST_MSVC) && (BOOST_MSVC >= 1310) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) - - // vc71-stlport: -# define BOOST_LIB_TOOLSET "vc71-stlport" - -#elif defined(BOOST_MSVC) && (BOOST_MSVC >= 1310) - - // vc71: -# define BOOST_LIB_TOOLSET "vc71" - -#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) - - // CBuilder 6: -# define BOOST_LIB_TOOLSET "bcb6" - -#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550) - - // CBuilder 6: -# define BOOST_LIB_TOOLSET "bcb5" - -#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x540) - - // CBuilder 6: -# define BOOST_LIB_TOOLSET "bcb4" - -#endif - -// -// select thread opt: -// -#if defined(_MT) || defined(__MT__) -# define BOOST_LIB_THREAD_OPT "m" -#else -# define BOOST_LIB_THREAD_OPT "s" -#endif - -// -// select runtime opt: -// -#if defined(_DLL) || defined(_RTLDLL) -# define BOOST_LIB_RT_OPT "d" -#else -# define BOOST_LIB_RT_OPT "s" -#endif - -// -// select linkage opt: -// -#if defined(BOOST_REGEX_STATIC_LINK) && defined(BOOST_REGEX_DYN_LINK) -# undef BOOST_REGEX_STATIC_LINK -#endif -#if (defined(_DLL) || defined(_RTLDLL)) && defined(BOOST_REGEX_DYN_LINK) -# define BOOST_LIB_PREFIX -#else -# define BOOST_LIB_PREFIX "lib" -#endif - -// -// select debug opt: -// -#if defined(BOOST_MSVC) && defined(_DEBUG) && (defined(_STLP_DEBUG) || defined(__STL_DEBUG)) -# define BOOST_LIB_DEBUG_OPT "dd" -#elif defined(BOOST_MSVC) && defined(_DEBUG) -# define BOOST_LIB_DEBUG_OPT "d" -#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (defined(_STLP_DEBUG) || defined(__STL_DEBUG)) -# define BOOST_LIB_DEBUG_OPT "dd" -#else -# define BOOST_LIB_DEBUG_OPT -#endif - -// -// now include the lib: -// -#if defined(BOOST_LIB_NAME) \ - && defined(BOOST_LIB_PREFIX) \ - && defined(BOOST_LIB_TOOLSET) \ - && defined(BOOST_LIB_THREAD_OPT) \ - && defined(BOOST_LIB_RT_OPT) \ - && defined(BOOST_LIB_DEBUG_OPT) - -# pragma comment(lib, BOOST_LIB_PREFIX BOOST_LIB_NAME "_" BOOST_LIB_TOOLSET "_" BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT BOOST_LIB_DEBUG_OPT ".lib") -#ifdef BOOST_REGEX_DIAG -# pragma message ("Linking to lib file: " BOOST_LIB_PREFIX BOOST_LIB_NAME "_" BOOST_LIB_TOOLSET "_" BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT BOOST_LIB_DEBUG_OPT ".lib") -#endif - -#endif - -// -// finally undef any macros we may have set: -// -#if defined(BOOST_LIB_NAME) -# undef BOOST_LIB_NAME -#endif -#if defined(BOOST_LIB_TOOLSET) -# undef BOOST_LIB_TOOLSET -#endif -#if defined(BOOST_LIB_THREAD_OPT) -# undef BOOST_LIB_THREAD_OPT -#endif -#if defined(BOOST_LIB_RT_OPT) -# undef BOOST_LIB_RT_OPT -#endif -#if defined(BOOST_LIB_LINK_OPT) -# undef BOOST_LIB_LINK_OPT -#endif -#if defined(BOOST_LIB_DEBUG_OPT) -# undef BOOST_LIB_DEBUG_OPT -#endif - - -#endif // BOOST_REGEX_LIBRARY_INCLUDE_HPP - - - - - - - - - - diff --git a/boost/boost/regex/pattern_except.hpp b/boost/boost/regex/pattern_except.hpp index 39d28ccfa7..25cab1cc5c 100644 --- a/boost/boost/regex/pattern_except.hpp +++ b/boost/boost/regex/pattern_except.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -23,6 +23,10 @@ #include #endif +#include +#include +#include + namespace boost{ #ifdef BOOST_HAS_ABI_HEADERS @@ -33,22 +37,39 @@ namespace boost{ #pragma warning(push) #pragma warning(disable : 4275) #endif -class BOOST_REGEX_DECL bad_pattern : public std::runtime_error + class BOOST_REGEX_DECL regex_error : public std::runtime_error { public: - explicit bad_pattern(const std::string& s) : std::runtime_error(s){}; - ~bad_pattern() throw(); + explicit regex_error(const std::string& s, regex_constants::error_type err = regex_constants::error_unknown, std::ptrdiff_t pos = 0); + explicit regex_error(regex_constants::error_type err); + ~regex_error() throw(); + regex_constants::error_type code()const + { return m_error_code; } + std::ptrdiff_t position()const + { return m_position; } + void raise()const; +private: + regex_constants::error_type m_error_code; + std::ptrdiff_t m_position; }; -#ifdef BOOST_MSVC -#pragma warning(pop) -#endif -class BOOST_REGEX_DECL bad_expression : public bad_pattern +typedef regex_error bad_pattern; +typedef regex_error bad_expression; + +namespace re_detail{ + +BOOST_REGEX_DECL void BOOST_REGEX_CALL raise_runtime_error(const std::runtime_error& ex); + +template +void raise_error(const traits& t, regex_constants::error_type code) { -public: - explicit bad_expression(const std::string& s) : bad_pattern(s) {} - ~bad_expression() throw(); -}; + (void)t; // warning suppression + std::runtime_error e(t.error_string(code)); + ::boost::re_detail::raise_runtime_error(e); +} + +} + #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_SUFFIX diff --git a/boost/boost/regex/pending/object_cache.hpp b/boost/boost/regex/pending/object_cache.hpp new file mode 100644 index 0000000000..561b08e875 --- /dev/null +++ b/boost/boost/regex/pending/object_cache.hpp @@ -0,0 +1,163 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE object_cache.hpp + * VERSION see + * DESCRIPTION: Implements a generic object cache. + */ + +#ifndef BOOST_REGEX_OBJECT_CACHE_HPP +#define BOOST_REGEX_OBJECT_CACHE_HPP + +#include +#include +#include +#include +#include +#include +#ifdef BOOST_HAS_THREADS +#include +#endif + +namespace boost{ + +template +class object_cache +{ +public: + typedef std::pair< ::boost::shared_ptr, Key const*> value_type; + typedef std::list list_type; + typedef typename list_type::iterator list_iterator; + typedef std::map map_type; + typedef typename map_type::iterator map_iterator; + typedef typename list_type::size_type size_type; + static boost::shared_ptr get(const Key& k, size_type max_cache_size); + +private: + static boost::shared_ptr do_get(const Key& k, size_type max_cache_size); + + struct data + { + list_type cont; + map_type index; + }; + + // Needed by compilers not implementing the resolution to DR45. For reference, + // see http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#45. + friend struct data; +}; + +template +boost::shared_ptr object_cache::get(const Key& k, size_type max_cache_size) +{ +#ifdef BOOST_HAS_THREADS + static boost::static_mutex mut = BOOST_STATIC_MUTEX_INIT; + + boost::static_mutex::scoped_lock l(mut); + if(l) + { + return do_get(k, max_cache_size); + } + // + // what do we do if the lock fails? + // for now just throw, but we should never really get here... + // + ::boost::throw_exception(std::runtime_error("Error in thread safety code: could not acquire a lock")); + return boost::shared_ptr(); +#else + return do_get(k, max_cache_size); +#endif +} + +template +boost::shared_ptr object_cache::do_get(const Key& k, size_type max_cache_size) +{ + typedef typename object_cache::data object_data; + typedef typename list_type::size_type list_size_type; + static object_data s_data; + + // + // see if the object is already in the cache: + // + map_iterator mpos = s_data.index.find(k); + if(mpos != s_data.index.end()) + { + // + // Eureka! + // We have a cached item, bump it up the list and return it: + // + if(--(s_data.cont.end()) != mpos->second) + { + // splice out the item we want to move: + list_type temp; + temp.splice(temp.end(), s_data.cont, mpos->second); + // and now place it at the end of the list: + s_data.cont.splice(s_data.cont.end(), temp, temp.begin()); + BOOST_ASSERT(*(s_data.cont.back().second) == k); + // update index with new position: + mpos->second = --(s_data.cont.end()); + BOOST_ASSERT(&(mpos->first) == mpos->second->second); + BOOST_ASSERT(&(mpos->first) == s_data.cont.back().second); + } + return s_data.cont.back().first; + } + // + // if we get here then the item is not in the cache, + // so create it: + // + boost::shared_ptr result(new Object(k)); + // + // Add it to the list, and index it: + // + s_data.cont.push_back(value_type(result, 0)); + s_data.index.insert(std::make_pair(k, --(s_data.cont.end()))); + s_data.cont.back().second = &(s_data.index.find(k)->first); + list_size_type s = s_data.cont.size(); + BOOST_ASSERT(s_data.index[k]->first.get() == result.get()); + BOOST_ASSERT(&(s_data.index.find(k)->first) == s_data.cont.back().second); + BOOST_ASSERT(s_data.index.find(k)->first == k); + if(s > max_cache_size) + { + // + // We have too many items in the list, so we need to start + // popping them off the back of the list, but only if they're + // being held uniquely by us: + // + list_iterator pos = s_data.cont.begin(); + list_iterator last = s_data.cont.end(); + while((pos != last) && (s > max_cache_size)) + { + if(pos->first.unique()) + { + list_iterator condemmed(pos); + ++pos; + // now remove the items from our containers, + // then order has to be as follows: + BOOST_ASSERT(s_data.index.find(*(condemmed->second)) != s_data.index.end()); + s_data.index.erase(*(condemmed->second)); + s_data.cont.erase(condemmed); + --s; + } + else + --pos; + } + BOOST_ASSERT(s_data.index[k]->first.get() == result.get()); + BOOST_ASSERT(&(s_data.index.find(k)->first) == s_data.cont.back().second); + BOOST_ASSERT(s_data.index.find(k)->first == k); + } + return result; +} + +} + +#endif diff --git a/boost/boost/regex/regex_traits.hpp b/boost/boost/regex/regex_traits.hpp index d54bb23e62..730ba6e0d8 100644 --- a/boost/boost/regex/regex_traits.hpp +++ b/boost/boost/regex/regex_traits.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -23,15 +23,9 @@ # include #endif -#ifdef BOOST_REGEX_V3 -# ifndef BOOST_REGEX_TRAITS_HPP_INCLUDED -# include -# endif -#else # ifndef BOOST_REGEX_TRAITS_HPP_INCLUDED # include # endif -#endif #endif // include diff --git a/boost/boost/regex/src.cpp b/boost/boost/regex/src.cpp deleted file mode 100644 index 4e20ea95b9..0000000000 --- a/boost/boost/regex/src.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * Dr John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - - /* - * LOCATION: see http://www.boost.org for most recent version. - * FILE src.cpp - * VERSION see - * DESCRIPTION: Includes all the regex source files, include this - * file only if you need to build the regex library - * as a single file. You must include this file - * before any other regex header. - * - * CAUTION: THIS FILE IS DEPRICATED AND WILL CAUSE - * UNNECESSARY CODE BLOAT. - */ - -#if (!defined(BOOST_REGEX_NO_LIB) || !defined(BOOST_REGEX_NO_EXTERNAL_TEMPLATES)) && defined(BOOST_REGEX_CONFIG_HPP) -#error too late you have already included a regex header - make sure that you include this header before any other boost header -#endif - -#define BOOST_REGEX_NO_LIB -#define BOOST_REGEX_STATIC_LINK -#define BOOST_REGEX_NO_EXTERNAL_TEMPLATES - -#include - -// -// include library source files: -// -#ifdef BOOST_REGEX_USE_WIN32_LOCALE -#include "libs/regex/src/w32_regex_traits.cpp" -#elif defined(BOOST_REGEX_USE_C_LOCALE) -#include "libs/regex/src/c_regex_traits.cpp" -#else -#include "libs/regex/src/cpp_regex_traits.cpp" -#endif -#include "libs/regex/src/c_regex_traits_common.cpp" -#include "libs/regex/src/cregex.cpp" -#include "libs/regex/src/fileiter.cpp" -#include "libs/regex/src/posix_api.cpp" -#include "libs/regex/src/wide_posix_api.cpp" -#include "libs/regex/src/regex.cpp" -#include "libs/regex/src/regex_debug.cpp" -#include "libs/regex/src/regex_synch.cpp" - - - diff --git a/boost/boost/regex/user.hpp b/boost/boost/regex/user.hpp index 9276121030..95908173d7 100644 --- a/boost/boost/regex/user.hpp +++ b/boost/boost/regex/user.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -55,10 +55,6 @@ // cause more problems than they are worth: // #define BOOST_REGEX_NO_FWD -// define this if your compiler can't cope with the new -// version 4 regex code. -// #define BOOST_REGEX_V3 - // define this if your compiler supports MS Windows structured // exception handling. // #define BOOST_REGEX_HAS_MS_STACK_GUARD @@ -90,3 +86,5 @@ // down quite a bit). // #define BOOST_REGEX_MATCH_EXTRA +// define this if you want to enable support for Unicode via ICU. +// #define BOOST_HAS_ICU diff --git a/boost/boost/regex/v4/basic_regex.hpp b/boost/boost/regex/v4/basic_regex.hpp index 737a24bd17..4d1aef27e6 100644 --- a/boost/boost/regex/v4/basic_regex.hpp +++ b/boost/boost/regex/v4/basic_regex.hpp @@ -1,7 +1,7 @@ /* * - * Copyright (c) 1998-2002 - * Dr John Maddock + * Copyright (c) 1998-2004 + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -13,8 +13,7 @@ * LOCATION: see http://www.boost.org for most recent version. * FILE basic_regex.cpp * VERSION see - * DESCRIPTION: Declares template class basic_regex (note that member function - * bodies are in regex_compile.hpp). + * DESCRIPTION: Declares template class basic_regex. */ #ifndef BOOST_REGEX_V4_BASIC_REGEX_HPP @@ -25,28 +24,166 @@ #endif namespace boost{ -// -// class reg_expression -// represents the compiled -// regular expression: -// - #ifdef BOOST_MSVC #pragma warning(push) #pragma warning(disable : 4251 4231 4660) #endif +namespace re_detail{ + +// +// forward declaration, we will need this one later: +// +template +class basic_regex_parser; + +// +// class regex_data: +// represents the data we wish to expose to the matching algorithms. +// +template +struct regex_data +{ + typedef regex_constants::syntax_option_type flag_type; + typedef std::size_t size_type; + + regex_data(const ::boost::shared_ptr< + ::boost::regex_traits_wrapper >& t) + : m_ptraits(t), m_expression(0), m_expression_len(0) {} + regex_data() + : m_ptraits(new ::boost::regex_traits_wrapper()), m_expression(0), m_expression_len(0) {} + + ::boost::shared_ptr< + ::boost::regex_traits_wrapper + > m_ptraits; // traits class instance + flag_type m_flags; // flags with which we were compiled + int m_status; // error code (0 implies OK). + 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 + 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 +}; +// +// class basic_regex_implementation +// pimpl implementation class for basic_regex. +// +template +class basic_regex_implementation + : public regex_data +{ +public: + typedef regex_constants::syntax_option_type flag_type; + typedef std::ptrdiff_t difference_type; + typedef std::size_t size_type; + typedef typename traits::locale_type locale_type; + typedef const charT* const_iterator; + + basic_regex_implementation(){} + basic_regex_implementation(const ::boost::shared_ptr< + ::boost::regex_traits_wrapper >& t) + : regex_data(t) {} + void assign(const charT* arg_first, + const charT* arg_last, + flag_type f) + { + regex_data* pdat = this; + basic_regex_parser parser(pdat); + parser.parse(arg_first, arg_last, f); + } + + locale_type BOOST_REGEX_CALL imbue(locale_type l) + { + return this->m_ptraits->imbue(l); + } + locale_type BOOST_REGEX_CALL getloc()const + { + return this->m_ptraits->getloc(); + } + std::basic_string BOOST_REGEX_CALL str()const + { + std::basic_string result; + if(this->m_status == 0) + result = std::basic_string(this->m_expression, this->m_expression_len); + return result; + } + const_iterator BOOST_REGEX_CALL expression()const + { + return this->m_expression; + } + // + // begin, end: + const_iterator BOOST_REGEX_CALL begin()const + { + return (!this->m_status ? 0 : this->m_expression); + } + const_iterator BOOST_REGEX_CALL end()const + { + return (!this->m_status ? 0 : this->m_expression + this->m_expression_len); + } + flag_type BOOST_REGEX_CALL flags()const + { + return this->m_flags; + } + size_type BOOST_REGEX_CALL size()const + { + return this->m_expression_len; + } + int BOOST_REGEX_CALL status()const + { + return this->m_status; + } + size_type BOOST_REGEX_CALL mark_count()const + { + return this->m_mark_count; + } + const re_detail::re_syntax_base* get_first_state()const + { + return this->m_first_state; + } + unsigned get_restart_type()const + { + return this->m_restart_type; + } + const unsigned char* get_map()const + { + return this->m_startmap; + } + const ::boost::regex_traits_wrapper& get_traits()const + { + return *(this->m_ptraits); + } + bool can_be_null()const + { + return this->m_can_be_null; + } + const regex_data& get_data()const + { + basic_regex_implementation const* p = this; + return *static_cast*>(p); + } +}; + +} // namespace re_detail +// +// class basic_regex: +// represents the compiled +// regular expression: +// + #ifdef BOOST_REGEX_NO_FWD -template , class Allocator = BOOST_DEFAULT_ALLOCATOR(charT) > +template > #else -template +template #endif -class reg_expression : public regbase +class basic_regex : public regbase { public: // typedefs: typedef typename traits::size_type traits_size_type; - typedef typename traits::uchar_type traits_uchar_type; typedef typename traits::string_type traits_string_type; typedef charT char_type; typedef traits traits_type; @@ -56,10 +193,8 @@ public: typedef const charT& const_reference; typedef const charT* const_iterator; typedef const_iterator iterator; - typedef typename Allocator::difference_type difference_type; - typedef typename Allocator::size_type size_type; - typedef Allocator allocator_type; - typedef Allocator alloc_type; + typedef std::ptrdiff_t difference_type; + typedef std::size_t size_type; typedef regex_constants::syntax_option_type flag_type; // locale_type // placeholder for actual locale type used by the @@ -67,319 +202,425 @@ public: typedef typename traits::locale_type locale_type; public: - explicit reg_expression(const Allocator& a = Allocator()); - explicit reg_expression(const charT* p, flag_type f = regex_constants::normal, const Allocator& a = Allocator()); - reg_expression(const charT* p1, const charT* p2, flag_type f = regex_constants::normal, const Allocator& a = Allocator()); - reg_expression(const charT* p, size_type len, flag_type f, const Allocator& a = Allocator()); - reg_expression(const reg_expression&); - ~reg_expression(); - reg_expression& BOOST_REGEX_CALL operator=(const reg_expression&); - reg_expression& BOOST_REGEX_CALL operator=(const charT* ptr) + explicit basic_regex(){} + explicit basic_regex(const charT* p, flag_type f = regex_constants::normal) { - set_expression(ptr, regex_constants::normal | regex_constants::use_except); - return *this; + assign(p, f); + } + basic_regex(const charT* p1, const charT* p2, flag_type f = regex_constants::normal) + { + assign(p1, p2, f); + } + basic_regex(const charT* p, size_type len, flag_type f) + { + assign(p, len, f); + } + basic_regex(const basic_regex& that) + : m_pimpl(that.m_pimpl) {} + ~basic_regex(){} + basic_regex& BOOST_REGEX_CALL operator=(const basic_regex& that) + { + return assign(that); + } + basic_regex& BOOST_REGEX_CALL operator=(const charT* ptr) + { + return assign(ptr); } // // assign: - reg_expression& assign(const reg_expression& that) - { return *this = that; } - reg_expression& assign(const charT* ptr, flag_type f = regex_constants::normal) - { - set_expression(ptr, f | regex_constants::use_except); - return *this; + basic_regex& assign(const basic_regex& that) + { + m_pimpl = that.m_pimpl; + return *this; } - reg_expression& assign(const charT* ptr, size_type len, flag_type f) + basic_regex& assign(const charT* p, flag_type f = regex_constants::normal) { - std::basic_string s(ptr, len); - set_expression(s.c_str(), f | regex_constants::use_except); - return *this; + return assign(p, p + traits::length(p), f); } - - reg_expression& assign(const charT* arg_first, - const charT* arg_last, + basic_regex& assign(const charT* p, size_type len, flag_type f) + { + return assign(p, p + len, f); + } +private: + basic_regex& do_assign(const charT* p1, + const charT* p2, + flag_type f); +public: + basic_regex& assign(const charT* p1, + const charT* p2, flag_type f = regex_constants::normal) { - set_expression(arg_first, arg_last, f | regex_constants::use_except); - return *this; + return do_assign(p1, p2, f); } #if !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__) template unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string& p, flag_type f = regex_constants::normal) - { return set_expression(p.data(), p.data() + p.size(), f); } + { + return set_expression(p.data(), p.data() + p.size(), f); + } template - explicit reg_expression(const std::basic_string& p, flag_type f = regex_constants::normal, const Allocator& a = Allocator()) - : data(a), pkmp(0), error_code_(REG_EMPTY), _expression(0) { set_expression(p, f | regex_constants::use_except); } + explicit basic_regex(const std::basic_string& p, flag_type f = regex_constants::normal) + { + assign(p, f); + } template - reg_expression(InputIterator arg_first, InputIterator arg_last, flag_type f = regex_constants::normal, const Allocator& al = Allocator()) - : data(al), pkmp(0), error_code_(REG_EMPTY), _expression(0) + basic_regex(InputIterator arg_first, InputIterator arg_last, flag_type f = regex_constants::normal) + { + typedef typename traits::string_type seq_type; + seq_type a(arg_first, arg_last); + if(a.size()) + assign(&*a.begin(), &*a.begin() + a.size(), f); + else + assign(static_cast(0), static_cast(0), f); + } + + template + basic_regex& BOOST_REGEX_CALL operator=(const std::basic_string& p) + { + return assign(p.data(), p.data() + p.size(), regex_constants::normal); + } + + template + basic_regex& BOOST_REGEX_CALL assign( + const std::basic_string& s, + flag_type f = regex_constants::normal) + { + return assign(s.data(), s.data() + s.size(), f); + } + + template + basic_regex& BOOST_REGEX_CALL assign(InputIterator arg_first, + InputIterator arg_last, + flag_type f = regex_constants::normal) + { + typedef typename traits::string_type seq_type; + seq_type a(arg_first, arg_last); + if(a.size()) + { + const charT* p1 = &*a.begin(); + const charT* p2 = &*a.begin() + a.size(); + return assign(p1, p2, f); + } + return assign(static_cast(0), static_cast(0), f); + } +#else + unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string& p, flag_type f = regex_constants::normal) + { + return set_expression(p.data(), p.data() + p.size(), f); + } + + basic_regex(const std::basic_string& p, flag_type f = regex_constants::normal) + { + assign(p, f); + } + + basic_regex& BOOST_REGEX_CALL operator=(const std::basic_string& p) + { + return assign(p.data(), p.data() + p.size(), regex_constants::normal); + } + + basic_regex& BOOST_REGEX_CALL assign( + const std::basic_string& s, + flag_type f = regex_constants::normal) + { + return assign(s.data(), s.data() + s.size(), f); + } + +#endif + + // + // locale: + locale_type BOOST_REGEX_CALL imbue(locale_type l); + locale_type BOOST_REGEX_CALL getloc()const + { + return m_pimpl.get() ? m_pimpl->getloc() : locale_type(); + } + // + // getflags: + // retained for backwards compatibility only, "flags" + // is now the prefered name: + flag_type BOOST_REGEX_CALL getflags()const + { + return flags(); + } + flag_type BOOST_REGEX_CALL flags()const + { + return m_pimpl.get() ? m_pimpl->flags() : 0; + } + // + // str: + std::basic_string BOOST_REGEX_CALL str()const + { + return m_pimpl.get() ? m_pimpl->str() : std::basic_string(); + } + // + // begin, end: + const_iterator BOOST_REGEX_CALL begin()const + { + return (m_pimpl.get() ? m_pimpl->begin() : 0); + } + const_iterator BOOST_REGEX_CALL end()const + { + return (m_pimpl.get() ? m_pimpl->end() : 0); + } + // + // swap: + void BOOST_REGEX_CALL swap(basic_regex& that)throw() + { + m_pimpl.swap(that.m_pimpl); + } + // + // size: + size_type BOOST_REGEX_CALL size()const + { + return (m_pimpl.get() ? m_pimpl->size() : 0); + } + // + // max_size: + size_type BOOST_REGEX_CALL max_size()const + { + return UINT_MAX; + } + // + // empty: + bool BOOST_REGEX_CALL empty()const + { + return (m_pimpl.get() ? 0 != m_pimpl->status() : true); + } + + size_type BOOST_REGEX_CALL mark_count()const + { + return (m_pimpl.get() ? m_pimpl->mark_count() : 0); + } + + int status()const + { + return (m_pimpl.get() ? m_pimpl->status() : regex_constants::error_empty); + } + + int BOOST_REGEX_CALL compare(const basic_regex& that) const + { + if(m_pimpl.get() == that.m_pimpl.get()) + return 0; + if(!m_pimpl.get()) + return -1; + if(!that.m_pimpl.get()) + return 1; + if(status() != that.status()) + return status() - that.status(); + if(flags() != that.flags()) + return flags() - that.flags(); + return str().compare(that.str()); + } + bool BOOST_REGEX_CALL operator==(const basic_regex& e)const + { + return compare(e) == 0; + } + bool BOOST_REGEX_CALL operator != (const basic_regex& e)const + { + return compare(e) != 0; + } + bool BOOST_REGEX_CALL operator<(const basic_regex& e)const + { + return compare(e) < 0; + } + bool BOOST_REGEX_CALL operator>(const basic_regex& e)const + { + return compare(e) > 0; + } + bool BOOST_REGEX_CALL operator<=(const basic_regex& e)const + { + return compare(e) <= 0; + } + bool BOOST_REGEX_CALL operator>=(const basic_regex& e)const + { + return compare(e) >= 0; + } + + // + // The following are deprecated as public interfaces + // but are available for compatibility with earlier versions. + const charT* BOOST_REGEX_CALL expression()const + { + return (m_pimpl.get() && !m_pimpl->status() ? m_pimpl->expression() : 0); + } + unsigned int BOOST_REGEX_CALL set_expression(const charT* p1, const charT* p2, flag_type f = regex_constants::normal) + { + assign(p1, p2, f | regex_constants::no_except); + return status(); + } + unsigned int BOOST_REGEX_CALL set_expression(const charT* p, flag_type f = regex_constants::normal) + { + assign(p, f | regex_constants::no_except); + return status(); + } + unsigned int BOOST_REGEX_CALL error_code()const + { + return status(); + } + // + // private access methods: + // + const re_detail::re_syntax_base* get_first_state()const + { + BOOST_ASSERT(0 != m_pimpl.get()); + return m_pimpl->get_first_state(); + } + unsigned get_restart_type()const + { + BOOST_ASSERT(0 != m_pimpl.get()); + return m_pimpl->get_restart_type(); + } + const unsigned char* get_map()const + { + BOOST_ASSERT(0 != m_pimpl.get()); + return m_pimpl->get_map(); + } + const ::boost::regex_traits_wrapper& get_traits()const + { + BOOST_ASSERT(0 != m_pimpl.get()); + return m_pimpl->get_traits(); + } + bool can_be_null()const + { + BOOST_ASSERT(0 != m_pimpl.get()); + return m_pimpl->can_be_null(); + } + const re_detail::regex_data& get_data()const + { + BOOST_ASSERT(0 != m_pimpl.get()); + return m_pimpl->get_data(); + } + +private: + shared_ptr > m_pimpl; +}; + +// +// out of line members; +// these are the only members that mutate the basic_regex object, +// and are designed to provide the strong exception guarentee +// (in the event of a throw, the state of the object remains unchanged). +// +template +basic_regex& basic_regex::do_assign(const charT* p1, + const charT* p2, + flag_type f) +{ + shared_ptr > temp; + if(!m_pimpl.get()) + { + temp = shared_ptr >(new re_detail::basic_regex_implementation()); + } + else + { + temp = shared_ptr >(new re_detail::basic_regex_implementation(m_pimpl->m_ptraits)); + } + temp->assign(p1, p2, f); + temp.swap(m_pimpl); + return *this; +} + +template +typename basic_regex::locale_type BOOST_REGEX_CALL basic_regex::imbue(locale_type l) +{ + shared_ptr > temp(new re_detail::basic_regex_implementation()); + locale_type result = temp->imbue(l); + temp.swap(m_pimpl); + return result; +} + +// +// non-members: +// +template +void swap(basic_regex& e1, basic_regex& e2) +{ + e1.swap(e2); +} + +#ifndef BOOST_NO_STD_LOCALE +template +std::basic_ostream& + operator << (std::basic_ostream& os, + const basic_regex& e) +{ + return (os << e.str()); +} +#else +template +std::ostream& operator << (std::ostream& os, const basic_regex& e) +{ + return (os << e.str()); +} +#endif + +// +// class reg_expression: +// this is provided for backwards compatibility only, +// it is deprecated, no not use! +// +#ifdef BOOST_REGEX_NO_FWD +template > +#else +template +#endif +class reg_expression : public basic_regex +{ +public: + typedef typename basic_regex::flag_type flag_type; + typedef typename basic_regex::size_type size_type; + explicit reg_expression(){} + explicit reg_expression(const charT* p, flag_type f = regex_constants::normal) + : basic_regex(p, f){} + reg_expression(const charT* p1, const charT* p2, flag_type f = regex_constants::normal) + : basic_regex(p1, p2, f){} + reg_expression(const charT* p, size_type len, flag_type f) + : basic_regex(p, len, f){} + reg_expression(const reg_expression& that) + : basic_regex(that) {} + ~reg_expression(){} + reg_expression& BOOST_REGEX_CALL operator=(const reg_expression& that) + { + return this->assign(that); + } + +#if !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__) + template + explicit reg_expression(const std::basic_string& p, flag_type f = regex_constants::normal) + : basic_regex(p, f) + { + } + + template + reg_expression(InputIterator arg_first, InputIterator arg_last, flag_type f = regex_constants::normal) + : basic_regex(arg_first, arg_last, f) { - std::basic_string a(arg_first, arg_last); - set_expression(a.data(), a.data() + a.size(), f | regex_constants::use_except); } template reg_expression& BOOST_REGEX_CALL operator=(const std::basic_string& p) { - set_expression(p.c_str(), p.c_str() + p.size(), regex_constants::normal | regex_constants::use_except); - return *this; - } - - template - reg_expression& BOOST_REGEX_CALL assign( - const std::basic_string& s, - flag_type f = regex_constants::normal) - { - set_expression(s.c_str(), s.c_str() + s.size(), f | regex_constants::use_except); - return *this; - } - - template - reg_expression& BOOST_REGEX_CALL assign(InputIterator arg_first, - InputIterator arg_last, - flag_type f = regex_constants::normal) - { - std::basic_string a(arg_first, arg_last); - set_expression(a.data(), a.data() + a.size(), f | regex_constants::use_except); + this->assign(p); return *this; } #else - unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string& p, flag_type f = regex_constants::normal) - { return set_expression(p.data(), p.data() + p.size(), f | regex_constants::use_except); } - - reg_expression(const std::basic_string& p, flag_type f = regex_constants::normal, const Allocator& a = Allocator()) - : data(a), pkmp(0) { set_expression(p, f | regex_constants::use_except); } + explicit reg_expression(const std::basic_string& p, flag_type f = regex_constants::normal) + : basic_regex(p, f) + { + } reg_expression& BOOST_REGEX_CALL operator=(const std::basic_string& p) - { - set_expression(p.c_str(), p.c_str() + p.size(), regex_constants::normal | regex_constants::use_except); - return *this; - } - - reg_expression& BOOST_REGEX_CALL assign( - const std::basic_string& s, - flag_type f = regex_constants::normal) - { - set_expression(s.c_str(), s.c_str() + s.size(), f | regex_constants::use_except); - return *this; - } - -#endif - - - // - // allocator access: - Allocator BOOST_REGEX_CALL get_allocator()const; - // - // locale: - locale_type BOOST_REGEX_CALL imbue(locale_type l){ return traits_inst.imbue(l); } - locale_type BOOST_REGEX_CALL getloc()const{ return traits_inst.getloc(); } - // - // getflags: - // retained for backwards compatibility only, the base class has "flags" - // member which is now the prefered name: - flag_type BOOST_REGEX_CALL getflags()const - { return this->flags(); } - // - // str: - std::basic_string BOOST_REGEX_CALL str()const - { - std::basic_string result; - if(this->error_code() == 0) - result = std::basic_string(_expression, _expression_len); - return result; - } - // - // begin, end: - const_iterator BOOST_REGEX_CALL begin()const - { return (this->error_code() ? 0 : _expression); } - const_iterator BOOST_REGEX_CALL end()const - { return (this->error_code() ? 0 : _expression + _expression_len); } - // - // swap: - void BOOST_REGEX_CALL swap(reg_expression&)throw(); - // - // size: - size_type BOOST_REGEX_CALL size()const - { return (this->error_code() ? 0 : _expression_len); } - // - // max_size: - size_type BOOST_REGEX_CALL max_size()const - { return UINT_MAX; } - // - // empty: - bool BOOST_REGEX_CALL empty()const - { return 0 != this->error_code(); } - - unsigned BOOST_REGEX_CALL mark_count()const { return (this->error_code() ? 0 : marks); } - int BOOST_REGEX_CALL compare(const reg_expression&) const; - bool BOOST_REGEX_CALL operator==(const reg_expression& e)const - { return compare(e) == 0; } - bool operator != (const reg_expression& e) - { return compare(e) != 0; } - bool BOOST_REGEX_CALL operator<(const reg_expression& e)const - { return compare(e) < 0; } - bool BOOST_REGEX_CALL operator>(const reg_expression& e)const - { return compare(e) > 0; } - bool BOOST_REGEX_CALL operator<=(const reg_expression& e)const - { return compare(e) <= 0; } - bool BOOST_REGEX_CALL operator>=(const reg_expression& e)const - { return compare(e) >= 0; } - - // - // The following are deprecated as public interfaces - // but are available for compatibility with earlier versions. - allocator_type BOOST_REGEX_CALL allocator()const; - const charT* BOOST_REGEX_CALL expression()const { return (this->error_code() ? 0 : _expression); } - unsigned int BOOST_REGEX_CALL set_expression(const charT* p, const charT* end, flag_type f = regex_constants::normal); - unsigned int BOOST_REGEX_CALL set_expression(const charT* p, flag_type f = regex_constants::normal) { return set_expression(p, p + traits_type::length(p), f); } - // - // this should be private but template friends don't work: - const traits_type& get_traits()const { return traits_inst; } - unsigned int BOOST_REGEX_CALL error_code()const - { - return error_code_; - } - -private: - traits_type traits_inst; // traits class in use - re_detail::raw_storage data; // our state machine - unsigned _restart_type; // search method to use - unsigned marks; // number of marked sub-expressions - int repeats; // number of repeats - unsigned char* startmap; // characters that can match the first state(s) in the machine - std::size_t _expression_len; // length of the expression - std::size_t _leading_len; // length of any leading literal - const charT* _leading_string; // leading literal string - std::size_t _leading_string_len; // and it's length - re_detail::kmp_info* pkmp; // pointer to Knuth Morris Pratt state machine when available - unsigned error_code_; // our current status - charT* _expression; // the expression we just compiled if any - - void BOOST_REGEX_CALL compile_maps(); - void BOOST_REGEX_CALL compile_map(re_detail::re_syntax_base* node, unsigned char* _map, unsigned int* pnull, unsigned char mask, re_detail::re_syntax_base* terminal = 0)const; - bool BOOST_REGEX_CALL probe_start(re_detail::re_syntax_base* node, charT c, re_detail::re_syntax_base* terminal)const; - bool BOOST_REGEX_CALL probe_start_null(re_detail::re_syntax_base* node, re_detail::re_syntax_base* terminal)const; - void BOOST_REGEX_CALL fixup_apply(re_detail::re_syntax_base* b, unsigned cbraces); - void BOOST_REGEX_CALL move_offsets(re_detail::re_syntax_base* j, unsigned size); - re_detail::re_syntax_base* BOOST_REGEX_CALL compile_set(const charT*& first, const charT* last); - re_detail::re_syntax_base* BOOST_REGEX_CALL compile_set_aux(re_detail::jstack& singles, re_detail::jstack& ranges, re_detail::jstack& classes, re_detail::jstack& equivalents, bool isnot, const re_detail::_narrow_type&); - re_detail::re_syntax_base* BOOST_REGEX_CALL compile_set_aux(re_detail::jstack& singles, re_detail::jstack& ranges, re_detail::jstack& classes, re_detail::jstack& equivalents, bool isnot, const re_detail::_wide_type&); - re_detail::re_syntax_base* BOOST_REGEX_CALL compile_set_simple(re_detail::re_syntax_base* dat, unsigned long cls, bool isnot = false); - unsigned int BOOST_REGEX_CALL parse_inner_set(const charT*& first, const charT* last); - - re_detail::re_syntax_base* BOOST_REGEX_CALL add_simple(re_detail::re_syntax_base* dat, re_detail::syntax_element_type type, unsigned int size = sizeof(re_detail::re_syntax_base)); - re_detail::re_syntax_base* BOOST_REGEX_CALL add_literal(re_detail::re_syntax_base* dat, charT c); - charT BOOST_REGEX_CALL parse_escape(const charT*& first, const charT* last); - void BOOST_REGEX_CALL parse_range(const charT*& first, const charT* last, unsigned& min, unsigned& max); - bool BOOST_REGEX_CALL skip_space(const charT*& first, const charT* last); - unsigned int BOOST_REGEX_CALL probe_restart(re_detail::re_syntax_base* dat); - unsigned int BOOST_REGEX_CALL fixup_leading_rep(re_detail::re_syntax_base* dat, re_detail::re_syntax_base* end); - void BOOST_REGEX_CALL fail(unsigned int err); - -protected: - static int BOOST_REGEX_CALL repeat_count(const reg_expression& e) - { return e.repeats; } - static unsigned int BOOST_REGEX_CALL restart_type(const reg_expression& e) - { return e._restart_type; } - static const re_detail::re_syntax_base* BOOST_REGEX_CALL first(const reg_expression& e) - { return (const re_detail::re_syntax_base*)e.data.data(); } - static const unsigned char* BOOST_REGEX_CALL get_map(const reg_expression& e) - { return e.startmap; } - static std::size_t BOOST_REGEX_CALL leading_length(const reg_expression& e) - { return e._leading_len; } - static const re_detail::kmp_info* get_kmp(const reg_expression& e) - { return e.pkmp; } - static bool BOOST_REGEX_CALL can_start(charT c, const unsigned char* _map, unsigned char mask, const re_detail::_wide_type&); - static bool BOOST_REGEX_CALL can_start(charT c, const unsigned char* _map, unsigned char mask, const re_detail::_narrow_type&); -}; - -template -void swap(reg_expression& a, reg_expression& b) -{ - a.swap(b); -} - -#ifndef BOOST_NO_STD_LOCALE -template -std::basic_ostream& - operator << (std::basic_ostream& os, - const reg_expression& e) -{ - return (os << e.str()); -} -#else -template -std::ostream& operator << (std::ostream& os, const reg_expression& e) -{ - return (os << e.str()); -} -#endif - -// -// We want to rename reg_expression basic_regex but maintain -// backwards compatibility, so class basic_regex is just a thin -// wrapper around reg_expression: -// -#ifdef BOOST_REGEX_NO_FWD -template , class Allocator = BOOST_DEFAULT_ALLOCATOR(charT) > -#else -template -#endif -class basic_regex : public reg_expression -{ -public: - typedef typename reg_expression::flag_type flag_type; - typedef typename reg_expression::size_type size_type; - explicit basic_regex(const Allocator& a = Allocator()) - : reg_expression(a){} - explicit basic_regex(const charT* p, flag_type f = regex_constants::normal, const Allocator& a = Allocator()) - : reg_expression(p,f,a){} - basic_regex(const charT* p1, const charT* p2, flag_type f = regex_constants::normal, const Allocator& a = Allocator()) - : reg_expression(p1,p2,f,a){} - basic_regex(const charT* p, size_type len, flag_type f, const Allocator& a = Allocator()) - : reg_expression(p,len,f,a){} - basic_regex(const basic_regex& that) - : reg_expression(that){} - ~basic_regex(){} - basic_regex& BOOST_REGEX_CALL operator=(const basic_regex& that) - { - this->assign(that); - return *this; - } - basic_regex& BOOST_REGEX_CALL operator=(const charT* ptr) - { - this->assign(ptr); - return *this; - } -#if !defined(BOOST_NO_MEMBER_TEMPLATES) && !(defined(__IBMCPP__) && (__IBMCPP__ <= 502)) - template - explicit basic_regex(const std::basic_string& p, flag_type f = regex_constants::normal, const Allocator& a = Allocator()) - : reg_expression(p,f,a){} - - template - basic_regex(I arg_first, I arg_last, flag_type f = regex_constants::normal, const Allocator& al = Allocator()) - : reg_expression(arg_first, arg_last, f, al){} - - template - basic_regex& BOOST_REGEX_CALL operator=(const std::basic_string& p) - { - this->assign(p); - return *this; - } -#else - basic_regex(const std::basic_string& p, flag_type f = regex_constants::normal, const Allocator& a = Allocator()) - : reg_expression(p,f,a){} - - basic_regex& BOOST_REGEX_CALL operator=(const std::basic_string& p) { this->assign(p); return *this; } #endif + }; #ifdef BOOST_MSVC diff --git a/boost/boost/regex/v4/basic_regex_creator.hpp b/boost/boost/regex/v4/basic_regex_creator.hpp new file mode 100644 index 0000000000..a45b382c0e --- /dev/null +++ b/boost/boost/regex/v4/basic_regex_creator.hpp @@ -0,0 +1,1289 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE basic_regex_creator.cpp + * VERSION see + * DESCRIPTION: Declares template class basic_regex_creator which fills in + * the data members of a regex_data object. + */ + +#ifndef BOOST_REGEX_V4_BASIC_REGEX_CREATOR_HPP +#define BOOST_REGEX_V4_BASIC_REGEX_CREATOR_HPP + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +namespace boost{ + +namespace re_detail{ + +template +struct digraph : public std::pair +{ + digraph() : std::pair(0, 0){} + digraph(charT c1) : std::pair(c1, 0){} + digraph(charT c1, charT c2) : std::pair(c1, c2) + {} +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) + digraph(const digraph& d) : std::pair(d.first, d.second){} +#endif + template + digraph(const Seq& s) : std::pair() + { + BOOST_ASSERT(s.size() <= 2); + BOOST_ASSERT(s.size()); + this->first = s[0]; + this->second = (s.size() > 1) ? s[1] : 0; + } +}; + +template +class basic_char_set +{ +public: + typedef digraph digraph_type; + typedef typename traits::string_type string_type; + typedef typename traits::char_class_type mask_type; + + basic_char_set() + { + m_negate = false; + m_has_digraphs = false; + m_classes = 0; + m_negated_classes = 0; + m_empty = true; + } + + void add_single(const digraph_type& s) + { + m_singles.insert(m_singles.end(), s); + if(s.second) + m_has_digraphs = true; + m_empty = false; + } + void add_range(const digraph_type& first, const digraph_type& end) + { + m_ranges.insert(m_ranges.end(), first); + m_ranges.insert(m_ranges.end(), end); + if(first.second) + { + m_has_digraphs = true; + add_single(first); + } + if(end.second) + { + m_has_digraphs = true; + add_single(end); + } + m_empty = false; + } + void add_class(mask_type m) + { + m_classes |= m; + m_empty = false; + } + void add_negated_class(mask_type m) + { + m_negated_classes |= m; + m_empty = false; + } + void add_equivalent(const digraph_type& s) + { + m_equivalents.insert(m_equivalents.end(), s); + if(s.second) + { + m_has_digraphs = true; + add_single(s); + } + m_empty = false; + } + void negate() + { + m_negate = true; + //m_empty = false; + } + + // + // accessor functions: + // + bool has_digraphs()const + { + return m_has_digraphs; + } + bool is_negated()const + { + return m_negate; + } + typedef typename std::vector::const_iterator list_iterator; + list_iterator singles_begin()const + { + return m_singles.begin(); + } + list_iterator singles_end()const + { + return m_singles.end(); + } + list_iterator ranges_begin()const + { + return m_ranges.begin(); + } + list_iterator ranges_end()const + { + return m_ranges.end(); + } + list_iterator equivalents_begin()const + { + return m_equivalents.begin(); + } + list_iterator equivalents_end()const + { + return m_equivalents.end(); + } + mask_type classes()const + { + return m_classes; + } + mask_type negated_classes()const + { + return m_negated_classes; + } + bool empty()const + { + return m_empty; + } +private: + std::vector m_singles; // a list of single characters to match + std::vector m_ranges; // a list of end points of our ranges + bool m_negate; // true if the set is to be negated + bool m_has_digraphs; // true if we have digraphs present + mask_type m_classes; // character classes to match + mask_type m_negated_classes; // negated character classes to match + bool m_empty; // whether we've added anything yet + std::vector m_equivalents; // a list of equivalence classes +}; + +template +class basic_regex_creator +{ +public: + basic_regex_creator(regex_data* data); + std::ptrdiff_t getoffset(void* addr) + { + return getoffset(addr, m_pdata->m_data.data()); + } + std::ptrdiff_t getoffset(const void* addr, const void* base) + { + return static_cast(addr) - static_cast(base); + } + re_syntax_base* getaddress(std::ptrdiff_t off) + { + return getaddress(off, m_pdata->m_data.data()); + } + re_syntax_base* getaddress(std::ptrdiff_t off, void* base) + { + return static_cast(static_cast(static_cast(base) + off)); + } + void init(unsigned flags) + { + m_pdata->m_flags = flags; + m_icase = flags & regex_constants::icase; + } + regbase::flag_type flags() + { + return m_pdata->m_flags; + } + void flags(regbase::flag_type f) + { + m_pdata->m_flags = f; + if(m_icase != static_cast(f & regbase::icase)) + { + m_icase = static_cast(f & regbase::icase); + } + } + re_syntax_base* append_state(syntax_element_type t, std::size_t s = sizeof(re_syntax_base)); + re_syntax_base* insert_state(std::ptrdiff_t pos, syntax_element_type t, std::size_t s = sizeof(re_syntax_base)); + re_literal* append_literal(charT c); + re_syntax_base* append_set(const basic_char_set& char_set); + re_syntax_base* append_set(const basic_char_set& char_set, mpl::false_*); + re_syntax_base* append_set(const basic_char_set& char_set, mpl::true_*); + void finalize(const charT* p1, const charT* p2); +protected: + regex_data* m_pdata; // pointer to the basic_regex_data struct we are filling in + const ::boost::regex_traits_wrapper& + m_traits; // convenience reference to traits class + re_syntax_base* m_last_state; // the last state we added + bool m_icase; // true for case insensitive matches + unsigned m_repeater_id; // the id of the next repeater + bool m_has_backrefs; // true if there are actually any backrefs + unsigned m_backrefs; // bitmask of permitted backrefs + boost::uintmax_t m_bad_repeats; // bitmask of repeats we can't deduce a startmap for; + typename traits::char_class_type m_word_mask; // mask used to determine if a character is a word character + typename traits::char_class_type m_mask_space; // mask used to determine if a character is a word character + typename traits::char_class_type m_lower_mask; // mask used to determine if a character is a lowercase character + typename traits::char_class_type m_upper_mask; // mask used to determine if a character is an uppercase character + typename traits::char_class_type m_alpha_mask; // mask used to determine if a character is an alphabetic character +private: + basic_regex_creator& operator=(const basic_regex_creator&); + basic_regex_creator(const basic_regex_creator&); + + void fixup_pointers(re_syntax_base* state); + void create_startmaps(re_syntax_base* state); + int calculate_backstep(re_syntax_base* state); + void create_startmap(re_syntax_base* state, unsigned char* l_map, unsigned int* pnull, unsigned char mask); + unsigned get_restart_type(re_syntax_base* state); + void set_all_masks(unsigned char* bits, unsigned char); + bool is_bad_repeat(re_syntax_base* pt); + void set_bad_repeat(re_syntax_base* pt); + syntax_element_type get_repeat_type(re_syntax_base* state); + void probe_leading_repeat(re_syntax_base* state); +}; + +template +basic_regex_creator::basic_regex_creator(regex_data* data) + : m_pdata(data), m_traits(*(data->m_ptraits)), m_last_state(0), m_repeater_id(0), m_has_backrefs(false), m_backrefs(0) +{ + m_pdata->m_data.clear(); + m_pdata->m_status = ::boost::regex_constants::error_ok; + static const charT w = 'w'; + static const charT s = 's'; + static const charT l[5] = { 'l', 'o', 'w', 'e', 'r', }; + static const charT u[5] = { 'u', 'p', 'p', 'e', 'r', }; + static const charT a[5] = { 'a', 'l', 'p', 'h', 'a', }; + m_word_mask = m_traits.lookup_classname(&w, &w +1); + m_mask_space = m_traits.lookup_classname(&s, &s +1); + m_lower_mask = m_traits.lookup_classname(l, l + 5); + m_upper_mask = m_traits.lookup_classname(u, u + 5); + m_alpha_mask = m_traits.lookup_classname(a, a + 5); + BOOST_ASSERT(m_word_mask != 0); + BOOST_ASSERT(m_mask_space != 0); + BOOST_ASSERT(m_lower_mask != 0); + BOOST_ASSERT(m_upper_mask != 0); + BOOST_ASSERT(m_alpha_mask != 0); +} + +template +re_syntax_base* basic_regex_creator::append_state(syntax_element_type t, std::size_t s) +{ + // if the state is a backref then make a note of it: + if(t == syntax_element_backref) + this->m_has_backrefs = true; + // append a new state, start by aligning our last one: + m_pdata->m_data.align(); + // set the offset to the next state in our last one: + if(m_last_state) + m_last_state->next.i = m_pdata->m_data.size() - getoffset(m_last_state); + // now actually extent our data: + m_last_state = static_cast(m_pdata->m_data.extend(s)); + // fill in boilerplate options in the new state: + m_last_state->next.i = 0; + m_last_state->type = t; + return m_last_state; +} + +template +re_syntax_base* basic_regex_creator::insert_state(std::ptrdiff_t pos, syntax_element_type t, std::size_t s) +{ + // append a new state, start by aligning our last one: + m_pdata->m_data.align(); + // set the offset to the next state in our last one: + if(m_last_state) + m_last_state->next.i = m_pdata->m_data.size() - getoffset(m_last_state); + // remember the last state position: + std::ptrdiff_t off = getoffset(m_last_state) + s; + // now actually insert our data: + re_syntax_base* new_state = static_cast(m_pdata->m_data.insert(pos, s)); + // fill in boilerplate options in the new state: + new_state->next.i = s; + new_state->type = t; + m_last_state = getaddress(off); + return new_state; +} + +template +re_literal* basic_regex_creator::append_literal(charT c) +{ + re_literal* result; + // start by seeing if we have an existing re_literal we can extend: + if((0 == m_last_state) || (m_last_state->type != syntax_element_literal)) + { + // no existing re_literal, create a new one: + result = static_cast(append_state(syntax_element_literal, sizeof(re_literal) + sizeof(charT))); + result->length = 1; + *static_cast(static_cast(result+1)) = m_traits.translate(c, m_icase); + } + else + { + // we have an existing re_literal, extend it: + std::ptrdiff_t off = getoffset(m_last_state); + m_pdata->m_data.extend(sizeof(charT)); + m_last_state = result = static_cast(getaddress(off)); + charT* characters = static_cast(static_cast(result+1)); + characters[result->length] = m_traits.translate(c, m_icase); + ++(result->length); + } + return result; +} + +template +inline re_syntax_base* basic_regex_creator::append_set( + const basic_char_set& char_set) +{ + typedef mpl::bool_< (sizeof(charT) == 1) > truth_type; + return char_set.has_digraphs() + ? append_set(char_set, static_cast(0)) + : append_set(char_set, static_cast(0)); +} + +template +re_syntax_base* basic_regex_creator::append_set( + const basic_char_set& char_set, mpl::false_*) +{ + typedef typename traits::string_type string_type; + typedef typename basic_char_set::list_iterator item_iterator; + typedef typename traits::char_class_type mask_type; + + re_set_long* result = static_cast*>(append_state(syntax_element_long_set, sizeof(re_set_long))); + // + // fill in the basics: + // + result->csingles = static_cast(::boost::re_detail::distance(char_set.singles_begin(), char_set.singles_end())); + result->cranges = static_cast(::boost::re_detail::distance(char_set.ranges_begin(), char_set.ranges_end())) / 2; + result->cequivalents = static_cast(::boost::re_detail::distance(char_set.equivalents_begin(), char_set.equivalents_end())); + result->cclasses = char_set.classes(); + result->cnclasses = char_set.negated_classes(); + if(flags() & regbase::icase) + { + // adjust classes as needed: + if(((result->cclasses & m_lower_mask) == m_lower_mask) || ((result->cclasses & m_upper_mask) == m_upper_mask)) + result->cclasses |= m_alpha_mask; + if(((result->cnclasses & m_lower_mask) == m_lower_mask) || ((result->cnclasses & m_upper_mask) == m_upper_mask)) + result->cnclasses |= m_alpha_mask; + } + + result->isnot = char_set.is_negated(); + result->singleton = !char_set.has_digraphs(); + // + // remember where the state is for later: + // + std::ptrdiff_t offset = getoffset(result); + // + // now extend with all the singles: + // + item_iterator first, last; + first = char_set.singles_begin(); + last = char_set.singles_end(); + while(first != last) + { + charT* p = static_cast(this->m_pdata->m_data.extend(sizeof(charT) * (first->second ? 3 : 2))); + p[0] = m_traits.translate(first->first, m_icase); + if(first->second) + { + p[1] = m_traits.translate(first->second, m_icase); + p[2] = 0; + } + else + p[1] = 0; + ++first; + } + // + // now extend with all the ranges: + // + first = char_set.ranges_begin(); + last = char_set.ranges_end(); + while(first != last) + { + // first grab the endpoints of the range: + digraph c1 = *first; + c1.first = this->m_traits.translate(c1.first, this->m_icase); + c1.second = this->m_traits.translate(c1.second, this->m_icase); + ++first; + digraph c2 = *first; + c2.first = this->m_traits.translate(c2.first, this->m_icase); + c2.second = this->m_traits.translate(c2.second, this->m_icase); + ++first; + string_type s1, s2; + // different actions now depending upon whether collation is turned on: + if(flags() & regex_constants::collate) + { + // we need to transform our range into sort keys: +#if BOOST_WORKAROUND(__GNUC__, < 3) + string_type in(3, charT(0)); + in[0] = c1.first; + in[1] = c1.second; + s1 = this->m_traits.transform(in.c_str(), (in[1] ? in.c_str()+2 : in.c_str()+1)); + in[0] = c2.first; + in[1] = c2.second; + s2 = this->m_traits.transform(in.c_str(), (in[1] ? in.c_str()+2 : in.c_str()+1)); +#else + charT a1[3] = { c1.first, c1.second, charT(0), }; + charT a2[3] = { c2.first, c2.second, charT(0), }; + s1 = this->m_traits.transform(a1, (a1[1] ? a1+2 : a1+1)); + s2 = this->m_traits.transform(a2, (a2[1] ? a2+2 : a2+1)); +#endif + if(s1.size() == 0) + s1 = string_type(1, charT(0)); + if(s2.size() == 0) + s2 = string_type(1, charT(0)); + } + else + { + if(c1.second) + { + s1.insert(s1.end(), c1.first); + s1.insert(s1.end(), c1.second); + } + else + s1 = string_type(1, c1.first); + if(c2.second) + { + s2.insert(s2.end(), c2.first); + s2.insert(s2.end(), c2.second); + } + else + s2.insert(s2.end(), c2.first); + } + if(s1 > s2) + { + // Oops error: + return 0; + } + charT* p = static_cast(this->m_pdata->m_data.extend(sizeof(charT) * (s1.size() + s2.size() + 2) ) ); + re_detail::copy(s1.begin(), s1.end(), p); + p[s1.size()] = charT(0); + p += s1.size() + 1; + re_detail::copy(s2.begin(), s2.end(), p); + p[s2.size()] = charT(0); + } + // + // now process the equivalence classes: + // + first = char_set.equivalents_begin(); + last = char_set.equivalents_end(); + while(first != last) + { + string_type s; + if(first->second) + { +#if BOOST_WORKAROUND(__GNUC__, < 3) + string_type in(3, charT(0)); + in[0] = first->first; + in[1] = first->second; + s = m_traits.transform_primary(in.c_str(), in.c_str()+2); +#else + charT cs[3] = { first->first, first->second, charT(0), }; + s = m_traits.transform_primary(cs, cs+2); +#endif + } + else + s = m_traits.transform_primary(&first->first, &first->first+1); + if(s.empty()) + return 0; // invalid or unsupported equivalence class + charT* p = static_cast(this->m_pdata->m_data.extend(sizeof(charT) * (s.size()+1) ) ); + re_detail::copy(s.begin(), s.end(), p); + p[s.size()] = charT(0); + ++first; + } + // + // finally reset the address of our last state: + // + m_last_state = result = static_cast*>(getaddress(offset)); + return result; +} + +namespace{ + +template +inline bool char_less(T t1, T t2) +{ + return t1 < t2; +} +template<> +inline bool char_less(char t1, char t2) +{ + return static_cast(t1) < static_cast(t2); +} +template<> +inline bool char_less(signed char t1, signed char t2) +{ + return static_cast(t1) < static_cast(t2); +} +} + +template +re_syntax_base* basic_regex_creator::append_set( + const basic_char_set& char_set, mpl::true_*) +{ + typedef typename traits::string_type string_type; + typedef typename basic_char_set::list_iterator item_iterator; + + re_set* result = static_cast(append_state(syntax_element_set, sizeof(re_set))); + bool negate = char_set.is_negated(); + std::memset(result->_map, 0, sizeof(result->_map)); + // + // handle singles first: + // + item_iterator first, last; + first = char_set.singles_begin(); + last = char_set.singles_end(); + while(first != last) + { + for(unsigned int i = 0; i < (1 << CHAR_BIT); ++i) + { + if(this->m_traits.translate(static_cast(i), this->m_icase) + == this->m_traits.translate(first->first, this->m_icase)) + result->_map[i] = true; + } + ++first; + } + // + // OK now handle ranges: + // + first = char_set.ranges_begin(); + last = char_set.ranges_end(); + while(first != last) + { + // first grab the endpoints of the range: + charT c1 = this->m_traits.translate(first->first, this->m_icase); + ++first; + charT c2 = this->m_traits.translate(first->first, this->m_icase); + ++first; + // different actions now depending upon whether collation is turned on: + if(flags() & regex_constants::collate) + { + // we need to transform our range into sort keys: + charT c3[2] = { c1, charT(0), }; + string_type s1 = this->m_traits.transform(c3, c3+1); + c3[0] = c2; + string_type s2 = this->m_traits.transform(c3, c3+1); + if(s1 > s2) + { + // Oops error: + return 0; + } + for(unsigned i = 0; i < (1u << CHAR_BIT); ++i) + { + charT c3[2] = { static_cast(i), charT(0), }; + string_type s3 = this->m_traits.transform(c3, c3 +1); + if((s1 <= s3) && (s3 <= s2)) + result->_map[i] = true; + } + } + else + { + if(char_less(c2, c1)) + { + // Oops error: + return 0; + } + // everything in range matches: + std::memset(result->_map + static_cast(c1), true, 1 + static_cast(c2) - static_cast(c1)); + } + } + // + // and now the classes: + // + typedef typename traits::char_class_type mask_type; + mask_type m = char_set.classes(); + if(flags() & regbase::icase) + { + // adjust m as needed: + if(((m & m_lower_mask) == m_lower_mask) || ((m & m_upper_mask) == m_upper_mask)) + m |= m_alpha_mask; + } + if(m != 0) + { + for(unsigned i = 0; i < (1u << CHAR_BIT); ++i) + { + if(this->m_traits.isctype(static_cast(i), m)) + result->_map[i] = true; + } + } + // + // and now the negated classes: + // + m = char_set.negated_classes(); + if(flags() & regbase::icase) + { + // adjust m as needed: + if(((m & m_lower_mask) == m_lower_mask) || ((m & m_upper_mask) == m_upper_mask)) + m |= m_alpha_mask; + } + if(m != 0) + { + for(unsigned i = 0; i < (1u << CHAR_BIT); ++i) + { + if(0 == this->m_traits.isctype(static_cast(i), m)) + result->_map[i] = true; + } + } + // + // now process the equivalence classes: + // + first = char_set.equivalents_begin(); + last = char_set.equivalents_end(); + while(first != last) + { + string_type s; + BOOST_ASSERT(static_cast(0) == first->second); + s = m_traits.transform_primary(&first->first, &first->first+1); + if(s.empty()) + return 0; // invalid or unsupported equivalence class + for(unsigned i = 0; i < (1u << CHAR_BIT); ++i) + { + charT c[2] = { (static_cast(i)), charT(0), }; + string_type s2 = this->m_traits.transform_primary(c, c+1); + if(s == s2) + result->_map[i] = true; + } + ++first; + } + if(negate) + { + for(unsigned i = 0; i < (1u << CHAR_BIT); ++i) + { + result->_map[i] = !(result->_map[i]); + } + } + return result; +} + +template +void basic_regex_creator::finalize(const charT* p1, const charT* p2) +{ + // we've added all the states we need, now finish things off. + // start by adding a terminating state: + append_state(syntax_element_match); + // extend storage to store original expression: + std::ptrdiff_t len = p2 - p1; + m_pdata->m_expression_len = len; + charT* ps = static_cast(m_pdata->m_data.extend(sizeof(charT) * (1 + (p2 - p1)))); + m_pdata->m_expression = ps; + re_detail::copy(p1, p2, ps); + ps[p2 - p1] = 0; + // fill in our other data... + // successful parsing implies a zero status: + m_pdata->m_status = 0; + // get the first state of the machine: + m_pdata->m_first_state = static_cast(m_pdata->m_data.data()); + // fixup pointers in the machine: + fixup_pointers(m_pdata->m_first_state); + // create nested startmaps: + create_startmaps(m_pdata->m_first_state); + // create main startmap: + std::memset(m_pdata->m_startmap, 0, sizeof(m_pdata->m_startmap)); + m_pdata->m_can_be_null = 0; + + m_bad_repeats = 0; + create_startmap(m_pdata->m_first_state, m_pdata->m_startmap, &(m_pdata->m_can_be_null), mask_all); + // get the restart type: + m_pdata->m_restart_type = get_restart_type(m_pdata->m_first_state); + // optimise a leading repeat if there is one: + probe_leading_repeat(m_pdata->m_first_state); +} + +template +void basic_regex_creator::fixup_pointers(re_syntax_base* state) +{ + while(state) + { + switch(state->type) + { + case syntax_element_rep: + case syntax_element_dot_rep: + case syntax_element_char_rep: + case syntax_element_short_set_rep: + case syntax_element_long_set_rep: + // set the id of this repeat: + static_cast(state)->id = m_repeater_id++; + // fall through: + case syntax_element_alt: + std::memset(static_cast(state)->_map, 0, sizeof(static_cast(state)->_map)); + static_cast(state)->can_be_null = 0; + // fall through: + case syntax_element_jump: + static_cast(state)->alt.p = getaddress(static_cast(state)->alt.i, state); + // fall through again: + default: + if(state->next.i) + state->next.p = getaddress(state->next.i, state); + else + state->next.p = 0; + } + state = state->next.p; + } +} + +template +void basic_regex_creator::create_startmaps(re_syntax_base* state) +{ + // non-recursive implementation: + // create the last map in the machine first, so that earlier maps + // can make use of the result... + // + // This was originally a recursive implementation, but that caused stack + // overflows with complex expressions on small stacks (think COM+). + + // start by saving the case setting: + bool l_icase = m_icase; + std::vector > v; + + while(state) + { + switch(state->type) + { + case syntax_element_toggle_case: + // we need to track case changes here: + m_icase = static_cast(state)->icase; + state = state->next.p; + continue; + case syntax_element_alt: + case syntax_element_rep: + case syntax_element_dot_rep: + case syntax_element_char_rep: + case syntax_element_short_set_rep: + case syntax_element_long_set_rep: + // just push the state onto our stack for now: + v.push_back(std::pair(m_icase, state)); + state = state->next.p; + break; + case syntax_element_backstep: + // we need to calculate how big the backstep is: + static_cast(state)->index + = this->calculate_backstep(state->next.p); + if(static_cast(state)->index < 0) + { + // Oops error: + if(0 == this->m_pdata->m_status) // update the error code if not already set + this->m_pdata->m_status = boost::regex_constants::error_bad_pattern; + // + // clear the expression, we should be empty: + // + this->m_pdata->m_expression = 0; + this->m_pdata->m_expression_len = 0; + // + // and throw if required: + // + if(0 == (this->flags() & regex_constants::no_except)) + { + std::string message = this->m_pdata->m_ptraits->error_string(boost::regex_constants::error_bad_pattern); + boost::regex_error e(message, boost::regex_constants::error_bad_pattern, 0); + e.raise(); + } + } + // fall through: + default: + state = state->next.p; + } + } + // now work through our list, building all the maps as we go: + while(v.size()) + { + const std::pair& p = v.back(); + m_icase = p.first; + state = p.second; + v.pop_back(); + + // Build maps: + create_startmap(state->next.p, static_cast(state)->_map, &static_cast(state)->can_be_null, mask_take); + m_bad_repeats = 0; + create_startmap(static_cast(state)->alt.p, static_cast(state)->_map, &static_cast(state)->can_be_null, mask_skip); + // adjust the type of the state to allow for faster matching: + state->type = this->get_repeat_type(state); + } + // restore case sensitivity: + m_icase = l_icase; +} + +template +int basic_regex_creator::calculate_backstep(re_syntax_base* state) +{ + typedef typename traits::char_class_type mask_type; + int result = 0; + while(state) + { + switch(state->type) + { + case syntax_element_startmark: + if((static_cast(state)->index == -1) + || (static_cast(state)->index == -2)) + { + state = static_cast(state->next.p)->alt.p->next.p; + continue; + } + else if(static_cast(state)->index == -3) + { + state = state->next.p->next.p; + continue; + } + break; + case syntax_element_endmark: + if((static_cast(state)->index == -1) + || (static_cast(state)->index == -2)) + return result; + break; + case syntax_element_literal: + result += static_cast(state)->length; + break; + case syntax_element_wild: + case syntax_element_set: + result += 1; + break; + case syntax_element_dot_rep: + case syntax_element_char_rep: + case syntax_element_short_set_rep: + case syntax_element_backref: + case syntax_element_rep: + case syntax_element_combining: + case syntax_element_long_set_rep: + case syntax_element_backstep: + { + re_repeat* rep = static_cast(state); + // adjust the type of the state to allow for faster matching: + state->type = this->get_repeat_type(state); + if((state->type == syntax_element_dot_rep) + || (state->type == syntax_element_char_rep) + || (state->type == syntax_element_short_set_rep)) + { + if(rep->max != rep->min) + return -1; + result += static_cast(rep->min); + state = rep->alt.p; + continue; + } + else if((state->type == syntax_element_long_set_rep)) + { + BOOST_ASSERT(rep->next.p->type == syntax_element_long_set); + if(static_cast*>(rep->next.p)->singleton == 0) + return -1; + if(rep->max != rep->min) + return -1; + result += static_cast(rep->min); + state = rep->alt.p; + continue; + } + } + return -1; + case syntax_element_long_set: + if(static_cast*>(state)->singleton == 0) + return -1; + result += 1; + break; + case syntax_element_jump: + state = static_cast(state)->alt.p; + continue; + default: + break; + } + state = state->next.p; + } + return -1; +} + +template +void basic_regex_creator::create_startmap(re_syntax_base* state, unsigned char* l_map, unsigned int* pnull, unsigned char mask) +{ + int not_last_jump = 1; + + // track case sensitivity: + bool l_icase = m_icase; + + while(state) + { + switch(state->type) + { + case syntax_element_toggle_case: + l_icase = static_cast(state)->icase; + state = state->next.p; + break; + case syntax_element_literal: + { + // don't set anything in *pnull, set each element in l_map + // that could match the first character in the literal: + if(l_map) + { + l_map[0] |= mask_init; + charT first_char = *static_cast(static_cast(static_cast(state) + 1)); + for(unsigned int i = 0; i < (1u << CHAR_BIT); ++i) + { + if(m_traits.translate(static_cast(i), l_icase) == first_char) + l_map[i] |= mask; + } + } + return; + } + case syntax_element_end_line: + { + // next character must be a line separator (if there is one): + if(l_map) + { + l_map[0] |= mask_init; + l_map['\n'] |= mask; + l_map['\r'] |= mask; + l_map['\f'] |= mask; + l_map[0x85] |= mask; + } + // now figure out if we can match a NULL string at this point: + if(pnull) + create_startmap(state->next.p, 0, pnull, mask); + return; + } + case syntax_element_backref: + // can be null, and any character can match: + if(pnull) + *pnull |= mask; + // fall through: + case syntax_element_wild: + { + // can't be null, any character can match: + set_all_masks(l_map, mask); + return; + } + case syntax_element_match: + { + // must be null, any character can match: + set_all_masks(l_map, mask); + if(pnull) + *pnull |= mask; + return; + } + case syntax_element_word_start: + { + // recurse, then AND with all the word characters: + create_startmap(state->next.p, l_map, pnull, mask); + if(l_map) + { + l_map[0] |= mask_init; + for(unsigned int i = 0; i < (1u << CHAR_BIT); ++i) + { + if(!m_traits.isctype(static_cast(i), m_word_mask)) + l_map[i] &= static_cast(~mask); + } + } + return; + } + case syntax_element_word_end: + { + // recurse, then AND with all the word characters: + create_startmap(state->next.p, l_map, pnull, mask); + if(l_map) + { + l_map[0] |= mask_init; + for(unsigned int i = 0; i < (1u << CHAR_BIT); ++i) + { + if(m_traits.isctype(static_cast(i), m_word_mask)) + l_map[i] &= static_cast(~mask); + } + } + return; + } + case syntax_element_buffer_end: + { + // we *must be null* : + if(pnull) + *pnull |= mask; + return; + } + case syntax_element_long_set: + if(l_map) + { + typedef typename traits::char_class_type mask_type; + if(static_cast*>(state)->singleton) + { + l_map[0] |= mask_init; + for(unsigned int i = 0; i < (1u << CHAR_BIT); ++i) + { + charT c = static_cast(i); + if(&c != re_is_set_member(&c, &c + 1, static_cast*>(state), *m_pdata, m_icase)) + l_map[i] |= mask; + } + } + else + set_all_masks(l_map, mask); + } + return; + case syntax_element_set: + if(l_map) + { + l_map[0] |= mask_init; + for(unsigned int i = 0; i < (1u << CHAR_BIT); ++i) + { + if(static_cast(state)->_map[ + static_cast(m_traits.translate(static_cast(i), l_icase))]) + l_map[i] |= mask; + } + } + return; + case syntax_element_jump: + // take the jump: + state = static_cast(state)->alt.p; + not_last_jump = -1; + break; + case syntax_element_alt: + case syntax_element_rep: + case syntax_element_dot_rep: + case syntax_element_char_rep: + case syntax_element_short_set_rep: + case syntax_element_long_set_rep: + { + re_alt* rep = static_cast(state); + if(rep->_map[0] & mask_init) + { + if(l_map) + { + // copy previous results: + l_map[0] |= mask_init; + for(unsigned int i = 0; i <= UCHAR_MAX; ++i) + { + if(rep->_map[i] & mask_any) + l_map[i] |= mask; + } + } + if(pnull) + { + if(rep->can_be_null & mask_any) + *pnull |= mask; + } + } + else + { + // we haven't created a startmap for this alternative yet + // so take the union of the two options: + if(is_bad_repeat(state)) + { + set_all_masks(l_map, mask); + return; + } + set_bad_repeat(state); + create_startmap(state->next.p, l_map, pnull, mask); + if((state->type == syntax_element_alt) + || (static_cast(state)->min == 0) + || (not_last_jump == 0)) + create_startmap(rep->alt.p, l_map, pnull, mask); + } + } + return; + case syntax_element_soft_buffer_end: + // match newline or null: + if(l_map) + { + l_map[0] |= mask_init; + l_map['\n'] |= mask; + l_map['\r'] |= mask; + } + if(pnull) + *pnull |= mask; + return; + case syntax_element_endmark: + // need to handle independent subs as a special case: + if(static_cast(state)->index < 0) + { + // can be null, any character can match: + set_all_masks(l_map, mask); + if(pnull) + *pnull |= mask; + return; + } + else + { + state = state->next.p; + break; + } + + case syntax_element_startmark: + // need to handle independent subs as a special case: + if(static_cast(state)->index == -3) + { + state = state->next.p->next.p; + break; + } + // otherwise fall through: + default: + state = state->next.p; + } + ++not_last_jump; + } +} + +template +unsigned basic_regex_creator::get_restart_type(re_syntax_base* state) +{ + // + // find out how the machine starts, so we can optimise the search: + // + while(state) + { + switch(state->type) + { + case syntax_element_startmark: + case syntax_element_endmark: + state = state->next.p; + continue; + case syntax_element_start_line: + return regbase::restart_line; + case syntax_element_word_start: + return regbase::restart_word; + case syntax_element_buffer_start: + return regbase::restart_buf; + case syntax_element_restart_continue: + return regbase::restart_continue; + default: + state = 0; + continue; + } + } + return regbase::restart_any; +} + +template +void basic_regex_creator::set_all_masks(unsigned char* bits, unsigned char mask) +{ + // + // set mask in all of bits elements, + // if bits[0] has mask_init not set then we can + // optimise this to a call to memset: + // + if(bits) + { + if(bits[0] == 0) + (std::memset)(bits, mask, 1u << CHAR_BIT); + else + { + for(unsigned i = 0; i < (1u << CHAR_BIT); ++i) + bits[i] |= mask; + } + bits[0] |= mask_init; + } +} + +template +bool basic_regex_creator::is_bad_repeat(re_syntax_base* pt) +{ + switch(pt->type) + { + case syntax_element_rep: + case syntax_element_dot_rep: + case syntax_element_char_rep: + case syntax_element_short_set_rep: + case syntax_element_long_set_rep: + { + unsigned id = static_cast(pt)->id; + if(id > sizeof(m_bad_repeats) * CHAR_BIT) + return true; // run out of bits, assume we can't traverse this one. + return m_bad_repeats & static_cast(1uL << id); + } + default: + return false; + } +} + +template +void basic_regex_creator::set_bad_repeat(re_syntax_base* pt) +{ + switch(pt->type) + { + case syntax_element_rep: + case syntax_element_dot_rep: + case syntax_element_char_rep: + case syntax_element_short_set_rep: + case syntax_element_long_set_rep: + { + unsigned id = static_cast(pt)->id; + if(id <= sizeof(m_bad_repeats) * CHAR_BIT) + m_bad_repeats |= static_cast(1uL << id); + } + default: + break; + } +} + +template +syntax_element_type basic_regex_creator::get_repeat_type(re_syntax_base* state) +{ + typedef typename traits::char_class_type mask_type; + if(state->type == syntax_element_rep) + { + // check to see if we are repeating a single state: + if(state->next.p->next.p->next.p == static_cast(state)->alt.p) + { + 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*>(state->next.p)->singleton) + return re_detail::syntax_element_long_set_rep; + break; + default: + break; + } + } + } + return state->type; +} + +template +void basic_regex_creator::probe_leading_repeat(re_syntax_base* state) +{ + // enumerate our states, and see if we have a leading repeat + // for which failed search restarts can be optimised; + do + { + switch(state->type) + { + case syntax_element_startmark: + if(static_cast(state)->index >= 0) + { + state = state->next.p; + continue; + } + return; + case syntax_element_endmark: + case syntax_element_start_line: + case syntax_element_end_line: + case syntax_element_word_boundary: + case syntax_element_within_word: + case syntax_element_word_start: + case syntax_element_word_end: + case syntax_element_buffer_start: + case syntax_element_buffer_end: + case syntax_element_restart_continue: + state = state->next.p; + break; + case syntax_element_dot_rep: + case syntax_element_char_rep: + case syntax_element_short_set_rep: + case syntax_element_long_set_rep: + if(this->m_has_backrefs == 0) + static_cast(state)->leading = true; + // fall through: + default: + return; + } + }while(state); +} + + +} // namespace re_detail + +} // namespace boost + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + +#endif diff --git a/boost/boost/regex/v4/basic_regex_parser.hpp b/boost/boost/regex/v4/basic_regex_parser.hpp new file mode 100644 index 0000000000..41ec0f330c --- /dev/null +++ b/boost/boost/regex/v4/basic_regex_parser.hpp @@ -0,0 +1,2080 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE basic_regex_parser.cpp + * VERSION see + * DESCRIPTION: Declares template class basic_regex_parser. + */ + +#ifndef BOOST_REGEX_V4_BASIC_REGEX_PARSER_HPP +#define BOOST_REGEX_V4_BASIC_REGEX_PARSER_HPP + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +namespace boost{ +namespace re_detail{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4244) +#endif + +template +class basic_regex_parser : public basic_regex_creator +{ +public: + basic_regex_parser(regex_data* data); + void parse(const charT* p1, const charT* p2, unsigned flags); + void fail(regex_constants::error_type error_code, std::ptrdiff_t position); + + bool parse_all(); + bool parse_basic(); + bool parse_extended(); + bool parse_literal(); + bool parse_open_paren(); + bool parse_basic_escape(); + bool parse_extended_escape(); + bool parse_match_any(); + bool parse_repeat(std::size_t low = 0, std::size_t high = (std::numeric_limits::max)()); + bool parse_repeat_range(bool isbasic); + bool parse_alt(); + bool parse_set(); + bool parse_backref(); + void parse_set_literal(basic_char_set& char_set); + bool parse_inner_set(basic_char_set& char_set); + bool parse_QE(); + bool parse_perl_extension(); + bool add_emacs_code(bool negate); + bool unwind_alts(std::ptrdiff_t last_paren_start); + digraph get_next_set_literal(basic_char_set& char_set); + charT unescape_character(); + regex_constants::syntax_option_type parse_options(); + +private: + typedef bool (basic_regex_parser::*parser_proc_type)(); + typedef typename traits::string_type string_type; + typedef typename traits::char_class_type char_class_type; + parser_proc_type m_parser_proc; // the main parser to use + const charT* m_base; // the start of the string being parsed + const charT* m_end; // the end of the string being parsed + const charT* m_position; // our current parser position + unsigned m_mark_count; // how many sub-expressions we have + std::ptrdiff_t m_paren_start; // where the last seen ')' began (where repeats are inserted). + std::ptrdiff_t m_alt_insert_point; // where to insert the next alternative + bool m_has_case_change; // true if somewhere in the current block the case has changed +#if defined(BOOST_MSVC) && defined(_M_IX86) + // This is an ugly warning suppression workaround (for warnings *inside* std::vector + // that can not otherwise be suppressed)... + BOOST_STATIC_ASSERT(sizeof(long) >= sizeof(void*)); + std::vector m_alt_jumps; // list of alternative in the current scope. +#else + std::vector m_alt_jumps; // list of alternative in the current scope. +#endif + + basic_regex_parser& operator=(const basic_regex_parser&); + basic_regex_parser(const basic_regex_parser&); +}; + +template +basic_regex_parser::basic_regex_parser(regex_data* data) + : basic_regex_creator(data), m_mark_count(0), m_paren_start(0), m_alt_insert_point(0), m_has_case_change(false) +{ +} + +template +void basic_regex_parser::parse(const charT* p1, const charT* p2, unsigned flags) +{ + // pass flags on to base class: + this->init(flags); + // set up pointers: + m_position = m_base = p1; + m_end = p2; + // empty strings are errors: + if(p1 == p2) + { + fail(regex_constants::error_empty, 0); + return; + } + // select which parser to use: + switch(flags & regbase::main_option_type) + { + case regbase::perl_syntax_group: + m_parser_proc = &basic_regex_parser::parse_extended; + break; + case regbase::basic_syntax_group: + m_parser_proc = &basic_regex_parser::parse_basic; + break; + case regbase::literal: + m_parser_proc = &basic_regex_parser::parse_literal; + break; + } + + // parse all our characters: + bool result = parse_all(); + // + // Unwind our alternatives: + // + unwind_alts(-1); + // reset flags as a global scope (?imsx) may have altered them: + this->flags(flags); + // if we haven't gobbled up all the characters then we must + // have had an unexpected ')' : + if(!result) + { + fail(regex_constants::error_paren, ::boost::re_detail::distance(m_base, m_position)); + return; + } + // if an error has been set then give up now: + if(this->m_pdata->m_status) + return; + // fill in our sub-expression count: + this->m_pdata->m_mark_count = 1 + m_mark_count; + this->finalize(p1, p2); +} + +template +void basic_regex_parser::fail(regex_constants::error_type error_code, std::ptrdiff_t position) +{ + if(0 == this->m_pdata->m_status) // update the error code if not already set + this->m_pdata->m_status = error_code; + m_position = m_end; // don't bother parsing anything else + // get the error message: + std::string message = this->m_pdata->m_ptraits->error_string(error_code); + // and raise the exception, this will do nothing if exceptions are disabled: +#ifndef BOOST_NO_EXCEPTIONS + if(0 == (this->flags() & regex_constants::no_except)) + { + boost::regex_error e(message, error_code, position); + e.raise(); + } +#else + (void)position; // suppress warnings. +#endif +} + +template +bool basic_regex_parser::parse_all() +{ + bool result = true; + while(result && (m_position != m_end)) + { + result = (this->*m_parser_proc)(); + } + return result; +} + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4702) +#endif +template +bool basic_regex_parser::parse_basic() +{ + switch(this->m_traits.syntax_type(*m_position)) + { + case regex_constants::syntax_escape: + return parse_basic_escape(); + case regex_constants::syntax_dot: + return parse_match_any(); + case regex_constants::syntax_caret: + ++m_position; + this->append_state(syntax_element_start_line); + break; + case regex_constants::syntax_dollar: + ++m_position; + this->append_state(syntax_element_end_line); + break; + case regex_constants::syntax_star: + if(!(this->m_last_state) || (this->m_last_state->type == syntax_element_start_line)) + return parse_literal(); + else + { + ++m_position; + return parse_repeat(); + } + case regex_constants::syntax_plus: + if(!(this->m_last_state) || (this->m_last_state->type == syntax_element_start_line) || !(this->flags() & regbase::emacs_ex)) + return parse_literal(); + else + { + ++m_position; + return parse_repeat(1); + } + case regex_constants::syntax_question: + if(!(this->m_last_state) || (this->m_last_state->type == syntax_element_start_line) || !(this->flags() & regbase::emacs_ex)) + return parse_literal(); + else + { + ++m_position; + return parse_repeat(0, 1); + } + case regex_constants::syntax_open_set: + return parse_set(); + default: + return parse_literal(); + } + return true; +} + +template +bool basic_regex_parser::parse_extended() +{ + bool result = true; + switch(this->m_traits.syntax_type(*m_position)) + { + case regex_constants::syntax_open_mark: + return parse_open_paren(); + case regex_constants::syntax_close_mark: + return false; + case regex_constants::syntax_escape: + return parse_extended_escape(); + case regex_constants::syntax_dot: + return parse_match_any(); + case regex_constants::syntax_caret: + ++m_position; + this->append_state( + (this->flags() & regex_constants::no_mod_m ? syntax_element_buffer_start : syntax_element_start_line)); + break; + case regex_constants::syntax_dollar: + ++m_position; + this->append_state( + (this->flags() & regex_constants::no_mod_m ? syntax_element_buffer_end : syntax_element_end_line)); + break; + case regex_constants::syntax_star: + if(m_position == this->m_base) + { + fail(regex_constants::error_badrepeat, 0); + return false; + } + ++m_position; + return parse_repeat(); + case regex_constants::syntax_question: + if(m_position == this->m_base) + { + fail(regex_constants::error_badrepeat, 0); + return false; + } + ++m_position; + return parse_repeat(0,1); + case regex_constants::syntax_plus: + if(m_position == this->m_base) + { + fail(regex_constants::error_badrepeat, 0); + return false; + } + ++m_position; + return parse_repeat(1); + case regex_constants::syntax_open_brace: + ++m_position; + return parse_repeat_range(false); + case regex_constants::syntax_close_brace: + fail(regex_constants::error_brace, this->m_position - this->m_end); + return false; + case regex_constants::syntax_or: + return parse_alt(); + case regex_constants::syntax_open_set: + return parse_set(); + case regex_constants::syntax_hash: + // + // If we have a mod_x flag set, then skip until + // we get to a newline character: + // + if((this->flags() + & (regbase::no_perl_ex|regbase::mod_x)) + == regbase::mod_x) + { + while((m_position != m_end) && !is_separator(*m_position++)){} + return true; + } + // Otherwise fall through: + default: + result = parse_literal(); + break; + } + return result; +} +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +template +bool basic_regex_parser::parse_literal() +{ + // append this as a literal provided it's not a space character + // or the perl option regbase::mod_x is not set: + if( + ((this->flags() + & (regbase::main_option_type|regbase::mod_x|regbase::no_perl_ex)) + != regbase::mod_x) + || !this->m_traits.isctype(*m_position, this->m_mask_space)) + this->append_literal(*m_position); + ++m_position; + return true; +} + +template +bool basic_regex_parser::parse_open_paren() +{ + // + // skip the '(' and error check: + // + if(++m_position == m_end) + { + fail(regex_constants::error_paren, m_position - m_base); + return false; + } + // + // begin by checking for a perl-style (?...) extension: + // + if( + ((this->flags() & (regbase::main_option_type | regbase::no_perl_ex)) == 0) + || ((this->flags() & (regbase::main_option_type | regbase::emacs_ex)) == (regbase::basic_syntax_group|regbase::emacs_ex)) + ) + { + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_question) + return parse_perl_extension(); + } + // + // update our mark count, and append the required state: + // + unsigned markid = 0; + if(0 == (this->flags() & regbase::nosubs)) + markid = ++m_mark_count; + re_brace* pb = static_cast(this->append_state(syntax_element_startmark, sizeof(re_brace))); + pb->index = markid; + std::ptrdiff_t last_paren_start = this->getoffset(pb); + // back up insertion point for alternations, and set new point: + std::ptrdiff_t last_alt_point = m_alt_insert_point; + this->m_pdata->m_data.align(); + m_alt_insert_point = this->m_pdata->m_data.size(); + // + // back up the current flags in case we have a nested (?imsx) group: + // + regex_constants::syntax_option_type opts = this->flags(); + bool old_case_change = m_has_case_change; + m_has_case_change = false; // no changes to this scope as yet... + // + // now recursively add more states, this will terminate when we get to a + // matching ')' : + // + parse_all(); + // + // Unwind pushed alternatives: + // + if(0 == unwind_alts(last_paren_start)) + return false; + // + // restore flags: + // + if(m_has_case_change) + { + // the case has changed in one or more of the alternatives + // within the scoped (...) block: we have to add a state + // to reset the case sensitivity: + static_cast( + this->append_state(syntax_element_toggle_case, sizeof(re_case)) + )->icase = opts & regbase::icase; + } + this->flags(opts); + m_has_case_change = old_case_change; + // + // we either have a ')' or we have run out of characters prematurely: + // + if(m_position == m_end) + { + this->fail(regex_constants::error_paren, ::boost::re_detail::distance(m_base, m_end)); + return false; + } + BOOST_ASSERT(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_mark); + ++m_position; + // + // append closing parenthesis state: + // + pb = static_cast(this->append_state(syntax_element_endmark, sizeof(re_brace))); + pb->index = markid; + this->m_paren_start = last_paren_start; + // + // restore the alternate insertion point: + // + this->m_alt_insert_point = last_alt_point; + // + // allow backrefs to this mark: + // + if((markid > 0) && (markid < sizeof(unsigned) * CHAR_BIT)) + this->m_backrefs |= 1u << (markid - 1); + + return true; +} + +template +bool basic_regex_parser::parse_basic_escape() +{ + ++m_position; + bool result = true; + switch(this->m_traits.escape_syntax_type(*m_position)) + { + case regex_constants::syntax_open_mark: + return parse_open_paren(); + case regex_constants::syntax_close_mark: + return false; + case regex_constants::syntax_plus: + if(this->flags() & regex_constants::bk_plus_qm) + { + ++m_position; + return parse_repeat(1); + } + else + return parse_literal(); + case regex_constants::syntax_question: + if(this->flags() & regex_constants::bk_plus_qm) + { + ++m_position; + return parse_repeat(0, 1); + } + else + return parse_literal(); + case regex_constants::syntax_open_brace: + if(this->flags() & regbase::no_intervals) + return parse_literal(); + ++m_position; + return parse_repeat_range(true); + case regex_constants::syntax_close_brace: + if(this->flags() & regbase::no_intervals) + return parse_literal(); + fail(regex_constants::error_brace, this->m_position - this->m_base); + return false; + case regex_constants::syntax_or: + if(this->flags() & regbase::bk_vbar) + return parse_alt(); + else + result = parse_literal(); + break; + case regex_constants::syntax_digit: + return parse_backref(); + case regex_constants::escape_type_start_buffer: + if(this->flags() & regbase::emacs_ex) + { + ++m_position; + this->append_state(syntax_element_buffer_start); + } + else + result = parse_literal(); + break; + case regex_constants::escape_type_end_buffer: + if(this->flags() & regbase::emacs_ex) + { + ++m_position; + this->append_state(syntax_element_buffer_end); + } + else + result = parse_literal(); + break; + case regex_constants::escape_type_word_assert: + if(this->flags() & regbase::emacs_ex) + { + ++m_position; + this->append_state(syntax_element_word_boundary); + } + else + result = parse_literal(); + break; + case regex_constants::escape_type_not_word_assert: + if(this->flags() & regbase::emacs_ex) + { + ++m_position; + this->append_state(syntax_element_within_word); + } + else + result = parse_literal(); + break; + case regex_constants::escape_type_left_word: + if(this->flags() & regbase::emacs_ex) + { + ++m_position; + this->append_state(syntax_element_word_start); + } + else + result = parse_literal(); + break; + case regex_constants::escape_type_right_word: + if(this->flags() & regbase::emacs_ex) + { + ++m_position; + this->append_state(syntax_element_word_end); + } + else + result = parse_literal(); + break; + default: + if(this->flags() & regbase::emacs_ex) + { + bool negate = true; + switch(*m_position) + { + case 'w': + negate = false; + // fall through: + case 'W': + { + basic_char_set char_set; + if(negate) + char_set.negate(); + char_set.add_class(this->m_word_mask); + if(0 == this->append_set(char_set)) + { + fail(regex_constants::error_ctype, m_position - m_base); + return false; + } + ++m_position; + return true; + } + case 's': + negate = false; + // fall through: + case 'S': + return add_emacs_code(negate); + case 'c': + case 'C': + // not supported yet: + fail(regex_constants::error_escape, m_position - m_base); + return false; + default: + break; + } + } + result = parse_literal(); + break; + } + return result; +} + +template +bool basic_regex_parser::parse_extended_escape() +{ + ++m_position; + bool negate = false; // in case this is a character class escape: \w \d etc + switch(this->m_traits.escape_syntax_type(*m_position)) + { + case regex_constants::escape_type_not_class: + negate = true; + // fall through: + case regex_constants::escape_type_class: + { + typedef typename traits::char_class_type mask_type; + mask_type m = this->m_traits.lookup_classname(m_position, m_position+1); + if(m != 0) + { + basic_char_set char_set; + if(negate) + char_set.negate(); + char_set.add_class(m); + if(0 == this->append_set(char_set)) + { + fail(regex_constants::error_ctype, m_position - m_base); + return false; + } + ++m_position; + return true; + } + // + // not a class, just a regular unknown escape: + // + this->append_literal(unescape_character()); + break; + } + case regex_constants::syntax_digit: + return parse_backref(); + case regex_constants::escape_type_left_word: + ++m_position; + this->append_state(syntax_element_word_start); + break; + case regex_constants::escape_type_right_word: + ++m_position; + this->append_state(syntax_element_word_end); + break; + case regex_constants::escape_type_start_buffer: + ++m_position; + this->append_state(syntax_element_buffer_start); + break; + case regex_constants::escape_type_end_buffer: + ++m_position; + this->append_state(syntax_element_buffer_end); + break; + case regex_constants::escape_type_word_assert: + ++m_position; + this->append_state(syntax_element_word_boundary); + break; + case regex_constants::escape_type_not_word_assert: + ++m_position; + this->append_state(syntax_element_within_word); + break; + case regex_constants::escape_type_Z: + ++m_position; + this->append_state(syntax_element_soft_buffer_end); + break; + case regex_constants::escape_type_Q: + return parse_QE(); + case regex_constants::escape_type_C: + return parse_match_any(); + case regex_constants::escape_type_X: + ++m_position; + this->append_state(syntax_element_combining); + break; + case regex_constants::escape_type_G: + ++m_position; + this->append_state(syntax_element_restart_continue); + break; + case regex_constants::escape_type_not_property: + negate = true; + // fall through: + case regex_constants::escape_type_property: + { + ++m_position; + char_class_type m; + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + // maybe have \p{ddd} + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_open_brace) + { + const charT* base = m_position; + // skip forward until we find enclosing brace: + while((m_position != m_end) && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_brace)) + ++m_position; + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + m = this->m_traits.lookup_classname(++base, m_position++); + } + else + { + m = this->m_traits.lookup_classname(m_position, m_position+1); + ++m_position; + } + if(m != 0) + { + basic_char_set char_set; + if(negate) + char_set.negate(); + char_set.add_class(m); + if(0 == this->append_set(char_set)) + { + fail(regex_constants::error_ctype, m_position - m_base); + return false; + } + return true; + } + fail(regex_constants::error_ctype, m_position - m_base); + } + default: + this->append_literal(unescape_character()); + break; + } + return true; +} + +template +bool basic_regex_parser::parse_match_any() +{ + // + // we have a '.' that can match any character: + // + ++m_position; + static_cast( + this->append_state(syntax_element_wild, sizeof(re_dot)) + )->mask = static_cast(this->flags() & regbase::no_mod_s + ? re_detail::force_not_newline + : this->flags() & regbase::mod_s ? + re_detail::force_newline : re_detail::dont_care); + return true; +} + +template +bool basic_regex_parser::parse_repeat(std::size_t low, std::size_t high) +{ + bool greedy = true; + std::size_t insert_point; + // + // when we get to here we may have a non-greedy ? mark still to come: + // + if((m_position != m_end) + && ( + (0 == (this->flags() & (regbase::main_option_type | regbase::no_perl_ex))) + || ((regbase::basic_syntax_group|regbase::emacs_ex) == (this->flags() & (regbase::main_option_type | regbase::emacs_ex))) + ) + ) + { + // OK we have a perl regex, check for a '?': + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_question) + { + greedy = false; + ++m_position; + } + } + if(0 == this->m_last_state) + { + fail(regex_constants::error_badrepeat, ::boost::re_detail::distance(m_base, m_position)); + return false; + } + if(this->m_last_state->type == syntax_element_endmark) + { + // insert a repeat before the '(' matching the last ')': + insert_point = this->m_paren_start; + } + else if((this->m_last_state->type == syntax_element_literal) && (static_cast(this->m_last_state)->length > 1)) + { + // the last state was a literal with more than one character, split it in two: + re_literal* lit = static_cast(this->m_last_state); + charT c = (static_cast(static_cast(lit+1)))[lit->length - 1]; + --(lit->length); + // now append new state: + lit = static_cast(this->append_state(syntax_element_literal, sizeof(re_literal) + sizeof(charT))); + lit->length = 1; + (static_cast(static_cast(lit+1)))[0] = c; + insert_point = this->getoffset(this->m_last_state); + } + else + { + // repeat the last state whatever it was, need to add some error checking here: + switch(this->m_last_state->type) + { + case syntax_element_start_line: + case syntax_element_end_line: + case syntax_element_word_boundary: + case syntax_element_within_word: + case syntax_element_word_start: + case syntax_element_word_end: + case syntax_element_buffer_start: + case syntax_element_buffer_end: + case syntax_element_alt: + case syntax_element_soft_buffer_end: + case syntax_element_restart_continue: + case syntax_element_jump: + case syntax_element_startmark: + // can't legally repeat any of the above: + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + default: + // do nothing... + break; + } + insert_point = this->getoffset(this->m_last_state); + } + // + // OK we now know what to repeat, so insert the repeat around it: + // + re_repeat* rep = static_cast(this->insert_state(insert_point, syntax_element_rep, re_repeater_size)); + rep->min = low; + rep->max = high; + rep->greedy = greedy; + rep->leading = false; + // store our repeater position for later: + std::ptrdiff_t rep_off = this->getoffset(rep); + // and append a back jump to the repeat: + re_jump* jmp = static_cast(this->append_state(syntax_element_jump, sizeof(re_jump))); + jmp->alt.i = rep_off - this->getoffset(jmp); + this->m_pdata->m_data.align(); + // now fill in the alt jump for the repeat: + rep = static_cast(this->getaddress(rep_off)); + rep->alt.i = this->m_pdata->m_data.size() - rep_off; + return true; +} + +template +bool basic_regex_parser::parse_repeat_range(bool isbasic) +{ + // + // parse a repeat-range: + // + std::size_t min, max; + int v; + // skip whitespace: + while((m_position != m_end) && this->m_traits.isctype(*m_position, this->m_mask_space)) + ++m_position; + // fail if at end: + if(this->m_position == this->m_end) + { + fail(regex_constants::error_brace, this->m_position - this->m_base); + return false; + } + // get min: + v = this->m_traits.toi(m_position, m_end, 10); + // skip whitespace: + while((m_position != m_end) && this->m_traits.isctype(*m_position, this->m_mask_space)) + ++m_position; + if(v < 0) + { + fail(regex_constants::error_badbrace, this->m_position - this->m_base); + return false; + } + else if(this->m_position == this->m_end) + { + fail(regex_constants::error_brace, this->m_position - this->m_base); + return false; + } + min = v; + // see if we have a comma: + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_comma) + { + // move on and error check: + ++m_position; + // skip whitespace: + while((m_position != m_end) && this->m_traits.isctype(*m_position, this->m_mask_space)) + ++m_position; + if(this->m_position == this->m_end) + { + fail(regex_constants::error_brace, this->m_position - this->m_base); + return false; + } + // get the value if any: + v = this->m_traits.toi(m_position, m_end, 10); + max = (v >= 0) ? v : (std::numeric_limits::max)(); + } + else + { + // no comma, max = min: + max = min; + } + // skip whitespace: + while((m_position != m_end) && this->m_traits.isctype(*m_position, this->m_mask_space)) + ++m_position; + // OK now check trailing }: + if(this->m_position == this->m_end) + { + fail(regex_constants::error_brace, this->m_position - this->m_base); + return false; + } + if(isbasic) + { + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_escape) + { + ++m_position; + if(this->m_position == this->m_end) + { + fail(regex_constants::error_brace, this->m_position - this->m_base); + return false; + } + } + else + { + fail(regex_constants::error_badbrace, this->m_position - this->m_base); + return false; + } + } + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_brace) + ++m_position; + else + { + fail(regex_constants::error_badbrace, this->m_position - this->m_base); + return false; + } + // + // finally go and add the repeat, unless error: + // + if(min > max) + { + fail(regex_constants::error_range, this->m_position - this->m_base); + return false; + } + return parse_repeat(min, max); +} + +template +bool basic_regex_parser::parse_alt() +{ + // + // error check: if there have been no previous states, + // or if the last state was a '(' then error: + // + if((this->m_last_state == 0) || (this->m_last_state->type == syntax_element_startmark)) + { + fail(regex_constants::error_empty, this->m_position - this->m_base); + return false; + } + ++m_position; + // + // we need to append a trailing jump: + // + re_syntax_base* pj = this->append_state(re_detail::syntax_element_jump, sizeof(re_jump)); + std::ptrdiff_t jump_offset = this->getoffset(pj); + // + // now insert the alternative: + // + re_alt* palt = static_cast(this->insert_state(this->m_alt_insert_point, syntax_element_alt, re_alt_size)); + jump_offset += re_alt_size; + this->m_pdata->m_data.align(); + palt->alt.i = this->m_pdata->m_data.size() - this->getoffset(palt); + // + // update m_alt_insert_point so that the next alternate gets + // inserted at the start of the second of the two we've just created: + // + this->m_alt_insert_point = this->m_pdata->m_data.size(); + // + // the start of this alternative must have a case changes state + // if the current block has messed around with case changes: + // + if(m_has_case_change) + { + static_cast( + this->append_state(syntax_element_toggle_case, sizeof(re_case)) + )->icase = this->m_icase; + } + // + // push the alternative onto our stack, a recursive + // implementation here is easier to understand (and faster + // as it happens), but causes all kinds of stack overflow problems + // on programs with small stacks (COM+). + // + m_alt_jumps.push_back(jump_offset); + return true; +} + +template +bool basic_regex_parser::parse_set() +{ + ++m_position; + if(m_position == m_end) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + basic_char_set char_set; + + const charT* base = m_position; // where the '[' was + const charT* item_base = m_position; // where the '[' or '^' was + + while(m_position != m_end) + { + switch(this->m_traits.syntax_type(*m_position)) + { + case regex_constants::syntax_caret: + if(m_position == base) + { + char_set.negate(); + ++m_position; + item_base = m_position; + } + else + parse_set_literal(char_set); + break; + case regex_constants::syntax_close_set: + if(m_position == item_base) + { + parse_set_literal(char_set); + break; + } + else + { + ++m_position; + if(0 == this->append_set(char_set)) + { + fail(regex_constants::error_range, m_position - m_base); + return false; + } + } + return true; + case regex_constants::syntax_open_set: + if(parse_inner_set(char_set)) + break; + return true; + case regex_constants::syntax_escape: + { + // + // look ahead and see if this is a character class shortcut + // \d \w \s etc... + // + ++m_position; + if(this->m_traits.escape_syntax_type(*m_position) + == regex_constants::escape_type_class) + { + char_class_type m = this->m_traits.lookup_classname(m_position, m_position+1); + if(m != 0) + { + char_set.add_class(m); + ++m_position; + break; + } + } + else if(this->m_traits.escape_syntax_type(*m_position) + == regex_constants::escape_type_not_class) + { + // negated character class: + char_class_type m = this->m_traits.lookup_classname(m_position, m_position+1); + if(m != 0) + { + char_set.add_negated_class(m); + ++m_position; + break; + } + } + // not a character class, just a regular escape: + --m_position; + parse_set_literal(char_set); + break; + } + default: + parse_set_literal(char_set); + break; + } + } + return m_position != m_end; +} + +template +bool basic_regex_parser::parse_inner_set(basic_char_set& char_set) +{ + // + // we have either a character class [:name:] + // a collating element [.name.] + // or an equivalence class [=name=] + // + if(m_end == ++m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + switch(this->m_traits.syntax_type(*m_position)) + { + case regex_constants::syntax_dot: + // + // a collating element is treated as a literal: + // + --m_position; + parse_set_literal(char_set); + return true; + case regex_constants::syntax_colon: + { + // check that character classes are actually enabled: + if((this->flags() & (regbase::main_option_type | regbase::no_char_classes)) + == (regbase::basic_syntax_group | regbase::no_char_classes)) + { + --m_position; + parse_set_literal(char_set); + return true; + } + // skip the ':' + if(m_end == ++m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + const charT* name_first = m_position; + // skip at least one character, then find the matching ':]' + if(m_end == ++m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + while((m_position != m_end) + && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_colon)) + ++m_position; + const charT* name_last = m_position; + if(m_end == m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + if((m_end == ++m_position) + || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_set)) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + // + // check for negated class: + // + bool negated = false; + if(this->m_traits.syntax_type(*name_first) == regex_constants::syntax_caret) + { + ++name_first; + negated = true; + } + typedef typename traits::char_class_type mask_type; + mask_type m = this->m_traits.lookup_classname(name_first, name_last); + if(m == 0) + { + if(char_set.empty() && (name_last - name_first == 1)) + { + // maybe a special case: + ++m_position; + if( (m_position != m_end) + && (this->m_traits.syntax_type(*m_position) + == regex_constants::syntax_close_set)) + { + if(this->m_traits.escape_syntax_type(*name_first) + == regex_constants::escape_type_left_word) + { + ++m_position; + this->append_state(syntax_element_word_start); + return false; + } + if(this->m_traits.escape_syntax_type(*name_first) + == regex_constants::escape_type_right_word) + { + ++m_position; + this->append_state(syntax_element_word_end); + return false; + } + } + } + fail(regex_constants::error_ctype, name_first - m_base); + return false; + } + if(negated == false) + char_set.add_class(m); + else + char_set.add_negated_class(m); + ++m_position; + break; + } + case regex_constants::syntax_equal: + { + // skip the '=' + if(m_end == ++m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + const charT* name_first = m_position; + // skip at least one character, then find the matching '=]' + if(m_end == ++m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + while((m_position != m_end) + && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_equal)) + ++m_position; + const charT* name_last = m_position; + if(m_end == m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + if((m_end == ++m_position) + || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_set)) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + string_type m = this->m_traits.lookup_collatename(name_first, name_last); + if((0 == m.size()) || (m.size() > 2)) + { + fail(regex_constants::error_collate, name_first - m_base); + return false; + } + digraph d; + d.first = m[0]; + if(m.size() > 1) + d.second = m[1]; + else + d.second = 0; + char_set.add_equivalent(d); + ++m_position; + break; + } + default: + --m_position; + parse_set_literal(char_set); + break; + } + return true; +} + +template +void basic_regex_parser::parse_set_literal(basic_char_set& char_set) +{ + digraph start_range(get_next_set_literal(char_set)); + if(m_end == m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return; + } + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_dash) + { + // we have a range: + if(m_end == ++m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return; + } + if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_set) + { + digraph end_range = get_next_set_literal(char_set); + char_set.add_range(start_range, end_range); + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_dash) + { + if(m_end == ++m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return; + } + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_set) + { + // trailing - : + --m_position; + return; + } + fail(regex_constants::error_range, m_position - m_base); + return; + } + return; + } + --m_position; + } + char_set.add_single(start_range); +} + +template +digraph basic_regex_parser::get_next_set_literal(basic_char_set& char_set) +{ + typedef typename traits::string_type string_type; + digraph result; + switch(this->m_traits.syntax_type(*m_position)) + { + case regex_constants::syntax_dash: + if(!char_set.empty()) + { + // see if we are at the end of the set: + if((++m_position == m_end) || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_set)) + { + fail(regex_constants::error_range, m_position - m_base); + return result; + } + --m_position; + } + result.first = *m_position++; + return result; + case regex_constants::syntax_escape: + // check to see if escapes are supported first: + if(this->flags() & regex_constants::no_escape_in_lists) + { + result = *m_position++; + break; + } + ++m_position; + result = unescape_character(); + break; + case regex_constants::syntax_open_set: + { + if(m_end == ++m_position) + { + fail(regex_constants::error_collate, m_position - m_base); + return result; + } + if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_dot) + { + --m_position; + result.first = *m_position; + ++m_position; + return result; + } + if(m_end == ++m_position) + { + fail(regex_constants::error_collate, m_position - m_base); + return result; + } + const charT* name_first = m_position; + // skip at least one character, then find the matching ':]' + if(m_end == ++m_position) + { + fail(regex_constants::error_collate, name_first - m_base); + return result; + } + while((m_position != m_end) + && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_dot)) + ++m_position; + const charT* name_last = m_position; + if(m_end == m_position) + { + fail(regex_constants::error_collate, name_first - m_base); + return result; + } + if((m_end == ++m_position) + || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_set)) + { + fail(regex_constants::error_collate, name_first - m_base); + return result; + } + ++m_position; + string_type s = this->m_traits.lookup_collatename(name_first, name_last); + if(s.empty() || (s.size() > 2)) + { + fail(regex_constants::error_collate, name_first - m_base); + return result; + } + result.first = s[0]; + if(s.size() > 1) + result.second = s[1]; + else + result.second = 0; + return result; + } + default: + result = *m_position++; + } + return result; +} + +// +// does a value fit in the specified charT type? +// +template +bool valid_value(charT, int v, const mpl::true_&) +{ + return (v >> (sizeof(charT) * CHAR_BIT)) == 0; +} +template +bool valid_value(charT, int, const mpl::false_&) +{ + return true; // v will alsways fit in a charT +} +template +bool valid_value(charT c, int v) +{ + return valid_value(c, v, mpl::bool_<(sizeof(charT) < sizeof(int))>()); +} + +template +charT basic_regex_parser::unescape_character() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif + charT result(0); + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + switch(this->m_traits.escape_syntax_type(*m_position)) + { + case regex_constants::escape_type_control_a: + result = charT('\a'); + break; + case regex_constants::escape_type_e: + result = charT(27); + break; + case regex_constants::escape_type_control_f: + result = charT('\f'); + break; + case regex_constants::escape_type_control_n: + result = charT('\n'); + break; + case regex_constants::escape_type_control_r: + result = charT('\r'); + break; + case regex_constants::escape_type_control_t: + result = charT('\t'); + break; + case regex_constants::escape_type_control_v: + result = charT('\v'); + break; + case regex_constants::escape_type_word_assert: + result = charT('\b'); + break; + case regex_constants::escape_type_ascii_control: + ++m_position; + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return result; + } + /* + if((*m_position < charT('@')) + || (*m_position > charT(125)) ) + { + fail(regex_constants::error_escape, m_position - m_base); + return result; + } + */ + result = static_cast(*m_position % 32); + break; + case regex_constants::escape_type_hex: + ++m_position; + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return result; + } + // maybe have \x{ddd} + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_open_brace) + { + ++m_position; + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return result; + } + int i = this->m_traits.toi(m_position, m_end, 16); + if((m_position == m_end) + || (i < 0) + || ((std::numeric_limits::is_specialized) && (charT(i) > (std::numeric_limits::max)())) + || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_brace)) + { + fail(regex_constants::error_badbrace, m_position - m_base); + return result; + } + ++m_position; + result = charT(i); + } + else + { + std::ptrdiff_t len = (std::min)(static_cast(2), m_end - m_position); + int i = this->m_traits.toi(m_position, m_position + len, 16); + if((i < 0) + || !valid_value(charT(0), i)) + { + fail(regex_constants::error_escape, m_position - m_base); + return result; + } + result = charT(i); + } + return result; + case regex_constants::syntax_digit: + { + // 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(4)); + const charT* bp = m_position; + int val = this->m_traits.toi(bp, bp + 1, 8); + if(val != 0) + { + // Oops not an octal escape after all: + fail(regex_constants::error_escape, m_position - m_base); + return result; + } + val = this->m_traits.toi(m_position, m_position + len, 8); + if(val < 0) + { + fail(regex_constants::error_escape, m_position - m_base); + return result; + } + return static_cast(val); + } + case regex_constants::escape_type_named_char: + { + ++m_position; + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + // maybe have \N{name} + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_open_brace) + { + const charT* base = m_position; + // skip forward until we find enclosing brace: + while((m_position != m_end) && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_brace)) + ++m_position; + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + string_type s = this->m_traits.lookup_collatename(++base, m_position++); + if(s.empty()) + { + fail(regex_constants::error_collate, m_position - m_base); + return false; + } + if(s.size() == 1) + { + return s[0]; + } + } + // fall through is a failure: + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + default: + result = *m_position; + break; + } + ++m_position; + return result; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool basic_regex_parser::parse_backref() +{ + BOOST_ASSERT(m_position != m_end); + const charT* pc = m_position; + int i = this->m_traits.toi(pc, pc + 1, 10); + if((i == 0) || (((this->flags() & regbase::main_option_type) == regbase::perl_syntax_group) && (this->flags() & regbase::no_bk_refs))) + { + // not a backref at all but an octal escape sequence: + charT c = unescape_character(); + this->append_literal(c); + } + else if((i > 0) && (this->m_backrefs & (1u << (i-1)))) + { + m_position = pc; + re_brace* pb = static_cast(this->append_state(syntax_element_backref, sizeof(re_brace))); + pb->index = i; + } + else + { + fail(regex_constants::error_backref, m_position - m_end); + return false; + } + return true; +} + +template +bool basic_regex_parser::parse_QE() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif + // + // parse a \Q...\E sequence: + // + ++m_position; // skip the Q + const charT* start = m_position; + const charT* end; + do + { + while((m_position != m_end) + && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape)) + ++m_position; + if(m_position == m_end) + { + // a \Q...\E sequence may terminate with the end of the expression: + end = m_position; + break; + } + if(++m_position == m_end) // skip the escape + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + // check to see if it's a \E: + if(this->m_traits.escape_syntax_type(*m_position) == regex_constants::escape_type_E) + { + ++m_position; + end = m_position - 2; + break; + } + // otherwise go round again: + }while(true); + // + // now add all the character between the two escapes as literals: + // + while(start != end) + { + this->append_literal(*start); + ++start; + } + return true; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool basic_regex_parser::parse_perl_extension() +{ + if(++m_position == m_end) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + // + // treat comments as a special case, as these + // are the only ones that don't start with a leading + // startmark state: + // + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_hash) + { + while((m_position != m_end) + && (this->m_traits.syntax_type(*m_position++) != regex_constants::syntax_close_mark)) + {} + return true; + } + // + // backup some state, and prepare the way: + // + int markid = 0; + std::ptrdiff_t jump_offset = 0; + re_brace* pb = static_cast(this->append_state(syntax_element_startmark, sizeof(re_brace))); + std::ptrdiff_t last_paren_start = this->getoffset(pb); + // back up insertion point for alternations, and set new point: + std::ptrdiff_t last_alt_point = m_alt_insert_point; + this->m_pdata->m_data.align(); + m_alt_insert_point = this->m_pdata->m_data.size(); + std::ptrdiff_t expected_alt_point = m_alt_insert_point; + bool restore_flags = true; + regex_constants::syntax_option_type old_flags = this->flags(); + bool old_case_change = m_has_case_change; + m_has_case_change = false; + // + // select the actual extension used: + // + switch(this->m_traits.syntax_type(*m_position)) + { + case regex_constants::syntax_colon: + // + // a non-capturing mark: + // + pb->index = markid = 0; + ++m_position; + break; + case regex_constants::syntax_equal: + pb->index = markid = -1; + ++m_position; + jump_offset = this->getoffset(this->append_state(syntax_element_jump, sizeof(re_jump))); + this->m_pdata->m_data.align(); + m_alt_insert_point = this->m_pdata->m_data.size(); + break; + case regex_constants::syntax_not: + pb->index = markid = -2; + ++m_position; + jump_offset = this->getoffset(this->append_state(syntax_element_jump, sizeof(re_jump))); + this->m_pdata->m_data.align(); + m_alt_insert_point = this->m_pdata->m_data.size(); + break; + case regex_constants::escape_type_left_word: + { + // a lookbehind assertion: + if(++m_position == m_end) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + regex_constants::syntax_type t = this->m_traits.syntax_type(*m_position); + if(t == regex_constants::syntax_not) + pb->index = markid = -2; + else if(t == regex_constants::syntax_equal) + pb->index = markid = -1; + else + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + ++m_position; + jump_offset = this->getoffset(this->append_state(syntax_element_jump, sizeof(re_jump))); + this->append_state(syntax_element_backstep, sizeof(re_brace)); + this->m_pdata->m_data.align(); + m_alt_insert_point = this->m_pdata->m_data.size(); + break; + } + case regex_constants::escape_type_right_word: + // + // an independent sub-expression: + // + pb->index = markid = -3; + ++m_position; + jump_offset = this->getoffset(this->append_state(syntax_element_jump, sizeof(re_jump))); + this->m_pdata->m_data.align(); + m_alt_insert_point = this->m_pdata->m_data.size(); + break; + case regex_constants::syntax_open_mark: + { + // a conditional expression: + pb->index = markid = -4; + if(++m_position == m_end) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + int v = this->m_traits.toi(m_position, m_end, 10); + if(v > 0) + { + re_brace* br = static_cast(this->append_state(syntax_element_assert_backref, sizeof(re_brace))); + br->index = v; + if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + if(++m_position == m_end) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + } + else + { + // verify that we have a lookahead or lookbehind assert: + if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_question) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + if(++m_position == m_end) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + if(this->m_traits.syntax_type(*m_position) == regex_constants::escape_type_left_word) + { + if(++m_position == m_end) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + if((this->m_traits.syntax_type(*m_position) != regex_constants::syntax_equal) + && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_not)) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + m_position -= 3; + } + else + { + if((this->m_traits.syntax_type(*m_position) != regex_constants::syntax_equal) + && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_not)) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + m_position -= 2; + } + } + break; + } + case regex_constants::syntax_close_mark: + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + default: + // + // lets assume that we have a (?imsx) group and try and parse it: + // + regex_constants::syntax_option_type opts = parse_options(); + if(m_position == m_end) + return false; + // make a note of whether we have a case change: + m_has_case_change = ((opts & regbase::icase) != (this->flags() & regbase::icase)); + pb->index = markid = 0; + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_mark) + { + // update flags and carry on as normal: + this->flags(opts); + restore_flags = false; + old_case_change |= m_has_case_change; // defer end of scope by one ')' + } + else if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_colon) + { + // update flags and carry on until the matching ')' is found: + this->flags(opts); + ++m_position; + } + else + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + + // finally append a case change state if we need it: + if(m_has_case_change) + { + static_cast( + this->append_state(syntax_element_toggle_case, sizeof(re_case)) + )->icase = opts & regbase::icase; + } + + } + // + // now recursively add more states, this will terminate when we get to a + // matching ')' : + // + parse_all(); + // + // Unwind alternatives: + // + if(0 == unwind_alts(last_paren_start)) + return false; + // + // we either have a ')' or we have run out of characters prematurely: + // + if(m_position == m_end) + { + this->fail(regex_constants::error_paren, ::boost::re_detail::distance(m_base, m_end)); + return false; + } + BOOST_ASSERT(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_mark); + ++m_position; + // + // restore the flags: + // + if(restore_flags) + { + // append a case change state if we need it: + if(m_has_case_change) + { + static_cast( + this->append_state(syntax_element_toggle_case, sizeof(re_case)) + )->icase = old_flags & regbase::icase; + } + this->flags(old_flags); + } + // + // set up the jump pointer if we have one: + // + if(jump_offset) + { + this->m_pdata->m_data.align(); + re_jump* jmp = static_cast(this->getaddress(jump_offset)); + jmp->alt.i = this->m_pdata->m_data.size() - this->getoffset(jmp); + if(this->m_last_state == jmp) + { + // Oops... we didn't have anything inside the assertion: + fail(regex_constants::error_empty, m_position - m_base); + return false; + } + } + // + // verify that if this is conditional expression, that we do have + // an alternative, if not add one: + // + if(markid == -4) + { + re_syntax_base* b = this->getaddress(expected_alt_point); + if(b->type != syntax_element_alt) + { + re_alt* alt = static_cast(this->insert_state(expected_alt_point, syntax_element_alt, sizeof(re_alt))); + alt->alt.i = this->m_pdata->m_data.size() - this->getoffset(alt); + } + else if(this->getaddress(static_cast(b)->alt.i, b)->type == syntax_element_alt) + { + fail(regex_constants::error_bad_pattern, m_position - m_base); + return false; + } + } + // + // append closing parenthesis state: + // + pb = static_cast(this->append_state(syntax_element_endmark, sizeof(re_brace))); + pb->index = markid; + this->m_paren_start = last_paren_start; + // + // restore the alternate insertion point: + // + this->m_alt_insert_point = last_alt_point; + // + // and the case change data: + // + m_has_case_change = old_case_change; + return true; +} + +template +bool basic_regex_parser::add_emacs_code(bool negate) +{ + // + // parses an emacs style \sx or \Sx construct. + // + if(++m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + basic_char_set char_set; + if(negate) + char_set.negate(); + + static const charT s_punct[5] = { 'p', 'u', 'n', 'c', 't', }; + + switch(*m_position) + { + case 's': + case ' ': + char_set.add_class(this->m_mask_space); + break; + case 'w': + char_set.add_class(this->m_word_mask); + break; + case '_': + char_set.add_single(digraph(charT('$'))); + char_set.add_single(digraph(charT('&'))); + char_set.add_single(digraph(charT('*'))); + char_set.add_single(digraph(charT('+'))); + char_set.add_single(digraph(charT('-'))); + char_set.add_single(digraph(charT('_'))); + char_set.add_single(digraph(charT('<'))); + char_set.add_single(digraph(charT('>'))); + break; + case '.': + char_set.add_class(this->m_traits.lookup_classname(s_punct, s_punct+5)); + break; + case '(': + char_set.add_single(digraph(charT('('))); + char_set.add_single(digraph(charT('['))); + char_set.add_single(digraph(charT('{'))); + break; + case ')': + char_set.add_single(digraph(charT(')'))); + char_set.add_single(digraph(charT(']'))); + char_set.add_single(digraph(charT('}'))); + break; + case '"': + char_set.add_single(digraph(charT('"'))); + char_set.add_single(digraph(charT('\''))); + char_set.add_single(digraph(charT('`'))); + break; + case '\'': + char_set.add_single(digraph(charT('\''))); + char_set.add_single(digraph(charT(','))); + char_set.add_single(digraph(charT('#'))); + break; + case '<': + char_set.add_single(digraph(charT(';'))); + break; + case '>': + char_set.add_single(digraph(charT('\n'))); + char_set.add_single(digraph(charT('\f'))); + break; + default: + fail(regex_constants::error_ctype, m_position - m_base); + return false; + } + if(0 == this->append_set(char_set)) + { + fail(regex_constants::error_ctype, m_position - m_base); + return false; + } + ++m_position; + return true; +} + +template +regex_constants::syntax_option_type basic_regex_parser::parse_options() +{ + // we have a (?imsx-imsx) group, convert it into a set of flags: + regex_constants::syntax_option_type f = this->flags(); + bool breakout = false; + do + { + switch(*m_position) + { + case 's': + f |= regex_constants::mod_s; + f &= ~regex_constants::no_mod_s; + break; + case 'm': + f &= ~regex_constants::no_mod_m; + break; + case 'i': + f |= regex_constants::icase; + break; + case 'x': + f |= regex_constants::mod_x; + break; + default: + breakout = true; + continue; + } + if(++m_position == m_end) + { + fail(regex_constants::error_paren, m_position - m_base); + return false; + } + } + while(!breakout); + + if(*m_position == static_cast('-')) + { + if(++m_position == m_end) + { + fail(regex_constants::error_paren, m_position - m_base); + return false; + } + do + { + switch(*m_position) + { + case 's': + f &= ~regex_constants::mod_s; + f |= regex_constants::no_mod_s; + break; + case 'm': + f |= regex_constants::no_mod_m; + break; + case 'i': + f &= ~regex_constants::icase; + break; + case 'x': + f &= ~regex_constants::mod_x; + break; + default: + breakout = true; + continue; + } + if(++m_position == m_end) + { + fail(regex_constants::error_paren, m_position - m_base); + return false; + } + } + while(!breakout); + } + return f; +} + +template +bool basic_regex_parser::unwind_alts(std::ptrdiff_t last_paren_start) +{ + // + // If we didn't actually add any states after the last + // alternative then that's an error: + // + if((this->m_alt_insert_point == static_cast(this->m_pdata->m_data.size())) + && m_alt_jumps.size() && (m_alt_jumps.back() > last_paren_start)) + { + fail(regex_constants::error_empty, this->m_position - this->m_base); + return false; + } + // + // Fix up our alternatives: + // + while(m_alt_jumps.size() && (m_alt_jumps.back() > last_paren_start)) + { + // + // fix up the jump to point to the end of the states + // that we've just added: + // + std::ptrdiff_t jump_offset = m_alt_jumps.back(); + m_alt_jumps.pop_back(); + this->m_pdata->m_data.align(); + re_jump* jmp = static_cast(this->getaddress(jump_offset)); + BOOST_ASSERT(jmp->type == syntax_element_jump); + jmp->alt.i = this->m_pdata->m_data.size() - jump_offset; + } + return true; +} + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace re_detail +} // namespace boost + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + +#endif diff --git a/boost/boost/regex/v4/c_regex_traits.hpp b/boost/boost/regex/v4/c_regex_traits.hpp new file mode 100644 index 0000000000..b4ec151826 --- /dev/null +++ b/boost/boost/regex/v4/c_regex_traits.hpp @@ -0,0 +1,197 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE c_regex_traits.hpp + * VERSION see + * DESCRIPTION: Declares regular expression traits class that wraps the global C locale. + */ + +#ifndef BOOST_C_REGEX_TRAITS_HPP_INCLUDED +#define BOOST_C_REGEX_TRAITS_HPP_INCLUDED + +#ifndef BOOST_REGEX_CONFIG_HPP +#include +#endif +#ifndef BOOST_REGEX_WORKAROUND_HPP +#include +#endif + +#include + +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std{ + using ::strlen; using ::tolower; +} +#endif + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +namespace boost{ + +template +struct c_regex_traits; + +template<> +struct BOOST_REGEX_DECL c_regex_traits +{ + c_regex_traits(){} + typedef char char_type; + typedef std::size_t size_type; + typedef std::string string_type; + struct locale_type{}; + typedef boost::uint32_t char_class_type; + + static size_type length(const char_type* p) + { + return (std::strlen)(p); + } + + char translate(char c) const + { + return c; + } + char translate_nocase(char c) const + { + return static_cast((std::tolower)(static_cast(c))); + } + + static string_type BOOST_REGEX_CALL transform(const char* p1, const char* p2); + static string_type BOOST_REGEX_CALL transform_primary(const char* p1, const char* p2); + + static char_class_type BOOST_REGEX_CALL lookup_classname(const char* p1, const char* p2); + static string_type BOOST_REGEX_CALL lookup_collatename(const char* p1, const char* p2); + + static bool BOOST_REGEX_CALL isctype(char, char_class_type); + static int BOOST_REGEX_CALL value(char, int); + + locale_type imbue(locale_type l) + { return l; } + locale_type getloc()const + { return locale_type(); } + +private: + // this type is not copyable: + c_regex_traits(const c_regex_traits&); + c_regex_traits& operator=(const c_regex_traits&); +}; + +#ifndef BOOST_NO_WREGEX +template<> +struct BOOST_REGEX_DECL c_regex_traits +{ + c_regex_traits(){} + typedef wchar_t char_type; + typedef std::size_t size_type; + typedef std::wstring string_type; + struct locale_type{}; + typedef boost::uint32_t char_class_type; + + static size_type length(const char_type* p) + { + return (std::wcslen)(p); + } + + wchar_t translate(wchar_t c) const + { + return c; + } + wchar_t translate_nocase(wchar_t c) const + { + return (std::towlower)(c); + } + + static string_type BOOST_REGEX_CALL transform(const wchar_t* p1, const wchar_t* p2); + static string_type BOOST_REGEX_CALL transform_primary(const wchar_t* p1, const wchar_t* p2); + + static char_class_type BOOST_REGEX_CALL lookup_classname(const wchar_t* p1, const wchar_t* p2); + static string_type BOOST_REGEX_CALL lookup_collatename(const wchar_t* p1, const wchar_t* p2); + + static bool BOOST_REGEX_CALL isctype(wchar_t, char_class_type); + static int BOOST_REGEX_CALL value(wchar_t, int); + + locale_type imbue(locale_type l) + { return l; } + locale_type getloc()const + { return locale_type(); } + +private: + // this type is not copyable: + c_regex_traits(const c_regex_traits&); + c_regex_traits& operator=(const c_regex_traits&); +}; + +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +// +// Provide an unsigned short version as well, so the user can link to this +// no matter whether they build with /Zc:wchar_t or not (MSVC specific). +// +template<> +struct BOOST_REGEX_DECL c_regex_traits +{ + c_regex_traits(){} + typedef unsigned short char_type; + typedef std::size_t size_type; + typedef std::basic_string string_type; + struct locale_type{}; + typedef boost::uint32_t char_class_type; + + static size_type length(const char_type* p) + { + return (std::wcslen)((const wchar_t*)p); + } + + unsigned short translate(unsigned short c) const + { + return c; + } + unsigned short translate_nocase(unsigned short c) const + { + return (std::towlower)((wchar_t)c); + } + + static string_type BOOST_REGEX_CALL transform(const unsigned short* p1, const unsigned short* p2); + static string_type BOOST_REGEX_CALL transform_primary(const unsigned short* p1, const unsigned short* p2); + + static char_class_type BOOST_REGEX_CALL lookup_classname(const unsigned short* p1, const unsigned short* p2); + static string_type BOOST_REGEX_CALL lookup_collatename(const unsigned short* p1, const unsigned short* p2); + + static bool BOOST_REGEX_CALL isctype(unsigned short, char_class_type); + static int BOOST_REGEX_CALL value(unsigned short, int); + + locale_type imbue(locale_type l) + { return l; } + locale_type getloc()const + { return locale_type(); } + +private: + // this type is not copyable: + c_regex_traits(const c_regex_traits&); + c_regex_traits& operator=(const c_regex_traits&); +}; + +#endif + +#endif // BOOST_NO_WREGEX + +} + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + +#endif + + + diff --git a/boost/boost/regex/v4/char_regex_traits.hpp b/boost/boost/regex/v4/char_regex_traits.hpp index 67cc3677f3..f00e65eb23 100644 --- a/boost/boost/regex/v4/char_regex_traits.hpp +++ b/boost/boost/regex/v4/char_regex_traits.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -42,10 +42,6 @@ public: typedef unsigned int size_type; typedef regex_traits base_type; - char BOOST_REGEX_CALL translate(char c, bool)const - { - return static_cast*>(this)->translate(c, true); - } }; #ifndef BOOST_NO_WREGEX @@ -58,17 +54,6 @@ public: typedef unsigned int size_type; typedef regex_traits base_type; - wchar_t BOOST_REGEX_CALL translate(wchar_t c, bool)const - { - return static_cast*>(this)->translate(c, true); - } - boost::uint_fast32_t BOOST_REGEX_CALL lookup_classname(const wchar_t* first, const wchar_t* last)const - { - boost::uint_fast32_t result = static_cast*>(this)->lookup_classname(first, last); - if((result & base_type::char_class_upper) == base_type::char_class_upper) - result |= base_type::char_class_alpha; - return result; - } }; #endif } // namespace deprecated diff --git a/boost/boost/regex/v4/cpp_regex_traits.hpp b/boost/boost/regex/v4/cpp_regex_traits.hpp new file mode 100644 index 0000000000..f7ba0bcc6f --- /dev/null +++ b/boost/boost/regex/v4/cpp_regex_traits.hpp @@ -0,0 +1,1039 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE cpp_regex_traits.hpp + * VERSION see + * DESCRIPTION: Declares regular expression traits class cpp_regex_traits. + */ + +#ifndef BOOST_CPP_REGEX_TRAITS_HPP_INCLUDED +#define BOOST_CPP_REGEX_TRAITS_HPP_INCLUDED + +#include + +#ifndef BOOST_NO_STD_LOCALE + +#ifndef BOOST_RE_PAT_EXCEPT_HPP +#include +#endif +#ifndef BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED +#include +#endif +#ifdef BOOST_HAS_THREADS +#include +#endif +#ifndef BOOST_REGEX_PRIMARY_TRANSFORM +#include +#endif +#ifndef BOOST_REGEX_OBJECT_CACHE_HPP +#include +#endif + +#include +#include + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4786) +#endif + +namespace boost{ + +// +// forward declaration is needed by some compilers: +// +template +class cpp_regex_traits; + +namespace re_detail{ + +// +// class parser_buf: +// acts as a stream buffer which wraps around a pair of pointers: +// +template > +class parser_buf : public ::std::basic_streambuf +{ + typedef ::std::basic_streambuf base_type; + typedef typename base_type::int_type int_type; + typedef typename base_type::char_type char_type; + typedef typename base_type::pos_type pos_type; + typedef ::std::streamsize streamsize; + typedef typename base_type::off_type off_type; +public: + parser_buf() : base_type() { setbuf(0, 0); } + const charT* getnext() { return this->gptr(); } +protected: + std::basic_streambuf* setbuf(char_type* s, streamsize n); + typename parser_buf::pos_type seekpos(pos_type sp, ::std::ios_base::openmode which); + typename parser_buf::pos_type seekoff(off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which); +private: + parser_buf& operator=(const parser_buf&); + parser_buf(const parser_buf&); +}; + +template +std::basic_streambuf* +parser_buf::setbuf(char_type* s, streamsize n) +{ + this->setg(s, s, s + n); + return this; +} + +template +typename parser_buf::pos_type +parser_buf::seekoff(off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which) +{ + if(which & ::std::ios_base::out) + return pos_type(off_type(-1)); + std::ptrdiff_t size = this->egptr() - this->eback(); + std::ptrdiff_t pos = this->gptr() - this->eback(); + charT* g = this->eback(); + switch(way) + { + case ::std::ios_base::beg: + if((off < 0) || (off > size)) + return pos_type(off_type(-1)); + else + this->setg(g, g + off, g + size); + break; + case ::std::ios_base::end: + if((off < 0) || (off > size)) + return pos_type(off_type(-1)); + else + this->setg(g, g + size - off, g + size); + break; + case ::std::ios_base::cur: + { + std::ptrdiff_t newpos = pos + off; + if((newpos < 0) || (newpos > size)) + return pos_type(off_type(-1)); + else + this->setg(g, g + newpos, g + size); + break; + } + default: ; + } +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4244) +#endif + return static_cast(this->gptr() - this->eback()); +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +typename parser_buf::pos_type +parser_buf::seekpos(pos_type sp, ::std::ios_base::openmode which) +{ + if(which & ::std::ios_base::out) + return pos_type(off_type(-1)); + off_type size = static_cast(this->egptr() - this->eback()); + charT* g = this->eback(); + if(off_type(sp) <= size) + { + this->setg(g, g + off_type(sp), g + size); + } + return pos_type(off_type(-1)); +} + +// +// class cpp_regex_traits_base: +// acts as a container for locale and the facets we are using. +// +template +struct cpp_regex_traits_base +{ + cpp_regex_traits_base(const std::locale& l) + { imbue(l); } + std::locale imbue(const std::locale& l); + + std::locale m_locale; + std::ctype const* m_pctype; +#ifndef BOOST_NO_STD_MESSAGES + std::messages const* m_pmessages; +#endif + std::collate const* m_pcollate; + + bool operator<(const cpp_regex_traits_base& b)const + { + if(m_pctype == b.m_pctype) + { +#ifndef BOOST_NO_STD_MESSAGES + if(m_pmessages == b.m_pmessages) + { + } + return m_pmessages < b.m_pmessages; +#else + return m_pcollate < b.m_pcollate; +#endif + } + return m_pctype < b.m_pctype; + } + bool operator==(const cpp_regex_traits_base& b)const + { + return (m_pctype == b.m_pctype) +#ifndef BOOST_NO_STD_MESSAGES + && (m_pmessages == b.m_pmessages) +#endif + && (m_pcollate == b.m_pcollate); + } +}; + +template +std::locale cpp_regex_traits_base::imbue(const std::locale& l) +{ + std::locale result(m_locale); + m_locale = l; + m_pctype = &BOOST_USE_FACET(std::ctype, l); +#ifndef BOOST_NO_STD_MESSAGES + m_pmessages = &BOOST_USE_FACET(std::messages, l); +#endif + m_pcollate = &BOOST_USE_FACET(std::collate, l); + return result; +} + +// +// class cpp_regex_traits_char_layer: +// implements methods that require specialisation for narrow characters: +// +template +class cpp_regex_traits_char_layer : public cpp_regex_traits_base +{ + typedef std::basic_string string_type; + typedef std::map map_type; + typedef typename map_type::const_iterator map_iterator_type; +public: + cpp_regex_traits_char_layer(const std::locale& l) + : cpp_regex_traits_base(l) + { + init(); + } + cpp_regex_traits_char_layer(const cpp_regex_traits_base& b) + : cpp_regex_traits_base(b) + { + init(); + } + void init(); + + regex_constants::syntax_type syntax_type(charT c)const + { + map_iterator_type i = m_char_map.find(c); + return ((i == m_char_map.end()) ? 0 : i->second); + } + regex_constants::escape_syntax_type escape_syntax_type(charT c) const + { + map_iterator_type i = m_char_map.find(c); + if(i == m_char_map.end()) + { + if(this->m_pctype->is(std::ctype_base::lower, c)) return regex_constants::escape_type_class; + if(this->m_pctype->is(std::ctype_base::upper, c)) return regex_constants::escape_type_not_class; + return 0; + } + return i->second; + } + +private: + string_type get_default_message(regex_constants::syntax_type); + // TODO: use a hash table when available! + map_type m_char_map; +}; + +template +void cpp_regex_traits_char_layer::init() +{ + // we need to start by initialising our syntax map so we know which + // character is used for which purpose: +#ifndef BOOST_NO_STD_MESSAGES +#ifndef __IBMCPP__ + typename std::messages::catalog cat = static_cast::catalog>(-1); +#else + typename std::messages::catalog cat = reinterpret_cast::catalog>(-1); +#endif + std::string cat_name(cpp_regex_traits::get_catalog_name()); + if(cat_name.size()) + { + cat = this->m_pmessages->open( + cat_name, + this->m_locale); + if((int)cat < 0) + { + std::string m("Unable to open message catalog: "); + std::runtime_error err(m + cat_name); + boost::re_detail::raise_runtime_error(err); + } + } + // + // if we have a valid catalog then load our messages: + // + if((int)cat >= 0) + { + try{ + for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i) + { + string_type mss = this->m_pmessages->get(cat, 0, i, get_default_message(i)); + for(typename string_type::size_type j = 0; j < mss.size(); ++j) + { + m_char_map[mss[j]] = i; + } + } + this->m_pmessages->close(cat); + } + catch(...) + { + this->m_pmessages->close(cat); + throw; + } + } + else + { +#endif + for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i) + { + const char* ptr = get_default_syntax(i); + while(ptr && *ptr) + { + m_char_map[this->m_pctype->widen(*ptr)] = i; + ++ptr; + } + } +#ifndef BOOST_NO_STD_MESSAGES + } +#endif +} + +template +typename cpp_regex_traits_char_layer::string_type + cpp_regex_traits_char_layer::get_default_message(regex_constants::syntax_type i) +{ + const char* ptr = get_default_syntax(i); + string_type result; + while(ptr && *ptr) + { + result.append(1, this->m_pctype->widen(*ptr)); + ++ptr; + } + return result; +} + +// +// specialised version for narrow characters: +// +template <> +class BOOST_REGEX_DECL cpp_regex_traits_char_layer : public cpp_regex_traits_base +{ + typedef std::string string_type; +public: + cpp_regex_traits_char_layer(const std::locale& l) + : cpp_regex_traits_base(l) + { + init(); + } + cpp_regex_traits_char_layer(const cpp_regex_traits_base& l) + : cpp_regex_traits_base(l) + { + init(); + } + + regex_constants::syntax_type syntax_type(char c)const + { + return m_char_map[static_cast(c)]; + } + regex_constants::escape_syntax_type escape_syntax_type(char c) const + { + return m_char_map[static_cast(c)]; + } + +private: + regex_constants::syntax_type m_char_map[1u << CHAR_BIT]; + void init(); +}; + +#ifdef BOOST_REGEX_BUGGY_CTYPE_FACET +enum +{ + char_class_space=1<<0, + char_class_print=1<<1, + char_class_cntrl=1<<2, + char_class_upper=1<<3, + char_class_lower=1<<4, + char_class_alpha=1<<5, + char_class_digit=1<<6, + char_class_punct=1<<7, + char_class_xdigit=1<<8, + char_class_alnum=char_class_alpha|char_class_digit, + char_class_graph=char_class_alnum|char_class_punct, + char_class_blank=1<<9, + char_class_word=1<<10, + char_class_unicode=1<<11 +}; + +#endif + +// +// class cpp_regex_traits_implementation: +// provides pimpl implementation for cpp_regex_traits. +// +template +class cpp_regex_traits_implementation : public cpp_regex_traits_char_layer +{ +public: + typedef typename cpp_regex_traits::char_class_type char_class_type; + typedef typename std::ctype::mask 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); + BOOST_STATIC_CONSTANT(char_class_type, mask_unicode = 1u << 26); +#endif + + typedef std::basic_string string_type; + typedef charT char_type; + //cpp_regex_traits_implementation(); + cpp_regex_traits_implementation(const std::locale& l) + : cpp_regex_traits_char_layer(l), m_is(&m_sbuf) + { + init(); + } + cpp_regex_traits_implementation(const cpp_regex_traits_base& l) + : cpp_regex_traits_char_layer(l), m_is(&m_sbuf) + { + init(); + } + std::string error_string(regex_constants::error_type n) const + { + if(!m_error_strings.empty()) + { + std::map::const_iterator p = m_error_strings.find(n); + return (p == m_error_strings.end()) ? std::string(get_default_error_string(n)) : p->second; + } + return get_default_error_string(n); + } + char_class_type lookup_classname(const charT* p1, const charT* p2) const + { + char_class_type result = lookup_classname_imp(p1, p2); + if(result == 0) + { + string_type temp(p1, p2); + this->m_pctype->tolower(&*temp.begin(), &*temp.begin() + temp.size()); + result = lookup_classname_imp(&*temp.begin(), &*temp.begin() + temp.size()); + } + return result; + } + string_type lookup_collatename(const charT* p1, const charT* p2) const; + string_type transform_primary(const charT* p1, const charT* p2) const; + string_type transform(const charT* p1, const charT* p2) const; + re_detail::parser_buf m_sbuf; // buffer for parsing numbers. + std::basic_istream m_is; // stream for parsing numbers. +private: + std::map m_error_strings; // error messages indexed by numberic ID + std::map m_custom_class_names; // character class names + std::map m_custom_collate_names; // collating element names + unsigned m_collate_type; // the form of the collation string + charT m_collate_delim; // the collation group delimiter + // + // helpers: + // + char_class_type lookup_classname_imp(const charT* p1, const charT* p2) const; + void init(); +#ifdef BOOST_REGEX_BUGGY_CTYPE_FACET +public: + bool isctype(charT c, char_class_type m)const; +#endif +}; + +#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET +#if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION) + +template +typename cpp_regex_traits_implementation::char_class_type const cpp_regex_traits_implementation::mask_blank; +template +typename cpp_regex_traits_implementation::char_class_type const cpp_regex_traits_implementation::mask_word; +template +typename cpp_regex_traits_implementation::char_class_type const cpp_regex_traits_implementation::mask_unicode; + +#endif +#endif + +template +typename cpp_regex_traits_implementation::string_type + cpp_regex_traits_implementation::transform_primary(const charT* p1, const charT* p2) const +{ + // + // PRECONDITIONS: + // + // A bug in gcc 3.2 (and maybe other versions as well) treats + // p1 as a null terminated string, for efficiency reasons + // we work around this elsewhere, but just assert here that + // we adhere to gcc's (buggy) preconditions... + // + BOOST_ASSERT(*p2 == 0); + + string_type result; + // + // swallowing all exceptions here is a bad idea + // however at least one std lib will always throw + // std::bad_alloc for certain arguments... + // + try{ + // + // What we do here depends upon the format of the sort key returned by + // sort key returned by this->transform: + // + switch(m_collate_type) + { + case sort_C: + case sort_unknown: + // the best we can do is translate to lower case, then get a regular sort key: + { + result.assign(p1, p2); + this->m_pctype->tolower(&*result.begin(), &*result.begin() + result.size()); + result = this->m_pcollate->transform(&*result.begin(), &*result.begin() + result.size()); + break; + } + case sort_fixed: + { + // get a regular sort key, and then truncate it: + result.assign(this->m_pcollate->transform(p1, p2)); + result.erase(this->m_collate_delim); + break; + } + case sort_delim: + // get a regular sort key, and then truncate everything after the delim: + result.assign(this->m_pcollate->transform(p1, p2)); + std::size_t i; + for(i = 0; i < result.size(); ++i) + { + if(result[i] == m_collate_delim) + break; + } + result.erase(i); + break; + } + }catch(...){} + while(result.size() && (charT(0) == *result.rbegin())) + result.erase(result.size() - 1); + if(result.empty()) + { + // character is ignorable at the primary level: + result = string_type(1, charT(0)); + } + return result; +} + +template +typename cpp_regex_traits_implementation::string_type + cpp_regex_traits_implementation::transform(const charT* p1, const charT* p2) const +{ + // + // PRECONDITIONS: + // + // A bug in gcc 3.2 (and maybe other versions as well) treats + // p1 as a null terminated string, for efficiency reasons + // we work around this elsewhere, but just assert here that + // we adhere to gcc's (buggy) preconditions... + // + BOOST_ASSERT(*p2 == 0); + // + // swallowing all exceptions here is a bad idea + // however at least one std lib will always throw + // std::bad_alloc for certain arguments... + // + string_type result; + try{ + result = this->m_pcollate->transform(p1, p2); + // + // Borland's STLPort version returns a NULL-terminated + // string that has garbage at the end - each call to + // std::collate::transform returns a different string! + // So as a workaround, we'll truncate the string at the first NULL + // which _seems_ to work.... +#if BOOST_WORKAROUND(__BORLANDC__, < 0x600) + result.erase(result.find(charT(0))); +#else + // + // some implementations (Dinkumware) append unnecessary trailing \0's: + while(result.size() && (charT(0) == *result.rbegin())) + result.erase(result.size() - 1); +#endif + BOOST_ASSERT(std::find(result.begin(), result.end(), charT(0)) == result.end()); + } + catch(...) + { + } + return result; +} + + +template +typename cpp_regex_traits_implementation::string_type + cpp_regex_traits_implementation::lookup_collatename(const charT* p1, const charT* p2) const +{ + typedef typename std::map::const_iterator iter_type; + if(m_custom_collate_names.size()) + { + iter_type pos = m_custom_collate_names.find(string_type(p1, p2)); + if(pos != m_custom_collate_names.end()) + return pos->second; + } +#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\ + && !BOOST_WORKAROUND(BOOST_MSVC, < 1300)\ + && !BOOST_WORKAROUND(__BORLANDC__, <= 0x0551) + std::string name(p1, p2); +#else + std::string name; + const charT* p0 = p1; + while(p0 != p2) + name.append(1, char(*p0++)); +#endif + name = lookup_default_collate_name(name); +#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\ + && !BOOST_WORKAROUND(BOOST_MSVC, < 1300)\ + && !BOOST_WORKAROUND(__BORLANDC__, <= 0x0551) + if(name.size()) + return string_type(name.begin(), name.end()); +#else + if(name.size()) + { + string_type result; + typedef std::string::const_iterator iter; + iter b = name.begin(); + iter e = name.end(); + while(b != e) + result.append(1, charT(*b++)); + return result; + } +#endif + if(p2 - p1 == 1) + return string_type(1, *p1); + return string_type(); +} + +template +void cpp_regex_traits_implementation::init() +{ +#ifndef BOOST_NO_STD_MESSAGES +#ifndef __IBMCPP__ + typename std::messages::catalog cat = static_cast::catalog>(-1); +#else + typename std::messages::catalog cat = reinterpret_cast::catalog>(-1); +#endif + std::string cat_name(cpp_regex_traits::get_catalog_name()); + if(cat_name.size()) + { + cat = this->m_pmessages->open( + cat_name, + this->m_locale); + if((int)cat < 0) + { + std::string m("Unable to open message catalog: "); + std::runtime_error err(m + cat_name); + boost::re_detail::raise_runtime_error(err); + } + } + // + // if we have a valid catalog then load our messages: + // + if((int)cat >= 0) + { + // + // Error messages: + // + for(boost::regex_constants::error_type i = static_cast(0); + i <= boost::regex_constants::error_unknown; + i = static_cast(i + 1)) + { + const char* p = get_default_error_string(i); + string_type default_message; + while(*p) + { + default_message.append(1, this->m_pctype->widen(*p)); + ++p; + } + string_type s = this->m_pmessages->get(cat, 0, i+200, default_message); + std::string result; + for(std::string::size_type j = 0; j < s.size(); ++j) + { + result.append(1, this->m_pctype->narrow(s[j], 0)); + } + m_error_strings[i] = result; + } + // + // Custom class names: + // +#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET + static const char_class_type masks[14] = + { + std::ctype::alnum, + std::ctype::alpha, + std::ctype::cntrl, + std::ctype::digit, + std::ctype::graph, + std::ctype::lower, + std::ctype::print, + std::ctype::punct, + std::ctype::space, + std::ctype::upper, + std::ctype::xdigit, + cpp_regex_traits_implementation::mask_blank, + cpp_regex_traits_implementation::mask_word, + cpp_regex_traits_implementation::mask_unicode, + }; +#else + static const char_class_type masks[14] = + { + ::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_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_xdigit, + ::boost::re_detail::char_class_blank, + ::boost::re_detail::char_class_word, + ::boost::re_detail::char_class_unicode, + }; +#endif + static const string_type null_string; + for(unsigned int j = 0; j <= 13; ++j) + { + string_type s(this->m_pmessages->get(cat, 0, j+300, null_string)); + if(s.size()) + this->m_custom_class_names[s] = masks[j]; + } + } +#endif + // + // get the collation format used by m_pcollate: + // + m_collate_type = re_detail::find_sort_syntax(this, &m_collate_delim); +} + +template +typename cpp_regex_traits_implementation::char_class_type + cpp_regex_traits_implementation::lookup_classname_imp(const charT* p1, const charT* p2) const +{ +#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET + static const char_class_type masks[20] = + { + 0, + std::ctype::alnum, + std::ctype::alpha, + cpp_regex_traits_implementation::mask_blank, + std::ctype::cntrl, + std::ctype::digit, + std::ctype::digit, + std::ctype::graph, + std::ctype::lower, + std::ctype::lower, + std::ctype::print, + std::ctype::punct, + std::ctype::space, + std::ctype::space, + std::ctype::upper, + cpp_regex_traits_implementation::mask_unicode, + std::ctype::upper, + std::ctype::alnum | cpp_regex_traits_implementation::mask_word, + std::ctype::alnum | cpp_regex_traits_implementation::mask_word, + std::ctype::xdigit, + }; +#else + static const char_class_type masks[20] = + { + 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_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_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, + }; +#endif + if(m_custom_class_names.size()) + { + typedef typename std::map, char_class_type>::const_iterator map_iter; + map_iter pos = m_custom_class_names.find(string_type(p1, p2)); + if(pos != m_custom_class_names.end()) + return pos->second; + } + std::size_t id = 1 + re_detail::get_default_class_id(p1, p2); + BOOST_ASSERT(id < sizeof(masks) / sizeof(masks[0])); + return masks[id]; +} + +#ifdef BOOST_REGEX_BUGGY_CTYPE_FACET +template +bool cpp_regex_traits_implementation::isctype(const charT c, char_class_type mask) const +{ + return + ((mask & ::boost::re_detail::char_class_space) && (m_pctype->is(std::ctype::space, c))) + || ((mask & ::boost::re_detail::char_class_print) && (m_pctype->is(std::ctype::print, c))) + || ((mask & ::boost::re_detail::char_class_cntrl) && (m_pctype->is(std::ctype::cntrl, c))) + || ((mask & ::boost::re_detail::char_class_upper) && (m_pctype->is(std::ctype::upper, c))) + || ((mask & ::boost::re_detail::char_class_lower) && (m_pctype->is(std::ctype::lower, c))) + || ((mask & ::boost::re_detail::char_class_alpha) && (m_pctype->is(std::ctype::alpha, c))) + || ((mask & ::boost::re_detail::char_class_digit) && (m_pctype->is(std::ctype::digit, c))) + || ((mask & ::boost::re_detail::char_class_punct) && (m_pctype->is(std::ctype::punct, c))) + || ((mask & ::boost::re_detail::char_class_xdigit) && (m_pctype->is(std::ctype::xdigit, c))) + || ((mask & ::boost::re_detail::char_class_blank) && (m_pctype->is(std::ctype::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)); +} +#endif + + +template +inline boost::shared_ptr > create_cpp_regex_traits(const std::locale& l BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(charT)) +{ + cpp_regex_traits_base key(l); + return ::boost::object_cache, cpp_regex_traits_implementation >::get(key, 5); +} + +} // re_detail + +template +class cpp_regex_traits +{ +private: + typedef std::ctype ctype_type; +public: + typedef charT char_type; + typedef std::size_t size_type; + typedef std::basic_string string_type; + typedef std::locale locale_type; + typedef boost::uint_least32_t char_class_type; + + struct boost_extensions_tag{}; + + cpp_regex_traits() + : m_pimpl(re_detail::create_cpp_regex_traits(std::locale())) + { } + static size_type length(const char_type* p) + { + return std::char_traits::length(p); + } + regex_constants::syntax_type syntax_type(charT c)const + { + return m_pimpl->syntax_type(c); + } + regex_constants::escape_syntax_type escape_syntax_type(charT c) const + { + return m_pimpl->escape_syntax_type(c); + } + charT translate(charT c) const + { + return c; + } + charT translate_nocase(charT c) const + { + return m_pimpl->m_pctype->tolower(c); + } + charT translate(charT c, bool icase) const + { + return icase ? m_pimpl->m_pctype->tolower(c) : c; + } + charT tolower(charT c) const + { + return m_pimpl->m_pctype->tolower(c); + } + charT toupper(charT c) const + { + return m_pimpl->m_pctype->toupper(c); + } + string_type transform(const charT* p1, const charT* p2) const + { + return m_pimpl->transform(p1, p2); + } + string_type transform_primary(const charT* p1, const charT* p2) const + { + return m_pimpl->transform_primary(p1, p2); + } + char_class_type lookup_classname(const charT* p1, const charT* p2) const + { + return m_pimpl->lookup_classname(p1, p2); + } + string_type lookup_collatename(const charT* p1, const charT* p2) const + { + return m_pimpl->lookup_collatename(p1, p2); + } + bool isctype(charT c, char_class_type f) const + { +#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET + typedef typename std::ctype::mask ctype_mask; + + static const ctype_mask mask_base = + static_cast( + std::ctype::alnum + | std::ctype::alpha + | std::ctype::cntrl + | std::ctype::digit + | std::ctype::graph + | std::ctype::lower + | std::ctype::print + | std::ctype::punct + | std::ctype::space + | std::ctype::upper + | std::ctype::xdigit); + + if((f & mask_base) + && (m_pimpl->m_pctype->is( + static_cast(f & mask_base), c))) + return true; + else if((f & re_detail::cpp_regex_traits_implementation::mask_unicode) && re_detail::is_extended(c)) + return true; + else if((f & re_detail::cpp_regex_traits_implementation::mask_word) && (c == '_')) + return true; + else if((f & re_detail::cpp_regex_traits_implementation::mask_blank) + && m_pimpl->m_pctype->is(std::ctype::space, c) + && !re_detail::is_separator(c)) + return true; + return false; +#else + return m_pimpl->isctype(c, f); +#endif + } + int toi(const charT*& p1, const charT* p2, int radix)const; + int value(charT c, int radix)const + { + const charT* pc = &c; + return toi(pc, pc + 1, radix); + } + locale_type imbue(locale_type l) + { + std::locale result(getloc()); + m_pimpl = re_detail::create_cpp_regex_traits(l); + return result; + } + locale_type getloc()const + { + return m_pimpl->m_locale; + } + std::string error_string(regex_constants::error_type n) const + { + return m_pimpl->error_string(n); + } + + // + // extension: + // set the name of the message catalog in use (defaults to "boost_regex"). + // + static std::string catalog_name(const std::string& name); + static std::string get_catalog_name(); + +private: + boost::shared_ptr > m_pimpl; + // + // catalog name handler: + // + static std::string& get_catalog_name_inst(); + +#ifdef BOOST_HAS_THREADS + static static_mutex& get_mutex_inst(); +#endif +}; + + +template +int cpp_regex_traits::toi(const charT*& first, const charT* last, int radix)const +{ + // we do NOT want to parse any thousands separators inside the stream: + last = std::find(first, last, BOOST_USE_FACET(std::numpunct, m_pimpl->m_is.getloc()).thousands_sep()); + m_pimpl->m_sbuf.pubsetbuf(const_cast(static_cast(first)), static_cast(last-first)); + m_pimpl->m_is.clear(); + if(std::abs(radix) == 16) m_pimpl->m_is >> std::hex; + else if(std::abs(radix) == 8) m_pimpl->m_is >> std::oct; + else m_pimpl->m_is >> std::dec; + int val; + if(m_pimpl->m_is >> val) + { + first = first + ((last - first) - m_pimpl->m_sbuf.in_avail()); + return val; + } + else + return -1; +} + +template +std::string cpp_regex_traits::catalog_name(const std::string& name) +{ +#ifdef BOOST_HAS_THREADS + static_mutex::scoped_lock lk(get_mutex_inst()); +#endif + std::string result(get_catalog_name_inst()); + get_catalog_name_inst() = name; + return result; +} + +template +std::string& cpp_regex_traits::get_catalog_name_inst() +{ + static std::string s_name; + return s_name; +} + +template +std::string cpp_regex_traits::get_catalog_name() +{ +#ifdef BOOST_HAS_THREADS + static_mutex::scoped_lock lk(get_mutex_inst()); +#endif + std::string result(get_catalog_name_inst()); + return result; +} + +#ifdef BOOST_HAS_THREADS +template +static_mutex& cpp_regex_traits::get_mutex_inst() +{ + static static_mutex s_mutex = BOOST_STATIC_MUTEX_INIT; + return s_mutex; +} +#endif + + +} // boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + +#endif + +#endif diff --git a/boost/boost/regex/v4/cregex.hpp b/boost/boost/regex/v4/cregex.hpp index 368f1d85e9..17818ec581 100644 --- a/boost/boost/regex/v4/cregex.hpp +++ b/boost/boost/regex/v4/cregex.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -24,6 +24,13 @@ #include #endif #include +#include + +#ifdef __cplusplus +#include +#else +#include +#endif #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX @@ -46,8 +53,12 @@ typedef size_t regsize_t; typedef struct { unsigned int re_magic; - unsigned int re_nsub; /* number of parenthesized subexpressions */ - const char* re_endp; /* end pointer for REG_PEND */ +#ifdef __cplusplus + std::size_t re_nsub; /* number of parenthesized subexpressions */ +#else + size_t re_nsub; +#endif + const char* re_endp; /* end pointer for REG_PEND */ void* guts; /* none of your business :-) */ match_flag_type eflags; /* none of your business :-) */ } regex_tA; @@ -56,7 +67,11 @@ typedef struct typedef struct { unsigned int re_magic; - unsigned int re_nsub; /* number of parenthesized subexpressions */ +#ifdef __cplusplus + std::size_t re_nsub; /* number of parenthesized subexpressions */ +#else + size_t re_nsub; +#endif const wchar_t* re_endp; /* end pointer for REG_PEND */ void* guts; /* none of your business :-) */ match_flag_type eflags; /* none of your business :-) */ @@ -102,6 +117,39 @@ typedef enum{ REG_STARTEND = 00004 } reg_exec_flags; +// +// POSIX error codes: +// +typedef unsigned reg_error_t; +typedef reg_error_t reg_errcode_t; // backwards compatibility + +static const reg_error_t REG_NOERROR = 0; /* Success. */ +static const reg_error_t REG_NOMATCH = 1; /* Didn't find a match (for regexec). */ + + /* POSIX regcomp return error codes. (In the order listed in the + standard.) */ +static const reg_error_t REG_BADPAT = 2; /* Invalid pattern. */ +static const reg_error_t REG_ECOLLATE = 3; /* Undefined collating element. */ +static const reg_error_t REG_ECTYPE = 4; /* Invalid character class name. */ +static const reg_error_t REG_EESCAPE = 5; /* Trailing backslash. */ +static const reg_error_t REG_ESUBREG = 6; /* Invalid back reference. */ +static const reg_error_t REG_EBRACK = 7; /* Unmatched left bracket. */ +static const reg_error_t REG_EPAREN = 8; /* Parenthesis imbalance. */ +static const reg_error_t REG_EBRACE = 9; /* Unmatched \{. */ +static const reg_error_t REG_BADBR = 10; /* Invalid contents of \{\}. */ +static const reg_error_t REG_ERANGE = 11; /* Invalid range end. */ +static const reg_error_t REG_ESPACE = 12; /* Ran out of memory. */ +static const reg_error_t REG_BADRPT = 13; /* No preceding re for repetition op. */ +static const reg_error_t REG_EEND = 14; /* unexpected end of expression */ +static const reg_error_t REG_ESIZE = 15; /* expression too big */ +static const reg_error_t REG_ERPAREN = 8; /* = REG_EPAREN : unmatched right parenthesis */ +static const reg_error_t REG_EMPTY = 17; /* empty expression */ +static const reg_error_t REG_E_MEMORY = 15; /* = REG_ESIZE : out of memory */ +static const reg_error_t REG_ECOMPLEXITY = 18; /* complexity too high */ +static const reg_error_t REG_ESTACK = 19; /* out of stack space */ +static const reg_error_t REG_E_UNKNOWN = 20; /* unknown error */ +static const reg_error_t REG_ENOSYS = 20; /* = REG_E_UNKNOWN : Reserved. */ + BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA*, const char*, int); BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int, const regex_tA*, char*, regsize_t); BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA*, const char*, regsize_t, regmatch_t*, int); @@ -128,34 +176,6 @@ BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeW(regex_tW*); #define regex_t regex_tA #endif -/* regerror() flags */ -typedef enum -{ - REG_NOERROR = 0, /* Success. */ - REG_NOMATCH = 1, /* Didn't find a match (for regexec). */ - - /* POSIX regcomp return error codes. (In the order listed in the - standard.) */ - REG_BADPAT = 2, /* Invalid pattern. */ - REG_ECOLLATE = 3, /* Undefined collating element. */ - REG_ECTYPE = 4, /* Invalid character class name. */ - REG_EESCAPE = 5, /* Trailing backslash. */ - REG_ESUBREG = 6, /* Invalid back reference. */ - REG_EBRACK = 7, /* Unmatched left bracket. */ - REG_EPAREN = 8, /* Parenthesis imbalance. */ - REG_EBRACE = 9, /* Unmatched \{. */ - REG_BADBR = 10, /* Invalid contents of \{\}. */ - REG_ERANGE = 11, /* Invalid range end. */ - REG_ESPACE = 12, /* Ran out of memory. */ - REG_BADRPT = 13, /* No preceding re for repetition op. */ - REG_EEND = 14, /* unexpected end of expression */ - REG_ESIZE = 15, /* expression too big */ - REG_ERPAREN = 16, /* unmatched right parenthesis */ - REG_EMPTY = 17, /* empty expression */ - REG_E_MEMORY = REG_ESIZE, /* out of memory */ - REG_E_UNKNOWN = 18 /* unknown error */ -} reg_errcode_t; - #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_SUFFIX #endif @@ -165,10 +185,10 @@ typedef enum } // namespace #endif -#if defined(__cplusplus) // // C++ high level wrapper goes here: // +#if defined(__cplusplus) #include #include namespace boost{ @@ -248,15 +268,12 @@ public: std::size_t Position(int i = 0)const; std::size_t Length(int i = 0)const; bool Matched(int i = 0)const; - unsigned int Marks()const; + std::size_t Marks()const; std::string What(int i = 0)const; std::string operator[](int i)const { return What(i); } -#ifdef __MINGW32__ - static const std::size_t npos = ~0u; -#else static const std::size_t npos; -#endif + friend struct re_detail::pred1; friend struct re_detail::pred2; friend struct re_detail::pred3; @@ -271,7 +288,7 @@ public: #endif -#endif /* include guard */ +#endif // include guard diff --git a/boost/boost/regex/v4/error_type.hpp b/boost/boost/regex/v4/error_type.hpp new file mode 100644 index 0000000000..b6633a0092 --- /dev/null +++ b/boost/boost/regex/v4/error_type.hpp @@ -0,0 +1,58 @@ +/* + * + * Copyright (c) 2003-2005 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE error_type.hpp + * VERSION see + * DESCRIPTION: Declares regular expression error type enumerator. + */ + +#ifndef BOOST_REGEX_ERROR_TYPE_HPP +#define BOOST_REGEX_ERROR_TYPE_HPP + +#ifdef __cplusplus +namespace boost{ +#endif + +#ifdef __cplusplus +namespace regex_constants{ + +enum error_type{ + + error_ok = 0, // not used + error_no_match = 1, // not used + error_bad_pattern = 2, + error_collate = 3, + error_ctype = 4, + error_escape = 5, + error_backref = 6, + error_brack = 7, + error_paren = 8, + error_brace = 9, + error_badbrace = 10, + error_range = 11, + error_space = 12, + error_badrepeat = 13, + error_end = 14, // not used + error_size = 15, + error_right_paren = 16, // not used + error_empty = 17, + error_complexity = 18, + error_stack = 19, + error_unknown = 20 +}; + +} +} +#endif // __cplusplus + +#endif diff --git a/boost/boost/regex/v4/fileiter.hpp b/boost/boost/regex/v4/fileiter.hpp index 341ce53bb1..21a785ea1a 100644 --- a/boost/boost/regex/v4/fileiter.hpp +++ b/boost/boost/regex/v4/fileiter.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -24,6 +24,7 @@ #ifndef BOOST_REGEX_CONFIG_HPP #include #endif +#include #ifndef BOOST_REGEX_NO_FILEITER @@ -60,6 +61,7 @@ typedef HANDLE _fi_find_handle; #elif defined(BOOST_REGEX_FI_POSIX_DIR) +#include #include #include #include @@ -239,8 +241,8 @@ public: mapfile_iterator& operator = (const mapfile_iterator& i); char operator* ()const { - assert(node >= file->_first); - assert(node < file->_last); + BOOST_ASSERT(node >= file->_first); + BOOST_ASSERT(node < file->_last); return file ? *(*node + sizeof(int) + offset) : char(0); } char operator[] (long off)const diff --git a/boost/boost/regex/v4/instances.hpp b/boost/boost/regex/v4/instances.hpp index 007ffd3562..b9898cb047 100644 --- a/boost/boost/regex/v4/instances.hpp +++ b/boost/boost/regex/v4/instances.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -33,6 +33,10 @@ namespace boost{ # error "BOOST_REGEX_CHAR_T not defined" #endif +#ifndef BOOST_REGEX_TRAITS_T +# define BOOST_REGEX_TRAITS_T , boost::regex_traits +#endif + // // what follows is compiler specific: // @@ -47,7 +51,11 @@ namespace boost{ # pragma option push -Jgx # endif -template class BOOST_REGEX_DECL reg_expression< BOOST_REGEX_CHAR_T >; +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::allocator_type BOOST_REGEX_TRAITS_T >; +#endif # ifndef BOOST_REGEX_INSTANTIATE # pragma option pop @@ -57,10 +65,14 @@ template class BOOST_REGEX_DECL reg_expression< BOOST_REGEX_CHAR_T >; # include BOOST_ABI_SUFFIX #endif -#elif (defined(BOOST_MSVC) && defined(_MSC_EXTENSIONS)) || defined(__GNUC__) +#elif defined(BOOST_MSVC) || defined(__ICL) # ifndef BOOST_REGEX_INSTANTIATE -# define template extern template +# ifdef __GNUC__ +# define template __extension__ extern template +# else +# define template extern template +# endif # endif # ifdef BOOST_MSVC @@ -68,7 +80,26 @@ template class BOOST_REGEX_DECL reg_expression< BOOST_REGEX_CHAR_T >; # pragma warning(disable : 4251 4231 4660) # endif -template class BOOST_REGEX_DECL reg_expression< BOOST_REGEX_CHAR_T >; +template class BOOST_REGEX_DECL basic_regex< BOOST_REGEX_CHAR_T BOOST_REGEX_TRAITS_T >; + +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) +template class BOOST_REGEX_DECL match_results< const BOOST_REGEX_CHAR_T* >; +#endif +#ifndef BOOST_NO_STD_ALLOCATOR +template class BOOST_REGEX_DECL ::boost::re_detail::perl_matcher::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))\ + && !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))\ + && !defined(BOOST_REGEX_ICU_INSTANCES) +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) +template class BOOST_REGEX_DECL match_results< std::basic_string::const_iterator >; +#endif +#ifndef BOOST_NO_STD_ALLOCATOR +template class BOOST_REGEX_DECL ::boost::re_detail::perl_matcher< std::basic_string::const_iterator, match_results< std::basic_string::const_iterator >::allocator_type, boost::regex_traits >; +#endif +#endif + # ifdef BOOST_MSVC # pragma warning(pop) @@ -78,6 +109,91 @@ template class BOOST_REGEX_DECL reg_expression< BOOST_REGEX_CHAR_T >; # undef template # endif +#elif (defined(__GNUC__) && (__GNUC__ >= 3)) + +# ifndef BOOST_REGEX_INSTANTIATE +# define template __extension__ extern template +# endif + +#if !defined(BOOST_NO_STD_LOCALE) && !defined(BOOST_REGEX_ICU_INSTANCES) +namespace re_detail{ +template BOOST_REGEX_DECL +std::locale cpp_regex_traits_base::imbue(const std::locale& l); + +template BOOST_REGEX_DECL +cpp_regex_traits_implementation::string_type + cpp_regex_traits_implementation::transform_primary(const BOOST_REGEX_CHAR_T* p1, const BOOST_REGEX_CHAR_T* p2) const; +template BOOST_REGEX_DECL +cpp_regex_traits_implementation::string_type + cpp_regex_traits_implementation::transform(const BOOST_REGEX_CHAR_T* p1, const BOOST_REGEX_CHAR_T* p2) const; +template BOOST_REGEX_DECL +cpp_regex_traits_implementation::string_type + cpp_regex_traits_implementation::lookup_collatename(const BOOST_REGEX_CHAR_T* p1, const BOOST_REGEX_CHAR_T* p2) const; +template BOOST_REGEX_DECL +void cpp_regex_traits_implementation::init(); +template BOOST_REGEX_DECL +cpp_regex_traits_implementation::char_class_type + cpp_regex_traits_implementation::lookup_classname_imp(const BOOST_REGEX_CHAR_T* p1, const BOOST_REGEX_CHAR_T* p2) const; +#ifdef BOOST_REGEX_BUGGY_CTYPE_FACET +template BOOST_REGEX_DECL +bool cpp_regex_traits_implementation::isctype(const BOOST_REGEX_CHAR_T c, char_class_type mask) const; +#endif +} // namespace +template BOOST_REGEX_DECL +int cpp_regex_traits::toi(const BOOST_REGEX_CHAR_T*& first, const BOOST_REGEX_CHAR_T* last, int radix)const; +template BOOST_REGEX_DECL +std::string cpp_regex_traits::catalog_name(const std::string& name); +template BOOST_REGEX_DECL +std::string& cpp_regex_traits::get_catalog_name_inst(); +template BOOST_REGEX_DECL +std::string cpp_regex_traits::get_catalog_name(); +#ifdef BOOST_HAS_THREADS +template BOOST_REGEX_DECL +static_mutex& cpp_regex_traits::get_mutex_inst(); +#endif +#endif + +template BOOST_REGEX_DECL basic_regex& + basic_regex::do_assign( + const BOOST_REGEX_CHAR_T* p1, + const BOOST_REGEX_CHAR_T* p2, + flag_type f); +template BOOST_REGEX_DECL basic_regex::locale_type BOOST_REGEX_CALL + basic_regex::imbue(locale_type l); + +template BOOST_REGEX_DECL void BOOST_REGEX_CALL + match_results::maybe_assign( + const match_results& m); + +namespace re_detail{ +template BOOST_REGEX_DECL void perl_matcher::allocator_type BOOST_REGEX_TRAITS_T >::construct_init( + const basic_regex& e, match_flag_type f); +template BOOST_REGEX_DECL bool perl_matcher::allocator_type BOOST_REGEX_TRAITS_T >::match(); +template BOOST_REGEX_DECL bool perl_matcher::allocator_type BOOST_REGEX_TRAITS_T >::find(); +} // namespace + +#if (defined(__GLIBCPP__) || defined(__GLIBCXX__)) \ + && !defined(BOOST_REGEX_ICU_INSTANCES)\ + && !defined(__SGI_STL_PORT)\ + && !defined(_STLPORT_VERSION) +// std:basic_string<>::const_iterator instances as well: +template BOOST_REGEX_DECL void BOOST_REGEX_CALL + match_results::const_iterator>::maybe_assign( + const match_results::const_iterator>& m); + +namespace re_detail{ +template BOOST_REGEX_DECL void perl_matcher::const_iterator, match_results< std::basic_string::const_iterator >::allocator_type, boost::regex_traits >::construct_init( + const basic_regex& e, match_flag_type f); +template BOOST_REGEX_DECL bool perl_matcher::const_iterator, match_results< std::basic_string::const_iterator >::allocator_type, boost::regex_traits >::match(); +template BOOST_REGEX_DECL bool perl_matcher::const_iterator, match_results< std::basic_string::const_iterator >::allocator_type, boost::regex_traits >::find(); +} // namespace +#endif + +# ifdef template +# undef template +# endif + + #endif } // namespace boost @@ -87,3 +203,4 @@ template class BOOST_REGEX_DECL reg_expression< BOOST_REGEX_CHAR_T >; + diff --git a/boost/boost/regex/v4/iterator_category.hpp b/boost/boost/regex/v4/iterator_category.hpp index aeb0e32c91..20870a0ced 100644 --- a/boost/boost/regex/v4/iterator_category.hpp +++ b/boost/boost/regex/v4/iterator_category.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file diff --git a/boost/boost/regex/v4/iterator_traits.hpp b/boost/boost/regex/v4/iterator_traits.hpp index 58fbd51c52..7e247f536b 100644 --- a/boost/boost/regex/v4/iterator_traits.hpp +++ b/boost/boost/regex/v4/iterator_traits.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -71,6 +71,24 @@ template<> struct regex_iterator_traits : pointer_iterator_traits{}; template<> struct regex_iterator_traits : const_pointer_iterator_traits{}; +// +// the follwoing are needed for ICU support: +// +template<> +struct regex_iterator_traits : pointer_iterator_traits{}; +template<> +struct regex_iterator_traits : const_pointer_iterator_traits{}; +template<> +struct regex_iterator_traits : pointer_iterator_traits{}; +template<> +struct regex_iterator_traits : const_pointer_iterator_traits{}; + +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +template<> +struct regex_iterator_traits : pointer_iterator_traits{}; +template<> +struct regex_iterator_traits : const_pointer_iterator_traits{}; +#endif #if defined(__SGI_STL_PORT) && defined(__STL_DEBUG) template<> diff --git a/boost/boost/regex/v4/match_flags.hpp b/boost/boost/regex/v4/match_flags.hpp index cb797b0e12..a86fe4613b 100644 --- a/boost/boost/regex/v4/match_flags.hpp +++ b/boost/boost/regex/v4/match_flags.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -23,58 +23,57 @@ # include #endif +#include #ifdef __cplusplus -#include namespace boost{ namespace regex_constants{ -#else -#define BOOST_WORKAROUND(x, y) 1 #endif typedef enum _match_flags { match_default = 0, - match_not_bol = 1, /* first is not start of line*/ - match_not_eol = match_not_bol << 1, /* last is not end of line*/ - match_not_bob = match_not_eol << 1, /* first is not start of buffer*/ - match_not_eob = match_not_bob << 1, /* last is not end of buffer*/ - match_not_bow = match_not_eob << 1, /* first is not start of word*/ - match_not_eow = match_not_bow << 1, /* last is not end of word*/ - match_not_dot_newline = match_not_eow << 1, /* \n is not matched by '.'*/ - match_not_dot_null = match_not_dot_newline << 1, /* '\0' is not matched by '.'*/ - match_prev_avail = match_not_dot_null << 1, /* *--first is a valid expression*/ - match_init = match_prev_avail << 1, /* internal use*/ - match_any = match_init << 1, /* don't care what we match*/ - match_not_null = match_any << 1, /* string can't be null*/ - match_continuous = match_not_null << 1, /* each grep match must continue from*/ - /* uninterupted from the previous one*/ - match_partial = match_continuous << 1, /* find partial matches*/ - - match_stop = match_partial << 1, /* stop after first match (grep) V3 only*/ - match_not_initial_null = match_stop, /* don't match initial null, V4 only*/ - match_all = match_stop << 1, /* must find the whole of input even if match_any is set*/ - match_perl = match_all << 1, /* Use perl matching rules*/ - match_posix = match_perl << 1, /* Use POSIX matching rules*/ - match_nosubs = match_posix << 1, /* don't trap marked subs*/ - match_extra = match_nosubs << 1, /* include full capture information for repeated captures*/ - match_single_line = match_extra << 1, /* treat text as single line and ignor any \n's when matching ^ and $.*/ - match_unused1 = match_single_line << 1, /* unused*/ - match_unused2 = match_unused1 << 1, /* unused*/ - match_unused3 = match_unused2 << 1, /* unused*/ + match_not_bol = 1, // first is not start of line + match_not_eol = match_not_bol << 1, // last is not end of line + match_not_bob = match_not_eol << 1, // first is not start of buffer + match_not_eob = match_not_bob << 1, // last is not end of buffer + match_not_bow = match_not_eob << 1, // first is not start of word + match_not_eow = match_not_bow << 1, // last is not end of word + match_not_dot_newline = match_not_eow << 1, // \n is not matched by '.' + match_not_dot_null = match_not_dot_newline << 1, // '\0' is not matched by '.' + match_prev_avail = match_not_dot_null << 1, // *--first is a valid expression + match_init = match_prev_avail << 1, // internal use + match_any = match_init << 1, // don't care what we match + match_not_null = match_any << 1, // string can't be null + match_continuous = match_not_null << 1, // each grep match must continue from + // uninterupted from the previous one + match_partial = match_continuous << 1, // find partial matches + + match_stop = match_partial << 1, // stop after first match (grep) V3 only + match_not_initial_null = match_stop, // don't match initial null, V4 only + match_all = match_stop << 1, // must find the whole of input even if match_any is set + match_perl = match_all << 1, // Use perl matching rules + match_posix = match_perl << 1, // Use POSIX matching rules + match_nosubs = match_posix << 1, // don't trap marked subs + match_extra = match_nosubs << 1, // include full capture information for repeated captures + match_single_line = match_extra << 1, // treat text as single line and ignor any \n's when matching ^ and $. + match_unused1 = match_single_line << 1, // unused + match_unused2 = match_unused1 << 1, // unused + match_unused3 = match_unused2 << 1, // unused match_max = match_unused3, - format_perl = 0, /* perl style replacement*/ - format_default = 0, /* ditto.*/ - format_sed = match_max << 1, /* sed style replacement.*/ - format_all = format_sed << 1, /* enable all extentions to sytax.*/ - format_no_copy = format_all << 1, /* don't copy non-matching segments.*/ - format_first_only = format_no_copy << 1, /* Only replace first occurance.*/ - format_is_if = format_first_only << 1 /* internal use only.*/ + format_perl = 0, // perl style replacement + format_default = 0, // ditto. + format_sed = match_max << 1, // sed style replacement. + format_all = format_sed << 1, // enable all extentions to sytax. + format_no_copy = format_all << 1, // don't copy non-matching segments. + format_first_only = format_no_copy << 1, // Only replace first occurance. + format_is_if = format_first_only << 1, // internal use only. + format_literal = format_is_if << 1 // treat string as a literal } match_flags; -#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) || defined(__SUNPRO_CC) +#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) typedef unsigned long match_flag_type; #else typedef match_flags match_flag_type; @@ -90,11 +89,11 @@ inline match_flags operator^(match_flags m1, match_flags m2) inline match_flags operator~(match_flags m1) { return static_cast(~static_cast(m1)); } inline match_flags& operator&=(match_flags& m1, match_flags m2) -{ m1 = static_cast(m1&m2); return m1; } +{ m1 = m1&m2; return m1; } inline match_flags& operator|=(match_flags& m1, match_flags m2) -{ m1 = static_cast(m1|m2); return m1; } +{ m1 = m1|m2; return m1; } inline match_flags& operator^=(match_flags& m1, match_flags m2) -{ m1 = static_cast(m1^m2); return m1; } +{ m1 = m1^m2; return m1; } #endif #endif @@ -136,6 +135,6 @@ using regex_constants::format_first_only; //using regex_constants::format_is_if; } // namespace boost -#endif /* __cplusplus */ -#endif /* include guard */ +#endif // __cplusplus +#endif // include guard diff --git a/boost/boost/regex/v4/match_results.hpp b/boost/boost/regex/v4/match_results.hpp index fdbc333740..72538fc015 100644 --- a/boost/boost/regex/v4/match_results.hpp +++ b/boost/boost/regex/v4/match_results.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -24,10 +24,12 @@ #endif namespace boost{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable : 4251 4231 4660) +#endif -template ) - > +template class match_results { private: @@ -47,11 +49,11 @@ public: typedef typename vector_type::const_iterator const_iterator; typedef const_iterator iterator; typedef typename re_detail::regex_iterator_traits< - BidiIterator>::difference_type difference_type; + BidiIterator>::difference_type difference_type; typedef typename Allocator::size_type size_type; typedef Allocator allocator_type; typedef typename re_detail::regex_iterator_traits< - BidiIterator>::value_type char_type; + BidiIterator>::value_type char_type; typedef std::basic_string string_type; // construct/copy/destroy: @@ -73,7 +75,7 @@ public: // size: size_type size() const - { return (m_subs.size() >= 2) ? m_subs.size() - 2 : 0; } + { return empty() ? 0 : m_subs.size() - 2; } size_type max_size() const { return m_subs.max_size(); } bool empty() const @@ -94,7 +96,7 @@ public: const sub_match& s = m_subs[sub]; if(s.matched) { - return boost::re_detail::distance((BidiIterator)(m_base), (BidiIterator)(s.first)); + return ::boost::re_detail::distance((BidiIterator)(m_base), (BidiIterator)(s.first)); } } return ~static_cast(0); @@ -108,7 +110,7 @@ public: const sub_match& s = m_subs[sub]; if(s.matched) { - result = s; + result = s.str(); } } return result; @@ -134,7 +136,7 @@ public: } const_iterator begin() const { - return (m_subs.size() >= 2) ? (m_subs.begin() + 2) : m_subs.end(); + return (m_subs.size() > 2) ? (m_subs.begin() + 2) : m_subs.end(); } const_iterator end() const { @@ -146,12 +148,36 @@ public: const string_type& fmt, match_flag_type flags = format_default) const { - return regex_format(out, *this, fmt, flags); + re_detail::trivial_format_traits traits; + return re_detail::regex_format_imp(out, *this, fmt.data(), fmt.data() + fmt.size(), flags, traits); } string_type format(const string_type& fmt, match_flag_type flags = format_default) const { - return regex_format(*this, fmt, flags); + string_type result; + re_detail::string_out_iterator i(result); + re_detail::trivial_format_traits traits; + re_detail::regex_format_imp(i, *this, fmt.data(), fmt.data() + fmt.size(), flags, traits); + return result; + } + // format with locale: + template + OutputIterator format(OutputIterator out, + const string_type& fmt, + match_flag_type flags, + const RegexT& re) const + { + return ::boost::re_detail::regex_format_imp(out, *this, fmt.data(), fmt.data() + fmt.size(), flags, re.get_traits()); + } + template + string_type format(const string_type& fmt, + match_flag_type flags, + const RegexT& re) const + { + string_type result; + re_detail::string_out_iterator i(result); + ::boost::re_detail::regex_format_imp(i, *this, fmt.data(), fmt.data() + fmt.size(), flags, re.get_traits()); + return result; } allocator_type get_allocator() const @@ -187,7 +213,7 @@ public: // private access functions: void BOOST_REGEX_CALL set_second(BidiIterator i) { - assert(m_subs.size() > 2); + BOOST_ASSERT(m_subs.size() > 2); m_subs[2].second = i; m_subs[2].matched = true; m_subs[0].first = i; @@ -200,7 +226,7 @@ public: void BOOST_REGEX_CALL set_second(BidiIterator i, size_type pos, bool m = true) { pos += 2; - assert(m_subs.size() > pos); + BOOST_ASSERT(m_subs.size() > pos); m_subs[pos].second = i; m_subs[pos].matched = m; if(pos == 2) @@ -233,6 +259,10 @@ public: { m_base = pos; } + BidiIterator base()const + { + return m_base; + } void BOOST_REGEX_CALL set_first(BidiIterator i) { // set up prefix: @@ -249,7 +279,7 @@ public: } void BOOST_REGEX_CALL set_first(BidiIterator i, size_type pos) { - assert(pos+2 < m_subs.size()); + BOOST_ASSERT(pos+2 < m_subs.size()); if(pos) m_subs[pos+2].first = i; else @@ -270,29 +300,73 @@ void BOOST_REGEX_CALL match_results::maybe_assign(const const_iterator p1, p2; p1 = begin(); p2 = m.begin(); - BidiIterator base = (*this)[-1].first; - std::size_t len1 = 0; - std::size_t len2 = 0; - std::size_t base1 = 0; - std::size_t base2 = 0; + // + // Distances are measured from the start of *this* match, unless this isn't + // a valid match in which case we use the start of the whole sequence. Note that + // no subsequent match-candidate can ever be to the left of the first match found. + // This ensures that when we are using bidirectional iterators, that distances + // measured are as short as possible, and therefore as efficient as possible + // to compute. Finally note that we don't use the "matched" data member to test + // whether a sub-expression is a valid match, because partial matches set this + // to false for sub-expression 0. + // + BidiIterator end = this->suffix().second; + BidiIterator base = (p1->first == end) ? this->prefix().first : (*this)[0].first; + difference_type len1 = 0; + difference_type len2 = 0; + difference_type base1 = 0; + difference_type base2 = 0; std::size_t i; - for(i = 0; i < size(); ++i) + for(i = 0; i < size(); ++i, ++p1, ++p2) { // - // leftmost takes priority over longest: - base1 = boost::re_detail::distance(base, p1->first); - base2 = boost::re_detail::distance(base, p2->first); + // Leftmost takes priority over longest; handle special cases + // where distances need not be computed first (an optimisation + // for bidirectional iterators: ensure that we don't accidently + // compute the length of the whole sequence, as this can be really + // expensive). + // + if(p1->first == end) + { + if(p2->first != end) + { + // p2 must be better than p1, and no need to calculate + // actual distances: + base1 = 1; + base2 = 0; + break; + } + else + { + // *p1 and *p2 are either unmatched or match end-of sequence, + // either way no need to calculate distances: + if((p1->matched == false) && (p2->matched == true)) + break; + if((p1->matched == true) && (p2->matched == false)) + return; + continue; + } + } + else if(p2->first == end) + { + // p1 better than p2, and no need to calculate distances: + return; + } + base1 = ::boost::re_detail::distance(base, p1->first); + base2 = ::boost::re_detail::distance(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::re_detail::distance((BidiIterator)p1->first, (BidiIterator)p1->second); + len2 = ::boost::re_detail::distance((BidiIterator)p2->first, (BidiIterator)p2->second); + BOOST_ASSERT(len1 >= 0); + BOOST_ASSERT(len2 >= 0); if((len1 != len2) || ((p1->matched == false) && (p2->matched == true))) break; if((p1->matched == true) && (p2->matched == false)) return; - ++p1; - ++p2; } if(i == size()) return; @@ -325,6 +399,9 @@ std::ostream& operator << (std::ostream& os, } #endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif } // namespace boost #ifdef BOOST_HAS_ABI_HEADERS diff --git a/boost/boost/regex/v4/mem_block_cache.hpp b/boost/boost/regex/v4/mem_block_cache.hpp index abe8bb87b9..222142dd69 100644 --- a/boost/boost/regex/v4/mem_block_cache.hpp +++ b/boost/boost/regex/v4/mem_block_cache.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -19,7 +19,9 @@ #define BOOST_REGEX_V4_MEM_BLOCK_CACHE_HPP #include -#include +#ifdef BOOST_HAS_THREADS +#include +#endif #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX @@ -38,6 +40,9 @@ struct mem_block_cache // this member has to be statically initialsed: mem_block_node* next; unsigned cached_blocks; +#ifdef BOOST_HAS_THREADS + boost::static_mutex mut; +#endif ~mem_block_cache() { @@ -51,7 +56,7 @@ struct mem_block_cache void* get() { #ifdef BOOST_HAS_THREADS - re_detail::cs_guard g(*re_detail::p_re_lock); + boost::static_mutex::scoped_lock g(mut); #endif if(next) { @@ -65,7 +70,7 @@ struct mem_block_cache void put(void* p) { #ifdef BOOST_HAS_THREADS - re_detail::cs_guard g(*re_detail::p_re_lock); + boost::static_mutex::scoped_lock g(mut); #endif if(cached_blocks >= BOOST_REGEX_MAX_CACHE_BLOCKS) { diff --git a/boost/boost/regex/v4/perl_matcher.hpp b/boost/boost/regex/v4/perl_matcher.hpp index 44751e582d..82f8a26d90 100644 --- a/boost/boost/regex/v4/perl_matcher.hpp +++ b/boost/boost/regex/v4/perl_matcher.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -24,7 +24,39 @@ namespace re_detail{ // // error checking API: // -BOOST_REGEX_DECL void BOOST_REGEX_CALL verify_options(boost::regex::flag_type ef, match_flag_type mf); +BOOST_REGEX_DECL void BOOST_REGEX_CALL verify_options(boost::regex_constants::syntax_option_type ef, match_flag_type mf); +// +// function can_start: +// +template +bool can_start(charT c, const unsigned char* map, unsigned char mask) +{ + return ((c < static_cast(0)) ? true : ((c >= static_cast(1 << CHAR_BIT)) ? true : map[c] & mask)); +} +inline bool can_start(char c, const unsigned char* map, unsigned char mask) +{ + return map[(unsigned char)c] & mask; +} +inline bool can_start(signed char c, const unsigned char* map, unsigned char mask) +{ + return map[(unsigned char)c] & mask; +} +inline bool can_start(unsigned char c, const unsigned char* map, unsigned char mask) +{ + return map[c] & mask; +} +inline bool can_start(unsigned short c, const unsigned char* map, unsigned char mask) +{ + return ((c >= (1 << CHAR_BIT)) ? true : map[c] & mask); +} +#if !defined(__HP_aCC) +#if defined(WCHAR_MIN) && (WCHAR_MIN == 0) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) +inline bool can_start(wchar_t c, const unsigned char* map, unsigned char mask) +{ + return ((c >= (1 << CHAR_BIT)) ? true : map[c] & mask); +} +#endif +#endif // @@ -36,42 +68,72 @@ BOOST_REGEX_DECL void BOOST_REGEX_CALL verify_options(boost::regex::flag_type ef // which succeeds when it should not. // #ifndef _RWSTD_VER -# define STR_COMP(s,p) s.compare(p) -#else +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1310) template inline int string_compare(const std::basic_string& s, const C* p) -{ return s.compare(p); } +{ + if(0 == *p) + { + if(s.empty() || ((s.size() == 1) && (s[0] == 0))) + return 0; + } + return s.compare(p); +} +#endif +#else +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1310) +template +inline int string_compare(const std::basic_string& s, const C* p) +{ + if(0 == *p) + { + if(s.empty() || ((s.size() == 1) && (s[0] == 0))) + return 0; + } + return s.compare(p); +} +#endif inline int string_compare(const std::string& s, const char* p) { return std::strcmp(s.c_str(), p); } # ifndef BOOST_NO_WREGEX inline int string_compare(const std::wstring& s, const wchar_t* p) { return std::wcscmp(s.c_str(), p); } #endif -# define STR_COMP(s,p) string_compare(s,p) #endif +template +inline int string_compare(const Seq& s, const C* p) +{ + std::size_t i = 0; + while((i < s.size()) && (p[i] == s[i])) + { + ++i; + } + return (i == s.size()) ? -p[i] : s[i] - p[i]; +} +# define STR_COMP(s,p) string_compare(s,p) template inline const charT* re_skip_past_null(const charT* p) { - while (*p != 0) ++p; + while (*p != static_cast(0)) ++p; return ++p; } -template +template iterator BOOST_REGEX_CALL re_is_set_member(iterator next, iterator last, - const re_set_long* set_, - const reg_expression& e) + const re_set_long* set_, + const regex_data& e, bool icase) { const charT* p = reinterpret_cast(set_+1); iterator ptr; unsigned int i; - bool icase = e.flags() & regex_constants::icase; + //bool icase = e.m_flags & regex_constants::icase; if(next == last) return next; typedef typename traits_type::string_type traits_string_type; - const traits_type& traits_inst = e.get_traits(); + const ::boost::regex_traits_wrapper& traits_inst = *(e.m_ptraits); // dwa 9/13/00 suppress incorrect MSVC warning - it claims this is never // referenced @@ -82,12 +144,12 @@ iterator BOOST_REGEX_CALL re_is_set_member(iterator next, for(i = 0; i < set_->csingles; ++i) { ptr = next; - if(*p == 0) + if(*p == static_cast(0)) { // treat null string as special case: if(traits_inst.translate(*ptr, icase) != *p) { - while(*p == 0)++p; + while(*p == static_cast(0))++p; continue; } return set_->isnot ? next : (ptr == next) ? ++next : ptr; @@ -102,7 +164,7 @@ iterator BOOST_REGEX_CALL re_is_set_member(iterator next, ++ptr; } - if(*p == 0) // if null we've matched + if(*p == static_cast(0)) // if null we've matched return set_->isnot ? next : (ptr == next) ? ++next : ptr; p = re_skip_past_null(p); // skip null @@ -114,33 +176,35 @@ iterator BOOST_REGEX_CALL re_is_set_member(iterator next, if(set_->cranges || set_->cequivalents) { - traits_string_type s2(1, col); traits_string_type s1; // // try and match a range, NB only a single character can match if(set_->cranges) { - if((e.flags() & regex_constants::collate) == 0) - s1 = s2; + if((e.m_flags & regex_constants::collate) == 0) + s1.assign(1, col); else - traits_inst.transform(s1, s2); + { + charT a[2] = { col, charT(0), }; + s1 = traits_inst.transform(a, a + 1); + } for(i = 0; i < set_->cranges; ++i) { - if(STR_COMP(s1, p) <= 0) + if(STR_COMP(s1, p) >= 0) { - while(*p)++p; + do{ ++p; }while(*p); ++p; - if(STR_COMP(s1, p) >= 0) + if(STR_COMP(s1, p) <= 0) return set_->isnot ? next : ++next; } else { // skip first string - while(*p)++p; + do{ ++p; }while(*p); ++p; } // skip second string - while(*p)++p; + do{ ++p; }while(*p); ++p; } } @@ -148,58 +212,33 @@ iterator BOOST_REGEX_CALL re_is_set_member(iterator next, // try and match an equivalence class, NB only a single character can match if(set_->cequivalents) { - traits_inst.transform_primary(s1, s2); + charT a[2] = { col, charT(0), }; + s1 = traits_inst.transform_primary(a, a +1); for(i = 0; i < set_->cequivalents; ++i) { if(STR_COMP(s1, p) == 0) return set_->isnot ? next : ++next; // skip string - while(*p)++p; + do{ ++p; }while(*p); ++p; } } } - if(traits_inst.is_class(col, set_->cclasses) == true) + if(traits_inst.isctype(col, set_->cclasses) == true) + return set_->isnot ? next : ++next; + if((set_->cnclasses != 0) && (traits_inst.isctype(col, set_->cnclasses) == false)) return set_->isnot ? next : ++next; return set_->isnot ? ++next : next; } -template -struct access_t : public reg_expression -{ - typedef typename is_byte::width_type width_type; - typedef reg_expression base_type; - typedef charT char_type; - typedef traits traits_type; - typedef Allocator alloc_type; - - static int repeat_count(const base_type& b) - { return base_type::repeat_count(b); } - static unsigned int restart_type(const base_type& b) - { return base_type::restart_type(b); } - static const re_syntax_base* first(const base_type& b) - { return base_type::first(b); } - static const unsigned char* get_map(const base_type& b) - { return base_type::get_map(b); } - static std::size_t leading_length(const base_type& b) - { return base_type::leading_length(b); } - static const kmp_info* get_kmp(const base_type& b) - { return base_type::get_kmp(b); } - static bool can_start(char_type c, const unsigned char* _map, unsigned char mask) - { - return reg_expression::can_start(c, _map, mask, width_type()); - } -}; - - template class repeater_count { repeater_count** stack; repeater_count* next; int id; - unsigned count; // the number of iterations so far - BidiIterator start_pos; // where the last repeat started + std::size_t count; // the number of iterations so far + BidiIterator start_pos; // where the last repeat started public: repeater_count(repeater_count** s) { @@ -230,10 +269,10 @@ public: { *stack = next; } - unsigned get_count() { return count; } + std::size_t get_count() { return count; } int get_id() { return id; } - int operator++() { return ++count; } - bool check_null_repeat(const BidiIterator& pos, unsigned max) + std::size_t operator++() { return ++count; } + bool check_null_repeat(const BidiIterator& pos, std::size_t max) { // this is called when we are about to start a new repeat, // if the last one was NULL move our count to max, @@ -268,32 +307,30 @@ enum saved_state_type saved_state_count = 14 }; -template +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable : 4251 4231 4660) +#endif + +template class perl_matcher { public: typedef typename traits::char_type char_type; - typedef perl_matcher self_type; + typedef perl_matcher self_type; typedef bool (self_type::*matcher_proc_type)(void); - typedef access_t access; typedef typename traits::size_type traits_size_type; - typedef typename traits::uchar_type traits_uchar_type; typedef typename is_byte::width_type width_type; typedef typename regex_iterator_traits::difference_type difference_type; perl_matcher(BidiIterator first, BidiIterator end, match_results& what, - const reg_expression& e, - match_flag_type f); + const basic_regex& e, + match_flag_type f, + BidiIterator base); bool match(); - bool match_imp(); bool find(); - bool find_imp(); -#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD - typedef bool (perl_matcher::*protected_proc_type)(); - bool protected_call(protected_proc_type); -#endif void setf(match_flag_type f) { m_match_flags |= f; } @@ -301,6 +338,13 @@ public: { m_match_flags &= ~f; } private: + void construct_init(const basic_regex& e, match_flag_type f); + bool find_imp(); + bool match_imp(); +#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD + typedef bool (perl_matcher::*protected_proc_type)(); + bool protected_call(protected_proc_type); +#endif void estimate_max_state_count(std::random_access_iterator_tag*); void estimate_max_state_count(void*); bool match_prefix(); @@ -334,7 +378,12 @@ private: bool match_char_repeat(); bool match_dot_repeat_fast(); bool match_dot_repeat_slow(); - bool backtrack_till_match(unsigned count); + bool match_backstep(); + bool match_assert_backref(); + bool match_toggle_case(); +#ifdef BOOST_REGEX_RECURSIVE + bool backtrack_till_match(std::size_t count); +#endif // find procs stored in s_find_vtable: bool find_restart_any(); @@ -360,10 +409,12 @@ private: BidiIterator restart; // where the current search started from, acts as base for $` during grep: BidiIterator search_base; + // how far we can go back when matching lookbehind: + BidiIterator backstop; // the expression being examined: - const reg_expression& re; + const basic_regex& re; // the expression's traits class: - const traits& traits_inst; + const ::boost::regex_traits_wrapper& traits_inst; // the next state in the machine being matched: const re_syntax_base* pstate; // matching flags in use: @@ -378,10 +429,16 @@ private: bool m_has_partial_match; // set to true whenever we get a match: bool m_has_found_match; + // set to true whenever we're inside an independent sub-expression: + bool m_independent; // the current repeat being examined: repeater_count* next_count; // the first repeat being examined (top of linked list): repeater_count rep_obj; + // the mask to pass when matching word boundaries: + typename traits::char_class_type m_word_mask; + // the bitmask to use when determining whether a match_any matches a newline or not: + unsigned char match_any_mask; #ifdef BOOST_REGEX_NON_RECURSIVE // @@ -411,7 +468,7 @@ private: void push_assertion(const re_syntax_base* ps, bool positive); void push_alt(const re_syntax_base* ps); void push_repeater_count(int i, repeater_count** s); - void push_single_repeat(unsigned c, const re_repeat* r, BidiIterator last_position, int id); + void push_single_repeat(std::size_t c, const re_repeat* r, BidiIterator last_position, int id); void push_non_greedy_repeat(const re_syntax_base* ps); @@ -426,11 +483,20 @@ private: unsigned used_block_count; #endif - // these operations aren't allowed, so are declared private: - perl_matcher& operator=(const perl_matcher&); - perl_matcher(const perl_matcher&); + // these operations aren't allowed, so are declared private, + // bodies are provided to keep explicit-instantiation requests happy: + perl_matcher& operator=(const perl_matcher&) + { + return *this; + } + perl_matcher(const perl_matcher& that) + : m_result(that.m_result), re(that.re), traits_inst(that.traits_inst), rep_obj(0) {} }; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + } // namespace re_detail #ifdef BOOST_HAS_ABI_HEADERS diff --git a/boost/boost/regex/v4/perl_matcher_common.hpp b/boost/boost/regex/v4/perl_matcher_common.hpp index 20148375b3..54edaa15d8 100644 --- a/boost/boost/regex/v4/perl_matcher_common.hpp +++ b/boost/boost/regex/v4/perl_matcher_common.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -31,14 +31,21 @@ namespace boost{ namespace re_detail{ -template -perl_matcher::perl_matcher(BidiIterator first, BidiIterator end, +template +perl_matcher::perl_matcher(BidiIterator first, BidiIterator end, match_results& what, - const reg_expression& e, - match_flag_type f) + const basic_regex& e, + match_flag_type f, + BidiIterator b) : m_result(what), base(first), last(end), - position(first), re(e), traits_inst(e.get_traits()), - next_count(&rep_obj), rep_obj(&next_count) + position(first), backstop(b), re(e), traits_inst(e.get_traits()), + m_independent(false), next_count(&rep_obj), rep_obj(&next_count) +{ + construct_init(e, f); +} + +template +void perl_matcher::construct_init(const basic_regex& e, match_flag_type f) { typedef typename regex_iterator_traits::iterator_category category; @@ -54,7 +61,9 @@ perl_matcher::perl_matcher(BidiIter estimate_max_state_count(static_cast(0)); if(!(m_match_flags & (match_perl|match_posix))) { - if((re.flags() & regex_constants::perlex) || (re.flags() & regex_constants::literal)) + if((re.flags() & (regbase::main_option_type|regbase::no_perl_ex)) == 0) + m_match_flags |= match_perl; + else if((re.flags() & (regbase::main_option_type|regbase::emacs_ex)) == (regbase::basic_syntax_group|regbase::emacs_ex)) m_match_flags |= match_perl; else m_match_flags |= match_posix; @@ -70,32 +79,40 @@ perl_matcher::perl_matcher(BidiIter m_stack_base = 0; m_backup_state = 0; #endif + // find the value to use for matching word boundaries: + const char_type w = static_cast('w'); + m_word_mask = traits_inst.lookup_classname(&w, &w+1); + // find bitmask to use for matching '.': + match_any_mask = static_cast((f & match_not_dot_newline) ? re_detail::test_not_newline : re_detail::test_newline); } -template -void perl_matcher::estimate_max_state_count(std::random_access_iterator_tag*) +template +void perl_matcher::estimate_max_state_count(std::random_access_iterator_tag*) { + static const difference_type k = 100000; difference_type dist = boost::re_detail::distance(base, last); traits_size_type states = static_cast(re.size()); states *= states; - difference_type lim = (std::numeric_limits::max)() - 100000 - states; - if(dist > (difference_type)(lim / states)) - max_state_count = lim; + difference_type lim = ((std::numeric_limits::max)() - k) / states; + if(dist >= lim) + max_state_count = (std::numeric_limits::max)(); else - max_state_count = 100000 + states * dist; + max_state_count = k + states * dist; } -template -void perl_matcher::estimate_max_state_count(void*) + +template +void perl_matcher::estimate_max_state_count(void*) { // we don't know how long the sequence is: max_state_count = BOOST_REGEX_MAX_STATE_COUNT; } #ifdef BOOST_REGEX_HAS_MS_STACK_GUARD -template -bool perl_matcher::protected_call( +template +bool perl_matcher::protected_call( protected_proc_type proc) { + /* __try{ return (this->*proc)(); }__except(EXCEPTION_STACK_OVERFLOW == GetExceptionCode()) @@ -103,24 +120,30 @@ bool perl_matcher::protected_call( reset_stack_guard_page(); } // we only get here after a stack overflow: - raise_error(traits_inst, REG_E_MEMORY); + raise_error(traits_inst, regex_constants::error_size); // and we never really get here at all: return false; + */ + ::boost::re_detail::concrete_protected_call + > + obj(this, proc); + return obj.execute(); + } #endif -template -bool perl_matcher::match() +template +bool perl_matcher::match() { #ifdef BOOST_REGEX_HAS_MS_STACK_GUARD - return protected_call(&perl_matcher::match_imp); + return protected_call(&perl_matcher::match_imp); #else return match_imp(); #endif } -template -bool perl_matcher::match_imp() +template +bool perl_matcher::match_imp() { // initialise our stack if we are non-recursive: #ifdef BOOST_REGEX_NON_RECURSIVE @@ -136,7 +159,7 @@ bool perl_matcher::match_imp() search_base = base; state_count = 0; m_match_flags |= regex_constants::match_all; - m_presult->set_size((m_match_flags & match_nosubs) ? 1 : re.mark_count(), base, last); + m_presult->set_size((m_match_flags & match_nosubs) ? 1 : re.mark_count(), search_base, last); m_presult->set_base(base); if(m_match_flags & match_posix) m_result = *m_presult; @@ -158,28 +181,28 @@ bool perl_matcher::match_imp() #endif } -template -bool perl_matcher::find() +template +bool perl_matcher::find() { #ifdef BOOST_REGEX_HAS_MS_STACK_GUARD - return protected_call(&perl_matcher::find_imp); + return protected_call(&perl_matcher::find_imp); #else return find_imp(); #endif } -template -bool perl_matcher::find_imp() +template +bool perl_matcher::find_imp() { static matcher_proc_type const s_find_vtable[7] = { - &perl_matcher::find_restart_any, - &perl_matcher::find_restart_word, - &perl_matcher::find_restart_line, - &perl_matcher::find_restart_buf, - &perl_matcher::match_prefix, - &perl_matcher::find_restart_lit, - &perl_matcher::find_restart_lit, + &perl_matcher::find_restart_any, + &perl_matcher::find_restart_word, + &perl_matcher::find_restart_line, + &perl_matcher::find_restart_buf, + &perl_matcher::match_prefix, + &perl_matcher::find_restart_lit, + &perl_matcher::find_restart_lit, }; // initialise our stack if we are non-recursive: @@ -195,9 +218,8 @@ bool perl_matcher::find_imp() if((m_match_flags & regex_constants::match_init) == 0) { // reset our state machine: - position = base; - search_base = base; - pstate = access::first(re); + search_base = position = base; + pstate = re.get_first_state(); m_presult->set_size((m_match_flags & match_nosubs) ? 1 : re.mark_count(), base, last); m_presult->set_base(base); m_match_flags |= regex_constants::match_init; @@ -217,8 +239,8 @@ bool perl_matcher::find_imp() } // reset $` start: m_presult->set_size((m_match_flags & match_nosubs) ? 1 : re.mark_count(), search_base, last); - if(base != search_base) - m_match_flags |= match_prev_avail; + //if((base != search_base) && (base == backstop)) + // m_match_flags |= match_prev_avail; } if(m_match_flags & match_posix) { @@ -230,7 +252,7 @@ bool perl_matcher::find_imp() // find out what kind of expression we have: unsigned type = (m_match_flags & match_continuous) ? static_cast(regbase::restart_continue) - : static_cast(access::restart_type(re)); + : static_cast(re.get_restart_type()); // call the appropriate search routine: matcher_proc_type proc = s_find_vtable[type]; @@ -249,12 +271,12 @@ bool perl_matcher::find_imp() #endif } -template -bool perl_matcher::match_prefix() +template +bool perl_matcher::match_prefix() { m_has_partial_match = false; m_has_found_match = false; - pstate = access::first(re); + pstate = re.get_first_state(); m_presult->set_first(position); restart = position; match_all_states(); @@ -282,8 +304,8 @@ bool perl_matcher::match_prefix() return m_has_found_match; } -template -bool perl_matcher::match_endmark() +template +bool perl_matcher::match_endmark() { int index = static_cast(pstate)->index; if(index > 0) @@ -291,7 +313,7 @@ bool perl_matcher::match_endmark() if((m_match_flags & match_nosubs) == 0) m_presult->set_second(position, index); } - else if(index < 0) + else if((index < 0) && (index != -4)) { // matched forward lookahead: pstate = 0; @@ -301,8 +323,8 @@ bool perl_matcher::match_endmark() return true; } -template -bool perl_matcher::match_literal() +template +bool perl_matcher::match_literal() { unsigned int len = static_cast(pstate)->length; const char_type* what = reinterpret_cast(static_cast(pstate) + 1); @@ -318,10 +340,10 @@ bool perl_matcher::match_literal() return true; } -template -bool perl_matcher::match_start_line() +template +bool perl_matcher::match_start_line() { - if(position == base) + if(position == backstop) { if((m_match_flags & match_prev_avail) == 0) { @@ -341,13 +363,13 @@ bool perl_matcher::match_start_line --t; if(position != last) { - if(traits_inst.is_separator(*t) && !((*t == '\r') && (*position == '\n')) ) + if(is_separator(*t) && !((*t == static_cast('\r')) && (*position == static_cast('\n'))) ) { pstate = pstate->next.p; return true; } } - else if(traits_inst.is_separator(*t)) + else if(is_separator(*t)) { pstate = pstate->next.p; return true; @@ -355,22 +377,22 @@ bool perl_matcher::match_start_line return false; } -template -bool perl_matcher::match_end_line() +template +bool perl_matcher::match_end_line() { if(position != last) { if(m_match_flags & match_single_line) return false; // we're not yet at the end so *first is always valid: - if(traits_inst.is_separator(*position)) + if(is_separator(*position)) { - if((position != base) || (m_match_flags & match_prev_avail)) + if((position != backstop) || (m_match_flags & match_prev_avail)) { // check that we're not in the middle of \r\n sequence BidiIterator t(position); --t; - if((*t == '\r') && (*position == '\n')) + if((*t == static_cast('\r')) && (*position == static_cast('\n'))) { return false; } @@ -387,12 +409,12 @@ bool perl_matcher::match_end_line() return false; } -template -bool perl_matcher::match_wild() +template +bool perl_matcher::match_wild() { if(position == last) return false; - if(traits_inst.is_separator(*position) && (m_match_flags & match_not_dot_newline)) + if(is_separator(*position) && ((match_any_mask & static_cast(pstate)->mask) == 0)) return false; if((*position == char_type(0)) && (m_match_flags & match_not_dot_null)) return false; @@ -401,8 +423,8 @@ bool perl_matcher::match_wild() return true; } -template -bool perl_matcher::match_match() +template +bool perl_matcher::match_match() { if((m_match_flags & match_not_null) && (position == (*m_presult)[0].first)) return false; @@ -413,10 +435,11 @@ bool perl_matcher::match_match() m_presult->set_second(position); pstate = 0; m_has_found_match = true; - if((m_match_flags & (match_posix|match_any)) == match_posix) + if((m_match_flags & match_posix) == match_posix) { m_result.maybe_assign(*m_presult); - return false; + if((m_match_flags & match_any) == 0) + return false; } #ifdef BOOST_REGEX_MATCH_EXTRA if(match_extra & m_match_flags) @@ -429,24 +452,24 @@ bool perl_matcher::match_match() return true; } -template -bool perl_matcher::match_word_boundary() +template +bool perl_matcher::match_word_boundary() { bool b; // indcates whether next character is a word character if(position != last) { // prev and this character must be opposites: #if defined(BOOST_REGEX_USE_C_LOCALE) && defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ < 95) - b = traits::is_class(*position, traits::char_class_word); + b = traits::isctype(*position, m_word_mask); #else - b = traits_inst.is_class(*position, traits::char_class_word); + b = traits_inst.isctype(*position, m_word_mask); #endif } else { b = (m_match_flags & match_not_eow) ? true : false; } - if((position == base) && ((m_match_flags & match_prev_avail) == 0)) + if((position == backstop) && ((m_match_flags & match_prev_avail) == 0)) { if(m_match_flags & match_not_bow) b ^= true; @@ -456,7 +479,7 @@ bool perl_matcher::match_word_bound else { --position; - b ^= traits_inst.is_class(*position, traits::char_class_word); + b ^= traits_inst.isctype(*position, m_word_mask); ++position; } if(b) @@ -467,21 +490,21 @@ bool perl_matcher::match_word_bound return false; // no match if we get to here... } -template -bool perl_matcher::match_within_word() +template +bool perl_matcher::match_within_word() { if(position == last) return false; - // both prev and this character must be traits::char_class_word: - if(traits_inst.is_class(*position, traits::char_class_word)) + // both prev and this character must be m_word_mask: + if(traits_inst.isctype(*position, m_word_mask)) { bool b; - if((position == base) && ((m_match_flags & match_prev_avail) == 0)) + if((position == backstop) && ((m_match_flags & match_prev_avail) == 0)) return false; else { --position; - b = traits_inst.is_class(*position, traits::char_class_word); + b = traits_inst.isctype(*position, m_word_mask); ++position; } if(b) @@ -493,14 +516,14 @@ bool perl_matcher::match_within_wor return false; } -template -bool perl_matcher::match_word_start() +template +bool perl_matcher::match_word_start() { if(position == last) return false; // can't be starting a word if we're already at the end of input - if(!traits_inst.is_class(*position, traits::char_class_word)) + if(!traits_inst.isctype(*position, m_word_mask)) return false; // next character isn't a word character - if((position == base) && ((m_match_flags & match_prev_avail) == 0)) + if((position == backstop) && ((m_match_flags & match_prev_avail) == 0)) { if(m_match_flags & match_not_bow) return false; // no previous input @@ -510,7 +533,7 @@ bool perl_matcher::match_word_start // otherwise inside buffer: BidiIterator t(position); --t; - if(traits_inst.is_class(*t, traits::char_class_word)) + if(traits_inst.isctype(*t, m_word_mask)) return false; // previous character not non-word } // OK we have a match: @@ -518,14 +541,14 @@ bool perl_matcher::match_word_start return true; } -template -bool perl_matcher::match_word_end() +template +bool perl_matcher::match_word_end() { - if((position == base) && ((m_match_flags & match_prev_avail) == 0)) + if((position == backstop) && ((m_match_flags & match_prev_avail) == 0)) return false; // start of buffer can't be end of word BidiIterator t(position); --t; - if(traits_inst.is_class(*t, traits::char_class_word) == false) + if(traits_inst.isctype(*t, m_word_mask) == false) return false; // previous character wasn't a word character if(position == last) @@ -536,25 +559,25 @@ bool perl_matcher::match_word_end() else { // otherwise inside buffer: - if(traits_inst.is_class(*position, traits::char_class_word)) + if(traits_inst.isctype(*position, m_word_mask)) return false; // next character is a word character } pstate = pstate->next.p; return true; // if we fall through to here then we've succeeded } -template -bool perl_matcher::match_buffer_start() +template +bool perl_matcher::match_buffer_start() { - if((position != base) || (m_match_flags & match_not_bob)) + if((position != backstop) || (m_match_flags & match_not_bob)) return false; // OK match: pstate = pstate->next.p; return true; } -template -bool perl_matcher::match_buffer_end() +template +bool perl_matcher::match_buffer_end() { if((position != last) || (m_match_flags & match_not_eob)) return false; @@ -563,8 +586,8 @@ bool perl_matcher::match_buffer_end return true; } -template -bool perl_matcher::match_backref() +template +bool perl_matcher::match_backref() { // compare with what we previously matched: BidiIterator i = (*m_presult)[static_cast(pstate)->index].first; @@ -580,13 +603,14 @@ bool perl_matcher::match_backref() return true; } -template -bool perl_matcher::match_long_set() +template +bool perl_matcher::match_long_set() { + typedef typename traits::char_class_type char_class_type; // let the traits class do the work: if(position == last) return false; - BidiIterator t = re_is_set_member(position, last, static_cast(pstate), re); + BidiIterator t = re_is_set_member(position, last, static_cast*>(pstate), re.get_data(), icase); if(t != position) { pstate = pstate->next.p; @@ -596,12 +620,12 @@ bool perl_matcher::match_long_set() return false; } -template -bool perl_matcher::match_set() +template +bool perl_matcher::match_set() { if(position == last) return false; - if(static_cast(pstate)->_map[(traits_uchar_type)traits_inst.translate(*position, icase)]) + if(static_cast(pstate)->_map[static_cast(traits_inst.translate(*position, icase))]) { pstate = pstate->next.p; ++position; @@ -610,42 +634,42 @@ bool perl_matcher::match_set() return false; } -template -bool perl_matcher::match_jump() +template +bool perl_matcher::match_jump() { pstate = static_cast(pstate)->alt.p; return true; } -template -bool perl_matcher::match_combining() +template +bool perl_matcher::match_combining() { if(position == last) return false; - if(traits_inst.is_combining(traits_inst.translate(*position, icase))) + if(is_combining(traits_inst.translate(*position, icase))) return false; ++position; - while((position != last) && traits_inst.is_combining(traits_inst.translate(*position, icase))) + while((position != last) && is_combining(traits_inst.translate(*position, icase))) ++position; pstate = pstate->next.p; return true; } -template -bool perl_matcher::match_soft_buffer_end() +template +bool perl_matcher::match_soft_buffer_end() { if(m_match_flags & match_not_eob) return false; BidiIterator p(position); - while((p != last) && traits_inst.is_separator(traits_inst.translate(*p, icase)))++p; + while((p != last) && is_separator(traits_inst.translate(*p, icase)))++p; if(p != last) return false; pstate = pstate->next.p; return true; } -template -bool perl_matcher::match_restart_continue() +template +bool perl_matcher::match_restart_continue() { if(position == search_base) { @@ -655,23 +679,73 @@ bool perl_matcher::match_restart_co return false; } -template -bool perl_matcher::find_restart_any() +template +bool perl_matcher::match_backstep() { #ifdef BOOST_MSVC #pragma warning(push) #pragma warning(disable:4127) #endif - const unsigned char* _map = access::get_map(re); + if( ::boost::is_random_access_iterator::value) + { + std::ptrdiff_t maxlen = ::boost::re_detail::distance(backstop, position); + if(maxlen < static_cast(pstate)->index) + return false; + std::advance(position, -static_cast(pstate)->index); + } + else + { + int c = static_cast(pstate)->index; + while(c--) + { + if(position == backstop) + return false; + --position; + } + } + pstate = pstate->next.p; + return true; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +inline bool perl_matcher::match_assert_backref() +{ + // return true if marked sub-expression N has been matched: + bool result = (*m_presult)[static_cast(pstate)->index].matched; + pstate = pstate->next.p; + return result; +} + +template +bool perl_matcher::match_toggle_case() +{ + // change our case sensitivity: + this->icase = static_cast(pstate)->icase; + pstate = pstate->next.p; + return true; +} + + +template +bool perl_matcher::find_restart_any() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif + const unsigned char* _map = re.get_map(); while(true) { // skip everything we can't match: - while((position != last) && !access::can_start(*position, _map, (unsigned char)mask_any) ) + while((position != last) && !can_start(*position, _map, (unsigned char)mask_any) ) ++position; if(position == last) { // run out of characters, try a null match if possible: - if(access::first(re)->can_be_null) + if(re.can_be_null()) return match_prefix(); break; } @@ -688,29 +762,29 @@ bool perl_matcher::find_restart_any #endif } -template -bool perl_matcher::find_restart_word() +template +bool perl_matcher::find_restart_word() { #ifdef BOOST_MSVC #pragma warning(push) #pragma warning(disable:4127) #endif // do search optimised for word starts: - const unsigned char* _map = access::get_map(re); + const unsigned char* _map = re.get_map(); if((m_match_flags & match_prev_avail) || (position != base)) --position; else if(match_prefix()) return true; do { - while((position != last) && traits_inst.is_class(*position, traits::char_class_word)) + while((position != last) && traits_inst.isctype(*position, m_word_mask)) ++position; - while((position != last) && !traits_inst.is_class(*position, traits::char_class_word)) + while((position != last) && !traits_inst.isctype(*position, m_word_mask)) ++position; if(position == last) break; - if(access::can_start(*position, _map, (unsigned char)mask_any) ) + if(can_start(*position, _map, (unsigned char)mask_any) ) { if(match_prefix()) return true; @@ -724,28 +798,28 @@ bool perl_matcher::find_restart_wor #endif } -template -bool perl_matcher::find_restart_line() +template +bool perl_matcher::find_restart_line() { // do search optimised for line starts: - const unsigned char* _map = access::get_map(re); + const unsigned char* _map = re.get_map(); if(match_prefix()) return true; while(position != last) { - while((position != last) && (*position != '\n')) + while((position != last) && !is_separator(*position)) ++position; if(position == last) return false; ++position; if(position == last) { - if((access::first(re)->can_be_null) && match_prefix()) + if(re.can_be_null() && match_prefix()) return true; return false; } - if( access::can_start(*position, _map, (unsigned char)mask_any) ) + if( can_start(*position, _map, (unsigned char)mask_any) ) { if(match_prefix()) return true; @@ -757,23 +831,24 @@ bool perl_matcher::find_restart_lin return false; } -template -bool perl_matcher::find_restart_buf() +template +bool perl_matcher::find_restart_buf() { if((position == base) && ((m_match_flags & match_not_bob) == 0)) return match_prefix(); return false; } -template -bool perl_matcher::find_restart_lit() +template +bool perl_matcher::find_restart_lit() { +#if 0 if(position == last) return false; // can't possibly match if we're at the end already unsigned type = (m_match_flags & match_continuous) ? static_cast(regbase::restart_continue) - : static_cast(access::restart_type(re)); + : static_cast(re.get_restart_type()); const kmp_info* info = access::get_kmp(re); int len = info->len; @@ -822,6 +897,7 @@ bool perl_matcher::find_restart_lit std::advance(position, -j); return match_prefix(); } +#endif return false; } diff --git a/boost/boost/regex/v4/perl_matcher_non_recursive.hpp b/boost/boost/regex/v4/perl_matcher_non_recursive.hpp index 893caa66ad..791c5d93f4 100644 --- a/boost/boost/regex/v4/perl_matcher_non_recursive.hpp +++ b/boost/boost/regex/v4/perl_matcher_non_recursive.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -40,10 +40,10 @@ struct saved_state { union{ unsigned int id; - // these ensure that this struct gets the same alignment as derived structs: - void* padding1; - std::size_t padding2; - std::ptrdiff_t padding3; + // this padding ensures correct alignment on 64-bit platforms: + std::size_t padding1; + std::ptrdiff_t padding2; + void* padding3; }; saved_state(unsigned i) : id(i) {} }; @@ -97,7 +97,7 @@ struct save_state_init *end = reinterpret_cast(reinterpret_cast(*base)+BOOST_REGEX_BLOCKSIZE); --(*end); (void) new (*end)saved_state(0); - assert(*end > *base); + BOOST_ASSERT(*end > *base); } ~save_state_init() { @@ -109,44 +109,47 @@ struct save_state_init template struct saved_single_repeat : public saved_state { - unsigned count; + std::size_t count; const re_repeat* rep; BidiIterator last_position; - saved_single_repeat(unsigned c, const re_repeat* r, BidiIterator lp, int arg_id) + saved_single_repeat(std::size_t c, const re_repeat* r, BidiIterator lp, int arg_id) : saved_state(arg_id), count(c), rep(r), last_position(lp){} }; -template -bool perl_matcher::match_all_states() +template +bool perl_matcher::match_all_states() { - static matcher_proc_type const s_match_vtable[26] = + static matcher_proc_type const s_match_vtable[29] = { - (&perl_matcher::match_startmark), - &perl_matcher::match_endmark, - &perl_matcher::match_literal, - &perl_matcher::match_start_line, - &perl_matcher::match_end_line, - &perl_matcher::match_wild, - &perl_matcher::match_match, - &perl_matcher::match_word_boundary, - &perl_matcher::match_within_word, - &perl_matcher::match_word_start, - &perl_matcher::match_word_end, - &perl_matcher::match_buffer_start, - &perl_matcher::match_buffer_end, - &perl_matcher::match_backref, - &perl_matcher::match_long_set, - &perl_matcher::match_set, - &perl_matcher::match_jump, - &perl_matcher::match_alt, - &perl_matcher::match_rep, - &perl_matcher::match_combining, - &perl_matcher::match_soft_buffer_end, - &perl_matcher::match_restart_continue, - (::boost::is_random_access_iterator::value ? &perl_matcher::match_dot_repeat_fast : &perl_matcher::match_dot_repeat_slow), - &perl_matcher::match_char_repeat, - &perl_matcher::match_set_repeat, - &perl_matcher::match_long_set_repeat, + (&perl_matcher::match_startmark), + &perl_matcher::match_endmark, + &perl_matcher::match_literal, + &perl_matcher::match_start_line, + &perl_matcher::match_end_line, + &perl_matcher::match_wild, + &perl_matcher::match_match, + &perl_matcher::match_word_boundary, + &perl_matcher::match_within_word, + &perl_matcher::match_word_start, + &perl_matcher::match_word_end, + &perl_matcher::match_buffer_start, + &perl_matcher::match_buffer_end, + &perl_matcher::match_backref, + &perl_matcher::match_long_set, + &perl_matcher::match_set, + &perl_matcher::match_jump, + &perl_matcher::match_alt, + &perl_matcher::match_rep, + &perl_matcher::match_combining, + &perl_matcher::match_soft_buffer_end, + &perl_matcher::match_restart_continue, + (::boost::is_random_access_iterator::value ? &perl_matcher::match_dot_repeat_fast : &perl_matcher::match_dot_repeat_slow), + &perl_matcher::match_char_repeat, + &perl_matcher::match_set_repeat, + &perl_matcher::match_long_set_repeat, + &perl_matcher::match_backstep, + &perl_matcher::match_assert_backref, + &perl_matcher::match_toggle_case, }; push_recursion_stopper(); @@ -158,10 +161,13 @@ bool perl_matcher::match_all_states if(!(this->*proc)()) { if(state_count > max_state_count) - raise_error(traits_inst, REG_ESPACE); - if((m_match_flags & match_partial) && (position == last)) + raise_error(traits_inst, regex_constants::error_space); + if((m_match_flags & match_partial) && (position == last) && (position != search_base)) m_has_partial_match = true; - if(false == unwind(false)) + bool successful_unwind = unwind(false); + if((m_match_flags & match_partial) && (position == last) && (position != search_base)) + m_has_partial_match = true; + if(false == successful_unwind) return m_recursive_result; } } @@ -169,8 +175,8 @@ bool perl_matcher::match_all_states return m_recursive_result; } -template -void perl_matcher::extend_stack() +template +void perl_matcher::extend_stack() { if(used_block_count) { @@ -186,13 +192,13 @@ void perl_matcher::extend_stack() m_backup_state = block; } else - raise_error(traits_inst, REG_E_MEMORY); + raise_error(traits_inst, regex_constants::error_size); } -template -inline void perl_matcher::push_matched_paren(int index, const sub_match& sub) +template +inline void perl_matcher::push_matched_paren(int index, const sub_match& sub) { - assert(index); + BOOST_ASSERT(index); saved_matched_paren* pmp = static_cast*>(m_backup_state); --pmp; if(pmp < m_stack_base) @@ -205,8 +211,8 @@ inline void perl_matcher::push_matc m_backup_state = pmp; } -template -inline void perl_matcher::push_recursion_stopper() +template +inline void perl_matcher::push_recursion_stopper() { saved_state* pmp = m_backup_state; --pmp; @@ -220,8 +226,8 @@ inline void perl_matcher::push_recu m_backup_state = pmp; } -template -inline void perl_matcher::push_assertion(const re_syntax_base* ps, bool positive) +template +inline void perl_matcher::push_assertion(const re_syntax_base* ps, bool positive) { saved_assertion* pmp = static_cast*>(m_backup_state); --pmp; @@ -235,8 +241,8 @@ inline void perl_matcher::push_asse m_backup_state = pmp; } -template -inline void perl_matcher::push_alt(const re_syntax_base* ps) +template +inline void perl_matcher::push_alt(const re_syntax_base* ps) { saved_position* pmp = static_cast*>(m_backup_state); --pmp; @@ -250,8 +256,8 @@ inline void perl_matcher::push_alt( m_backup_state = pmp; } -template -inline void perl_matcher::push_non_greedy_repeat(const re_syntax_base* ps) +template +inline void perl_matcher::push_non_greedy_repeat(const re_syntax_base* ps) { saved_position* pmp = static_cast*>(m_backup_state); --pmp; @@ -265,8 +271,8 @@ inline void perl_matcher::push_non_ m_backup_state = pmp; } -template -inline void perl_matcher::push_repeater_count(int i, repeater_count** s) +template +inline void perl_matcher::push_repeater_count(int i, repeater_count** s) { saved_repeater* pmp = static_cast*>(m_backup_state); --pmp; @@ -280,8 +286,8 @@ inline void perl_matcher::push_repe m_backup_state = pmp; } -template -inline void perl_matcher::push_single_repeat(unsigned c, const re_repeat* r, BidiIterator last_position, int id) +template +inline void perl_matcher::push_single_repeat(std::size_t c, const re_repeat* r, BidiIterator last_position, int id) { saved_single_repeat* pmp = static_cast*>(m_backup_state); --pmp; @@ -295,8 +301,8 @@ inline void perl_matcher::push_sing m_backup_state = pmp; } -template -bool perl_matcher::match_startmark() +template +bool perl_matcher::match_startmark() { int index = static_cast(pstate)->index; switch(index) @@ -316,10 +322,13 @@ bool perl_matcher::match_startmark( case -3: { // independent sub-expression, currently this is always recursive: + bool old_independent = m_independent; + m_independent = true; const re_syntax_base* next_pstate = static_cast(pstate->next.p)->alt.p->next.p; pstate = pstate->next.p->next.p; bool r = match_all_states(); pstate = next_pstate; + m_independent = old_independent; #ifdef BOOST_REGEX_MATCH_EXTRA if(r && (m_match_flags & match_extra)) { @@ -349,9 +358,40 @@ bool perl_matcher::match_startmark( #endif return r; } + case -4: + { + // conditional expression: + const re_alt* alt = static_cast(pstate->next.p); + BOOST_ASSERT(alt->type == syntax_element_alt); + pstate = alt->next.p; + if(pstate->type == syntax_element_assert_backref) + { + if(!match_assert_backref()) + pstate = alt->alt.p; + break; + } + else + { + // zero width assertion, have to match this recursively: + BOOST_ASSERT(pstate->type == syntax_element_startmark); + bool negated = static_cast(pstate)->index == -2; + BidiIterator saved_position = position; + const re_syntax_base* next_pstate = static_cast(pstate->next.p)->alt.p->next.p; + pstate = pstate->next.p->next.p; + bool r = match_all_states(); + position = saved_position; + if(negated) + r = !r; + if(r) + pstate = next_pstate; + else + pstate = alt->alt.p; + break; + } + } default: { - assert(index > 0); + BOOST_ASSERT(index > 0); if((m_match_flags & match_nosubs) == 0) { push_matched_paren(index, (*m_presult)[index]); @@ -364,11 +404,11 @@ bool perl_matcher::match_startmark( return true; } -template -bool perl_matcher::match_alt() +template +bool perl_matcher::match_alt() { bool take_first, take_second; - const re_jump* jmp = static_cast(pstate); + const re_alt* jmp = static_cast(pstate); // find out which of these two alternatives we need to take: if(position == last) @@ -378,8 +418,8 @@ bool perl_matcher::match_alt() } else { - take_first = access::can_start(*position, jmp->_map, (unsigned char)mask_take); - take_second = access::can_start(*position, jmp->_map, (unsigned char)mask_skip); + take_first = can_start(*position, jmp->_map, (unsigned char)mask_take); + take_second = can_start(*position, jmp->_map, (unsigned char)mask_skip); } if(take_first) @@ -401,8 +441,8 @@ bool perl_matcher::match_alt() return false; // neither option is possible } -template -bool perl_matcher::match_rep() +template +bool perl_matcher::match_rep() { #ifdef BOOST_MSVC #pragma warning(push) @@ -422,8 +462,8 @@ bool perl_matcher::match_rep() } else { - take_first = access::can_start(*position, rep->_map, (unsigned char)mask_take); - take_second = access::can_start(*position, rep->_map, (unsigned char)mask_skip); + take_first = can_start(*position, rep->_map, (unsigned char)mask_take); + take_second = can_start(*position, rep->_map, (unsigned char)mask_skip); } if(take_first || (next_count->get_id() != rep->id)) @@ -452,7 +492,8 @@ bool perl_matcher::match_rep() return false; } - if(rep->greedy) + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + if(greedy) { // try and take the repeat if we can: if((next_count->get_count() < rep->max) && take_first) @@ -479,8 +520,11 @@ bool perl_matcher::match_rep() // try and skip the repeat if we can: if(take_second) { - // store position in case we fail: - push_non_greedy_repeat(rep->next.p); + if((next_count->get_count() < rep->max) && take_first) + { + // store position in case we fail: + push_non_greedy_repeat(rep->next.p); + } pstate = rep->alt.p; return true; } @@ -501,8 +545,8 @@ bool perl_matcher::match_rep() #endif } -template -bool perl_matcher::match_dot_repeat_slow() +template +bool perl_matcher::match_dot_repeat_slow() { unsigned count = 0; const re_repeat* rep = static_cast(pstate); @@ -515,7 +559,8 @@ bool perl_matcher::match_dot_repeat return false; ++count; } - if(rep->greedy) + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + if(greedy) { // repeat for as long as we can: while(count < rep->max) @@ -541,23 +586,29 @@ bool perl_matcher::match_dot_repeat if(count < rep->max) push_single_repeat(count, rep, position, saved_state_rep_slow_dot); pstate = rep->alt.p; - return (position == last) ? (rep->can_be_null & mask_skip) : access::can_start(*position, rep->_map, mask_skip); + return (position == last) ? (rep->can_be_null & mask_skip) : can_start(*position, rep->_map, mask_skip); } } -template -bool perl_matcher::match_dot_repeat_fast() +template +bool perl_matcher::match_dot_repeat_fast() { - if(m_match_flags & (match_not_dot_newline | match_not_dot_null)) + if(m_match_flags & match_not_dot_null) + return match_dot_repeat_slow(); + if((static_cast(pstate->next.p)->mask & match_any_mask) == 0) return match_dot_repeat_slow(); const re_repeat* rep = static_cast(pstate); - unsigned count = (std::min)(static_cast(re_detail::distance(position, last)), static_cast(rep->greedy ? rep->max : rep->min)); + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + unsigned count = static_cast((std::min)(static_cast(::boost::re_detail::distance(position, last)), static_cast(greedy ? rep->max : rep->min))); if(rep->min > count) + { + position = last; return false; // not enough text left to match + } std::advance(position, count); - if(rep->greedy) + if(greedy) { if((rep->leading) && (count < rep->max)) restart = position; @@ -574,12 +625,12 @@ bool perl_matcher::match_dot_repeat if(count < rep->max) push_single_repeat(count, rep, position, saved_state_rep_fast_dot); pstate = rep->alt.p; - return (position == last) ? (rep->can_be_null & mask_skip) : access::can_start(*position, rep->_map, mask_skip); + return (position == last) ? (rep->can_be_null & mask_skip) : can_start(*position, rep->_map, mask_skip); } } -template -bool perl_matcher::match_char_repeat() +template +bool perl_matcher::match_char_repeat() { #ifdef BOOST_MSVC #pragma warning(push) @@ -589,23 +640,24 @@ bool perl_matcher::match_char_repea #pragma option push -w-8008 -w-8066 -w-8004 #endif const re_repeat* rep = static_cast(pstate); - assert(1 == static_cast(rep->next.p)->length); + BOOST_ASSERT(1 == static_cast(rep->next.p)->length); const char_type what = *reinterpret_cast(static_cast(rep->next.p) + 1); - unsigned count = 0; + std::size_t count = 0; // // start by working out how much we can skip: // - unsigned desired = rep->greedy ? rep->max : rep->min; + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + std::size_t desired = greedy ? rep->max : rep->min; if(::boost::is_random_access_iterator::value) { BidiIterator end = position; - std::advance(end, (std::min)((unsigned)re_detail::distance(position, last), desired)); + std::advance(end, (std::min)((std::size_t)::boost::re_detail::distance(position, last), desired)); BidiIterator origin(position); while((position != end) && (traits_inst.translate(*position, icase) == what)) { ++position; } - count = (unsigned)re_detail::distance(origin, position); + count = (unsigned)::boost::re_detail::distance(origin, position); } else { @@ -619,7 +671,7 @@ bool perl_matcher::match_char_repea if(count < rep->min) return false; - if(rep->greedy) + if(greedy) { if((rep->leading) && (count < rep->max)) restart = position; @@ -636,7 +688,7 @@ bool perl_matcher::match_char_repea if(count < rep->max) push_single_repeat(count, rep, position, saved_state_rep_char); pstate = rep->alt.p; - return (position == last) ? (rep->can_be_null & mask_skip) : access::can_start(*position, rep->_map, mask_skip); + return (position == last) ? (rep->can_be_null & mask_skip) : can_start(*position, rep->_map, mask_skip); } #ifdef __BORLANDC__ #pragma option pop @@ -646,8 +698,8 @@ bool perl_matcher::match_char_repea #endif } -template -bool perl_matcher::match_set_repeat() +template +bool perl_matcher::match_set_repeat() { #ifdef BOOST_MSVC #pragma warning(push) @@ -658,25 +710,26 @@ bool perl_matcher::match_set_repeat #endif const re_repeat* rep = static_cast(pstate); const unsigned char* map = static_cast(rep->next.p)->_map; - unsigned count = 0; + std::size_t count = 0; // // start by working out how much we can skip: // - unsigned desired = rep->greedy ? rep->max : rep->min; + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + std::size_t desired = greedy ? rep->max : rep->min; if(::boost::is_random_access_iterator::value) { BidiIterator end = position; - std::advance(end, (std::min)((unsigned)re_detail::distance(position, last), desired)); + std::advance(end, (std::min)((std::size_t)::boost::re_detail::distance(position, last), desired)); BidiIterator origin(position); - while((position != end) && map[(traits_uchar_type)traits_inst.translate(*position, icase)]) + while((position != end) && map[static_cast(traits_inst.translate(*position, icase))]) { ++position; } - count = (unsigned)re_detail::distance(origin, position); + count = (unsigned)::boost::re_detail::distance(origin, position); } else { - while((count < desired) && (position != last) && map[(traits_uchar_type)traits_inst.translate(*position, icase)]) + while((count < desired) && (position != last) && map[static_cast(traits_inst.translate(*position, icase))]) { ++position; ++count; @@ -686,7 +739,7 @@ bool perl_matcher::match_set_repeat if(count < rep->min) return false; - if(rep->greedy) + if(greedy) { if((rep->leading) && (count < rep->max)) restart = position; @@ -703,7 +756,7 @@ bool perl_matcher::match_set_repeat if(count < rep->max) push_single_repeat(count, rep, position, saved_state_rep_short_set); pstate = rep->alt.p; - return (position == last) ? (rep->can_be_null & mask_skip) : access::can_start(*position, rep->_map, mask_skip); + return (position == last) ? (rep->can_be_null & mask_skip) : can_start(*position, rep->_map, mask_skip); } #ifdef __BORLANDC__ #pragma option pop @@ -713,8 +766,8 @@ bool perl_matcher::match_set_repeat #endif } -template -bool perl_matcher::match_long_set_repeat() +template +bool perl_matcher::match_long_set_repeat() { #ifdef BOOST_MSVC #pragma warning(push) @@ -723,27 +776,29 @@ bool perl_matcher::match_long_set_r #ifdef __BORLANDC__ #pragma option push -w-8008 -w-8066 -w-8004 #endif + typedef typename traits::char_class_type mask_type; const re_repeat* rep = static_cast(pstate); - const re_set_long* set = static_cast(pstate->next.p); - unsigned count = 0; + const re_set_long* set = static_cast*>(pstate->next.p); + std::size_t count = 0; // // start by working out how much we can skip: // - unsigned desired = rep->greedy ? rep->max : rep->min; + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + std::size_t desired = greedy ? rep->max : rep->min; if(::boost::is_random_access_iterator::value) { BidiIterator end = position; - std::advance(end, (std::min)((unsigned)re_detail::distance(position, last), desired)); + std::advance(end, (std::min)((std::size_t)::boost::re_detail::distance(position, last), desired)); BidiIterator origin(position); - while((position != end) && (position != re_is_set_member(position, last, set, re))) + while((position != end) && (position != re_is_set_member(position, last, set, re.get_data(), icase))) { ++position; } - count = (unsigned)re_detail::distance(origin, position); + count = (unsigned)::boost::re_detail::distance(origin, position); } else { - while((count < desired) && (position != last) && (position != re_is_set_member(position, last, set, re))) + while((count < desired) && (position != last) && (position != re_is_set_member(position, last, set, re.get_data(), icase))) { ++position; ++count; @@ -753,7 +808,7 @@ bool perl_matcher::match_long_set_r if(count < rep->min) return false; - if(rep->greedy) + if(greedy) { if((rep->leading) && (count < rep->max)) restart = position; @@ -770,7 +825,7 @@ bool perl_matcher::match_long_set_r if(count < rep->max) push_single_repeat(count, rep, position, saved_state_rep_long_set); pstate = rep->alt.p; - return (position == last) ? (rep->can_be_null & mask_skip) : access::can_start(*position, rep->_map, mask_skip); + return (position == last) ? (rep->can_be_null & mask_skip) : can_start(*position, rep->_map, mask_skip); } #ifdef __BORLANDC__ #pragma option pop @@ -787,25 +842,25 @@ unwinding does in the recursive implementation. ****************************************************************************/ -template -bool perl_matcher::unwind(bool have_match) +template +bool perl_matcher::unwind(bool have_match) { static unwind_proc_type const s_unwind_table[14] = { - &perl_matcher::unwind_end, - &perl_matcher::unwind_paren, - &perl_matcher::unwind_recursion_stopper, - &perl_matcher::unwind_assertion, - &perl_matcher::unwind_alt, - &perl_matcher::unwind_repeater_counter, - &perl_matcher::unwind_extra_block, - &perl_matcher::unwind_greedy_single_repeat, - &perl_matcher::unwind_slow_dot_repeat, - &perl_matcher::unwind_fast_dot_repeat, - &perl_matcher::unwind_char_repeat, - &perl_matcher::unwind_short_set_repeat, - &perl_matcher::unwind_long_set_repeat, - &perl_matcher::unwind_non_greedy_repeat, + &perl_matcher::unwind_end, + &perl_matcher::unwind_paren, + &perl_matcher::unwind_recursion_stopper, + &perl_matcher::unwind_assertion, + &perl_matcher::unwind_alt, + &perl_matcher::unwind_repeater_counter, + &perl_matcher::unwind_extra_block, + &perl_matcher::unwind_greedy_single_repeat, + &perl_matcher::unwind_slow_dot_repeat, + &perl_matcher::unwind_fast_dot_repeat, + &perl_matcher::unwind_char_repeat, + &perl_matcher::unwind_short_set_repeat, + &perl_matcher::unwind_long_set_repeat, + &perl_matcher::unwind_non_greedy_repeat, }; m_recursive_result = have_match; @@ -825,15 +880,15 @@ bool perl_matcher::unwind(bool have return pstate ? true : false; } -template -bool perl_matcher::unwind_end(bool) +template +bool perl_matcher::unwind_end(bool) { pstate = 0; // nothing left to search return false; // end of stack nothing more to search } -template -bool perl_matcher::unwind_paren(bool have_match) +template +bool perl_matcher::unwind_paren(bool have_match) { saved_matched_paren* pmp = static_cast*>(m_backup_state); // restore previous values if no match was found: @@ -855,16 +910,16 @@ bool perl_matcher::unwind_paren(boo return true; // keep looking } -template -bool perl_matcher::unwind_recursion_stopper(bool) +template +bool perl_matcher::unwind_recursion_stopper(bool) { boost::re_detail::inplace_destroy(m_backup_state++); pstate = 0; // nothing left to search return false; // end of stack nothing more to search } -template -bool perl_matcher::unwind_assertion(bool r) +template +bool perl_matcher::unwind_assertion(bool r) { saved_assertion* pmp = static_cast*>(m_backup_state); pstate = pmp->pstate; @@ -876,8 +931,8 @@ bool perl_matcher::unwind_assertion return !result; // return false if the assertion was matched to stop search. } -template -bool perl_matcher::unwind_alt(bool r) +template +bool perl_matcher::unwind_alt(bool r) { saved_position* pmp = static_cast*>(m_backup_state); if(!r) @@ -890,8 +945,8 @@ bool perl_matcher::unwind_alt(bool return r; } -template -bool perl_matcher::unwind_repeater_counter(bool) +template +bool perl_matcher::unwind_repeater_counter(bool) { saved_repeater* pmp = static_cast*>(m_backup_state); boost::re_detail::inplace_destroy(pmp++); @@ -899,8 +954,8 @@ bool perl_matcher::unwind_repeater_ return true; // keep looking } -template -bool perl_matcher::unwind_extra_block(bool) +template +bool perl_matcher::unwind_extra_block(bool) { saved_extra_block* pmp = static_cast(m_backup_state); void* condemmed = m_stack_base; @@ -911,16 +966,16 @@ bool perl_matcher::unwind_extra_blo return true; // keep looking } -template -inline void perl_matcher::destroy_single_repeat() +template +inline void perl_matcher::destroy_single_repeat() { saved_single_repeat* p = static_cast*>(m_backup_state); boost::re_detail::inplace_destroy(p++); m_backup_state = p; } -template -bool perl_matcher::unwind_greedy_single_repeat(bool r) +template +bool perl_matcher::unwind_greedy_single_repeat(bool r) { saved_single_repeat* pmp = static_cast*>(m_backup_state); @@ -932,16 +987,16 @@ bool perl_matcher::unwind_greedy_si } const re_repeat* rep = pmp->rep; - unsigned count = pmp->count; - assert(rep->next.p != 0); - assert(rep->alt.p != 0); + std::size_t count = pmp->count; + BOOST_ASSERT(rep->next.p != 0); + BOOST_ASSERT(rep->alt.p != 0); count -= rep->min; if((m_match_flags & match_partial) && (position == last)) m_has_partial_match = true; - assert(count); + BOOST_ASSERT(count); position = pmp->last_position; // backtrack till we can skip out: @@ -950,13 +1005,13 @@ bool perl_matcher::unwind_greedy_si --position; --count; ++state_count; - }while(count && !access::can_start(*position, rep->_map, mask_skip)); + }while(count && !can_start(*position, rep->_map, mask_skip)); // if we've hit base, destroy this state: if(count == 0) { destroy_single_repeat(); - if(!access::can_start(*position, rep->_map, mask_skip)) + if(!can_start(*position, rep->_map, mask_skip)) return true; } else @@ -968,8 +1023,8 @@ bool perl_matcher::unwind_greedy_si return false; } -template -bool perl_matcher::unwind_slow_dot_repeat(bool r) +template +bool perl_matcher::unwind_slow_dot_repeat(bool r) { saved_single_repeat* pmp = static_cast*>(m_backup_state); @@ -981,13 +1036,13 @@ bool perl_matcher::unwind_slow_dot_ } const re_repeat* rep = pmp->rep; - unsigned count = pmp->count; - assert(rep->type == syntax_element_dot_rep); - assert(rep->next.p != 0); - assert(rep->alt.p != 0); - assert(rep->next.p->type == syntax_element_wild); + std::size_t count = pmp->count; + BOOST_ASSERT(rep->type == syntax_element_dot_rep); + BOOST_ASSERT(rep->next.p != 0); + BOOST_ASSERT(rep->alt.p != 0); + BOOST_ASSERT(rep->next.p->type == syntax_element_wild); - assert(count < rep->max); + BOOST_ASSERT(count < rep->max); pstate = rep->next.p; position = pmp->last_position; @@ -1005,7 +1060,7 @@ bool perl_matcher::unwind_slow_dot_ ++count; ++state_count; pstate = rep->next.p; - }while((count < rep->max) && (position != last) && !access::can_start(*position, rep->_map, mask_skip)); + }while((count < rep->max) && (position != last) && !can_start(*position, rep->_map, mask_skip)); } if(position == last) { @@ -1018,7 +1073,7 @@ bool perl_matcher::unwind_slow_dot_ { // can't repeat any more, remove the pushed state: destroy_single_repeat(); - if(!access::can_start(*position, rep->_map, mask_skip)) + if(!can_start(*position, rep->_map, mask_skip)) return true; } else @@ -1030,8 +1085,8 @@ bool perl_matcher::unwind_slow_dot_ return false; } -template -bool perl_matcher::unwind_fast_dot_repeat(bool r) +template +bool perl_matcher::unwind_fast_dot_repeat(bool r) { saved_single_repeat* pmp = static_cast*>(m_backup_state); @@ -1043,9 +1098,9 @@ bool perl_matcher::unwind_fast_dot_ } const re_repeat* rep = pmp->rep; - unsigned count = pmp->count; + std::size_t count = pmp->count; - assert(count < rep->max); + BOOST_ASSERT(count < rep->max); position = pmp->last_position; if(position != last) { @@ -1056,7 +1111,7 @@ bool perl_matcher::unwind_fast_dot_ ++position; ++count; ++state_count; - }while((count < rep->max) && (position != last) && !access::can_start(*position, rep->_map, mask_skip)); + }while((count < rep->max) && (position != last) && !can_start(*position, rep->_map, mask_skip)); } if(position == last) @@ -1070,7 +1125,7 @@ bool perl_matcher::unwind_fast_dot_ { // can't repeat any more, remove the pushed state: destroy_single_repeat(); - if(!access::can_start(*position, rep->_map, mask_skip)) + if(!can_start(*position, rep->_map, mask_skip)) return true; } else @@ -1082,8 +1137,8 @@ bool perl_matcher::unwind_fast_dot_ return false; } -template -bool perl_matcher::unwind_char_repeat(bool r) +template +bool perl_matcher::unwind_char_repeat(bool r) { saved_single_repeat* pmp = static_cast*>(m_backup_state); @@ -1095,16 +1150,16 @@ bool perl_matcher::unwind_char_repe } const re_repeat* rep = pmp->rep; - unsigned count = pmp->count; + std::size_t count = pmp->count; pstate = rep->next.p; const char_type what = *reinterpret_cast(static_cast(pstate) + 1); position = pmp->last_position; - assert(rep->type == syntax_element_char_rep); - assert(rep->next.p != 0); - assert(rep->alt.p != 0); - assert(rep->next.p->type == syntax_element_literal); - assert(count < rep->max); + BOOST_ASSERT(rep->type == syntax_element_char_rep); + BOOST_ASSERT(rep->next.p != 0); + BOOST_ASSERT(rep->alt.p != 0); + BOOST_ASSERT(rep->next.p->type == syntax_element_literal); + BOOST_ASSERT(count < rep->max); if(position != last) { @@ -1121,7 +1176,7 @@ bool perl_matcher::unwind_char_repe ++ position; ++state_count; pstate = rep->next.p; - }while((count < rep->max) && (position != last) && !access::can_start(*position, rep->_map, mask_skip)); + }while((count < rep->max) && (position != last) && !can_start(*position, rep->_map, mask_skip)); } if(position == last) { @@ -1134,7 +1189,7 @@ bool perl_matcher::unwind_char_repe { // can't repeat any more, remove the pushed state: destroy_single_repeat(); - if(!access::can_start(*position, rep->_map, mask_skip)) + if(!can_start(*position, rep->_map, mask_skip)) return true; } else @@ -1146,8 +1201,8 @@ bool perl_matcher::unwind_char_repe return false; } -template -bool perl_matcher::unwind_short_set_repeat(bool r) +template +bool perl_matcher::unwind_short_set_repeat(bool r) { saved_single_repeat* pmp = static_cast*>(m_backup_state); @@ -1159,23 +1214,23 @@ bool perl_matcher::unwind_short_set } const re_repeat* rep = pmp->rep; - unsigned count = pmp->count; + std::size_t count = pmp->count; pstate = rep->next.p; const unsigned char* map = static_cast(rep->next.p)->_map; position = pmp->last_position; - assert(rep->type == syntax_element_short_set_rep); - assert(rep->next.p != 0); - assert(rep->alt.p != 0); - assert(rep->next.p->type == syntax_element_set); - assert(count < rep->max); + BOOST_ASSERT(rep->type == syntax_element_short_set_rep); + BOOST_ASSERT(rep->next.p != 0); + BOOST_ASSERT(rep->alt.p != 0); + BOOST_ASSERT(rep->next.p->type == syntax_element_set); + BOOST_ASSERT(count < rep->max); if(position != last) { // wind forward until we can skip out of the repeat: do { - if(!map[(traits_uchar_type)traits_inst.translate(*position, icase)]) + if(!map[static_cast(traits_inst.translate(*position, icase))]) { // failed repeat match, discard this state and look for another: destroy_single_repeat(); @@ -1185,7 +1240,7 @@ bool perl_matcher::unwind_short_set ++ position; ++state_count; pstate = rep->next.p; - }while((count < rep->max) && (position != last) && !access::can_start(*position, rep->_map, mask_skip)); + }while((count < rep->max) && (position != last) && !can_start(*position, rep->_map, mask_skip)); } if(position == last) { @@ -1198,7 +1253,7 @@ bool perl_matcher::unwind_short_set { // can't repeat any more, remove the pushed state: destroy_single_repeat(); - if(!access::can_start(*position, rep->_map, mask_skip)) + if(!can_start(*position, rep->_map, mask_skip)) return true; } else @@ -1210,9 +1265,10 @@ bool perl_matcher::unwind_short_set return false; } -template -bool perl_matcher::unwind_long_set_repeat(bool r) +template +bool perl_matcher::unwind_long_set_repeat(bool r) { + typedef typename traits::char_class_type mask_type; saved_single_repeat* pmp = static_cast*>(m_backup_state); // if we have a match, just discard this state: @@ -1223,24 +1279,23 @@ bool perl_matcher::unwind_long_set_ } const re_repeat* rep = pmp->rep; - unsigned count = pmp->count; + std::size_t count = pmp->count; pstate = rep->next.p; - const re_set_long* set = static_cast(pstate); + const re_set_long* set = static_cast*>(pstate); position = pmp->last_position; - assert(rep->type == syntax_element_long_set_rep); - assert(rep->next.p != 0); - assert(rep->alt.p != 0); - assert(rep->next.p->type == syntax_element_long_set); - assert(position != last); - assert(count < rep->max); + BOOST_ASSERT(rep->type == syntax_element_long_set_rep); + BOOST_ASSERT(rep->next.p != 0); + BOOST_ASSERT(rep->alt.p != 0); + BOOST_ASSERT(rep->next.p->type == syntax_element_long_set); + BOOST_ASSERT(count < rep->max); if(position != last) { // wind forward until we can skip out of the repeat: do { - if(position == re_is_set_member(position, last, set, re)) + if(position == re_is_set_member(position, last, set, re.get_data(), icase)) { // failed repeat match, discard this state and look for another: destroy_single_repeat(); @@ -1250,7 +1305,7 @@ bool perl_matcher::unwind_long_set_ ++count; ++state_count; pstate = rep->next.p; - }while((count < rep->max) && (position != last) && !access::can_start(*position, rep->_map, mask_skip)); + }while((count < rep->max) && (position != last) && !can_start(*position, rep->_map, mask_skip)); } if(position == last) { @@ -1263,7 +1318,7 @@ bool perl_matcher::unwind_long_set_ { // can't repeat any more, remove the pushed state: destroy_single_repeat(); - if(!access::can_start(*position, rep->_map, mask_skip)) + if(!can_start(*position, rep->_map, mask_skip)) return true; } else @@ -1275,8 +1330,8 @@ bool perl_matcher::unwind_long_set_ return false; } -template -bool perl_matcher::unwind_non_greedy_repeat(bool r) +template +bool perl_matcher::unwind_non_greedy_repeat(bool r) { saved_position* pmp = static_cast*>(m_backup_state); if(!r) diff --git a/boost/boost/regex/v4/perl_matcher_recursive.hpp b/boost/boost/regex/v4/perl_matcher_recursive.hpp index 721e44d39f..3a76309490 100644 --- a/boost/boost/regex/v4/perl_matcher_recursive.hpp +++ b/boost/boost/regex/v4/perl_matcher_recursive.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -45,48 +45,51 @@ public: const sub_match& get() { return sub; } }; -template -bool perl_matcher::match_all_states() +template +bool perl_matcher::match_all_states() { - static matcher_proc_type const s_match_vtable[26] = + static matcher_proc_type const s_match_vtable[29] = { - (&perl_matcher::match_startmark), - &perl_matcher::match_endmark, - &perl_matcher::match_literal, - &perl_matcher::match_start_line, - &perl_matcher::match_end_line, - &perl_matcher::match_wild, - &perl_matcher::match_match, - &perl_matcher::match_word_boundary, - &perl_matcher::match_within_word, - &perl_matcher::match_word_start, - &perl_matcher::match_word_end, - &perl_matcher::match_buffer_start, - &perl_matcher::match_buffer_end, - &perl_matcher::match_backref, - &perl_matcher::match_long_set, - &perl_matcher::match_set, - &perl_matcher::match_jump, - &perl_matcher::match_alt, - &perl_matcher::match_rep, - &perl_matcher::match_combining, - &perl_matcher::match_soft_buffer_end, - &perl_matcher::match_restart_continue, - (::boost::is_random_access_iterator::value ? &perl_matcher::match_dot_repeat_fast : &perl_matcher::match_dot_repeat_slow), - &perl_matcher::match_char_repeat, - &perl_matcher::match_set_repeat, - &perl_matcher::match_long_set_repeat, + (&perl_matcher::match_startmark), + &perl_matcher::match_endmark, + &perl_matcher::match_literal, + &perl_matcher::match_start_line, + &perl_matcher::match_end_line, + &perl_matcher::match_wild, + &perl_matcher::match_match, + &perl_matcher::match_word_boundary, + &perl_matcher::match_within_word, + &perl_matcher::match_word_start, + &perl_matcher::match_word_end, + &perl_matcher::match_buffer_start, + &perl_matcher::match_buffer_end, + &perl_matcher::match_backref, + &perl_matcher::match_long_set, + &perl_matcher::match_set, + &perl_matcher::match_jump, + &perl_matcher::match_alt, + &perl_matcher::match_rep, + &perl_matcher::match_combining, + &perl_matcher::match_soft_buffer_end, + &perl_matcher::match_restart_continue, + (::boost::is_random_access_iterator::value ? &perl_matcher::match_dot_repeat_fast : &perl_matcher::match_dot_repeat_slow), + &perl_matcher::match_char_repeat, + &perl_matcher::match_set_repeat, + &perl_matcher::match_long_set_repeat, + &perl_matcher::match_backstep, + &perl_matcher::match_assert_backref, + &perl_matcher::match_toggle_case, }; if(state_count > max_state_count) - raise_error(traits_inst, REG_ESPACE); + raise_error(traits_inst, regex_constants::error_space); while(pstate) { matcher_proc_type proc = s_match_vtable[pstate->type]; ++state_count; if(!(this->*proc)()) { - if((m_match_flags & match_partial) && (position == last)) + if((m_match_flags & match_partial) && (position == last) && (position != search_base)) m_has_partial_match = true; return 0; } @@ -94,8 +97,8 @@ bool perl_matcher::match_all_states return true; } -template -bool perl_matcher::match_startmark() +template +bool perl_matcher::match_startmark() { int index = static_cast(pstate)->index; bool r = true; @@ -123,10 +126,13 @@ bool perl_matcher::match_startmark( case -3: { // independent sub-expression: + bool old_independent = m_independent; + m_independent = true; const re_syntax_base* next_pstate = static_cast(pstate->next.p)->alt.p->next.p; pstate = pstate->next.p->next.p; r = match_all_states(); pstate = next_pstate; + m_independent = old_independent; #ifdef BOOST_REGEX_MATCH_EXTRA if(r && (m_match_flags & match_extra)) { @@ -156,9 +162,40 @@ bool perl_matcher::match_startmark( #endif break; } + case -4: + { + // conditional expression: + const re_alt* alt = static_cast(pstate->next.p); + BOOST_ASSERT(alt->type == syntax_element_alt); + pstate = alt->next.p; + if(pstate->type == syntax_element_assert_backref) + { + if(!match_assert_backref()) + pstate = alt->alt.p; + break; + } + else + { + // zero width assertion, have to match this recursively: + BOOST_ASSERT(pstate->type == syntax_element_startmark); + bool negated = static_cast(pstate)->index == -2; + BidiIterator saved_position = position; + const re_syntax_base* next_pstate = static_cast(pstate->next.p)->alt.p->next.p; + pstate = pstate->next.p->next.p; + bool r = match_all_states(); + position = saved_position; + if(negated) + r = !r; + if(r) + pstate = next_pstate; + else + pstate = alt->alt.p; + break; + } + } default: { - assert(index > 0); + BOOST_ASSERT(index > 0); if((m_match_flags & match_nosubs) == 0) { backup_subex sub(*m_presult, index); @@ -185,11 +222,11 @@ bool perl_matcher::match_startmark( return r; } -template -bool perl_matcher::match_alt() +template +bool perl_matcher::match_alt() { bool take_first, take_second; - const re_jump* jmp = static_cast(pstate); + const re_alt* jmp = static_cast(pstate); // find out which of these two alternatives we need to take: if(position == last) @@ -199,8 +236,8 @@ bool perl_matcher::match_alt() } else { - take_first = access::can_start(*position, jmp->_map, (unsigned char)mask_take); - take_second = access::can_start(*position, jmp->_map, (unsigned char)mask_skip); + take_first = can_start(*position, jmp->_map, (unsigned char)mask_take); + take_second = can_start(*position, jmp->_map, (unsigned char)mask_skip); } if(take_first) @@ -230,8 +267,8 @@ bool perl_matcher::match_alt() return false; // neither option is possible } -template -bool perl_matcher::match_rep() +template +bool perl_matcher::match_rep() { #ifdef BOOST_MSVC #pragma warning(push) @@ -261,8 +298,8 @@ bool perl_matcher::match_rep() } else { - take_first = access::can_start(*position, rep->_map, (unsigned char)mask_take); - take_second = access::can_start(*position, rep->_map, (unsigned char)mask_skip); + take_first = can_start(*position, rep->_map, (unsigned char)mask_take); + take_second = can_start(*position, rep->_map, (unsigned char)mask_skip); } if(next_count->get_count() < rep->min) @@ -277,8 +314,8 @@ bool perl_matcher::match_rep() } return false; } - - if(rep->greedy) + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + if(greedy) { // try and take the repeat if we can: if((next_count->get_count() < rep->max) && take_first) @@ -327,8 +364,8 @@ bool perl_matcher::match_rep() #endif } -template -bool perl_matcher::match_dot_repeat_slow() +template +bool perl_matcher::match_dot_repeat_slow() { #ifdef BOOST_MSVC #pragma warning(push) @@ -345,7 +382,8 @@ bool perl_matcher::match_dot_repeat return false; ++count; } - if(rep->greedy) + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + if(greedy) { // normal repeat: while(count < rep->max) @@ -387,38 +425,51 @@ bool perl_matcher::match_dot_repeat #endif } -template -bool perl_matcher::match_dot_repeat_fast() +template +bool perl_matcher::match_dot_repeat_fast() { #ifdef BOOST_MSVC #pragma warning(push) #pragma warning(disable:4127) #endif - if(m_match_flags & (match_not_dot_newline | match_not_dot_null)) + if(m_match_flags & match_not_dot_null) + return match_dot_repeat_slow(); + if((static_cast(pstate->next.p)->mask & match_any_mask) == 0) return match_dot_repeat_slow(); // // start by working out how much we can skip: // const re_repeat* rep = static_cast(pstate); - unsigned count = (std::min)(static_cast(re_detail::distance(position, last)), (rep->greedy ? rep->max : rep->min)); +#ifdef BOOST_MSVC +#pragma warning(push) +#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(::boost::re_detail::distance(position, last)), static_cast(greedy ? rep->max : rep->min)); if(rep->min > count) + { + position = last; return false; // not enough text left to match + } std::advance(position, count); - if((rep->leading) && (count < rep->max) && (rep->greedy)) +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + if((rep->leading) && (count < rep->max) && greedy) restart = position; - if(rep->greedy) + if(greedy) return backtrack_till_match(count - rep->min); // non-greedy, keep trying till we get a match: BidiIterator save_pos; do { - while((position != last) && (count < rep->max) && !access::can_start(*position, rep->_map, mask_skip)) + while((position != last) && (count < rep->max) && !can_start(*position, rep->_map, mask_skip)) { ++position; ++count; } - if((rep->leading) && (count == UINT_MAX)) + if((rep->leading) && (rep->max == UINT_MAX)) restart = position; pstate = rep->alt.p; save_pos = position; @@ -437,8 +488,8 @@ bool perl_matcher::match_dot_repeat #endif } -template -bool perl_matcher::match_char_repeat() +template +bool perl_matcher::match_char_repeat() { #ifdef BOOST_MSVC #pragma warning(push) @@ -448,23 +499,24 @@ bool perl_matcher::match_char_repea #pragma option push -w-8008 -w-8066 -w-8004 #endif const re_repeat* rep = static_cast(pstate); - assert(1 == static_cast(rep->next.p)->length); + BOOST_ASSERT(1 == static_cast(rep->next.p)->length); const char_type what = *reinterpret_cast(static_cast(rep->next.p) + 1); unsigned count = 0; // // start by working out how much we can skip: // - unsigned desired = rep->greedy ? rep->max : rep->min; + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + std::size_t desired = greedy ? rep->max : rep->min; if(::boost::is_random_access_iterator::value) { BidiIterator end = position; - std::advance(end, (std::min)((unsigned)re_detail::distance(position, last), desired)); + std::advance(end, (std::min)((std::size_t)::boost::re_detail::distance(position, last), desired)); BidiIterator origin(position); while((position != end) && (traits_inst.translate(*position, icase) == what)) { ++position; } - count = (unsigned)re_detail::distance(origin, position); + count = (unsigned)::boost::re_detail::distance(origin, position); } else { @@ -474,19 +526,19 @@ bool perl_matcher::match_char_repea ++count; } } - if((rep->leading) && (count < rep->max) && (rep->greedy)) + if((rep->leading) && (count < rep->max) && greedy) restart = position; if(count < rep->min) return false; - if(rep->greedy) + if(greedy) return backtrack_till_match(count - rep->min); // non-greedy, keep trying till we get a match: BidiIterator save_pos; do { - while((position != last) && (count < rep->max) && !access::can_start(*position, rep->_map, mask_skip)) + while((position != last) && (count < rep->max) && !can_start(*position, rep->_map, mask_skip)) { if((traits_inst.translate(*position, icase) == what)) { @@ -526,8 +578,8 @@ bool perl_matcher::match_char_repea #endif } -template -bool perl_matcher::match_set_repeat() +template +bool perl_matcher::match_set_repeat() { #ifdef BOOST_MSVC #pragma warning(push) @@ -542,41 +594,42 @@ bool perl_matcher::match_set_repeat // // start by working out how much we can skip: // - unsigned desired = rep->greedy ? rep->max : rep->min; + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + std::size_t desired = greedy ? rep->max : rep->min; if(::boost::is_random_access_iterator::value) { BidiIterator end = position; - std::advance(end, (std::min)((unsigned)re_detail::distance(position, last), desired)); + std::advance(end, (std::min)((std::size_t)::boost::re_detail::distance(position, last), desired)); BidiIterator origin(position); - while((position != end) && map[(traits_uchar_type)traits_inst.translate(*position, icase)]) + while((position != end) && map[static_cast(traits_inst.translate(*position, icase))]) { ++position; } - count = (unsigned)re_detail::distance(origin, position); + count = (unsigned)::boost::re_detail::distance(origin, position); } else { - while((count < desired) && (position != last) && map[(traits_uchar_type)traits_inst.translate(*position, icase)]) + while((count < desired) && (position != last) && map[static_cast(traits_inst.translate(*position, icase))]) { ++position; ++count; } } - if((rep->leading) && (count < rep->max) && (rep->greedy)) + if((rep->leading) && (count < rep->max) && greedy) restart = position; if(count < rep->min) return false; - if(rep->greedy) + if(greedy) return backtrack_till_match(count - rep->min); // non-greedy, keep trying till we get a match: BidiIterator save_pos; do { - while((position != last) && (count < rep->max) && !access::can_start(*position, rep->_map, mask_skip)) + while((position != last) && (count < rep->max) && !can_start(*position, rep->_map, mask_skip)) { - if(map[(traits_uchar_type)traits_inst.translate(*position, icase)]) + if(map[static_cast(traits_inst.translate(*position, icase))]) { ++position; ++count; @@ -596,7 +649,7 @@ bool perl_matcher::match_set_repeat if(position == last) return false; position = save_pos; - if(map[(traits_uchar_type)traits_inst.translate(*position, icase)]) + if(map[static_cast(traits_inst.translate(*position, icase))]) { ++position; ++count; @@ -614,8 +667,8 @@ bool perl_matcher::match_set_repeat #endif } -template -bool perl_matcher::match_long_set_repeat() +template +bool perl_matcher::match_long_set_repeat() { #ifdef BOOST_MSVC #pragma warning(push) @@ -624,47 +677,49 @@ bool perl_matcher::match_long_set_r #ifdef __BORLANDC__ #pragma option push -w-8008 -w-8066 -w-8004 #endif + typedef typename traits::char_class_type char_class_type; const re_repeat* rep = static_cast(pstate); - const re_set_long* set = static_cast(pstate->next.p); + const re_set_long* set = static_cast*>(pstate->next.p); unsigned count = 0; // // start by working out how much we can skip: // - unsigned desired = rep->greedy ? rep->max : rep->min; + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + std::size_t desired = greedy ? rep->max : rep->min; if(::boost::is_random_access_iterator::value) { BidiIterator end = position; - std::advance(end, (std::min)((unsigned)re_detail::distance(position, last), desired)); + std::advance(end, (std::min)((std::size_t)::boost::re_detail::distance(position, last), desired)); BidiIterator origin(position); - while((position != end) && (position != re_is_set_member(position, last, set, re))) + while((position != end) && (position != re_is_set_member(position, last, set, re.get_data(), icase))) { ++position; } - count = (unsigned)re_detail::distance(origin, position); + count = (unsigned)::boost::re_detail::distance(origin, position); } else { - while((count < desired) && (position != last) && (position != re_is_set_member(position, last, set, re))) + while((count < desired) && (position != last) && (position != re_is_set_member(position, last, set, re.get_data(), icase))) { ++position; ++count; } } - if((rep->leading) && (count < rep->max) && (rep->greedy)) + if((rep->leading) && (count < rep->max) && greedy) restart = position; if(count < rep->min) return false; - if(rep->greedy) + if(greedy) return backtrack_till_match(count - rep->min); // non-greedy, keep trying till we get a match: BidiIterator save_pos; do { - while((position != last) && (count < rep->max) && !access::can_start(*position, rep->_map, mask_skip)) + while((position != last) && (count < rep->max) && !can_start(*position, rep->_map, mask_skip)) { - if(position != re_is_set_member(position, last, set, re)) + if(position != re_is_set_member(position, last, set, re.get_data(), icase)) { ++position; ++count; @@ -684,7 +739,7 @@ bool perl_matcher::match_long_set_r if(position == last) return false; position = save_pos; - if(position != re_is_set_member(position, last, set, re)) + if(position != re_is_set_member(position, last, set, re.get_data(), icase)) { ++position; ++count; @@ -702,8 +757,8 @@ bool perl_matcher::match_long_set_r #endif } -template -bool perl_matcher::backtrack_till_match(unsigned count) +template +bool perl_matcher::backtrack_till_match(std::size_t count) { #ifdef BOOST_MSVC #pragma warning(push) @@ -732,7 +787,7 @@ bool perl_matcher::backtrack_till_m } do { - while(count && !access::can_start(*position, rep->_map, mask_skip)) + while(count && !can_start(*position, rep->_map, mask_skip)) { --position; --count; diff --git a/boost/libs/regex/src/primary_transform.hpp b/boost/boost/regex/v4/primary_transform.hpp similarity index 71% rename from boost/libs/regex/src/primary_transform.hpp rename to boost/boost/regex/v4/primary_transform.hpp index a7381b8b0a..e498b63b02 100644 --- a/boost/libs/regex/src/primary_transform.hpp +++ b/boost/boost/regex/v4/primary_transform.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -17,6 +17,13 @@ * by the current locale. */ +#ifndef BOOST_REGEX_PRIMARY_TRANSFORM +#define BOOST_REGEX_PRIMARY_TRANSFORM + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + namespace boost{ namespace re_detail{ @@ -31,6 +38,12 @@ enum{ template unsigned count_chars(const S& s, charT c) { + // + // Count how many occurances of character c occur + // in string s: if c is a delimeter between collation + // fields, then this should be the same value for all + // sort keys: + // unsigned int count = 0; for(unsigned pos = 0; pos < s.size(); ++pos) { @@ -53,20 +66,17 @@ unsigned find_sort_syntax(const traits* pt, charT* delim) // Suppress incorrect warning for MSVC (void)pt; - string_type a(1, (char_type)'a'); - string_type sa; - pt->transform(sa, a); + char_type a[2] = {'a', '\0', }; + string_type sa(pt->transform(a, a+1)); if(sa == a) { *delim = 0; return sort_C; } - string_type A(1, (char_type)'A'); - string_type sA; - pt->transform(sA, A); - string_type c(1, (char_type)';'); - string_type sc; - pt->transform(sc, c); + char_type A[2] = { 'A', '\0', }; + string_type sA(pt->transform(A, A+1)); + char_type c[2] = { ';', '\0', }; + string_type sc(pt->transform(c, c+1)); int pos = 0; while((pos <= static_cast(sa.size())) && (pos <= static_cast(sA.size())) && (sa[pos] == sA[pos])) ++pos; @@ -77,11 +87,11 @@ unsigned find_sort_syntax(const traits* pt, charT* delim) return sort_unknown; } // - // at this point sa[pos] is either the end of a fixed with field + // at this point sa[pos] is either the end of a fixed width field // or the character that acts as a delimiter: // charT maybe_delim = sa[pos]; - if((pos != 0) && (count_chars(sa, maybe_delim) == count_chars(sA, maybe_delim)) && (count_chars(sa, maybe_delim) == count_chars(c, maybe_delim))) + if((pos != 0) && (count_chars(sa, maybe_delim) == count_chars(sA, maybe_delim)) && (count_chars(sa, maybe_delim) == count_chars(sc, maybe_delim))) { *delim = maybe_delim; return sort_delim; @@ -89,10 +99,10 @@ unsigned find_sort_syntax(const traits* pt, charT* delim) // // OK doen't look like a delimiter, try for fixed width field: // - if((sa.size() == sA.size()) && (sa.size() == c.size())) + if((sa.size() == sA.size()) && (sa.size() == sc.size())) { // note assumes that the fixed width field is less than - // numeric_limits::max(), should be true for all types + // (numeric_limits::max)(), should be true for all types // I can't imagine 127 character fields... *delim = static_cast(++pos); return sort_fixed; @@ -108,6 +118,11 @@ unsigned find_sort_syntax(const traits* pt, charT* delim) } // namespace re_detail } // namespace boost +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + +#endif diff --git a/boost/boost/regex/v4/protected_call.hpp b/boost/boost/regex/v4/protected_call.hpp new file mode 100644 index 0000000000..197c45563d --- /dev/null +++ b/boost/boost/regex/v4/protected_call.hpp @@ -0,0 +1,67 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE basic_regex_creator.cpp + * VERSION see + * DESCRIPTION: Declares template class basic_regex_creator which fills in + * the data members of a regex_data object. + */ + +#ifndef BOOST_REGEX_V4_PROTECTED_CALL_HPP +#define BOOST_REGEX_V4_PROTECTED_CALL_HPP + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +namespace boost{ +namespace re_detail{ + +class BOOST_REGEX_DECL abstract_protected_call +{ +public: + bool BOOST_REGEX_CALL execute()const; + // this stops gcc-4 from complaining: + virtual ~abstract_protected_call(){} +private: + virtual bool call()const = 0; +}; + +template +class concrete_protected_call + : public abstract_protected_call +{ +public: + typedef bool (T::*proc_type)(); + concrete_protected_call(T* o, proc_type p) + : obj(o), proc(p) {} +private: + virtual bool call()const; + T* obj; + proc_type proc; +}; + +template +bool concrete_protected_call::call()const +{ + return (obj->*proc)(); +} + +} +} // namespace boost + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + +#endif diff --git a/boost/boost/regex/v4/regbase.hpp b/boost/boost/regex/v4/regbase.hpp index e198326f13..4c6bde83f3 100644 --- a/boost/boost/regex/v4/regbase.hpp +++ b/boost/boost/regex/v4/regbase.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -33,32 +33,59 @@ class BOOST_REGEX_DECL regbase public: enum flag_type_ { - escape_in_lists = 1, // '\' special inside [...] - char_classes = escape_in_lists << 1, // [[:CLASS:]] allowed - intervals = char_classes << 1, // {x,y} allowed - limited_ops = intervals << 1, // all of + ? and | are normal characters - newline_alt = limited_ops << 1, // \n is the same as | - bk_plus_qm = newline_alt << 1, // uses \+ and \? - bk_braces = bk_plus_qm << 1, // uses \{ and \} - bk_parens = bk_braces << 1, // uses \( and \) - bk_refs = bk_parens << 1, // \d allowed - bk_vbar = bk_refs << 1, // uses \| + // + // Divide the flags up into logical groups: + // bits 0-7 indicate main synatx type. + // bits 8-15 indicate syntax subtype. + // bits 16-31 indicate options that are common to all + // regex syntaxes. + // In all cases the default is 0. + // + // Main synatx group: + // + perl_syntax_group = 0, // default + basic_syntax_group = 1, // POSIX basic + literal = 2, // all characters are literals + main_option_type = literal | basic_syntax_group | perl_syntax_group, // everything! + // + // options specific to perl group: + // + no_bk_refs = 1 << 8, // \d not allowed + no_perl_ex = 1 << 9, // disable perl extensions + no_mod_m = 1 << 10, // disable Perl m modifier + mod_x = 1 << 11, // Perl x modifier + mod_s = 1 << 12, // force s modifier on (overrides match_not_dot_newline) + no_mod_s = 1 << 13, // force s modifier off (overrides match_not_dot_newline) - use_except = bk_vbar << 1, // exception on error - failbit = use_except << 1, // error flag - literal = failbit << 1, // all characters are literals - icase = literal << 1, // characters are matched regardless of case - nocollate = 0, // don't use locale specific collation (deprecated) - collate = icase << 1, // use locale specific collation - perlex = collate << 1, // perl extensions - nosubs = perlex << 1, // don't mark sub-expressions - optimize = 0, // not really supported + // + // options specific to basic group: + // + no_char_classes = 1 << 8, // [[:CLASS:]] not allowed + no_intervals = 1 << 9, // {x,y} not allowed + bk_plus_qm = 1 << 10, // uses \+ and \? + bk_vbar = 1 << 11, // use \| for alternatives + emacs_ex = 1 << 12, // enables emacs extensions - basic = char_classes | intervals | limited_ops | bk_braces | bk_parens | bk_refs | collate, - extended = char_classes | intervals | bk_refs | collate, - normal = perlex | escape_in_lists | char_classes | intervals | bk_refs | nocollate, - emacs = bk_braces | bk_parens | bk_refs | bk_vbar, - awk = extended | escape_in_lists, + // + // options common to all groups: + // + no_escape_in_lists = 1 << 16, // '\' not special inside [...] + newline_alt = 1 << 17, // \n is the same as | + no_except = 1 << 18, // no exception on error + failbit = 1 << 19, // error flag + icase = 1 << 20, // characters are matched regardless of case + nocollate = 0, // don't use locale specific collation (deprecated) + collate = 1 << 21, // use locale specific collation + nosubs = 1 << 22, // don't mark sub-expressions + optimize = 0, // not really supported + + + + basic = basic_syntax_group | collate | no_escape_in_lists, + extended = no_bk_refs | collate | no_perl_ex | no_escape_in_lists, + normal = 0, + emacs = basic_syntax_group | collate | emacs_ex | bk_vbar, + awk = no_bk_refs | collate | no_perl_ex, grep = basic | newline_alt, egrep = extended | newline_alt, sed = basic, @@ -80,18 +107,6 @@ public: restart_fixed_lit = 6, restart_count = 7 }; - - flag_type BOOST_REGEX_CALL flags()const - { - return _flags; - } - - regbase(); - regbase(const regbase& b); - void swap(regbase& that) - { std::swap(_flags, that._flags); } -protected: - flag_type _flags; }; // @@ -101,26 +116,24 @@ namespace regex_constants{ enum flag_type_ { - escape_in_lists = ::boost::regbase::escape_in_lists, - char_classes = ::boost::regbase::char_classes, - intervals = ::boost::regbase::intervals, - limited_ops = ::boost::regbase::limited_ops, - newline_alt = ::boost::regbase::newline_alt, - bk_plus_qm = ::boost::regbase::bk_plus_qm, - bk_braces = ::boost::regbase::bk_braces, - bk_parens = ::boost::regbase::bk_parens, - bk_refs = ::boost::regbase::bk_refs, - bk_vbar = ::boost::regbase::bk_vbar, - use_except = ::boost::regbase::use_except, + no_except = ::boost::regbase::no_except, failbit = ::boost::regbase::failbit, literal = ::boost::regbase::literal, icase = ::boost::regbase::icase, nocollate = ::boost::regbase::nocollate, collate = ::boost::regbase::collate, - perlex = ::boost::regbase::perlex, nosubs = ::boost::regbase::nosubs, optimize = ::boost::regbase::optimize, + bk_plus_qm = ::boost::regbase::bk_plus_qm, + bk_vbar = ::boost::regbase::bk_vbar, + no_intervals = ::boost::regbase::no_intervals, + no_char_classes = ::boost::regbase::no_char_classes, + no_escape_in_lists = ::boost::regbase::no_escape_in_lists, + no_mod_m = ::boost::regbase::no_mod_m, + mod_x = ::boost::regbase::mod_x, + mod_s = ::boost::regbase::mod_s, + no_mod_s = ::boost::regbase::no_mod_s, basic = ::boost::regbase::basic, extended = ::boost::regbase::extended, diff --git a/boost/boost/regex/v4/regex.hpp b/boost/boost/regex/v4/regex.hpp index 081df67030..7cc260a3ac 100644 --- a/boost/boost/regex/v4/regex.hpp +++ b/boost/boost/regex/v4/regex.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -13,7 +13,7 @@ * LOCATION: see http://www.boost.org for most recent version. * FILE regex.cpp * VERSION see - * DESCRIPTION: Declares boost::reg_expression<> and associated + * DESCRIPTION: Declares boost::basic_regex<> and associated * functions and classes. This header is the main * entry point for the template regex code. */ @@ -21,42 +21,35 @@ #ifndef BOOST_RE_REGEX_HPP_INCLUDED #define BOOST_RE_REGEX_HPP_INCLUDED -#ifndef BOOST_RE_CREGEX_HPP -#include -#endif - #ifdef __cplusplus // what follows is all C++ don't include in C builds!! -#ifdef BOOST_REGEX_DEBUG -# include -#endif - -#include -#include #ifndef BOOST_REGEX_CONFIG_HPP #include #endif +#ifndef BOOST_REGEX_WORKAROUND_HPP +#include +#endif + #ifndef BOOST_REGEX_FWD_HPP #include #endif -#ifndef BOOST_REGEX_STACK_HPP -#include -#endif -#ifndef BOOST_REGEX_RAW_BUFFER_HPP -#include -#endif -#ifndef BOOST_REGEX_KMP_HPP -#include -#endif -#ifndef BOOST_RE_PAT_EXCEPT_HPP -#include -#endif #ifndef BOOST_REGEX_TRAITS_HPP #include #endif -#include +#ifndef BOOST_REGEX_RAW_BUFFER_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_MATCH_FLAGS +#include +#endif +#ifndef BOOST_REGEX_RAW_BUFFER_HPP +#include +#endif +#ifndef BOOST_RE_PAT_EXCEPT_HPP +#include +#endif #ifndef BOOST_REGEX_V4_CHAR_REGEX_TRAITS_HPP #include @@ -70,12 +63,15 @@ #ifndef BOOST_REGEX_V4_ITERATOR_TRAITS_HPP #include #endif -#ifndef BOOST_REGEX_V4_ITERATOR_TRAITS_HPP -#include -#endif #ifndef BOOST_REGEX_V4_BASIC_REGEX_HPP #include #endif +#ifndef BOOST_REGEX_V4_BASIC_REGEX_CREATOR_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_BASIC_REGEX_PARSER_HPP +#include +#endif #ifndef BOOST_REGEX_V4_SUB_MATCH_HPP #include #endif @@ -85,10 +81,12 @@ #ifndef BOOST_REGEX_V4_MATCH_RESULTS_HPP #include #endif -#ifndef BOOST_REGEX_COMPILE_HPP -#include +#ifndef BOOST_REGEX_V4_PROTECTED_CALL_HPP +#include +#endif +#ifndef BOOST_REGEX_MATCHER_HPP +#include #endif - // // template instances: // @@ -103,7 +101,7 @@ #endif #ifndef BOOST_NO_WREGEX -#define BOOST_REGEX_CHAR_T boost::regex_wchar_type +#define BOOST_REGEX_CHAR_T wchar_t #ifdef BOOST_REGEX_WIDE_INSTANTIATE # define BOOST_REGEX_INSTANTIATE #endif @@ -114,12 +112,24 @@ #endif #endif +#if !defined(BOOST_NO_WREGEX) && defined(BOOST_REGEX_HAS_OTHER_WCHAR_T) +#define BOOST_REGEX_CHAR_T unsigned short +#ifdef BOOST_REGEX_US_INSTANTIATE +# define BOOST_REGEX_INSTANTIATE +#endif +#include +#undef BOOST_REGEX_CHAR_T +#ifdef BOOST_REGEX_INSTANTIATE +# undef BOOST_REGEX_INSTANTIATE +#endif +#endif + namespace boost{ #ifdef BOOST_REGEX_NO_FWD -typedef reg_expression, BOOST_DEFAULT_ALLOCATOR(char)> regex; +typedef basic_regex > regex; #ifndef BOOST_NO_WREGEX -typedef reg_expression, BOOST_DEFAULT_ALLOCATOR(wchar_t)> wregex; +typedef basic_regex > wregex; #endif #endif @@ -137,6 +147,12 @@ typedef match_results wsmatch; #ifndef BOOST_REGEX_V4_REGEX_SEARCH_HPP #include #endif +#ifndef BOOST_REGEX_ITERATOR_HPP +#include +#endif +#ifndef BOOST_REGEX_TOKEN_ITERATOR_HPP +#include +#endif #ifndef BOOST_REGEX_V4_REGEX_GREP_HPP #include #endif @@ -149,12 +165,6 @@ typedef match_results wsmatch; #ifndef BOOST_REGEX_SPLIT_HPP #include #endif -#ifndef BOOST_REGEX_ITERATOR_HPP -#include -#endif -#ifndef BOOST_REGEX_TOKEN_ITERATOR_HPP -#include -#endif #endif // __cplusplus diff --git a/boost/boost/regex/v4/regex_compile.hpp b/boost/boost/regex/v4/regex_compile.hpp deleted file mode 100644 index 0a0d8d6e64..0000000000 --- a/boost/boost/regex/v4/regex_compile.hpp +++ /dev/null @@ -1,2215 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * Dr John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - - /* - * LOCATION: see http://www.boost.org for most recent version. - * FILE regex_compile.hpp - * VERSION see - * DESCRIPTION: Declares reg_expression<> member functions. This is - * an internal header file, do not include directly. - */ - -#ifndef BOOST_REGEX_COMPILE_HPP -#define BOOST_REGEX_COMPILE_HPP - -namespace boost{ -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif -#ifdef __BORLANDC__ -#pragma option push -w-8004 -#endif - -namespace re_detail{ - - -template -struct kmp_translator -{ - typedef typename traits::char_type char_type; - bool icase; - const traits* pt; - kmp_translator(bool c, traits* p) : icase(c), pt(p) {} - char_type operator()(char_type c) - { - return pt->translate(c, icase); - } -}; - - -template -bool BOOST_REGEX_CALL re_maybe_set_member(charT c, - const re_set_long* set_, - const reg_expression& e) -{ - const charT* p = reinterpret_cast(set_+1); - bool icase = e.flags() & regex_constants::icase; - charT col = e.get_traits().translate(c, icase); - for(unsigned int i = 0; i < set_->csingles; ++i) - { - if(col == *p) - return set_->isnot ? false : true; - - while(*p)++p; - ++p; // skip null - } - return set_->isnot ? true : false; -} - -} // namespace re_detail - -template -struct is_big_char -{ - typedef typename traits::uchar_type traits_uchar_type; - typedef typename traits::size_type traits_size_type; -#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1200) - static bool test(char) - { return false; } - static bool test(unsigned char) - { return false; } - static bool test(signed char) - { return false; } -#endif - template static bool test(charT c) - { return (traits_size_type)(traits_uchar_type)c >= 256; } -}; - -template -inline bool BOOST_REGEX_CALL reg_expression::can_start(charT c, const unsigned char* _map, unsigned char mask, const re_detail::_wide_type&) -{ - if(is_big_char::test(c)) - return true; - return BOOST_REGEX_MAKE_BOOL(_map[(traits_uchar_type)c] & mask); -} - -template -inline bool BOOST_REGEX_CALL reg_expression::can_start(charT c, const unsigned char* _map, unsigned char mask, const re_detail::_narrow_type&) -{ - return BOOST_REGEX_MAKE_BOOL(_map[(traits_uchar_type)c] & mask); -} - -template -reg_expression::reg_expression(const Allocator& a) - : regbase(), data(a), pkmp(0), error_code_(REG_EMPTY), _expression(0) -{ -} - -template -reg_expression::reg_expression(const charT* p, flag_type f, const Allocator& a) - : data(a), pkmp(0), error_code_(REG_EMPTY), _expression(0) -{ - set_expression(p, f | regex_constants::use_except); -} - -template -reg_expression::reg_expression(const charT* p1, const charT* p2, flag_type f, const Allocator& a) - : data(a), pkmp(0), error_code_(REG_EMPTY), _expression(0) -{ - set_expression(p1, p2, f | regex_constants::use_except); -} - -template -reg_expression::reg_expression(const charT* p, size_type len, flag_type f, const Allocator& a) - : data(a), pkmp(0), error_code_(REG_EMPTY), _expression(0) -{ - set_expression(p, p + len, f | regex_constants::use_except); -} - -template -reg_expression::reg_expression(const reg_expression& e) - : regbase(e), data(e.allocator()), pkmp(0), error_code_(REG_EMPTY), _expression(0) -{ - // - // we do a deep copy only if e is a valid expression, otherwise fail. - // - if(e.error_code() == 0) - { - const charT* pe = e.expression(); - set_expression(pe, pe + e._expression_len, e.flags() | regex_constants::use_except); - } - else - { - _flags = e.flags() & ~(regex_constants::use_except); - fail(e.error_code()); - } -} - -template -reg_expression::~reg_expression() -{ - if(pkmp) - re_detail::kmp_free(pkmp, data.allocator()); -} - -template -reg_expression& BOOST_REGEX_CALL reg_expression::operator=(const reg_expression& e) -{ - // - // we do a deep copy only if e is a valid expression, otherwise fail. - // - if(this == &e) return *this; - _flags = use_except; - fail(e.error_code()); - if(error_code() == 0) - set_expression(e._expression, e._expression + e._expression_len, e.flags() | regex_constants::use_except); - return *this; -} - -template -int BOOST_REGEX_CALL reg_expression::compare(const reg_expression& e)const -{ - if(_flags != e.flags()) - return _flags - e.flags(); - return str().compare(e.str()); -} - -template -void BOOST_REGEX_CALL reg_expression::swap(reg_expression& that)throw() -{ - traits_inst.swap(that.traits_inst); - data.swap(that.data); - static_cast(*this).swap(that); - - std::swap(_restart_type, that._restart_type); - std::swap(marks, that.marks); - std::swap(repeats, that.repeats); - std::swap(startmap, that.startmap); - std::swap(_expression_len, that._expression_len); - std::swap(_leading_len, that._leading_len); - std::swap(_leading_string, that._leading_string); - std::swap(_leading_string_len, that._leading_string_len); - std::swap(pkmp, that.pkmp); - std::swap(error_code_, that.error_code_); - std::swap(_expression, that._expression); -} - -template -Allocator BOOST_REGEX_CALL reg_expression::allocator()const -{ - return data.allocator(); -} - -template -Allocator BOOST_REGEX_CALL reg_expression::get_allocator()const -{ - return data.allocator(); -} - -template -unsigned int BOOST_REGEX_CALL reg_expression::parse_inner_set(const charT*& arg_first, const charT* arg_last) -{ - // - // we have an inner [...] construct - // - jm_assert(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*arg_first) == traits_type::syntax_open_set); - const charT* base = arg_first; - while( (arg_first != arg_last) - && (traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*arg_first) != traits_type::syntax_close_set) ) - ++arg_first; - if(arg_first == arg_last) - return 0; - ++arg_first; - if((arg_first-base) < 5) - return 0; - if(*(base+1) != *(arg_first-2)) - return 0; - unsigned int result = traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*(base+1)); - if((result == traits_type::syntax_colon) && ((arg_first-base) == 5)) - { - unsigned type = traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*(base+2)); - if((type == traits_type::syntax_left_word) || (type == traits_type::syntax_right_word)) - return type; - } - return ((result == traits_type::syntax_colon) || (result == traits_type::syntax_dot) || (result == traits_type::syntax_equal)) ? result : 0; -} - - -template -bool BOOST_REGEX_CALL reg_expression::skip_space(const charT*& arg_first, const charT* arg_last) -{ - // - // returns true if we get to arg_last: - // - while((arg_first != arg_last) && (traits_inst.is_class(*arg_first, traits_type::char_class_space) == true)) - { - ++arg_first; - } - return arg_first == arg_last; -} - -template -void BOOST_REGEX_CALL reg_expression::parse_range(const charT*& ptr, const charT* arg_end, unsigned& min, unsigned& max) -{ - // - // we have {x} or {x,} or {x,y} NB no spaces inside braces - // anything else is illegal - // On input ptr points to "{" - // - ++ptr; - if(skip_space(ptr, arg_end)) - { - fail(REG_EBRACE); - return; - } - if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*ptr) != traits_type::syntax_digit) - { - fail(REG_BADBR); - return; - } - min = traits_inst.toi(ptr, arg_end, 10); - if(skip_space(ptr, arg_end)) - { - fail(REG_EBRACE); - return; - } - if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*ptr) == traits_type::syntax_comma) - { - //we have a second interval: - ++ptr; - if(skip_space(ptr, arg_end)) - { - fail(REG_EBRACE); - return; - } - if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*ptr) == traits_type::syntax_digit) - max = traits_inst.toi(ptr, arg_end, 10); - else - max = (unsigned)-1; - } - else - max = min; - - // validate input: - if(skip_space(ptr, arg_end)) - { - fail(REG_EBRACE); - return; - } - if(max < min) - { - fail(REG_ERANGE); - return; - } - if(_flags & bk_braces) - { - if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*ptr) != traits_type::syntax_slash) - { - fail(REG_BADBR); - return; - } - else - { - // back\ is OK now check the } - ++ptr; - if((ptr == arg_end) || (traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*ptr) != traits_type::syntax_close_brace)) - { - fail(REG_BADBR); - return; - } - } - } - else if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*ptr) != traits_type::syntax_close_brace) - { - fail(REG_BADBR); - return; - } -} - -template -charT BOOST_REGEX_CALL reg_expression::parse_escape(const charT*& arg_first, const charT* arg_last) -{ - charT c(*arg_first); - traits_size_type c_unsigned = (traits_size_type)(traits_uchar_type)*arg_first; - // this is only used for the switch(), but cannot be folded in - // due to a bug in Comeau 4.2.44beta3 - traits_size_type syntax = traits_inst.syntax_type(c_unsigned); - switch(syntax) - { - case traits_type::syntax_a: - c = '\a'; - ++arg_first; - break; - case traits_type::syntax_f: - c = '\f'; - ++arg_first; - break; - case traits_type::syntax_n: - c = '\n'; - ++arg_first; - break; - case traits_type::syntax_r: - c = '\r'; - ++arg_first; - break; - case traits_type::syntax_t: - c = '\t'; - ++arg_first; - break; - case traits_type::syntax_v: - c = '\v'; - ++arg_first; - break; - case traits_type::syntax_x: - ++arg_first; - if(arg_first == arg_last) - { - fail(REG_EESCAPE); - break; - } - // maybe have \x{ddd} - if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*arg_first)) == traits_type::syntax_open_brace) - { - ++arg_first; - if(arg_first == arg_last) - { - fail(REG_EESCAPE); - break; - } - if(traits_inst.is_class(*arg_first, traits_type::char_class_xdigit) == false) - { - fail(REG_BADBR); - break; - } - c = (charT)traits_inst.toi(arg_first, arg_last, -16); - if((arg_first == arg_last) || (traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*arg_first)) != traits_type::syntax_close_brace)) - { - fail(REG_BADBR); - } - ++arg_first; - break; - } - else - { - if(traits_inst.is_class(*arg_first, traits_type::char_class_xdigit) == false) - { - fail(REG_BADBR); - break; - } - c = (charT)traits_inst.toi(arg_first, arg_last, -16); - } - break; - case traits_type::syntax_c: - ++arg_first; - if(arg_first == arg_last) - { - fail(REG_EESCAPE); - break; - } - if(((traits_uchar_type)(*arg_first) < (traits_uchar_type)'@') - || ((traits_uchar_type)(*arg_first) > (traits_uchar_type)127) ) - { - fail(REG_EESCAPE); - return (charT)0; - } - c = (charT)((traits_uchar_type)(*arg_first) - (traits_uchar_type)'@'); - ++arg_first; - break; - case traits_type::syntax_e: - c = (charT)27; - ++arg_first; - break; - case traits_type::syntax_digit: - c = (charT)traits_inst.toi(arg_first, arg_last, -8); - break; - default: - //c = *arg_first; - ++arg_first; - } - return c; -} - -template -void BOOST_REGEX_CALL reg_expression::compile_maps() -{ - re_detail::re_syntax_base* record = static_cast(data.data()); - // always compile the first _map: - std::memset(startmap, 0, 256); - record->can_be_null = 0; - compile_map(record, startmap, 0, re_detail::mask_all); - - while(record->type != re_detail::syntax_element_match) - { - if((record->type == re_detail::syntax_element_alt) || (record->type == re_detail::syntax_element_rep)) - { - std::memset(&(static_cast(record)->_map), 0, 256); - record->can_be_null = 0; - compile_map(record->next.p, static_cast(record)->_map, &(record->can_be_null), re_detail::mask_take, static_cast(record)->alt.p); - compile_map(static_cast(record)->alt.p, static_cast(record)->_map, &(record->can_be_null), re_detail::mask_skip); - if(record->type == re_detail::syntax_element_rep) - { - re_detail::re_repeat* rep = static_cast(record); - // set whether this is a singleton repeat or not: - if(rep->next.p->next.p->next.p == rep->alt.p) - { - switch(rep->next.p->type) - { - case re_detail::syntax_element_wild: - rep->type = re_detail::syntax_element_dot_rep; - break; - case re_detail::syntax_element_literal: - rep->type = re_detail::syntax_element_char_rep; - break; - case re_detail::syntax_element_set: - rep->type = re_detail::syntax_element_short_set_rep; - break; - case re_detail::syntax_element_long_set: - if(static_cast(rep->next.p)->singleton) - rep->type = re_detail::syntax_element_long_set_rep; - break; - default: - break; - } - } - } - } - else - { - record->can_be_null = 0; - compile_map(record, 0, &(record->can_be_null), re_detail::mask_all); - } - record = record->next.p; - } - record->can_be_null = re_detail::mask_all; -} - -template -bool BOOST_REGEX_CALL reg_expression::probe_start( - re_detail::re_syntax_base* node, charT cc, re_detail::re_syntax_base* terminal) const -{ - unsigned int c; - - switch(node->type) - { - case re_detail::syntax_element_startmark: - if(static_cast(node)->index == -1) - { - return probe_start(node->next.p->next.p, cc, terminal) - && probe_start(static_cast(node->next.p)->alt.p, cc, terminal); - } - else if(static_cast(node)->index == -3) - { - return probe_start(node->next.p->next.p, cc, terminal); - } - // doesn't tell us anything about the next character, so: - return probe_start(node->next.p, cc, terminal); - case re_detail::syntax_element_endmark: - if(static_cast(node)->index == -3) - { - return true; - } - // fall through: - case re_detail::syntax_element_start_line: - case re_detail::syntax_element_word_boundary: - case re_detail::syntax_element_buffer_start: - case re_detail::syntax_element_restart_continue: - // doesn't tell us anything about the next character, so: - return probe_start(node->next.p, cc, terminal); - case re_detail::syntax_element_literal: - // only the first character of the literal can match: - // note these have already been translated: - if(*reinterpret_cast(static_cast(node)+1) == traits_inst.translate(cc, (_flags & regex_constants::icase))) - return true; - return false; - case re_detail::syntax_element_end_line: - // next character (if there is one!) must be a newline: - if(traits_inst.is_separator(traits_inst.translate(cc, (_flags & regex_constants::icase)))) - return true; - return false; - case re_detail::syntax_element_wild: - return true; - case re_detail::syntax_element_match: - return true; - case re_detail::syntax_element_within_word: - case re_detail::syntax_element_word_start: - return traits_inst.is_class(traits_inst.translate(cc, (_flags & regex_constants::icase)), traits_type::char_class_word); - case re_detail::syntax_element_word_end: - // what follows must not be a word character, - return traits_inst.is_class(traits_inst.translate(cc, (_flags & regex_constants::icase)), traits_type::char_class_word) ? false : true; - case re_detail::syntax_element_buffer_end: - // we can be null, nothing must follow, - // NB we assume that this is followed by - // re_detail::syntax_element_match, if its not then we can - // never match anything anyway!! - return false; - case re_detail::syntax_element_soft_buffer_end: - // we can be null, only newlines must follow, - // NB we assume that this is followed by - // re_detail::syntax_element_match, if its not then we can - // never match anything anyway!! - return traits_inst.is_separator(traits_inst.translate(cc, (_flags & regex_constants::icase))); - case re_detail::syntax_element_backref: - // there's no easy way to determine this - // which is not to say it can't be done! - // for now: - return true; - case re_detail::syntax_element_long_set: - // we can not be null, - // we need to add already translated values in the set - // to values in the _map - return re_detail::re_maybe_set_member(cc, static_cast(node), *this) || (re_detail::re_is_set_member(static_cast(&cc), static_cast(&cc+1), static_cast(node), *this) != &cc); - case re_detail::syntax_element_set: - // set all the elements that are set in corresponding set: - c = (traits_size_type)(traits_uchar_type)traits_inst.translate(cc, (_flags & regex_constants::icase)); - return static_cast(node)->_map[c] != 0; - case re_detail::syntax_element_jump: - if(static_cast(node)->alt.p < node) - { - // backwards jump, - // caused only by end of repeat section, we'll treat this - // the same as a match, because the sub-expression has matched. - if(node->next.p == terminal) - return true; // null repeat - we can always take this - else - { - // - // take the jump, add in fix for the fact that if the - // repeat that we're jumping to has non-zero minimum count - // then we need to add in the possiblity that we could still - // skip that repeat. - re_detail::re_syntax_base* next = static_cast(node)->alt.p; - bool b = probe_start(next, cc, terminal); - if((next->type == re_detail::syntax_element_rep) && (static_cast(next)->min != 0)) - { - b = b || probe_start(static_cast(next)->alt.p, cc, terminal); - } - return b; - } - } - else - // take the jump and compile: - return probe_start(static_cast(node)->alt.p, cc, terminal); - case re_detail::syntax_element_alt: - // we need to take the OR of the two alternatives: - return probe_start(static_cast(node)->alt.p, cc, terminal) || probe_start(node->next.p, cc, terminal); - case re_detail::syntax_element_rep: - case re_detail::syntax_element_char_rep: - case re_detail::syntax_element_dot_rep: - case re_detail::syntax_element_long_set_rep: - case re_detail::syntax_element_short_set_rep: - // we need to take the OR of the two alternatives - if(static_cast(node)->min == 0) - return probe_start(node->next.p, cc, static_cast(node)->alt.p) || probe_start(static_cast(node)->alt.p, cc, terminal); - else - return probe_start(node->next.p, cc, static_cast(node)->alt.p); - case re_detail::syntax_element_combining: - return !traits_inst.is_combining(traits_inst.translate(cc, (_flags & regex_constants::icase))); - } - return false; -} - -template -bool BOOST_REGEX_CALL reg_expression::probe_start_null(re_detail::re_syntax_base* node, re_detail::re_syntax_base* terminal)const -{ - switch(node->type) - { - case re_detail::syntax_element_endmark: - if(static_cast(node)->index == -3) - { - return true; - } - // fall through: - case re_detail::syntax_element_startmark: - case re_detail::syntax_element_start_line: - case re_detail::syntax_element_word_boundary: - case re_detail::syntax_element_buffer_start: - case re_detail::syntax_element_restart_continue: - case re_detail::syntax_element_end_line: - case re_detail::syntax_element_word_end: - // doesn't tell us anything about the next character, so: - return probe_start_null(node->next.p, terminal); - case re_detail::syntax_element_match: - case re_detail::syntax_element_buffer_end: - case re_detail::syntax_element_soft_buffer_end: - case re_detail::syntax_element_backref: - return true; - case re_detail::syntax_element_jump: - if(static_cast(node)->alt.p < node) - { - // backwards jump, - // caused only by end of repeat section, we'll treat this - // the same as a match, because the sub-expression has matched. - // this is only caused by NULL repeats as in "(a*)*" or "(\<)*" - // these are really nonsensence and make the matching code much - // harder, it would be nice to get rid of them altogether. - if(node->next.p == terminal) - return true; - else - return probe_start_null(static_cast(node)->alt.p, terminal); - } - else - // take the jump and compile: - return probe_start_null(static_cast(node)->alt.p, terminal); - case re_detail::syntax_element_alt: - // we need to take the OR of the two alternatives: - return probe_start_null(static_cast(node)->alt.p, terminal) || probe_start_null(node->next.p, terminal); - case re_detail::syntax_element_rep: - // only need to consider skipping the repeat: - return probe_start_null(static_cast(node)->alt.p, terminal); - default: - break; - } - return false; -} - -template -void BOOST_REGEX_CALL reg_expression::compile_map( - re_detail::re_syntax_base* node, unsigned char* _map, - unsigned int* pnull, unsigned char mask, re_detail::re_syntax_base* terminal)const -{ - if(_map) - { - for(unsigned int i = 0; i < 256; ++i) - { - if(probe_start(node, (charT)i, terminal)) - _map[i] |= mask; - } - } - if(pnull && probe_start_null(node, terminal)) - *pnull |= mask; -} - -template -void BOOST_REGEX_CALL reg_expression::move_offsets(re_detail::re_syntax_base* j, unsigned arg_size) -{ -# ifdef BOOST_MSVC -# pragma warning(push) -# pragma warning(disable: 4127) -#endif - // move all offsets starting with j->link forward by arg_size - // called after an insert: - j = reinterpret_cast(reinterpret_cast(data.data()) + j->next.i); - while(true) - { - switch(j->type) - { - case re_detail::syntax_element_rep: - static_cast(j)->alt.i += arg_size; - j->next.i += arg_size; - break; - case re_detail::syntax_element_jump: - case re_detail::syntax_element_alt: - static_cast(j)->alt.i += arg_size; - j->next.i += arg_size; - break; - default: - j->next.i += arg_size; - break; - } - if(j->next.i == arg_size) - break; - j = reinterpret_cast(reinterpret_cast(data.data()) + j->next.i); - } -# ifdef BOOST_MSVC -# pragma warning(pop) -#endif -} - -template -re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression::compile_set_simple(re_detail::re_syntax_base* dat, unsigned long cls, bool isnot) -{ - typedef typename re_detail::is_byte::width_type width_type; - re_detail::jstack singles(64, data.allocator()); - re_detail::jstack ranges(64, data.allocator()); - re_detail::jstack classes(64, data.allocator()); - re_detail::jstack equivalents(64, data.allocator()); - if(_flags & regbase::icase) - { - if((cls == traits_type::char_class_upper) || (cls == traits_type::char_class_lower)) - { - cls = traits_type::char_class_alpha; - } - } - classes.push(cls); - if(dat) - { - data.align(); - dat->next.i = data.size(); - } - return compile_set_aux(singles, ranges, classes, equivalents, isnot, width_type()); -} - -template -re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression::compile_set(const charT*& arg_first, const charT* arg_last) -{ - re_detail::jstack singles(64, data.allocator()); - re_detail::jstack ranges(64, data.allocator()); - re_detail::jstack classes(64, data.allocator()); - re_detail::jstack equivalents(64, data.allocator()); - bool has_digraphs = false; - jm_assert(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*arg_first) == traits_type::syntax_open_set); - ++arg_first; - bool started = false; - bool done = false; - bool isnot = false; - - enum last_type - { - last_single, - last_none, - last_dash - }; - - unsigned l = last_none; - traits_string_type s; - - while((arg_first != arg_last) && !done) - { - traits_size_type c = (traits_size_type)(traits_uchar_type)*arg_first; - // this is only used for the switch(), but cannot be folded in - // due to a bug in Comeau 4.2.44beta3 - traits_size_type syntax = traits_inst.syntax_type(c); - switch(syntax) - { - case traits_type::syntax_caret: - if(!started && !isnot) - { - isnot = true; - } - else - { - s = (charT)c; - goto char_set_literal; - } - break; - case traits_type::syntax_open_set: - { - if((_flags & char_classes) == 0) - { - s = (charT)c; - goto char_set_literal; - } - // check to see if we really have a class: - const charT* base = arg_first; - // this is only used for the switch(), but cannot be folded in - // due to a bug in Comeau 4.2.44beta3 - unsigned int inner_set = parse_inner_set(arg_first, arg_last); - switch(inner_set) - { - case traits_type::syntax_colon: - { - if(l == last_dash) - { - fail(REG_ERANGE); - return 0; - } - boost::uint_fast32_t id = traits_inst.lookup_classname(base+2, arg_first-2); - if(_flags & regex_constants::icase) - { - if((id == traits_type::char_class_upper) || (id == traits_type::char_class_lower)) - { - id = traits_type::char_class_alpha; - } - } - if(id == 0) - { - fail(REG_ECTYPE); - return 0; - } - classes.push(id); - started = true; - l = last_none; - } - break; - case traits_type::syntax_dot: - // - // we have a collating element [.collating-name.] - // - if(traits_inst.lookup_collatename(s, base+2, arg_first-2)) - { - --arg_first; - if(s.size() > 1) - has_digraphs = true; - if(s.size())goto char_set_literal; - } - fail(REG_ECOLLATE); - return 0; - case traits_type::syntax_equal: - // - // we have an equivalence class [=collating-name=] - // - if(traits_inst.lookup_collatename(s, base+2, arg_first-2)) - { - std::size_t len = s.size(); - if(len) - { - unsigned i = 0; - while(i < len) - { - s[i] = traits_inst.translate(s[i], (_flags & regex_constants::icase)); - ++i; - } - traits_string_type s2; - traits_inst.transform_primary(s2, s); - equivalents.push(s2); - started = true; - l = last_none; - break; - } - } - fail(REG_ECOLLATE); - return 0; - case traits_type::syntax_left_word: - if((started == false) && (traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*arg_first) == traits_type::syntax_close_set)) - { - ++arg_first; - return add_simple(0, re_detail::syntax_element_word_start); - } - fail(REG_EBRACK); - return 0; - case traits_type::syntax_right_word: - if((started == false) && (traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*arg_first) == traits_type::syntax_close_set)) - { - ++arg_first; - return add_simple(0, re_detail::syntax_element_word_end); - } - fail(REG_EBRACK); - return 0; - default: - if(started == false) - { - unsigned int t = traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*(base+1)); - if((t != traits_type::syntax_colon) && (t != traits_type::syntax_dot) && (t != traits_type::syntax_equal)) - { - arg_first = base; - s = (charT)c; - goto char_set_literal; - } - } - fail(REG_EBRACK); - return 0; - } - if(arg_first == arg_last) - { - fail(REG_EBRACK); - return 0; - } - continue; - } - case traits_type::syntax_close_set: - if(started == false) - { - s = (charT)c; - goto char_set_literal; - } - done = true; - break; - case traits_type::syntax_dash: - if(!started) - { - s = (charT)c; - goto char_set_literal; - } - ++arg_first; - if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*arg_first) == traits_type::syntax_close_set) - { - --arg_first; - s = (charT)c; - goto char_set_literal; - } - if((singles.empty() == true) || (l != last_single)) - { - fail(REG_ERANGE); - return 0; - } - ranges.push(singles.peek()); - if(singles.peek().size() <= 1) // leave digraphs and ligatures in place - singles.pop(); - l = last_dash; - continue; - case traits_type::syntax_slash: - if(_flags & regex_constants::escape_in_lists) - { - ++arg_first; - if(arg_first == arg_last) - continue; - /*traits_size_type*/ c = (traits_size_type)(traits_uchar_type)*arg_first; - // this is only used for the switch(), but cannot be folded in - // due to a bug in Comeau 4.2.44beta3 - traits_size_type syntax4 = traits_inst.syntax_type(c); - switch(syntax4) - { - case traits_type::syntax_w: - if(l == last_dash) - { - fail(REG_ERANGE); - return 0; - } - classes.push(traits_type::char_class_word); - started = true; - l = last_none; - ++arg_first; - continue; - case traits_type::syntax_d: - if(l == last_dash) - { - fail(REG_ERANGE); - return 0; - } - classes.push(traits_type::char_class_digit); - started = true; - l = last_none; - ++arg_first; - continue; - case traits_type::syntax_s: - if(l == last_dash) - { - fail(REG_ERANGE); - return 0; - } - classes.push(traits_type::char_class_space); - started = true; - l = last_none; - ++arg_first; - continue; - case traits_type::syntax_l: - if(l == last_dash) - { - fail(REG_ERANGE); - return 0; - } - classes.push(traits_type::char_class_lower); - started = true; - l = last_none; - ++arg_first; - continue; - case traits_type::syntax_u: - if(l == last_dash) - { - fail(REG_ERANGE); - return 0; - } - classes.push(traits_type::char_class_upper); - started = true; - l = last_none; - ++arg_first; - continue; - case traits_type::syntax_W: - case traits_type::syntax_D: - case traits_type::syntax_S: - case traits_type::syntax_U: - case traits_type::syntax_L: - fail(REG_EESCAPE); - return 0; - default: - c = parse_escape(arg_first, arg_last); - --arg_first; - s = (charT)c; - goto char_set_literal; - } - } - else - { - s = (charT)c; - goto char_set_literal; - } - default: - s = (charT)c; - char_set_literal: - unsigned i = 0; - // get string length to stop us going past the end of string (DWA) - std::size_t len = s.size(); - while(i < len) - { - s[i] = traits_inst.translate(s[i], (_flags & regex_constants::icase)); - ++i; - } - started = true; - if(l == last_dash) - { - ranges.push(s); - l = last_none; - if(s.size() > 1) // add ligatures to singles list as well - singles.push(s); - } - else - { - singles.push(s); - l = last_single; - } - } - ++arg_first; - } - if(!done) - return 0; - - typedef typename re_detail::is_byte::width_type width_type; - - re_detail::re_syntax_base* result; - if(has_digraphs) - result = compile_set_aux(singles, ranges, classes, equivalents, isnot, re_detail::_wide_type()); - else - result = compile_set_aux(singles, ranges, classes, equivalents, isnot, width_type()); - #ifdef __BORLANDC__ - // delayed throw: - if((result == 0) && (_flags & regex_constants::use_except)) - fail(error_code()); - #endif - return result; -} - -template -re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression::compile_set_aux(re_detail::jstack& singles, re_detail::jstack& ranges, re_detail::jstack& classes, re_detail::jstack& equivalents, bool isnot, const re_detail::_wide_type&) -{ - size_type base = data.size(); - data.extend(sizeof(re_detail::re_set_long)); - unsigned int csingles = 0; - unsigned int cranges = 0; - boost::uint_fast32_t cclasses = 0; - unsigned int cequivalents = 0; - bool nocollate_state = !(flags() & regex_constants::collate); - bool singleton = true; - - while(singles.empty() == false) - { - ++csingles; - const traits_string_type& s = singles.peek(); - std::size_t len = (s.size() + 1) * sizeof(charT); - if(len > sizeof(charT) * 2) - singleton = false; - std::memcpy(reinterpret_cast(data.extend(len)), s.c_str(), len); - singles.pop(); - } - while(ranges.empty() == false) - { - traits_string_type c1, c2; - if(nocollate_state) - c1 = ranges.peek(); - else - traits_inst.transform(c1, ranges.peek()); - ranges.pop(); - if(nocollate_state) - c2 = ranges.peek(); - else - traits_inst.transform(c2, ranges.peek()); - ranges.pop(); - if(c1 < c2) - { - // for some reason bc5 crashes when throwing exceptions - // from here - probably an EH-compiler bug, but hard to - // be sure... - // delay throw to later: - #ifdef __BORLANDC__ - boost::uint_fast32_t f = _flags; - _flags &= ~regex_constants::use_except; - #endif - fail(REG_ERANGE); - #ifdef __BORLANDC__ - _flags = f; - #endif - return 0; - } - ++cranges; - std::size_t len = (re_detail::re_strlen(c1.c_str()) + 1) * sizeof(charT); - std::memcpy(data.extend(len), c1.c_str(), len); - len = (re_detail::re_strlen(c2.c_str()) + 1) * sizeof(charT); - std::memcpy(data.extend(len), c2.c_str(), len); - } - while(classes.empty() == false) - { - cclasses |= classes.peek(); - classes.pop(); - } - while(equivalents.empty() == false) - { - ++cequivalents; - const traits_string_type& s = equivalents.peek(); - std::size_t len = (re_detail::re_strlen(s.c_str()) + 1) * sizeof(charT); - std::memcpy(reinterpret_cast(data.extend(len)), s.c_str(), len); - equivalents.pop(); - } - - re_detail::re_set_long* dat = reinterpret_cast(reinterpret_cast(data.data()) + base); - dat->type = re_detail::syntax_element_long_set; - dat->csingles = csingles; - dat->cranges = cranges; - dat->cclasses = cclasses; - dat->cequivalents = cequivalents; - dat->isnot = isnot; - dat->next.i = 0; - dat->singleton = isnot ? true : singleton; - return dat; -} - -template -re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression::compile_set_aux(re_detail::jstack& singles, re_detail::jstack& ranges, re_detail::jstack& classes, re_detail::jstack& equivalents, bool isnot, const re_detail::_narrow_type&) -{ - re_detail::re_set* dat = reinterpret_cast(data.extend(sizeof(re_detail::re_set))); - std::memset(dat, 0, sizeof(re_detail::re_set)); - - while(singles.empty() == false) - { - dat->_map[(traits_size_type)(traits_uchar_type)*(singles.peek().c_str())] = re_detail::mask_all; - singles.pop(); - } - while(ranges.empty() == false) - { - traits_string_type c1, c2, c3, c4; - - if((flags() & regex_constants::collate) == 0) - c1 = ranges.peek(); - else - traits_inst.transform(c1, ranges.peek()); - ranges.pop(); - if((flags() & regex_constants::collate) == 0) - c2 = ranges.peek(); - else - traits_inst.transform(c2, ranges.peek()); - ranges.pop(); - - if(c1 < c2) - { - // for some reason bc5 crashes when throwing exceptions - // from here - probably an EH-compiler bug, but hard to - // be sure... - // delay throw to later: - #ifdef __BORLANDC__ - boost::uint_fast32_t f = _flags; - _flags &= ~regex_constants::use_except; - #endif - fail(REG_ERANGE); - #ifdef __BORLANDC__ - _flags = f; - #endif - return 0; - } - for(unsigned int i = 0; i < 256; ++i) - { - c4 = (charT)i; - if((flags() & regex_constants::collate) == 0) - c3 = c4; - else - traits_inst.transform(c3, c4); - if((c3 <= c1) && (c3 >= c2)) - dat->_map[i] = re_detail::mask_all; - } - } - while(equivalents.empty() == false) - { - traits_string_type c1, c2; - for(unsigned int i = 0; i < 256; ++i) - { - c2 = (charT)i; - traits_inst.transform_primary(c1, c2); - if(c1 == equivalents.peek()) - dat->_map[i] = re_detail::mask_all; - } - equivalents.pop(); - } - - boost::uint_fast32_t l_flags = 0; - while(classes.empty() == false) - { - l_flags |= classes.peek(); - classes.pop(); - } - if(l_flags) - { - for(unsigned int i = 0; i < 256; ++i) - { - if(traits_inst.is_class(charT(i), l_flags)) - dat->_map[(traits_uchar_type)traits_inst.translate((charT)i, (_flags & regex_constants::icase))] = re_detail::mask_all; - } - } - - if(isnot) - { - for(unsigned int i = 0; i < 256; ++i) - { - dat->_map[i] = !dat->_map[i]; - } - } - - dat->type = re_detail::syntax_element_set; - dat->next.i = 0; - return dat; -} - -#ifndef __CODEGUARD__ -// this must not be inline when Borland's codeguard support is turned -// on, otherwise we _will_ get surious codeguard errors... -inline -#endif - re_detail::re_syntax_base* add_offset(void* base, std::ptrdiff_t off) -{ - return reinterpret_cast(reinterpret_cast(base) + off); -} - -template -void BOOST_REGEX_CALL reg_expression::fixup_apply(re_detail::re_syntax_base* b, unsigned cbraces) -{ - typedef typename boost::detail::rebind_allocator::type b_alloc; - - register unsigned char* base = reinterpret_cast(b); - register re_detail::re_syntax_base* ptr = b; - bool* pb = 0; - b_alloc a(data.allocator()); -#ifndef BOOST_NO_EXCEPTIONS - try - { -#endif - pb = a.allocate(cbraces); - BOOST_REGEX_NOEH_ASSERT(pb) - for(unsigned i = 0; i < cbraces; ++i) - pb[i] = false; - - repeats = 0; - - while(ptr->next.i) - { - switch(ptr->type) - { - case re_detail::syntax_element_rep: - jm_assert(data.size() > static_cast(ptr)->alt.i); - static_cast(ptr)->alt.p = add_offset(base, static_cast(ptr)->alt.i); -#ifdef BOOST_REGEX_DEBUG - if((re_detail::padding_mask & reinterpret_cast(static_cast(ptr)->alt.p)) && (static_cast(ptr)->alt.p != b)) - { - jm_trace("padding mis-aligment in repeat jump to object type: " << static_cast(ptr)->alt.p->type) - //jm_assert(0 == (padding_mask & (int)((re_detail::re_jump*)ptr)->alt.p)); - } -#endif - static_cast(ptr)->id = repeats; - ++repeats; - goto rebase; - case re_detail::syntax_element_jump: - case re_detail::syntax_element_alt: - jm_assert(data.size() > static_cast(ptr)->alt.i); - static_cast(ptr)->alt.p = add_offset(base, static_cast(ptr)->alt.i); -#ifdef BOOST_REGEX_DEBUG - if((re_detail::padding_mask & reinterpret_cast(static_cast(ptr)->alt.p) && (static_cast(ptr)->alt.p != b))) - { - jm_trace("padding mis-aligment in alternation jump to object type: " << static_cast(ptr)->alt.p->type) - //jm_assert(0 == (padding_mask & (int)((re_detail::re_jump*)ptr)->alt.p)); - } -#endif - goto rebase; - case re_detail::syntax_element_backref: - if((static_cast(ptr)->index >= (int)cbraces) || (pb[static_cast(ptr)->index] == false) ) - { - fail(REG_ESUBREG); - a.deallocate(pb, cbraces); - return; - } - goto rebase; - case re_detail::syntax_element_endmark: - if(static_cast(ptr)->index > 0) - pb[static_cast(ptr)->index] = true; - goto rebase; - default: - rebase: - jm_assert(data.size() > ptr->next.i); - ptr->next.p = add_offset(base, ptr->next.i); -#ifdef BOOST_REGEX_DEBUG - if((re_detail::padding_mask & (int)(ptr->next.p)) && (static_cast(ptr)->alt.p != b)) - { - jm_trace("padding mis-alignment in next record of type " << ptr->next.p->type) - jm_assert(0 == (re_detail::padding_mask & (int)(ptr->next.p))); - } -#endif - ptr = ptr->next.p; - } - } - a.deallocate(pb, cbraces); - pb = 0; -#ifndef BOOST_NO_EXCEPTIONS - } - catch(...) - { - if(pb) - a.deallocate(pb, cbraces); - throw; - } -#endif -} - - -template -unsigned int BOOST_REGEX_CALL reg_expression::set_expression(const charT* arg_first, const charT* arg_last, flag_type f) -{ -# ifdef BOOST_MSVC -# pragma warning(push) -# pragma warning(disable: 4127) -#endif -#ifdef __OpenBSD__ - // strxfrm not working on OpenBSD?? - f &= ~regex_constants::collate; -#endif - - if(arg_first == expression()) - { - traits_string_type s(arg_first, arg_last); - return set_expression(s.c_str(), s.c_str() + s.size(), f); - } - typedef typename traits_type::sentry sentry_t; - sentry_t sent(traits_inst); - if(sent){ - - const charT* base = arg_first; - data.clear(); - _flags = f; - fail(REG_NOERROR); // clear any error - _leading_len = 0; // set this to non-zero if there are any backrefs, we'll refer to it later... - - if(arg_first >= arg_last) - { - fail(REG_EMPTY); - return error_code(); - } - - const charT* ptr = arg_first; - marks = 0; - re_detail::jstack mark(64, data.allocator()); - re_detail::jstack markid(64, data.allocator()); - std::size_t last_mark_popped = 0; - register traits_size_type c; - register re_detail::re_syntax_base* dat; - - unsigned rep_min = 0; - unsigned rep_max = 0; - - // - // set up header: - // - ++marks; - dat = 0; - - if(_flags & regex_constants::literal) - { - while(ptr != arg_last) - { - dat = add_literal(dat, traits_inst.translate(*ptr, (_flags & regex_constants::icase))); - ++ptr; - } - } - - while (ptr < arg_last) - { - c = (traits_size_type)(traits_uchar_type)*ptr; - // this is only used for the switch(), but cannot be folded in - // due to a bug in Comeau 4.2.44beta3 - traits_size_type syntax = traits_inst.syntax_type(c); - switch(syntax) - { - case traits_type::syntax_open_bracket: - if(_flags & bk_parens) - { - dat = add_literal(dat, (charT)c); - ++ptr; - continue; - } - open_bracked_jump: - // extend: - dat = add_simple(dat, re_detail::syntax_element_startmark, sizeof(re_detail::re_brace)); - if(_flags & nosubs) - { - markid.push(0); - static_cast(dat)->index = 0; - } - else - { - markid.push(marks); - static_cast(dat)->index = marks++; - } - mark.push(data.index(dat)); - ++ptr; - // - // check for perl like (?...) extention syntax - c = (traits_size_type)(traits_uchar_type)*ptr; - if(((_flags & (bk_parens|perlex)) == perlex) && (traits_type::syntax_question == traits_inst.syntax_type(c))) - { - ++ptr; - c = (traits_size_type)(traits_uchar_type)*ptr; - // this is only used for the switch(), but cannot be folded in - // due to a bug in Comeau 4.2.44beta3 - traits_size_type syntax2 = traits_inst.syntax_type(c); - switch(syntax2) - { - case traits_type::syntax_colon: - static_cast(dat)->index = 0; - if((_flags & nosubs) == 0) - --marks; - markid.pop(); - markid.push(0); - ++ptr; - continue; - case traits_type::syntax_equal: - static_cast(dat)->index = -1; - markid.pop(); - markid.push(-1); - common_forward_assert: - if((_flags & nosubs) == 0) - --marks; - ++ptr; - // extend: - dat = add_simple(dat, re_detail::syntax_element_jump, re_detail::re_jump_size); - data.align(); - // - // we don't know what value to put here yet, - // use an arbitrarily large value for now - // and check it later: - static_cast(dat)->alt.i = INT_MAX/2; - mark.push(data.size() - re_detail::re_jump_size); - continue; - case traits_type::syntax_right_word: - static_cast(dat)->index = -3; - markid.pop(); - markid.push(-3); - goto common_forward_assert; - case traits_type::syntax_not: - static_cast(dat)->index = -2; - markid.pop(); - markid.push(-2); - goto common_forward_assert; - case traits_type::syntax_hash: - // comment just skip it: - static_cast(dat)->index = 0; - if((_flags & nosubs) == 0) - --marks; - markid.pop(); - mark.pop(); - do{ - ++ptr; - c = (traits_size_type)(traits_uchar_type)*ptr; - }while(traits_type::syntax_close_bracket != traits_inst.syntax_type(c)); - ++ptr; - continue; - default: - // - // error, return to standard parsing and let that handle the error: - --ptr; - continue; - } - } - break; - case traits_type::syntax_close_bracket: - if(_flags & bk_parens) - { - dat = add_literal(dat, (charT)c); - ++ptr; - continue; - } - - close_bracked_jump: - if(dat) - { - data.align(); - dat->next.i = data.size(); - } - - if(mark.empty()) - { - fail(REG_EPAREN); - return error_code(); - } - // see if we have an empty alternative: - if(mark.peek() == data.index(dat) ) - { - re_detail::re_syntax_base* para = reinterpret_cast(reinterpret_cast(data.data()) + mark.peek()); - if(para->type == re_detail::syntax_element_jump) - { - fail(REG_EMPTY); - return error_code(); - } - } - - // pop any pushed alternatives and set the target arg_last destination: - dat = reinterpret_cast(reinterpret_cast(data.data()) + mark.peek()); - while(dat->type == re_detail::syntax_element_jump) - { - static_cast(dat)->alt.i = data.size(); - mark.pop(); - if(mark.empty()) - { - fail(REG_EPAREN); - return error_code(); - } - dat = reinterpret_cast(reinterpret_cast(data.data()) + mark.peek()); - } - - dat = add_simple(0, re_detail::syntax_element_endmark, sizeof(re_detail::re_brace)); - static_cast(dat)->index = markid.peek(); - markid.pop(); - last_mark_popped = mark.peek(); - mark.pop(); - ++ptr; - break; - case traits_type::syntax_char: - dat = add_literal(dat, (charT)c); - ++ptr; - break; - case traits_type::syntax_slash: - { - if(++ptr == arg_last) - { - fail(REG_EESCAPE); - return error_code(); - } - c = (traits_size_type)(traits_uchar_type)*ptr; - // this is only used for the switch(), but cannot be folded in - // due to a bug in Comeau 4.2.44beta3 - traits_size_type syntax3 = traits_inst.syntax_type(c); - switch(syntax3) - { - case traits_type::syntax_open_bracket: - if(_flags & bk_parens) - goto open_bracked_jump; - break; - case traits_type::syntax_close_bracket: - if(_flags & bk_parens) - goto close_bracked_jump; - break; - case traits_type::syntax_plus: - if((_flags & bk_plus_qm) && ((_flags & limited_ops) == 0)) - { - rep_min = 1; - rep_max = (unsigned)-1; - goto repeat_jump; - } - break; - case traits_type::syntax_question: - if((_flags & bk_plus_qm) && ((_flags & limited_ops) == 0)) - { - rep_min = 0; - rep_max = 1; - goto repeat_jump; - } - break; - case traits_type::syntax_or: - if(((_flags & bk_vbar) == 0) || (_flags & limited_ops)) - break; - goto alt_string_jump; - case traits_type::syntax_open_brace: - if( ((_flags & bk_braces) == 0) || ((_flags & intervals) == 0)) - break; - - // we have {x} or {x,} or {x,y}: - parse_range(ptr, arg_last, rep_min, rep_max); - goto repeat_jump; - - case traits_type::syntax_digit: - if(_flags & bk_refs) - { - // update previous: - int i = traits_inst.toi((charT)c); - if(i == 0) - { - // we can have \025 which means take char whose - // code is 25 (octal), so parse string: - c = traits_inst.toi(ptr, arg_last, -8); - --ptr; - break; - } - dat = add_simple(dat, re_detail::syntax_element_backref, sizeof(re_detail::re_brace)); - static_cast(dat)->index = i; - ++ptr; - _leading_len = 1; - continue; - } - break; - case traits_type::syntax_b: // re_detail::syntax_element_word_boundary - dat = add_simple(dat, re_detail::syntax_element_word_boundary); - ++ptr; - continue; - case traits_type::syntax_B: - dat = add_simple(dat, re_detail::syntax_element_within_word); - ++ptr; - continue; - case traits_type::syntax_left_word: - dat = add_simple(dat, re_detail::syntax_element_word_start); - ++ptr; - continue; - case traits_type::syntax_right_word: - dat = add_simple(dat, re_detail::syntax_element_word_end); - ++ptr; - continue; - case traits_type::syntax_w: //re_detail::syntax_element_word_char - dat = compile_set_simple(dat, traits_type::char_class_word); - ++ptr; - continue; - case traits_type::syntax_W: - dat = compile_set_simple(dat, traits_type::char_class_word, true); - ++ptr; - continue; - case traits_type::syntax_d: //re_detail::syntax_element_word_char - dat = compile_set_simple(dat, traits_type::char_class_digit); - ++ptr; - continue; - case traits_type::syntax_D: - dat = compile_set_simple(dat, traits_type::char_class_digit, true); - ++ptr; - continue; - case traits_type::syntax_s: //re_detail::syntax_element_word_char - dat = compile_set_simple(dat, traits_type::char_class_space); - ++ptr; - continue; - case traits_type::syntax_S: - dat = compile_set_simple(dat, traits_type::char_class_space, true); - ++ptr; - continue; - case traits_type::syntax_l: //re_detail::syntax_element_word_char - dat = compile_set_simple(dat, traits_type::char_class_lower); - ++ptr; - continue; - case traits_type::syntax_L: - dat = compile_set_simple(dat, traits_type::char_class_lower, true); - ++ptr; - continue; - case traits_type::syntax_u: //re_detail::syntax_element_word_char - dat = compile_set_simple(dat, traits_type::char_class_upper); - ++ptr; - continue; - case traits_type::syntax_U: - dat = compile_set_simple(dat, traits_type::char_class_upper, true); - ++ptr; - continue; - case traits_type::syntax_Q: - ++ptr; - while(true) - { - if(ptr == arg_last) - { - fail(REG_EESCAPE); - return error_code(); - } - if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*ptr) == traits_type::syntax_slash) - { - ++ptr; - if((ptr != arg_last) && (traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*ptr) == traits_type::syntax_E)) - break; - else - { - dat = add_literal(dat, *(ptr-1)); - continue; - } - } - dat = add_literal(dat, *ptr); - ++ptr; - } - ++ptr; - continue; - case traits_type::syntax_C: - dat = add_simple(dat, re_detail::syntax_element_wild); - ++ptr; - continue; - case traits_type::syntax_X: - dat = add_simple(dat, re_detail::syntax_element_combining); - ++ptr; - continue; - case traits_type::syntax_Z: - dat = add_simple(dat, re_detail::syntax_element_soft_buffer_end); - ++ptr; - continue; - case traits_type::syntax_G: - dat = add_simple(dat, re_detail::syntax_element_restart_continue); - ++ptr; - continue; - case traits_type::syntax_start_buffer: - dat = add_simple(dat, re_detail::syntax_element_buffer_start); - ++ptr; - continue; - case traits_type::syntax_end_buffer: - dat = add_simple(dat, re_detail::syntax_element_buffer_end); - ++ptr; - continue; - default: - c = (traits_size_type)(traits_uchar_type)parse_escape(ptr, arg_last); - dat = add_literal(dat, (charT)c); - continue; - } - dat = add_literal(dat, (charT)c); - ++ptr; - break; - } - case traits_type::syntax_dollar: - dat = add_simple(dat, re_detail::syntax_element_end_line, sizeof(re_detail::re_syntax_base)); - ++ptr; - continue; - case traits_type::syntax_caret: - dat = add_simple(dat, re_detail::syntax_element_start_line, sizeof(re_detail::re_syntax_base)); - ++ptr; - continue; - case traits_type::syntax_dot: - dat = add_simple(dat, re_detail::syntax_element_wild, sizeof(re_detail::re_syntax_base)); - ++ptr; - continue; - case traits_type::syntax_star: - rep_min = 0; - rep_max = (unsigned)-1; - - repeat_jump: - { - std::ptrdiff_t offset; - if(dat == 0) - { - fail(REG_BADRPT); - return error_code(); - } - switch(dat->type) - { - case re_detail::syntax_element_endmark: - offset = last_mark_popped; - break; - case re_detail::syntax_element_literal: - if(static_cast(dat)->length > 1) - { - // update previous: - charT lit = *reinterpret_cast(reinterpret_cast(dat) + sizeof(re_detail::re_literal) + ((static_cast(dat)->length-1)*sizeof(charT))); - --static_cast(dat)->length; - dat = add_simple(dat, re_detail::syntax_element_literal, sizeof(re_detail::re_literal) + sizeof(charT)); - static_cast(dat)->length = 1; - *reinterpret_cast(static_cast(dat)+1) = lit; - } - offset = reinterpret_cast(dat) - reinterpret_cast(data.data()); - break; - case re_detail::syntax_element_backref: - case re_detail::syntax_element_long_set: - case re_detail::syntax_element_set: - case re_detail::syntax_element_wild: - case re_detail::syntax_element_combining: - // we're repeating a single item: - offset = reinterpret_cast(dat) - reinterpret_cast(data.data()); - break; - default: - fail(REG_BADRPT); - return error_code(); - } - data.align(); - dat->next.i = data.size(); - //unsigned pos = (char*)dat - (char*)data.data(); - - // add the trailing jump: - dat = add_simple(dat, re_detail::syntax_element_jump, re_detail::re_jump_size); - static_cast(dat)->alt.i = 0; - - // now insert the leading repeater: - dat = static_cast(data.insert(offset, re_detail::re_repeater_size)); - dat->next.i = (reinterpret_cast(dat) - reinterpret_cast(data.data())) + re_detail::re_repeater_size; - dat->type = re_detail::syntax_element_rep; - static_cast(dat)->alt.i = data.size(); - static_cast(dat)->min = rep_min; - static_cast(dat)->max = rep_max; - static_cast(dat)->leading = false; - static_cast(dat)->greedy = true; - move_offsets(dat, re_detail::re_repeater_size); - ++ptr; - // - // now check to see if we have a non-greedy repeat: - if((ptr != arg_last) && (_flags & (perlex | limited_ops | bk_plus_qm | bk_braces)) == perlex) - { - c = (traits_size_type)(traits_uchar_type)*ptr; - if(traits_type::syntax_question == traits_inst.syntax_type(c)) - { - // OK repeat is non-greedy: - static_cast(dat)->greedy = false; - ++ptr; - } - } - dat = reinterpret_cast(reinterpret_cast(data.data()) + data.size() - re_detail::re_jump_size); - static_cast(dat)->alt.i = offset; - continue; - } - case traits_type::syntax_plus: - if(_flags & (bk_plus_qm | limited_ops)) - { - dat = add_literal(dat, (charT)c); - ++ptr; - continue; - } - rep_min = 1; - rep_max = (unsigned)-1; - goto repeat_jump; - case traits_type::syntax_question: - if(_flags & (bk_plus_qm | limited_ops)) - { - dat = add_literal(dat, (charT)c); - ++ptr; - continue; - } - rep_min = 0; - rep_max = 1; - goto repeat_jump; - case traits_type::syntax_open_set: - // update previous: - if(dat) - { - data.align(); - dat->next.i = data.size(); - } - // extend: - dat = compile_set(ptr, arg_last); - if(dat == 0) - { - if((_flags & regex_constants::failbit) == 0) - fail(REG_EBRACK); - return error_code(); - } - break; - case traits_type::syntax_or: - { - if(_flags & (bk_vbar | limited_ops)) - { - dat = add_literal(dat, (charT)c); - ++ptr; - continue; - } - - alt_string_jump: - - // update previous: - if(dat == 0) - { - // start of pattern can't have empty "|" - fail(REG_EMPTY); - return error_code(); - } - // see if we have an empty alternative: - if(mark.empty() == false) - if(mark.peek() == data.index(dat)) - { - fail(REG_EMPTY); - return error_code(); - } - // extend: - dat = add_simple(dat, re_detail::syntax_element_jump, re_detail::re_jump_size); - data.align(); - // - // we don't know what value to put here yet, - // use an arbitrarily large value for now - // and check it later (TODO!) - static_cast(dat)->alt.i = INT_MAX/2; - - // now work out where to insert: - std::size_t offset = 0; - if(mark.empty() == false) - { - // we have a '(' or '|' to go back to: - offset = mark.peek(); - re_detail::re_syntax_base* base2 = reinterpret_cast(reinterpret_cast(data.data()) + offset); - offset = base2->next.i; - } - re_detail::re_jump* j = static_cast(data.insert(offset, re_detail::re_jump_size)); - j->type = re_detail::syntax_element_alt; - j->next.i = offset + re_detail::re_jump_size; - j->alt.i = data.size(); - move_offsets(j, re_detail::re_jump_size); - dat = reinterpret_cast(reinterpret_cast(data.data()) + data.size() - re_detail::re_jump_size); - mark.push(data.size() - re_detail::re_jump_size); - ++ptr; - break; - } - case traits_type::syntax_open_brace: - if((_flags & bk_braces) || ((_flags & intervals) == 0)) - { - dat = add_literal(dat, (charT)c); - ++ptr; - continue; - } - // we have {x} or {x,} or {x,y}: - parse_range(ptr, arg_last, rep_min, rep_max); - goto repeat_jump; - case traits_type::syntax_newline: - if(_flags & newline_alt) - goto alt_string_jump; - dat = add_literal(dat, (charT)c); - ++ptr; - continue; - case traits_type::syntax_close_brace: - if(_flags & bk_braces) - { - dat = add_literal(dat, (charT)c); - ++ptr; - continue; - } - fail(REG_BADPAT); - return error_code(); - default: - dat = add_literal(dat, (charT)c); - ++ptr; - break; - } // switch - } // while - - // - // update previous: - if(dat) - { - data.align(); - dat->next.i = data.size(); - } - - // see if we have an empty alternative: - if(mark.empty() == false) - if(mark.peek() == data.index(dat) ) - { - re_detail::re_syntax_base* para = reinterpret_cast(reinterpret_cast(data.data()) + mark.peek()); - if(para->type == re_detail::syntax_element_jump) - { - fail(REG_EMPTY); - return error_code(); - } - } - // - // set up tail: - // - if(mark.empty() == false) - { - // pop any pushed alternatives and set the target arg_last destination: - dat = reinterpret_cast(reinterpret_cast(data.data()) + mark.peek()); - while(dat->type == re_detail::syntax_element_jump) - { - static_cast(dat)->alt.i = data.size(); - mark.pop(); - if(mark.empty() == true) - break; - dat = reinterpret_cast(reinterpret_cast(data.data()) + mark.peek()); - } - } - - dat = static_cast(data.extend(sizeof(re_detail::re_syntax_base))); - dat->type = re_detail::syntax_element_match; - dat->next.i = 0; - - if(mark.empty() == false) - { - fail(REG_EPAREN); - return error_code(); - } - - // - // allocate space for start _map: - startmap = reinterpret_cast(data.extend(256 + ((arg_last - base + 1) * sizeof(charT)))); - // - // and copy the expression we just compiled: - _expression = reinterpret_cast(reinterpret_cast(startmap) + 256); - _expression_len = arg_last - base; - std::memcpy(_expression, base, _expression_len * sizeof(charT)); - *(_expression + _expression_len) = charT(0); - - // - // now we need to apply fixups to the array - // so that we can use pointers and not indexes - fixup_apply(static_cast(data.data()), marks); - - // check for error during fixup: - if(_flags & regex_constants::failbit) - return error_code(); - - // - // finally compile the maps so that we can make intelligent choices - // whenever we encounter an alternative: - compile_maps(); - if(pkmp) - { - re_detail::kmp_free(pkmp, data.allocator()); - pkmp = 0; - } - re_detail::re_syntax_base* sbase = static_cast(data.data()); - _restart_type = probe_restart(sbase); - _leading_len = fixup_leading_rep(sbase, 0); - if((sbase->type == re_detail::syntax_element_literal) && (sbase->next.p->type == re_detail::syntax_element_match)) - { - _restart_type = restart_fixed_lit; - if(0 == pkmp) - { - charT* p1 = reinterpret_cast(reinterpret_cast(sbase) + sizeof(re_detail::re_literal)); - charT* p2 = p1 + static_cast(sbase)->length; - pkmp = re_detail::kmp_compile(p1, p2, charT(), re_detail::kmp_translator(_flags®ex_constants::icase, &traits_inst), data.allocator()); - } - } - return error_code(); - - } // sentry - return REG_EMPTY; - -# ifdef BOOST_MSVC -# pragma warning(pop) -#endif - -} - -template -re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression::add_simple(re_detail::re_syntax_base* dat, re_detail::syntax_element_type type, unsigned int arg_size) -{ - if(dat) - { - data.align(); - dat->next.i = data.size(); - } - if(arg_size < sizeof(re_detail::re_syntax_base)) - arg_size = sizeof(re_detail::re_syntax_base); - dat = static_cast(data.extend(arg_size)); - dat->type = type; - dat->next.i = 0; - return dat; -} - -template -re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression::add_literal(re_detail::re_syntax_base* dat, charT c) -{ - if(dat && (dat->type == re_detail::syntax_element_literal)) - { - // add another charT to the list: - std::ptrdiff_t pos = reinterpret_cast(dat) - reinterpret_cast(data.data()); - *reinterpret_cast(data.extend(sizeof(charT))) = traits_inst.translate(c, (_flags & regex_constants::icase)); - dat = reinterpret_cast(reinterpret_cast(data.data()) + pos); - ++(static_cast(dat)->length); - } - else - { - // extend: - dat = add_simple(dat, re_detail::syntax_element_literal, sizeof(re_detail::re_literal) + sizeof(charT)); - static_cast(dat)->length = 1; - *reinterpret_cast(reinterpret_cast(dat)+1) = traits_inst.translate(c, (_flags & regex_constants::icase)); - } - return dat; -} - -template -unsigned int BOOST_REGEX_CALL reg_expression::probe_restart(re_detail::re_syntax_base* dat) -{ - switch(dat->type) - { - case re_detail::syntax_element_startmark: - case re_detail::syntax_element_endmark: - if(static_cast(dat)->index == -2) - return regbase::restart_any; - return probe_restart(dat->next.p); - case re_detail::syntax_element_start_line: - return regbase::restart_line; - case re_detail::syntax_element_word_start: - return regbase::restart_word; - case re_detail::syntax_element_buffer_start: - return regbase::restart_buf; - case re_detail::syntax_element_restart_continue: - return regbase::restart_continue; - default: - return regbase::restart_any; - } -} - -template -unsigned int BOOST_REGEX_CALL reg_expression::fixup_leading_rep(re_detail::re_syntax_base* dat, re_detail::re_syntax_base* arg_end) -{ - unsigned int len = 0; - if((_restart_type >= restart_word) || (_restart_type <= restart_continue)) - return 0; - bool leading_lit = arg_end ? false : true; - while(dat != arg_end) - { - switch(dat->type) - { - case re_detail::syntax_element_literal: - len += static_cast(dat)->length; - if((leading_lit) && (static_cast(dat)->length > 2)) - { - // we can do a literal search for the leading literal string - // using Knuth-Morris-Pratt (or whatever), and only then check for - // matches. We need a decent length string though to make it - // worth while. - _leading_string = reinterpret_cast(reinterpret_cast(dat) + sizeof(re_detail::re_literal)); - _leading_string_len = static_cast(dat)->length; - _restart_type = restart_lit; - leading_lit = false; - const charT* p1 = _leading_string; - const charT* p2 = _leading_string + _leading_string_len; - pkmp = re_detail::kmp_compile(p1, p2, charT(), re_detail::kmp_translator(_flags®ex_constants::icase, &traits_inst), data.allocator()); - } - leading_lit = false; - break; - case re_detail::syntax_element_wild: - ++len; - leading_lit = false; - break; - case re_detail::syntax_element_match: - return len; - case re_detail::syntax_element_backref: - //case re_detail::syntax_element_jump: - case re_detail::syntax_element_alt: - case re_detail::syntax_element_combining: - return 0; - case re_detail::syntax_element_long_set: - { - // we need to verify that there are no multi-character - // collating elements inside the repeat: - if(!static_cast(dat)->singleton) - return 0; - ++len; - leading_lit = false; - break; - } - case re_detail::syntax_element_set: - ++len; - leading_lit = false; - break; - case re_detail::syntax_element_rep: - case re_detail::syntax_element_dot_rep: - case re_detail::syntax_element_char_rep: - case re_detail::syntax_element_short_set_rep: - case re_detail::syntax_element_long_set_rep: - if((len == 0) && (_leading_len == 0) && (1 == fixup_leading_rep(dat->next.p, static_cast(dat)->alt.p) )) - { - static_cast(dat)->leading = leading_lit; - return len; - } - return len; - case re_detail::syntax_element_startmark: - if(static_cast(dat)->index == -2) - return 0; - // fall through: - default: - break; - } - dat = dat->next.p; - } - return len; -} - -template -void BOOST_REGEX_CALL reg_expression::fail(unsigned int err) -{ - error_code_ = err; - if(err) - { - _flags |= regex_constants::failbit; -#ifndef BOOST_NO_EXCEPTIONS - if(_flags & regex_constants::use_except) - { - re_detail::raise_error(traits_inst, err); - } -#endif - } - else - _flags &= ~regex_constants::failbit; -} - -#ifdef __BORLANDC__ -#pragma option pop -#endif -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -} // namespace boost - - -#endif // BOOST_REGEX_COMPILE_HPP - - - - - - - - - - - diff --git a/boost/boost/regex/v4/regex_cstring.hpp b/boost/boost/regex/v4/regex_cstring.hpp index 82b3923a1b..589380d6ee 100644 --- a/boost/boost/regex/v4/regex_cstring.hpp +++ b/boost/boost/regex/v4/regex_cstring.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file diff --git a/boost/boost/regex/v4/regex_format.hpp b/boost/boost/regex/v4/regex_format.hpp index a2ae92509f..f0e327f34f 100644 --- a/boost/boost/regex/v4/regex_format.hpp +++ b/boost/boost/regex/v4/regex_format.hpp @@ -1,10 +1,10 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) * */ @@ -31,638 +31,590 @@ namespace boost{ // // Forward declaration: // -template + template >::allocator_type > class match_results; namespace re_detail{ -// make_upper and make_lower should ideally be implemented in regex_traits -#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) - // -// VC6 needs to link to user32.lib, as do all compilers that -// claim to be VC6/7 compatible: +// struct trivial_format_traits: +// defines minimum localisation support for formatting +// in the case that the actual regex traits is unavailable. // -#if defined(_MSC_VER) && !defined(__BORLANDC__) -#pragma comment(lib, "user32.lib") -#endif - -inline wchar_t make_upper(wchar_t c) +template +struct trivial_format_traits { - return LOWORD(::CharUpperW(reinterpret_cast(static_cast(c)))); -} + typedef charT char_type; -inline char make_upper(char c) -{ - return static_cast(LOWORD(::CharUpperA(reinterpret_cast(static_cast(c))))); -} - -inline wchar_t make_lower(wchar_t c) -{ - return LOWORD(::CharLowerW(reinterpret_cast(static_cast(c)))); -} - -inline char make_lower(char c) -{ - return static_cast(LOWORD(::CharLowerA(reinterpret_cast(static_cast(c))))); -} - -#else - -// TODO: make this traits class sensitive: -#ifndef BOOST_NO_WREGEX -inline wchar_t make_upper(wchar_t c) -{ - return (std::towupper)(c); -} - -inline wchar_t make_lower(wchar_t c) -{ - return (std::towlower)(c); -} -#endif -inline char make_upper(char c) -{ - return static_cast((std::toupper)(c)); -} - -inline char make_lower(char c) -{ - return static_cast((std::tolower)(c)); -} - -#endif //defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) - -typedef enum { - case_nochange, - case_oneupper, - case_onelower, - case_allupper, - case_alllower -} case_flags_type; - -// traits_type is unused, but provided to make it possible to use it for case conversion -template -void BOOST_REGEX_CALL output_char(O& out, charT c, traits_type& /*t*/, case_flags_type& f) -{ - switch (f) { - case case_oneupper: - f = case_nochange; - // drop through - case case_allupper: - *out = make_upper(c); - break; - case case_onelower: - f = case_nochange; - // drop through - case case_alllower: - *out = make_lower(c); - break; - default: - *out = c; - break; - } -} - -template -O BOOST_REGEX_CALL re_copy_out(O out, I first, I last, traits_type& t, case_flags_type& f) -{ - while(first != last) + static std::ptrdiff_t length(const charT* p) { - if (f != case_nochange) - output_char(out, *first, t, f); - else - *out = *first; - - ++out; - ++first; + return global_length(p); } - return out; + static charT tolower(charT c) + { + return ::boost::re_detail::global_lower(c); + } + static charT toupper(charT c) + { + return ::boost::re_detail::global_upper(c); + } + static int value(const charT c, int radix) + { + int result = global_value(c); + return result >= radix ? -1 : result; + } + int toi(const charT*& p1, const charT* p2, int radix)const + { + return global_toi(p1, p2, radix, *this); + } +}; + +template +class basic_regex_formatter +{ +public: + typedef typename traits::char_type char_type; + basic_regex_formatter(OutputIterator o, const Results& r, const traits& t) + : m_traits(t), m_results(r), m_out(o), m_state(output_copy), m_have_conditional(false) {} + OutputIterator format(const char_type* p1, const char_type* p2, match_flag_type f); + OutputIterator format(const char_type* p1, match_flag_type f) + { + return format(p1, p1 + m_traits.length(p1), f); + } +private: + typedef typename Results::value_type sub_match_type; + enum output_state + { + output_copy, + output_next_lower, + output_next_upper, + output_lower, + output_upper, + output_none + }; + + void put(char_type c); + void put(const sub_match_type& sub); + void format_all(); + void format_perl(); + void format_escape(); + void format_conditional(); + void format_until_scope_end(); + + const traits& m_traits; // the traits class for localised formatting operations + const Results& m_results; // the match_results being used. + OutputIterator m_out; // where to send output. + const char_type* m_position; // format string, current position + const char_type* m_end; // format string end + match_flag_type m_flags; // format flags to use + output_state m_state; // what to do with the next character + bool m_have_conditional; // we are parsing a conditional +private: + basic_regex_formatter(const basic_regex_formatter&); + basic_regex_formatter& operator=(const basic_regex_formatter&); +}; + +template +OutputIterator basic_regex_formatter::format(const char_type* p1, const char_type* p2, match_flag_type f) +{ + m_position = p1; + m_end = p2; + m_flags = f; + format_all(); + return m_out; } - -template -void BOOST_REGEX_CALL re_skip_format(const charT*& fmt, const traits_type& traits_inst) +template +void basic_regex_formatter::format_all() { - // dwa 9/13/00 - suppress incorrect unused parameter warning for MSVC - (void)traits_inst; - - typedef typename traits_type::size_type traits_size_type; - typedef typename traits_type::uchar_type traits_uchar_type; - typedef typename traits_type::string_type traits_string_type; - - unsigned int parens = 0; - unsigned int c; - while(*fmt) + // over and over: + while(m_position != m_end) { - c = traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*fmt)); - if((c == traits_type::syntax_colon) && (parens == 0)) + switch(*m_position) { - ++fmt; - return; - } - else if(c == traits_type::syntax_close_bracket) - { - if(parens == 0) + case '&': + if(m_flags & ::boost::regex_constants::format_sed) + { + ++m_position; + put(m_results[0]); + break; + } + put(*m_position++); + break; + case '\\': + format_escape(); + break; + case '(': + if(m_flags & boost::regex_constants::format_all) + { + ++m_position; + bool have_conditional = m_have_conditional; + m_have_conditional = false; + format_until_scope_end(); + m_have_conditional = have_conditional; + if(m_position == m_end) + return; + BOOST_ASSERT(*m_position == static_cast(')')); + ++m_position; // skip the closing ')' + break; + } + put(*m_position); + ++m_position; + break; + case ')': + if(m_flags & boost::regex_constants::format_all) { - ++fmt; return; } - --parens; - } - else if(c == traits_type::syntax_open_bracket) - ++parens; - else if(c == traits_type::syntax_slash) - { - ++fmt; - if(*fmt == 0) + put(*m_position); + ++m_position; + break; + case ':': + if((m_flags & boost::regex_constants::format_all) && m_have_conditional) + { return; + } + put(*m_position); + ++m_position; + break; + case '?': + if(m_flags & boost::regex_constants::format_all) + { + ++m_position; + format_conditional(); + break; + } + put(*m_position); + ++m_position; + break; + case '$': + if((m_flags & format_sed) == 0) + { + format_perl(); + break; + } + // fall through, not a special character: + default: + put(*m_position); + ++m_position; + break; } - ++fmt; } } -#ifdef BOOST_NO_STD_OUTPUT_ITERATOR_ASSIGN - -// -// ugly hack for buggy output iterators - -template -inline void oi_assign(T* p, T v) -{ - ::boost::re_detail::pointer_destroy(p); - pointer_construct(p, v); -} - -#else - -template -inline void oi_assign(T* p, T v) +template +void basic_regex_formatter::format_perl() { // - // if you get a compile time error in here then you either - // need to rewrite your output iterator to make it assignable - // (as is required by the standard), or define - // BOOST_NO_STD_OUTPUT_ITERATOR_ASSIGN to use the ugly hack above - *p = v; -} - -#endif - - -#if defined(BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE) -// -// Ugly ugly hack, -// template don't merge if they contain switch statements so declare these -// templates in unnamed namespace (ie with internal linkage), each translation -// unit then gets its own local copy, it works seemlessly but bloats the app. -namespace{ -#endif - -// -// algorithm reg_format: -// takes the result of a match and a format string -// and merges them to produce a new string which -// is sent to an OutputIterator, -// _reg_format_aux does the actual work: -// -template -OutputIterator BOOST_REGEX_CALL _reg_format_aux(OutputIterator out, - const match_results& m, - const charT*& fmt, - match_flag_type flags, const traits_type& traits_inst, - case_flags_type& case_flags) -{ -#ifdef __BORLANDC__ -#pragma option push -w-8037 -#endif - const charT* fmt_end = fmt; - while(*fmt_end) ++ fmt_end; - - typedef typename traits_type::size_type traits_size_type; - typedef typename traits_type::uchar_type traits_uchar_type; - typedef typename traits_type::string_type traits_string_type; - - while(*fmt) + // On entry *m_position points to a '$' character + // output the information that goes with it: + // + BOOST_ASSERT(*m_position == '$'); + // + // see if this is a trailing '$': + // + if(++m_position == m_end) { - switch(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*fmt))) + --m_position; + put(*m_position); + ++m_position; + return; + } + // + // OK find out what kind it is: + // + switch(*m_position) + { + case '&': + ++m_position; + put(this->m_results[0]); + break; + case '`': + ++m_position; + put(this->m_results.prefix()); + break; + case '\'': + ++m_position; + put(this->m_results.suffix()); + break; + case '$': + put(*m_position++); + break; + default: + // see if we have a number: { - case traits_type::syntax_dollar: - if(flags & format_sed) + std::ptrdiff_t len = (std::min)(static_cast(2), ::boost::re_detail::distance(m_position, m_end)); + int v = m_traits.toi(m_position, m_position + len, 10); + if(v < 0) { - // no perl style replacement, - // $ is an ordinary character: - goto default_opt; - } - ++fmt; - if(*fmt == 0) // oops trailing $ - { - --fmt; - *out = *fmt; - ++out; - return out; - } - switch(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*fmt))) - { - case traits_type::syntax_start_buffer: - oi_assign(&out, re_copy_out(out, Iterator(m[-1].first), Iterator(m[-1].second), - traits_inst, case_flags)); - ++fmt; - continue; - case traits_type::syntax_end_buffer: - oi_assign(&out, re_copy_out(out, Iterator(m[-2].first), Iterator(m[-2].second), - traits_inst, case_flags)); - ++fmt; - continue; - case traits_type::syntax_digit: - { -expand_sub: - unsigned int index = traits_inst.toi(fmt, fmt_end, 10); - if(index < m.size()) - oi_assign(&out, re_copy_out(out, Iterator(m[index].first), Iterator(m[index].second), - traits_inst, case_flags)); - continue; - } - } - // anything else: - if(*fmt == '&') - { - oi_assign(&out, re_copy_out(out, Iterator(m[0].first), Iterator(m[0].second), - traits_inst, case_flags)); - ++fmt; - } - else - { - // probably an error, treat as a literal '$' - --fmt; - *out = *fmt; - ++out; - ++fmt; - } - continue; - case traits_type::syntax_slash: - { - // escape sequence: - ++fmt; - charT c(*fmt); - if(*fmt == 0) - { - --fmt; - *out = *fmt; - ++out; - ++fmt; - return out; - } - switch(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*fmt))) - { - case traits_type::syntax_a: - c = '\a'; - ++fmt; + // leave the $ as is, and carry on: + --m_position; + put(*m_position); + ++m_position; break; - case traits_type::syntax_f: - c = '\f'; - ++fmt; - break; - case traits_type::syntax_n: - c = '\n'; - ++fmt; - break; - case traits_type::syntax_r: - c = '\r'; - ++fmt; - break; - case traits_type::syntax_t: - c = '\t'; - ++fmt; - break; - case traits_type::syntax_v: - c = '\v'; - ++fmt; - break; - case traits_type::syntax_x: - ++fmt; - if(fmt == fmt_end) - { - *out = *--fmt; - ++out; - return out; - } - // maybe have \x{ddd} - if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*fmt)) == traits_type::syntax_open_brace) - { - ++fmt; - if(fmt == fmt_end) - { - fmt -= 2; - *out = *fmt; - ++out; - ++fmt; - continue; - } - if(traits_inst.is_class(*fmt, traits_type::char_class_xdigit) == false) - { - fmt -= 2; - *out = *fmt; - ++out; - ++fmt; - continue; - } - c = (charT)traits_inst.toi(fmt, fmt_end, -16); - if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*fmt)) != traits_type::syntax_close_brace) - { - while(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*fmt)) != traits_type::syntax_slash) - --fmt; - ++fmt; - *out = *fmt; - ++out; - ++fmt; - continue; - } - ++fmt; - break; - } - else - { - if(traits_inst.is_class(*fmt, traits_type::char_class_xdigit) == false) - { - --fmt; - *out = *fmt; - ++out; - ++fmt; - continue; - } - c = (charT)traits_inst.toi(fmt, fmt_end, -16); - } - break; - case traits_type::syntax_c: - ++fmt; - if(fmt == fmt_end) - { - --fmt; - *out = *fmt; - ++out; - return out; - } - if(((typename traits_type::uchar_type)(*fmt) < (typename traits_type::uchar_type)'@') - || ((typename traits_type::uchar_type)(*fmt) > (typename traits_type::uchar_type)127) ) - { - --fmt; - *out = *fmt; - ++out; - ++fmt; - break; - } - c = (charT)((typename traits_type::uchar_type)(*fmt) - (typename traits_type::uchar_type)'@'); - ++fmt; - break; - case traits_type::syntax_e: - c = (charT)27; - ++fmt; - break; - case traits_type::syntax_digit: - if(flags & format_sed) - goto expand_sub; - else - c = (charT)traits_inst.toi(fmt, fmt_end, -8); - break; - - case traits_type::syntax_u: - ++fmt; - if(flags & format_sed) break; - case_flags = case_oneupper; - continue; - case traits_type::syntax_l: - ++fmt; - if(flags & format_sed) break; - case_flags = case_onelower; - continue; - case traits_type::syntax_U: - ++fmt; - if(flags & format_sed) break; - case_flags = case_allupper; - continue; - case traits_type::syntax_L: - ++fmt; - if(flags & format_sed) break; - case_flags = case_alllower; - continue; - case traits_type::syntax_E: - ++fmt; - if(flags & format_sed) break; - case_flags = case_nochange; - continue; - default: - //c = *fmt; - ++fmt; } - *out = c; - ++out; - continue; - } - case traits_type::syntax_open_bracket: - if(0 == (flags & format_all)) - { - *out = *fmt; - ++out; - ++fmt; - continue; - } - else - { - ++fmt; // recurse - oi_assign(&out, _reg_format_aux(out, m, fmt, flags, traits_inst, case_flags)); - continue; - } - case traits_type::syntax_close_bracket: - if(0 == (flags & format_all)) - { - *out = *fmt; - ++out; - ++fmt; - continue; - } - else - { - ++fmt; // return from recursion - return out; - } - case traits_type::syntax_colon: - if(flags & regex_constants::format_is_if) - { - ++fmt; - return out; - } - *out = *fmt; - ++out; - ++fmt; - continue; - case traits_type::syntax_question: - { - if(0 == (flags & format_all)) - { - *out = *fmt; - ++out; - ++fmt; - continue; - } - else - { - ++fmt; - if(*fmt == 0) - { - --fmt; - *out = *fmt; - ++out; - ++fmt; - return out; - } - unsigned int id = traits_inst.toi(fmt, fmt_end, 10); - if(m[id].matched) - { - oi_assign(&out, _reg_format_aux(out, m, fmt, flags | regex_constants::format_is_if, traits_inst, case_flags)); - if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*(fmt-1))) == traits_type::syntax_colon) - re_skip_format(fmt, traits_inst); - } - else - { - re_skip_format(fmt, traits_inst); - if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*(fmt-1))) == traits_type::syntax_colon) - oi_assign(&out, _reg_format_aux(out, m, fmt, flags | regex_constants::format_is_if, traits_inst, case_flags)); - } - return out; - } - } - default: -default_opt: - if((flags & format_sed) && (*fmt == '&')) - { - oi_assign(&out, re_copy_out(out, Iterator(m[0].first), Iterator(m[0].second), - traits_inst, case_flags)); - ++fmt; - continue; - } - - output_char(out, *fmt, traits_inst, case_flags); - ++out; - ++fmt; + // otherwise output sub v: + put(this->m_results[v]); } } - - return out; -#ifdef __BORLANDC__ -#pragma option pop -#endif } -#if defined(BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE) -} // namespace -#endif +template +void basic_regex_formatter::format_escape() +{ + // skip the escape and check for trailing escape: + if(++m_position == m_end) + { + put(static_cast('\\')); + return; + } + // now switch on the escape type: + switch(*m_position) + { + case 'a': + put(static_cast('\a')); + ++m_position; + break; + case 'f': + put(static_cast('\f')); + ++m_position; + break; + case 'n': + put(static_cast('\n')); + ++m_position; + break; + case 'r': + put(static_cast('\r')); + ++m_position; + break; + case 't': + put(static_cast('\t')); + ++m_position; + break; + case 'v': + put(static_cast('\v')); + ++m_position; + break; + case 'x': + if(++m_position == m_end) + { + put(static_cast('x')); + return; + } + // maybe have \x{ddd} + if(*m_position == static_cast('{')) + { + ++m_position; + int val = m_traits.toi(m_position, m_end, 16); + if(val < 0) + { + // invalid value treat everything as literals: + put(static_cast('x')); + put(static_cast('{')); + return; + } + if(*m_position != static_cast('}')) + { + while(*m_position != static_cast('\\')) + --m_position; + ++m_position; + put(*m_position++); + return; + } + ++m_position; + put(static_cast(val)); + return; + } + else + { + std::ptrdiff_t len = (std::min)(static_cast(2), ::boost::re_detail::distance(m_position, m_end)); + int val = m_traits.toi(m_position, m_position + len, 16); + if(val < 0) + { + --m_position; + put(*m_position++); + return; + } + put(static_cast(val)); + } + break; + case 'c': + if(++m_position == m_end) + { + --m_position; + put(*m_position++); + return; + } + put(static_cast(*m_position++ % 32)); + break; + case 'e': + put(static_cast(27)); + ++m_position; + break; + default: + // see if we have a perl specific escape: + if((m_flags & boost::regex_constants::format_sed) == 0) + { + bool breakout = false; + switch(*m_position) + { + case 'l': + ++m_position; + m_state = output_next_lower; + breakout = true; + break; + case 'L': + ++m_position; + m_state = output_lower; + breakout = true; + break; + case 'u': + ++m_position; + m_state = output_next_upper; + breakout = true; + break; + case 'U': + ++m_position; + m_state = output_upper; + breakout = true; + break; + case 'E': + ++m_position; + m_state = output_copy; + breakout = true; + break; + } + if(breakout) + break; + } + // see if we have a \n sed style backreference: + int v = m_traits.toi(m_position, m_position+1, 10); + if((v > 0) || ((v == 0) && (m_flags & ::boost::regex_constants::format_sed))) + { + put(m_results[v]); + break; + } + else if(v == 0) + { + // octal ecape sequence: + --m_position; + std::ptrdiff_t len = (std::min)(static_cast(4), ::boost::re_detail::distance(m_position, m_end)); + v = m_traits.toi(m_position, m_position + len, 8); + BOOST_ASSERT(v >= 0); + put(static_cast(v)); + break; + } + // Otherwise output the character "as is": + put(*m_position++); + break; + } +} + +template +void basic_regex_formatter::format_conditional() +{ + if(m_position == m_end) + { + // oops trailing '?': + put(static_cast('?')); + return; + } + std::ptrdiff_t len = (std::min)(static_cast(2), ::boost::re_detail::distance(m_position, m_end)); + int v = m_traits.toi(m_position, m_position + len, 10); + if(v < 0) + { + // oops not a number: + put(static_cast('?')); + return; + } + + // output varies depending upon whether sub-expression v matched or not: + if(m_results[v].matched) + { + m_have_conditional = true; + format_all(); + m_have_conditional = false; + if((m_position != m_end) && (*m_position == static_cast(':'))) + { + // skip the ':': + ++m_position; + // save output state, then turn it off: + output_state saved_state = m_state; + m_state = output_none; + // format the rest of this scope: + format_until_scope_end(); + // restore output state: + m_state = saved_state; + } + } + else + { + // save output state, then turn it off: + output_state saved_state = m_state; + m_state = output_none; + // format until ':' or ')': + m_have_conditional = true; + format_all(); + m_have_conditional = false; + // restore state: + m_state = saved_state; + if((m_position != m_end) && (*m_position == static_cast(':'))) + { + // skip the ':': + ++m_position; + // format the rest of this scope: + format_until_scope_end(); + } + } +} + +template +void basic_regex_formatter::format_until_scope_end() +{ + do + { + format_all(); + if((m_position == m_end) || (*m_position == static_cast(')'))) + return; + put(*m_position++); + }while(m_position != m_end); +} + +template +void basic_regex_formatter::put(char_type c) +{ + // write a single character to output + // according to which case translation mode we are in: + switch(this->m_state) + { + case output_none: + return; + case output_next_lower: + c = m_traits.tolower(c); + this->m_state = output_copy; + break; + case output_next_upper: + c = m_traits.toupper(c); + this->m_state = output_copy; + break; + case output_lower: + c = m_traits.tolower(c); + break; + case output_upper: + c = m_traits.toupper(c); + break; + default: + break; + } + *m_out = c; + ++m_out; +} + +template +void basic_regex_formatter::put(const sub_match_type& sub) +{ + typedef typename sub_match_type::iterator iterator_type; + iterator_type i = sub.first; + while(i != sub.second) + { + put(*i); + ++i; + } +} template class string_out_iterator +#ifndef BOOST_NO_STD_ITERATOR + : public std::iterator +#endif { S* out; public: - typedef typename S::difference_type difference_type; - typedef typename S::value_type value_type; - typedef typename S::pointer pointer; - typedef typename S::reference reference; - typedef std::output_iterator_tag iterator_category; - string_out_iterator(S& s) : out(&s) {} string_out_iterator& operator++() { return *this; } string_out_iterator& operator++(int) { return *this; } string_out_iterator& operator*() { return *this; } - string_out_iterator& operator=(typename S::value_type v) - { - out->append(1, v); - return *this; + string_out_iterator& operator=(typename S::value_type v) + { + out->append(1, v); + return *this; } + +#ifdef BOOST_NO_STD_ITERATOR + typedef std::ptrdiff_t difference_type; + typedef typename S::value_type value_type; + typedef value_type* pointer; + typedef value_type& reference; + typedef std::output_iterator_tag iterator_category; +#endif }; -template -class merge_out_predicate +template +OutputIterator regex_format_imp(OutputIterator out, + const match_results& m, + const charT* p1, const charT* p2, + match_flag_type flags, + const traits& t + ) { - OutputIterator* out; - Iterator* last; - const charT* fmt; - match_flag_type flags; - const traits_type* pt; - // rebind allocator to correct type: - typedef typename detail::rebind_allocator, Allocator>::type alloc_type; - -public: - merge_out_predicate(OutputIterator& o, Iterator& pi, const charT* f, match_flag_type format_flags, const traits_type& p) - : out(&o), last(&pi), fmt(f), flags(format_flags), pt(&p){} - - ~merge_out_predicate() {} - bool BOOST_REGEX_CALL operator()(const boost::match_results& m) + if(flags & regex_constants::format_literal) { - const charT* f = fmt; - case_flags_type cf = case_nochange; - if(0 == (flags & format_no_copy)) - { - oi_assign(out, re_copy_out( - *out, - Iterator(m[-1].first), - Iterator(m[-1].second), - *pt, - cf)); - } - oi_assign(out, _reg_format_aux(*out, m, f, flags, *pt, cf)); - *last = m[-2].first; - return flags & format_first_only ? false : true; + return re_detail::copy(p1, p2, out); } -}; + + re_detail::basic_regex_formatter< + OutputIterator, + match_results, + traits > f(out, m, t); + return f.format(p1, p2, flags); +} + } // namespace re_detail -template +template OutputIterator regex_format(OutputIterator out, - const match_results& m, + const match_results& m, const charT* fmt, match_flag_type flags = format_all ) { - regex_traits t; - - re_detail::case_flags_type cf = re_detail::case_nochange; - return re_detail::_reg_format_aux(out, m, fmt, flags, t, cf); + re_detail::trivial_format_traits traits; + return re_detail::regex_format_imp(out, m, fmt, fmt + traits.length(fmt), flags, traits); } -template +template OutputIterator regex_format(OutputIterator out, - const match_results& m, + const match_results& m, const std::basic_string& fmt, match_flag_type flags = format_all ) { - regex_traits t; - const charT* start = fmt.c_str(); + re_detail::trivial_format_traits traits; + return re_detail::regex_format_imp(out, m, fmt.data(), fmt.data() + fmt.size(), flags, traits); +} - re_detail::case_flags_type cf = re_detail::case_nochange; - return re_detail::_reg_format_aux(out, m, start, flags, t, cf); -} - -template -std::basic_string regex_format(const match_results& m, - const charT* fmt, +template +std::basic_string regex_format(const match_results& m, + const charT* fmt, match_flag_type flags = format_all) { std::basic_string result; re_detail::string_out_iterator > i(result); - regex_format(i, m, fmt, flags); + re_detail::trivial_format_traits traits; + re_detail::regex_format_imp(i, m, fmt, fmt + traits.length(fmt), flags, traits); return result; } -template -std::basic_string regex_format(const match_results& m, - const std::basic_string& fmt, +template +std::basic_string regex_format(const match_results& m, + const std::basic_string& fmt, match_flag_type flags = format_all) { std::basic_string result; re_detail::string_out_iterator > i(result); - regex_format(i, m, fmt.c_str(), flags); + re_detail::trivial_format_traits traits; + re_detail::regex_format_imp(i, m, fmt.data(), fmt.data() + fmt.size(), flags, traits); return result; } diff --git a/boost/boost/regex/v4/regex_fwd.hpp b/boost/boost/regex/v4/regex_fwd.hpp index e5b437cc4a..3076b069ac 100644 --- a/boost/boost/regex/v4/regex_fwd.hpp +++ b/boost/boost/regex/v4/regex_fwd.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -13,7 +13,7 @@ * LOCATION: see http://www.boost.org for most recent version. * FILE regex_fwd.cpp * VERSION see - * DESCRIPTION: Forward declares boost::reg_expression<> and + * DESCRIPTION: Forward declares boost::basic_regex<> and * associated typedefs. */ @@ -21,9 +21,8 @@ #define BOOST_REGEX_FWD_HPP_INCLUDED #ifndef BOOST_REGEX_CONFIG_HPP -#include +#include #endif -#include // // define BOOST_REGEX_NO_FWD if this @@ -35,27 +34,32 @@ # endif #else -// -// If there isn't good enough wide character support then there will -// be no wide character regular expressions: -// -#if (defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_CWCTYPE) || defined(BOOST_NO_STD_WSTRING)) && !defined(BOOST_NO_WREGEX) -# define BOOST_NO_WREGEX -#endif - namespace boost{ template -class regex_traits; +class cpp_regex_traits; +template +struct c_regex_traits; +template +class w32_regex_traits; -template , class Allocator = BOOST_DEFAULT_ALLOCATOR(charT) > -class reg_expression; -template , class Allocator = BOOST_DEFAULT_ALLOCATOR(charT) > +#ifdef BOOST_REGEX_USE_WIN32_LOCALE +template > +struct regex_traits; +#elif defined(BOOST_REGEX_USE_CPP_LOCALE) +template > +struct regex_traits; +#else +template > +struct regex_traits; +#endif + +template > class basic_regex; -typedef basic_regex, BOOST_DEFAULT_ALLOCATOR(char) > regex; +typedef basic_regex > regex; #ifndef BOOST_NO_WREGEX -typedef basic_regex, BOOST_DEFAULT_ALLOCATOR(wchar_t) > wregex; +typedef basic_regex > wregex; #endif } // namespace boost diff --git a/boost/boost/regex/v4/regex_grep.hpp b/boost/boost/regex/v4/regex_grep.hpp index f59fceb8b0..b8bb84796e 100644 --- a/boost/boost/regex/v4/regex_grep.hpp +++ b/boost/boost/regex/v4/regex_grep.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -30,21 +30,20 @@ namespace boost{ // regex_grep: // find all non-overlapping matches within the sequence first last: // -template +template inline unsigned int regex_grep(Predicate foo, BidiIterator first, BidiIterator last, - const reg_expression& e, + const basic_regex& e, match_flag_type flags = match_default) { if(e.flags() & regex_constants::failbit) return false; - typedef detail::rebind_allocator, Allocator> binder; - typedef typename binder::type match_allocator_type; - //typedef Allocator match_allocator_type; - match_results m; - re_detail::perl_matcher matcher(first, last, m, e, flags); + typedef typename match_results::allocator_type match_allocator_type; + + match_results m; + re_detail::perl_matcher matcher(first, last, m, e, flags, first); unsigned int count = 0; while(matcher.find()) { @@ -85,17 +84,17 @@ inline unsigned int regex_grep(Predicate foo, // this isn't really a partial specialisation, but template function // overloading - if the compiler doesn't support partial specialisation // then it really won't support this either: -template +template inline unsigned int regex_grep(Predicate foo, const charT* str, - const reg_expression& e, + const basic_regex& e, match_flag_type flags = match_default) { return regex_grep(foo, str, str + traits::length(str), e, flags); } -template +template inline unsigned int regex_grep(Predicate foo, const std::basic_string& s, - const reg_expression& e, + const basic_regex& e, match_flag_type flags = match_default) { return regex_grep(foo, s.begin(), s.end(), e, flags); diff --git a/boost/boost/regex/v4/regex_iterator.hpp b/boost/boost/regex/v4/regex_iterator.hpp index 0229246cb5..eb51a46fdb 100644 --- a/boost/boost/regex/v4/regex_iterator.hpp +++ b/boost/boost/regex/v4/regex_iterator.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 2003 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -29,52 +29,54 @@ namespace boost{ template + class traits> class regex_iterator_implementation { - typedef basic_regex regex_type; + typedef basic_regex regex_type; match_results what; // current match BidirectionalIterator base; // start of sequence BidirectionalIterator end; // end of sequence - const regex_type* pre; // the expression + const regex_type re; // the expression match_flag_type flags; // flags for matching public: regex_iterator_implementation(const regex_type* p, BidirectionalIterator last, match_flag_type f) - : base(), end(last), pre(p), flags(f){} + : base(), end(last), re(*p), flags(f){} bool init(BidirectionalIterator first) { base = first; - return regex_search(first, end, what, *pre, flags); + return regex_search(first, end, what, re, flags); } bool compare(const regex_iterator_implementation& that) { if(this == &that) return true; - return (pre == that.pre) && (end == that.end) && (flags == that.flags) && (what[0].first == that.what[0].first) && (what[0].second == that.what[0].second); + return (&re.get_data() == &that.re.get_data()) && (end == that.end) && (flags == that.flags) && (what[0].first == that.what[0].first) && (what[0].second == that.what[0].second); } const match_results& get() { return what; } bool next() { - if(what.prefix().first != what[0].second) - flags |= match_prev_avail; + //if(what.prefix().first != what[0].second) + // flags |= match_prev_avail; BidirectionalIterator next_start = what[0].second; match_flag_type f(flags); if(!what.length()) f |= regex_constants::match_not_initial_null; - bool result = regex_search(next_start, end, what, *pre, f); + //if(base != next_start) + // f |= regex_constants::match_not_bob; + bool result = regex_search(next_start, end, what, re, f, base); if(result) what.set_base(base); return result; } +private: + regex_iterator_implementation& operator=(const regex_iterator_implementation&); }; template ::value_type, - class traits = regex_traits, - class Allocator = BOOST_DEFAULT_ALLOCATOR(charT) > + class traits = regex_traits > class regex_iterator #ifndef BOOST_NO_STD_ITERATOR : public std::iterator< @@ -86,10 +88,10 @@ class regex_iterator #endif { private: - typedef regex_iterator_implementation impl; + typedef regex_iterator_implementation impl; typedef shared_ptr pimpl; public: - typedef basic_regex regex_type; + typedef basic_regex regex_type; typedef match_results value_type; typedef typename re_detail::regex_iterator_traits::difference_type difference_type; @@ -163,6 +165,18 @@ typedef regex_iterator wcregex_iterator; typedef regex_iterator wsregex_iterator; #endif +// make_regex_iterator: +template +inline regex_iterator make_regex_iterator(const charT* p, const basic_regex& e, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_iterator(p, p+traits::length(p), e, m); +} +template +inline regex_iterator::const_iterator, charT, traits> make_regex_iterator(const std::basic_string& p, const basic_regex& e, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_iterator::const_iterator, charT, traits>(p.begin(), p.end(), e, m); +} + #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_SUFFIX #endif diff --git a/boost/boost/regex/v4/regex_kmp.hpp b/boost/boost/regex/v4/regex_kmp.hpp index eaea55e014..3607ef7182 100644 --- a/boost/boost/regex/v4/regex_kmp.hpp +++ b/boost/boost/regex/v4/regex_kmp.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -55,7 +55,7 @@ kmp_info* kmp_compile(iterator first, iterator last, charT, Trans transla typedef typename boost::detail::rebind_allocator::type atype; int i, j, m; i = 0; - m = static_cast(boost::re_detail::distance(first, last)); + m = static_cast(::boost::re_detail::distance(first, last)); ++m; unsigned int size = sizeof(kmp_info) + sizeof(int)*m + sizeof(charT)*m; --m; diff --git a/boost/boost/regex/v4/regex_match.hpp b/boost/boost/regex/v4/regex_match.hpp index a34a07ad64..7c1f88d646 100644 --- a/boost/boost/regex/v4/regex_match.hpp +++ b/boost/boost/regex/v4/regex_match.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -22,14 +22,6 @@ #ifndef BOOST_REGEX_MATCH_HPP #define BOOST_REGEX_MATCH_HPP -#ifndef BOOST_REGEX_MAX_STATE_COUNT -# define BOOST_REGEX_MAX_STATE_COUNT 100000000 -#endif - -#include -#include - - namespace boost{ #ifdef BOOST_HAS_ABI_HEADERS @@ -41,22 +33,22 @@ namespace boost{ // returns true if the specified regular expression matches // the whole of the input. Fills in what matched in m. // -template +template bool regex_match(BidiIterator first, BidiIterator last, match_results& m, - const reg_expression& e, + const basic_regex& e, match_flag_type flags = match_default) { - re_detail::perl_matcher matcher(first, last, m, e, flags); + re_detail::perl_matcher matcher(first, last, m, e, flags, first); return matcher.match(); } -template +template bool regex_match(iterator first, iterator last, - const reg_expression& e, + const basic_regex& e, match_flag_type flags = match_default) { match_results m; - return regex_match(first, last, m, e, flags); + return regex_match(first, last, m, e, flags | regex_constants::match_any); } // // query_match convenience interfaces: @@ -65,40 +57,40 @@ bool regex_match(iterator first, iterator last, // this isn't really a partial specialisation, but template function // overloading - if the compiler doesn't support partial specialisation // then it really won't support this either: -template +template inline bool regex_match(const charT* str, match_results& m, - const reg_expression& e, + const basic_regex& e, match_flag_type flags = match_default) { return regex_match(str, str + traits::length(str), m, e, flags); } -template +template inline bool regex_match(const std::basic_string& s, match_results::const_iterator, Allocator>& m, - const reg_expression& e, + const basic_regex& e, match_flag_type flags = match_default) { return regex_match(s.begin(), s.end(), m, e, flags); } -template +template inline bool regex_match(const charT* str, - const reg_expression& e, + const basic_regex& e, match_flag_type flags = match_default) { match_results m; - return regex_match(str, str + traits::length(str), m, e, flags); + return regex_match(str, str + traits::length(str), m, e, flags | regex_constants::match_any); } -template +template inline bool regex_match(const std::basic_string& s, - const reg_expression& e, + const basic_regex& e, match_flag_type flags = match_default) { typedef typename std::basic_string::const_iterator iterator; match_results m; - return regex_match(s.begin(), s.end(), m, e, flags); + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); } #else // partial ordering inline bool regex_match(const char* str, @@ -113,8 +105,54 @@ inline bool regex_match(const char* str, match_flag_type flags = match_default) { match_results m; + return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#ifndef BOOST_NO_STD_LOCALE +inline bool regex_match(const char* str, + cmatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ return regex_match(str, str + regex::traits_type::length(str), m, e, flags); } +inline bool regex_match(const char* str, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#endif +inline bool regex_match(const char* str, + cmatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(str, str + regex::traits_type::length(str), m, e, flags); +} +inline bool regex_match(const char* str, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) +inline bool regex_match(const char* str, + cmatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(str, str + regex::traits_type::length(str), m, e, flags); +} +inline bool regex_match(const char* str, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#endif #ifndef BOOST_NO_WREGEX inline bool regex_match(const wchar_t* str, wcmatch& m, @@ -128,8 +166,54 @@ inline bool regex_match(const wchar_t* str, match_flag_type flags = match_default) { match_results m; + return regex_match(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#ifndef BOOST_NO_STD_LOCALE +inline bool regex_match(const wchar_t* str, + wcmatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ return regex_match(str, str + wregex::traits_type::length(str), m, e, flags); } +inline bool regex_match(const wchar_t* str, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#endif +inline bool regex_match(const wchar_t* str, + wcmatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(str, str + wregex::traits_type::length(str), m, e, flags); +} +inline bool regex_match(const wchar_t* str, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) +inline bool regex_match(const wchar_t* str, + wcmatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(str, str + wregex::traits_type::length(str), m, e, flags); +} +inline bool regex_match(const wchar_t* str, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#endif #endif inline bool regex_match(const std::string& s, smatch& m, @@ -143,11 +227,57 @@ inline bool regex_match(const std::string& s, match_flag_type flags = match_default) { match_results m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#ifndef BOOST_NO_STD_LOCALE +inline bool regex_match(const std::string& s, + smatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ return regex_match(s.begin(), s.end(), m, e, flags); } +inline bool regex_match(const std::string& s, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#endif +inline bool regex_match(const std::string& s, + smatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(s.begin(), s.end(), m, e, flags); +} +inline bool regex_match(const std::string& s, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) +inline bool regex_match(const std::string& s, + smatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(s.begin(), s.end(), m, e, flags); +} +inline bool regex_match(const std::string& s, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#endif #if !defined(BOOST_NO_WREGEX) inline bool regex_match(const std::basic_string& s, - wsmatch& m, + match_results::const_iterator>& m, const wregex& e, match_flag_type flags = match_default) { @@ -158,8 +288,54 @@ inline bool regex_match(const std::basic_string& s, match_flag_type flags = match_default) { match_results::const_iterator> m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#ifndef BOOST_NO_STD_LOCALE +inline bool regex_match(const std::basic_string& s, + match_results::const_iterator>& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ return regex_match(s.begin(), s.end(), m, e, flags); } +inline bool regex_match(const std::basic_string& s, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results::const_iterator> m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#endif +inline bool regex_match(const std::basic_string& s, + match_results::const_iterator>& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(s.begin(), s.end(), m, e, flags); +} +inline bool regex_match(const std::basic_string& s, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results::const_iterator> m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) +inline bool regex_match(const std::basic_string& s, + match_results::const_iterator>& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(s.begin(), s.end(), m, e, flags); +} +inline bool regex_match(const std::basic_string& s, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results::const_iterator> m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#endif #endif #endif diff --git a/boost/boost/regex/v4/regex_merge.hpp b/boost/boost/regex/v4/regex_merge.hpp index ff6e1aa396..85c66dc996 100644 --- a/boost/boost/regex/v4/regex_merge.hpp +++ b/boost/boost/regex/v4/regex_merge.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -28,40 +28,40 @@ namespace boost{ # include BOOST_ABI_PREFIX #endif -template +template inline OutputIterator regex_merge(OutputIterator out, Iterator first, Iterator last, - const reg_expression& e, + const basic_regex& e, const charT* fmt, match_flag_type flags = match_default) { return regex_replace(out, first, last, e, fmt, flags); } -template +template inline OutputIterator regex_merge(OutputIterator out, Iterator first, Iterator last, - const reg_expression& e, + const basic_regex& e, const std::basic_string& fmt, match_flag_type flags = match_default) { return regex_merge(out, first, last, e, fmt.c_str(), flags); } -template +template inline std::basic_string regex_merge(const std::basic_string& s, - const reg_expression& e, + const basic_regex& e, const charT* fmt, match_flag_type flags = match_default) { return regex_replace(s, e, fmt, flags); } -template +template inline std::basic_string regex_merge(const std::basic_string& s, - const reg_expression& e, + const basic_regex& e, const std::basic_string& fmt, match_flag_type flags = match_default) { diff --git a/boost/boost/regex/v4/regex_raw_buffer.hpp b/boost/boost/regex/v4/regex_raw_buffer.hpp index e44fa64720..6de7664a2f 100644 --- a/boost/boost/regex/v4/regex_raw_buffer.hpp +++ b/boost/boost/regex/v4/regex_raw_buffer.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -25,6 +25,9 @@ #include #endif +#include +#include + namespace boost{ namespace re_detail{ @@ -93,43 +96,33 @@ enum{ // // class raw_storage // basically this is a simplified vector -// this is used by reg_expression for expression storage +// this is used by basic_regex for expression storage // -template -class raw_storage +class BOOST_REGEX_DECL raw_storage { public: - typedef Allocator allocator_type; - typedef typename boost::detail::rebind_allocator::type alloc_inst_type; - typedef typename alloc_inst_type::size_type size_type; - typedef typename alloc_inst_type::pointer pointer; + typedef std::size_t size_type; + typedef unsigned char* pointer; private: - // - // empty member optimisation: - struct alloc_data : public alloc_inst_type - { - typename alloc_inst_type::pointer last; - alloc_data(const Allocator& a) : alloc_inst_type(a){} - } alloc_inst; - pointer start, end; + pointer last, start, end; public: - raw_storage(const Allocator& a = Allocator()); - raw_storage(size_type n, const Allocator& a = Allocator()); + raw_storage(); + raw_storage(size_type n); ~raw_storage() { - alloc_inst.deallocate(start, (alloc_inst.last - start)); + ::operator delete(start); } void BOOST_REGEX_CALL resize(size_type n); void* BOOST_REGEX_CALL extend(size_type n) { - if(size_type(alloc_inst.last - end) < n) + if(size_type(last - end) < n) resize(n + (end - start)); - register void* result = end; + register pointer result = end; end += n; return result; } @@ -143,7 +136,7 @@ public: size_type BOOST_REGEX_CALL capacity() { - return alloc_inst.last - start; + return last - start; } void* BOOST_REGEX_CALL data()const @@ -153,7 +146,7 @@ public: size_type BOOST_REGEX_CALL index(void* ptr) { - return reinterpret_cast(ptr) - reinterpret_cast(data()); + return static_cast(ptr) - static_cast(data()); } void BOOST_REGEX_CALL clear() @@ -164,78 +157,28 @@ public: void BOOST_REGEX_CALL align() { // move end up to a boundary: - end = reinterpret_cast(start) + (((reinterpret_cast(end) - reinterpret_cast(start)) + padding_mask) & ~padding_mask); + end = start + (((end - start) + padding_mask) & ~padding_mask); } - - Allocator BOOST_REGEX_CALL allocator()const; void swap(raw_storage& that) { std::swap(start, that.start); std::swap(end, that.end); - std::swap(alloc_inst.last, that.alloc_inst.last); - std::swap(static_cast(alloc_inst), static_cast(that.alloc_inst)); + std::swap(last, that.last); } }; -template -raw_storage::raw_storage(const Allocator& a) - : alloc_inst(a) +inline raw_storage::raw_storage() { - start = end = alloc_inst.allocate(1024); - BOOST_REGEX_NOEH_ASSERT(start) - alloc_inst.last = start + 1024; + last = start = end = 0; } -template -raw_storage::raw_storage(size_type n, const Allocator& a) - : alloc_inst(a) +inline raw_storage::raw_storage(size_type n) { - start = end = alloc_inst.allocate(n); - BOOST_REGEX_NOEH_ASSERT(start) - alloc_inst.last = start + n; + start = end = static_cast(::operator new(n)); + BOOST_REGEX_NOEH_ASSERT(start) + last = start + n; } -template -Allocator BOOST_REGEX_CALL raw_storage::allocator()const -{ - return alloc_inst; -} - -template -void BOOST_REGEX_CALL raw_storage::resize(size_type n) -{ - register size_type newsize = (alloc_inst.last - start) * 2; - register size_type datasize = end - start; - if(newsize < n) - newsize = n; - // extend newsize to WORD/DWORD boundary: - newsize = (newsize + padding_mask) & ~(padding_mask); - - // allocate and copy data: - register unsigned char* ptr = alloc_inst.allocate(newsize); - BOOST_REGEX_NOEH_ASSERT(ptr) - std::memcpy(ptr, start, datasize); - - // get rid of old buffer: - alloc_inst.deallocate(start, (alloc_inst.last - start)); - - // and set up pointers: - start = ptr; - end = ptr + datasize; - alloc_inst.last = ptr + newsize; -} - -template -void* BOOST_REGEX_CALL raw_storage::insert(size_type pos, size_type n) -{ - jm_assert(pos <= size_type(end - start)); - if(size_type(alloc_inst.last - end) < n) - resize(n + (end - start)); - register void* result = start + pos; - std::memmove(start + pos + n, start + pos, (end - start) - pos); - end += n; - return result; -} #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_SUFFIX diff --git a/boost/boost/regex/v4/regex_replace.hpp b/boost/boost/regex/v4/regex_replace.hpp index d1a9500e1e..a852ffec08 100644 --- a/boost/boost/regex/v4/regex_replace.hpp +++ b/boost/boost/regex/v4/regex_replace.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -28,34 +28,54 @@ namespace boost{ # include BOOST_ABI_PREFIX #endif -template +template OutputIterator regex_replace(OutputIterator out, - Iterator first, - Iterator last, - const reg_expression& e, + BidirectionalIterator first, + BidirectionalIterator last, + const basic_regex& e, const charT* fmt, match_flag_type flags = match_default) { - Iterator l = first; - re_detail::merge_out_predicate oi(out, l, fmt, flags, e.get_traits()); - regex_grep(oi, first, last, e, flags); - return (flags & format_no_copy) ? out : std::copy(l, last, out); + regex_iterator i(first, last, e, flags); + regex_iterator j; + if(i == j) + { + if(!(flags & regex_constants::format_no_copy)) + out = re_detail::copy(first, last, out); + } + else + { + BidirectionalIterator last_m = first; + while(i != j) + { + if(!(flags & regex_constants::format_no_copy)) + out = re_detail::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) + break; + ++i; + } + if(!(flags & regex_constants::format_no_copy)) + out = re_detail::copy(last_m, last, out); + } + return out; } -template +template inline OutputIterator regex_replace(OutputIterator out, Iterator first, Iterator last, - const reg_expression& e, + const basic_regex& e, const std::basic_string& fmt, match_flag_type flags = match_default) { return regex_replace(out, first, last, e, fmt.c_str(), flags); } -template +template std::basic_string regex_replace(const std::basic_string& s, - const reg_expression& e, + const basic_regex& e, const charT* fmt, match_flag_type flags = match_default) { @@ -65,9 +85,9 @@ std::basic_string regex_replace(const std::basic_string& s, return result; } -template +template std::basic_string regex_replace(const std::basic_string& s, - const reg_expression& e, + const basic_regex& e, const std::basic_string& fmt, match_flag_type flags = match_default) { diff --git a/boost/boost/regex/v4/regex_search.hpp b/boost/boost/regex/v4/regex_search.hpp index 91aef71289..ee6028c29a 100644 --- a/boost/boost/regex/v4/regex_search.hpp +++ b/boost/boost/regex/v4/regex_search.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -26,16 +26,26 @@ namespace boost{ # include BOOST_ABI_PREFIX #endif -template +template bool regex_search(BidiIterator first, BidiIterator last, match_results& m, - const reg_expression& e, + const basic_regex& e, match_flag_type flags = match_default) +{ + return regex_search(first, last, m, e, flags, first); +} + +template +bool regex_search(BidiIterator first, BidiIterator last, + match_results& m, + const basic_regex& e, + match_flag_type flags, + BidiIterator base) { if(e.flags() & regex_constants::failbit) return false; - re_detail::perl_matcher matcher(first, last, m, e, flags); + re_detail::perl_matcher matcher(first, last, m, e, flags, base); return matcher.find(); } @@ -46,24 +56,24 @@ bool regex_search(BidiIterator first, BidiIterator last, // this isn't really a partial specialisation, but template function // overloading - if the compiler doesn't support partial specialisation // then it really won't support this either: -template +template inline bool regex_search(const charT* str, match_results& m, - const reg_expression& e, + const basic_regex& e, match_flag_type flags = match_default) { return regex_search(str, str + traits::length(str), m, e, flags); } -template +template inline bool regex_search(const std::basic_string& s, match_results::const_iterator, Allocator>& m, - const reg_expression& e, + const basic_regex& e, match_flag_type flags = match_default) { return regex_search(s.begin(), s.end(), m, e, flags); } -#else // partial specialisation +#else // partial overloads: inline bool regex_search(const char* str, cmatch& m, const regex& e, @@ -71,6 +81,14 @@ inline bool regex_search(const char* str, { return regex_search(str, str + regex::traits_type::length(str), m, e, flags); } +inline bool regex_search(const char* first, const char* last, + const regex& e, + match_flag_type flags = match_default) +{ + cmatch m; + return regex_search(first, last, m, e, flags | regex_constants::match_any); +} + #ifndef BOOST_NO_WREGEX inline bool regex_search(const wchar_t* str, wcmatch& m, @@ -79,6 +97,13 @@ inline bool regex_search(const wchar_t* str, { return regex_search(str, str + wregex::traits_type::length(str), m, e, flags); } +inline bool regex_search(const wchar_t* first, const wchar_t* last, + const wregex& e, + match_flag_type flags = match_default) +{ + wcmatch m; + return regex_search(first, last, m, e, flags | regex_constants::match_any); +} #endif inline bool regex_search(const std::string& s, smatch& m, @@ -99,9 +124,9 @@ inline bool regex_search(const std::basic_string& s, #endif -template +template bool regex_search(BidiIterator first, BidiIterator last, - const reg_expression& e, + const basic_regex& e, match_flag_type flags = match_default) { if(e.flags() & regex_constants::failbit) @@ -109,51 +134,34 @@ bool regex_search(BidiIterator first, BidiIterator last, match_results m; typedef typename match_results::allocator_type match_alloc_type; - re_detail::perl_matcher matcher(first, last, m, e, flags); + re_detail::perl_matcher matcher(first, last, m, e, flags | regex_constants::match_any, first); return matcher.find(); } #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING -template +template inline bool regex_search(const charT* str, - const reg_expression& e, + const basic_regex& e, match_flag_type flags = match_default) { return regex_search(str, str + traits::length(str), e, flags); } -template +template inline bool regex_search(const std::basic_string& s, - const reg_expression& e, + const basic_regex& e, match_flag_type flags = match_default) { return regex_search(s.begin(), s.end(), e, flags); } #else // non-template function overloads -inline bool regex_search(const char* first, const char* last, - const regex& e, - match_flag_type flags = match_default) -{ - cmatch m; - return regex_search(first, last, m, e, flags); -} - -#ifndef BOOST_NO_WREGEX -inline bool regex_search(const wchar_t* first, const wchar_t* last, - const wregex& e, - match_flag_type flags = match_default) -{ - wcmatch m; - return regex_search(first, last, m, e, flags); -} -#endif inline bool regex_search(const char* str, const regex& e, match_flag_type flags = match_default) { cmatch m; - return regex_search(str, str + regex::traits_type::length(str), m, e, flags); + return regex_search(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any); } #ifndef BOOST_NO_WREGEX inline bool regex_search(const wchar_t* str, @@ -161,7 +169,7 @@ inline bool regex_search(const wchar_t* str, match_flag_type flags = match_default) { wcmatch m; - return regex_search(str, str + wregex::traits_type::length(str), m, e, flags); + return regex_search(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any); } #endif inline bool regex_search(const std::string& s, @@ -169,7 +177,7 @@ inline bool regex_search(const std::string& s, match_flag_type flags = match_default) { smatch m; - return regex_search(s.begin(), s.end(), m, e, flags); + return regex_search(s.begin(), s.end(), m, e, flags | regex_constants::match_any); } #if !defined(BOOST_NO_WREGEX) inline bool regex_search(const std::basic_string& s, @@ -177,11 +185,12 @@ inline bool regex_search(const std::basic_string& s, match_flag_type flags = match_default) { wsmatch m; - return regex_search(s.begin(), s.end(), m, e, flags); + return regex_search(s.begin(), s.end(), m, e, flags | regex_constants::match_any); } -#endif -#endif +#endif // BOOST_NO_WREGEX + +#endif // partial overload #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_SUFFIX diff --git a/boost/boost/regex/v4/regex_split.hpp b/boost/boost/regex/v4/regex_split.hpp index ab614214a7..60e13e33fd 100644 --- a/boost/boost/regex/v4/regex_split.hpp +++ b/boost/boost/regex/v4/regex_split.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -30,14 +30,14 @@ namespace boost{ namespace re_detail{ template -const reg_expression& get_default_expression(charT) +const basic_regex& get_default_expression(charT) { static const charT expression_text[4] = { '\\', 's', '+', '\00', }; - static const reg_expression e(expression_text); + static const basic_regex e(expression_text); return e; } -template +template class split_pred { typedef std::basic_string string_type; @@ -50,12 +50,12 @@ public: split_pred(iterator_type* a, OutputIterator* b, std::size_t* c) : p_last(a), p_out(b), p_max(c), initial_max(*c) {} - bool operator()(const match_results& what); + bool operator()(const match_results& what); }; -template -bool split_pred::operator() - (const match_results& what) +template +bool split_pred::operator() + (const match_results& what) { *p_last = what[0].second; if(what.size() > 1) @@ -63,7 +63,7 @@ bool split_pred::operator() // output sub-expressions only: for(unsigned i = 1; i < what.size(); ++i) { - *(*p_out) = static_cast(what[i]); + *(*p_out) = what.str(i); ++(*p_out); if(0 == --*p_max) return false; } @@ -75,7 +75,7 @@ bool split_pred::operator() const sub_match& sub = what[-1]; if((sub.first != sub.second) || (*p_max != initial_max)) { - *(*p_out) = static_cast(sub); + *(*p_out) = sub.str(); ++(*p_out); return --*p_max; } @@ -87,18 +87,18 @@ bool split_pred::operator() } // namespace re_detail -template +template std::size_t regex_split(OutputIterator out, std::basic_string& s, - const reg_expression& e, + const basic_regex& e, match_flag_type flags, std::size_t max_split) { - typedef typename std::basic_string::const_iterator ci_t; - typedef typename detail::rebind_allocator, Alloc2>::type match_allocator; + typedef typename std::basic_string::const_iterator ci_t; + typedef typename match_results::allocator_type match_allocator; ci_t last = s.begin(); std::size_t init_size = max_split; - re_detail::split_pred pred(&last, &out, &max_split); + re_detail::split_pred pred(&last, &out, &max_split); ci_t i, j; i = s.begin(); j = s.end(); @@ -122,10 +122,10 @@ std::size_t regex_split(OutputIterator out, return init_size - max_split; } -template +template inline std::size_t regex_split(OutputIterator out, std::basic_string& s, - const reg_expression& e, + const basic_regex& e, match_flag_type flags = match_default) { return regex_split(out, s, e, flags, UINT_MAX); diff --git a/boost/boost/regex/v4/regex_stack.hpp b/boost/boost/regex/v4/regex_stack.hpp index a22b531f0c..453df203a0 100644 --- a/boost/boost/regex/v4/regex_stack.hpp +++ b/boost/boost/regex/v4/regex_stack.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -177,7 +177,7 @@ void BOOST_REGEX_CALL jstack::pop_aux()const { // make sure that we have a valid item // on TOS: - jm_assert(m_stack->next); + BOOST_ASSERT(m_stack->next); register node* p = m_stack; m_stack = p->next; p->next = unused; diff --git a/boost/boost/regex/v4/regex_synch.hpp b/boost/boost/regex/v4/regex_synch.hpp deleted file mode 100644 index dc1f0743f0..0000000000 --- a/boost/boost/regex/v4/regex_synch.hpp +++ /dev/null @@ -1,210 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * Dr John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - - /* - * LOCATION: see http://www.boost.org for most recent version. - * FILE regex_synch.hpp - * VERSION see - * DESCRIPTION: Thread synchronisation for regex code. - * Note this is an internal header file included - * by regex.hpp, do not include on its own. - */ - -#ifndef BOOST_REGEX_SYNCH_HPP -#define BOOST_REGEX_SYNCH_HPP - -#ifndef BOOST_REGEX_CONFIG_HPP -#include -#endif - -#if defined(BOOST_HAS_THREADS) -# if defined(BOOST_HAS_WINTHREADS) -# include -# elif defined(BOOST_HAS_BETHREADS) -# include -# include -# elif defined(BOOST_HAS_PTHREADS) -# include -# else -# error "Unknown threading API" -# endif -#endif - - -namespace boost{ - namespace re_detail{ - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_PREFIX -#endif - -void BOOST_REGEX_CALL re_init_threads(); -void BOOST_REGEX_CALL re_free_threads(); - -#ifdef BOOST_HAS_THREADS - -# ifdef BOOST_HAS_BETHREADS - -typedef sem_id CRITICAL_SECTION; - -inline void BOOST_REGEX_CALL InitializeCriticalSection(CRITICAL_SECTION* ps) -{ - *ps = create_sem(1, "regex++"); - assert(*ps > 0); -} - -inline void BOOST_REGEX_CALL DeleteCriticalSection(CRITICAL_SECTION* ps) -{ - int t = delete_sem(*ps); - assert(t == B_NO_ERROR); -} - -inline void BOOST_REGEX_CALL EnterCriticalSection(CRITICAL_SECTION* ps) -{ - status_t t = acquire_sem(*ps); - assert(t == B_NO_ERROR); -} - -inline void BOOST_REGEX_CALL LeaveCriticalSection(CRITICAL_SECTION* ps) -{ - status_t t = release_sem(*ps); - assert(t == B_NO_ERROR); -} - -# elif defined(BOOST_HAS_PTHREADS) - -typedef pthread_mutex_t CRITICAL_SECTION; - -inline void BOOST_REGEX_CALL InitializeCriticalSection(CRITICAL_SECTION* ps) -{ - pthread_mutex_init(ps, 0); -} - -inline void BOOST_REGEX_CALL DeleteCriticalSection(CRITICAL_SECTION* ps) -{ - pthread_mutex_destroy(ps); -} - -inline void BOOST_REGEX_CALL EnterCriticalSection(CRITICAL_SECTION* ps) -{ - pthread_mutex_lock(ps); -} - -inline void BOOST_REGEX_CALL LeaveCriticalSection(CRITICAL_SECTION* ps) -{ - pthread_mutex_unlock(ps); -} - -# elif !defined(BOOST_HAS_WINTHREADS) -# error "Unknown threading API" -# endif - -template -class lock_guard -{ - typedef Lock lock_type; -public: - lock_guard(lock_type& m, bool aq = true) - : mut(m), owned(false){ acquire(aq); } - - ~lock_guard() - { acquire(false); } - - void BOOST_REGEX_CALL acquire(bool aq = true) - { - if(aq && !owned) - { - mut.acquire(true); - owned = true; - } - else if(!aq && owned) - { - mut.acquire(false); - owned = false; - } - } -private: - lock_type& mut; - bool owned; - // VC6 warning suppression: - lock_guard& operator=(const lock_guard&); -}; - - -class critical_section -{ -public: - critical_section() - { InitializeCriticalSection(&hmutex);} - - critical_section(const critical_section&) - { InitializeCriticalSection(&hmutex);} - - const critical_section& BOOST_REGEX_CALL operator=(const critical_section&) - {return *this;} - - ~critical_section() - {DeleteCriticalSection(&hmutex);} - -private: - - void BOOST_REGEX_CALL acquire(bool aq) - { if(aq) EnterCriticalSection(&hmutex); - else LeaveCriticalSection(&hmutex); - } - - CRITICAL_SECTION hmutex; - -public: - typedef lock_guard ro_guard; - typedef lock_guard rw_guard; - - friend class lock_guard; -}; - -inline bool BOOST_REGEX_CALL operator==(const critical_section&, const critical_section&) -{ - return false; -} - -inline bool BOOST_REGEX_CALL operator<(const critical_section&, const critical_section&) -{ - return true; -} - -typedef lock_guard cs_guard; - -BOOST_REGEX_DECL extern critical_section* p_re_lock; -BOOST_REGEX_DECL extern unsigned int re_lock_count; - -#define BOOST_REGEX_GUARD(inst) boost::re_detail::critical_section::rw_guard g(inst); - -#else // BOOST_HAS_THREADS - -#define BOOST_REGEX_GUARD(inst) - -#endif // BOOST_HAS_THREADS - -#ifdef BOOST_HAS_ABI_HEADERS -# include BOOST_ABI_SUFFIX -#endif - -} // namespace re_detail -} // namespace boost - -#endif // sentry - - - - - - - diff --git a/boost/boost/regex/v4/regex_token_iterator.hpp b/boost/boost/regex/v4/regex_token_iterator.hpp index e25230b94e..adbb534de4 100644 --- a/boost/boost/regex/v4/regex_token_iterator.hpp +++ b/boost/boost/regex/v4/regex_token_iterator.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 2003 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -23,8 +23,7 @@ #include #if (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\ || BOOST_WORKAROUND(BOOST_MSVC, < 1300) \ - || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) \ - || BOOST_WORKAROUND(__HP_aCC, BOOST_TESTED_AT(55500)) + || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) // // Borland C++ Builder 6, and Visual C++ 6, // can't cope with the array template constructor @@ -47,16 +46,16 @@ namespace boost{ template + class traits> class regex_token_iterator_implementation { - typedef basic_regex regex_type; + typedef basic_regex regex_type; typedef sub_match value_type; match_results what; // current match + BidirectionalIterator base; // start of search area BidirectionalIterator end; // end of search area - const regex_type* pre; // the expression + const regex_type re; // the expression match_flag_type flags; // match flags value_type result; // the current string result int N; // the current sub-expression being enumerated @@ -64,16 +63,17 @@ class regex_token_iterator_implementation public: regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, int sub, match_flag_type f) - : end(last), pre(p), flags(f){ subs.push_back(sub); } + : end(last), re(*p), flags(f){ subs.push_back(sub); } regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const std::vector& v, match_flag_type f) - : end(last), pre(p), flags(f), subs(v){} + : end(last), re(*p), flags(f), subs(v){} +#if !BOOST_WORKAROUND(__HP_aCC, BOOST_TESTED_AT(55500)) #if (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\ || BOOST_WORKAROUND(BOOST_MSVC, < 1300) \ || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) \ || BOOST_WORKAROUND(__HP_aCC, BOOST_TESTED_AT(55500)) template regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const T& submatches, match_flag_type f) - : end(last), pre(p), flags(f) + : end(last), re(*p), flags(f) { // assert that T really is an array: BOOST_STATIC_ASSERT(::boost::is_array::value); @@ -86,7 +86,7 @@ public: #else template regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const int (&submatches)[CN], match_flag_type f) - : end(last), pre(p), flags(f) + : end(last), re(*p), flags(f) { for(std::size_t i = 0; i < CN; ++i) { @@ -94,11 +94,12 @@ public: } } #endif - +#endif bool init(BidirectionalIterator first) { N = 0; - if(regex_search(first, end, what, *pre, flags) == true) + base = first; + if(regex_search(first, end, what, re, flags, base) == true) { N = 0; result = ((subs[N] == -1) ? what.prefix() : what[(int)subs[N]]); @@ -116,7 +117,7 @@ public: bool compare(const regex_token_iterator_implementation& that) { if(this == &that) return true; - return (pre == that.pre) + return (&re.get_data() == &that.re.get_data()) && (end == that.end) && (flags == that.flags) && (N == that.N) @@ -135,10 +136,10 @@ public: result =((subs[N] == -1) ? what.prefix() : what[subs[N]]); return true; } - if(what.prefix().first != what[0].second) - flags |= match_prev_avail; + //if(what.prefix().first != what[0].second) + // flags |= /*match_prev_avail |*/ regex_constants::match_not_bob; BidirectionalIterator last_end(what[0].second); - if(regex_search(last_end, end, what, *pre, ((what[0].first == what[0].second) ? flags | regex_constants::match_not_initial_null : flags))) + if(regex_search(last_end, end, what, re, ((what[0].first == what[0].second) ? flags | regex_constants::match_not_initial_null : flags), base)) { N =0; result =((subs[N] == -1) ? what.prefix() : what[subs[N]]); @@ -154,12 +155,13 @@ public: } return false; } +private: + regex_token_iterator_implementation& operator=(const regex_token_iterator_implementation&); }; template ::value_type, - class traits = regex_traits, - class Allocator = BOOST_DEFAULT_ALLOCATOR(charT) > + class traits = regex_traits > class regex_token_iterator #ifndef BOOST_NO_STD_ITERATOR : public std::iterator< @@ -171,10 +173,10 @@ class regex_token_iterator #endif { private: - typedef regex_token_iterator_implementation impl; + typedef regex_token_iterator_implementation impl; typedef shared_ptr pimpl; public: - typedef basic_regex regex_type; + typedef basic_regex regex_type; typedef sub_match value_type; typedef typename re_detail::regex_iterator_traits::difference_type difference_type; @@ -197,6 +199,7 @@ public: if(!pdata->init(a)) pdata.reset(); } +#if !BOOST_WORKAROUND(__HP_aCC, BOOST_TESTED_AT(55500)) #if (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\ || BOOST_WORKAROUND(BOOST_MSVC, < 1300) \ || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) \ @@ -218,6 +221,7 @@ public: if(!pdata->init(a)) pdata.reset(); } +#endif #endif regex_token_iterator(const regex_token_iterator& that) : pdata(that.pdata) {} @@ -274,6 +278,39 @@ typedef regex_token_iterator wcregex_token_iterator; typedef regex_token_iterator wsregex_token_iterator; #endif +template +inline regex_token_iterator make_regex_token_iterator(const charT* p, const basic_regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_token_iterator(p, p+traits::length(p), e, submatch, m); +} +template +inline regex_token_iterator::const_iterator, charT, traits> make_regex_token_iterator(const std::basic_string& p, const basic_regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_token_iterator::const_iterator, charT, traits>(p.begin(), p.end(), e, submatch, m); +} +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) +template +inline regex_token_iterator make_regex_token_iterator(const charT* p, const basic_regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_token_iterator(p, p+traits::length(p), e, submatch, m); +} +template +inline regex_token_iterator::const_iterator, charT, traits> make_regex_token_iterator(const std::basic_string& p, const basic_regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_token_iterator::const_iterator, charT, traits>(p.begin(), p.end(), e, submatch, m); +} +#endif +template +inline regex_token_iterator make_regex_token_iterator(const charT* p, const basic_regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_token_iterator(p, p+traits::length(p), e, submatch, m); +} +template +inline regex_token_iterator::const_iterator, charT, traits> make_regex_token_iterator(const std::basic_string& p, const basic_regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_token_iterator::const_iterator, charT, traits>(p.begin(), p.end(), e, submatch, m); +} + #if BOOST_WORKAROUND(BOOST_MSVC, == 1310) # pragma warning(pop) #endif diff --git a/boost/boost/regex/v4/regex_traits.hpp b/boost/boost/regex/v4/regex_traits.hpp index 27bd75ba72..93ee9caa25 100644 --- a/boost/boost/regex/v4/regex_traits.hpp +++ b/boost/boost/regex/v4/regex_traits.hpp @@ -1,7 +1,7 @@ /* * - * Copyright (c) 1998-2002 - * Dr John Maddock + * Copyright (c) 2003 + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -19,1180 +19,157 @@ #ifndef BOOST_REGEX_TRAITS_HPP_INCLUDED #define BOOST_REGEX_TRAITS_HPP_INCLUDED -#ifndef BOOST_RE_CREGEX_HPP -#include +#ifndef BOOST_REGEX_CONFIG_HPP +#include #endif -#ifndef BOOST_REGEX_CSTRING_HPP -#include +#ifndef BOOST_REGEX_WORKAROUND_HPP +#include +#endif +#ifndef BOOST_REGEX_SYNTAX_TYPE_HPP +#include +#endif +#ifndef BOOST_REGEX_ERROR_TYPE_HPP +#include +#endif +#ifndef BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED +#include +#endif +#ifndef BOOST_NO_STD_LOCALE +# ifndef BOOST_CPP_REGEX_TRAITS_HPP_INCLUDED +# include +# endif +#endif +#if !BOOST_WORKAROUND(__BORLANDC__, < 0x560) +# ifndef BOOST_C_REGEX_TRAITS_HPP_INCLUDED +# include +# endif +#endif +#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) +# ifndef BOOST_W32_REGEX_TRAITS_HPP_INCLUDED +# include +# endif +#endif +#ifndef BOOST_REGEX_FWD_HPP_INCLUDED +#include #endif -namespace boost{ +#include "boost/mpl/has_xxx.hpp" +#include #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX #endif -template -class c_regex_traits; +namespace boost{ +template +struct regex_traits : public implementationT +{ + regex_traits() : implementationT() {} +}; + +// +// class regex_traits_wrapper. +// this is what our implementation will actually store; +// it provides default implementations of the "optional" +// interfaces that we support, in addition to the +// required "standard" ones: +// namespace re_detail{ - -struct mss -{ - unsigned int id; - const char* what; -}; - -BOOST_REGEX_DECL bool BOOST_REGEX_CALL re_lookup_def_collate_name(std::string& buf, const char* name); -BOOST_REGEX_DECL std::size_t BOOST_REGEX_CALL re_get_default_message(char* buf, std::size_t len, std::size_t id); -extern BOOST_REGEX_DECL const char *re_default_error_messages[]; - -#ifndef BOOST_NO_WREGEX -extern BOOST_REGEX_DECL regex_wchar_type wide_lower_case_map[]; -extern BOOST_REGEX_DECL unsigned short wide_unicode_classes[]; -BOOST_REGEX_DECL bool BOOST_REGEX_CALL is_combining(regex_wchar_type c); -#endif - - -struct BOOST_REGEX_DECL regex_traits_base -{ - enum char_syntax_type - { - syntax_char = 0, - syntax_open_bracket = 1, // ( - syntax_close_bracket = 2, // ) - syntax_dollar = 3, // $ - syntax_caret = 4, // ^ - syntax_dot = 5, // . - syntax_star = 6, // * - syntax_plus = 7, // + - syntax_question = 8, // ? - syntax_open_set = 9, // [ - syntax_close_set = 10, // ] - syntax_or = 11, // | - syntax_slash = 12, // - syntax_hash = 13, // # - syntax_dash = 14, // - - syntax_open_brace = 15, // { - syntax_close_brace = 16, // } - syntax_digit = 17, // 0-9 - syntax_b = 18, // for \b - syntax_B = 19, // for \B - syntax_left_word = 20, // for \< - syntax_right_word = 21, // for \> - syntax_w = 22, // for \w - syntax_W = 23, // for \W - syntax_start_buffer = 24, // for \` - syntax_end_buffer = 25, // for \' - syntax_newline = 26, // for newline alt - syntax_comma = 27, // for {x,y} - - syntax_a = 28, // for \a - syntax_f = 29, // for \f - syntax_n = 30, // for \n - syntax_r = 31, // for \r - syntax_t = 32, // for \t - syntax_v = 33, // for \v - syntax_x = 34, // for \xdd - syntax_c = 35, // for \cx - syntax_colon = 36, // for [:...:] - syntax_equal = 37, // for [=...=] - - // perl ops: - syntax_e = 38, // for \e - syntax_l = 39, // for \l - syntax_L = 40, // for \L - syntax_u = 41, // for \u - syntax_U = 42, // for \U - syntax_s = 43, // for \s - syntax_S = 44, // for \S - syntax_d = 45, // for \d - syntax_D = 46, // for \D - syntax_E = 47, // for \Q\E - syntax_Q = 48, // for \Q\E - syntax_X = 49, // for \X - syntax_C = 50, // for \C - syntax_Z = 51, // for \Z - syntax_G = 52, // for \G - - // new extentions: - syntax_not = 53, // for (?!...) - - syntax_max = 54 - }; -#ifdef __BORLANDC__ -private: - char dummy_member; -#endif -}; - -struct BOOST_REGEX_DECL c_traits_base : public regex_traits_base -{ -public: - enum{ - char_class_none = 0, - char_class_alpha = 0x0001, - char_class_cntrl = 0x0002, - char_class_digit = 0x0004, - char_class_lower = 0x0008, - char_class_punct = 0x0010, - char_class_space = 0x0020, - char_class_upper = 0x0040, - char_class_xdigit = 0x0080, - char_class_blank = 0x0100, - char_class_underscore = 0x4000, - char_class_unicode = 0x8000, - - char_class_alnum = char_class_alpha | char_class_digit, - char_class_graph = char_class_alpha | char_class_digit | char_class_punct | char_class_underscore, - char_class_print = char_class_alpha | char_class_digit | char_class_punct | char_class_underscore | char_class_blank, - char_class_word = char_class_alpha | char_class_digit | char_class_underscore - }; - static std::string BOOST_REGEX_CALL set_message_catalogue(const std::string& s); -protected: -#if defined(__MWERKS__) && __MWERKS__ <= 0x6000 - friend class c_regex_traits; - friend class c_regex_traits; -#endif - - static char regex_message_catalogue[BOOST_REGEX_MAX_PATH]; - enum syntax_map_size - { - map_size = UCHAR_MAX + 1 - }; - - static unsigned char syntax_map[map_size]; - static unsigned short class_map[map_size]; - static char lower_case_map[map_size]; - - static boost::uint_fast32_t BOOST_REGEX_CALL do_lookup_class(const char* p); - static bool BOOST_REGEX_CALL do_lookup_collate(std::string& buf, const char* p); - static void BOOST_REGEX_CALL do_update_ctype(); - static void BOOST_REGEX_CALL do_update_collate(); -public: - static std::string BOOST_REGEX_CALL error_string(unsigned id); - static char* BOOST_REGEX_CALL get_catalogue() { return regex_message_catalogue; } -}; - -} // namespace re_detail - - -template<> -class BOOST_REGEX_DECL c_regex_traits : public re_detail::c_traits_base -{ - typedef re_detail::c_traits_base base_type; -public: - typedef char char_type; - typedef unsigned char uchar_type; - typedef unsigned int size_type; - typedef std::string string_type; - typedef int locale_type; - - static std::size_t BOOST_REGEX_CALL length(const char_type* p) - { - return std::strlen(p); - } - static unsigned int BOOST_REGEX_CALL syntax_type(size_type c) - { - return syntax_map[c]; - } - static char BOOST_REGEX_CALL translate(char c, bool icase) - { - return icase ? lower_case_map[(size_type)(uchar_type)c] : c; - } - static void BOOST_REGEX_CALL transform(std::string& out, const std::string& in); - - static void BOOST_REGEX_CALL transform_primary(std::string& out, const std::string& in); - - static bool BOOST_REGEX_CALL is_separator(char c) - { - return BOOST_REGEX_MAKE_BOOL((c == '\n') || (c == '\r')); - } - - static bool BOOST_REGEX_CALL is_combining(char) - { - return false; - } - - static bool BOOST_REGEX_CALL is_class(char c, boost::uint_fast32_t f) - { - return BOOST_REGEX_MAKE_BOOL(class_map[(size_type)(uchar_type)c] & f); - } - - static int BOOST_REGEX_CALL toi(char c); - static int BOOST_REGEX_CALL toi(const char*& first, const char* last, int radix); - - static boost::uint_fast32_t BOOST_REGEX_CALL lookup_classname(const char* first, const char* last) - { - std::string s(first, last); - return do_lookup_class(s.c_str()); - } - - static bool BOOST_REGEX_CALL lookup_collatename(std::string& buf, const char* first, const char* last) - { - std::string s(first, last); - return do_lookup_collate(buf, s.c_str()); - } - - static locale_type BOOST_REGEX_CALL imbue(locale_type l){ return l; } - locale_type BOOST_REGEX_CALL getloc()const{ return locale_type(); } - void swap(c_regex_traits&){} - - c_regex_traits() - { - init(); - } - ~c_regex_traits() - { - m_free(); - } - struct sentry - { - sentry(const c_regex_traits&) - { c_regex_traits::update(); } - operator void*() { return this; } - }; - static void BOOST_REGEX_CALL update(); -private: - static void BOOST_REGEX_CALL init(); - static void BOOST_REGEX_CALL m_free(); - static c_regex_traits i; - - static unsigned sort_type; - static char sort_delim; -}; - -#ifndef BOOST_NO_WREGEX -template<> -class BOOST_REGEX_DECL c_regex_traits : public re_detail::c_traits_base -{ - typedef re_detail::c_traits_base base_type; -public: - typedef regex_wchar_type char_type; - typedef unsigned short uchar_type; - typedef unsigned int size_type; - typedef std::basic_string string_type; - typedef int locale_type; -#ifndef BOOST_REGEX_HAS_SHORT_WCHAR_T - static std::size_t BOOST_REGEX_CALL length(const char_type* p) - { - return std::wcslen(p); - } +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !BOOST_WORKAROUND(__HP_aCC, BOOST_TESTED_AT(55500)) +BOOST_MPL_HAS_XXX_TRAIT_DEF(boost_extensions_tag) #else - static std::size_t BOOST_REGEX_CALL length(const char_type* p) - { - return std::wcslen(reinterpret_cast(p)); - } +template +struct has_boost_extensions_tag +{ + BOOST_STATIC_CONSTANT(bool, value = false); +}; #endif - static unsigned int BOOST_REGEX_CALL syntax_type(size_type c); - static regex_wchar_type BOOST_REGEX_CALL translate(regex_wchar_type c, bool icase) + +template +struct default_wrapper : public BaseT +{ + typedef typename BaseT::char_type char_type; + std::string error_string(::boost::regex_constants::error_type e)const { - return icase ? ((c < 256) ? re_detail::wide_lower_case_map[(uchar_type)c] : std::towlower(c)) : c; + return ::boost::re_detail::get_default_error_string(e); } - - static void BOOST_REGEX_CALL transform(std::basic_string& out, const std::basic_string& in); - - static void BOOST_REGEX_CALL transform_primary(std::basic_string& out, const std::basic_string& in); - - static bool BOOST_REGEX_CALL is_separator(regex_wchar_type c) + ::boost::regex_constants::syntax_type syntax_type(char_type c)const { - return BOOST_REGEX_MAKE_BOOL((c == L'\n') || (c == L'\r') || (c == (regex_wchar_type)0x2028) || (c == (regex_wchar_type)0x2029)); + return ((c & 0x7f) == c) ? get_default_syntax_type(static_cast(c)) : ::boost::regex_constants::syntax_char; } - - static bool BOOST_REGEX_CALL is_combining(regex_wchar_type c) - { return re_detail::is_combining(c); } - - static bool BOOST_REGEX_CALL is_class(regex_wchar_type c, boost::uint_fast32_t f) + ::boost::regex_constants::escape_syntax_type escape_syntax_type(char_type c)const { - return BOOST_REGEX_MAKE_BOOL(((uchar_type)c < 256) ? (re_detail::wide_unicode_classes[(size_type)(uchar_type)c] & f) : do_iswclass(c, f)); + return ((c & 0x7f) == c) ? get_default_escape_syntax_type(static_cast(c)) : ::boost::regex_constants::escape_type_identity; } - - static int BOOST_REGEX_CALL toi(regex_wchar_type c); - static int BOOST_REGEX_CALL toi(const regex_wchar_type*& first, const regex_wchar_type* last, int radix); - - static boost::uint_fast32_t BOOST_REGEX_CALL lookup_classname(const regex_wchar_type* first, const regex_wchar_type* last); - - static bool BOOST_REGEX_CALL lookup_collatename(std::basic_string& s, const regex_wchar_type* first, const regex_wchar_type* last); - - static locale_type BOOST_REGEX_CALL imbue(locale_type l){ return l; } - locale_type BOOST_REGEX_CALL getloc()const{ return locale_type(); } - void swap(c_regex_traits&){} - c_regex_traits() - { init(); } - ~c_regex_traits() - { m_free(); } - struct sentry + int toi(const char_type*& p1, const char_type* p2, int radix)const { - sentry(const c_regex_traits&) - { c_regex_traits::update(); } - operator void*() { return this; } - }; - static void BOOST_REGEX_CALL update(); - static std::size_t BOOST_REGEX_CALL strnarrow(char *s1, std::size_t len, const regex_wchar_type *s2); - static std::size_t BOOST_REGEX_CALL strwiden(regex_wchar_type *s1, std::size_t len, const char *s2); -private: - static bool BOOST_REGEX_CALL do_iswclass(regex_wchar_type c, boost::uint_fast32_t f); - static void BOOST_REGEX_CALL m_free(); - static void BOOST_REGEX_CALL init(); - static bool BOOST_REGEX_CALL do_lookup_collate(std::basic_string& out, const regex_wchar_type* first, const regex_wchar_type* last); - static c_regex_traits init_; - - static unsigned sort_type; - static regex_wchar_type sort_delim; + return ::boost::re_detail::global_toi(p1, p2, radix, *this); + } + char_type translate(char_type c, bool icase)const + { + return (icase ? this->translate_nocase(c) : this->translate(c)); + } + char_type translate(char_type c)const + { + return BaseT::translate(c); + } + char_type tolower(char_type c)const + { + return ::boost::re_detail::global_lower(c); + } + char_type toupper(char_type c)const + { + return ::boost::re_detail::global_upper(c); + } }; -#ifdef BOOST_REGEX_HAS_SHORT_WCHAR_T -// -// What follows here is Visual Studio specific - it is a thin wrapper -// that redirects calls to c_regex_traits to -// c_regex_traits<__wchar_t>. This allows the library to be built -// so that it supports programs built both with and without /Zc:wchar_t. -// -template<> -class c_regex_traits : public re_detail::c_traits_base +template +struct compute_wrapper_base { - typedef re_detail::c_traits_base base_type; -public: - typedef unsigned short char_type; - typedef unsigned short uchar_type; - typedef unsigned int size_type; - typedef std::basic_string string_type; - typedef int locale_type; - static std::size_t BOOST_REGEX_CALL length(const char_type* p) - { - return c_regex_traits::length( - reinterpret_cast(p)); - } - static unsigned int BOOST_REGEX_CALL syntax_type(size_type c) - { - return c_regex_traits::syntax_type(c); - } - static unsigned short BOOST_REGEX_CALL translate(unsigned short c, bool icase) - { - return c_regex_traits::translate(c, icase); - } - - static void BOOST_REGEX_CALL transform(std::basic_string& out, const std::basic_string& in) - { - c_regex_traits::transform( - reinterpret_cast&>(out), - reinterpret_cast&>(in)); - } - - static void BOOST_REGEX_CALL transform_primary(std::basic_string& out, const std::basic_string& in) - { - c_regex_traits::transform_primary( - reinterpret_cast&>(out), - reinterpret_cast&>(in)); } - - static bool BOOST_REGEX_CALL is_separator(unsigned short c) - { - return c_regex_traits::is_separator(c); - } - - static bool BOOST_REGEX_CALL is_combining(unsigned short c) - { - return c_regex_traits::is_combining(c); - } - - static bool BOOST_REGEX_CALL is_class(unsigned short c, boost::uint_fast32_t f) - { - return c_regex_traits::is_class(c, f); - } - - static int BOOST_REGEX_CALL toi(unsigned short c) - { - return c_regex_traits::toi(c); - } - static int BOOST_REGEX_CALL toi(const unsigned short*& first, const unsigned short* last, int radix) - { - return c_regex_traits::toi( - reinterpret_cast(first), - reinterpret_cast(last), - radix); - } - - static boost::uint_fast32_t BOOST_REGEX_CALL lookup_classname(const unsigned short* first, const unsigned short* last) - { - return c_regex_traits::lookup_classname( - reinterpret_cast(first), - reinterpret_cast(last)); - } - - static bool BOOST_REGEX_CALL lookup_collatename(std::basic_string& s, const unsigned short* first, const unsigned short* last) - { - return c_regex_traits::lookup_collatename( - reinterpret_cast&>(s), - reinterpret_cast(first), - reinterpret_cast(last)); - } - - static locale_type BOOST_REGEX_CALL imbue(locale_type l){ return l; } - locale_type BOOST_REGEX_CALL getloc()const{ return locale_type(); } - - struct sentry - { - sentry(const c_regex_traits&) - { c_regex_traits::update(); } - ~sentry(){} - operator void*() { return this; } - }; - static void BOOST_REGEX_CALL update() - { - c_regex_traits::update(); - } - void swap(c_regex_traits&){} - c_regex_traits(){}; - ~c_regex_traits(){}; - static std::size_t BOOST_REGEX_CALL strnarrow(char *s1, std::size_t len, const unsigned short *s2) - { - return c_regex_traits::strnarrow( - s1, - len, - reinterpret_cast(s2)); - } - static std::size_t BOOST_REGEX_CALL strwiden(unsigned short *s1, std::size_t len, const char *s2) - { - return c_regex_traits::strwiden( - reinterpret_cast(s1), len, s2); - } - -private: - c_regex_traits m_init; - + typedef BaseT type; }; - -#endif // BOOST_REGEX_HAS_SHORT_WCHAR_T - -#endif // wide characters - -#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) - -namespace re_detail{ - -struct BOOST_REGEX_DECL w32_traits_base : public regex_traits_base +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !BOOST_WORKAROUND(__HP_aCC, BOOST_TESTED_AT(55500)) +template +struct compute_wrapper_base { - enum{ - char_class_none = 0, - char_class_alnum = C1_ALPHA | C1_DIGIT, - char_class_alpha = C1_ALPHA, - char_class_cntrl = C1_CNTRL, - char_class_digit = C1_DIGIT, - char_class_graph = C1_UPPER | C1_LOWER | C1_DIGIT | C1_PUNCT | C1_ALPHA, - char_class_lower = C1_LOWER, - char_class_print = C1_UPPER | C1_LOWER | C1_DIGIT | C1_PUNCT | C1_BLANK | C1_ALPHA, - char_class_punct = C1_PUNCT, - char_class_space = C1_SPACE, - char_class_upper = C1_UPPER, - char_class_xdigit = C1_XDIGIT, - char_class_blank = C1_BLANK, - char_class_underscore = 0x4000, - char_class_word = C1_ALPHA | C1_DIGIT | char_class_underscore, - char_class_unicode = 0x8000, - char_class_win = 0x01FF - }; - - -public: - static std::string BOOST_REGEX_CALL set_message_catalogue(const std::string& s); -protected: - static char regex_message_catalogue[BOOST_REGEX_MAX_PATH]; - enum syntax_map_size - { - map_size = UCHAR_MAX + 1 - }; - - static unsigned char syntax_map[map_size]; - static unsigned short class_map[map_size]; - static char lower_case_map[map_size]; - - static boost::uint_fast32_t BOOST_REGEX_CALL do_lookup_class(const char* p); - static bool BOOST_REGEX_CALL do_lookup_collate(std::string& buf, const char* p); - static void BOOST_REGEX_CALL do_free(); - static void BOOST_REGEX_CALL do_init(); -public: - static std::string BOOST_REGEX_CALL error_string(unsigned id); - static char* BOOST_REGEX_CALL get_catalogue() { return regex_message_catalogue; } + typedef default_wrapper type; }; - - -} // namespace re_detail - -template -class w32_regex_traits; - -template<> -class BOOST_REGEX_DECL w32_regex_traits : public re_detail::w32_traits_base -{ - typedef re_detail::w32_traits_base base_type; -public: - typedef char char_type; - typedef unsigned char uchar_type; - typedef unsigned int size_type; - typedef std::string string_type; - typedef int locale_type; - - static std::size_t BOOST_REGEX_CALL length(const char_type* p) - { - return std::strlen(p); - } - static unsigned int BOOST_REGEX_CALL syntax_type(size_type c) - { - return syntax_map[c]; - } - static char BOOST_REGEX_CALL translate(char c, bool icase) - { - return icase ? lower_case_map[(size_type)(uchar_type)c] : c; - } - static void BOOST_REGEX_CALL transform(std::string& out, const std::string& in); - - static void BOOST_REGEX_CALL transform_primary(std::string& out, const std::string& in); - - static bool BOOST_REGEX_CALL is_separator(char c) - { - return BOOST_REGEX_MAKE_BOOL((c == '\n') || (c == '\r')); - } - - static bool BOOST_REGEX_CALL is_combining(char) - { - return false; - } - - static bool BOOST_REGEX_CALL is_class(char c, boost::uint_fast32_t f) - { - return BOOST_REGEX_MAKE_BOOL(class_map[(size_type)(uchar_type)c] & f); - } - - static int BOOST_REGEX_CALL toi(char c); - static int BOOST_REGEX_CALL toi(const char*& first, const char* last, int radix); - - static boost::uint_fast32_t BOOST_REGEX_CALL lookup_classname(const char* first, const char* last) - { - std::string s(first, last); - return do_lookup_class(s.c_str()); - } - - static bool BOOST_REGEX_CALL lookup_collatename(std::string& buf, const char* first, const char* last) - { - std::string s(first, last); - return do_lookup_collate(buf, s.c_str()); - } - - static locale_type BOOST_REGEX_CALL imbue(locale_type l){ return l; } - locale_type BOOST_REGEX_CALL getloc()const{ return locale_type(); } - - struct sentry - { - sentry(const w32_regex_traits&) - { w32_regex_traits::update(); } - ~sentry(){} - operator void*() { return this; } - }; - static void BOOST_REGEX_CALL update(); - void swap(w32_regex_traits&){} - w32_regex_traits(); - ~w32_regex_traits(); -private: - static w32_regex_traits i; -}; - -#ifndef BOOST_NO_WREGEX -template<> -class BOOST_REGEX_DECL w32_regex_traits : public re_detail::w32_traits_base -{ - typedef re_detail::w32_traits_base base_type; -public: - typedef regex_wchar_type char_type; - typedef unsigned short uchar_type; - typedef unsigned int size_type; - typedef std::basic_string string_type; - typedef int locale_type; -#ifndef BOOST_REGEX_HAS_SHORT_WCHAR_T - static std::size_t BOOST_REGEX_CALL length(const char_type* p) - { - return std::wcslen(p); - } #else - static std::size_t BOOST_REGEX_CALL length(const char_type* p) - { - return std::wcslen(reinterpret_cast(p)); - } -#endif - static unsigned int BOOST_REGEX_CALL syntax_type(size_type c); - static regex_wchar_type BOOST_REGEX_CALL translate(regex_wchar_type c, bool icase) - { - return icase ? ((c < 256) ? re_detail::wide_lower_case_map[(uchar_type)c] : wtolower(c)) : c; - } - - static void BOOST_REGEX_CALL transform(std::basic_string& out, const std::basic_string& in); - - static void BOOST_REGEX_CALL transform_primary(std::basic_string& out, const std::basic_string& in); - - static bool BOOST_REGEX_CALL is_separator(regex_wchar_type c) - { - return BOOST_REGEX_MAKE_BOOL((c == L'\n') || (c == L'\r') || (c == (regex_wchar_type)0x2028) || (c == (regex_wchar_type)0x2029)); - } - - static bool BOOST_REGEX_CALL is_combining(regex_wchar_type c) - { return re_detail::is_combining(c); } - - static bool BOOST_REGEX_CALL is_class(regex_wchar_type c, boost::uint_fast32_t f) - { - return BOOST_REGEX_MAKE_BOOL(((uchar_type)c < 256) ? (wide_unicode_classes[(size_type)(uchar_type)c] & f) : do_iswclass(c, f)); - } - - static int BOOST_REGEX_CALL toi(regex_wchar_type c); - static int BOOST_REGEX_CALL toi(const regex_wchar_type*& first, const regex_wchar_type* last, int radix); - - static boost::uint_fast32_t BOOST_REGEX_CALL lookup_classname(const regex_wchar_type* first, const regex_wchar_type* last); - - static bool BOOST_REGEX_CALL lookup_collatename(std::basic_string& s, const regex_wchar_type* first, const regex_wchar_type* last); - - static locale_type BOOST_REGEX_CALL imbue(locale_type l){ return l; } - locale_type BOOST_REGEX_CALL getloc()const{ return locale_type(); } - - struct sentry - { - sentry(const w32_regex_traits&) - { w32_regex_traits::update(); } - ~sentry(){} - operator void*() { return this; } - }; - static void BOOST_REGEX_CALL update(); - void swap(w32_regex_traits&){} - w32_regex_traits(); - ~w32_regex_traits(); - static std::size_t BOOST_REGEX_CALL strnarrow(char *s1, std::size_t len, const regex_wchar_type *s2); - static std::size_t BOOST_REGEX_CALL strwiden(regex_wchar_type *s1, std::size_t len, const char *s2); - -private: - static bool BOOST_REGEX_CALL do_iswclass(regex_wchar_type c, boost::uint_fast32_t f); - static bool BOOST_REGEX_CALL do_lookup_collate(std::basic_string& out, const regex_wchar_type* first, const regex_wchar_type* last); - static w32_regex_traits init_; - static regex_wchar_type BOOST_REGEX_CALL wtolower(regex_wchar_type c); - static unsigned short wide_unicode_classes[]; -}; - -#ifdef BOOST_REGEX_HAS_SHORT_WCHAR_T -// -// What follows here is Visual Studio specific - it is a thin wrapper -// that redirects calls to w32_regex_traits to -// w32_regex_traits<__wchar_t>. This allows the library to be built -// so that it supports programs built both with and without /Zc:wchar_t. -// -template<> -class w32_regex_traits : public re_detail::w32_traits_base -{ - typedef re_detail::w32_traits_base base_type; -public: - typedef unsigned short char_type; - typedef unsigned short uchar_type; - typedef unsigned int size_type; - typedef std::basic_string string_type; - typedef int locale_type; - static std::size_t BOOST_REGEX_CALL length(const char_type* p) - { - return w32_regex_traits::length( - reinterpret_cast(p)); - } - static unsigned int BOOST_REGEX_CALL syntax_type(size_type c) - { - return w32_regex_traits::syntax_type(c); - } - static unsigned short BOOST_REGEX_CALL translate(unsigned short c, bool icase) - { - return w32_regex_traits::translate(c, icase); - } - - static void BOOST_REGEX_CALL transform(std::basic_string& out, const std::basic_string& in) - { - w32_regex_traits::transform( - reinterpret_cast&>(out), - reinterpret_cast&>(in)); - } - - static void BOOST_REGEX_CALL transform_primary(std::basic_string& out, const std::basic_string& in) - { - w32_regex_traits::transform_primary( - reinterpret_cast&>(out), - reinterpret_cast&>(in)); } - - static bool BOOST_REGEX_CALL is_separator(unsigned short c) - { - return w32_regex_traits::is_separator(c); - } - - static bool BOOST_REGEX_CALL is_combining(unsigned short c) - { - return w32_regex_traits::is_combining(c); - } - - static bool BOOST_REGEX_CALL is_class(unsigned short c, boost::uint_fast32_t f) - { - return w32_regex_traits::is_class(c, f); - } - - static int BOOST_REGEX_CALL toi(unsigned short c) - { - return w32_regex_traits::toi(c); - } - static int BOOST_REGEX_CALL toi(const unsigned short*& first, const unsigned short* last, int radix) - { - return w32_regex_traits::toi( - reinterpret_cast(first), - reinterpret_cast(last), - radix); - } - - static boost::uint_fast32_t BOOST_REGEX_CALL lookup_classname(const unsigned short* first, const unsigned short* last) - { - return w32_regex_traits::lookup_classname( - reinterpret_cast(first), - reinterpret_cast(last)); - } - - static bool BOOST_REGEX_CALL lookup_collatename(std::basic_string& s, const unsigned short* first, const unsigned short* last) - { - return w32_regex_traits::lookup_collatename( - reinterpret_cast&>(s), - reinterpret_cast(first), - reinterpret_cast(last)); - } - - static locale_type BOOST_REGEX_CALL imbue(locale_type l){ return l; } - locale_type BOOST_REGEX_CALL getloc()const{ return locale_type(); } - - struct sentry - { - sentry(const w32_regex_traits&) - { w32_regex_traits::update(); } - ~sentry(){} - operator void*() { return this; } - }; - static void BOOST_REGEX_CALL update() - { - w32_regex_traits::update(); - } - void swap(w32_regex_traits&){} - w32_regex_traits(){}; - ~w32_regex_traits(){}; - static std::size_t BOOST_REGEX_CALL strnarrow(char *s1, std::size_t len, const unsigned short *s2) - { - return w32_regex_traits::strnarrow( - s1, - len, - reinterpret_cast(s2)); - } - static std::size_t BOOST_REGEX_CALL strwiden(unsigned short *s1, std::size_t len, const char *s2) - { - return w32_regex_traits::strwiden( - reinterpret_cast(s1), len, s2); - } - -private: - w32_regex_traits m_init; - -}; - -#endif // BOOST_REGEX_HAS_SHORT_WCHAR_T - -#endif // Wide strings -#endif // Win32 - -#if !defined(BOOST_NO_STD_LOCALE) - -namespace re_detail -{ - -template -struct message_data; - template <> -struct message_data; - -template <> -struct message_data; - -struct BOOST_REGEX_DECL cpp_regex_traits_base : public regex_traits_base +struct compute_wrapper_base, false> { - enum char_class_type - { - char_class_none = 0, - char_class_alnum = std::ctype_base::alnum, - char_class_alpha = std::ctype_base::alpha, - char_class_cntrl = std::ctype_base::cntrl, - char_class_digit = std::ctype_base::digit, - char_class_graph = std::ctype_base::graph, - char_class_lower = std::ctype_base::lower, - char_class_print = std::ctype_base::print, - char_class_punct = std::ctype_base::punct, - char_class_space = std::ctype_base::space, - char_class_upper = std::ctype_base::upper, - char_class_xdigit = std::ctype_base::xdigit, - char_class_blank = 1<<12, - char_class_underscore = 1<<13, - char_class_word = std::ctype_base::alnum | char_class_underscore, - char_class_unicode = 1<<14, - char_class_all_base = char_class_alnum | char_class_alpha | char_class_cntrl - | char_class_digit | char_class_graph | char_class_lower - | char_class_print | char_class_punct | char_class_space - | char_class_upper | char_class_xdigit - }; - - static std::string BOOST_REGEX_CALL set_message_catalogue(const std::string& s); -protected: - static char regex_message_cat[BOOST_REGEX_MAX_PATH]; + typedef default_wrapper > type; }; +#ifndef BOOST_NO_WREGEX +template <> +struct compute_wrapper_base, false> +{ + typedef default_wrapper > type; +}; +#endif +#endif } // namespace re_detail -template -class cpp_regex_traits; - -template<> -class BOOST_REGEX_DECL cpp_regex_traits : public re_detail::cpp_regex_traits_base +template +struct regex_traits_wrapper + : public ::boost::re_detail::compute_wrapper_base< + BaseT, + ::boost::re_detail::has_boost_extensions_tag::value + >::type { - typedef re_detail::cpp_regex_traits_base base_type; + regex_traits_wrapper(){} private: - re_detail::message_data* pmd; - const unsigned char* psyntax; - char* lower_map; - const std::ctype* pctype; - const std::collate* pcollate; - std::locale locale_inst; - unsigned sort_type; - char sort_delim; - - cpp_regex_traits(const cpp_regex_traits&); - cpp_regex_traits& operator=(const cpp_regex_traits&); - -public: - typedef char char_type; - typedef unsigned char uchar_type; - typedef unsigned int size_type; - typedef std::string string_type; - typedef std::locale locale_type; - - cpp_regex_traits(); - ~cpp_regex_traits(); - - static std::size_t BOOST_REGEX_CALL length(const char_type* p) - { - return std::strlen(p); - } - unsigned int BOOST_REGEX_CALL syntax_type(size_type c)const - { - return psyntax[c]; - } - char BOOST_REGEX_CALL translate(char c, bool icase)const - { - return icase ? lower_map[(size_type)(uchar_type)c] : c; - } - void BOOST_REGEX_CALL transform(std::string& out, const std::string& in)const - { - out = pcollate->transform(in.c_str(), in.c_str() + in.size()).c_str(); - } - - void BOOST_REGEX_CALL transform_primary(std::string& out, const std::string& in)const; - - static bool BOOST_REGEX_CALL is_separator(char c) - { - return BOOST_REGEX_MAKE_BOOL((c == '\n') || (c == '\r')); - } - - static bool BOOST_REGEX_CALL is_combining(char) - { - return false; - } - - bool BOOST_REGEX_CALL is_class(char c, boost::uint_fast32_t f)const - { - if(pctype->is((std::ctype::mask)(f & char_class_all_base), c)) - return true; - if((f & char_class_underscore) && (c == '_')) - return true; - if((f & char_class_blank) && ((c == ' ') || (c == '\t'))) - return true; - return false; - } - - int BOOST_REGEX_CALL toi(char c)const; - int BOOST_REGEX_CALL toi(const char*& first, const char* last, int radix)const; - - boost::uint_fast32_t BOOST_REGEX_CALL lookup_classname(const char* first, const char* last)const; - bool BOOST_REGEX_CALL lookup_collatename(std::string& s, const char* first, const char* last)const; - - std::string BOOST_REGEX_CALL error_string(unsigned id)const; - locale_type BOOST_REGEX_CALL imbue(locale_type l); - locale_type BOOST_REGEX_CALL getloc()const{ return locale_inst; } - void swap(cpp_regex_traits&); - - struct sentry - { - sentry(const cpp_regex_traits&){} - operator void*() { return this; } - }; + regex_traits_wrapper(const regex_traits_wrapper&); + regex_traits_wrapper& operator=(const regex_traits_wrapper&); }; -#if !defined(BOOST_NO_WREGEX) && !defined(BOOST_NO_STD_WSTREAMBUF) -template<> -class BOOST_REGEX_DECL cpp_regex_traits : public re_detail::cpp_regex_traits_base -{ - typedef re_detail::cpp_regex_traits_base base_type; -public: - typedef regex_wchar_type char_type; - typedef unsigned short uchar_type; - typedef unsigned int size_type; - typedef std::basic_string string_type; - typedef std::locale locale_type; - -private: - re_detail::message_data* pmd; - const unsigned char* psyntax; - regex_wchar_type* lower_map; - const std::ctype* pctype; - const std::collate* pcollate; - const std::codecvt* pcdv; - std::locale locale_inst; - unsigned int BOOST_REGEX_CALL do_syntax_type(size_type c)const; - unsigned sort_type; - regex_wchar_type sort_delim; - - cpp_regex_traits(const cpp_regex_traits&); - cpp_regex_traits& operator=(const cpp_regex_traits&); - -public: -#ifndef BOOST_REGEX_HAS_SHORT_WCHAR_T - static std::size_t BOOST_REGEX_CALL length(const char_type* p) - { - return std::wcslen(p); - } -#else - static std::size_t BOOST_REGEX_CALL length(const char_type* p) - { - return std::wcslen(reinterpret_cast(p)); - } -#endif - unsigned int BOOST_REGEX_CALL syntax_type(size_type c)const - { - return (c < UCHAR_MAX) ? psyntax[c] : do_syntax_type(c); - } - regex_wchar_type BOOST_REGEX_CALL translate(regex_wchar_type c, bool icase)const - { - return icase ? (((uchar_type)c) <= UCHAR_MAX) ? lower_map[c] : pctype->tolower(c) : c; - } - void BOOST_REGEX_CALL transform(std::basic_string& out, const std::basic_string& in)const - { - out = pcollate->transform(in.c_str(), in.c_str() + in.size()); - } - - void BOOST_REGEX_CALL transform_primary(std::basic_string& out, const std::basic_string& in)const; - - static bool BOOST_REGEX_CALL is_separator(regex_wchar_type c) - { - return BOOST_REGEX_MAKE_BOOL((c == L'\n') || (c == L'\r') || (c == (regex_wchar_type)0x2028) || (c == (regex_wchar_type)0x2029)); - } - - static bool BOOST_REGEX_CALL is_combining(regex_wchar_type c) - { return re_detail::is_combining(c); } - - bool BOOST_REGEX_CALL is_class(regex_wchar_type c, boost::uint_fast32_t f)const - { - if(pctype->is((std::ctype::mask)(f & char_class_all_base), c)) - return true; - if((f & char_class_underscore) && (c == '_')) - return true; - if((f & char_class_blank) && ((c == ' ') || (c == '\t'))) - return true; - if((f & char_class_unicode) && ((uchar_type)c > (uchar_type)255)) - return true; - return false; - } - - int BOOST_REGEX_CALL toi(regex_wchar_type c)const; - int BOOST_REGEX_CALL toi(const regex_wchar_type*& first, const regex_wchar_type* last, int radix)const; - - boost::uint_fast32_t BOOST_REGEX_CALL lookup_classname(const regex_wchar_type* first, const regex_wchar_type* last)const; - bool BOOST_REGEX_CALL lookup_collatename(std::basic_string& s, const regex_wchar_type* first, const regex_wchar_type* last)const; - - std::string BOOST_REGEX_CALL error_string(unsigned id)const; - void swap(cpp_regex_traits&); - cpp_regex_traits(); - ~cpp_regex_traits(); - locale_type BOOST_REGEX_CALL imbue(locale_type l); - locale_type BOOST_REGEX_CALL getloc()const{ return locale_inst; } - std::size_t BOOST_REGEX_CALL strwiden(regex_wchar_type *s1, std::size_t len, const char *s2)const; - - struct sentry - { - sentry(const cpp_regex_traits&){} - operator void*() { return this; } - }; -}; - -#ifdef BOOST_REGEX_HAS_SHORT_WCHAR_T -// -// What follows here is Visual Studio specific - it is a thin wrapper -// that redirects calls to cpp_regex_traits to -// cpp_regex_traits<__wchar_t>. This allows the library to be built -// so that it supports programs built both with and without /Zc:wchar_t. -// -template<> -class cpp_regex_traits : public re_detail::cpp_regex_traits_base -{ - typedef re_detail::cpp_regex_traits_base base_type; -public: - typedef unsigned short char_type; - typedef unsigned short uchar_type; - typedef unsigned int size_type; - typedef std::basic_string string_type; - typedef std::locale locale_type; - static std::size_t BOOST_REGEX_CALL length(const char_type* p) - { - return cpp_regex_traits::length( - reinterpret_cast(p)); - } - unsigned int BOOST_REGEX_CALL syntax_type(size_type c)const - { - return m_imp.syntax_type(c); - } - unsigned short BOOST_REGEX_CALL translate(unsigned short c, bool icase)const - { - return m_imp.translate(c, icase); - } - - void BOOST_REGEX_CALL transform(std::basic_string& out, const std::basic_string& in)const - { - m_imp.transform( - reinterpret_cast&>(out), - reinterpret_cast&>(in)); - } - - void BOOST_REGEX_CALL transform_primary(std::basic_string& out, const std::basic_string& in)const - { - m_imp.transform_primary( - reinterpret_cast&>(out), - reinterpret_cast&>(in)); } - - static bool BOOST_REGEX_CALL is_separator(unsigned short c) - { - return cpp_regex_traits::is_separator(c); - } - - static bool BOOST_REGEX_CALL is_combining(unsigned short c) - { - return cpp_regex_traits::is_combining(c); - } - - bool BOOST_REGEX_CALL is_class(unsigned short c, boost::uint_fast32_t f)const - { - return m_imp.is_class(c, f); - } - - int BOOST_REGEX_CALL toi(unsigned short c)const - { - return m_imp.toi(c); - } - int BOOST_REGEX_CALL toi(const unsigned short*& first, const unsigned short* last, int radix)const - { - return m_imp.toi( - reinterpret_cast(first), - reinterpret_cast(last), - radix); - } - - boost::uint_fast32_t BOOST_REGEX_CALL lookup_classname(const unsigned short* first, const unsigned short* last)const - { - return m_imp.lookup_classname( - reinterpret_cast(first), - reinterpret_cast(last)); - } - - bool BOOST_REGEX_CALL lookup_collatename(std::basic_string& s, const unsigned short* first, const unsigned short* last)const - { - return m_imp.lookup_collatename( - reinterpret_cast&>(s), - reinterpret_cast(first), - reinterpret_cast(last)); - } - - locale_type BOOST_REGEX_CALL imbue(locale_type l) - { - return m_imp.imbue(l); - } - locale_type BOOST_REGEX_CALL getloc()const - { - return m_imp.getloc(); - } - - struct sentry - { - sentry(const cpp_regex_traits&){} - operator void*() { return this; } - }; - void swap(cpp_regex_traits& that) - { - m_imp.swap(that.m_imp); - } - cpp_regex_traits(){}; - ~cpp_regex_traits(){}; - std::size_t BOOST_REGEX_CALL strwiden(unsigned short *s1, std::size_t len, const char *s2)const - { - return m_imp.strwiden( - reinterpret_cast(s1), len, s2); - } - std::string BOOST_REGEX_CALL error_string(unsigned id)const - { - return m_imp.error_string(id); - } - -private: - cpp_regex_traits m_imp; - -}; - -#endif // BOOST_REGEX_HAS_SHORT_WCHAR_T -#endif // BOOST_NO_WREGEX - -#endif // BOOST_NO_STD_LOCALE - -#ifdef BOOST_REGEX_USE_WIN32_LOCALE - -template -class regex_traits : public w32_regex_traits -{ -}; - -#elif defined(BOOST_REGEX_USE_C_LOCALE) - -template -class regex_traits : public c_regex_traits -{ -}; - -#elif defined(BOOST_REGEX_USE_CPP_LOCALE) - -template -class regex_traits : public cpp_regex_traits -{ -}; - -#else -#error No default localisation model defined -#endif +} // namespace boost #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_SUFFIX #endif -} // namespace boost - #endif // include - - - - - - - diff --git a/boost/boost/regex/v4/regex_traits_defaults.hpp b/boost/boost/regex/v4/regex_traits_defaults.hpp new file mode 100644 index 0000000000..095c2b350e --- /dev/null +++ b/boost/boost/regex/v4/regex_traits_defaults.hpp @@ -0,0 +1,313 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_traits_defaults.hpp + * VERSION see + * DESCRIPTION: Declares API's for access to regex_traits default properties. + */ + +#ifndef BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED +#define BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +#ifndef BOOST_REGEX_SYNTAX_TYPE_HPP +#include +#endif +#ifndef BOOST_REGEX_ERROR_TYPE_HPP +#include +#endif + +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std{ + using ::strlen; +} +#endif + +namespace boost{ namespace re_detail{ + + +// +// helpers to suppress warnings: +// +template +inline bool is_extended(charT c) +{ return c > 256; } +inline bool is_extended(char) +{ return false; } + + +BOOST_REGEX_DECL const char* BOOST_REGEX_CALL get_default_syntax(regex_constants::syntax_type n); +BOOST_REGEX_DECL const char* BOOST_REGEX_CALL get_default_error_string(regex_constants::error_type n); +BOOST_REGEX_DECL regex_constants::syntax_type BOOST_REGEX_CALL get_default_syntax_type(char c); +BOOST_REGEX_DECL regex_constants::escape_syntax_type BOOST_REGEX_CALL get_default_escape_syntax_type(char c); + +// is charT c a combining character? +BOOST_REGEX_DECL bool BOOST_REGEX_CALL is_combining_implementation(uint_least16_t s); + +template +inline bool is_combining(charT c) +{ + return (c <= static_cast(0)) ? false : ((c >= static_cast((std::numeric_limits::max)())) ? false : is_combining_implementation(static_cast(c))); +} +template <> +inline bool is_combining(char) +{ + return false; +} +template <> +inline bool is_combining(signed char) +{ + return false; +} +template <> +inline bool is_combining(unsigned char) +{ + return false; +} +#ifndef __HP_aCC +#ifdef _MSC_VER +template<> +inline bool is_combining(wchar_t c) +{ + return is_combining_implementation(static_cast(c)); +} +#elif !defined(__DECCXX) && !defined(__osf__) && !defined(__OSF__) && defined(WCHAR_MIN) && (WCHAR_MIN == 0) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) +#if defined(WCHAR_MAX) && (WCHAR_MAX <= USHRT_MAX) +template<> +inline bool is_combining(wchar_t c) +{ + return is_combining_implementation(static_cast(c)); +} +#else +template<> +inline bool is_combining(wchar_t c) +{ + return (c >= (std::numeric_limits::max)()) ? false : is_combining_implementation(static_cast(c)); +} +#endif +#endif +#endif + +// +// is a charT c a line separator? +// +template +inline bool is_separator(charT c) +{ + return BOOST_REGEX_MAKE_BOOL( + (c == static_cast('\n')) + || (c == static_cast('\r')) + || (c == static_cast('\f')) + || (static_cast(c) == 0x2028u) + || (static_cast(c) == 0x2029u) + || (static_cast(c) == 0x85u)); +} +template <> +inline bool is_separator(char c) +{ + return BOOST_REGEX_MAKE_BOOL((c == '\n') || (c == '\r') || (c == '\f')); +} + +// +// get a default collating element: +// +BOOST_REGEX_DECL std::string BOOST_REGEX_CALL lookup_default_collate_name(const std::string& name); + +// +// get the id of a character clasification, the individual +// traits classes then transform that id into a bitmask: +// +template +struct character_pointer_range +{ + const charT* p1; + const charT* p2; + + bool operator < (const character_pointer_range& r)const + { + return std::lexicographical_compare(p1, p2, r.p1, r.p2); + } + bool operator == (const character_pointer_range& r)const + { + return ((p2 - p1) == (r.p2 - r.p1)) && std::equal(p1, p2, r.p1); + } +}; +template +int get_default_class_id(const charT* p1, const charT* p2) +{ + static const charT data[72] = { + 'a', 'l', 'n', 'u', 'm', + 'a', 'l', 'p', 'h', 'a', + 'b', 'l', 'a', 'n', 'k', + 'c', 'n', 't', 'r', 'l', + 'd', 'i', 'g', 'i', 't', + 'g', 'r', 'a', 'p', 'h', + 'l', 'o', 'w', 'e', 'r', + 'p', 'r', 'i', 'n', 't', + 'p', 'u', 'n', 'c', 't', + 's', 'p', 'a', 'c', 'e', + 'u', 'n', 'i', 'c', 'o', 'd', 'e', + 'u', 'p', 'p', 'e', 'r', + 'w', 'o', 'r', 'd', + 'x', 'd', 'i', 'g', 'i', 't', + }; + + static const character_pointer_range ranges[19] = + { + {data+0, data+5,}, // alnum + {data+5, data+10,}, // alpha + {data+10, data+15,}, // blank + {data+15, data+20,}, // cntrl + {data+20, data+21,}, // d + {data+20, data+25,}, // digit + {data+25, data+30,}, // graph + {data+30, data+31,}, // l + {data+30, data+35,}, // lower + {data+35, data+40,}, // print + {data+40, data+45,}, // punct + {data+45, data+46,}, // s + {data+45, data+50,}, // space + {data+57, data+58,}, // u + {data+50, data+57,}, // unicode + {data+57, data+62,}, // upper + {data+62, data+63,}, // w + {data+62, data+66,}, // word + {data+66, data+72,}, // xdigit + }; + static const character_pointer_range* ranges_begin = ranges; + static const character_pointer_range* ranges_end = ranges + (sizeof(ranges)/sizeof(ranges[0])); + + character_pointer_range t = { p1, p2, }; + const character_pointer_range* p = std::lower_bound(ranges_begin, ranges_end, t); + if((p != ranges_end) && (t == *p)) + return static_cast(p - ranges); + return -1; +} + +// +// helper functions: +// +template +std::ptrdiff_t global_length(const charT* p) +{ + std::ptrdiff_t n = 0; + while(*p) + { + ++p; + ++n; + } + return n; +} +template<> +inline std::ptrdiff_t global_length(const char* p) +{ + return (std::strlen)(p); +} +#ifndef BOOST_NO_WREGEX +template<> +inline std::ptrdiff_t global_length(const wchar_t* p) +{ + return (std::wcslen)(p); +} +#endif +template +inline charT BOOST_REGEX_CALL global_lower(charT c) +{ + return c; +} +template +inline charT BOOST_REGEX_CALL global_upper(charT c) +{ + return c; +} + +BOOST_REGEX_DECL char BOOST_REGEX_CALL do_global_lower(char c); +BOOST_REGEX_DECL char BOOST_REGEX_CALL do_global_upper(char c); +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL do_global_lower(wchar_t c); +BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL do_global_upper(wchar_t c); +#endif +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL do_global_lower(unsigned short c); +BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL do_global_upper(unsigned short c); +#endif +// +// This sucks: declare template specialisations of global_lower/global_upper +// that just forward to the non-template implementation functions. We do +// this because there is one compiler (Compaq Tru64 C++) that doesn't seem +// to differentiate between templates and non-template overloads.... +// what's more, the primary template, plus all overloads have to be +// defined in the same translation unit (if one is inline they all must be) +// otherwise the "local template instantiation" compiler option can pick +// the wrong instantiation when linking: +// +template<> inline char BOOST_REGEX_CALL global_lower(char c){ return do_global_lower(c); } +template<> inline char BOOST_REGEX_CALL global_upper(char c){ return do_global_upper(c); } +#ifndef BOOST_NO_WREGEX +template<> inline wchar_t BOOST_REGEX_CALL global_lower(wchar_t c){ return do_global_lower(c); } +template<> inline wchar_t BOOST_REGEX_CALL global_upper(wchar_t c){ return do_global_upper(c); } +#endif +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +template<> inline unsigned short BOOST_REGEX_CALL global_lower(unsigned short c){ return do_global_lower(c); } +template<> inline unsigned short BOOST_REGEX_CALL global_upper(unsigned short c){ return do_global_upper(c); } +#endif + +template +int global_value(charT c) +{ + static const charT zero = '0'; + static const charT nine = '9'; + static const charT a = 'a'; + static const charT f = 'f'; + static const charT A = 'A'; + static const charT F = 'F'; + + if(c > f) return -1; + if(c >= a) return 10 + (c - a); + if(c > F) return -1; + if(c >= A) return 10 + (c - A); + if(c > nine) return -1; + if(c >= zero) return c - zero; + return -1; +} +template +int global_toi(const charT*& p1, const charT* p2, int radix, const traits& t) +{ + (void)t; // warning suppression + int next_value = t.value(*p1, radix); + if((p1 == p2) || (next_value < 0) || (next_value >= radix)) + return -1; + int result = 0; + while(p1 != p2) + { + next_value = t.value(*p1, radix); + if((next_value < 0) || (next_value >= radix)) + break; + result *= radix; + result += next_value; + ++p1; + } + return result; +} + +} // re_detail +} // boost + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + +#endif diff --git a/boost/boost/regex/v4/regex_workaround.hpp b/boost/boost/regex/v4/regex_workaround.hpp new file mode 100644 index 0000000000..695e8f65e6 --- /dev/null +++ b/boost/boost/regex/v4/regex_workaround.hpp @@ -0,0 +1,192 @@ +/* + * + * Copyright (c) 1998-2005 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_workarounds.cpp + * VERSION see + * DESCRIPTION: Declares Misc workarounds. + */ + +#ifndef BOOST_REGEX_WORKAROUND_HPP +#define BOOST_REGEX_WORKAROUND_HPP + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef BOOST_NO_STD_LOCALE +# include +#endif + +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::sprintf; using ::strcpy; using ::strcat; using ::strlen; +} +#endif + +namespace boost{ namespace re_detail{ +#ifdef BOOST_NO_STD_DISTANCE +template +std::ptrdiff_t distance(const T& x, const T& y) +{ return y - x; } +#else +using std::distance; +#endif +}} + + +#ifdef BOOST_REGEX_NO_BOOL +# define BOOST_REGEX_MAKE_BOOL(x) static_cast((x) ? true : false) +#else +# ifdef BOOST_MSVC + // warning suppression with VC6: +# pragma warning(disable: 4800) +# pragma warning(disable: 4786) +# endif +# define BOOST_REGEX_MAKE_BOOL(x) static_cast(x) +#endif + +/***************************************************************************** + * + * Fix broken broken namespace support: + * + ****************************************************************************/ + +#if defined(BOOST_NO_STDC_NAMESPACE) && defined(__cplusplus) + +namespace std{ + using ::ptrdiff_t; + using ::size_t; + using ::abs; + using ::memset; + using ::memcpy; +} + +#endif + +/***************************************************************************** + * + * helper functions pointer_construct/pointer_destroy: + * + ****************************************************************************/ + +#ifdef __cplusplus +namespace boost{ namespace re_detail{ + +#ifdef BOOST_MSVC +#pragma warning (push) +#pragma warning (disable : 4100) +#endif + +template +inline void pointer_destroy(T* p) +{ p->~T(); (void)p; } + +#ifdef BOOST_MSVC +#pragma warning (pop) +#endif + +template +inline void pointer_construct(T* p, const T& t) +{ new (p) T(t); } + +}} // namespaces +#endif + +/***************************************************************************** + * + * helper function copy: + * + ****************************************************************************/ + +#ifdef __cplusplus +namespace boost{ namespace re_detail{ +#if BOOST_WORKAROUND(BOOST_MSVC,>=1400) + // + // MSVC 8 will either emit warnings or else refuse to compile + // code that makes perfectly legitimate use of std::copy, when + // the OutputIterator type is a user-defined class (apparently all user + // defined iterators are "unsafe"). This code works around that: + // + template + inline OutputIterator copy( + InputIterator first, + InputIterator last, + OutputIterator dest + ) + { + return stdext::unchecked_copy(first, last, dest); + } + + // use safe versions of strcpy etc: + using ::strcpy_s; + using ::strcat_s; +#else + using std::copy; + + inline std::size_t strcpy_s( + char *strDestination, + std::size_t sizeInBytes, + const char *strSource + ) + { + if(std::strlen(strSource)+1 > sizeInBytes) + return 1; + std::strcpy(strDestination, strSource); + return 0; + } + inline std::size_t strcat_s( + char *strDestination, + std::size_t sizeInBytes, + const char *strSource + ) + { + if(std::strlen(strSource) + std::strlen(strDestination) + 1 > sizeInBytes) + return 1; + std::strcat(strDestination, strSource); + return 0; + } + +#endif + + inline void overflow_error_if_not_zero(std::size_t i) + { + if(i) + { + std::overflow_error e("String buffer too small"); + boost::throw_exception(e); + } + } + +}} // namespaces +#endif + +#endif // include guard + diff --git a/boost/boost/regex/v4/states.hpp b/boost/boost/regex/v4/states.hpp index 1e4e11d648..551ed669a1 100644 --- a/boost/boost/regex/v4/states.hpp +++ b/boost/boost/regex/v4/states.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -36,6 +36,7 @@ enum mask_type { mask_take = 1, mask_skip = 2, + mask_init = 4, mask_any = mask_skip | mask_take, mask_all = mask_any }; @@ -105,7 +106,12 @@ enum syntax_element_type syntax_element_dot_rep = syntax_element_restart_continue + 1, syntax_element_char_rep = syntax_element_dot_rep + 1, syntax_element_short_set_rep = syntax_element_char_rep + 1, - syntax_element_long_set_rep = syntax_element_short_set_rep + 1 + syntax_element_long_set_rep = syntax_element_short_set_rep + 1, + // a backstep for lookbehind repeats: + syntax_element_backstep = syntax_element_long_set_rep + 1, + // an assertion that a mark was matched: + syntax_element_assert_backref = syntax_element_backstep + 1, + syntax_element_toggle_case = syntax_element_assert_backref + 1 }; #ifdef BOOST_REGEX_DEBUG @@ -123,7 +129,7 @@ execution of the machine. union offset_type { re_syntax_base* p; - std::size_t i; + std::ptrdiff_t i; }; /*** struct re_syntax_base ******************************************** @@ -133,11 +139,10 @@ struct re_syntax_base { syntax_element_type type; // what kind of state this is offset_type next; // next state in the machine - unsigned int can_be_null; // true if we match a NULL string }; /*** struct re_brace ************************************************** -Base class for all states in the machine. +A marked parenthesis. ***********************************************************************/ struct re_brace : public re_syntax_base { @@ -146,6 +151,23 @@ struct re_brace : public re_syntax_base int index; }; +/*** struct re_dot ************************************************** +Match anything. +***********************************************************************/ +enum +{ + dont_care = 1, + force_not_newline = 0, + force_newline = 2, + + test_not_newline = 2, + test_newline = 3 +}; +struct re_dot : public re_syntax_base +{ + unsigned char mask; +}; + /*** struct re_literal ************************************************ A string of literals, following this structure will be an array of characters: charT[length] @@ -155,6 +177,14 @@ struct re_literal : public re_syntax_base unsigned int length; }; +/*** struct re_case ************************************************ +Indicates whether we are moving to a case insensive block or not +***********************************************************************/ +struct re_case : public re_syntax_base +{ + bool icase; +}; + /*** struct re_set_long *********************************************** A wide character set of characters, following this structure will be an array of type charT: @@ -162,10 +192,12 @@ First csingles null-terminated strings Then 2 * cranges NULL terminated strings Then cequivalents NULL terminated strings ***********************************************************************/ +template struct re_set_long : public re_syntax_base { unsigned int csingles, cranges, cequivalents; - boost::uint_fast32_t cclasses; + mask_type cclasses; + mask_type cnclasses; bool isnot; bool singleton; }; @@ -175,7 +207,7 @@ A set of narrow-characters, matches any of _map which is none-zero ***********************************************************************/ struct re_set : public re_syntax_base { - unsigned char _map[256]; + unsigned char _map[1 << CHAR_BIT]; }; /*** struct re_jump *************************************************** @@ -183,19 +215,27 @@ Jump to a new location in the machine (not next). ***********************************************************************/ struct re_jump : public re_syntax_base { - offset_type alt; // location to jump to - unsigned char _map[256]; // which characters can take the jump + offset_type alt; // location to jump to +}; + +/*** struct re_alt *************************************************** +Jump to a new location in the machine (possibly next). +***********************************************************************/ +struct re_alt : public re_jump +{ + unsigned char _map[1 << CHAR_BIT]; // which characters can take the jump + unsigned int can_be_null; // true if we match a NULL string }; /*** struct re_repeat ************************************************* Repeat a section of the machine ***********************************************************************/ -struct re_repeat : public re_jump +struct re_repeat : public re_alt { - unsigned min, max; // min and max allowable repeats - int id; // Unique identifier for this repeat - bool leading; // True if this repeat is at the start of the machine (lets us optimize some searches) - bool greedy; // True if this is a greedy repeat + std::size_t min, max; // min and max allowable repeats + int id; // Unique identifier for this repeat + bool leading; // True if this repeat is at the start of the machine (lets us optimize some searches) + bool greedy; // True if this is a greedy repeat }; /*** enum re_jump_size_type ******************************************* @@ -206,17 +246,22 @@ We provide this so we know how manybytes to insert when constructing the machine enum re_jump_size_type { re_jump_size = (sizeof(re_jump) + padding_mask) & ~(padding_mask), - re_repeater_size = (sizeof(re_repeat) + padding_mask) & ~(padding_mask) + re_repeater_size = (sizeof(re_repeat) + padding_mask) & ~(padding_mask), + re_alt_size = (sizeof(re_alt) + padding_mask) & ~(padding_mask) }; /*** proc re_is_set_member ********************************************* Forward declaration: we'll need this one later... ***********************************************************************/ -template + +template +struct regex_data; + +template iterator BOOST_REGEX_CALL re_is_set_member(iterator next, iterator last, - const re_set_long* set_, - const reg_expression& e); + const re_set_long* set_, + const regex_data& e, bool icase); } // namespace re_detail diff --git a/boost/boost/regex/v4/sub_match.hpp b/boost/boost/regex/v4/sub_match.hpp index e67a2f84e2..b21f4fab3e 100644 --- a/boost/boost/regex/v4/sub_match.hpp +++ b/boost/boost/regex/v4/sub_match.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -42,20 +42,30 @@ struct sub_match : public std::pair sub_match() : std::pair(), matched(false) {} sub_match(BidiIterator i) : std::pair(i, i), matched(false) {} - +#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\ + && !BOOST_WORKAROUND(BOOST_MSVC, < 1310)\ + && !BOOST_WORKAROUND(__BORLANDC__, <= 0x0551)\ + && !BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042)) + template + operator std::basic_string ()const + { + return std::basic_string(this->first, this->second); + } +#else operator std::basic_string ()const { return str(); } +#endif difference_type BOOST_REGEX_CALL length()const { - difference_type n = boost::re_detail::distance((BidiIterator)this->first, (BidiIterator)this->second); + difference_type n = ::boost::re_detail::distance((BidiIterator)this->first, (BidiIterator)this->second); return n; } std::basic_string str()const { std::basic_string result; - std::size_t len = boost::re_detail::distance((BidiIterator)this->first, (BidiIterator)this->second); + std::size_t len = ::boost::re_detail::distance((BidiIterator)this->first, (BidiIterator)this->second); result.reserve(len); BidiIterator i = this->first; while(i != this->second) @@ -71,6 +81,14 @@ struct sub_match : public std::pair return static_cast(matched) - static_cast(s.matched); return str().compare(s.str()); } + int compare(const std::basic_string& s)const + { + return str().compare(s); + } + int compare(const value_type* p)const + { + return str().compare(p); + } bool operator==(const sub_match& that)const { return compare(that) == 0; } @@ -154,6 +172,13 @@ public: #endif }; +typedef sub_match csub_match; +typedef sub_match ssub_match; +#ifndef BOOST_NO_WREGEX +typedef sub_match wcsub_match; +typedef sub_match wssub_match; +#endif + // comparison to std::basic_string<> part 1: template inline bool operator == (const std::basic_string::value_type, traits, Allocator>& s, diff --git a/boost/boost/regex/v4/syntax_type.hpp b/boost/boost/regex/v4/syntax_type.hpp new file mode 100644 index 0000000000..92c00d4c55 --- /dev/null +++ b/boost/boost/regex/v4/syntax_type.hpp @@ -0,0 +1,102 @@ +/* + * + * Copyright (c) 2003 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE syntax_type.hpp + * VERSION see + * DESCRIPTION: Declares regular expression synatx type enumerator. + */ + +#ifndef BOOST_REGEX_SYNTAX_TYPE_HPP +#define BOOST_REGEX_SYNTAX_TYPE_HPP + +namespace boost{ +namespace regex_constants{ + +typedef unsigned char syntax_type; + +// +// values chosen are binary compatible with previous version: +// +static const syntax_type syntax_char = 0; +static const syntax_type syntax_open_mark = 1; +static const syntax_type syntax_close_mark = 2; +static const syntax_type syntax_dollar = 3; +static const syntax_type syntax_caret = 4; +static const syntax_type syntax_dot = 5; +static const syntax_type syntax_star = 6; +static const syntax_type syntax_plus = 7; +static const syntax_type syntax_question = 8; +static const syntax_type syntax_open_set = 9; +static const syntax_type syntax_close_set = 10; +static const syntax_type syntax_or = 11; +static const syntax_type syntax_escape = 12; +static const syntax_type syntax_dash = 14; +static const syntax_type syntax_open_brace = 15; +static const syntax_type syntax_close_brace = 16; +static const syntax_type syntax_digit = 17; +static const syntax_type syntax_comma = 27; +static const syntax_type syntax_equal = 37; +static const syntax_type syntax_colon = 36; +static const syntax_type syntax_not = 53; + +// extensions: + +static const syntax_type syntax_hash = 13; +static const syntax_type syntax_newline = 26; + +// escapes: + +typedef syntax_type escape_syntax_type; + +static const escape_syntax_type escape_type_word_assert = 18; +static const escape_syntax_type escape_type_not_word_assert = 19; +static const escape_syntax_type escape_type_control_f = 29; +static const escape_syntax_type escape_type_control_n = 30; +static const escape_syntax_type escape_type_control_r = 31; +static const escape_syntax_type escape_type_control_t = 32; +static const escape_syntax_type escape_type_control_v = 33; +static const escape_syntax_type escape_type_ascii_control = 35; +static const escape_syntax_type escape_type_hex = 34; +static const escape_syntax_type escape_type_unicode = 0; // not used +static const escape_syntax_type escape_type_identity = 0; // not used +static const escape_syntax_type escape_type_backref = syntax_digit; +static const escape_syntax_type escape_type_decimal = syntax_digit; // not used +static const escape_syntax_type escape_type_class = 22; +static const escape_syntax_type escape_type_not_class = 23; + +// extensions: + +static const escape_syntax_type escape_type_left_word = 20; +static const escape_syntax_type escape_type_right_word = 21; +static const escape_syntax_type escape_type_start_buffer = 24; // for \` +static const escape_syntax_type escape_type_end_buffer = 25; // for \' +static const escape_syntax_type escape_type_control_a = 28; // for \a +static const escape_syntax_type escape_type_e = 38; // for \e +static const escape_syntax_type escape_type_E = 47; // for \Q\E +static const escape_syntax_type escape_type_Q = 48; // for \Q\E +static const escape_syntax_type escape_type_X = 49; // for \X +static const escape_syntax_type escape_type_C = 50; // for \C +static const escape_syntax_type escape_type_Z = 51; // for \Z +static const escape_syntax_type escape_type_G = 52; // for \G + +static const escape_syntax_type escape_type_property = 54; // for \p +static const escape_syntax_type escape_type_not_property = 55; // for \P +static const escape_syntax_type escape_type_named_char = 56; // for \N + +static const escape_syntax_type syntax_max = 57; + +} +} + + +#endif diff --git a/boost/boost/regex_fwd.hpp b/boost/boost/regex_fwd.hpp index 21e8ad483a..2ee4a2495f 100644 --- a/boost/boost/regex_fwd.hpp +++ b/boost/boost/regex_fwd.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -13,7 +13,7 @@ * LOCATION: see http://www.boost.org/libs/regex for documentation. * FILE regex_fwd.cpp * VERSION see - * DESCRIPTION: Forward declares boost::reg_expression<> and + * DESCRIPTION: Forward declares boost::basic_regex<> and * associated typedefs. */ @@ -24,11 +24,7 @@ #include #endif -#ifdef BOOST_REGEX_V3 -#include -#else #include -#endif #endif diff --git a/boost/boost/shared_ptr.hpp b/boost/boost/shared_ptr.hpp index 0a3bf6d869..8d6196cadb 100644 --- a/boost/boost/shared_ptr.hpp +++ b/boost/boost/shared_ptr.hpp @@ -121,7 +121,7 @@ public: } template - explicit shared_ptr(Y * p): px(p), pn(p, checked_deleter()) // Y must be complete + explicit shared_ptr( Y * p ): px( p ), pn( p ) // Y must be complete { detail::sp_enable_shared_from_this( pn, p, p ); } @@ -268,7 +268,10 @@ public: return px != 0; } -#elif defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) +#elif \ + ( defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, < 0x3200) ) || \ + ( defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304) ) + typedef T * (this_type::*unspecified_bool_type)() const; operator unspecified_bool_type() const // never throws @@ -442,10 +445,12 @@ template std::basic_ostream & operator<< (std:: // get_deleter (experimental) -#if (defined(__GNUC__) && (__GNUC__ < 3)) || (defined(__EDG_VERSION__) && (__EDG_VERSION__ <= 238)) +#if ( defined(__GNUC__) && BOOST_WORKAROUND(__GNUC__, < 3) ) || \ + ( defined(__EDG_VERSION__) && BOOST_WORKAROUND(__EDG_VERSION__, <= 238) ) || \ + ( defined(__HP_aCC) && BOOST_WORKAROUND(__HP_aCC, <= 33500) ) // g++ 2.9x doesn't allow static_cast(void *) -// apparently EDG 2.38 also doesn't accept it +// apparently EDG 2.38 and HP aCC A.03.35 also don't accept it template D * get_deleter(shared_ptr const & p) { diff --git a/boost/boost/signals/connection.hpp b/boost/boost/signals/connection.hpp index 1be3c439cd..48493aabf9 100644 --- a/boost/boost/signals/connection.hpp +++ b/boost/boost/signals/connection.hpp @@ -53,6 +53,7 @@ namespace boost { void* signal; void* signal_data; void (*signal_disconnect)(void*, void*); + bool blocked_; std::list bound_objects; }; @@ -69,6 +70,12 @@ namespace boost { connection(const connection&); ~connection(); + // Block he connection: if the connection is still active, there + // will be no notification + void block(bool should_block = true) { con->blocked_ = should_block; } + void unblock() { con->blocked_ = false; } + bool blocked() const { return !connected() || con->blocked_; } + // Disconnect the signal and slot, if they are connected void disconnect() const; @@ -87,11 +94,11 @@ namespace boost { public: // TBD: CHANGE THIS // Set whether this connection object is controlling or not - void set_controlling(bool control = true) + void set_controlling(bool control = true) { controlling_connection = control; } shared_ptr - get_connection() const + get_connection() const { return con; } private: @@ -162,6 +169,18 @@ namespace boost { } }; + // Determines if the underlying connection is callable, ie if + // it is connected and not blocked + struct is_callable { + typedef connection_slot_pair argument_type; + typedef bool result_type; + + inline bool operator()(const argument_type& c) const + { + return c.first.connected() && !c.first.blocked() ; + } + }; + // Autodisconnects the bound object when it is destroyed unless the // release method is invoked. class auto_disconnect_bound_object { diff --git a/boost/boost/signals/detail/config.hpp b/boost/boost/signals/detail/config.hpp index d579f38973..bdd6d20ed4 100644 --- a/boost/boost/signals/detail/config.hpp +++ b/boost/boost/signals/detail/config.hpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Copyright (c) 2003-2004 * Douglas Gregor diff --git a/boost/boost/signals/detail/named_slot_map.hpp b/boost/boost/signals/detail/named_slot_map.hpp index a277533558..815406d6d8 100644 --- a/boost/boost/signals/detail/named_slot_map.hpp +++ b/boost/boost/signals/detail/named_slot_map.hpp @@ -13,11 +13,11 @@ #include #include #include -#include -#include #include +#include #include #include +#include #include #include @@ -27,39 +27,50 @@ enum connect_position { at_back, at_front }; namespace detail { -typedef function2 compare_type; +class stored_group +{ + public: + enum storage_kind { sk_empty, sk_front, sk_back, sk_group }; -// Used to delimit the front and back of the list for O(1) insertion. -struct front_type {}; -struct back_type {}; + stored_group(storage_kind kind = sk_empty) : kind(kind), group() { } + + template + stored_group(const T& group) : kind(sk_group), group(new T(group)) { } + + bool is_front() const { return kind == sk_front; } + bool is_back() const { return kind == sk_back; } + bool empty() const { return kind == sk_empty; } + + void* get() const { return group.get(); } + + private: + storage_kind kind; + shared_ptr group; +}; + +typedef function2 compare_type; // This function object bridges from a pair of any objects that hold // values of type Key to the underlying function object that compares // values of type Key. template -class any_bridge_compare { +class group_bridge_compare { public: typedef bool result_type; - typedef const any& first_argument_type; - typedef const any& second_argument_type; + typedef const stored_group& first_argument_type; + typedef const stored_group& second_argument_type; - any_bridge_compare(const Compare& c) : comp(c) {} + group_bridge_compare(const Compare& c) : comp(c) {} - bool operator()(const any& k1, const any& k2) const + bool operator()(const stored_group& k1, const stored_group& k2) const { - if (k1.type() == typeid(front_type)) - return !(k2.type() == typeid(front_type)); - if (k1.type() == typeid(back_type)) - return false; - if (k2.type() == typeid(front_type)) - return false; - if (k2.type() == typeid(back_type)) - return true; + if (k1.is_front()) return !k2.is_front(); + if (k1.is_back()) return false; + if (k2.is_front()) return false; + if (k2.is_back()) return true; // Neither is empty, so compare their values to order them - // The strange */& is so that we will get a reference to the - // value stored in the any object instead of a copy - return comp(*any_cast(&k1), *any_cast(&k2)); + return comp(*static_cast(k1.get()), *static_cast(k2.get())); } private: @@ -71,34 +82,51 @@ class BOOST_SIGNALS_DECL named_slot_map_iterator : connection_slot_pair, forward_traversal_tag> { - class impl; + typedef std::list group_list; + typedef group_list::iterator slot_pair_iterator; + typedef std::map slot_container_type; + typedef slot_container_type::iterator group_iterator; + typedef slot_container_type::const_iterator const_group_iterator; typedef iterator_facade inherited; public: named_slot_map_iterator(); - named_slot_map_iterator(const named_slot_map_iterator& other); - ~named_slot_map_iterator(); - named_slot_map_iterator& operator=(const named_slot_map_iterator& other); + named_slot_map_iterator(const named_slot_map_iterator&); + named_slot_map_iterator& operator=(const named_slot_map_iterator&); connection_slot_pair& dereference() const; void increment(); bool equal(const named_slot_map_iterator& other) const; -#if BOOST_WORKAROUND(BOOST_MSVC, <= 0x1701) +#if BOOST_WORKAROUND(_MSC_VER, <= 1400) void decrement(); void advance(difference_type); #endif private: - named_slot_map_iterator(std::auto_ptr); + named_slot_map_iterator(group_iterator group, group_iterator last) : + group(group), last_group(last), slot_assigned(false) + { init_next_group(); } + named_slot_map_iterator(group_iterator group, group_iterator last, + slot_pair_iterator slot) : + group(group), last_group(last), slot_(slot), slot_assigned(true) + { } -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - shared_ptr impl_; -#else - scoped_ptr impl_; -#endif + void init_next_group() + { + while (group != last_group && group->second.empty()) ++group; + if (group != last_group) { + slot_ = group->second.begin(); + slot_assigned = true; + } + } + + group_iterator group; + group_iterator last_group; + slot_pair_iterator slot_; + bool slot_assigned; friend class named_slot_map; }; @@ -109,25 +137,28 @@ public: typedef named_slot_map_iterator iterator; named_slot_map(const compare_type& compare); - ~named_slot_map(); void clear(); iterator begin(); iterator end(); - iterator insert(const any& name, const connection& con, const any& slot, - connect_position at); - void disconnect(const any& name); + iterator insert(const stored_group& name, const connection& con, + const any& slot, connect_position at); + void disconnect(const stored_group& name); void erase(iterator pos); void remove_disconnected_slots(); private: - class impl; + typedef std::list group_list; + typedef std::map slot_container_type; + typedef slot_container_type::iterator group_iterator; + typedef slot_container_type::const_iterator const_group_iterator; -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - shared_ptr impl_; -#else - scoped_ptr impl_; -#endif + bool empty(const_group_iterator group) const + { + return (group->second.empty() && group != groups.begin() && group != back); + } + slot_container_type groups; + group_iterator back; }; } } } diff --git a/boost/boost/signals/detail/signal_base.hpp b/boost/boost/signals/detail/signal_base.hpp index 93ff0a6d35..0438cf7bae 100644 --- a/boost/boost/signals/detail/signal_base.hpp +++ b/boost/boost/signals/detail/signal_base.hpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -46,7 +45,7 @@ namespace boost { public: friend class call_notification; - typedef function2 compare_type; + typedef function2 compare_type; // Make sure that an exception does not cause the "clearing" flag to // remain set @@ -81,13 +80,13 @@ namespace boost { std::size_t num_slots() const; // Disconnect all slots in the given group - void disconnect(const any&); + void disconnect(const stored_group&); // We're being notified that a slot has disconnected static void slot_disconnected(void* obj, void* data); connection connect_slot(const any& slot, - const any& name, + const stored_group& name, shared_ptr data, connect_position at); @@ -138,7 +137,7 @@ namespace boost { protected: connection connect_slot(const any& slot, - const any& name, + const stored_group& name, shared_ptr data, connect_position at) { diff --git a/boost/boost/signals/detail/slot_call_iterator.hpp b/boost/boost/signals/detail/slot_call_iterator.hpp index 44c0ca24c1..c6706bef8c 100644 --- a/boost/boost/signals/detail/slot_call_iterator.hpp +++ b/boost/boost/signals/detail/slot_call_iterator.hpp @@ -10,11 +10,12 @@ #ifndef BOOST_SIGNALS_SLOT_CALL_ITERATOR #define BOOST_SIGNALS_SLOT_CALL_ITERATOR -#include +#include #include #include #include #include +#include #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX @@ -23,13 +24,6 @@ namespace boost { namespace BOOST_SIGNALS_NAMESPACE { namespace detail { - // A cached return value from a slot - template - struct cached_return_value { - cached_return_value(const T& t) : value(t) {} - - T value; - }; // Generates a slot call iterator. Essentially, this is an iterator that: // - skips over disconnected slots in the underlying list @@ -53,35 +47,34 @@ namespace boost { friend class iterator_core_access; public: - slot_call_iterator() {} - - slot_call_iterator(Iterator iter_in, Iterator end_in, Function f) - : iter(iter_in), end(end_in), f(f), cache() + slot_call_iterator(Iterator iter_in, Iterator end_in, Function f, + optional &c) + : iter(iter_in), end(end_in), f(f), cache(&c) { - iter = std::find_if(iter, end, std::not1(is_disconnected())); + iter = std::find_if(iter, end, is_callable()); } typename inherited::reference dereference() const { - if (!cache.get()) { - cache.reset(new cached_return_value(f(*iter))); + if (!cache->is_initialized()) { + cache->reset(f(*iter)); } - return cache->value; + return cache->get(); } void increment() { - iter = std::find_if(++iter, end, std::not1(is_disconnected())); - cache.reset(); + iter = std::find_if(++iter, end, is_callable()); + cache->reset(); } bool equal(const slot_call_iterator& other) const { - iter = std::find_if(iter, end, std::not1(is_disconnected())); + iter = std::find_if(iter, end, is_callable()); other.iter = std::find_if(other.iter, other.end, - std::not1(is_disconnected())); + is_callable()); return iter == other.iter; } @@ -89,7 +82,7 @@ namespace boost { mutable Iterator iter; Iterator end; Function f; - mutable shared_ptr< cached_return_value > cache; + optional* cache; }; } // end namespace detail } // end namespace BOOST_SIGNALS_NAMESPACE diff --git a/boost/boost/signals/signal_template.hpp b/boost/boost/signals/signal_template.hpp index afdd975686..e4017ec8ae 100644 --- a/boost/boost/signals/signal_template.hpp +++ b/boost/boost/signals/signal_template.hpp @@ -91,7 +91,7 @@ namespace boost { template R operator()(const Pair& slot) const { - F* target = const_cast(any_cast(&slot.second)); + F* target = const_cast(unsafe_any_cast(&slot.second)); return (*target)(BOOST_SIGNALS_BOUND_ARGS); } }; @@ -115,7 +115,7 @@ namespace boost { template unusable operator()(const Pair& slot) const { - F* target = const_cast(any_cast(&slot.second)); + F* target = const_cast(unsafe_any_cast(&slot.second)); (*target)(BOOST_SIGNALS_BOUND_ARGS); return unusable(); } @@ -160,7 +160,7 @@ namespace boost { private: // The real slot name comparison object type - typedef BOOST_SIGNALS_NAMESPACE::detail::any_bridge_compare + typedef BOOST_SIGNALS_NAMESPACE::detail::group_bridge_compare real_group_compare_type; // The function object passed to the slot call iterator that will call @@ -238,7 +238,7 @@ namespace boost { BOOST_SIGNALS_NAMESPACE::detail::call_notification notification(this->impl); for (iterator i = impl->slots_.begin(); i != impl->slots_.end(); ++i) { - slot_function_type& s = *any_cast(&i->second); + slot_function_type& s = *unsafe_any_cast(&i->second); if (s == f) i->first.disconnect(); } } @@ -251,10 +251,10 @@ namespace boost { result_type operator()(BOOST_SIGNALS_PARMS) const; Combiner& combiner() - { return *any_cast(&impl->combiner_); } + { return *unsafe_any_cast(&impl->combiner_); } const Combiner& combiner() const - { return *any_cast(&impl->combiner_); } + { return *unsafe_any_cast(&impl->combiner_); } }; template< @@ -274,13 +274,15 @@ namespace boost { >::connect(const slot_type& in_slot, BOOST_SIGNALS_NAMESPACE::connect_position at) { + using boost::BOOST_SIGNALS_NAMESPACE::detail::stored_group; + // If the slot has been disconnected, just return a disconnected // connection if (!in_slot.is_active()) { return BOOST_SIGNALS_NAMESPACE::connection(); } - return impl->connect_slot(in_slot.get_slot_function(), any(), + return impl->connect_slot(in_slot.get_slot_function(), stored_group(), in_slot.get_data(), at); } @@ -308,7 +310,7 @@ namespace boost { return BOOST_SIGNALS_NAMESPACE::connection(); } - return impl->connect_slot(in_slot.get_slot_function(), group, + return impl->connect_slot(in_slot.get_slot_function(), group, in_slot.get_data(), at); } @@ -343,11 +345,13 @@ namespace boost { #endif // BOOST_SIGNALS_NUM_ARGS > 0 call_bound_slot f(&args); + typedef typename call_bound_slot::result_type result_type; + optional cache; // Let the combiner call the slots via a pair of input iterators return combiner()(slot_call_iterator(notification.impl->slots_.begin(), - impl->slots_.end(), f), + impl->slots_.end(), f, cache), slot_call_iterator(notification.impl->slots_.end(), - impl->slots_.end(), f)); + impl->slots_.end(), f, cache)); } template< @@ -382,11 +386,14 @@ namespace boost { call_bound_slot f(&args); + typedef typename call_bound_slot::result_type result_type; + optional cache; + // Let the combiner call the slots via a pair of input iterators return combiner()(slot_call_iterator(notification.impl->slots_.begin(), - impl->slots_.end(), f), + impl->slots_.end(), f, cache), slot_call_iterator(notification.impl->slots_.end(), - impl->slots_.end(), f)); + impl->slots_.end(), f, cache)); } } // namespace boost diff --git a/boost/boost/signals/trackable.hpp b/boost/boost/signals/trackable.hpp index b532b71ea6..544ec611e0 100644 --- a/boost/boost/signals/trackable.hpp +++ b/boost/boost/signals/trackable.hpp @@ -102,7 +102,7 @@ namespace BOOST_SIGNALS_NAMESPACE { { // Take the address of this object, because the object itself may be // trackable - add_if_trackable(addressof(t)); + add_if_trackable(boost::addressof(t)); } // add_if_trackable() adds trackable objects to the list of bound objects diff --git a/boost/boost/spirit/core/assert.hpp b/boost/boost/spirit/core/assert.hpp index 498315df6a..11002442ee 100644 --- a/boost/boost/spirit/core/assert.hpp +++ b/boost/boost/spirit/core/assert.hpp @@ -25,7 +25,8 @@ #if defined(NDEBUG) #define BOOST_SPIRIT_ASSERT(x) #elif defined (BOOST_SPIRIT_ASSERT_EXCEPTION) - #define BOOST_SPIRIT_ASSERT_AUX(f, l, x) \ + #define BOOST_SPIRIT_ASSERT_AUX(f, l, x) BOOST_SPIRIT_ASSERT_AUX2(f, l, x) + #define BOOST_SPIRIT_ASSERT_AUX2(f, l, x) \ do{ if (!(x)) boost::throw_exception( \ BOOST_SPIRIT_ASSERT_EXCEPTION(f "(" #l "): " #x)); } while(0) #define BOOST_SPIRIT_ASSERT(x) BOOST_SPIRIT_ASSERT_AUX(__FILE__, __LINE__, x) diff --git a/boost/boost/spirit/core/composite/epsilon.hpp b/boost/boost/spirit/core/composite/epsilon.hpp index fcfb125e1c..b7d4b1b39e 100644 --- a/boost/boost/spirit/core/composite/epsilon.hpp +++ b/boost/boost/spirit/core/composite/epsilon.hpp @@ -44,7 +44,7 @@ namespace boost { namespace spirit { typename parser_result::type parse(ScannerT const& scan) const { - if (positive_ == cond()) + if (positive_ == bool(cond())) // allow cond to return int return scan.empty_match(); else return scan.no_match(); @@ -59,7 +59,9 @@ namespace boost { namespace spirit { CondT cond; }; -#if BOOST_WORKAROUND(BOOST_MSVC, == 1310) // VC 7.1 +#if BOOST_WORKAROUND(BOOST_MSVC, == 1310) || \ + BOOST_WORKAROUND(BOOST_MSVC, == 1400) +// VC 7.1 and VC8 template inline condition_parser operator~(condition_parser const& p) @@ -69,12 +71,12 @@ namespace boost { namespace spirit { inline condition_parser operator~(condition_parser const& p) { return p.negate(); } -#else // BOOST_WORKAROUND(BOOST_MSVC, == 1310) +#else // BOOST_WORKAROUND(BOOST_MSVC, == 1310) || == 1400 template inline condition_parser operator~(condition_parser const& p) { return p.negate(); } -#endif // BOOST_WORKAROUND(BOOST_MSVC, == 1310) +#endif // BOOST_WORKAROUND(BOOST_MSVC, == 1310) || == 1400 /////////////////////////////////////////////////////////////////////////////// // diff --git a/boost/boost/spirit/core/composite/intersection.hpp b/boost/boost/spirit/core/composite/intersection.hpp index 51efa7032b..07fb38484c 100644 --- a/boost/boost/spirit/core/composite/intersection.hpp +++ b/boost/boost/spirit/core/composite/intersection.hpp @@ -58,7 +58,7 @@ namespace boost { namespace spirit { iterator_t save = scan.first; if (result_t hl = this->left().parse(scan)) { - ScannerT bscan(scan.first, scan.first); + ScannerT bscan(scan.first, scan.first, scan); scan.first = save; result_t hr = this->right().parse(bscan); if (hl.length() == hr.length()) diff --git a/boost/boost/spirit/core/impl/match_attr_traits.ipp b/boost/boost/spirit/core/impl/match_attr_traits.ipp index bcaa0ef491..c6398b5664 100644 --- a/boost/boost/spirit/core/impl/match_attr_traits.ipp +++ b/boost/boost/spirit/core/impl/match_attr_traits.ipp @@ -11,6 +11,9 @@ #include #include +#include +#include +#include namespace boost { namespace spirit { namespace impl { @@ -22,14 +25,33 @@ namespace boost { namespace spirit { namespace impl const_reference; // case where src *IS* convertible to T (dest) + template static void - convert(boost::optional& dest, const_reference src) - { dest.reset(src); } + convert(boost::optional& dest, T2 const& src, mpl::true_) + { + dest.reset(src); + } // case where src *IS NOT* convertible to T (dest) + template static void - convert(boost::optional& dest, .../*src*/) - { dest.reset(); } + convert(boost::optional& dest, T2 const& /*src*/, mpl::false_) + { + dest.reset(); + } + + static void + convert(boost::optional& dest, nil_t/*src*/) + { + dest.reset(); + } + + template + static void + convert(boost::optional& dest, T2 const& src) + { + convert(dest, src, is_convertible()); + } template static void diff --git a/boost/boost/spirit/core/non_terminal/impl/grammar.ipp b/boost/boost/spirit/core/non_terminal/impl/grammar.ipp index 51faf88bce..32a4265219 100644 --- a/boost/boost/spirit/core/non_terminal/impl/grammar.ipp +++ b/boost/boost/spirit/core/non_terminal/impl/grammar.ipp @@ -325,7 +325,7 @@ struct grammar_definition public: typedef entry_grammar self_t; - typedef DerivedT const& embed_t; + typedef self_t embed_t; typedef typename ContextT::context_linker_t context_t; typedef typename context_t::attr_t attr_t; @@ -348,8 +348,8 @@ struct grammar_definition { typedef typename parser_result::type result_t; typedef parser_scanner_linker scanner_t; - BOOST_SPIRIT_CONTEXT_PARSE(scan, *this, scanner_t, context_t, - result_t) + BOOST_SPIRIT_CONTEXT_PARSE(scan, target_grammar, scanner_t, + context_t, result_t) } private: diff --git a/boost/boost/spirit/core/non_terminal/impl/object_with_id.ipp b/boost/boost/spirit/core/non_terminal/impl/object_with_id.ipp index 057c886c2f..e3624f0fd0 100644 --- a/boost/boost/spirit/core/non_terminal/impl/object_with_id.ipp +++ b/boost/boost/spirit/core/non_terminal/impl/object_with_id.ipp @@ -15,6 +15,7 @@ #ifdef BOOST_SPIRIT_THREADSAFE #include +#include #endif /////////////////////////////////////////////////////////////////////////////// @@ -54,6 +55,10 @@ namespace boost { namespace spirit { void release_object_id(object_id); private: +#ifdef BOOST_SPIRIT_THREADSAFE + static boost::mutex &mutex_instance(); + static void mutex_init(); +#endif boost::shared_ptr > id_supply; }; @@ -127,7 +132,9 @@ namespace boost { namespace spirit { { { #ifdef BOOST_SPIRIT_THREADSAFE - static boost::mutex mutex; + static boost::once_flag been_here = BOOST_ONCE_INIT; + boost::call_once(mutex_init, been_here); + boost::mutex &mutex = mutex_instance(); boost::mutex::scoped_lock lock(mutex); #endif static boost::shared_ptr > @@ -149,6 +156,27 @@ namespace boost { namespace spirit { id_supply->release(id); } + ////////////////////////////////// +#ifdef BOOST_SPIRIT_THREADSAFE + template + inline boost::mutex & + object_with_id_base::mutex_instance() + { + static boost::mutex mutex; + return mutex; + } +#endif + + ////////////////////////////////// +#ifdef BOOST_SPIRIT_THREADSAFE + template + inline void + object_with_id_base::mutex_init() + { + mutex_instance(); + } +#endif + } // namespace impl /////////////////////////////////////////////////////////////////////////////// diff --git a/boost/boost/spirit/core/non_terminal/parser_id.hpp b/boost/boost/spirit/core/non_terminal/parser_id.hpp index 3899865d28..25bccb848c 100644 --- a/boost/boost/spirit/core/non_terminal/parser_id.hpp +++ b/boost/boost/spirit/core/non_terminal/parser_id.hpp @@ -10,6 +10,10 @@ #if !defined(BOOST_SPIRIT_PARSER_ID_HPP) #define BOOST_SPIRIT_PARSER_ID_HPP +#if defined(BOOST_SPIRIT_DEBUG) +# include +#endif + /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { diff --git a/boost/boost/spirit/core/primitives/impl/primitives.ipp b/boost/boost/spirit/core/primitives/impl/primitives.ipp index 27ad87a054..198770eba9 100644 --- a/boost/boost/spirit/core/primitives/impl/primitives.ipp +++ b/boost/boost/spirit/core/primitives/impl/primitives.ipp @@ -178,76 +178,77 @@ namespace boost { namespace spirit { isalnum_(char c) { using namespace std; - return isalnum(to_int_type(c)); + return isalnum(to_int_type(c)) ? true : false; } inline bool isalpha_(char c) { using namespace std; - return isalpha(to_int_type(c)); + return isalpha(to_int_type(c)) ? true : false; } inline bool iscntrl_(char c) { using namespace std; - return iscntrl(to_int_type(c)); + return iscntrl(to_int_type(c)) ? true : false; } inline bool isdigit_(char c) { using namespace std; - return isdigit(to_int_type(c)); + return isdigit(to_int_type(c)) ? true : false; } inline bool isgraph_(char c) { using namespace std; - return isgraph(to_int_type(c)); + return isgraph(to_int_type(c)) ? true : false; } inline bool islower_(char c) { using namespace std; - return islower(to_int_type(c)); + return islower(to_int_type(c)) ? true : false; } inline bool isprint_(char c) { using namespace std; - return isprint(to_int_type(c)); + return isprint(to_int_type(c)) ? true : false; } inline bool ispunct_(char c) { using namespace std; - return ispunct(to_int_type(c)); + return ispunct(to_int_type(c)) ? true : false; } inline bool isspace_(char c) { using namespace std; - return isspace(to_int_type(c)); + return isspace(to_int_type(c)) ? true : false; } inline bool isupper_(char c) { using namespace std; - return isupper(to_int_type(c)); } + return isupper(to_int_type(c)) ? true : false; + } inline bool isxdigit_(char c) { using namespace std; - return isxdigit(to_int_type(c)); + return isxdigit(to_int_type(c)) ? true : false; } inline bool @@ -276,77 +277,77 @@ namespace boost { namespace spirit { isalnum_(wchar_t c) { using namespace std; - return iswalnum(to_int_type(c)); + return iswalnum(to_int_type(c)) ? true : false; } inline bool isalpha_(wchar_t c) { using namespace std; - return iswalpha(to_int_type(c)); + return iswalpha(to_int_type(c)) ? true : false; } inline bool iscntrl_(wchar_t c) { using namespace std; - return iswcntrl(to_int_type(c)); + return iswcntrl(to_int_type(c)) ? true : false; } inline bool isdigit_(wchar_t c) { using namespace std; - return iswdigit(to_int_type(c)); + return iswdigit(to_int_type(c)) ? true : false; } inline bool isgraph_(wchar_t c) { using namespace std; - return iswgraph(to_int_type(c)); + return iswgraph(to_int_type(c)) ? true : false; } inline bool islower_(wchar_t c) { using namespace std; - return iswlower(to_int_type(c)); + return iswlower(to_int_type(c)) ? true : false; } inline bool isprint_(wchar_t c) { using namespace std; - return iswprint(to_int_type(c)); + return iswprint(to_int_type(c)) ? true : false; } inline bool ispunct_(wchar_t c) { using namespace std; - return iswpunct(to_int_type(c)); + return iswpunct(to_int_type(c)) ? true : false; } inline bool isspace_(wchar_t c) { using namespace std; - return iswspace(to_int_type(c)); + return iswspace(to_int_type(c)) ? true : false; } inline bool isupper_(wchar_t c) { using namespace std; - return iswupper(to_int_type(c)); + return iswupper(to_int_type(c)) ? true : false; } inline bool isxdigit_(wchar_t c) { using namespace std; - return iswxdigit(to_int_type(c)); + return iswxdigit(to_int_type(c)) ? true : false; } inline bool diff --git a/boost/boost/spirit/core/primitives/primitives.hpp b/boost/boost/spirit/core/primitives/primitives.hpp index af8036b443..f491028a68 100644 --- a/boost/boost/spirit/core/primitives/primitives.hpp +++ b/boost/boost/spirit/core/primitives/primitives.hpp @@ -123,6 +123,17 @@ namespace boost { namespace spirit { return chlit(ch); } + // This should take care of ch_p("a") "bugs" + template + inline chlit + ch_p(CharT const (& str)[N]) + { + // ch_p's argument should be a single character or a null-terminated + // string with a single character + BOOST_STATIC_ASSERT(N < 3); + return chlit(str[0]); + } + /////////////////////////////////////////////////////////////////////////// // // range class @@ -243,6 +254,13 @@ namespace boost { namespace spirit { return strlit(str); } + template + inline strlit + str_p(CharT * str) + { + return strlit(str); + } + template inline strlit str_p(IteratorT first, IteratorT last) @@ -250,6 +268,14 @@ namespace boost { namespace spirit { return strlit(first, last); } + // This should take care of str_p('a') "bugs" + template + inline chlit + str_p(CharT ch) + { + return chlit(ch); + } + /////////////////////////////////////////////////////////////////////////// // // nothing_parser class @@ -561,7 +587,8 @@ namespace boost { namespace spirit { ++len; } - if (!scan.at_end() && *scan == '\n') // LF + // Don't call skipper here + if (scan.first != scan.last && *scan == '\n') // LF { ++scan.first; ++len; diff --git a/boost/boost/spirit/dynamic/if.hpp b/boost/boost/spirit/dynamic/if.hpp index c73d5a8471..81cc4c1b16 100644 --- a/boost/boost/spirit/dynamic/if.hpp +++ b/boost/boost/spirit/dynamic/if.hpp @@ -178,6 +178,7 @@ namespace boost { namespace spirit { length += then_result.length(); return scan.create_match(std::size_t(length), nil_t(), save, scan.first); } + return scan.no_match(); } return scan.empty_match(); } diff --git a/boost/boost/spirit/error_handling/exceptions.hpp b/boost/boost/spirit/error_handling/exceptions.hpp index 8a3e0da1a8..0186a3ac6d 100644 --- a/boost/boost/spirit/error_handling/exceptions.hpp +++ b/boost/boost/spirit/error_handling/exceptions.hpp @@ -39,7 +39,8 @@ namespace boost { namespace spirit { public: - parser_error_base(parser_error_base const&) {} + parser_error_base(parser_error_base const& rhs) + : std::exception(rhs) {} parser_error_base& operator=(parser_error_base const&) { return *this; @@ -70,7 +71,8 @@ namespace boost { namespace spirit { : where(where_), descriptor(descriptor_) {} parser_error(parser_error const& rhs) - : where(rhs.where), descriptor(rhs.descriptor) {} + : parser_error_base(rhs) + , where(rhs.where), descriptor(rhs.descriptor) {} parser_error& operator=(parser_error const& rhs) diff --git a/boost/boost/spirit/iterator/file_iterator.hpp b/boost/boost/spirit/iterator/file_iterator.hpp index 0cad0e2529..8d79629d6b 100644 --- a/boost/boost/spirit/iterator/file_iterator.hpp +++ b/boost/boost/spirit/iterator/file_iterator.hpp @@ -96,7 +96,7 @@ namespace fileiter_impl { template < typename CharT = char, typename BaseIterator = -#ifndef BOOST_SPIRIT_FILEITERATOR_WINDOWS +#ifdef BOOST_SPIRIT_FILEITERATOR_STD fileiter_impl::std_file_iterator #else fileiter_impl::mmap_file_iterator @@ -232,7 +232,7 @@ private: }} /* namespace boost::spirit */ /////////////////////////////////////////////////////////////////////////////// -#include "impl/file_iterator.ipp" /* implementation */ +#include /* implementation */ #endif /* BOOST_SPIRIT_FILE_ITERATOR_HPP */ diff --git a/boost/boost/spirit/iterator/multi_pass.hpp b/boost/boost/spirit/iterator/multi_pass.hpp index 68397c8091..591b9075da 100644 --- a/boost/boost/spirit/iterator/multi_pass.hpp +++ b/boost/boost/spirit/iterator/multi_pass.hpp @@ -262,7 +262,7 @@ class inner // will be called from the destructor of the last iterator. void destroy() { - BOOST_SPIRIT_ASSERT(queuedElements); + BOOST_SPIRIT_ASSERT(NULL != queuedElements); delete queuedElements; queuedElements = 0; } @@ -401,7 +401,7 @@ class inner // will be called from the destructor of the last iterator. void destroy() { - BOOST_SPIRIT_ASSERT(queuedElements); + BOOST_SPIRIT_ASSERT(NULL != queuedElements); delete queuedElements; queuedElements = 0; } @@ -500,6 +500,12 @@ class inner bool was_initialized; }; + // Needed by compilers not implementing the resolution to DR45. For + // reference, see + // http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#45. + + friend struct Data; + public: typedef result_type value_type; typedef @@ -555,14 +561,14 @@ class inner public: reference get_input() const { - BOOST_SPIRIT_ASSERT(0 != data); + BOOST_SPIRIT_ASSERT(NULL != data); ensure_initialized(); return data->curtok; } void advance_input() { - BOOST_SPIRIT_ASSERT(0 != data); + BOOST_SPIRIT_ASSERT(NULL != data); data->was_initialized = false; // should get the next token ++data->input; } diff --git a/boost/boost/spirit/iterator/position_iterator.hpp b/boost/boost/spirit/iterator/position_iterator.hpp index 506b4b4a20..d9c2961541 100644 --- a/boost/boost/spirit/iterator/position_iterator.hpp +++ b/boost/boost/spirit/iterator/position_iterator.hpp @@ -94,7 +94,7 @@ class position_iterator; // This must be included here for full compatibility with old MSVC -#include "impl/position_iterator.ipp" +#include "boost/spirit/iterator/impl/position_iterator.ipp" /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { diff --git a/boost/boost/spirit/phoenix/actor.hpp b/boost/boost/spirit/phoenix/actor.hpp index 7c7d3c4c24..9398bc1a66 100644 --- a/boost/boost/spirit/phoenix/actor.hpp +++ b/boost/boost/spirit/phoenix/actor.hpp @@ -30,23 +30,6 @@ namespace impl { struct make_binary1; } -namespace impl { - - /////////////////////////////////////////////////////////////////////////// - // - // if_t selects type A or B depending on the condition C If C is of - // type char[2], B is selected, otherwise A - // - // TODO: This should be part of a common meta-library - // - /////////////////////////////////////////////////////////////////////////// - template - struct if_t { typedef A type; }; - - template - struct if_t { typedef B type; }; -} - /////////////////////////////////////////////////////////////////////////////// // // unpack_tuple class @@ -86,7 +69,7 @@ struct unpack_tuple : public TupleT { // // arg0 ---------| // arg1 ---------| -// arg3 ---------|---> tupled_args ---> base.eval +// arg2 ---------|---> tupled_args ---> base.eval // ... | // argN ---------| // diff --git a/boost/boost/spirit/phoenix/binders.hpp b/boost/boost/spirit/phoenix/binders.hpp index a894ff8cb6..4b2ca57e8f 100644 --- a/boost/boost/spirit/phoenix/binders.hpp +++ b/boost/boost/spirit/phoenix/binders.hpp @@ -12,6 +12,7 @@ /////////////////////////////////////////////////////////////////////////////// #include #include +#include /////////////////////////////////////////////////////////////////////////////// namespace phoenix { @@ -440,9 +441,8 @@ struct member_var_ptr_action { template struct result { - - typedef char is_const[boost::is_const::value ? 1 : 2]; - typedef typename impl::if_t::type type; + typedef typename boost::mpl::if_, T const&, T& + >::type type; }; typedef T ClassT::*mem_var_ptr_t; @@ -1517,8 +1517,8 @@ struct member_function_ptr_action::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template struct result { typedef result_type type; }; @@ -1574,8 +1574,8 @@ struct member_function_ptr_action::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template struct result { typedef result_type type; }; @@ -1632,8 +1632,8 @@ struct member_function_ptr_action::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template struct result { typedef result_type type; }; @@ -1688,8 +1688,8 @@ struct member_function_ptr_action::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template struct result { typedef result_type type; }; @@ -1745,8 +1745,8 @@ struct member_function_ptr_action::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template ::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template ::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template ::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template ::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template ::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template ::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template ::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template ::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template ::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template ::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template ::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template ::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template struct result { typedef result_type type; }; @@ -2777,8 +2777,8 @@ struct bound_member_action::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template struct result { typedef result_type type; }; @@ -2850,8 +2850,8 @@ struct bound_member_action::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template struct result { typedef result_type type; }; @@ -2920,8 +2920,8 @@ struct bound_member_action::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template struct result { typedef result_type type; }; @@ -2991,8 +2991,8 @@ struct bound_member_action::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template struct result { typedef result_type type; }; @@ -3075,8 +3075,8 @@ struct bound_member_action::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template ::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template < typename A_, typename B_, typename C_, typename D_, @@ -3255,8 +3255,8 @@ struct bound_member_action::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template < typename A_, typename B_, typename C_, typename D_, @@ -3345,8 +3345,8 @@ struct bound_member_action::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template < typename A_, typename B_, typename C_, typename D_, @@ -3433,8 +3433,8 @@ struct bound_member_action::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template < typename A_, typename B_, typename C_, typename D_, @@ -3521,8 +3521,8 @@ struct bound_member_action::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template < typename A_, typename B_, typename C_, typename D_, @@ -3616,8 +3616,8 @@ struct bound_member_action::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template < typename A_, typename B_, typename C_, typename D_, @@ -3707,8 +3707,8 @@ struct bound_member_action::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template < typename A_, typename B_, typename C_, typename D_, @@ -3797,8 +3797,8 @@ struct bound_member_action::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template < typename A_, typename B_, typename C_, typename D_, @@ -3887,8 +3887,8 @@ struct bound_member_action::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template < typename A_, typename B_, typename C_, typename D_, @@ -3978,8 +3978,8 @@ struct bound_member_action::value ? 1 : 2]; - typedef typename impl::if_t::type mem_func_ptr_t; + typedef typename boost::mpl::if_, cmf, mf>::type + mem_func_ptr_t; template < typename A_, typename B_, typename C_, typename D_, diff --git a/boost/boost/spirit/phoenix/closures.hpp b/boost/boost/spirit/phoenix/closures.hpp index 3f7c1f6ce3..fb707ba469 100644 --- a/boost/boost/spirit/phoenix/closures.hpp +++ b/boost/boost/spirit/phoenix/closures.hpp @@ -16,6 +16,7 @@ #ifdef PHOENIX_THREADSAFE #include +#include #endif /////////////////////////////////////////////////////////////////////////////// @@ -397,11 +398,28 @@ private: typedef impl::closure_frame_holder holder_t; +#ifdef PHOENIX_THREADSAFE + static boost::thread_specific_ptr & + tsp_frame_instance() + { + static boost::thread_specific_ptr the_instance; + return the_instance; + } + + static void + tsp_frame_instance_init() + { + tsp_frame_instance(); + } +#endif + static holder_t & closure_frame_holder_ref(holder_t* holder_ = 0) { #ifdef PHOENIX_THREADSAFE - static boost::thread_specific_ptr tsp_frame; + static boost::once_flag been_here = BOOST_ONCE_INIT; + boost::call_once(tsp_frame_instance_init, been_here); + boost::thread_specific_ptr &tsp_frame = tsp_frame_instance(); if (!tsp_frame.get()) tsp_frame.reset(new holder_t *(0)); holder_t *& holder = *tsp_frame; diff --git a/boost/boost/spirit/phoenix/new.hpp b/boost/boost/spirit/phoenix/new.hpp index 61d5dc79dd..acd3255c94 100644 --- a/boost/boost/spirit/phoenix/new.hpp +++ b/boost/boost/spirit/phoenix/new.hpp @@ -873,9 +873,10 @@ inline typename impl::make_composite >::type new_() { typedef impl::make_composite > make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; - return make_composite_t::type( - make_composite_t::composite_type(new_l_0())); + return type_t(composite_type_t(new_l_0())); } ////////////////////////////////// @@ -884,8 +885,10 @@ inline typename impl::make_composite, A>::type new_(A const& a) { typedef impl::make_composite, A> make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; - return make_composite_t::type(make_composite_t::composite_type(new_1(), + return type_t(composite_type_t(new_1(), as_actor::convert(a) )); } @@ -896,8 +899,10 @@ inline typename impl::make_composite, A, B>::type new_(A const& a, B const& b) { typedef impl::make_composite, A, B> make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; - return make_composite_t::type(make_composite_t::composite_type(new_2(), + return type_t(composite_type_t(new_2(), as_actor::convert(a), as_actor::convert(b) )); @@ -909,8 +914,10 @@ inline typename impl::make_composite, A, B, C>::type new_(A const& a, B const& b, C const& c) { typedef impl::make_composite, A, B, C> make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; - return make_composite_t::type(make_composite_t::composite_type(new_3(), + return type_t(composite_type_t(new_3(), as_actor::convert(a), as_actor::convert(b), as_actor::convert(c) @@ -929,8 +936,10 @@ new_( typedef impl::make_composite, A, B, C, D> make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; - return make_composite_t::type(make_composite_t::composite_type(new_4(), + return type_t(composite_type_t(new_4(), as_actor::convert(a), as_actor::convert(b), as_actor::convert(c), @@ -949,8 +958,10 @@ new_( typedef impl::make_composite, A, B, C, D, E> make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; - return make_composite_t::type(make_composite_t::composite_type(new_5(), + return type_t(composite_type_t(new_5(), as_actor::convert(a), as_actor::convert(b), as_actor::convert(c), @@ -972,8 +983,10 @@ new_( typedef impl::make_composite, A, B, C, D, E, F> make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; - return make_composite_t::type(make_composite_t::composite_type(new_6(), + return type_t(composite_type_t(new_6(), as_actor::convert(a), as_actor::convert(b), as_actor::convert(c), @@ -997,8 +1010,10 @@ new_( typedef impl::make_composite, A, B, C, D, E, F, G> make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; - return make_composite_t::type(make_composite_t::composite_type(new_7(), + return type_t(composite_type_t(new_7(), as_actor::convert(a), as_actor::convert(b), as_actor::convert(c), @@ -1022,8 +1037,10 @@ new_( typedef impl::make_composite, A, B, C, D, E, F, G, H> make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; - return make_composite_t::type(make_composite_t::composite_type(new_8(), + return type_t(composite_type_t(new_8(), as_actor::convert(a), as_actor::convert(b), as_actor::convert(c), @@ -1048,8 +1065,10 @@ new_( typedef impl::make_composite, A, B, C, D, E, F, G, H, I> make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; - return make_composite_t::type(make_composite_t::composite_type(new_9(), + return type_t(composite_type_t(new_9(), as_actor::convert(a), as_actor::convert(b), as_actor::convert(c), @@ -1079,8 +1098,10 @@ new_( new_10, A, B, C, D, E, F, G, H, I, J > make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; - return make_composite_t::type(make_composite_t::composite_type(new_10(), + return type_t(composite_type_t(new_10(), as_actor::convert(a), as_actor::convert(b), as_actor::convert(c), @@ -1111,8 +1132,10 @@ new_( new_11, A, B, C, D, E, F, G, H, I, J, K > make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; - return make_composite_t::type(make_composite_t::composite_type(new_11(), + return type_t(composite_type_t(new_11(), as_actor::convert(a), as_actor::convert(b), as_actor::convert(c), @@ -1145,8 +1168,10 @@ new_( new_12, A, B, C, D, E, F, G, H, I, J, K, L > make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; - return make_composite_t::type(make_composite_t::composite_type(new_12(), + return type_t(composite_type_t(new_12(), as_actor::convert(a), as_actor::convert(b), as_actor::convert(c), @@ -1181,8 +1206,10 @@ new_( new_13, A, B, C, D, E, F, G, H, I, J, K, L, M > make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; - return make_composite_t::type(make_composite_t::composite_type(new_13(), + return type_t(composite_type_t(new_13(), as_actor::convert(a), as_actor::convert(b), as_actor::convert(c), @@ -1217,8 +1244,10 @@ new_( new_14, A, B, C, D, E, F, G, H, I, J, K, L, M, N > make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; - return make_composite_t::type(make_composite_t::composite_type(new_14(), + return type_t(composite_type_t(new_14(), as_actor::convert(a), as_actor::convert(b), as_actor::convert(c), @@ -1254,8 +1283,10 @@ new_( new_15, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O > make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; - return make_composite_t::type(make_composite_t::composite_type(new_15(), + return type_t(composite_type_t(new_15(), as_actor::convert(a), as_actor::convert(b), as_actor::convert(c), diff --git a/boost/boost/spirit/phoenix/operators.hpp b/boost/boost/spirit/phoenix/operators.hpp index 6d2d03b6a6..a50cfd3420 100644 --- a/boost/boost/spirit/phoenix/operators.hpp +++ b/boost/boost/spirit/phoenix/operators.hpp @@ -23,6 +23,7 @@ #include #include #include +#include /////////////////////////////////////////////////////////////////////////////// namespace phoenix { @@ -399,21 +400,9 @@ template struct rank /////////////////////////////////////////////////////////////////////////////// template struct higher_rank { - - enum { - - rank1 = rank::value, - rank2 = rank::value, - -#if defined __BORLANDC__ && __BORLANDC__ >= 0x561 - siz = (rank::value < rank::value) ? 1 : 2 -#else - siz = (rank1 < rank2) ? 1 : 2 -#endif - }; - - typedef char compare_rank[siz]; - typedef typename impl::if_t::type type; + typedef typename boost::mpl::if_c< + rank::value < rank::value, + T1, T0>::type type; }; /////////////////////////////////////////////////////////////////////////////// diff --git a/boost/boost/spirit/symbols/impl/tst.ipp b/boost/boost/spirit/symbols/impl/tst.ipp index f328453e88..47169cf877 100644 --- a/boost/boost/spirit/symbols/impl/tst.ipp +++ b/boost/boost/spirit/symbols/impl/tst.ipp @@ -11,6 +11,7 @@ /////////////////////////////////////////////////////////////////////////////// #include // for std::auto_ptr +#include /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { @@ -133,6 +134,9 @@ namespace boost { namespace spirit { node_t** np = &root; CharT ch = *first; + BOOST_SPIRIT_ASSERT(first == last || ch != 0 + && "Won't add string containing null character"); + for (;;) { if (*np == 0 || ch == 0) @@ -167,7 +171,9 @@ namespace boost { namespace spirit { } } ++first; - ch = (first == last) ? 0 : *first; + ch = (first == last) ? CharT(0) : *first; + BOOST_SPIRIT_ASSERT(first == last || ch != 0 + && "Won't add string containing null character"); np = &(**np).middle.link; } else @@ -195,7 +201,8 @@ namespace boost { namespace spirit { while (np) { - if (ch < np->value) + + if (ch < np->value) // => go left! { if (np->value == 0) { @@ -206,41 +213,41 @@ namespace boost { namespace spirit { latest_len = result.length; } } + np = np->left; } - else + else if (ch == np->value) // => go middle! { - if (ch == np->value) + // Matching the null character is not allowed. + if (np->value == 0) { - if (scan.at_end()) + result.data = np->middle.data; + if (result.data) { - result.data = np->middle.data; - if (result.data) - { - latest = scan.first; - latest_len = result.length; - } - break; + latest = scan.first; + latest_len = result.length; } - - ++scan; - ch = scan.at_end() ? 0 : *scan; - np = np->middle.link; - ++result.length; + break; } - else + + ++scan; + ch = scan.at_end() ? CharT(0) : *scan; + np = np->middle.link; + ++result.length; + } + else // (ch > np->value) => go right! + { + if (np->value == 0) { - if (np->value == 0) + result.data = np->middle.data; + if (result.data) { - result.data = np->middle.data; - if (result.data) - { - latest = scan.first; - latest_len = result.length; - } + latest = scan.first; + latest_len = result.length; } - np = np->right; - } + } + + np = np->right; } } diff --git a/boost/boost/spirit/utility/escape_char.hpp b/boost/boost/spirit/utility/escape_char.hpp index 6adeeceeed..2db0436ce4 100644 --- a/boost/boost/spirit/utility/escape_char.hpp +++ b/boost/boost/spirit/utility/escape_char.hpp @@ -15,6 +15,8 @@ #include #include +#include + #include /////////////////////////////////////////////////////////////////////////////// diff --git a/boost/boost/spirit/utility/impl/chset/range_run.hpp b/boost/boost/spirit/utility/impl/chset/range_run.hpp index 2a9318f933..320e949e1f 100644 --- a/boost/boost/spirit/utility/impl/chset/range_run.hpp +++ b/boost/boost/spirit/utility/impl/chset/range_run.hpp @@ -50,6 +50,13 @@ namespace boost { namespace spirit { namespace utility { namespace impl { bool operator()(const CharT x, range const& y) const { return x < y.first; } + + // This additional operator is required for the checked STL shipped + // with VC8 testing the ordering of the iterators passed to the + // std::lower_bound algo this range_char_compare<> predicate is passed + // to. + bool operator()(range const& x, range const& y) const + { return x.first < y.first; } }; ////////////////////////////////// diff --git a/boost/boost/spirit/utility/impl/escape_char.ipp b/boost/boost/spirit/utility/impl/escape_char.ipp index ad8a59b682..85f27daba7 100644 --- a/boost/boost/spirit/utility/impl/escape_char.ipp +++ b/boost/boost/spirit/utility/impl/escape_char.ipp @@ -10,6 +10,11 @@ #ifndef BOOST_SPIRIT_ESCAPE_CHAR_IPP #define BOOST_SPIRIT_ESCAPE_CHAR_IPP +#include +#include +#include +#include + /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { diff --git a/boost/boost/spirit/version.hpp b/boost/boost/spirit/version.hpp index 8d83ad00dc..91bad02bf3 100644 --- a/boost/boost/spirit/version.hpp +++ b/boost/boost/spirit/version.hpp @@ -17,7 +17,7 @@ #include #if BOOST_VERSION < 103200 -#error "Spirit V1.8.1 needs at least Boost V1.32.0 to compile successfully." +#error "Spirit v1.8.x needs at least Boost V1.32.0 to compile successfully." #endif /////////////////////////////////////////////////////////////////////////////// @@ -25,7 +25,7 @@ // This is the version of the current Spirit distribution // /////////////////////////////////////////////////////////////////////////////// -#define SPIRIT_VERSION 0x1801 -#define SPIRIT_PIZZA_VERSION SPIRIT_FOUR_SEASONS // :-) +#define SPIRIT_VERSION 0x1803 +#define SPIRIT_PIZZA_VERSION SPIRIT_DOUBLE_CHEESE // :-) #endif // defined(SPIRIT_VERSION_HPP) diff --git a/boost/boost/static_assert.hpp b/boost/boost/static_assert.hpp index 6984d373f6..9d24c05647 100644 --- a/boost/boost/static_assert.hpp +++ b/boost/boost/static_assert.hpp @@ -62,8 +62,7 @@ template struct static_assert_test{}; // style casts: too many compilers currently have problems with static_cast // when used inside integral constant expressions. // -#if !defined(BOOST_BUGGY_INTEGRAL_CONSTANT_EXPRESSIONS) && \ - !BOOST_WORKAROUND(__MWERKS__, < 0x3003) +#if !defined(BOOST_BUGGY_INTEGRAL_CONSTANT_EXPRESSIONS) #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) // __LINE__ macro broken when -ZI is used see Q199057 @@ -92,6 +91,12 @@ template struct static_assert_test{}; sizeof(::boost::STATIC_ASSERTION_FAILURE< \ BOOST_JOIN(boost_static_assert_test_, __LINE__) >)>\ BOOST_JOIN(boost_static_assert_typedef_, __LINE__) +#elif BOOST_WORKAROUND(__MWERKS__, <= 0x3003) +// special version for CodeWarrior <= 8.x +#define BOOST_STATIC_ASSERT( B ) \ + BOOST_STATIC_CONSTANT(int, \ + BOOST_JOIN(boost_static_assert_test_, __LINE__) = \ + sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool)( B ) >) ) #else // generic version #define BOOST_STATIC_ASSERT( B ) \ diff --git a/boost/boost/test/detail/enable_warnings.hpp b/boost/boost/test/detail/enable_warnings.hpp new file mode 100644 index 0000000000..ad6ff6e892 --- /dev/null +++ b/boost/boost/test/detail/enable_warnings.hpp @@ -0,0 +1,41 @@ +// (C) Copyright Gennadiy Rozental 2004-2005. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/test for the library home page. +// +// File : $RCSfile: enable_warnings.hpp,v $ +// +// Version : $Revision: 1.4 $ +// +// Description : enable previosly suppressed warnings +// *************************************************************************** + +#ifdef BOOST_MSVC +# pragma warning(default: 4511) // copy constructor could not be generated +# pragma warning(default: 4512) // assignment operator could not be generated +# pragma warning(default: 4100) // unreferenced formal parameter +# pragma warning(default: 4996) // was declared deprecated +# pragma warning(default: 4355) // 'this' : used in base member initializer list +# pragma warning(default: 4706) // assignment within conditional expression +# pragma warning(pop) +#endif + +// *************************************************************************** +// Revision History : +// +// $Log: enable_warnings.hpp,v $ +// Revision 1.4 2005/02/20 08:27:06 rogeeff +// This a major update for Boost.Test framework. See release docs for complete list of fixes/updates +// +// Revision 1.3 2005/02/01 06:40:07 rogeeff +// copyright update +// old log entries removed +// minor stilistic changes +// depricated tools removed +// +// Revision 1.2 2005/01/31 06:00:37 rogeeff +// deprecated std symbols warning suppressed +// +// *************************************************************************** diff --git a/boost/boost/test/detail/suppress_warnings.hpp b/boost/boost/test/detail/suppress_warnings.hpp new file mode 100644 index 0000000000..7aac657a8c --- /dev/null +++ b/boost/boost/test/detail/suppress_warnings.hpp @@ -0,0 +1,41 @@ +// (C) Copyright Gennadiy Rozental 2004-2005. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/test for the library home page. +// +// File : $RCSfile: suppress_warnings.hpp,v $ +// +// Version : $Revision: 1.4 $ +// +// Description : suppress some warnings +// *************************************************************************** + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable: 4511) // copy constructor could not be generated +# pragma warning(disable: 4512) // assignment operator could not be generated +# pragma warning(disable: 4100) // unreferenced formal parameter +# pragma warning(disable: 4996) // was declared deprecated +# pragma warning(disable: 4355) // 'this' : used in base member initializer list +# pragma warning(disable: 4706) // assignment within conditional expression +#endif + +// *************************************************************************** +// Revision History : +// +// $Log: suppress_warnings.hpp,v $ +// Revision 1.4 2005/02/20 08:27:06 rogeeff +// This a major update for Boost.Test framework. See release docs for complete list of fixes/updates +// +// Revision 1.3 2005/02/01 06:40:07 rogeeff +// copyright update +// old log entries removed +// minor stilistic changes +// depricated tools removed +// +// Revision 1.2 2005/01/31 06:00:37 rogeeff +// deprecated std symbols warning suppressed +// +// *************************************************************************** diff --git a/boost/boost/test/detail/nullstream.hpp b/boost/boost/test/utils/nullstream.hpp similarity index 78% rename from boost/boost/test/detail/nullstream.hpp rename to boost/boost/test/utils/nullstream.hpp index e63fd0cea7..8e69ff9990 100644 --- a/boost/boost/test/detail/nullstream.hpp +++ b/boost/boost/test/utils/nullstream.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2002-2003. +// (C) Copyright Gennadiy Rozental 2002-2005. // (C) Copyright Daryle Walker 2000-2001. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -8,7 +8,7 @@ // // File : $RCSfile: nullstream.hpp,v $ // -// Version : $Revision: 1.9 $ +// Version : $Revision: 1.4 $ // // Description : simulate /dev/null stream // *************************************************************************** @@ -22,6 +22,10 @@ #include +#include + +//____________________________________________________________________________// + namespace boost { // ************************************************************************** // @@ -65,6 +69,11 @@ typedef basic_nullbuf wnullbuf; // ************************************************************************** // // Output streams based on basic_nullbuf. +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable: 4355) // 'this' : used in base member initializer list +#endif + template< typename CharType, class CharTraits = ::std::char_traits > class basic_onullstream : private boost::base_from_member > , public ::std::basic_ostream { @@ -75,23 +84,37 @@ public: basic_onullstream() : pbase_type(), base_type( &this->pbase_type::member ) {} }; +#ifdef BOOST_MSVC +# pragma warning(default: 4355) +#endif + typedef basic_onullstream onullstream; typedef basic_onullstream wonullstream; } // namespace boost +//____________________________________________________________________________// + +#include + // *************************************************************************** // Revision History : // // $Log: nullstream.hpp,v $ -// Revision 1.9 2004/07/19 12:21:08 rogeeff -// guard rename +// Revision 1.4 2005/02/20 08:27:08 rogeeff +// This a major update for Boost.Test framework. See release docs for complete list of fixes/updates // -// Revision 1.8 2004/05/21 06:19:35 rogeeff -// licence update +// Revision 1.3 2005/02/01 06:40:07 rogeeff +// copyright update +// old log entries removed +// minor stilistic changes +// depricated tools removed // -// Revision 1.7 2003/12/01 00:41:56 rogeeff -// prerelease cleaning +// Revision 1.2 2005/01/30 01:42:49 rogeeff +// warnings suppressed +// +// Revision 1.1 2005/01/22 18:21:40 rogeeff +// moved sharable staff into utils // // *************************************************************************** diff --git a/boost/boost/type_traits.hpp b/boost/boost/type_traits.hpp index 004d7b9733..08bb5a1e01 100644 --- a/boost/boost/type_traits.hpp +++ b/boost/boost/type_traits.hpp @@ -24,10 +24,14 @@ #include "boost/type_traits/has_trivial_constructor.hpp" #include "boost/type_traits/has_trivial_copy.hpp" #include "boost/type_traits/has_trivial_destructor.hpp" +#include "boost/type_traits/has_virtual_destructor.hpp" +#include "boost/type_traits/is_signed.hpp" +#include "boost/type_traits/is_unsigned.hpp" #include "boost/type_traits/is_abstract.hpp" #include "boost/type_traits/is_arithmetic.hpp" #include "boost/type_traits/is_array.hpp" #include "boost/type_traits/is_base_and_derived.hpp" +#include "boost/type_traits/is_base_of.hpp" #include "boost/type_traits/is_class.hpp" #include "boost/type_traits/is_compound.hpp" #include "boost/type_traits/is_const.hpp" @@ -35,10 +39,12 @@ #include "boost/type_traits/is_empty.hpp" #include "boost/type_traits/is_enum.hpp" #include "boost/type_traits/is_float.hpp" +#include "boost/type_traits/is_floating_point.hpp" #include "boost/type_traits/is_function.hpp" #include "boost/type_traits/is_fundamental.hpp" #include "boost/type_traits/is_integral.hpp" #include "boost/type_traits/is_member_function_pointer.hpp" +#include "boost/type_traits/is_member_object_pointer.hpp" #include "boost/type_traits/is_member_pointer.hpp" #include "boost/type_traits/is_object.hpp" #include "boost/type_traits/is_pod.hpp" @@ -51,7 +57,11 @@ #include "boost/type_traits/is_union.hpp" #include "boost/type_traits/is_void.hpp" #include "boost/type_traits/is_volatile.hpp" +#include "boost/type_traits/rank.hpp" +#include "boost/type_traits/extent.hpp" #include "boost/type_traits/remove_bounds.hpp" +#include "boost/type_traits/remove_extent.hpp" +#include "boost/type_traits/remove_all_extents.hpp" #include "boost/type_traits/remove_const.hpp" #include "boost/type_traits/remove_cv.hpp" #include "boost/type_traits/remove_pointer.hpp" @@ -59,6 +69,7 @@ #include "boost/type_traits/remove_volatile.hpp" #include "boost/type_traits/type_with_alignment.hpp" #include "boost/type_traits/function_traits.hpp" +#include "boost/type_traits/aligned_storage.hpp" #include "boost/type_traits/ice.hpp" diff --git a/boost/boost/type_traits/aligned_storage.hpp b/boost/boost/type_traits/aligned_storage.hpp new file mode 100644 index 0000000000..634fa7454a --- /dev/null +++ b/boost/boost/type_traits/aligned_storage.hpp @@ -0,0 +1,12 @@ + +// (C) John Maddock 2005. +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). +// +// See http://www.boost.org/libs/type_traits for most recent version including documentation. + +#ifndef BOOST_TT_ALIGNED_STORAGE_HPP_INCLUDED +# define BOOST_TT_ALIGNED_STORAGE_HPP_INCLUDED +# include +#endif // BOOST_TT_ALIGNED_STORAGE_HPP_INCLUDED diff --git a/boost/boost/type_traits/config.hpp b/boost/boost/type_traits/config.hpp index f522cce358..cdb4ac64c9 100644 --- a/boost/boost/type_traits/config.hpp +++ b/boost/boost/type_traits/config.hpp @@ -24,10 +24,36 @@ # define BOOST_TT_DECL /**/ #endif -# if (defined(__MWERKS__) && __MWERKS__ >= 0x3000) || (defined(BOOST_MSVC) && (BOOST_MSVC > 1301)) || defined(__EDG_VERSION__) || (defined(__GNUC__) && (__GNUC__ >= 3)) || defined(__DMC__) || defined(BOOST_NO_COMPILER_CONFIG) +# if (defined(__MWERKS__) && __MWERKS__ >= 0x3000) || (defined(BOOST_MSVC) && (BOOST_MSVC > 1301)) || defined(__EDG_VERSION__) || (defined(__GNUC__) && (__GNUC__ >= 3)) || defined(__DMC__) || ( defined(__IBMCPP__) && (__IBMCPP__ >= 600 ) ) || defined(BOOST_NO_COMPILER_CONFIG) # define BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION #endif +// +// Define BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +// when we can't test for function types with elipsis: +// +#if defined(__GNUC__) && (__GNUC__ < 3) +# define BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +#endif + +// +// define BOOST_TT_TEST_MS_FUNC_SIGS +// when we want to test __stdcall etc function types with is_function etc +// (Note, does not work with Borland, even though it does support __stdcall etc): +// +#if defined(_MSC_EXTENSIONS) && !defined(__BORLANDC__) +# define BOOST_TT_TEST_MS_FUNC_SIGS +#endif + +// +// define BOOST_TT_NO_CV_FUNC_TEST +// if tests for cv-qualified member functions don't +// work in is_member_function_pointer +// +#if (defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600) +# define BOOST_TT_NO_CV_FUNC_TEST +#endif + #endif // BOOST_TT_CONFIG_HPP_INCLUDED diff --git a/boost/boost/type_traits/detail/bool_trait_def.hpp b/boost/boost/type_traits/detail/bool_trait_def.hpp index 40aa3aff9e..40ec5e201b 100644 --- a/boost/boost/type_traits/detail/bool_trait_def.hpp +++ b/boost/boost/type_traits/detail/bool_trait_def.hpp @@ -8,17 +8,18 @@ // http://www.boost.org/LICENSE_1_0.txt) // $Source: /cvsroot/boost/boost/boost/type_traits/detail/bool_trait_def.hpp,v $ -// $Date: 2004/09/02 15:41:27 $ -// $Revision: 1.16 $ +// $Date: 2005/03/16 12:22:22 $ +// $Revision: 1.18 $ #include +#include #include #include #include -#if defined(__SUNPRO_CC) +#if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x570) # define BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ - typedef BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE::bool_< C > type; \ + typedef ::boost::integral_constant type; \ enum { value = type::value }; \ /**/ # define BOOST_TT_AUX_BOOL_C_BASE(C) @@ -26,7 +27,7 @@ #elif defined(BOOST_MSVC) && BOOST_MSVC <= 1200 # define BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ - typedef BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE::bool_< C > base_; \ + typedef ::boost::integral_constant base_; \ using base_::value; \ /**/ @@ -37,7 +38,7 @@ #endif #ifndef BOOST_TT_AUX_BOOL_C_BASE -# define BOOST_TT_AUX_BOOL_C_BASE(C) : BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE::bool_< C > +# define BOOST_TT_AUX_BOOL_C_BASE(C) : ::boost::integral_constant #endif @@ -148,46 +149,3 @@ template< param > struct trait##_impl< sp1,sp2 > \ BOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp,value) \ /**/ #endif - -#if 0 // there are true_type and false_type already in boost:: - // This also induces dependencies which may be undesirable - // Let's wait until sometime not just before a release and clean - // the whole ct_if mess up. -# ifndef BOOST_TT_INTEGRAL_CONSTANT -# define BOOST_TT_INTEGRAL_CONSTANT -# include - -// -// this is not a TR1 conforming integral_constant, -// but it is a first start: -// - -namespace boost{ - -template -struct integral_constant -: public BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE::integral_c {}; - - -template<> struct integral_constant< bool, true > \ - BOOST_TT_AUX_BOOL_C_BASE(true) \ -{ \ - BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(true) \ - BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(1,integral_constant,(bool)) \ -}; -template<> struct integral_constant< bool, false > \ - BOOST_TT_AUX_BOOL_C_BASE(false) \ -{ \ - BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(false) \ - BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(1,integral_constant,(bool)) \ -}; - -namespace pending { -typedef BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE::true_ true_type; -typedef BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE::false_ false_type; -} - -} - -# endif -#endif diff --git a/boost/boost/type_traits/detail/cv_traits_impl.hpp b/boost/boost/type_traits/detail/cv_traits_impl.hpp index 9f59f290f0..eee7c7d2a2 100644 --- a/boost/boost/type_traits/detail/cv_traits_impl.hpp +++ b/boost/boost/type_traits/detail/cv_traits_impl.hpp @@ -12,13 +12,22 @@ #define BOOST_TT_DETAIL_CV_TRAITS_IMPL_HPP_INCLUDED #include "boost/config.hpp" +#include "boost/detail/workaround.hpp" #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +// implementation helper: + + +#if !(BOOST_WORKAROUND(__GNUC__,== 3) && (__GNUC_MINOR__ <= 2)) namespace boost { namespace detail { - -// implementation helper: +#else +#include "boost/type_traits/detail/yes_no_type.hpp" +namespace boost { +namespace type_traits { +namespace gcc8503 { +#endif template struct cv_traits_imp {}; @@ -54,6 +63,32 @@ struct cv_traits_imp typedef T unqualified_type; }; +#if BOOST_WORKAROUND(__GNUC__,== 3) && BOOST_WORKAROUND(__GNUC_MINOR__, <= 2) +// We have to exclude function pointers +// (see http://gcc.gnu.org/bugzilla/show_bug.cgi?8503) +yes_type mini_funcptr_tester(...); +no_type mini_funcptr_tester(const volatile void*); + +} // namespace gcc8503 +} // namespace type_traits + +namespace detail { + +// Use the implementation above for non function pointers +template +struct cv_traits_imp : ::boost::type_traits::gcc8503::cv_traits_imp { }; + +// Functions are never cv-qualified +template struct cv_traits_imp +{ + BOOST_STATIC_CONSTANT(bool, is_const = false); + BOOST_STATIC_CONSTANT(bool, is_volatile = false); + typedef T unqualified_type; +}; + +#endif + } // namespace detail } // namespace boost diff --git a/boost/boost/type_traits/detail/is_function_ptr_helper.hpp b/boost/boost/type_traits/detail/is_function_ptr_helper.hpp index 20c7f80e2a..7a6fdda761 100644 --- a/boost/boost/type_traits/detail/is_function_ptr_helper.hpp +++ b/boost/boost/type_traits/detail/is_function_ptr_helper.hpp @@ -35,84 +35,162 @@ struct is_function_ptr_helper #if !defined(BOOST_TT_PREPROCESSING_MODE) // preprocessor-generated part, don't edit by hand! -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - -template -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool,value = true); }; - +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif #else #undef BOOST_STATIC_CONSTANT @@ -130,10 +208,13 @@ struct is_function_ptr_helper -struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; - -#undef i +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +@#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_function_ptr_helper { BOOST_STATIC_CONSTANT(bool, value = true); }; +@#endif +#undef BOOST_PP_COUNTER #endif // BOOST_PP_IS_ITERATING diff --git a/boost/boost/type_traits/detail/is_mem_fun_pointer_impl.hpp b/boost/boost/type_traits/detail/is_mem_fun_pointer_impl.hpp index 4d35dc3a8b..a9f0f5ec14 100644 --- a/boost/boost/type_traits/detail/is_mem_fun_pointer_impl.hpp +++ b/boost/boost/type_traits/detail/is_mem_fun_pointer_impl.hpp @@ -32,292 +32,736 @@ struct is_mem_fun_pointer_impl }; #if !defined(BOOST_TT_PREPROCESSING_MODE) -// preprocessor-generated part, don't edit by hand! +// pre-processed code, don't edit, try GNU cpp with +// cpp -I../../../ -DBOOST_TT_PREPROCESSING_MODE -x c++ -P filename -template +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#endif -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template -struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template -struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template -struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; #endif -template +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif +#endif +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif + +#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template + +template struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +#endif #endif #else @@ -337,23 +781,37 @@ struct is_mem_fun_pointer_impl -struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +@#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +@#endif -// Metrowerks and Visual Age think this creates ambiguities -/// #if !((defined(__MWERKS__) && __MWERKS__ < 0x3000) || (defined(__IBMCPP__) && __IBMCPP__ <= 600)) -template -struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +@#if !defined(BOOST_TT_NO_CV_FUNC_TEST) +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template -struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -template -struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -/// #endif +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +@#ifndef BOOST_TT_NO_ELLIPSIS_IN_FUNC_TESTING +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; -#undef i +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; + +template +struct is_mem_fun_pointer_impl { BOOST_STATIC_CONSTANT(bool, value = true); }; +@#endif +@#endif + +#undef BOOST_PP_COUNTER #endif // BOOST_PP_IS_ITERATING + diff --git a/boost/boost/type_traits/detail/size_t_trait_def.hpp b/boost/boost/type_traits/detail/size_t_trait_def.hpp index 0cd2a950c2..ec169b9306 100644 --- a/boost/boost/type_traits/detail/size_t_trait_def.hpp +++ b/boost/boost/type_traits/detail/size_t_trait_def.hpp @@ -8,20 +8,23 @@ // http://www.boost.org/LICENSE_1_0.txt) // $Source: /cvsroot/boost/boost/boost/type_traits/detail/size_t_trait_def.hpp,v $ -// $Date: 2004/09/02 15:41:27 $ -// $Revision: 1.7 $ +// $Date: 2005/01/30 15:47:45 $ +// $Revision: 1.8 $ #include -#include +#include #include +#include #include #if !defined(BOOST_MSVC) || BOOST_MSVC > 1200 +# define BOOST_TT_AUX_SIZE_T_BASE(C) ::boost::integral_constant # define BOOST_TT_AUX_SIZE_T_TRAIT_VALUE_DECL(C) /**/ #else +# define BOOST_TT_AUX_SIZE_T_BASE(C) ::boost::mpl::size_t # define BOOST_TT_AUX_SIZE_T_TRAIT_VALUE_DECL(C) \ - typedef mpl::size_t< C > base_; \ + typedef ::boost::mpl::size_t base_; \ using base_::value; \ /**/ #endif @@ -29,7 +32,7 @@ #define BOOST_TT_AUX_SIZE_T_TRAIT_DEF1(trait,T,C) \ template< typename T > struct trait \ - : mpl::size_t< C > \ + : BOOST_TT_AUX_SIZE_T_BASE(C) \ { \ BOOST_TT_AUX_SIZE_T_TRAIT_VALUE_DECL(C) \ BOOST_MPL_AUX_LAMBDA_SUPPORT(1,trait,(T)) \ @@ -40,7 +43,7 @@ BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1,trait) \ #define BOOST_TT_AUX_SIZE_T_TRAIT_SPEC1(trait,spec,C) \ template<> struct trait \ - : mpl::size_t< C > \ + : BOOST_TT_AUX_SIZE_T_BASE(C) \ { \ BOOST_TT_AUX_SIZE_T_TRAIT_VALUE_DECL(C) \ BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(1,trait,(spec)) \ @@ -49,7 +52,7 @@ template<> struct trait \ #define BOOST_TT_AUX_SIZE_T_TRAIT_PARTIAL_SPEC1_1(param,trait,spec,C) \ template< param > struct trait \ - : mpl::size_t< C > \ + : BOOST_TT_AUX_SIZE_T_BASE(C) \ { \ }; \ /**/ diff --git a/boost/boost/type_traits/extent.hpp b/boost/boost/type_traits/extent.hpp new file mode 100644 index 0000000000..88f98dd2de --- /dev/null +++ b/boost/boost/type_traits/extent.hpp @@ -0,0 +1,134 @@ + +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). +// +// See http://www.boost.org/libs/type_traits for most recent version including documentation. + + +#ifndef BOOST_TT_EXTENT_HPP_INCLUDED +#define BOOST_TT_EXTENT_HPP_INCLUDED + +// should be the last #include +#include "boost/type_traits/detail/size_t_trait_def.hpp" + +namespace boost { + +namespace detail{ + +template +struct extent_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = 0); +}; +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS) +template +struct extent_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp::value)); +}; + +template +struct extent_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp::value)); +}; + +template +struct extent_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp::value)); +}; + +template +struct extent_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp::value)); +}; + +template +struct extent_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = R); +}; + +template +struct extent_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = R); +}; + +template +struct extent_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = R); +}; + +template +struct extent_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = R); +}; + +#if !BOOST_WORKAROUND(__BORLANDC__, < 0x600) && !defined(__IBMCPP__) && !BOOST_WORKAROUND(__DMC__, BOOST_TESTED_AT(0x840)) && !defined(__MWERKS__) +template +struct extent_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp::value)); +}; +template +struct extent_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp::value)); +}; +template +struct extent_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp::value)); +}; +template +struct extent_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::extent_imp::value)); +}; +template +struct extent_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = 0); +}; +template +struct extent_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = 0); +}; +template +struct extent_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = 0); +}; +template +struct extent_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = 0); +}; +#endif +#endif +} + +template +struct extent + : public ::boost::integral_constant::value> +{ +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200) + typedef ::boost::integral_constant::value> base_; + using base_::value; +#endif + BOOST_MPL_AUX_LAMBDA_SUPPORT(1,extent,(T)) +}; + +} // namespace boost + +#include "boost/type_traits/detail/size_t_trait_undef.hpp" + +#endif // BOOST_TT_IS_MEMBER_FUNCTION_POINTER_HPP_INCLUDED diff --git a/boost/boost/type_traits/has_nothrow_assign.hpp b/boost/boost/type_traits/has_nothrow_assign.hpp index 9bc0107e99..2f52924565 100644 --- a/boost/boost/type_traits/has_nothrow_assign.hpp +++ b/boost/boost/type_traits/has_nothrow_assign.hpp @@ -16,7 +16,20 @@ namespace boost { -BOOST_TT_AUX_BOOL_TRAIT_DEF1(has_nothrow_assign,T,::boost::has_trivial_assign::value) +namespace detail{ + +template +struct has_nothrow_assign_imp{ + BOOST_STATIC_CONSTANT(bool, value = + (::boost::type_traits::ice_or< + ::boost::has_trivial_assign::value, + BOOST_HAS_NOTHROW_ASSIGN(T) + >::value)); +}; + +} + +BOOST_TT_AUX_BOOL_TRAIT_DEF1(has_nothrow_assign,T,::boost::detail::has_nothrow_assign_imp::value) } // namespace boost diff --git a/boost/boost/type_traits/has_nothrow_constructor.hpp b/boost/boost/type_traits/has_nothrow_constructor.hpp index 8fea675650..f3c7ce764b 100644 --- a/boost/boost/type_traits/has_nothrow_constructor.hpp +++ b/boost/boost/type_traits/has_nothrow_constructor.hpp @@ -16,7 +16,20 @@ namespace boost { -BOOST_TT_AUX_BOOL_TRAIT_DEF1(has_nothrow_constructor,T,::boost::has_trivial_constructor::value) +namespace detail{ + +template +struct has_nothrow_constructor_imp{ + BOOST_STATIC_CONSTANT(bool, value = + (::boost::type_traits::ice_or< + ::boost::has_trivial_constructor::value, + BOOST_HAS_NOTHROW_CONSTRUCTOR(T) + >::value)); +}; + +} + +BOOST_TT_AUX_BOOL_TRAIT_DEF1(has_nothrow_constructor,T,::boost::detail::has_nothrow_constructor_imp::value) } // namespace boost diff --git a/boost/boost/type_traits/has_nothrow_copy.hpp b/boost/boost/type_traits/has_nothrow_copy.hpp index dd9a82678a..5c83412e0e 100644 --- a/boost/boost/type_traits/has_nothrow_copy.hpp +++ b/boost/boost/type_traits/has_nothrow_copy.hpp @@ -16,7 +16,20 @@ namespace boost { -BOOST_TT_AUX_BOOL_TRAIT_DEF1(has_nothrow_copy,T,::boost::has_trivial_copy::value) +namespace detail{ + +template +struct has_nothrow_copy_imp{ + BOOST_STATIC_CONSTANT(bool, value = + (::boost::type_traits::ice_or< + ::boost::has_trivial_copy::value, + BOOST_HAS_NOTHROW_COPY(T) + >::value)); +}; + +} + +BOOST_TT_AUX_BOOL_TRAIT_DEF1(has_nothrow_copy,T,::boost::detail::has_nothrow_copy_imp::value) } // namespace boost diff --git a/boost/boost/type_traits/has_virtual_destructor.hpp b/boost/boost/type_traits/has_virtual_destructor.hpp new file mode 100644 index 0000000000..4d15704d9d --- /dev/null +++ b/boost/boost/type_traits/has_virtual_destructor.hpp @@ -0,0 +1,25 @@ + +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). +// +// See http://www.boost.org/libs/type_traits for most recent version including documentation. + + +#ifndef BOOST_TT_HAS_VIRTUAL_DESTRUCTOR_HPP_INCLUDED +#define BOOST_TT_HAS_VIRTUAL_DESTRUCTOR_HPP_INCLUDED + +#include +// should be the last #include +#include "boost/type_traits/detail/bool_trait_def.hpp" + +namespace boost { + +BOOST_TT_AUX_BOOL_TRAIT_DEF1(has_virtual_destructor,T,BOOST_HAS_VIRTUAL_DESTRUCTOR(T)) + +} // namespace boost + +#include "boost/type_traits/detail/bool_trait_undef.hpp" + +#endif // BOOST_TT_IS_MEMBER_FUNCTION_POINTER_HPP_INCLUDED diff --git a/boost/boost/type_traits/integral_constant.hpp b/boost/boost/type_traits/integral_constant.hpp new file mode 100644 index 0000000000..26f952a497 --- /dev/null +++ b/boost/boost/type_traits/integral_constant.hpp @@ -0,0 +1,82 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_TYPE_TRAITS_INTEGRAL_CONSTANT_HPP +#define BOOST_TYPE_TRAITS_INTEGRAL_CONSTANT_HPP + +#include +#include +#include + +namespace boost{ + +#if defined(BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS) || defined(__BORLANDC__) +template +#else +template +#endif +struct integral_constant : public mpl::integral_c +{ + //BOOST_STATIC_CONSTANT(T, value = val); + //typedef T value_type; + typedef integral_constant type; + +#if 0 + // + // everything that follows now, is MPL-compatibility code: + // + typedef ::boost::mpl::integral_c_tag tag; + + // have to #ifdef here: some compilers don't like the 'val + 1' form (MSVC), + // while some other don't like 'value + 1' (Borland), and some don't like + // either +#if BOOST_WORKAROUND(__EDG_VERSION__, <= 243) +private: + BOOST_STATIC_CONSTANT(T, next_value = BOOST_MPL_AUX_STATIC_CAST(T, (val + 1))); + BOOST_STATIC_CONSTANT(T, prior_value = BOOST_MPL_AUX_STATIC_CAST(T, (val - 1))); +public: + typedef integral_constant next; + typedef integral_constant prior; +#elif BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x561)) \ + || BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(502)) \ + || BOOST_WORKAROUND(__HP_aCC, BOOST_TESTED_AT(53800)) + typedef integral_constant next; + typedef integral_constant prior; +#else + typedef integral_constant next; + typedef integral_constant prior; +#endif + + // enables uniform function call syntax for families of overloaded + // functions that return objects of both arithmetic ('int', 'long', + // 'double', etc.) and wrapped integral types (for an example, see + // "mpl/example/power.cpp") + operator T() const { return static_cast(this->value); } +#endif +}; + +template<> struct integral_constant : public mpl::true_ +{ +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200) + typedef mpl::true_ base_; + using base_::value; +#endif + typedef integral_constant type; +}; +template<> struct integral_constant : public mpl::false_ +{ +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200) + typedef mpl::false_ base_; + using base_::value; +#endif + typedef integral_constant type; +}; + +typedef integral_constant true_type; +typedef integral_constant false_type; + +} + +#endif diff --git a/boost/boost/type_traits/intrinsics.hpp b/boost/boost/type_traits/intrinsics.hpp index 55f22e373b..f993613a91 100644 --- a/boost/boost/type_traits/intrinsics.hpp +++ b/boost/boost/type_traits/intrinsics.hpp @@ -27,6 +27,10 @@ // BOOST_HAS_TRIVIAL_COPY(T) should evaluate to true if T(t) <==> memcpy // BOOST_HAS_TRIVIAL_ASSIGN(T) should evaluate to true if t = u <==> memcpy // BOOST_HAS_TRIVIAL_DESTRUCTOR(T) should evaluate to true if ~T() has no effect +// BOOST_HAS_NOTHROW_CONSTRUCTOR(T) should evaluate to true if "T x;" can not throw +// BOOST_HAS_NOTHROW_COPY(T) should evaluate to true if T(t) can not throw +// BOOST_HAS_NOTHROW_ASSIGN(T) should evaluate to true if t = u can not throw +// BOOST_HAS_VIRTUAL_DESTRUCTOR(T) should evaluate to true T has a virtual destructor #ifdef BOOST_HAS_SGI_TYPE_TRAITS // Hook into SGI's __type_traits class, this will pick up user supplied @@ -59,6 +63,22 @@ # define BOOST_HAS_TYPE_TRAITS_INTRINSICS #endif +#if defined(BOOST_MSVC) && defined(_MSC_FULL_VER) && (_MSC_FULL_VER >=140050215) +# define BOOST_IS_UNION(T) __is_union(T) +# define BOOST_IS_POD(T) __is_pod(T) +# define BOOST_IS_EMPTY(T) __is_empty(T) +# define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) __has_trivial_constructor(T) +# define BOOST_HAS_TRIVIAL_COPY(T) __has_trivial_copy(T) +# define BOOST_HAS_TRIVIAL_ASSIGN(T) __has_trivial_assign(T) +# define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T) +# define BOOST_HAS_NOTHROW_CONSTRUCTOR(T) __has_nothrow_constructor(T) +# define BOOST_HAS_NOTHROW_COPY(T) __has_nothrow_copy(T) +# define BOOST_HAS_NOTHROW_ASSIGN(T) __has_nothrow_assign(T) +# define BOOST_HAS_VIRTUAL_DESTRUCTOR(T) __has_virtual_destructor(T) +# define BOOST_HAS_TYPE_TRAITS_INTRINSICS +#endif + + #ifndef BOOST_IS_UNION # define BOOST_IS_UNION(T) false #endif @@ -87,6 +107,22 @@ # define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) false #endif +#ifndef BOOST_HAS_NOTHROW_CONSTRUCTOR +# define BOOST_HAS_NOTHROW_CONSTRUCTOR(T) false +#endif + +#ifndef BOOST_HAS_NOTHROW_COPY +# define BOOST_HAS_NOTHROW_COPY(T) false +#endif + +#ifndef BOOST_HAS_NOTHROW_ASSIGN +# define BOOST_HAS_NOTHROW_ASSIGN(T) false +#endif + +#ifndef BOOST_HAS_VIRTUAL_DESTRUCTOR +# define BOOST_HAS_VIRTUAL_DESTRUCTOR(T) false +#endif + #endif // BOOST_TT_INTRINSICS_HPP_INCLUDED diff --git a/boost/boost/type_traits/is_abstract.hpp b/boost/boost/type_traits/is_abstract.hpp index 48d98e5888..4f9b79128a 100755 --- a/boost/boost/type_traits/is_abstract.hpp +++ b/boost/boost/type_traits/is_abstract.hpp @@ -41,11 +41,20 @@ // (starting with submission #10). // - Jan 2004: GCC 3.4 fixed to suport DR337 (Giovanni Bajo). // - Jan 2004: modified to be part of Boost.TypeTraits (Pavel Vozenilek). +// - Nov 2004: Christoph Ludwig found that the implementation did not work with +// template types and gcc-3.4 or VC7.1, fix due to Christoph Ludwig +// and John Maddock. +// - Dec 2004: Added new config macro BOOST_NO_IS_ABSTRACT which causes the template +// to degrade gracefully, rather than trash the compiler (John Maddock). // +#include #include #include #include "boost/type_traits/detail/ice_and.hpp" +#ifdef BOOST_NO_IS_ABSTRACT +#include +#endif // should be the last #include #include "boost/type_traits/detail/bool_trait_def.hpp" @@ -53,8 +62,9 @@ namespace boost { namespace detail{ +#ifndef BOOST_NO_IS_ABSTRACT template -struct is_abstract_imp +struct is_abstract_imp2 { // Deduction fails if T is void, function type, // reference type (14.8.2/2)or an abstract class type @@ -64,25 +74,61 @@ struct is_abstract_imp static type_traits::no_type check_sig(U (*)[1]); template static type_traits::yes_type check_sig(...); + // + // T must be a complete type, further if T is a template then + // it must be instantiated in order for us to get the right answer: + // + BOOST_STATIC_ASSERT(sizeof(T) != 0); // GCC2 won't even parse this template if we embed the computation // of s1 in the computation of value. #ifdef __GNUC__ - BOOST_STATIC_CONSTANT(unsigned, s1 = sizeof(is_abstract_imp::template check_sig(0))); + BOOST_STATIC_CONSTANT(unsigned, s1 = sizeof(is_abstract_imp2::template check_sig(0))); #else BOOST_STATIC_CONSTANT(unsigned, s1 = sizeof(check_sig(0))); #endif BOOST_STATIC_CONSTANT(bool, value = - (::boost::type_traits::ice_and< - ::boost::is_class::value, - (s1 == sizeof(type_traits::yes_type)) - >::value)); + (s1 == sizeof(type_traits::yes_type))); }; +template +struct is_abstract_select +{ + template + struct rebind + { + typedef is_abstract_imp2 type; + }; +}; +template <> +struct is_abstract_select +{ + template + struct rebind + { + typedef false_type type; + }; +}; + +template +struct is_abstract_imp +{ + typedef is_abstract_select< ::boost::is_class::value> selector; + typedef typename selector::template rebind binder; + typedef typename binder::type type; + + BOOST_STATIC_CONSTANT(bool, value = type::value); +}; + +#endif } +#ifndef BOOST_NO_IS_ABSTRACT BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_abstract,T,::boost::detail::is_abstract_imp::value) +#else +BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_abstract,T,::boost::detail::is_polymorphic_imp::value) +#endif } // namespace boost diff --git a/boost/boost/type_traits/is_base_and_derived.hpp b/boost/boost/type_traits/is_base_and_derived.hpp index 7e0ffe5807..cf420d8bcb 100644 --- a/boost/boost/type_traits/is_base_and_derived.hpp +++ b/boost/boost/type_traits/is_base_and_derived.hpp @@ -110,9 +110,19 @@ google.com and links therein. template struct bd_helper { + // + // This VC7.1 specific workaround stops the compiler from generating + // an internal compiler error when compiling with /vmg (thanks to + // Aleksey Gurtovoy for figuring out the workaround). + // +#if !BOOST_WORKAROUND(BOOST_MSVC, == 1310) template static type_traits::yes_type check_sig(D const volatile *, T); static type_traits::no_type check_sig(B const volatile *, int); +#else + static type_traits::yes_type check_sig(D const volatile *, long); + static type_traits::no_type check_sig(B const volatile * const&, int); +#endif }; template @@ -120,7 +130,11 @@ struct is_base_and_derived_impl2 { struct Host { +#if !BOOST_WORKAROUND(BOOST_MSVC, == 1310) operator B const volatile *() const; +#else + operator B const volatile * const&() const; +#endif operator D const volatile *(); }; diff --git a/boost/boost/type_traits/is_base_of.hpp b/boost/boost/type_traits/is_base_of.hpp new file mode 100644 index 0000000000..a02a15ffd2 --- /dev/null +++ b/boost/boost/type_traits/is_base_of.hpp @@ -0,0 +1,36 @@ + +// (C) Copyright Rani Sharoni 2003-2005. +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). +// +// See http://www.boost.org/libs/type_traits for most recent version including documentation. + +#ifndef BOOST_TT_IS_BASE_OF_HPP_INCLUDED +#define BOOST_TT_IS_BASE_OF_HPP_INCLUDED + +#include "boost/type_traits/is_base_and_derived.hpp" + +// should be the last #include +#include "boost/type_traits/detail/bool_trait_def.hpp" + +namespace boost { + +BOOST_TT_AUX_BOOL_TRAIT_DEF2( + is_base_of + , Base + , Derived + , (::boost::detail::is_base_and_derived_impl::value) + ) + +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(typename Base,typename Derived,is_base_of,Base&,Derived,false) +BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(typename Base,typename Derived,is_base_of,Base,Derived&,false) +BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(typename Base,typename Derived,is_base_of,Base&,Derived&,false) +#endif + +} // namespace boost + +#include "boost/type_traits/detail/bool_trait_undef.hpp" + +#endif // BOOST_TT_IS_BASE_AND_DERIVED_HPP_INCLUDED diff --git a/boost/boost/type_traits/is_convertible.hpp b/boost/boost/type_traits/is_convertible.hpp index 88a8ccf35c..5b62877f3f 100644 --- a/boost/boost/type_traits/is_convertible.hpp +++ b/boost/boost/type_traits/is_convertible.hpp @@ -17,6 +17,10 @@ #include "boost/type_traits/is_array.hpp" #include "boost/type_traits/add_reference.hpp" #include "boost/type_traits/ice.hpp" +#include "boost/type_traits/is_arithmetic.hpp" +#ifndef BOOST_NO_IS_ABSTRACT +#include "boost/type_traits/is_abstract.hpp" +#endif #if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300) # include "boost/type_traits/is_void.hpp" @@ -125,7 +129,7 @@ struct is_convertible_basic_impl }; #elif (defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 245) && !defined(__ICL)) \ - || defined(__IBMCPP__) + || defined(__IBMCPP__) || defined(__HP_aCC) // // This is *almost* an ideal world implementation as it doesn't rely // on undefined behaviour by passing UDT's through (...). @@ -232,6 +236,71 @@ struct is_convertible_impl }; #endif +template +struct is_convertible_impl_select +{ + template + struct rebind + { + typedef is_convertible_impl type; + }; +}; + +template <> +struct is_convertible_impl_select +{ + template + struct rebind + { + typedef true_type type; + }; +}; + +template <> +struct is_convertible_impl_select +{ + template + struct rebind + { + typedef false_type type; + }; +}; + +template <> +struct is_convertible_impl_select +{ + template + struct rebind + { + typedef false_type type; + }; +}; + +template +struct is_convertible_impl_dispatch_base +{ +#ifndef __HP_aCC + typedef is_convertible_impl_select< + ::boost::is_arithmetic::value, + ::boost::is_arithmetic::value, +#ifndef BOOST_NO_IS_ABSTRACT + ::boost::is_abstract::value +#else + false +#endif + > selector; +#else + typedef is_convertible_impl_select selector; +#endif + typedef typename selector::template rebind isc_binder; + typedef typename isc_binder::type type; +}; + +template +struct is_convertible_impl_dispatch + : public is_convertible_impl_dispatch_base::type +{}; + // // Now add the full and partial specialisations // for void types, these are common to all the @@ -276,51 +345,7 @@ BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,v } // namespace detail -BOOST_TT_AUX_BOOL_TRAIT_DEF2(is_convertible,From,To,(::boost::detail::is_convertible_impl::value)) - - -#if defined(__GNUC__) - -// Declare specializations of is_convertible for all of the floating -// types to all of the integral types. This suppresses some nasty -// warnings - -# define TT_AUX_IS_CONVERTIBLE_SPEC(T1,T2) \ - BOOST_TT_AUX_BOOL_TRAIT_SPEC2(is_convertible,T1,T2,true) \ - /**/ - -# define TT_AUX_IS_CONVERTIBLE_SPEC_2(T1,T2) \ - TT_AUX_IS_CONVERTIBLE_SPEC(T1,signed T2) \ - TT_AUX_IS_CONVERTIBLE_SPEC(T1,unsigned T2) \ - /**/ - -# define TT_AUX_IS_CONVERTIBLE_FROM_FLOAT_SPEC(F) \ - TT_AUX_IS_CONVERTIBLE_SPEC(F,char) \ - TT_AUX_IS_CONVERTIBLE_SPEC_2(F,char) \ - TT_AUX_IS_CONVERTIBLE_SPEC_2(F,short) \ - TT_AUX_IS_CONVERTIBLE_SPEC_2(F,int) \ - TT_AUX_IS_CONVERTIBLE_SPEC_2(F,long) \ - TT_AUX_IS_CONVERTIBLE_SPEC(F,::boost::long_long_type) \ - TT_AUX_IS_CONVERTIBLE_SPEC(F,::boost::ulong_long_type) \ - /**/ - -# define TT_AUX_IS_CONVERTIBLE_FROM_FLOAT_CV_SPEC(F) \ - TT_AUX_IS_CONVERTIBLE_FROM_FLOAT_SPEC(F) \ - TT_AUX_IS_CONVERTIBLE_FROM_FLOAT_SPEC(F const) \ - TT_AUX_IS_CONVERTIBLE_FROM_FLOAT_SPEC(F volatile) \ - TT_AUX_IS_CONVERTIBLE_FROM_FLOAT_SPEC(F const volatile) \ - /**/ - -TT_AUX_IS_CONVERTIBLE_FROM_FLOAT_CV_SPEC(float) -TT_AUX_IS_CONVERTIBLE_FROM_FLOAT_CV_SPEC(double) -TT_AUX_IS_CONVERTIBLE_FROM_FLOAT_CV_SPEC(long double) - -# undef TT_AUX_IS_CONVERTIBLE_FROM_FLOAT_CV_SPEC -# undef TT_AUX_IS_CONVERTIBLE_FROM_FLOAT_SPEC -# undef TT_AUX_IS_CONVERTIBLE_SPEC_2 -# undef TT_AUX_IS_CONVERTIBLE_SPEC - -#endif // __GNUC__ +BOOST_TT_AUX_BOOL_TRAIT_DEF2(is_convertible,From,To,(::boost::detail::is_convertible_impl_dispatch::value)) } // namespace boost diff --git a/boost/boost/type_traits/is_enum.hpp b/boost/boost/type_traits/is_enum.hpp index 0661c97006..3b81b7f74a 100644 --- a/boost/boost/type_traits/is_enum.hpp +++ b/boost/boost/type_traits/is_enum.hpp @@ -15,6 +15,7 @@ #include "boost/type_traits/is_arithmetic.hpp" #include "boost/type_traits/is_reference.hpp" #include "boost/type_traits/is_convertible.hpp" +#include "boost/type_traits/is_array.hpp" #ifdef __GNUC__ #include #endif @@ -91,44 +92,53 @@ template <> struct is_enum_helper { template struct type - : ::boost::is_convertible + : ::boost::is_convertible::type,::boost::detail::int_convertible> { }; }; template struct is_enum_impl { - typedef ::boost::add_reference ar_t; - typedef typename ar_t::type r_type; + //typedef ::boost::add_reference ar_t; + //typedef typename ar_t::type r_type; #if defined(__GNUC__) #ifdef BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION + + // We MUST check for is_class_or_union on conforming compilers in + // order to correctly deduce that noncopyable types are not enums + // (dwa 2002/04/15)... BOOST_STATIC_CONSTANT(bool, selector = (::boost::type_traits::ice_or< ::boost::is_arithmetic::value , ::boost::is_reference::value , ::boost::is_function::value , is_class_or_union::value + , is_array::value >::value)); #else + // ...however, not checking is_class_or_union on non-conforming + // compilers prevents a dependency recursion. BOOST_STATIC_CONSTANT(bool, selector = (::boost::type_traits::ice_or< ::boost::is_arithmetic::value , ::boost::is_reference::value , ::boost::is_function::value + , is_array::value >::value)); #endif // BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION -#else +#else // !defined(__GNUC__): + BOOST_STATIC_CONSTANT(bool, selector = (::boost::type_traits::ice_or< ::boost::is_arithmetic::value , ::boost::is_reference::value , is_class_or_union::value - // However, not doing this on non-conforming compilers prevents - // a dependency recursion. + , is_array::value >::value)); + #endif #if BOOST_WORKAROUND(__BORLANDC__, < 0x600) @@ -139,7 +149,7 @@ template struct is_enum_impl typedef ::boost::detail::is_enum_helper se_t; #endif - typedef typename se_t::template type helper; + typedef typename se_t::template type helper; BOOST_STATIC_CONSTANT(bool, value = helper::value); }; diff --git a/boost/boost/type_traits/is_floating_point.hpp b/boost/boost/type_traits/is_floating_point.hpp new file mode 100644 index 0000000000..eec7c85070 --- /dev/null +++ b/boost/boost/type_traits/is_floating_point.hpp @@ -0,0 +1,27 @@ + +// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000-2005. +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). +// +// See http://www.boost.org/libs/type_traits for most recent version including documentation. + +#ifndef BOOST_TYPE_TRAITS_IS_FLOATING_HPP_INCLUDED +#define BOOST_TYPE_TRAITS_IS_FLOATING_HPP_INCLUDED + +// should be the last #include +#include "boost/type_traits/detail/bool_trait_def.hpp" + +namespace boost { + +//* is a type T a floating-point type described in the standard (3.9.1p8) +BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_floating_point,T,false) +BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(is_floating_point,float,true) +BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(is_floating_point,double,true) +BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(is_floating_point,long double,true) + +} // namespace boost + +#include "boost/type_traits/detail/bool_trait_undef.hpp" + +#endif // BOOST_TYPE_TRAITS_IS_FLOAT_HPP_INCLUDED diff --git a/boost/boost/type_traits/is_function.hpp b/boost/boost/type_traits/is_function.hpp index ef22d71f38..ecb0b5d665 100644 --- a/boost/boost/type_traits/is_function.hpp +++ b/boost/boost/type_traits/is_function.hpp @@ -15,7 +15,7 @@ #include "boost/type_traits/detail/false_result.hpp" #include "boost/config.hpp" -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_TT_TEST_MS_FUNC_SIGS) # include "boost/type_traits/detail/is_function_ptr_helper.hpp" #else # include "boost/type_traits/detail/is_function_ptr_tester.hpp" @@ -34,7 +34,7 @@ namespace boost { namespace detail { -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_TT_TEST_MS_FUNC_SIGS) template struct is_function_chooser : ::boost::type_traits::false_result @@ -69,6 +69,12 @@ struct is_function_impl ); }; +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) +template +struct is_function_impl : public false_type +{}; +#endif + #endif } // namespace detail diff --git a/boost/boost/type_traits/is_member_function_pointer.hpp b/boost/boost/type_traits/is_member_function_pointer.hpp index d6ccd2276c..1cba5bf76c 100644 --- a/boost/boost/type_traits/is_member_function_pointer.hpp +++ b/boost/boost/type_traits/is_member_function_pointer.hpp @@ -14,15 +14,21 @@ #include "boost/type_traits/config.hpp" #include "boost/detail/workaround.hpp" -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !BOOST_WORKAROUND(__BORLANDC__, < 0x600) +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ + && !BOOST_WORKAROUND(__BORLANDC__, < 0x600) && !defined(BOOST_TT_TEST_MS_FUNC_SIGS) + // + // Note: we use the "workaround" version for MSVC because it works for + // __stdcall etc function types, where as the partial specialisation + // version does not do so. + // # include "boost/type_traits/detail/is_mem_fun_pointer_impl.hpp" #else # include "boost/type_traits/is_reference.hpp" # include "boost/type_traits/is_array.hpp" -# include "boost/type_traits/detail/is_mem_fun_pointer_tester.hpp" # include "boost/type_traits/detail/yes_no_type.hpp" # include "boost/type_traits/detail/false_result.hpp" # include "boost/type_traits/detail/ice_or.hpp" +# include "boost/type_traits/detail/is_mem_fun_pointer_tester.hpp" #endif // should be the last #include @@ -30,7 +36,7 @@ namespace boost { -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !BOOST_WORKAROUND(__BORLANDC__, < 0x600) +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !BOOST_WORKAROUND(__BORLANDC__, < 0x600) && !defined(BOOST_TT_TEST_MS_FUNC_SIGS) BOOST_TT_AUX_BOOL_TRAIT_DEF1( is_member_function_pointer @@ -55,7 +61,7 @@ struct is_mem_fun_pointer_select { template struct result_ { - static T& make_t; + static T* make_t; typedef result_ self_type; BOOST_STATIC_CONSTANT( @@ -76,12 +82,17 @@ struct is_member_function_pointer_impl { }; +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +template +struct is_member_function_pointer_impl : public false_type{}; +#endif + #else // Borland C++ template struct is_member_function_pointer_impl { - static T& m_t; + static T* m_t; BOOST_STATIC_CONSTANT( bool, value = (1 == sizeof(type_traits::is_mem_fun_pointer_tester(m_t))) ); diff --git a/boost/boost/type_traits/is_member_object_pointer.hpp b/boost/boost/type_traits/is_member_object_pointer.hpp new file mode 100644 index 0000000000..b1e8bf2817 --- /dev/null +++ b/boost/boost/type_traits/is_member_object_pointer.hpp @@ -0,0 +1,46 @@ + +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). +// +// See http://www.boost.org/libs/type_traits for most recent version including documentation. + + +#ifndef BOOST_TT_IS_MEMBER_OBJECT_POINTER_HPP_INCLUDED +#define BOOST_TT_IS_MEMBER_OBJECT_POINTER_HPP_INCLUDED + +#include "boost/type_traits/config.hpp" +#include "boost/type_traits/is_member_pointer.hpp" +#include "boost/type_traits/is_member_function_pointer.hpp" +#include "boost/type_traits/detail/ice_and.hpp" +#include "boost/type_traits/detail/ice_not.hpp" + +// should be the last #include +#include "boost/type_traits/detail/bool_trait_def.hpp" + +namespace boost { + +namespace detail{ + +template +struct is_member_object_pointer_impl +{ + BOOST_STATIC_CONSTANT( + bool, value = (::boost::type_traits::ice_and< + ::boost::is_member_pointer::value, + ::boost::type_traits::ice_not< + ::boost::is_member_function_pointer::value + >::value + >::value )); +}; + +} // namespace detail + +BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_member_object_pointer,T,::boost::detail::is_member_object_pointer_impl::value) + +} // namespace boost + +#include "boost/type_traits/detail/bool_trait_undef.hpp" + +#endif // BOOST_TT_IS_MEMBER_FUNCTION_POINTER_HPP_INCLUDED diff --git a/boost/boost/type_traits/is_member_pointer.hpp b/boost/boost/type_traits/is_member_pointer.hpp index a3d3e32098..2a77c6dde2 100644 --- a/boost/boost/type_traits/is_member_pointer.hpp +++ b/boost/boost/type_traits/is_member_pointer.hpp @@ -53,7 +53,7 @@ BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,typename U,is_member_pointer, namespace detail { template -::boost::type_traits::yes_type BOOST_TT_DECL is_member_pointer_tester(R T::*); +::boost::type_traits::yes_type BOOST_TT_DECL is_member_pointer_tester(R T::*const volatile*); ::boost::type_traits::no_type BOOST_TT_DECL is_member_pointer_tester(...); template @@ -67,7 +67,7 @@ struct is_member_pointer_select { template struct result_ { - static T& make_t(); + static T* make_t(); BOOST_STATIC_CONSTANT( bool, value = (::boost::type_traits::ice_or< diff --git a/boost/boost/type_traits/is_reference.hpp b/boost/boost/type_traits/is_reference.hpp index 5f05f949d9..3655373a4f 100644 --- a/boost/boost/type_traits/is_reference.hpp +++ b/boost/boost/type_traits/is_reference.hpp @@ -28,11 +28,6 @@ # include "boost/type_traits/detail/wrap.hpp" #endif -#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && defined(BOOST_MSVC) -# include "boost/type_traits/detail/is_function_type_tester.hpp" -# include "boost/type_traits/detail/false_result.hpp" -#endif - // should be the last #include #include "boost/type_traits/detail/bool_trait_def.hpp" diff --git a/boost/boost/type_traits/is_signed.hpp b/boost/boost/type_traits/is_signed.hpp new file mode 100644 index 0000000000..2b35dccc1f --- /dev/null +++ b/boost/boost/type_traits/is_signed.hpp @@ -0,0 +1,117 @@ + +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). +// +// See http://www.boost.org/libs/type_traits for most recent version including documentation. + + +#ifndef BOOST_TT_IS_SIGNED_HPP_INCLUDED +#define BOOST_TT_IS_SIGNED_HPP_INCLUDED + +#include "boost/type_traits/is_integral.hpp" +#include "boost/type_traits/is_enum.hpp" +#include "boost/type_traits/detail/ice_or.hpp" + +// should be the last #include +#include "boost/type_traits/detail/bool_trait_def.hpp" + +namespace boost { + +namespace detail{ + +#if !(defined(__EDG_VERSION__) && __EDG_VERSION__ <= 238) + +template +struct is_signed_helper +{ + BOOST_STATIC_CONSTANT(bool, value = (static_cast(-1) < 0)); +}; + +template +struct is_signed_select_helper +{ + template + struct rebind + { + typedef is_signed_helper type; + }; +}; + +template <> +struct is_signed_select_helper +{ + template + struct rebind + { + typedef false_type type; + }; +}; + +template +struct is_signed_imp +{ + typedef is_signed_select_helper< + ::boost::type_traits::ice_or< + ::boost::is_integral::value, + ::boost::is_enum::value>::value + > selector; + typedef typename selector::template rebind binder; + typedef typename binder::type type; +#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1200) + BOOST_STATIC_CONSTANT(bool, value = is_signed_imp::type::value); +#else + BOOST_STATIC_CONSTANT(bool, value = type::value); +#endif +}; + +#else + +template struct is_signed_imp : public false_type{}; +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +#ifdef BOOST_HAS_LONG_LONG +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +#endif +#if defined(CHAR_MIN) && (CHAR_MIN != 0) +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +#endif +#if defined(WCHAR_MIN) && (WCHAR_MIN != 0) +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +template <> struct is_signed_imp : public true_type{}; +#endif + +#endif + +} + +BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_signed,T,::boost::detail::is_signed_imp::value) + +} // namespace boost + +#include "boost/type_traits/detail/bool_trait_undef.hpp" + +#endif // BOOST_TT_IS_MEMBER_FUNCTION_POINTER_HPP_INCLUDED diff --git a/boost/boost/type_traits/is_unsigned.hpp b/boost/boost/type_traits/is_unsigned.hpp new file mode 100644 index 0000000000..68fb230fdd --- /dev/null +++ b/boost/boost/type_traits/is_unsigned.hpp @@ -0,0 +1,114 @@ + +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). +// +// See http://www.boost.org/libs/type_traits for most recent version including documentation. + + +#ifndef BOOST_TT_IS_UNSIGNED_HPP_INCLUDED +#define BOOST_TT_IS_UNSIGNED_HPP_INCLUDED + +#include "boost/type_traits/is_integral.hpp" +#include "boost/type_traits/is_enum.hpp" +#include "boost/type_traits/detail/ice_or.hpp" + +// should be the last #include +#include "boost/type_traits/detail/bool_trait_def.hpp" + +namespace boost { + +namespace detail{ + +#if !(defined(__EDG_VERSION__) && __EDG_VERSION__ <= 238) + +template +struct is_ununsigned_helper +{ + BOOST_STATIC_CONSTANT(bool, value = (static_cast(-1) > 0)); +}; + +template +struct is_ununsigned_select_helper +{ + template + struct rebind + { + typedef is_ununsigned_helper type; + }; +}; + +template <> +struct is_ununsigned_select_helper +{ + template + struct rebind + { + typedef false_type type; + }; +}; + +template +struct is_unsigned_imp +{ + typedef is_ununsigned_select_helper< + ::boost::type_traits::ice_or< + ::boost::is_integral::value, + ::boost::is_enum::value>::value + > selector; + typedef typename selector::template rebind binder; + typedef typename binder::type type; + BOOST_STATIC_CONSTANT(bool, value = type::value); +}; + +#else + +template struct is_unsigned_imp : public false_type{}; +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +#ifdef BOOST_HAS_LONG_LONG +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +#endif +#if defined(CHAR_MIN) && (CHAR_MIN == 0) +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +#endif +#if defined(WCHAR_MIN) && (WCHAR_MIN == 0) +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +template <> struct is_unsigned_imp : public true_type{}; +#endif + +#endif + + +} + +BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_unsigned,T,::boost::detail::is_unsigned_imp::value) + +} // namespace boost + +#include "boost/type_traits/detail/bool_trait_undef.hpp" + +#endif // BOOST_TT_IS_MEMBER_FUNCTION_POINTER_HPP_INCLUDED diff --git a/boost/boost/type_traits/rank.hpp b/boost/boost/type_traits/rank.hpp new file mode 100644 index 0000000000..43b428db2b --- /dev/null +++ b/boost/boost/type_traits/rank.hpp @@ -0,0 +1,81 @@ + +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). +// +// See http://www.boost.org/libs/type_traits for most recent version including documentation. + + +#ifndef BOOST_TT_RANK_HPP_INCLUDED +#define BOOST_TT_RANK_HPP_INCLUDED + +// should be the last #include +#include "boost/type_traits/detail/size_t_trait_def.hpp" + +namespace boost { + +namespace detail{ + +template +struct rank_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = N); +}; +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS) +template +struct rank_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::rank_imp::value)); +}; + +template +struct rank_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::rank_imp::value)); +}; + +template +struct rank_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::rank_imp::value)); +}; + +template +struct rank_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::rank_imp::value)); +}; + +#if !BOOST_WORKAROUND(__BORLANDC__, < 0x600) && !defined(__IBMCPP__) && !BOOST_WORKAROUND(__DMC__, BOOST_TESTED_AT(0x840)) +template +struct rank_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::rank_imp::value)); +}; +template +struct rank_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::rank_imp::value)); +}; +template +struct rank_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::rank_imp::value)); +}; +template +struct rank_imp +{ + BOOST_STATIC_CONSTANT(std::size_t, value = (::boost::detail::rank_imp::value)); +}; +#endif +#endif +} + +BOOST_TT_AUX_SIZE_T_TRAIT_DEF1(rank,T,(::boost::detail::rank_imp::value)) + +} // namespace boost + +#include "boost/type_traits/detail/size_t_trait_undef.hpp" + +#endif // BOOST_TT_IS_MEMBER_FUNCTION_POINTER_HPP_INCLUDED diff --git a/boost/boost/type_traits/remove_all_extents.hpp b/boost/boost/type_traits/remove_all_extents.hpp new file mode 100644 index 0000000000..b64112b51f --- /dev/null +++ b/boost/boost/type_traits/remove_all_extents.hpp @@ -0,0 +1,39 @@ + +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). +// +// See http://www.boost.org/libs/type_traits for most recent version including documentation. + +#ifndef BOOST_TT_REMOVE_ALL_EXTENTS_HPP_INCLUDED +#define BOOST_TT_REMOVE_ALL_EXTENTS_HPP_INCLUDED + +#include "boost/config.hpp" +#include + +// should be the last #include +#include "boost/type_traits/detail/type_trait_def.hpp" + +namespace boost { + +BOOST_TT_AUX_TYPE_TRAIT_DEF1(remove_all_extents,T,T) + +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS) +BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_2(typename T,std::size_t N,remove_all_extents,T[N],typename boost::remove_all_extents::type type) +BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_2(typename T,std::size_t N,remove_all_extents,T const[N],typename boost::remove_all_extents::type type) +BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_2(typename T,std::size_t N,remove_all_extents,T volatile[N],typename boost::remove_all_extents::type type) +BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_2(typename T,std::size_t N,remove_all_extents,T const volatile[N],typename boost::remove_all_extents::type type) +#if !BOOST_WORKAROUND(__BORLANDC__, < 0x600) && !defined(__IBMCPP__) && !BOOST_WORKAROUND(__DMC__, BOOST_TESTED_AT(0x840)) +BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_1(typename T,remove_all_extents,T[],typename boost::remove_all_extents::type) +BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_1(typename T,remove_all_extents,T const[],typename boost::remove_all_extents::type) +BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_1(typename T,remove_all_extents,T volatile[],typename boost::remove_all_extents::type) +BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_1(typename T,remove_all_extents,T const volatile[],typename boost::remove_all_extents::type) +#endif +#endif + +} // namespace boost + +#include "boost/type_traits/detail/type_trait_undef.hpp" + +#endif // BOOST_TT_REMOVE_BOUNDS_HPP_INCLUDED diff --git a/boost/boost/type_traits/remove_extent.hpp b/boost/boost/type_traits/remove_extent.hpp new file mode 100644 index 0000000000..693f1afe88 --- /dev/null +++ b/boost/boost/type_traits/remove_extent.hpp @@ -0,0 +1,39 @@ + +// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000-2005. +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). +// +// See http://www.boost.org/libs/type_traits for most recent version including documentation. + +#ifndef BOOST_TT_REMOVE_EXTENT_HPP_INCLUDED +#define BOOST_TT_REMOVE_EXTENT_HPP_INCLUDED + +#include "boost/config.hpp" +#include + +// should be the last #include +#include "boost/type_traits/detail/type_trait_def.hpp" + +namespace boost { + +BOOST_TT_AUX_TYPE_TRAIT_DEF1(remove_extent,T,T) + +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS) +BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_2(typename T,std::size_t N,remove_extent,T[N],T type) +BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_2(typename T,std::size_t N,remove_extent,T const[N],T const type) +BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_2(typename T,std::size_t N,remove_extent,T volatile[N],T volatile type) +BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_2(typename T,std::size_t N,remove_extent,T const volatile[N],T const volatile type) +#if !BOOST_WORKAROUND(__BORLANDC__, < 0x600) && !defined(__IBMCPP__) && !BOOST_WORKAROUND(__DMC__, BOOST_TESTED_AT(0x840)) +BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_1(typename T,remove_extent,T[],T) +BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_1(typename T,remove_extent,T const[],T const) +BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_1(typename T,remove_extent,T volatile[],T volatile) +BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_1(typename T,remove_extent,T const volatile[],T const volatile) +#endif +#endif + +} // namespace boost + +#include "boost/type_traits/detail/type_trait_undef.hpp" + +#endif // BOOST_TT_REMOVE_BOUNDS_HPP_INCLUDED diff --git a/boost/boost/type_traits/type_traits_test.hpp b/boost/boost/type_traits/type_traits_test.hpp deleted file mode 100644 index 1e8961c213..0000000000 --- a/boost/boost/type_traits/type_traits_test.hpp +++ /dev/null @@ -1,436 +0,0 @@ -// (C) Copyright John Maddock 2000. -// Use, modification and distribution are subject to the Boost Software License, -// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt). -// -// See http://www.boost.org/libs/type_traits for most recent version including documentation. - - -// common test code for type-traits tests -// WARNING: contains code as well as declarations! - - -#ifndef BOOST_TYPE_TRAITS_TEST_HPP -#define BOOST_TYPE_TRAITS_TEST_HPP - -#include "boost/config.hpp" -#include "boost/utility.hpp" -#include "boost/type_traits/alignment_of.hpp" -#include "boost/type_traits/type_with_alignment.hpp" -#include "boost/type_traits/ice.hpp" - -#include -#include - -// -// define tests here -unsigned failures = 0; -unsigned test_count = 0; -// -// This must get defined within the test file. -// All compilers have bugs, set this to the number of -// regressions *expected* from a given compiler, -// if there are no workarounds for the bugs, *and* -// the regressions have been investigated. -// -extern unsigned int expected_failures; -// -// proc check_result() -// Checks that there were no regressions: -// -int check_result(int argc, char** argv) -{ - std::cout << test_count << " tests completed, " - << failures << " failures found, " - << expected_failures << " failures expected from this compiler." << std::endl; - if((argc == 2) - && (argv[1][0] == '-') - && (argv[1][1] == 'a') - && (argv[1][2] == 0)) - { - std::cout << "Press any key to continue..."; - std::cin.get(); - } - return (failures == expected_failures) - ? 0 - : (failures != 0) ? static_cast(failures) : -1; -} - - -// -// this one is to verify that a constant is indeed a -// constant-integral-expression: -// -// HP aCC cannot deal with missing names for template value parameters -template -struct checker -{ - static void check(bool, bool, const char*, bool){ ++test_count; } -}; - -template <> -struct checker -{ - static void check(bool o, bool n, const char* name, bool soft) - { - ++test_count; - ++failures; - // if this is a soft test, then failure is expected, - // or may depend upon factors outside our control - // (like compiler options)... - if(soft)++expected_failures; - std::cout << "checking value of " << name << "...failed" << std::endl; - std::cout << "\tfound: " << n << " expected " << o << std::endl; - } -}; - -template -struct typify{}; - -template -struct type_checker -{ - static void check(const char* TT, const char*, const char* expression) - { - ++test_count; - if(typeid(typify) != typeid(typify)) - { - ++failures; - std::cout << "checking type of " << expression << "...failed" << std::endl; - std::cout << " evaluating: type_checker<" << TT << "," << expression << ">" << std::endl; - std::cout << " expected: type_checker<" << TT << "," << TT << ">" << std::endl; - std::cout << " but got: " << typeid(type_checker).name() << std::endl; - } - } -}; - -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -template -struct type_checker -{ - static void check(const char*, const char*, const char*) - { - ++test_count; - } -}; -#endif - - -#define value_test(v, x) checker<(v == x)>::check(v, x, #x, false); -#define soft_value_test(v, x) checker<(v == x)>::check(v, x, #x, true); - -#define value_fail(v, x) \ - ++test_count; \ - ++failures; \ - ++expected_failures;\ - std::cout << "checking value of " << #x << "...failed" << std::endl; \ - std::cout << " " #x " does not compile on this compiler" << std::endl; - - -#define type_test(v, x) type_checker::check(#v, #x, #x); -#define type_test3(v, x, z) type_checker::check(#v, #x "," #z, #x "," #z); -#ifndef SHORT_TRANSFORM_TEST -#define transform_check(name, from_suffix, to_suffix)\ - type_test(bool to_suffix, name::type);\ - type_test(char to_suffix, name::type);\ - type_test(wchar_t to_suffix, name::type);\ - type_test(signed char to_suffix, name::type);\ - type_test(unsigned char to_suffix, name::type);\ - type_test(short to_suffix, name::type);\ - type_test(unsigned short to_suffix, name::type);\ - type_test(int to_suffix, name::type);\ - type_test(unsigned int to_suffix, name::type);\ - type_test(long to_suffix, name::type);\ - type_test(unsigned long to_suffix, name::type);\ - type_test(float to_suffix, name::type);\ - type_test(long double to_suffix, name::type);\ - type_test(double to_suffix, name::type);\ - type_test(UDT to_suffix, name::type);\ - type_test(enum1 to_suffix, name::type); -#else -#define transform_check(name, from_suffix, to_suffix)\ - type_test(int to_suffix, name::type);\ - type_test(UDT to_suffix, name::type);\ - type_test(enum1 to_suffix, name::type); -#endif - -#define boost_dummy_macro_param - -template -struct test_align -{ - struct padded - { - char c; - T t; - }; - - static void do_it() - { - padded p; - unsigned a = reinterpret_cast(&(p.t)) - reinterpret_cast(&p); - ++test_count; - // only fail if we do not have a multiple of the actual value: - if((a > ::boost::alignment_of::value) || (a % ::boost::alignment_of::value)) - { - ++failures; - std::cout << "checking value of " << typeid(boost::alignment_of).name() << "...failed" << std::endl; - std::cout << "\tfound: " << boost::alignment_of::value << " expected " << a << std::endl; - } - // suppress warnings about unused variables: - not_unused(p); - not_unused(a); - } - - template - static void not_unused(U const&) {} -}; -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -template -struct test_align -{ - static void do_it() - { - // - // we can't do the usual test because we can't take the address - // of a reference, so check that the result is the same as for a - // pointer type instead: - unsigned a = boost::alignment_of::value; - ++test_count; - if(a != boost::alignment_of::value) - { - ++failures; - std::cout << "checking value of " << typeid(boost::alignment_of).name() << "...failed" << std::endl; - std::cout << "\tfound: " << boost::alignment_of::value << " expected " << a << std::endl; - } - } -}; -#endif - -#define align_test(T) test_align::do_it() - -template -struct test_type_with_align -{ - typedef typename boost::type_with_alignment< - (boost::alignment_of::value)>::type - align_t; - - static void do_it() - { - int align = boost::alignment_of::value; - int new_align = boost::alignment_of::value; - ++test_count; - if (new_align % align != 0) { - ++failures; - std::cerr << "checking for an object with same alignment as " - << typeid(T).name() << "...failed" << std::endl; - std::cerr << "\tfound: " << typeid(align_t).name() << std::endl; - } - } -}; - -#define type_with_align_test(T) test_type_with_align::do_it() - -// -// the following code allows us to test that a particular -// template functions correctly when instanciated inside another template -// (some bugs only show up in that situation). For each template -// we declare one NESTED_DECL(classname) that sets up the template class -// and multiple NESTED_TEST(classname, template-arg) declarations, to carry -// the actual tests: -template -struct nested_test -{ - typedef nested_test type; - bool run_time_value; - const char* what; - nested_test(bool b2, const char* w) : run_time_value(b2), what(w) { check(); } - void check() - { - ++test_count; - if(b != run_time_value) - { - ++failures; - std::cerr << "Mismatch between runtime and compile time values in " << what << std::endl; - } - } -}; - -#ifndef __SUNPRO_CC -#define NESTED_DECL(what)\ -template \ -struct BOOST_TT_JOIN(nested_tester_,what){\ - nested_test< (::boost::type_traits::ice_ne<0, ::boost::what::value>::value)> tester;\ - BOOST_TT_JOIN(nested_tester_,what)(const char* s) : tester(::boost::what::value, s){}\ -}; -#define NESTED_TEST(what, with)\ -{BOOST_TT_JOIN(nested_tester_,what) check(#what "<" #with ">"); (void)check;} -#else -#define NESTED_DECL(what) -#define NESTED_TEST(what, with) -#endif - -#define BOOST_TT_JOIN( X, Y ) BOOST_DO_TT_JOIN( X, Y ) -#define BOOST_DO_TT_JOIN( X, Y ) X##Y - - - -// -// define some types to test with: -// -enum enum_UDT{ one, two, three }; -struct UDT -{ - UDT(){}; - ~UDT(){}; - UDT(const UDT&); - UDT& operator=(const UDT&); - int i; - - void f1(); - int f2(); - int f3(int); - int f4(int, float); -}; - -typedef void(*f1)(); -typedef int(*f2)(int); -typedef int(*f3)(int, bool); -typedef void (UDT::*mf1)(); -typedef int (UDT::*mf2)(); -typedef int (UDT::*mf3)(int); -typedef int (UDT::*mf4)(int, float); -typedef int (UDT::*mp); -typedef int (UDT::*cmf)(int) const; - -// cv-qualifiers applied to reference types should have no effect -// declare these here for later use with is_reference and remove_reference: -# ifdef BOOST_MSVC -# pragma warning(push) -# pragma warning(disable: 4181) -# elif defined(__ICL) -# pragma warning(push) -# pragma warning(disable: 21) -# endif -// -// This is intentional: -// r_type and cr_type should be the same type -// but some compilers wrongly apply cv-qualifiers -// to reference types (this may generate a warning -// on some compilers): -// -typedef int& r_type; -typedef const r_type cr_type; -# ifdef BOOST_MSVC -# pragma warning(pop) -# elif defined(__ICL) -# pragma warning(pop) -# pragma warning(disable: 985) // identifier truncated in debug information -# endif - -struct POD_UDT { int x; }; -struct empty_UDT -{ - ~empty_UDT(){}; - empty_UDT& operator=(const empty_UDT&){ return *this; } - bool operator==(const empty_UDT&)const - { return true; } -}; -struct empty_POD_UDT -{ - empty_POD_UDT& operator=(const empty_POD_UDT&){ return *this; } - bool operator==(const empty_POD_UDT&)const - { return true; } -}; -union union_UDT -{ - int x; - double y; - ~union_UDT(); -}; -union POD_union_UDT -{ - int x; - double y; -}; -union empty_union_UDT -{ - ~empty_union_UDT(); -}; -union empty_POD_union_UDT{}; - -class Base { }; - -class Derived : public Base { }; - -class NonDerived { }; - -enum enum1 -{ - one_,two_ -}; - -enum enum2 -{ - three_,four_ -}; - -struct VB -{ - virtual ~VB(){}; -}; - -struct VD : VB -{ - ~VD(){}; -}; -// -// struct non_pointer: -// used to verify that is_pointer does not return -// true for class types that implement operator void*() -// -struct non_pointer -{ - operator void*(){return this;} -}; -struct non_int_pointer -{ - int i; - operator int*(){return &i;} -}; -struct int_constructible -{ - int_constructible(int); -}; -struct int_convertible -{ - operator int(); -}; -// -// struct non_empty: -// used to verify that is_empty does not emit -// spurious warnings or errors. -// -struct non_empty : private boost::noncopyable -{ - int i; -}; -// -// abstract base classes: -struct test_abc1 -{ - virtual void foo() = 0; - virtual void foo2() = 0; -}; - -struct test_abc2 -{ - virtual void foo() = 0; - virtual void foo2() = 0; -}; - -struct incomplete_type; - - -#endif // BOOST_TYPE_TRAITS_TEST_HPP diff --git a/boost/boost/utility/addressof.hpp b/boost/boost/utility/addressof.hpp index 603ea60e37..76294886ad 100644 --- a/boost/boost/utility/addressof.hpp +++ b/boost/boost/utility/addressof.hpp @@ -13,9 +13,6 @@ # include # include -# if BOOST_WORKAROUND(BOOST_MSVC, == 1300) -# include -# endif namespace boost { @@ -23,7 +20,14 @@ namespace boost { // VC7 strips const from nested classes unless we add indirection here # if BOOST_WORKAROUND(BOOST_MSVC, == 1300) -template typename add_pointer::type + +template struct _addp +{ + typedef T * type; +}; + +template typename _addp::type + # else template T* # endif @@ -33,6 +37,22 @@ addressof(T& v) &const_cast(reinterpret_cast(v))); } +// Borland doesn't like casting an array reference to a char reference +// but these overloads work around the problem. +# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) +template +T (*addressof(T (&t)[N]))[N] +{ + return reinterpret_cast(&t); +} + +template +const T (*addressof(const T (&t)[N]))[N] +{ + return reinterpret_cast(&t); +} +# endif + } #endif // BOOST_UTILITY_ADDRESSOF_HPP diff --git a/boost/boost/version.hpp b/boost/boost/version.hpp index 38fb10eb6d..37519ef328 100644 --- a/boost/boost/version.hpp +++ b/boost/boost/version.hpp @@ -19,7 +19,7 @@ // BOOST_VERSION / 100 % 1000 is the minor version // BOOST_VERSION / 100000 is the major version -#define BOOST_VERSION 103200 +#define BOOST_VERSION 103301 // // BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION @@ -27,7 +27,9 @@ // number and y is the minor version number. This is used by // to select which library version to link to. -#define BOOST_LIB_VERSION "1_32" +#define BOOST_LIB_VERSION "1_33_1" #endif + + diff --git a/boost/libs/filesystem/src/operations_posix_windows.cpp b/boost/libs/filesystem/src/operations_posix_windows.cpp index 0d990b1c75..e314498098 100644 --- a/boost/libs/filesystem/src/operations_posix_windows.cpp +++ b/boost/libs/filesystem/src/operations_posix_windows.cpp @@ -21,17 +21,24 @@ // the library is being built (possibly exporting rather than importing code) #define BOOST_FILESYSTEM_SOURCE +#define _FILE_OFFSET_BITS 64 // at worst, these defines may have no effect, +#define __USE_FILE_OFFSET64 // but that is harmless on Windows and on POSIX + // 64-bit systems or on 32-bit systems which don't have files larger + // than can be represented by a traditional POSIX/UNIX off_t type. + // OTOH, defining them should kick in 64-bit off_t's (and thus + // st_size) on 32-bit systems that provide the Large File + // Support (LFS) interface, such as Linux, Solaris, and IRIX. + // The defines are given before any headers are included to + // ensure that they are available to all included headers. + // That is required at least on Solaris, and possibly on other + // systems as well. + #include #include #include #include #include #include -#include - -#ifdef BOOST_NO_STDC_NAMESPACE -namespace std { using ::strcmp; using ::remove; using ::rename; } -#endif namespace fs = boost::filesystem; @@ -46,51 +53,6 @@ namespace fs = boost::filesystem; # if defined(BOOST_WINDOWS) # include "windows.h" - - ////////////////////////////////////////////////////////////////////// - // - // Enable Boost.Filesystem to run on Win95 using the emulation - // of GetFileAttributesEx available in the Microsoft Platform SDK - // header file NewAPIs.h. - // - // The user needs only to define WANT_GETFILEATTRIBUTESEX_WRAPPER - // to enable this emulation. - // - // Please note, however, that this block of preprocessor code enables - // the user to compile against the emulation code. To link the - // executable the user must also compile the function definitions in - // NewAPIs.h. See NewAPIs.h for further details. - // - // This code should work both with Microsoft's native implementation - // of the winapi headers and also with MinGW/Cygwin's version. - // - ////////////////////////////////////////////////////////////////////// -# if defined(WANT_GETFILEATTRIBUTESEX_WRAPPER) -# if (defined(__MINGW32__) || defined(__CYGWIN__)) && WINVER < 0x040A - // MinGW/Cygwin's winapi header files and NewAPIs.h do not live - // well together because NewAPIs.h redefines - // WIN32_FILE_ATTRIBUTE_DATA and GET_FILEEX_INFO_LEVELS - // if WINVER < 0x04A. -# include -# if __W32API_MAJOR_VERSION < 3 || \ - __W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION <= 3 -# define BOOST_FILESYSTEM_WINVER WINVER -# undef WINVER -# define WINVER 0x040A -# endif -# endif - -# include - - // Return macro definitions to their original state. -# ifdef BOOST_FILESYSTEM_WINVER -# undef WINVER -# define WINVER BOOST_FILESYSTEM_WINVER -# undef BOOST_FILESYSTEM_WINVER -# endif -# endif - ////////////////////////////////////////////////////////////////////// - # if defined(__BORLANDC__) || defined(__MWERKS__) # if defined(__BORLANDC__) using std::time_t; @@ -106,14 +68,6 @@ namespace fs = boost::filesystem; // other macros defined. There was a bug report of this happening.) # else // BOOST_POSIX -# define _USE_FILE_OFFSET_BITS 64 // at worst, -# define __USE_FILE_OFFSET64 // these defines may do nothing, - // but that won't matter on 64-bit systems or on 32-bit systems which - // don't have files larger than can be represented by a traditional - // POSIX/UNIX off_t type. OTOH, defining them should kick - // in 64-bit off_t's (and thus st_size) on 32-bit systems that support - // the Large File Support (LFS) interface, such as Linux, Solaris, and IRIX. - # include # include "dirent.h" # include "unistd.h" @@ -123,9 +77,15 @@ namespace fs = boost::filesystem; #include // even on Windows some functions use stat() #include +#include #include // for remove, rename #include #include +//#include // for debugging only; comment out when not in use + +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std { using ::strcmp; using ::remove; using ::rename; } +#endif #include // must be the last header @@ -137,7 +97,7 @@ namespace # define BOOST_HANDLE DIR * # define BOOST_INVALID_HANDLE_VALUE 0 -# define BOOST_SYSTEM_DIRECTORY_TYPE struct dirent * +# define BOOST_SYSTEM_DIRECTORY_TYPE struct dirent inline const char * find_first_file( const char * dir, BOOST_HANDLE & handle, BOOST_SYSTEM_DIRECTORY_TYPE & ) @@ -154,29 +114,44 @@ namespace ::closedir( handle ); } - inline const char * find_next_file( - BOOST_HANDLE handle, const fs::path & ph, BOOST_SYSTEM_DIRECTORY_TYPE & ) + // warning: the only dirent member updated is d_name + inline int readdir_r_simulator( DIR * dirp, struct dirent * entry, + struct dirent ** result ) // *result set to 0 on end of directory + { +# if defined(_POSIX_THREAD_SAFE_FUNCTIONS) \ + && defined(_SC_THREAD_SAFE_FUNCTIONS) \ + && (_POSIX_THREAD_SAFE_FUNCTIONS+0 >= 0) \ + && ( !defined(__HP_aCC) || ( defined(__HP_aCC) && defined(_REENTRANT) ) ) + if ( ::sysconf( _SC_THREAD_SAFE_FUNCTIONS ) >= 0 ) + { return ::readdir_r( dirp, entry, result ); } +# endif + + struct dirent * p; + errno = 0; + *result = 0; + if ( (p = ::readdir( dirp )) == 0 ) + return errno; + // POSIX specs require entry->d_name be large enough: + std::strcpy( entry->d_name, p->d_name ); + *result = entry; + return 0; + } + + inline const char * find_next_file( BOOST_HANDLE handle, + const fs::path & ph, BOOST_SYSTEM_DIRECTORY_TYPE & entry ) // Returns: if EOF 0, otherwise name // Throws: if system reports error { - -// TODO: use readdir_r() if available, so code is multi-thread safe. -// Fly-in-ointment: not all platforms support readdir_r(). - - struct dirent * dp; - errno = 0; - if ( (dp = ::readdir( handle )) == 0 ) + struct dirent * result; + int return_code; + if ( (return_code = ::readdir_r_simulator( handle, &entry, &result )) != 0 ) { - if ( errno != 0 ) - { - boost::throw_exception( - fs::filesystem_error( - "boost::filesystem::directory_iterator::operator++", - ph, errno ) ); - } - else { return 0; } // end reached + boost::throw_exception( + fs::filesystem_error( + "boost::filesystem::directory_iterator::operator++", + ph, return_code ) ); } - return dp->d_name; + return result ? entry.d_name : 0; } #else // BOOST_WINDOWS @@ -187,16 +162,23 @@ namespace inline const char * find_first_file( const char * dir, BOOST_HANDLE & handle, BOOST_SYSTEM_DIRECTORY_TYPE & data ) // Returns: 0 if error, otherwise name + // Note: an empty root directory has no "." or ".." entries, so this causes + // a ERROR_FILE_NOT_FOUND error which we do not considered an error. Instead, + // the handle is set to BOOST_INVALID_HANDLE_VALUE and a non-zero is returned. { -// std::cout << "find_first_file " << dir << std::endl; - std::string dirpath( std::string(dir) + "/*" ); + // use a form of search Sebastian Martel reports will work with Win98 + std::string dirpath( dir ); + dirpath += (dirpath.empty() + || (dirpath[dirpath.size()-1] != '\\' + && dirpath[dirpath.size()-1] != '/')) ? "\\*" : "*"; + return ( (handle = ::FindFirstFileA( dirpath.c_str(), &data )) - == BOOST_INVALID_HANDLE_VALUE ) ? 0 : data.cFileName; + == BOOST_INVALID_HANDLE_VALUE + && ::GetLastError() != ERROR_FILE_NOT_FOUND) ? 0 : data.cFileName; } inline void find_close( BOOST_HANDLE handle ) { -// std::cout << "find_close" << std::endl; assert( handle != BOOST_INVALID_HANDLE_VALUE ); ::FindClose( handle ); } @@ -295,11 +277,18 @@ namespace boost BOOST_SYSTEM_DIRECTORY_TYPE scratch; const char * name = 0; // initialization quiets compiler warnings if ( dir_path.empty() ) - m_imp->handle = BOOST_INVALID_HANDLE_VALUE; + m_imp->handle = BOOST_INVALID_HANDLE_VALUE; else + { name = find_first_file( dir_path.native_directory_string().c_str(), m_imp->handle, scratch ); // sets handle - + if ( m_imp->handle == BOOST_INVALID_HANDLE_VALUE + && name ) // eof + { + m_imp.reset(); // make end iterator + return; + } + } if ( m_imp->handle != BOOST_INVALID_HANDLE_VALUE ) { m_imp->entry_path = dir_path; @@ -369,11 +358,12 @@ namespace boost if(::GetFileAttributesA( ph.string().c_str() ) == 0xFFFFFFFF) { UINT err = ::GetLastError(); - if((err == ERROR_FILE_NOT_FOUND) || - (err == ERROR_INVALID_PARAMETER) || - (err == ERROR_PATH_NOT_FOUND) || - (err == ERROR_INVALID_NAME) || - (err == ERROR_ACCESS_DENIED)) + if((err == ERROR_FILE_NOT_FOUND) + || (err == ERROR_INVALID_PARAMETER) + || (err == ERROR_NOT_READY) + || (err == ERROR_PATH_NOT_FOUND) + || (err == ERROR_INVALID_NAME) + || (err == ERROR_BAD_NETPATH )) return false; // GetFileAttributes failed because the path does not exist // for any other error we assume the file does exist and fall through, // this may not be the best policy though... (JM 20040330) @@ -440,7 +430,7 @@ namespace boost : path_stat.st_size == 0; # else WIN32_FILE_ATTRIBUTE_DATA fad; - if ( !::GetFileAttributesEx( ph.string().c_str(), + if ( !::GetFileAttributesExA( ph.string().c_str(), ::GetFileExInfoStandard, &fad ) ) boost::throw_exception( filesystem_error( "boost::filesystem::is_empty", @@ -544,28 +534,17 @@ namespace boost "boost::filesystem::equivalent", ph2, fs::detail::system_error_code() ) ); // In theory, volume serial numbers are sufficient to distinguish between - // devices, but in practice VSN's are sometimes duplicated, so device id - // is also checked. Device id's alone aren't sufficient because network - // share devices on different machines will have the same id. Furthermore, - // cheap floppy disks often have 0 VSN's and are mounted on the same - // lettered drive across networks, so last write time and file size is - // checked to distinguish that case as far as is possible. - if ( info1.dwVolumeSerialNumber != info2.dwVolumeSerialNumber - || info1.nFileIndexHigh != info2.nFileIndexHigh - || info1.nFileIndexLow != info2.nFileIndexLow - || info1.nFileSizeHigh != info2.nFileSizeHigh - || info1.nFileSizeLow != info2.nFileSizeLow ) return false; - struct stat s1; - if ( ::stat( ph1.string().c_str(), &s1 ) != 0 ) - boost::throw_exception( filesystem_error( - "boost::filesystem::equivalent", - ph1, fs::detail::system_error_code() ) ); - struct stat s2; - if ( ::stat( ph2.string().c_str(), &s2 ) != 0 ) - boost::throw_exception( filesystem_error( - "boost::filesystem::equivalent", - ph2, fs::detail::system_error_code() ) ); - return s1.st_dev == s2.st_dev; + // devices, but in practice VSN's are sometimes duplicated, so last write + // time and file size are also checked. + return info1.dwVolumeSerialNumber == info2.dwVolumeSerialNumber + && info1.nFileIndexHigh == info2.nFileIndexHigh + && info1.nFileIndexLow == info2.nFileIndexLow + && info1.nFileSizeHigh == info2.nFileSizeHigh + && info1.nFileSizeLow == info2.nFileSizeLow + && info1.ftLastWriteTime.dwLowDateTime + == info2.ftLastWriteTime.dwLowDateTime + && info1.ftLastWriteTime.dwHighDateTime + == info2.ftLastWriteTime.dwHighDateTime; # endif } @@ -587,7 +566,7 @@ namespace boost # else // by now, intmax_t is 64-bits on all Windows compilers WIN32_FILE_ATTRIBUTE_DATA fad; - if ( !::GetFileAttributesEx( ph.string().c_str(), + if ( !::GetFileAttributesExA( ph.string().c_str(), ::GetFileExInfoStandard, &fad ) ) boost::throw_exception( filesystem_error( "boost::filesystem::file_size", @@ -658,9 +637,20 @@ namespace boost # ifdef BOOST_POSIX || symbolic_link_exists( ph ) ) // handle dangling symbolic links { +# if defined(__QNXNTO__) || (defined(__MSL__) && (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__))) + // Some Metrowerks C library versions fail on directories because of a + // known Metrowerks coding error in ::remove. Workaround is to call + // rmdir() or unlink() as indicated. + // Same bug reported for QNX; same fix. + if ( (is_directory( ph ) + ? ::rmdir( ph.string().c_str() ) + : ::unlink( ph.string().c_str() )) != 0 ) +# else // note that the POSIX behavior for symbolic links is what we want; // the link rather than what it points to is deleted if ( std::remove( ph.string().c_str() ) != 0 ) +# endif + { int error = fs::detail::system_error_code(); // POSIX says "If the directory is not an empty directory, rmdir() @@ -713,12 +703,23 @@ namespace boost old_path, new_path, fs::detail::system_error_code() ) ); } +#ifdef BOOST_POSIX + namespace detail + { + void throw_copy_file_error( const path & from_file_ph, + const path & to_file_ph ) + { + boost::throw_exception( fs::filesystem_error( + "boost::filesystem::copy_file", + from_file_ph, to_file_ph, system_error_code() ) ); + } + } +#endif + BOOST_FILESYSTEM_DECL void copy_file( const path & from_file_ph, const path & to_file_ph ) { # ifdef BOOST_POSIX - // TODO: Ask POSIX experts if this is the best way to copy a file - const std::size_t buf_sz = 32768; boost::scoped_array buf( new char [buf_sz] ); int infile=0, outfile=0; // init quiets compiler warning @@ -731,27 +732,40 @@ namespace boost O_WRONLY | O_CREAT | O_EXCL, from_stat.st_mode )) < 0 ) { - if ( infile != 0 ) ::close( infile ); - boost::throw_exception( filesystem_error( - "boost::filesystem::copy_file", - from_file_ph, to_file_ph, fs::detail::system_error_code() ) ); + if ( infile >= 0 ) ::close( infile ); + detail::throw_copy_file_error( from_file_ph, to_file_ph ); } - ssize_t sz; - while ( (sz = ::read( infile, buf.get(), buf_sz )) > 0 - && (sz = ::write( outfile, buf.get(), sz )) > 0 ) {} + ssize_t sz, sz_read=1, sz_write; + while ( sz_read > 0 + && (sz_read = ::read( infile, buf.get(), buf_sz )) > 0 ) + { + // Allow for partial writes - see Advanced Unix Programming (2nd Ed.), + // Marc Rochkind, Addison-Wesley, 2004, page 94 + sz_write = 0; + do + { + if ( (sz = ::write( outfile, buf.get(), sz_read - sz_write )) < 0 ) + { + sz_read = sz; // cause read loop termination + break; // and error to be thrown after closes + } + sz_write += sz; + } while ( sz_write < sz_read ); + } - ::close( infile ); - ::close( outfile ); + if ( ::close( infile) < 0 ) sz_read = -1; + if ( ::close( outfile) < 0 ) sz_read = -1; - if ( sz != 0 ) + if ( sz_read < 0 ) + detail::throw_copy_file_error( from_file_ph, to_file_ph ); # else if ( !::CopyFileA( from_file_ph.string().c_str(), to_file_ph.string().c_str(), /*fail_if_exists=*/true ) ) -# endif - boost::throw_exception( filesystem_error( + boost::throw_exception( fs::filesystem_error( "boost::filesystem::copy_file", - from_file_ph, to_file_ph, fs::detail::system_error_code() ) ); + from_file_ph, to_file_ph, detail::system_error_code() ) ); +# endif } BOOST_FILESYSTEM_DECL path current_path() @@ -763,7 +777,12 @@ namespace boost buf( new char[static_cast(path_max)] ); if ( ::getcwd( buf.get(), static_cast(path_max) ) == 0 ) { - if ( errno != ERANGE ) + if ( errno != ERANGE +// there is a bug in some versions of the Metrowerks C lib on the Mac: wrong errno set +#if defined(__MSL__) && (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) + && errno != 0 +#endif + ) boost::throw_exception( filesystem_error( "boost::filesystem::current_path", path(), fs::detail::system_error_code() ) ); diff --git a/boost/libs/filesystem/src/path_posix_windows.cpp b/boost/libs/filesystem/src/path_posix_windows.cpp index 0e586736b7..3256b9f3c7 100644 --- a/boost/libs/filesystem/src/path_posix_windows.cpp +++ b/boost/libs/filesystem/src/path_posix_windows.cpp @@ -650,7 +650,7 @@ namespace boost // path::iterator implementation --------------------------------------------// - void path::iterator::increment() + BOOST_FILESYSTEM_DECL void path::iterator::increment() { assert( m_pos < m_path_ptr->m_path.size() ); // detect increment past end m_pos += m_name.size(); @@ -677,7 +677,7 @@ namespace boost m_name = m_path_ptr->m_path.substr( m_pos, end_pos - m_pos ); } - void path::iterator::decrement() + BOOST_FILESYSTEM_DECL void path::iterator::decrement() { assert( m_pos ); // detect decrement of begin std::string::size_type end_pos( m_pos ); diff --git a/boost/libs/regex/src/Makefile.am b/boost/libs/regex/src/Makefile.am index 8a621f795b..2e53f2e357 100644 --- a/boost/libs/regex/src/Makefile.am +++ b/boost/libs/regex/src/Makefile.am @@ -13,15 +13,15 @@ AM_CPPFLAGS += \ libboost_regex_la_SOURCES = \ cpp_regex_traits.cpp \ - c_regex_traits_common.cpp \ c_regex_traits.cpp \ cregex.cpp \ fileiter.cpp \ instances.cpp \ primary_transform.hpp \ regex.cpp \ - w32_regex_traits.cpp \ - regex_synch.cpp + regex_raw_buffer.cpp \ + regex_traits_defaults.cpp \ + w32_regex_traits.cpp # posix_api.cpp \ # wide_posix_api.cpp \ diff --git a/boost/libs/regex/src/c_regex_traits.cpp b/boost/libs/regex/src/c_regex_traits.cpp index f8be3ebb46..da960eb0c5 100644 --- a/boost/libs/regex/src/c_regex_traits.cpp +++ b/boost/libs/regex/src/c_regex_traits.cpp @@ -1,1073 +1,206 @@ /* * - * Copyright (c) 1998-2002 - * Dr John Maddock + * Copyright (c) 2004 + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) * */ - + /* * LOCATION: see http://www.boost.org for most recent version. - * FILE c_regex_traits.cpp - * VERSION see - * DESCRIPTION: Implements the c_regex_traits traits class + * FILE: c_regex_traits.cpp + * VERSION: see + * DESCRIPTION: Implements out of line c_regex_traits members */ + #define BOOST_REGEX_SOURCE #include +#include -# ifdef BOOST_MSVC -# pragma warning(disable: 4702) -# endif +#if !BOOST_WORKAROUND(__BORLANDC__, < 0x560) -#include -#include -#include -#include -#include -#include -#include -#ifdef BOOST_REGEX_V3 -#include -#include -#else -#include -#include -#endif -#include +#include +#include +#include -#include "primary_transform.hpp" - - -#if defined(BOOST_HAS_NL_TYPES_H) -#include -#endif - -// Fixes a very strange bug in Comeau 4.2.45.2 that would otherwise result in -// an instantiation loop -#if defined(__COMO__) && __COMO_VERSION__ <= 4245 -void c_regex_adopted_no_longer_needed_loop_shutter_upper() { } -#endif - -namespace{ - -// -// helper function to get the locale name, -// works around possibly broken setlocale implementations: -// -const char* re_get_locale(int id) -{ - static const char* def = "Unknown"; - const char* pl = std::setlocale(id, 0); - return pl ? pl : def; -} - -// -// character classes: -// -boost::uint_fast32_t re_char_class_id[] = { - boost::re_detail::c_traits_base::char_class_alnum, - boost::re_detail::c_traits_base::char_class_alpha, - boost::re_detail::c_traits_base::char_class_cntrl, - boost::re_detail::c_traits_base::char_class_digit, - boost::re_detail::c_traits_base::char_class_graph, - boost::re_detail::c_traits_base::char_class_lower, - boost::re_detail::c_traits_base::char_class_print, - boost::re_detail::c_traits_base::char_class_punct, - boost::re_detail::c_traits_base::char_class_space, - boost::re_detail::c_traits_base::char_class_upper, - boost::re_detail::c_traits_base::char_class_xdigit, - boost::re_detail::c_traits_base::char_class_blank, - boost::re_detail::c_traits_base::char_class_word, - boost::re_detail::c_traits_base::char_class_unicode, -}; - -const char* re_char_class_names[] = { -"alnum", -"alpha", -"cntrl", -"digit", -"graph", -"lower", -"print", -"punct", -"space", -"upper", -"xdigit", -"blank", -"word", -"unicode", -}; - -std::string* re_cls_name; -std::string* pclasses; -unsigned int classes_count = 0; -const unsigned int re_classes_max = 14; - -// -// collate names: - -struct collate_name_t -{ - std::string name; - std::string value; - collate_name_t(const char* p1, const char* p2, const char* p3, const char* p4) - : name(p1, p2), value(p3, p4) {} -}; - -std::string* re_coll_name; -std::list* pcoll_names; -unsigned int collate_count = 0; - -// -// message handling: -#ifndef BOOST_RE_MESSAGE_BASE -#define BOOST_RE_MESSAGE_BASE 0 -#endif - -#if defined(BOOST_HAS_NL_TYPES_H) -nl_catd message_cat = (nl_catd)-1; -#endif - -unsigned int message_count = 0; -std::string* mess_locale; - -char* re_custom_error_messages[] = { - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, -}; - -#if !defined(LC_MESSAGES) -#define LC_MESSAGES LC_CTYPE -#endif - -char re_zero; -char re_ten; - -unsigned int entry_count = 0; - -std::string* ctype_name; -std::string* collate_name; -enum syntax_map_size -{ - map_size = UCHAR_MAX + 1 -}; - -std::size_t BOOST_REGEX_CALL _re_get_message(char* buf, std::size_t len, std::size_t id); - -#ifndef BOOST_NO_WREGEX - -boost::regex_wchar_type re_zero_w; -boost::regex_wchar_type re_ten_w; - -unsigned int nlsw_count = 0; -std::string* wlocale_name = 0; - -struct syntax_map_t -{ - boost::regex_wchar_type c; - unsigned int type; -}; - -std::list* syntax; - -std::size_t BOOST_REGEX_CALL re_get_message(boost::regex_wchar_type* buf, std::size_t len, std::size_t id) -{ - std::size_t size = _re_get_message(static_cast(0), 0, id); - if(len < size) - return size; - boost::scoped_array cb(new char[size]); - _re_get_message(cb.get(), size, id); - size = boost::c_regex_traits::strwiden(buf, len, cb.get()); - return size; +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std{ + using ::strxfrm; using ::isspace; + using ::ispunct; using ::isalpha; + using ::isalnum; using ::iscntrl; + using ::isprint; using ::isupper; + using ::islower; using ::isdigit; + using ::isxdigit; using ::strtol; } #endif -inline std::size_t BOOST_REGEX_CALL re_get_message(char* buf, std::size_t len, std::size_t id) -{ - return _re_get_message(buf, len, id); -} - -void BOOST_REGEX_CALL re_init_classes() -{ - BOOST_RE_GUARD_STACK - if(classes_count == 0) - { - re_cls_name = new std::string("xxxxxxxx"); -#ifndef BOOST_NO_EXCEPTIONS - try{ +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX #endif - pclasses = new std::string[re_classes_max]; - BOOST_REGEX_NOEH_ASSERT(pclasses) -#ifndef BOOST_NO_EXCEPTIONS - } - catch(...) - { - delete re_cls_name; - throw; - } -#endif - } - ++classes_count; -} - -void BOOST_REGEX_CALL re_free_classes() -{ - BOOST_RE_GUARD_STACK - if(--classes_count == 0) - { - delete re_cls_name; - delete[] pclasses; - } -} - -void BOOST_REGEX_CALL re_update_classes() -{ - BOOST_RE_GUARD_STACK - if(*re_cls_name != re_get_locale(LC_CTYPE)) - { - *re_cls_name = re_get_locale(LC_CTYPE); - char buf[256]; - unsigned int i; - for(i = 0; i < re_classes_max; ++i) - { - re_get_message(buf, 256, i+300); - pclasses[i] = buf; - } - } -} - -void BOOST_REGEX_CALL re_init_collate() -{ - BOOST_RE_GUARD_STACK - if(collate_count == 0) - { - re_coll_name = new std::string("xxxxxxxx"); -#ifndef BOOST_NO_EXCEPTIONS - try{ -#endif - pcoll_names = new std::list(); - BOOST_REGEX_NOEH_ASSERT(pcoll_names) -#ifndef BOOST_NO_EXCEPTIONS - } - catch(...) - { - delete re_coll_name; - throw; - } -#endif - } - ++collate_count; -} - -void BOOST_REGEX_CALL re_free_collate() -{ - BOOST_RE_GUARD_STACK - if(--collate_count == 0) - { - delete re_coll_name; - delete pcoll_names; - } -} - -void BOOST_REGEX_CALL re_update_collate() -{ - BOOST_RE_GUARD_STACK - if(*re_coll_name != re_get_locale(LC_COLLATE)) - { - *re_coll_name = re_get_locale(LC_COLLATE); - char buf[256]; - unsigned int i = 400; - re_get_message(buf, 256, i); - while(*buf) - { - char* p1, *p2, *p3, *p4;; - p1 = buf; - while(*p1 && std::isspace((unsigned char)*p1))++p1; - p2 = p1; - while(*p2 && !std::isspace((unsigned char)*p2))++p2; - p3 = p2; - while(*p3 && std::isspace((unsigned char)*p3))++p3; - p4 = p3; - while(*p4 && !std::isspace((unsigned char)*p4))++p4; - pcoll_names->push_back(collate_name_t(p1, p2, p3, p4)); - ++i; - re_get_message(buf, 256, i); - } - } -} - -std::size_t BOOST_REGEX_CALL _re_get_message(char* buf, std::size_t len, std::size_t id) -{ - BOOST_RE_GUARD_STACK - // get the customised message if any: - #if defined(BOOST_HAS_NL_TYPES_H) - if(message_cat != (nl_catd)-1) - { - const char* m = catgets(message_cat, 0, id, 0); - if(m) - { - std::size_t size = std::strlen(m) + 1; - if(size > len) - return size; - std::strcpy(buf, m); - return size; - } - } - #endif - - // - // now get the default message if any: - return boost::re_detail::re_get_default_message(buf, len, id); -} - -void BOOST_REGEX_CALL re_message_init() -{ - BOOST_RE_GUARD_STACK - if(message_count == 0) - { - mess_locale = new std::string("xxxxxxxxxxxxxxxx"); - } - ++message_count; -} - -void BOOST_REGEX_CALL re_message_update() -{ - BOOST_RE_GUARD_STACK - // - // called whenever the global locale changes: - // - std::string l(re_get_locale(LC_MESSAGES)); - if(*mess_locale != l) - { - *mess_locale = l; -#if defined(BOOST_HAS_NL_TYPES_H) - if(message_cat != (nl_catd)-1) - { - catclose(message_cat); - message_cat = (nl_catd)-1; - } - if(*boost::re_detail::c_traits_base::get_catalogue()) - { - message_cat = catopen(boost::re_detail::c_traits_base::get_catalogue(), 0); - if(message_cat == (nl_catd)-1) - { - std::string m("Unable to open message catalog: "); - std::runtime_error err(m + boost::re_detail::c_traits_base::get_catalogue()); - boost::throw_exception(err); - } - } -#endif - for(int i = 0; i < boost::REG_E_UNKNOWN; ++i) - { - if(re_custom_error_messages[i]) - { - boost::re_detail::re_strfree(re_custom_error_messages[i]); - re_custom_error_messages[i] = 0; - } - } - } -} - -void BOOST_REGEX_CALL re_message_free() -{ - BOOST_RE_GUARD_STACK - --message_count; - if(message_count == 0) - { -#if defined(BOOST_HAS_NL_TYPES_H) - if(message_cat != (nl_catd)-1) - catclose(message_cat); -#endif - delete mess_locale; - for(int i = 0; i < boost::REG_E_UNKNOWN; ++i) - { - if(re_custom_error_messages[i]) - { - boost::re_detail::re_strfree(re_custom_error_messages[i]); - re_custom_error_messages[i] = 0; - } - } - } -} - - -const char* BOOST_REGEX_CALL re_get_error_str(unsigned int id) -{ - BOOST_RE_GUARD_STACK -#ifdef BOOST_HAS_THREADS - boost::re_detail::cs_guard g(*boost::re_detail::p_re_lock); -#endif - if(re_custom_error_messages[id] == 0) - { - char buf[256]; - _re_get_message(buf, 256, id + 200); - if(*buf) - { - re_custom_error_messages[id] = boost::re_detail::re_strdup(buf); - return re_custom_error_messages[id]; - } - return boost::re_detail::re_default_error_messages[id]; - } - return re_custom_error_messages[id]; -} - -} // namespace namespace boost{ -namespace re_detail{ -char c_traits_base::regex_message_catalogue[BOOST_REGEX_MAX_PATH] = {0}; - -std::string BOOST_REGEX_CALL c_traits_base::error_string(unsigned id) -{ - return re_get_error_str(id); +c_regex_traits::string_type BOOST_REGEX_CALL c_regex_traits::transform(const char* p1, const char* p2) +{ + std::string result(10, ' '); + std::size_t s = result.size(); + std::size_t r; + std::string src(p1, p2); + while(s < (r = std::strxfrm(&*result.begin(), src.c_str(), s))) + { + result.append(r - s + 3, ' '); + s = result.size(); + } + result.erase(r); + return result; } -void BOOST_REGEX_CALL c_traits_base::do_update_collate() +c_regex_traits::string_type BOOST_REGEX_CALL c_regex_traits::transform_primary(const char* p1, const char* p2) { - BOOST_RE_GUARD_STACK - re_update_collate(); - std::string s; - const char* p = "zero"; - if(c_regex_traits::lookup_collatename(s, p, p+4)) + static char s_delim; + static const int s_collate_type = ::boost::re_detail::find_sort_syntax(static_cast*>(0), &s_delim); + std::string result; + // + // What we do here depends upon the format of the sort key returned by + // sort key returned by this->transform: + // + switch(s_collate_type) { - jm_assert(s.size() == 1); - re_zero = *s.c_str(); - } - else - re_zero = '0'; - - p = "ten"; - if(c_regex_traits::lookup_collatename(s, p, p+3)) - { - jm_assert(s.size() == 1); - re_ten = *s.c_str(); - } - else - re_ten = 'a'; -} - -void BOOST_REGEX_CALL c_traits_base::do_update_ctype() -{ - BOOST_RE_GUARD_STACK - // start by updating the syntax map: - unsigned int i; - char buf[map_size+2]; - std::memset(syntax_map, syntax_char, map_size); - for(i = 1; i < syntax_max; ++i) - { - char* ptr = buf; - re_get_message(static_cast(buf), map_size, i+100); - for(; *ptr; ++ptr) + case ::boost::re_detail::sort_C: + case ::boost::re_detail::sort_unknown: + // the best we can do is translate to lower case, then get a regular sort key: { - syntax_map[(unsigned char)*ptr] = (unsigned char)i; + result.assign(p1, p2); + for(std::string::size_type i = 0; i < result.size(); ++i) + result[i] = static_cast((std::tolower)(static_cast(result[i]))); + result = transform(&*result.begin(), &*result.begin() + result.size()); + break; } - } - - // now update the character class map, - // and lower case map: - std::memset(class_map, 0, sizeof(class_map)); - for(i = 0; i < map_size; ++i) - { - if(std::isalpha(i)) - class_map[i] |= char_class_alpha; - if(std::iscntrl(i)) - class_map[i] |= char_class_cntrl; - if(std::isdigit(i)) - class_map[i] |= char_class_digit; - if(std::islower(i)) - class_map[i] |= char_class_lower; - if(std::isupper(i)) - class_map[i] |= char_class_upper; - if(std::ispunct(i)) - class_map[i] |= char_class_punct; - if(std::isspace(i)) - class_map[i] |= char_class_space; - if(std::isxdigit(i)) - class_map[i] |= char_class_xdigit; - } - class_map[(unsigned char)'_'] |= char_class_underscore; - class_map[(unsigned char)' '] |= char_class_blank; - class_map[(unsigned char)'\t'] |= char_class_blank; - for(i = 0; i < map_size; ++i) - { - lower_case_map[i] = (char)std::tolower(i); - } - re_update_classes(); -} - -boost::uint_fast32_t BOOST_REGEX_CALL c_traits_base::do_lookup_class(const char* p) -{ - BOOST_RE_GUARD_STACK - unsigned int i; - for(i = 0; i < re_classes_max; ++i) - { - if(pclasses[i] == p) + case ::boost::re_detail::sort_fixed: { - return re_char_class_id[i]; + // get a regular sort key, and then truncate it: + result = transform(p1, p2); + result.erase(s_delim); + break; } - } - for(i = 0; i < re_classes_max; ++i) - { - if(std::strcmp(re_char_class_names[i], p) == 0) - { - return re_char_class_id[i]; - } - } - return 0; -} - -bool BOOST_REGEX_CALL c_traits_base::do_lookup_collate(std::string& buf, const char* p) -{ - BOOST_RE_GUARD_STACK - std::list::iterator first, last; - first = pcoll_names->begin(); - last = pcoll_names->end(); - while(first != last) - { - if((*first).name == p) - { - buf = (*first).value; - return true; - } - ++first; - } - - bool result = re_detail::re_lookup_def_collate_name(buf, p); - if((result == 0) && (std::strlen(p) == 1)) - { - result = true; - buf = *p; - } - return result; -} - -std::string BOOST_REGEX_CALL c_traits_base::set_message_catalogue(const std::string& l) -{ - if(sizeof(regex_message_catalogue) <= l.size()) - return l; - std::string old(regex_message_catalogue); - std::strcpy(regex_message_catalogue, l.c_str()); - return old; -} - -unsigned char c_traits_base::syntax_map[map_size]; -unsigned short c_traits_base::class_map[map_size]; -char c_traits_base::lower_case_map[map_size]; - -} // namespace re_detail - -#ifndef BOOST_NO_WREGEX -bool BOOST_REGEX_CALL c_regex_traits::lookup_collatename(std::basic_string& out, const regex_wchar_type* first, const regex_wchar_type* last) -{ - BOOST_RE_GUARD_STACK - std::basic_string s(first, last); - std::size_t len = strnarrow(static_cast(0), 0, s.c_str()); - scoped_array buf(new char[len]); - strnarrow(buf.get(), len, s.c_str()); - std::string t_out; - bool result = base_type::do_lookup_collate(t_out, buf.get()); - if(t_out.size() == 0) result = false; - if(result) - { - if(t_out[0]) - { - len = strwiden(static_cast(0), 0, t_out.c_str()); - scoped_array wb(new regex_wchar_type[len]); - strwiden(wb.get(), len, t_out.c_str()); - out = wb.get(); - } - else - out.append(1, (regex_wchar_type)0); - } - return result; -} -#endif - -c_regex_traits c_regex_traits::i; - -void BOOST_REGEX_CALL c_regex_traits::init() -{ - BOOST_RE_GUARD_STACK -#ifdef BOOST_HAS_THREADS - re_detail::re_init_threads(); - re_detail::cs_guard g(*re_detail::p_re_lock); -#endif - // just keep track of entry_count - if(entry_count == 0) - { - ctype_name = new std::string("xxxxxxxxxxxxxxxx"); -#ifndef BOOST_NO_EXCEPTIONS - try{ -#endif - collate_name = new std::string("xxxxxxxxxxxxxxxx"); - BOOST_REGEX_NOEH_ASSERT(collate_name) -#ifndef BOOST_NO_EXCEPTIONS - } - catch(...) - { - delete ctype_name; - throw; - } -#endif - } - re_message_init(); - re_init_classes(); - re_init_collate(); - ++entry_count; -} - -void BOOST_REGEX_CALL c_regex_traits::update() -{ - BOOST_RE_GUARD_STACK - #ifdef BOOST_HAS_THREADS - re_detail::cs_guard g(*re_detail::p_re_lock); - #endif - re_message_update(); - if(*collate_name != re_get_locale(LC_COLLATE)) - { - do_update_collate(); - *collate_name = re_get_locale(LC_COLLATE); - } - if(*ctype_name != re_get_locale(LC_CTYPE)) - { - do_update_ctype(); - *ctype_name = re_get_locale(LC_CTYPE); - } - sort_type = re_detail::find_sort_syntax(&i, &sort_delim); -} - -void BOOST_REGEX_CALL c_regex_traits::m_free() -{ - BOOST_RE_GUARD_STACK - #ifdef BOOST_HAS_THREADS - re_detail::cs_guard g(*re_detail::p_re_lock); - #endif - re_message_free(); - re_free_classes(); - re_free_collate(); - --entry_count; - // add reference to static member here to ensure - // that the linker includes it in the .exe: - if((entry_count == 0) && (0 != &c_regex_traits::i)) - { - delete ctype_name; - delete collate_name; - } -#ifdef BOOST_HAS_THREADS - g.acquire(false); - re_detail::re_free_threads(); -#endif -} - -void BOOST_REGEX_CALL c_regex_traits::transform(std::string& out, const std::string& in) -{ - BOOST_RE_GUARD_STACK - std::size_t n = std::strxfrm(0, in.c_str(), 0); - if(n == (std::size_t)(-1)) - { - out = in; - return; - } - scoped_array buf(new char[n+1]); - n = std::strxfrm(buf.get(), in.c_str(), n+1); - if(n == (std::size_t)(-1)) - { - out = in; - return; - } - out = buf.get(); -} - -void BOOST_REGEX_CALL c_regex_traits::transform_primary(std::string& out, const std::string& in) -{ - transform(out, in); - switch(sort_type) - { - case re_detail::sort_C: - case re_detail::sort_unknown: - break; - case re_detail::sort_fixed: - out.erase((int)sort_delim); - break; - case re_detail::sort_delim: - for(unsigned int j = 0; j < out.size(); ++j) - { - if((out[j] == sort_delim) && (j+1 < out.size())) - { - out.erase(j+1); + case ::boost::re_detail::sort_delim: + // get a regular sort key, and then truncate everything after the delim: + result = transform(p1, p2); + if(result.size() && (result[0] == s_delim)) break; - } - } - } -} - -unsigned c_regex_traits::sort_type; -char c_regex_traits::sort_delim; - - -int BOOST_REGEX_CALL c_regex_traits::toi(char c) -{ - if(is_class(c, char_class_digit)) - return c - re_zero; - if(is_class(c, char_class_xdigit)) - return 10 + translate(c, true) - translate(re_ten, true); - return -1; // error!! -} - -int BOOST_REGEX_CALL c_regex_traits::toi(const char*& first, const char* last, int radix) -{ - unsigned int maxval; - if(radix < 0) - { - // if radix is less than zero, then restrict - // return value to charT. NB assumes sizeof(charT) <= sizeof(int) - radix *= -1; - maxval = 1u << (sizeof(*first) * CHAR_BIT - 1); - maxval /= radix; - maxval *= 2; - maxval -= 1; - } - else - { - maxval = (unsigned int)-1; - maxval /= radix; - } - - unsigned int result = 0; - unsigned int type = (radix > 10) ? char_class_xdigit : char_class_digit; - while((first != last) && is_class(*first, type) && (result <= maxval)) - { - result *= radix; - result += toi(*first); - ++first; - } - return result; -} - -#ifndef BOOST_NO_WREGEX - -unsigned int BOOST_REGEX_CALL c_regex_traits::syntax_type(size_type c) -{ - BOOST_RE_GUARD_STACK - std::list::const_iterator first, last; - first = syntax->begin(); - last = syntax->end(); - while(first != last) - { - if((uchar_type)(*first).c == c) - return (*first).type; - ++first; - } - return 0; -} - -void BOOST_REGEX_CALL c_regex_traits::init() -{ - BOOST_RE_GUARD_STACK - re_detail::re_init_threads(); -#ifdef BOOST_HAS_THREADS - re_detail::cs_guard g(*re_detail::p_re_lock); -#endif - re_message_init(); - re_init_classes(); - re_init_collate(); - if(nlsw_count == 0) - { - wlocale_name = new std::string("xxxxxxxxxxxxxxxx"); -#ifndef BOOST_NO_EXCEPTIONS - try{ -#endif - syntax = new std::list(); - BOOST_REGEX_NOEH_ASSERT(syntax) -#ifndef BOOST_NO_EXCEPTIONS - } - catch(...) - { - delete wlocale_name; - throw; - } -#endif - } - ++nlsw_count; -} - -bool BOOST_REGEX_CALL c_regex_traits::do_lookup_collate(std::basic_string& out, const regex_wchar_type* first, const regex_wchar_type* last) -{ - BOOST_RE_GUARD_STACK - std::basic_string s(first, last); - std::size_t len = strnarrow(static_cast(0), 0, s.c_str()); - scoped_array buf(new char[len]); - strnarrow(buf.get(), len, s.c_str()); - std::string t_out; - bool result = base_type::do_lookup_collate(t_out, buf.get()); - if(result) - { - len = strwiden(static_cast(0), 0, t_out.c_str()); - scoped_array wb(new regex_wchar_type[len]); - strwiden(wb.get(), len, t_out.c_str()); - out = wb.get(); - } - return result; -} - - -void BOOST_REGEX_CALL c_regex_traits::update() -{ - BOOST_RE_GUARD_STACK -#ifdef BOOST_HAS_THREADS - re_detail::cs_guard g(*re_detail::p_re_lock); -#endif - re_message_update(); - re_update_classes(); - re_update_collate(); - std::string l(re_get_locale(LC_CTYPE)); - if(*wlocale_name != l) - { - *wlocale_name = l; - std::basic_string s; - const regex_wchar_type* p = (const regex_wchar_type*)L"zero"; - if(do_lookup_collate(s, p, p+4)) - { - jm_assert(s.size() == 1); - re_zero_w = *s.c_str(); - } - else - re_zero_w = L'0'; - - p = (const regex_wchar_type*)L"ten"; - if(do_lookup_collate(s, p, p+3)) - { - jm_assert(s.size() == 1); - re_ten_w = *s.c_str(); - } - else - re_ten_w = L'a'; - - unsigned int i; - regex_wchar_type buf[256]; - syntax_map_t sm; - syntax->clear(); - for(i = 1; i < syntax_max; ++i) - { - regex_wchar_type* ptr = buf; - re_get_message(static_cast(buf), 256, i+100); - for(; *ptr; ++ptr) + std::size_t i; + for(i = 0; i < result.size(); ++i) { - sm.c = *ptr; - sm.type = i; - syntax->push_back(sm); + if(result[i] == s_delim) + break; } - } - sort_type = re_detail::find_sort_syntax(&init_, &sort_delim); - } -} - -void BOOST_REGEX_CALL c_regex_traits::m_free() -{ - BOOST_RE_GUARD_STACK -#ifdef BOOST_HAS_THREADS - re_detail::cs_guard g(*re_detail::p_re_lock); -#endif - --nlsw_count; - re_message_free(); - re_free_classes(); - re_free_collate(); - // add reference to static member here to ensure - // that the linker includes it in the .exe: - if((nlsw_count == 0) && (0 != &c_regex_traits::init_)) - { - // cleanup: - delete wlocale_name; - delete syntax; - } -#ifdef BOOST_HAS_THREADS - g.acquire(false); - re_detail::re_free_threads(); -#endif -} - -bool BOOST_REGEX_CALL c_regex_traits::do_iswclass(regex_wchar_type c, boost::uint_fast32_t f) -{ - BOOST_RE_GUARD_STACK - if((c & ~0xFF) == 0) - return BOOST_REGEX_MAKE_BOOL(re_detail::wide_unicode_classes[(uchar_type)c] & f); - if((f & char_class_alpha) && std::iswalpha(c)) - return true; - if((f & char_class_cntrl) && std::iswcntrl(c)) - return true; - if((f & char_class_digit) && std::iswdigit(c)) - return true; - if((f & char_class_lower) && std::iswlower(c)) - return true; - if((f & char_class_punct) && std::iswpunct(c)) - return true; - if((f & char_class_space) && std::iswspace(c)) - return true; - if((f & char_class_upper) && std::iswupper(c)) - return true; - if((f & char_class_xdigit) && std::iswxdigit(c)) - return true; - if(f & char_class_unicode) - return true; - return false; -} - -void BOOST_REGEX_CALL c_regex_traits::transform(std::basic_string& out, const std::basic_string& in) -{ - BOOST_RE_GUARD_STACK -#ifndef BOOST_MSVC - std::size_t n = std::wcsxfrm(0, in.c_str(), 0); -#else - // broken wcsxfrm under VC6 doesn't check size of - // output buffer, we have no choice but to guess! - std::size_t n = 100 * in.size(); -#endif - if((n == (std::size_t)(-1)) || (n == 0)) - { - out = in; - return; - } - scoped_array buf(new regex_wchar_type[n+1]); - n = std::wcsxfrm((wchar_t*)buf.get(), (const wchar_t*)in.c_str(), n+1); - if(n == (std::size_t)(-1)) - { - out = in; - return; - } - out = buf.get(); -} - -void BOOST_REGEX_CALL c_regex_traits::transform_primary(std::basic_string& out, const std::basic_string& in) -{ - transform(out, in); - switch(sort_type) - { - case re_detail::sort_C: - case re_detail::sort_unknown: - break; - case re_detail::sort_fixed: - if((unsigned)sort_delim < out.size()) - out.erase((int)sort_delim); - break; - case re_detail::sort_delim: - for(unsigned int i = 0; i < out.size(); ++i) - { - if((out[i] == sort_delim) && (i+1 < out.size())) - { - out.erase(i+1); - break; - } - } - } -} - -unsigned c_regex_traits::sort_type; -regex_wchar_type c_regex_traits::sort_delim; - - -int BOOST_REGEX_CALL c_regex_traits::toi(regex_wchar_type c) -{ - if(is_class(c, char_class_digit)) - return c - re_zero_w; - if(is_class(c, char_class_xdigit)) - return 10 + translate(c, true) - translate(re_ten_w, true); - return -1; // error!! -} - -int BOOST_REGEX_CALL c_regex_traits::toi(const regex_wchar_type*& first, const regex_wchar_type* last, int radix) -{ - unsigned int maxval; - if(radix < 0) - { - // if radix is less than zero, then restrict - // return value to charT. NB assumes sizeof(charT) <= sizeof(int) - radix *= -1; - maxval = 1u << (sizeof(*first) * CHAR_BIT - 1); - maxval /= radix; - maxval *= 2; - maxval -= 1; - } - else - { - maxval = (unsigned int)-1; - maxval /= radix; - } - - unsigned int result = 0; - unsigned int type = (radix > 10) ? char_class_xdigit : char_class_digit; - while((first != last) && is_class(*first, type) && (result <= maxval)) - { - result *= radix; - result += toi(*first); - ++first; + result.erase(i); + break; } + if(result.empty()) + result = std::string(1, char(0)); return result; } -boost::uint_fast32_t BOOST_REGEX_CALL c_regex_traits::lookup_classname(const regex_wchar_type* first, const regex_wchar_type* last) +enum { - std::basic_string s(first, last); - std::size_t len = strnarrow(static_cast(0), 0, s.c_str()); - scoped_array buf(new char[len]); - strnarrow(buf.get(), len, s.c_str()); - boost::uint_fast32_t result = do_lookup_class(buf.get()); + char_class_space=1<<0, + char_class_print=1<<1, + char_class_cntrl=1<<2, + char_class_upper=1<<3, + char_class_lower=1<<4, + char_class_alpha=1<<5, + char_class_digit=1<<6, + char_class_punct=1<<7, + char_class_xdigit=1<<8, + char_class_alnum=char_class_alpha|char_class_digit, + char_class_graph=char_class_alnum|char_class_punct, + char_class_blank=1<<9, + char_class_word=1<<10, + char_class_unicode=1<<11 +}; + +c_regex_traits::char_class_type BOOST_REGEX_CALL c_regex_traits::lookup_classname(const char* p1, const char* p2) +{ + static const char_class_type masks[] = + { + 0, + char_class_alnum, + char_class_alpha, + char_class_blank, + char_class_cntrl, + char_class_digit, + char_class_digit, + char_class_graph, + char_class_lower, + char_class_lower, + char_class_print, + char_class_punct, + char_class_space, + char_class_space, + char_class_upper, + char_class_unicode, + char_class_upper, + char_class_alnum | char_class_word, + char_class_alnum | char_class_word, + char_class_xdigit, + }; + + int id = ::boost::re_detail::get_default_class_id(p1, p2); + if(id < 0) + { + std::string s(p1, p2); + for(std::string::size_type i = 0; i < s.size(); ++i) + s[i] = static_cast((std::tolower)(static_cast(s[i]))); + id = ::boost::re_detail::get_default_class_id(&*s.begin(), &*s.begin() + s.size()); + } + BOOST_ASSERT(std::size_t(id+1) < sizeof(masks) / sizeof(masks[0])); + return masks[id+1]; +} + +bool BOOST_REGEX_CALL c_regex_traits::isctype(char c, char_class_type mask) +{ + return + ((mask & char_class_space) && (std::isspace)(static_cast(c))) + || ((mask & char_class_print) && (std::isprint)(static_cast(c))) + || ((mask & char_class_cntrl) && (std::iscntrl)(static_cast(c))) + || ((mask & char_class_upper) && (std::isupper)(static_cast(c))) + || ((mask & char_class_lower) && (std::islower)(static_cast(c))) + || ((mask & char_class_alpha) && (std::isalpha)(static_cast(c))) + || ((mask & char_class_digit) && (std::isdigit)(static_cast(c))) + || ((mask & char_class_punct) && (std::ispunct)(static_cast(c))) + || ((mask & char_class_xdigit) && (std::isxdigit)(static_cast(c))) + || ((mask & char_class_blank) && (std::isspace)(static_cast(c)) && !::boost::re_detail::is_separator(c)) + || ((mask & char_class_word) && (c == '_')); +} + +c_regex_traits::string_type BOOST_REGEX_CALL c_regex_traits::lookup_collatename(const char* p1, const char* p2) +{ + std::string s(p1, p2); + s = ::boost::re_detail::lookup_default_collate_name(s); + if(s.empty() && (p2-p1 == 1)) + s.append(1, *p1); + return s; +} + +int BOOST_REGEX_CALL c_regex_traits::value(char c, int radix) +{ + char b[2] = { c, '\0', }; + char* ep; + int result = std::strtol(b, &ep, radix); + if(ep == b) + return -1; return result; } -c_regex_traits c_regex_traits::init_; - -std::size_t BOOST_REGEX_CALL c_regex_traits::strnarrow(char *s1, std::size_t len, const regex_wchar_type *s2) -{ - BOOST_RE_GUARD_STACK - std::size_t size = std::wcslen((const wchar_t*)s2) + 1; - if(size > len) - return size; - return std::wcstombs(s1, (const wchar_t*)s2, len); } +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif -std::size_t BOOST_REGEX_CALL c_regex_traits::strwiden(regex_wchar_type *s1, std::size_t len, const char *s2) -{ - BOOST_RE_GUARD_STACK - std::size_t size = std::strlen(s2) + 1; - if(size > len) - return size; - size = std::mbstowcs((wchar_t*)s1, s2, len); - s1[size] = 0; - return size + 1; -} - -#endif // BOOST_NO_WREGEX - -} // namespace boost - - - - - +#endif diff --git a/boost/libs/regex/src/c_regex_traits_common.cpp b/boost/libs/regex/src/c_regex_traits_common.cpp deleted file mode 100644 index 1dc0b4b4ac..0000000000 --- a/boost/libs/regex/src/c_regex_traits_common.cpp +++ /dev/null @@ -1,559 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * Dr John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - - /* - * LOCATION: see http://www.boost.org for most recent version. - * FILE: c_regex_traits_common.cpp - * VERSION: see - * DESCRIPTION: Implements common code and data for the - * c_regex_traits traits classes. - */ - - -#define BOOST_REGEX_SOURCE - -#include -#include -#include -#include -#include -#ifdef BOOST_REGEX_V3 -#include -#else -#include -#endif - - -namespace boost{ - namespace re_detail{ - -// -// these are the POSIX collating names: -// -BOOST_REGEX_DECL const char* def_coll_names[] = { -"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "alert", "backspace", "tab", "newline", -"vertical-tab", "form-feed", "carriage-return", "SO", "SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", -"SYN", "ETB", "CAN", "EM", "SUB", "ESC", "IS4", "IS3", "IS2", "IS1", "space", "exclamation-mark", -"quotation-mark", "number-sign", "dollar-sign", "percent-sign", "ampersand", "apostrophe", -"left-parenthesis", "right-parenthesis", "asterisk", "plus-sign", "comma", "hyphen", -"period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", -"colon", "semicolon", "less-than-sign", "equals-sign", "greater-than-sign", -"question-mark", "commercial-at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", -"Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "left-square-bracket", "backslash", -"right-square-bracket", "circumflex", "underscore", "grave-accent", "a", "b", "c", "d", "e", "f", -"g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "left-curly-bracket", -"vertical-line", "right-curly-bracket", "tilde", "DEL", "", -}; - -// these multi-character collating elements -// should keep most Western-European locales -// happy - we should really localise these a -// little more - but this will have to do for -// now: - -BOOST_REGEX_DECL const char* def_multi_coll[] = { - "ae", - "Ae", - "AE", - "ch", - "Ch", - "CH", - "ll", - "Ll", - "LL", - "ss", - "Ss", - "SS", - "nj", - "Nj", - "NJ", - "dz", - "Dz", - "DZ", - "lj", - "Lj", - "LJ", - "", -}; - - - -BOOST_REGEX_DECL bool BOOST_REGEX_CALL re_lookup_def_collate_name(std::string& buf, const char* name) -{ - BOOST_RE_GUARD_STACK - unsigned int i = 0; - while(*def_coll_names[i]) - { - if(std::strcmp(def_coll_names[i], name) == 0) - { - buf = (char)i; - return true; - } - ++i; - } - i = 0; - while(*def_multi_coll[i]) - { - if(std::strcmp(def_multi_coll[i], name) == 0) - { - buf = def_multi_coll[i]; - return true; - } - ++i; - } - return false; -} - -// -// messages: -BOOST_REGEX_DECL const char * re_default_error_messages[] = -{ "Success", /* REG_NOERROR */ - "No match", /* REG_NOMATCH */ - "Invalid regular expression", /* REG_BADPAT */ - "Invalid collation character", /* REG_ECOLLATE */ - "Invalid character class name", /* REG_ECTYPE */ - "Trailing backslash", /* REG_EESCAPE */ - "Invalid back reference", /* REG_ESUBREG */ - "Unmatched [ or [^", /* REG_EBRACK */ - "Unmatched ( or \\(", /* REG_EPAREN */ - "Unmatched \\{", /* REG_EBRACE */ - "Invalid content of \\{\\}", /* REG_BADBR */ - "Invalid range end", /* REG_ERANGE */ - "Memory exhausted", /* REG_ESPACE */ - "Invalid preceding regular expression", /* REG_BADRPT */ - "Premature end of regular expression", /* REG_EEND */ - "Regular expression too big", /* REG_ESIZE */ - "Unmatched ) or \\)", /* REG_ERPAREN */ - "Empty expression", /* REG_EMPTY */ - "Unknown error", /* REG_E_UNKNOWN */ - "", - "", - "", -}; - -const mss default_messages[] = { - { 100+ c_regex_traits::syntax_open_bracket, "(", }, - { 100+ c_regex_traits::syntax_close_bracket, ")", }, - { 100+ c_regex_traits::syntax_dollar, "$", }, - { 100+ c_regex_traits::syntax_caret, "^", }, - { 100+ c_regex_traits::syntax_dot, ".", }, - { 100+ c_regex_traits::syntax_star, "*", }, - { 100+ c_regex_traits::syntax_plus, "+", }, - { 100+ c_regex_traits::syntax_question, "?", }, - { 100+ c_regex_traits::syntax_open_set, "[", }, - { 100+ c_regex_traits::syntax_close_set, "]", }, - { 100+ c_regex_traits::syntax_or, "|", }, - { 100+ c_regex_traits::syntax_slash, "\\", }, - { 100+ c_regex_traits::syntax_hash, "#", }, - { 100+ c_regex_traits::syntax_dash, "-", }, - { 100+ c_regex_traits::syntax_open_brace, "{", }, - { 100+ c_regex_traits::syntax_close_brace, "}", }, - { 100+ c_regex_traits::syntax_digit, "0123456789", }, - { 100+ c_regex_traits::syntax_b, "b", }, - { 100+ c_regex_traits::syntax_B, "B", }, - { 100+ c_regex_traits::syntax_left_word, "<", }, - { 100+ c_regex_traits::syntax_right_word, ">", }, - { 100+ c_regex_traits::syntax_w, "w", }, - { 100+ c_regex_traits::syntax_W, "W", }, - { 100+ c_regex_traits::syntax_start_buffer, "`A", }, - { 100+ c_regex_traits::syntax_end_buffer, "'z", }, - { 100+ c_regex_traits::syntax_newline, "\n", }, - { 100+ c_regex_traits::syntax_comma, ",", }, - { 100+ c_regex_traits::syntax_a, "a", }, - { 100+ c_regex_traits::syntax_f, "f", }, - { 100+ c_regex_traits::syntax_n, "n", }, - { 100+ c_regex_traits::syntax_r, "r", }, - { 100+ c_regex_traits::syntax_t, "t", }, - { 100+ c_regex_traits::syntax_v, "v", }, - { 100+ c_regex_traits::syntax_x, "x", }, - { 100+ c_regex_traits::syntax_c, "c", }, - { 100+ c_regex_traits::syntax_colon, ":", }, - { 100+ c_regex_traits::syntax_equal, "=", }, - - { 100 + c_regex_traits::syntax_e, "e", }, - { 100 + c_regex_traits::syntax_l, "l", }, - { 100 + c_regex_traits::syntax_L, "L", }, - { 100 + c_regex_traits::syntax_u, "u", }, - { 100 + c_regex_traits::syntax_U, "U", }, - { 100 + c_regex_traits::syntax_s, "s", }, - { 100 + c_regex_traits::syntax_S, "S", }, - { 100 + c_regex_traits::syntax_d, "d", }, - { 100 + c_regex_traits::syntax_D, "D", }, - { 100 + c_regex_traits::syntax_E, "E", }, - { 100 + c_regex_traits::syntax_Q, "Q", }, - { 100 + c_regex_traits::syntax_X, "X", }, - { 100 + c_regex_traits::syntax_C, "C", }, - { 100 + c_regex_traits::syntax_Z, "Z", }, - { 100 + c_regex_traits::syntax_G, "G", }, - - { 100 + c_regex_traits::syntax_not, "!", }, - - { 0, "", }, - }; - -BOOST_REGEX_DECL std::size_t BOOST_REGEX_CALL re_get_default_message(char* buf, std::size_t len, std::size_t id) -{ - BOOST_RE_GUARD_STACK - const mss* pm = default_messages; - while(pm->id) - { - if(pm->id == id) - { - std::size_t size = re_strlen(pm->what) + 1; - if(size > len) - return size; - re_strcpy(buf, pm->what); - return size; - } - ++pm; - } - if(buf && len) - *buf = 0; - return 1; -} - -#ifndef BOOST_NO_WREGEX -const regex_wchar_type combining_ranges[] = { 0x0300, 0x0361, - 0x0483, 0x0486, - 0x0903, 0x0903, - 0x093E, 0x0940, - 0x0949, 0x094C, - 0x0982, 0x0983, - 0x09BE, 0x09C0, - 0x09C7, 0x09CC, - 0x09D7, 0x09D7, - 0x0A3E, 0x0A40, - 0x0A83, 0x0A83, - 0x0ABE, 0x0AC0, - 0x0AC9, 0x0ACC, - 0x0B02, 0x0B03, - 0x0B3E, 0x0B3E, - 0x0B40, 0x0B40, - 0x0B47, 0x0B4C, - 0x0B57, 0x0B57, - 0x0B83, 0x0B83, - 0x0BBE, 0x0BBF, - 0x0BC1, 0x0BCC, - 0x0BD7, 0x0BD7, - 0x0C01, 0x0C03, - 0x0C41, 0x0C44, - 0x0C82, 0x0C83, - 0x0CBE, 0x0CBE, - 0x0CC0, 0x0CC4, - 0x0CC7, 0x0CCB, - 0x0CD5, 0x0CD6, - 0x0D02, 0x0D03, - 0x0D3E, 0x0D40, - 0x0D46, 0x0D4C, - 0x0D57, 0x0D57, - 0x0F7F, 0x0F7F, - 0x20D0, 0x20E1, - 0x3099, 0x309A, - 0xFE20, 0xFE23, - 0xffff, 0xffff, }; - -BOOST_REGEX_DECL bool BOOST_REGEX_CALL is_combining(regex_wchar_type c) -{ - BOOST_RE_GUARD_STACK - const regex_wchar_type* p = combining_ranges + 1; - while(*p < c) p += 2; - --p; - if((c >= *p) && (c <= *(p+1))) - return true; - return false; -} - -BOOST_REGEX_DECL unsigned short wide_unicode_classes[] = { - c_traits_base::char_class_cntrl, // '' 0 - c_traits_base::char_class_cntrl, // '' 1 - c_traits_base::char_class_cntrl, // '' 2 - c_traits_base::char_class_cntrl, // '' 3 - c_traits_base::char_class_cntrl, // '' 4 - c_traits_base::char_class_cntrl, // '' 5 - c_traits_base::char_class_cntrl, // '' 6 - c_traits_base::char_class_cntrl, // '' 7 - c_traits_base::char_class_cntrl, // '' 8 - c_traits_base::char_class_cntrl | c_traits_base::char_class_space | c_traits_base::char_class_blank, // '' 9 - c_traits_base::char_class_cntrl | c_traits_base::char_class_space, // '' 10 - c_traits_base::char_class_cntrl | c_traits_base::char_class_space, // '' 11 - c_traits_base::char_class_cntrl | c_traits_base::char_class_space, // '' 12 - c_traits_base::char_class_cntrl | c_traits_base::char_class_space, // '' 13 - c_traits_base::char_class_cntrl, // '.' 14 - c_traits_base::char_class_cntrl, // '.' 15 - c_traits_base::char_class_cntrl, // '.' 16 - c_traits_base::char_class_cntrl, // '.' 17 - c_traits_base::char_class_cntrl, // '.' 18 - c_traits_base::char_class_cntrl, // '.' 19 - c_traits_base::char_class_cntrl, // '.' 20 - c_traits_base::char_class_cntrl, // '.' 21 - c_traits_base::char_class_cntrl, // '.' 22 - c_traits_base::char_class_cntrl, // '.' 23 - c_traits_base::char_class_cntrl, // '.' 24 - c_traits_base::char_class_cntrl, // '' 25 - c_traits_base::char_class_cntrl, // '' 26 - c_traits_base::char_class_cntrl, // '' 27 - c_traits_base::char_class_cntrl, // '.' 28 - c_traits_base::char_class_cntrl, // '.' 29 - c_traits_base::char_class_cntrl, // '.' 30 - c_traits_base::char_class_cntrl, // '.' 31 - c_traits_base::char_class_space | c_traits_base::char_class_blank, // ' ' 32 - c_traits_base::char_class_punct, // '!' 33 - c_traits_base::char_class_punct, // '"' 34 - c_traits_base::char_class_punct, // '#' 35 - c_traits_base::char_class_punct, // '$' 36 - c_traits_base::char_class_punct, // '%' 37 - c_traits_base::char_class_punct, // '&' 38 - c_traits_base::char_class_punct, // ''' 39 - c_traits_base::char_class_punct, // '(' 40 - c_traits_base::char_class_punct, // ')' 41 - c_traits_base::char_class_punct, // '*' 42 - c_traits_base::char_class_punct, // '+' 43 - c_traits_base::char_class_punct, // ',' 44 - c_traits_base::char_class_punct, // '-' 45 - c_traits_base::char_class_punct, // '.' 46 - c_traits_base::char_class_punct, // '/' 47 - c_traits_base::char_class_digit | c_traits_base::char_class_xdigit, // '0' 48 - c_traits_base::char_class_digit | c_traits_base::char_class_xdigit, // '1' 49 - c_traits_base::char_class_digit | c_traits_base::char_class_xdigit, // '2' 50 - c_traits_base::char_class_digit | c_traits_base::char_class_xdigit, // '3' 51 - c_traits_base::char_class_digit | c_traits_base::char_class_xdigit, // '4' 52 - c_traits_base::char_class_digit | c_traits_base::char_class_xdigit, // '5' 53 - c_traits_base::char_class_digit | c_traits_base::char_class_xdigit, // '6' 54 - c_traits_base::char_class_digit | c_traits_base::char_class_xdigit, // '7' 55 - c_traits_base::char_class_digit | c_traits_base::char_class_xdigit, // '8' 56 - c_traits_base::char_class_digit | c_traits_base::char_class_xdigit, // '9' 57 - c_traits_base::char_class_punct, // ':' 58 - c_traits_base::char_class_punct, // ';' 59 - c_traits_base::char_class_punct, // '<' 60 - c_traits_base::char_class_punct, // '=' 61 - c_traits_base::char_class_punct, // '>' 62 - c_traits_base::char_class_punct, // '?' 63 - c_traits_base::char_class_punct, // '@' 64 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper | c_traits_base::char_class_xdigit, // 'A' 65 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper | c_traits_base::char_class_xdigit, // 'B' 66 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper | c_traits_base::char_class_xdigit, // 'C' 67 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper | c_traits_base::char_class_xdigit, // 'D' 68 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper | c_traits_base::char_class_xdigit, // 'E' 69 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper | c_traits_base::char_class_xdigit, // 'F' 70 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'G' 71 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'H' 72 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'I' 73 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'J' 74 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'K' 75 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'L' 76 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'M' 77 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'N' 78 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'O' 79 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'P' 80 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'Q' 81 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'R' 82 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'S' 83 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'T' 84 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'U' 85 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'V' 86 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'W' 87 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'X' 88 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'Y' 89 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // 'Z' 90 - c_traits_base::char_class_punct, // '[' 91 - c_traits_base::char_class_punct, // '\' 92 - c_traits_base::char_class_punct, // ']' 93 - c_traits_base::char_class_punct, // '^' 94 - c_traits_base::char_class_punct | c_traits_base::char_class_underscore, // '_' 95 - c_traits_base::char_class_punct, // '`' 96 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower | c_traits_base::char_class_xdigit, // 'a' 97 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower | c_traits_base::char_class_xdigit, // 'b' 98 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower | c_traits_base::char_class_xdigit, // 'c' 99 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower | c_traits_base::char_class_xdigit, // 'd' 100 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower | c_traits_base::char_class_xdigit, // 'e' 101 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower | c_traits_base::char_class_xdigit, // 'f' 102 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'g' 103 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'h' 104 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'i' 105 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'j' 106 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'k' 107 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'l' 108 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'm' 109 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'n' 110 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'o' 111 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'p' 112 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'q' 113 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'r' 114 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 's' 115 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 't' 116 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'u' 117 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'v' 118 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'w' 119 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'x' 120 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'y' 121 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // 'z' 122 - c_traits_base::char_class_punct, // '{' 123 - c_traits_base::char_class_punct, // '|' 124 - c_traits_base::char_class_punct, // '}' 125 - c_traits_base::char_class_punct, // '~' 126 - - c_traits_base::char_class_cntrl, // '' 127 - c_traits_base::char_class_cntrl, // '' 128 - c_traits_base::char_class_cntrl, // '' 129 - c_traits_base::char_class_cntrl, // '' 130 - c_traits_base::char_class_cntrl, // '' 131 - c_traits_base::char_class_cntrl, // '' 132 - c_traits_base::char_class_cntrl, // '' 133 - c_traits_base::char_class_cntrl, // '' 134 - c_traits_base::char_class_cntrl, // '' 135 - c_traits_base::char_class_cntrl, // '' 136 - c_traits_base::char_class_cntrl, // '' 137 - c_traits_base::char_class_cntrl, // '' 138 - c_traits_base::char_class_cntrl, // '' 139 - c_traits_base::char_class_cntrl, // '' 140 - c_traits_base::char_class_cntrl, // '' 141 - c_traits_base::char_class_cntrl, // '' 142 - c_traits_base::char_class_cntrl, // '' 143 - c_traits_base::char_class_cntrl, // '' 144 - c_traits_base::char_class_cntrl, // '' 145 - c_traits_base::char_class_cntrl, // '' 146 - c_traits_base::char_class_cntrl, // '' 147 - c_traits_base::char_class_cntrl, // '' 148 - c_traits_base::char_class_cntrl, // '' 149 - c_traits_base::char_class_cntrl, // '' 150 - c_traits_base::char_class_cntrl, // '' 151 - c_traits_base::char_class_cntrl, // '' 152 - c_traits_base::char_class_cntrl, // '' 153 - c_traits_base::char_class_cntrl, // '' 154 - c_traits_base::char_class_cntrl, // '' 155 - c_traits_base::char_class_cntrl, // '' 156 - c_traits_base::char_class_cntrl, // '' 157 - c_traits_base::char_class_cntrl, // '' 158 - c_traits_base::char_class_cntrl, // '' 159 - c_traits_base::char_class_space | c_traits_base::char_class_blank, // '' 160 - c_traits_base::char_class_punct, // '' 161 - c_traits_base::char_class_punct, // '' 162 - c_traits_base::char_class_punct, // '' 163 - c_traits_base::char_class_punct, // '' 164 - c_traits_base::char_class_punct, // '' 165 - c_traits_base::char_class_punct, // '' 166 - c_traits_base::char_class_punct, // '' 167 - c_traits_base::char_class_punct, // '' 168 - c_traits_base::char_class_punct, // '' 169 - c_traits_base::char_class_punct, // '' 170 - c_traits_base::char_class_punct, // '' 171 - c_traits_base::char_class_punct, // '' 172 - c_traits_base::char_class_punct, // '' 173 - c_traits_base::char_class_punct, // '' 174 - c_traits_base::char_class_punct, // '' 175 - c_traits_base::char_class_punct, // '' 176 - c_traits_base::char_class_punct, // '' 177 - c_traits_base::char_class_punct, // '' 178 - c_traits_base::char_class_punct, // '' 179 - c_traits_base::char_class_punct, // '' 180 - c_traits_base::char_class_punct, // '' 181 - c_traits_base::char_class_punct, // '' 182 - c_traits_base::char_class_punct, // '' 183 - c_traits_base::char_class_punct, // '' 184 - c_traits_base::char_class_punct, // '' 185 - c_traits_base::char_class_punct, // '' 186 - c_traits_base::char_class_punct, // '' 187 - c_traits_base::char_class_punct, // '' 188 - c_traits_base::char_class_punct, // '' 189 - c_traits_base::char_class_punct, // '' 190 - c_traits_base::char_class_punct, // '' 191 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 192 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 193 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 194 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 195 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 196 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 197 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 198 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 199 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 200 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 201 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 202 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 203 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 204 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 205 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 206 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 207 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 208 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 209 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 210 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 211 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 212 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 213 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 214 - c_traits_base::char_class_punct, // '' 215 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 216 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 217 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 218 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 219 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 220 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 221 - c_traits_base::char_class_alpha | c_traits_base::char_class_upper, // '' 222 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 223 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 224 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 225 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 226 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 227 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 228 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 229 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 230 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 231 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 232 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 233 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 234 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 235 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 236 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 237 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 238 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 239 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 240 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 241 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 242 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 243 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 244 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 245 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 246 - c_traits_base::char_class_punct, // '' 247 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 248 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 249 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 250 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 251 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 252 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 253 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 254 - c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '' 255 -}; - -BOOST_REGEX_DECL regex_wchar_type wide_lower_case_map[] = { - 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, - 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xd7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xdf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, -}; -#endif // BOOST_NO_WREGEX - - } // namespace re_detail -} // namespace boost - - - - diff --git a/boost/libs/regex/src/cpp_regex_traits.cpp b/boost/libs/regex/src/cpp_regex_traits.cpp index 24b9e10ec6..9ed66be646 100644 --- a/boost/libs/regex/src/cpp_regex_traits.cpp +++ b/boost/libs/regex/src/cpp_regex_traits.cpp @@ -1,7 +1,7 @@ /* * - * Copyright (c) 1998-2002 - * Dr John Maddock + * Copyright (c) 2004 + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -11,897 +11,107 @@ /* * LOCATION: see http://www.boost.org for most recent version. - * FILE: c_regex_traits.cpp - * VERSION: see - * DESCRIPTION: Implements the cpp_regex_traits traits class + * FILE cpp_regex_traits.cpp + * VERSION see + * DESCRIPTION: Implements cpp_regex_traits (and associated helper classes). */ - #define BOOST_REGEX_SOURCE +#include +#ifndef BOOST_NO_STD_LOCALE +#include +#include -#include - -#if defined(BOOST_REGEX_HAS_SHORT_WCHAR_T) && !defined(_NATIVE_WCHAR_T_DEFINED) -# pragma message ("disabling support for class cpp_regex_traits - rebuild with /Zc:wchar_t if you really need this") -# define BOOST_NO_WREGEX +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std{ + using ::memset; +} #endif -#if !defined(BOOST_NO_STD_LOCALE) +namespace boost{ namespace re_detail{ -# ifdef BOOST_MSVC -# pragma warning(disable:4786 4702 4127 4244) -# endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "primary_transform.hpp" - -# ifdef BOOST_MSVC -# pragma warning(disable:4786 4702 4127 4244) -# endif - -namespace{ - const unsigned int re_classes_max = 14; - const unsigned int char_set_size = CHAR_MAX - CHAR_MIN + 1; - -boost::uint_fast32_t re_char_class_id[] = { - boost::re_detail::cpp_regex_traits_base::char_class_alnum, - boost::re_detail::cpp_regex_traits_base::char_class_alpha, - boost::re_detail::cpp_regex_traits_base::char_class_cntrl, - boost::re_detail::cpp_regex_traits_base::char_class_digit, - boost::re_detail::cpp_regex_traits_base::char_class_graph, - boost::re_detail::cpp_regex_traits_base::char_class_lower, - boost::re_detail::cpp_regex_traits_base::char_class_print, - boost::re_detail::cpp_regex_traits_base::char_class_punct, - boost::re_detail::cpp_regex_traits_base::char_class_space, - boost::re_detail::cpp_regex_traits_base::char_class_upper, - boost::re_detail::cpp_regex_traits_base::char_class_xdigit, - boost::re_detail::cpp_regex_traits_base::char_class_blank, - boost::re_detail::cpp_regex_traits_base::char_class_word, - boost::re_detail::cpp_regex_traits_base::char_class_unicode, -}; - -const char* re_char_class_names[] = { -"alnum", -"alpha", -"cntrl", -"digit", -"graph", -"lower", -"print", -"punct", -"space", -"upper", -"xdigit", -"blank", -"word", -"unicode", -}; - -template > -class parser_buf : public ::std::basic_streambuf +void cpp_regex_traits_char_layer::init() { - typedef ::std::basic_streambuf base_type; - typedef typename base_type::int_type int_type; - typedef typename base_type::char_type char_type; - typedef typename base_type::pos_type pos_type; - typedef ::std::streamsize streamsize; - typedef typename base_type::off_type off_type; -public: - parser_buf() : base_type() { setbuf(0, 0); } - const charT* getnext() { return this->gptr(); } -protected: - std::basic_streambuf* setbuf(char_type* s, streamsize n); - typename parser_buf::pos_type seekpos(pos_type sp, ::std::ios_base::openmode which); - typename parser_buf::pos_type seekoff(off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which); -private: - parser_buf& operator=(const parser_buf&); - parser_buf(const parser_buf&); -}; - -template -std::basic_streambuf* -parser_buf::setbuf(char_type* s, streamsize n) -{ - this->setg(s, s, s + n); - return this; -} - -template -typename parser_buf::pos_type -parser_buf::seekoff(off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which) -{ - if(which & ::std::ios_base::out) - return pos_type(off_type(-1)); - std::ptrdiff_t size = this->egptr() - this->eback(); - std::ptrdiff_t pos = this->gptr() - this->eback(); - charT* g = this->eback(); - switch(way) - { - case ::std::ios_base::beg: - if((off < 0) || (off > size)) - return pos_type(off_type(-1)); - else - this->setg(g, g + off, g + size); - break; - case ::std::ios_base::end: - if((off < 0) || (off > size)) - return pos_type(off_type(-1)); - else - this->setg(g, g + size - off, g + size); - break; - case ::std::ios_base::cur: - { - std::ptrdiff_t newpos = pos + off; - if((newpos < 0) || (newpos > size)) - return pos_type(off_type(-1)); - else - this->setg(g, g + newpos, g + size); - break; - } - default: ; - } - return static_cast(this->gptr() - this->eback()); -} - -template -typename parser_buf::pos_type -parser_buf::seekpos(pos_type sp, ::std::ios_base::openmode which) -{ - if(which & ::std::ios_base::out) - return pos_type(off_type(-1)); - off_type size = this->egptr() - this->eback(); - charT* g = this->eback(); - if(off_type(sp) <= size) - { - this->setg(g, g + off_type(sp), g + size); - } - return pos_type(off_type(-1)); -} - - -} // namespace - -namespace boost{ - namespace re_detail{ - -template <> -struct message_data -{ - unsigned char syntax_map[CHAR_MAX-CHAR_MIN]; - std::map > collating_elements; - std::map > classes; - //std::string _zero; - //std::string _ten; - parser_buf sbuf; - std::istream is; - std::string error_strings[boost::REG_E_UNKNOWN+1]; - - message_data(const std::locale& l, std::string regex_message_catalogue); -private: - message_data(const message_data&); - message_data& operator=(const message_data&); -}; - - -message_data::message_data(const std::locale& l, std::string regex_message_catalogue) - : is(&sbuf) -{ - is.imbue(l); + // we need to start by initialising our syntax map so we know which + // character is used for which purpose: + std::memset(m_char_map, 0, sizeof(m_char_map)); #ifndef BOOST_NO_STD_MESSAGES - - const std::messages* pm = 0; #ifndef __IBMCPP__ std::messages::catalog cat = static_cast::catalog>(-1); #else std::messages::catalog cat = reinterpret_cast::catalog>(-1); #endif - if(regex_message_catalogue.size()) + std::string cat_name(cpp_regex_traits::get_catalog_name()); + if(cat_name.size()) { - pm = &BOOST_USE_FACET(std::messages, l); - cat = pm->open(regex_message_catalogue, l); - if(cat < 0) + cat = this->m_pmessages->open( + cat_name, + this->m_locale); + if((int)cat < 0) { std::string m("Unable to open message catalog: "); - std::runtime_error err(m + regex_message_catalogue); - boost::throw_exception(err); - } - } -#endif - std::memset(syntax_map, cpp_regex_traits::syntax_char, 256); - unsigned i; - scoped_array a; - std::size_t array_size = 0; - std::size_t new_size; - for(i = 1; i < cpp_regex_traits::syntax_max; ++i) - { - new_size = re_get_default_message(0, 0, i+100); - if(new_size > array_size) - { - a.reset(new char[new_size]); - array_size = new_size; - } - re_get_default_message(a.get(), array_size, i+100); - std::string s = a.get(); -#ifndef BOOST_NO_STD_MESSAGES - if((int)cat >= 0) - s = pm->get(cat, 0, i+100, s); -#endif - for(std::size_t j = 0; j < s.size(); ++j) - { - syntax_map[(unsigned char)s[j]] = (unsigned char)(i); + std::runtime_error err(m + cat_name); + boost::re_detail::raise_runtime_error(err); } } - -#ifndef BOOST_NO_STD_MESSAGES - // load any custom collate names: // - // for some reason Borland C++ Builder 6 won't let us use - // std::isspace(char, std::locale) unless we call it - // unqualifed - weird. This seems to be affecting other - // STLport users as well (gcc3.1+STLport5), so enable the - // workaround for all STLport users... + // if we have a valid catalog then load our messages: // -#if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && !defined(BOOST_MSVC) - using namespace std; - using stlport::isspace; -# define BOOST_REGEX_STD -#else -# define BOOST_REGEX_STD std:: -#endif - - std::string c1, c2; - i = 400; if((int)cat >= 0) { - c2 = pm->get(cat, 0, i, c1); - while(c2.size()) - { - const char* p1, *p2, *p3, *p4;; - p1 = c2.c_str(); - while(*p1 && BOOST_REGEX_STD isspace((char)*p1, l))++p1; - p2 = p1; - while(*p2 && !BOOST_REGEX_STD isspace((char)*p2, l))++p2; - p3 = p2; - while(*p3 && BOOST_REGEX_STD isspace((char)*p3, l))++p3; - p4 = p3; - while(*p4 && !BOOST_REGEX_STD isspace((char)*p4, l))++p4; - collating_elements[std::string(p1, p2)] = std::string(p3, p4); - - ++i; - c2 = pm->get(cat, 0, i, c1); - } - } -#endif - std::string m; - std::string s; -#ifndef BOOST_NO_STD_MESSAGES - if((int)cat >= 0) - { - for(i = 0; i < re_classes_max; ++i) - { - s = pm->get(cat, 0, i+300, m); - if(s.size()) - classes[s] = i; - } - for(i = 0; i <= boost::REG_E_UNKNOWN ; ++i) - { - s = pm->get(cat, 0, i+200, m); - error_strings[i] = s; - } - } - - if((int)cat >= 0) - pm->close(cat); -#endif -} - -std::string BOOST_REGEX_CALL cpp_regex_traits_base::set_message_catalogue(const std::string& l) -{ - if(sizeof(regex_message_cat) <= l.size()) - return l; - std::string old(regex_message_cat); - std::strcpy(regex_message_cat, l.c_str()); - return old; -} - -char cpp_regex_traits_base::regex_message_cat[BOOST_REGEX_MAX_PATH] = {0}; - - -} // namespace re_detail - - -cpp_regex_traits::cpp_regex_traits() -{ - pmd = new re_detail::message_data(locale_inst, regex_message_cat); - psyntax = pmd->syntax_map; #ifndef BOOST_NO_EXCEPTIONS - try{ + try{ #endif - lower_map = new char[char_set_size]; - BOOST_REGEX_NOEH_ASSERT(lower_map) + for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i) + { + string_type mss = this->m_pmessages->get(cat, 0, i, get_default_syntax(i)); + for(string_type::size_type j = 0; j < mss.size(); ++j) + { + m_char_map[static_cast(mss[j])] = i; + } + } + this->m_pmessages->close(cat); #ifndef BOOST_NO_EXCEPTIONS - } - catch(...) - { - delete pmd; - throw; - } + } + catch(...) + { + this->m_pmessages->close(cat); + throw; + } #endif - for(unsigned int i = 0; i < char_set_size; ++i) - lower_map[i] = static_cast(i); - pctype = &BOOST_USE_FACET(std::ctype, locale_inst); - pctype->tolower(&lower_map[0], &lower_map[char_set_size]); - pcollate = &BOOST_USE_FACET(std::collate, locale_inst); - sort_type = re_detail::find_sort_syntax(this, &(this->sort_delim)); -} - -void cpp_regex_traits::swap(cpp_regex_traits& that) -{ - std::swap(locale_inst, that.locale_inst); // this one goes first - std::swap(pmd, that.pmd); - std::swap(psyntax, that.psyntax); - std::swap(lower_map, that.lower_map); - std::swap(pctype, that.pctype); - std::swap(pcollate, that.pcollate); - std::swap(sort_type, that.sort_type); - std::swap(sort_delim, that.sort_delim); -} - -cpp_regex_traits::~cpp_regex_traits() -{ - delete pmd; - delete[] lower_map; -} - -int BOOST_REGEX_CALL cpp_regex_traits::toi(char c)const -{ - pmd->sbuf.pubsetbuf(&c, 1); - pmd->is.clear(); - pmd->is >> std::dec; - int val; - if(pmd->is >> val) - { - return val; } else - return 0; -} - -int BOOST_REGEX_CALL cpp_regex_traits::toi(const char*& first, const char* last, int radix)const -{ - pmd->sbuf.pubsetbuf(const_cast(static_cast(first)), static_cast(last-first)); - pmd->is.clear(); - if(std::abs(radix) == 16) pmd->is >> std::hex; - else if(std::abs(radix) == 8) pmd->is >> std::oct; - else pmd->is >> std::dec; - int val; - if(pmd->is >> val) { - first = first + ((last - first) - pmd->sbuf.in_avail()); - return val; - } - else - return 0; -} - -boost::uint_fast32_t BOOST_REGEX_CALL cpp_regex_traits::lookup_classname(const char* first, const char* last)const -{ - BOOST_RE_GUARD_STACK - unsigned int i; - std::string s(first, last); - - std::map >::const_iterator pos = pmd->classes.find(s); - if(pos != pmd->classes.end()) - return re_char_class_id[(*pos).second]; - - for(i = 0; i < re_classes_max; ++i) - { - if(s == re_char_class_names[i]) - return re_char_class_id[i]; - } - return 0; -} - -bool BOOST_REGEX_CALL cpp_regex_traits::lookup_collatename(std::string& s, const char* first, const char* last)const -{ - BOOST_RE_GUARD_STACK - std::string name(first, last); - std::map >::const_iterator pos = pmd->collating_elements.find(name); - if(pos != pmd->collating_elements.end()) - { - s = (*pos).second; - return true; - } - return re_detail::re_lookup_def_collate_name(s, name.c_str()); -} - -void BOOST_REGEX_CALL cpp_regex_traits::transform_primary(std::string& out, const std::string& in)const -{ - transform(out, in); - switch(sort_type) - { - case re_detail::sort_C: - case re_detail::sort_unknown: - break; - case re_detail::sort_fixed: - if((unsigned)sort_delim < out.size()) - out.erase((int)sort_delim); - break; - case re_detail::sort_delim: - for(unsigned int i = 0; i < out.size(); ++i) +#endif + for(regex_constants::syntax_type j = 1; j < regex_constants::syntax_max; ++j) { - if((out[i] == sort_delim) && (i+1 < out.size())) + const char* ptr = get_default_syntax(j); + while(ptr && *ptr) { - out.erase(i+1); - break; + m_char_map[static_cast(*ptr)] = j; + ++ptr; } } +#ifndef BOOST_NO_STD_MESSAGES } -} - - -std::string BOOST_REGEX_CALL cpp_regex_traits::error_string(unsigned id)const -{ - if((id <= boost::REG_E_UNKNOWN) && (pmd->error_strings[id].size())) - return pmd->error_strings[id]; - return boost::re_detail::re_default_error_messages[id]; -} - -cpp_regex_traits::locale_type BOOST_REGEX_CALL cpp_regex_traits::imbue(locale_type l) -{ - locale_type old_l(locale_inst); - locale_inst = l; - re_detail::message_data* npmd = new re_detail::message_data(locale_inst, regex_message_cat); - delete pmd; - pmd = npmd; - psyntax = pmd->syntax_map; - for(unsigned int i = 0; i < char_set_size; ++i) - lower_map[i] = static_cast(i); - pctype = &BOOST_USE_FACET(std::ctype, locale_inst); - pctype->tolower(&lower_map[0], &lower_map[char_set_size]); - pcollate = &BOOST_USE_FACET(std::collate, locale_inst); - sort_type = re_detail::find_sort_syntax(this, &(this->sort_delim)); - return old_l; -} - -#if !defined(BOOST_NO_WREGEX) && !defined(BOOST_NO_STD_WSTREAMBUF) - -namespace re_detail{ - -std::string BOOST_REGEX_CALL to_narrow(const std::basic_string& is, const std::codecvt& cvt) -{ - BOOST_RE_GUARD_STACK - std::basic_string::size_type bufsize = is.size() * 2; +#endif // - // declare buffer first as VC6 workaround for internal compiler error! - char* pc = new char[bufsize]; - scoped_array t(pc); - #if defined(BOOST_MSVC) && !defined(DINKUMWARE_CE) - std::mbstate_t state = 0; - #else - std::mbstate_t state = std::mbstate_t(); - #endif - - const wchar_t* next_in; - char* next_out; - while(true) - { - switch(cvt.out(state, is.c_str(), is.c_str() + is.size(), next_in, t.get(), t.get() + bufsize, next_out)) - { - case std::codecvt_base::ok: - return std::string(t.get(), next_out); - case std::codecvt_base::partial: - bufsize *= 2; - t.reset(new char[bufsize]); - continue; - case std::codecvt_base::error: - // not much we can do here but guess: - case std::codecvt_base::noconv: - std::string out; - for(unsigned i = 0; i < is.size(); ++i) - { - out.append(1, (char)is[i]); - } - return out; - } - } -} - -std::wstring BOOST_REGEX_CALL to_wide(const std::string& is, const std::codecvt& cvt) -{ - BOOST_RE_GUARD_STACK - std::string::size_type bufsize = is.size() + 2; - std::string::size_type maxsize = is.size() * 100; + // finish off by calculating our escape types: // - // declare buffer first as VC6 workaround for internal compiler error! - wchar_t* pc = new wchar_t[bufsize]; - scoped_array t(pc); - #if defined(BOOST_MSVC) && !defined(DINKUMWARE_CE) - std::mbstate_t state = 0; - #else - std::mbstate_t state = std::mbstate_t(); - #endif - - - wchar_t* next_out; - const char* next_in; - while(true) + unsigned char i = 'A'; + do { - switch(cvt.in(state, is.c_str(), is.c_str() + is.size(), next_in, t.get(), t.get() + bufsize, next_out)) + if(m_char_map[i] == 0) { - case std::codecvt_base::ok: - return std::wstring(t.get(), next_out); - case std::codecvt_base::partial: - bufsize *= 2; - if(bufsize < maxsize) - { - t.reset(new wchar_t[bufsize]); - continue; - } - // - // error fall through: - case std::codecvt_base::error: - // not much we can do here but guess: - case std::codecvt_base::noconv: - std::wstring out; - for(unsigned i = 0; i < is.size(); ++i) - { - out.append(1, is[i]); - } - return out; + if(this->m_pctype->is(std::ctype_base::lower, i)) + m_char_map[i] = regex_constants::escape_type_class; + else if(this->m_pctype->is(std::ctype_base::upper, i)) + m_char_map[i] = regex_constants::escape_type_not_class; } - } + }while(0xFF != i++); } - - -template <> -struct message_data -{ -#ifndef BOOST_NO_STD_MESSAGES - typedef std::messages::string_type string_type; -#else - typedef std::wstring string_type; +} // re_detail +} // boost #endif - string_type name; - - struct syntax_map - { - wchar_t c; - unsigned int type; - }; - - std::list syntax; - std::map classes; - std::map collating_elements; - unsigned char syntax_[CHAR_MAX-CHAR_MIN+1]; - - parser_buf sbuf; - std::wistream is; - std::string error_strings[boost::REG_E_UNKNOWN+1]; - - message_data(const std::locale& l, const std::string& regex_message_catalogue); -private: - message_data(const message_data&); - message_data& operator=(const message_data&); -}; - -message_data::message_data(const std::locale& l, const std::string& regex_message_catalogue) - : is(&sbuf) -{ - is.imbue(l); - syntax_map m; - typedef std::codecvt cvt_type; - const cvt_type& cvt = BOOST_USE_FACET(cvt_type, l); -#ifndef BOOST_NO_STD_MESSAGES - const std::messages& msgs = BOOST_USE_FACET(std::messages, l); -#ifndef __IBMCPP__ - std::messages::catalog cat = static_cast::catalog>(-1); -#else - std::messages::catalog cat = reinterpret_cast::catalog>(-1); -#endif - if(regex_message_catalogue.size()) - { - cat = msgs.open(regex_message_catalogue, l); - if(cat < 0) - { - std::string mess("Unable to open message catalog: "); - std::runtime_error err(mess + regex_message_catalogue); - boost::throw_exception(err); - } - } -#endif - scoped_array a; - std::size_t array_size = 0; - std::size_t new_size; - std::size_t i; - std::memset(syntax_, cpp_regex_traits::syntax_char, sizeof(syntax_)); - for(i = 1; i < cpp_regex_traits::syntax_max; ++i) - { - new_size = re_get_default_message(0, 0, i+100); - if(new_size > array_size) - { - a.reset(new char[new_size]); - array_size = new_size; - } - re_get_default_message(a.get(), array_size, i+100); - std::string ns = a.get(); - string_type s = to_wide(ns, cvt); -#ifndef BOOST_NO_STD_MESSAGES - if((int)cat >= 0) - s = BOOST_USE_FACET(std::messages, l).get(cat, 0, (int)i+100, s); -#endif - for(unsigned int j = 0; j < s.size(); ++j) - { -#if defined(WCHAR_MIN) && (WCHAR_MIN == 0) - if(s[j] <= UCHAR_MAX) -#else - if((s[j] <= UCHAR_MAX) && (s[j] >= 0)) -#endif - syntax_[s[j]] = static_cast(i); - else - { - m.c = s[j]; - m.type = static_cast(i); - syntax.push_back(m); - } - } - } - -#ifndef BOOST_NO_STD_MESSAGES - // load any custom collate names: - string_type c1, c2; - i = 400; - if((int)cat >= 0) - { - c2 = msgs.get(cat, 0, (int)i, c1); - while(c2.size()) - { - const wchar_t* p1, *p2, *p3, *p4;; - p1 = c2.c_str(); - while(*p1 && BOOST_REGEX_STD isspace((wchar_t)*p1, l))++p1; - p2 = p1; - while(*p2 && !BOOST_REGEX_STD isspace((wchar_t)*p2, l))++p2; - p3 = p2; - while(*p3 && BOOST_REGEX_STD isspace((wchar_t)*p3, l))++p3; - p4 = p3; - while(*p4 && !BOOST_REGEX_STD isspace((wchar_t)*p4, l))++p4; - collating_elements[std::basic_string(p1, p2)] = std::basic_string(p3, p4); - - ++i; - c2 = msgs.get(cat, 0, (int)i, c1); - } - } - - if((int)cat >= 0) - { - c2.erase(); - for(i = 0; i < re_classes_max; ++i) - { - c1 = msgs.get(cat, 0, static_cast(i+300), c2); - if(c1.size()) - classes[c1] = i; - } - for(i = 0; i <= boost::REG_E_UNKNOWN ; ++i) - { - c1 = msgs.get(cat, 0, static_cast(i+200), c2); - error_strings[i] = to_narrow(c1, cvt); - } - } - - if((int)cat >= 0) - msgs.close(cat); -#endif -} - -} // namespace re_detail - -unsigned int BOOST_REGEX_CALL cpp_regex_traits::do_syntax_type(size_type c)const -{ - std::list::syntax_map>::const_iterator i, j; - i = pmd->syntax.begin(); - j = pmd->syntax.end(); - while(i != j) - { - if(((uchar_type)(*i).c) == c) - return (*i).type; - ++i; - } - return 0; -} - -void BOOST_REGEX_CALL cpp_regex_traits::transform_primary(std::basic_string& out, const std::basic_string& in)const -{ - transform(out, in); - switch(sort_type) - { - case re_detail::sort_C: - case re_detail::sort_unknown: - break; - case re_detail::sort_fixed: - if((unsigned)sort_delim < out.size()) - out.erase((int)sort_delim); - break; - case re_detail::sort_delim: - for(unsigned int i = 0; i < out.size(); ++i) - { - if((out[i] == sort_delim) && (i+1 < out.size())) - { - out.erase(i+1); - break; - } - } - } -} - -int BOOST_REGEX_CALL cpp_regex_traits::toi(wchar_t c)const -{ - pmd->sbuf.pubsetbuf(&c, 1); - pmd->is.clear(); - pmd->is >> std::dec; - int val; - if(pmd->is >> val) - { - return val; - } - else - return 0; -} - -int BOOST_REGEX_CALL cpp_regex_traits::toi(const wchar_t*& first, const wchar_t* last, int radix)const -{ - pmd->sbuf.pubsetbuf(const_cast(first), static_cast(last-first)); - pmd->is.clear(); - if(std::abs(radix) == 16) pmd->is >> std::hex; - else if(std::abs(radix) == 8) pmd->is >> std::oct; - else pmd->is >> std::dec; - int val; - if(pmd->is >> val) - { - first = first + ((last - first) - pmd->sbuf.in_avail()); - return val; - } - else - return 0; -} - -boost::uint_fast32_t BOOST_REGEX_CALL cpp_regex_traits::lookup_classname(const wchar_t* first, const wchar_t* last)const -{ - BOOST_RE_GUARD_STACK - unsigned int i; - std::wstring s(first, last); - - std::map::const_iterator pos = pmd->classes.find(s); - if(pos != pmd->classes.end()) - return re_char_class_id[(*pos).second]; - - std::string ns = re_detail::to_narrow(s, *pcdv); - - for(i = 0; i < re_classes_max; ++i) - { - if(ns == re_char_class_names[i]) - return re_char_class_id[i]; - } - return 0; -} - -bool BOOST_REGEX_CALL cpp_regex_traits::lookup_collatename(std::basic_string& s, const wchar_t* first, const wchar_t* last)const -{ - BOOST_RE_GUARD_STACK - std::wstring name(first, last); - std::map::const_iterator pos = pmd->collating_elements.find(name); - if(pos != pmd->collating_elements.end()) - { - s = (*pos).second; - return true; - } - std::string ns = re_detail::to_narrow(name, *pcdv); - std::string ns2; - bool result = re_detail::re_lookup_def_collate_name(ns2, ns.c_str()); - s = re_detail::to_wide(ns2, *pcdv); - return result; -} - -std::string BOOST_REGEX_CALL cpp_regex_traits::error_string(unsigned id)const -{ - if((id <= boost::REG_E_UNKNOWN) && (pmd->error_strings[id].size())) - return pmd->error_strings[id]; - return boost::re_detail::re_default_error_messages[id]; -} - -cpp_regex_traits::cpp_regex_traits() -{ - pmd = new re_detail::message_data(locale_inst, std::string(regex_message_cat)); - psyntax = pmd->syntax_; -#ifndef BOOST_NO_EXCEPTIONS - try{ -#endif - lower_map = new wchar_t[char_set_size]; - BOOST_REGEX_NOEH_ASSERT(lower_map) -#ifndef BOOST_NO_EXCEPTIONS - } - catch(...) - { - delete pmd; - throw; - } -#endif - for(unsigned int i = 0; i < char_set_size; ++i) - lower_map[i] = static_cast(i); - pctype = &BOOST_USE_FACET(std::ctype, locale_inst); - pctype->tolower(&lower_map[0], &lower_map[char_set_size]); - pcollate = &BOOST_USE_FACET(std::collate, locale_inst); - typedef std::codecvt cvt_t; - pcdv = &BOOST_USE_FACET(cvt_t, locale_inst); - sort_type = re_detail::find_sort_syntax(this, &(this->sort_delim)); -} - -cpp_regex_traits::~cpp_regex_traits() -{ - delete pmd; - delete[] lower_map; -} - -cpp_regex_traits::locale_type BOOST_REGEX_CALL cpp_regex_traits::imbue(locale_type l) -{ - locale_type old_l(locale_inst); - locale_inst = l; - re_detail::message_data* npmd = new re_detail::message_data(locale_inst, std::string(regex_message_cat)); - delete pmd; - pmd = npmd; - psyntax = pmd->syntax_; - for(unsigned int i = 0; i < char_set_size; ++i) - lower_map[i] = static_cast(i); - pctype = &BOOST_USE_FACET(std::ctype, locale_inst); - pctype->tolower(&lower_map[0], &lower_map[char_set_size]); - pcollate = &BOOST_USE_FACET(std::collate, locale_inst); - typedef std::codecvt cvt_t; - pcdv = &BOOST_USE_FACET(cvt_t, locale_inst); - sort_type = re_detail::find_sort_syntax(this, &(this->sort_delim)); - return old_l; -} - -std::size_t BOOST_REGEX_CALL cpp_regex_traits::strwiden(wchar_t *s1, std::size_t len, const char *s2)const -{ - std::string s(s2); - std::wstring ws = re_detail::to_wide(s2, *pcdv); - if(len > ws.size()) - std::wcscpy(s1, ws.c_str()); - return ws.size()+1; -} - -void cpp_regex_traits::swap(cpp_regex_traits& that) -{ - std::swap(locale_inst, that.locale_inst); // this one must go first - std::swap(pmd, that.pmd); - std::swap(psyntax, that.psyntax); - std::swap(lower_map, that.lower_map); - std::swap(pctype, that.pctype); - std::swap(pcollate, that.pcollate); - std::swap(pcdv, that.pcdv); - std::swap(sort_type, that.sort_type); - std::swap(sort_delim, that.sort_delim); -} - -#endif // BOOST_NO_WREGEX - - -} // namespace boost - -#endif - - - - diff --git a/boost/libs/regex/src/cregex.cpp b/boost/libs/regex/src/cregex.cpp index ef25994600..ca134265a0 100644 --- a/boost/libs/regex/src/cregex.cpp +++ b/boost/libs/regex/src/cregex.cpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -21,9 +21,6 @@ #include #include -#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION -# include -#endif #if !defined(BOOST_NO_STD_STRING) #include #include @@ -54,7 +51,6 @@ namespace{ template std::string to_string(iterator i, iterator j) { - BOOST_RE_GUARD_STACK std::string s; while(i != j) { @@ -108,7 +104,6 @@ public: void RegExData::update() { - BOOST_RE_GUARD_STACK strings.erase(strings.begin(), strings.end()); positions.erase(positions.begin(), positions.end()); if(t == type_pc) @@ -116,7 +111,7 @@ void RegExData::update() for(unsigned int i = 0; i < m.size(); ++i) { if(m[i].matched) strings[i] = std::string(m[i].first, m[i].second); - positions[i] = m[i].matched ? m[i].first - pbase : RegEx::npos; + positions[i] = m[i].matched ? m[i].first - pbase : -1; } } #ifndef BOOST_REGEX_NO_FILEITER @@ -125,7 +120,7 @@ void RegExData::update() for(unsigned int i = 0; i < fm.size(); ++i) { if(fm[i].matched) strings[i] = to_string(fm[i].first, fm[i].second); - positions[i] = fm[i].matched ? fm[i].first - fbase : RegEx::npos; + positions[i] = fm[i].matched ? fm[i].first - fbase : -1; } } #endif @@ -134,7 +129,6 @@ void RegExData::update() void RegExData::clean() { - BOOST_RE_GUARD_STACK #ifndef BOOST_REGEX_NO_FILEITER fbase = mapfile::iterator(); fm = match_results(); @@ -145,54 +139,46 @@ void RegExData::clean() RegEx::RegEx() { - BOOST_RE_GUARD_STACK pdata = new re_detail::RegExData(); } RegEx::RegEx(const RegEx& o) { - BOOST_RE_GUARD_STACK pdata = new re_detail::RegExData(*(o.pdata)); } RegEx::~RegEx() { - BOOST_RE_GUARD_STACK delete pdata; } RegEx::RegEx(const char* c, bool icase) { - BOOST_RE_GUARD_STACK pdata = new re_detail::RegExData(); SetExpression(c, icase); } RegEx::RegEx(const std::string& s, bool icase) { - BOOST_RE_GUARD_STACK pdata = new re_detail::RegExData(); SetExpression(s.c_str(), icase); } RegEx& RegEx::operator=(const RegEx& o) { - BOOST_RE_GUARD_STACK *pdata = *(o.pdata); return *this; } RegEx& RegEx::operator=(const char* p) { - BOOST_RE_GUARD_STACK SetExpression(p, false); return *this; } unsigned int RegEx::SetExpression(const char* p, bool icase) { - BOOST_RE_GUARD_STACK - boost::uint_fast32_t f = icase ? regex::normal | regex::use_except | regex::icase : regex::normal | regex::use_except; + boost::uint_fast32_t f = icase ? regex::normal | regex::icase : regex::normal; return pdata->e.set_expression(p, f); } @@ -204,7 +190,6 @@ unsigned int RegEx::error_code()const std::string RegEx::Expression()const { - BOOST_RE_GUARD_STACK return pdata->e.expression(); } @@ -213,7 +198,6 @@ std::string RegEx::Expression()const // bool RegEx::Match(const char* p, match_flag_type flags) { - BOOST_RE_GUARD_STACK pdata->t = re_detail::RegExData::type_pc; pdata->pbase = p; const char* end = p; @@ -229,7 +213,6 @@ bool RegEx::Match(const char* p, match_flag_type flags) bool RegEx::Search(const char* p, match_flag_type flags) { - BOOST_RE_GUARD_STACK pdata->t = re_detail::RegExData::type_pc; pdata->pbase = p; const char* end = p; @@ -257,7 +240,6 @@ struct pred1 } unsigned int RegEx::Grep(GrepCallback cb, const char* p, match_flag_type flags) { - BOOST_RE_GUARD_STACK pdata->t = re_detail::RegExData::type_pc; pdata->pbase = p; const char* end = p; @@ -287,7 +269,6 @@ private: unsigned int RegEx::Grep(std::vector& v, const char* p, match_flag_type flags) { - BOOST_RE_GUARD_STACK pdata->t = re_detail::RegExData::type_pc; pdata->pbase = p; const char* end = p; @@ -317,7 +298,6 @@ private: } unsigned int RegEx::Grep(std::vector& v, const char* p, match_flag_type flags) { - BOOST_RE_GUARD_STACK pdata->t = re_detail::RegExData::type_pc; pdata->pbase = p; const char* end = p; @@ -350,24 +330,23 @@ struct pred4 namespace{ void BuildFileList(std::list* pl, const char* files, bool recurse) { - BOOST_RE_GUARD_STACK file_iterator start(files); file_iterator end; if(recurse) { // go through sub directories: char buf[MAX_PATH]; - std::strcpy(buf, start.root()); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(buf, MAX_PATH, start.root())); if(*buf == 0) { - std::strcpy(buf, "."); - std::strcat(buf, directory_iterator::separator()); - std::strcat(buf, "*"); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(buf, MAX_PATH, ".")); + re_detail::overflow_error_if_not_zero(re_detail::strcat_s(buf, MAX_PATH, directory_iterator::separator())); + re_detail::overflow_error_if_not_zero(re_detail::strcat_s(buf, MAX_PATH, "*")); } else { - std::strcat(buf, directory_iterator::separator()); - std::strcat(buf, "*"); + re_detail::overflow_error_if_not_zero(re_detail::strcat_s(buf, MAX_PATH, directory_iterator::separator())); + re_detail::overflow_error_if_not_zero(re_detail::strcat_s(buf, MAX_PATH, "*")); } directory_iterator dstart(buf); directory_iterator dend; @@ -380,7 +359,11 @@ void BuildFileList(std::list* pl, const char* files, bool recurse) while(dstart != dend) { - std::sprintf(buf, "%s%s%s", dstart.path(), directory_iterator::separator(), ptr); +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) + (::sprintf_s)(buf, sizeof(buf), "%s%s%s", dstart.path(), directory_iterator::separator(), ptr); +#else + (std::sprintf)(buf, "%s%s%s", dstart.path(), directory_iterator::separator(), ptr); +#endif BuildFileList(pl, buf, recurse); ++dstart; } @@ -395,7 +378,6 @@ void BuildFileList(std::list* pl, const char* files, bool recurse) unsigned int RegEx::GrepFiles(GrepFileCallback cb, const char* files, bool recurse, match_flag_type flags) { - BOOST_RE_GUARD_STACK unsigned int result = 0; std::list file_list; BuildFileList(&file_list, files, recurse); @@ -423,7 +405,6 @@ unsigned int RegEx::GrepFiles(GrepFileCallback cb, const char* files, bool recur unsigned int RegEx::FindFiles(FindFilesCallback cb, const char* files, bool recurse, match_flag_type flags) { - BOOST_RE_GUARD_STACK unsigned int result = 0; std::list file_list; BuildFileList(&file_list, files, recurse); @@ -491,7 +472,6 @@ std::size_t RegEx::Split(std::vector& v, // std::size_t RegEx::Position(int i)const { - BOOST_RE_GUARD_STACK switch(pdata->t) { case re_detail::RegExData::type_pc: @@ -511,16 +491,14 @@ std::size_t RegEx::Position(int i)const return RegEx::npos; } -unsigned int RegEx::Marks()const +std::size_t RegEx::Marks()const { - BOOST_RE_GUARD_STACK return pdata->e.mark_count(); } std::size_t RegEx::Length(int i)const { - BOOST_RE_GUARD_STACK switch(pdata->t) { case re_detail::RegExData::type_pc: @@ -542,7 +520,6 @@ std::size_t RegEx::Length(int i)const bool RegEx::Matched(int i)const { - BOOST_RE_GUARD_STACK switch(pdata->t) { case re_detail::RegExData::type_pc: @@ -565,7 +542,6 @@ bool RegEx::Matched(int i)const std::string RegEx::What(int i)const { - BOOST_RE_GUARD_STACK std::string result; switch(pdata->t) { @@ -588,14 +564,10 @@ std::string RegEx::What(int i)const return result; } -#ifndef __MINGW32__ -#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION -const std::size_t RegEx::npos = ::boost::integer_traits::const_max; -#elif defined(BOOST_HAS_LONG_LONG) -const std::size_t RegEx::npos = ~0ULL; +#ifdef BOOST_HAS_LONG_LONG +const std::size_t RegEx::npos = static_cast(~0ULL); #else -const std::size_t RegEx::npos = ~0UL; -#endif +const std::size_t RegEx::npos = static_cast(~0UL); #endif } // namespace boost diff --git a/boost/libs/regex/src/fileiter.cpp b/boost/libs/regex/src/fileiter.cpp index af4c23464d..cbb46c01d0 100644 --- a/boost/libs/regex/src/fileiter.cpp +++ b/boost/libs/regex/src/fileiter.cpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -21,12 +21,31 @@ #include #include -#ifdef BOOST_REGEX_V3 -#include -#else +#include +#include #include +#include +#include + +#include +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::sprintf; + using ::fseek; + using ::fread; + using ::ftell; + using ::fopen; + using ::fclose; + using ::FILE; + using ::strcpy; + using ::strcpy; + using ::strcat; + using ::strcmp; + using ::strlen; +} #endif + #ifndef BOOST_REGEX_NO_FILEITER #if defined(__CYGWIN__) || defined(__CYGWIN32__) @@ -47,7 +66,7 @@ namespace boost{ // directories are separated with '\\' // and names are insensitive of case -const char* _fi_sep = "\\"; +BOOST_REGEX_DECL const char* _fi_sep = "\\"; const char* _fi_sep_alt = "/"; #define BOOST_REGEX_FI_TRANSLATE(c) std::tolower(c) @@ -57,7 +76,7 @@ const char* _fi_sep_alt = "/"; // directories are separated with '/' // and names are sensitive of case -const char* _fi_sep = "/"; +BOOST_REGEX_DECL const char* _fi_sep = "/"; const char* _fi_sep_alt = _fi_sep; #define BOOST_REGEX_FI_TRANSLATE(c) c @@ -67,7 +86,6 @@ const char* _fi_sep_alt = _fi_sep; void mapfile::open(const char* file) { - BOOST_RE_GUARD_STACK #if defined(__CYGWIN__)||defined(__CYGWIN32__) char win32file[ MAX_PATH ]; cygwin_conv_to_win32_path( file, win32file ); @@ -84,7 +102,7 @@ void mapfile::open(const char* file) hmap = 0; hfile = 0; std::runtime_error err("Unable to create file mapping."); - boost::throw_exception(err); + boost::re_detail::raise_runtime_error(err); } _first = static_cast(MapViewOfFile(hmap, FILE_MAP_READ, 0, 0, 0)); if(_first == 0) @@ -110,7 +128,6 @@ void mapfile::open(const char* file) void mapfile::close() { - BOOST_RE_GUARD_STACK if(hfile != INVALID_HANDLE_VALUE) { UnmapViewOfFile((void*)_first); @@ -125,7 +142,6 @@ void mapfile::close() mapfile_iterator& mapfile_iterator::operator = (const mapfile_iterator& i) { - BOOST_RE_GUARD_STACK if(file && node) file->unlock(node); file = i.file; @@ -138,7 +154,6 @@ mapfile_iterator& mapfile_iterator::operator = (const mapfile_iterator& i) mapfile_iterator& mapfile_iterator::operator++ () { - BOOST_RE_GUARD_STACK if((++offset == mapfile::buf_size) && file) { ++node; @@ -151,7 +166,6 @@ mapfile_iterator& mapfile_iterator::operator++ () mapfile_iterator mapfile_iterator::operator++ (int) { - BOOST_RE_GUARD_STACK mapfile_iterator temp(*this); if((++offset == mapfile::buf_size) && file) { @@ -165,7 +179,6 @@ mapfile_iterator mapfile_iterator::operator++ (int) mapfile_iterator& mapfile_iterator::operator-- () { - BOOST_RE_GUARD_STACK if((offset == 0) && file) { --node; @@ -180,7 +193,6 @@ mapfile_iterator& mapfile_iterator::operator-- () mapfile_iterator mapfile_iterator::operator-- (int) { - BOOST_RE_GUARD_STACK mapfile_iterator temp(*this); if((offset == 0) && file) { @@ -196,7 +208,6 @@ mapfile_iterator mapfile_iterator::operator-- (int) mapfile_iterator operator + (const mapfile_iterator& i, long off) { - BOOST_RE_GUARD_STACK mapfile_iterator temp(i); temp += off; return temp; @@ -204,7 +215,6 @@ mapfile_iterator operator + (const mapfile_iterator& i, long off) mapfile_iterator operator - (const mapfile_iterator& i, long off) { - BOOST_RE_GUARD_STACK mapfile_iterator temp(i); temp -= off; return temp; @@ -212,21 +222,18 @@ mapfile_iterator operator - (const mapfile_iterator& i, long off) mapfile::iterator mapfile::begin()const { - BOOST_RE_GUARD_STACK return mapfile_iterator(this, 0); } mapfile::iterator mapfile::end()const { - BOOST_RE_GUARD_STACK return mapfile_iterator(this, _size); } void mapfile::lock(pointer* node)const { - BOOST_RE_GUARD_STACK - assert(node >= _first); - assert(node <= _last); + BOOST_ASSERT(node >= _first); + BOOST_ASSERT(node <= _last); if(node < _last) { if(*node == 0) @@ -265,9 +272,8 @@ void mapfile::lock(pointer* node)const void mapfile::unlock(pointer* node)const { - BOOST_RE_GUARD_STACK - assert(node >= _first); - assert(node <= _last); + BOOST_ASSERT(node >= _first); + BOOST_ASSERT(node <= _last); if(node < _last) { if(--(*reinterpret_cast(*node)) == 0) @@ -279,7 +285,6 @@ void mapfile::unlock(pointer* node)const long int get_file_length(std::FILE* hfile) { - BOOST_RE_GUARD_STACK long int result; std::fseek(hfile, 0, SEEK_END); result = std::ftell(hfile); @@ -290,7 +295,6 @@ long int get_file_length(std::FILE* hfile) void mapfile::open(const char* file) { - BOOST_RE_GUARD_STACK hfile = std::fopen(file, "rb"); #ifndef BOOST_NO_EXCEPTIONS try{ @@ -325,7 +329,6 @@ void mapfile::open(const char* file) void mapfile::close() { - BOOST_RE_GUARD_STACK if(hfile != 0) { pointer* p = _first; @@ -350,7 +353,6 @@ void mapfile::close() file_iterator::file_iterator() { - BOOST_RE_GUARD_STACK _root = _path = 0; ref = 0; #ifndef BOOST_NO_EXCEPTIONS @@ -381,7 +383,6 @@ file_iterator::file_iterator() file_iterator::file_iterator(const char* wild) { - BOOST_RE_GUARD_STACK _root = _path = 0; ref = 0; #ifndef BOOST_NO_EXCEPTIONS @@ -391,34 +392,24 @@ file_iterator::file_iterator(const char* wild) BOOST_REGEX_NOEH_ASSERT(_root) _path = new char[MAX_PATH]; BOOST_REGEX_NOEH_ASSERT(_path) - std::strcpy(_root, wild); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_root, MAX_PATH, wild)); ptr = _root; while(*ptr)++ptr; while((ptr > _root) && (*ptr != *_fi_sep) && (*ptr != *_fi_sep_alt))--ptr; - #if 0 - *ptr = 0; - std::strcpy(_path, _root); - if(*_path == 0) - std::strcpy(_path, "."); - std::strcat(_path, _fi_sep); - ptr = _path + std::strlen(_path); - #else if((ptr == _root) && ( (*ptr== *_fi_sep) || (*ptr==*_fi_sep_alt) ) ) { _root[1]='\0'; - std::strcpy(_path, _root); - ptr = _path + std::strlen(_path); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, _root)); } else { *ptr = 0; - std::strcpy(_path, _root); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, _root)); if(*_path == 0) - std::strcpy(_path, "."); - std::strcat(_path, _fi_sep); - ptr = _path + std::strlen(_path); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, ".")); + re_detail::overflow_error_if_not_zero(re_detail::strcat_s(_path, MAX_PATH, _fi_sep)); } - #endif + ptr = _path + std::strlen(_path); ref = new file_iterator_ref(); BOOST_REGEX_NOEH_ASSERT(ref) @@ -432,7 +423,7 @@ file_iterator::file_iterator(const char* wild) } else { - std::strcpy(ptr, ref->_data.cFileName); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(ptr, (MAX_PATH - (ptr - _path)), ref->_data.cFileName)); if(ref->_data.dwFileAttributes & _fi_dir) next(); } @@ -450,7 +441,6 @@ file_iterator::file_iterator(const char* wild) file_iterator::file_iterator(const file_iterator& other) { - BOOST_RE_GUARD_STACK _root = _path = 0; ref = 0; #ifndef BOOST_NO_EXCEPTIONS @@ -460,8 +450,8 @@ file_iterator::file_iterator(const file_iterator& other) BOOST_REGEX_NOEH_ASSERT(_root) _path = new char[MAX_PATH]; BOOST_REGEX_NOEH_ASSERT(_path) - std::strcpy(_root, other._root); - std::strcpy(_path, other._path); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_root, MAX_PATH, other._root)); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, other._path)); ptr = _path + (other.ptr - other._path); ref = other.ref; #ifndef BOOST_NO_EXCEPTIONS @@ -478,9 +468,8 @@ file_iterator::file_iterator(const file_iterator& other) file_iterator& file_iterator::operator=(const file_iterator& other) { - BOOST_RE_GUARD_STACK - std::strcpy(_root, other._root); - std::strcpy(_path, other._path); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_root, MAX_PATH, other._root)); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, other._path)); ptr = _path + (other.ptr - other._path); if(--(ref->count) == 0) { @@ -496,7 +485,6 @@ file_iterator& file_iterator::operator=(const file_iterator& other) file_iterator::~file_iterator() { - BOOST_RE_GUARD_STACK delete[] _root; delete[] _path; if(--(ref->count) == 0) @@ -509,7 +497,6 @@ file_iterator::~file_iterator() file_iterator file_iterator::operator++(int) { - BOOST_RE_GUARD_STACK file_iterator temp(*this); next(); return temp; @@ -518,7 +505,6 @@ file_iterator file_iterator::operator++(int) void file_iterator::next() { - BOOST_RE_GUARD_STACK if(ref->hf != _fi_invalid_handle) { bool cont = true; @@ -537,7 +523,7 @@ void file_iterator::next() ptr = _path; } else - std::strcpy(ptr, ref->_data.cFileName); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(ptr, MAX_PATH - (ptr - _path), ref->_data.cFileName)); } } @@ -545,7 +531,6 @@ void file_iterator::next() directory_iterator::directory_iterator() { - BOOST_RE_GUARD_STACK _root = _path = 0; ref = 0; #ifndef BOOST_NO_EXCEPTIONS @@ -576,7 +561,6 @@ directory_iterator::directory_iterator() directory_iterator::directory_iterator(const char* wild) { - BOOST_RE_GUARD_STACK _root = _path = 0; ref = 0; #ifndef BOOST_NO_EXCEPTIONS @@ -586,34 +570,26 @@ directory_iterator::directory_iterator(const char* wild) BOOST_REGEX_NOEH_ASSERT(_root) _path = new char[MAX_PATH]; BOOST_REGEX_NOEH_ASSERT(_path) - std::strcpy(_root, wild); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_root, MAX_PATH, wild)); ptr = _root; while(*ptr)++ptr; while((ptr > _root) && (*ptr != *_fi_sep) && (*ptr != *_fi_sep_alt))--ptr; - #if 0 - *ptr = 0; - std::strcpy(_path, _root); - if(*_path == 0) - std::strcpy(_path, "."); - std::strcat(_path, _fi_sep); - ptr = _path + std::strlen(_path); - #else + if((ptr == _root) && ( (*ptr== *_fi_sep) || (*ptr==*_fi_sep_alt) ) ) { _root[1]='\0'; - std::strcpy(_path, _root); - ptr = _path + std::strlen(_path); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, _root)); } else { *ptr = 0; - std::strcpy(_path, _root); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, _root)); if(*_path == 0) - std::strcpy(_path, "."); - std::strcat(_path, _fi_sep); - ptr = _path + std::strlen(_path); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, ".")); + re_detail::overflow_error_if_not_zero(re_detail::strcat_s(_path, MAX_PATH, _fi_sep)); } - #endif + ptr = _path + std::strlen(_path); + ref = new file_iterator_ref(); BOOST_REGEX_NOEH_ASSERT(ref) ref->count = 1; @@ -625,7 +601,7 @@ directory_iterator::directory_iterator(const char* wild) } else { - std::strcpy(ptr, ref->_data.cFileName); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(ptr, MAX_PATH - (ptr - _path), ref->_data.cFileName)); if(((ref->_data.dwFileAttributes & _fi_dir) == 0) || (std::strcmp(ref->_data.cFileName, ".") == 0) || (std::strcmp(ref->_data.cFileName, "..") == 0)) next(); } @@ -643,7 +619,6 @@ directory_iterator::directory_iterator(const char* wild) directory_iterator::~directory_iterator() { - BOOST_RE_GUARD_STACK delete[] _root; delete[] _path; if(--(ref->count) == 0) @@ -656,7 +631,6 @@ directory_iterator::~directory_iterator() directory_iterator::directory_iterator(const directory_iterator& other) { - BOOST_RE_GUARD_STACK _root = _path = 0; ref = 0; #ifndef BOOST_NO_EXCEPTIONS @@ -666,8 +640,8 @@ directory_iterator::directory_iterator(const directory_iterator& other) BOOST_REGEX_NOEH_ASSERT(_root) _path = new char[MAX_PATH]; BOOST_REGEX_NOEH_ASSERT(_path) - std::strcpy(_root, other._root); - std::strcpy(_path, other._path); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_root, MAX_PATH, other._root)); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, other._path)); ptr = _path + (other.ptr - other._path); ref = other.ref; #ifndef BOOST_NO_EXCEPTIONS @@ -684,9 +658,8 @@ directory_iterator::directory_iterator(const directory_iterator& other) directory_iterator& directory_iterator::operator=(const directory_iterator& other) { - BOOST_RE_GUARD_STACK - std::strcpy(_root, other._root); - std::strcpy(_path, other._path); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_root, MAX_PATH, other._root)); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, other._path)); ptr = _path + (other.ptr - other._path); if(--(ref->count) == 0) { @@ -701,7 +674,6 @@ directory_iterator& directory_iterator::operator=(const directory_iterator& othe directory_iterator directory_iterator::operator++(int) { - BOOST_RE_GUARD_STACK directory_iterator temp(*this); next(); return temp; @@ -709,7 +681,6 @@ directory_iterator directory_iterator::operator++(int) void directory_iterator::next() { - BOOST_RE_GUARD_STACK if(ref->hf != _fi_invalid_handle) { bool cont = true; @@ -731,7 +702,7 @@ void directory_iterator::next() ptr = _path; } else - std::strcpy(ptr, ref->_data.cFileName); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(ptr, MAX_PATH - (ptr - _path), ref->_data.cFileName)); } } @@ -748,7 +719,6 @@ struct _fi_priv_data _fi_priv_data::_fi_priv_data(const char* p) { - BOOST_RE_GUARD_STACK std::strcpy(root, p); mask = root; while(*mask) ++mask; @@ -775,7 +745,6 @@ _fi_priv_data::_fi_priv_data(const char* p) bool iswild(const char* mask, const char* name) { - BOOST_RE_GUARD_STACK while(*mask && *name) { switch(*mask) @@ -817,12 +786,11 @@ bool iswild(const char* mask, const char* name) unsigned _fi_attributes(const char* root, const char* name) { - BOOST_RE_GUARD_STACK char buf[MAX_PATH]; if( ( (root[0] == *_fi_sep) || (root[0] == *_fi_sep_alt) ) && (root[1] == '\0') ) - std::sprintf(buf, "%s%s", root, name); + (std::sprintf)(buf, "%s%s", root, name); else - std::sprintf(buf, "%s%s%s", root, _fi_sep, name); + (std::sprintf)(buf, "%s%s%s", root, _fi_sep, name); DIR* d = opendir(buf); if(d) { @@ -834,7 +802,6 @@ unsigned _fi_attributes(const char* root, const char* name) _fi_find_handle _fi_FindFirstFile(const char* lpFileName, _fi_find_data* lpFindFileData) { - BOOST_RE_GUARD_STACK _fi_find_handle dat = new _fi_priv_data(lpFileName); DIR* h = opendir(dat->root); @@ -850,7 +817,6 @@ _fi_find_handle _fi_FindFirstFile(const char* lpFileName, _fi_find_data* lpFindF bool _fi_FindNextFile(_fi_find_handle dat, _fi_find_data* lpFindFileData) { - BOOST_RE_GUARD_STACK dirent* d; do { @@ -868,7 +834,6 @@ bool _fi_FindNextFile(_fi_find_handle dat, _fi_find_data* lpFindFileData) bool _fi_FindClose(_fi_find_handle dat) { - BOOST_RE_GUARD_STACK closedir(dat->d); delete dat; return true; diff --git a/boost/libs/regex/src/instances.cpp b/boost/libs/regex/src/instances.cpp index 6ff3e96d68..69d72ad6e1 100644 --- a/boost/libs/regex/src/instances.cpp +++ b/boost/libs/regex/src/instances.cpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -30,4 +30,3 @@ #include #endif - diff --git a/boost/libs/regex/src/posix_api.cpp b/boost/libs/regex/src/posix_api.cpp index 56ef8552e6..eb82f1b948 100644 --- a/boost/libs/regex/src/posix_api.cpp +++ b/boost/libs/regex/src/posix_api.cpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -19,8 +19,18 @@ #define BOOST_REGEX_SOURCE #include +#include #include +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::sprintf; + using ::strcpy; + using ::strcmp; +} +#endif + + namespace boost{ namespace{ @@ -35,7 +45,6 @@ const char* names[] = {"REG_NOERROR", "REG_NOMATCH", "REG_BADPAT", "REG_ECOLLATE BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char* ptr, int f) { - BOOST_RE_GUARD_STACK if(expression->re_magic != magic_value) { expression->guts = 0; @@ -54,7 +63,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char #endif } // set default flags: - boost::uint_fast32_t flags = (f & REG_EXTENDED) ? regex::extended : regex::basic; + boost::uint_fast32_t flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? regex::extended : regex::basic); expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : match_default; // and translate those that are actually set: @@ -67,20 +76,19 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char } if(f & REG_NOSUB) - expression->eflags |= match_any; + { + //expression->eflags |= match_any; + flags |= regex::nosubs; + } if(f & REG_NOSPEC) flags |= regex::literal; if(f & REG_ICASE) flags |= regex::icase; if(f & REG_ESCAPE_IN_LISTS) - flags |= regex::escape_in_lists; + flags &= ~regex::no_escape_in_lists; if(f & REG_NEWLINE_ALT) flags |= regex::newline_alt; -#ifndef BOOST_REGEX_V3 - if(f & REG_PERLEX) - flags |= regex::perlex; -#endif const char* p2; if(f & REG_PEND) @@ -97,7 +105,12 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char expression->re_nsub = static_cast(expression->guts)->mark_count() - 1; result = static_cast(expression->guts)->error_code(); #ifndef BOOST_NO_EXCEPTIONS - } catch(...) + } + catch(const boost::regex_error& be) + { + result = be.code(); + } + catch(...) { result = REG_E_UNKNOWN; } @@ -110,16 +123,15 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA* e, char* buf, regsize_t buf_size) { - BOOST_RE_GUARD_STACK std::size_t result = 0; if(code & REG_ITOA) { code &= ~REG_ITOA; - if(code <= REG_E_UNKNOWN) + if(code <= (int)REG_E_UNKNOWN) { result = std::strlen(names[code]) + 1; if(buf_size >= result) - std::strcpy(buf, names[code]); + re_detail::strcpy_s(buf, buf_size, names[code]); return result; } return result; @@ -129,35 +141,42 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA* char localbuf[5]; if(e == 0) return 0; - for(int i = 0; i <= REG_E_UNKNOWN; ++i) + for(int i = 0; i <= (int)REG_E_UNKNOWN; ++i) { if(std::strcmp(e->re_endp, names[i]) == 0) { - std::sprintf(localbuf, "%d", i); +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) + (::sprintf_s)(localbuf, 5, "%d", i); +#else + (std::sprintf)(localbuf, "%d", i); +#endif if(std::strlen(localbuf) < buf_size) - std::strcpy(buf, localbuf); + re_detail::strcpy_s(buf, buf_size, localbuf); return std::strlen(localbuf) + 1; } } - std::sprintf(localbuf, "%d", 0); +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) + (::sprintf_s)(localbuf, 5, "%d", 0); +#else + (std::sprintf)(localbuf, "%d", 0); +#endif if(std::strlen(localbuf) < buf_size) - std::strcpy(buf, localbuf); + re_detail::strcpy_s(buf, buf_size, localbuf); return std::strlen(localbuf) + 1; } - if(code <= REG_E_UNKNOWN) + if(code <= (int)REG_E_UNKNOWN) { std::string p; if((e) && (e->re_magic == magic_value)) - p = static_cast(e->guts)->get_traits().error_string(code); + p = static_cast(e->guts)->get_traits().error_string(static_cast< ::boost::regex_constants::error_type>(code)); else { - boost::regex_traits t; - p = t.error_string(code); + p = re_detail::get_default_error_string(static_cast< ::boost::regex_constants::error_type>(code)); } std::size_t len = p.size(); if(len < buf_size) { - std::strcpy(buf, p.c_str()); + re_detail::strcpy_s(buf, buf_size, p.c_str()); } return len + 1; } @@ -168,7 +187,10 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA* BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA* expression, const char* buf, regsize_t n, regmatch_t* array, int eflags) { - BOOST_RE_GUARD_STACK +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4267) +#endif bool result = false; match_flag_type flags = match_default | expression->eflags; const char* end; @@ -209,7 +231,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA* expression, cons if(result) { // extract what matched: - unsigned int i; + std::size_t i; for(i = 0; (i < n) && (i < expression->re_nsub + 1); ++i) { array[i].rm_so = (m[i].matched == false) ? -1 : (m[i].first - buf); @@ -224,11 +246,13 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA* expression, cons return 0; } return REG_NOMATCH; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif } BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeA(regex_tA* expression) { - BOOST_RE_GUARD_STACK if(expression->re_magic == magic_value) { delete static_cast(expression->guts); diff --git a/boost/libs/regex/src/regex.cpp b/boost/libs/regex/src/regex.cpp index 4b990f866c..741465329b 100644 --- a/boost/libs/regex/src/regex.cpp +++ b/boost/libs/regex/src/regex.cpp @@ -1,7 +1,7 @@ /* * - * Copyright (c) 1998-2002 - * Dr John Maddock + * Copyright (c) 1998-2004 + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -26,6 +26,13 @@ #if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && defined(_MSC_VER) && (_MSC_VER >= 1300) # include #endif +#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD +#define WIN32_LEAN_AND_MEAN +#define NOMINMAX +#define NOGDI +#define NOUSER +#include +#endif #if defined(BOOST_REGEX_NON_RECURSIVE) && !defined(BOOST_REGEX_V3) #if BOOST_REGEX_MAX_CACHE_BLOCKS == 0 @@ -43,18 +50,39 @@ namespace boost{ // that dll builds contain the Virtual table for these // types - this ensures that exceptions can be thrown // from the dll and caught in an exe. -bad_pattern::~bad_pattern() throw() {} -bad_expression::~bad_expression() throw() {} +regex_error::regex_error(const std::string& s, regex_constants::error_type err, std::ptrdiff_t pos) + : std::runtime_error(s) + , m_error_code(err) + , m_position(pos) +{ +} -regbase::regbase() - : _flags(regbase::failbit){} +regex_error::regex_error(regex_constants::error_type err) + : std::runtime_error(::boost::re_detail::get_default_error_string(err)) + , m_error_code(err) + , m_position(0) +{ +} + +regex_error::~regex_error() throw() +{ +} + +void regex_error::raise()const +{ +#ifndef BOOST_NO_EXCEPTIONS + ::boost::throw_exception(*this); +#endif +} -regbase::regbase(const regbase& b) - : _flags(b._flags){} namespace re_detail{ +BOOST_REGEX_DECL void BOOST_REGEX_CALL raise_runtime_error(const std::runtime_error& ex) +{ + ::boost::throw_exception(ex); +} // // error checking API: // @@ -74,6 +102,29 @@ BOOST_REGEX_DECL void BOOST_REGEX_CALL verify_options(boost::regex::flag_type /* #ifdef BOOST_REGEX_HAS_MS_STACK_GUARD +static void execute_eror() +{ + // we only get here after a stack overflow, + // this has to be a separate proceedure because we + // can't mix __try{}__except block with local objects + // that have destructors: + reset_stack_guard_page(); + std::runtime_error err("Out of stack space, while attempting to match a regular expression."); + raise_runtime_error(err); +} + +bool BOOST_REGEX_CALL abstract_protected_call::execute()const +{ + __try{ + return this->call(); + }__except(EXCEPTION_STACK_OVERFLOW == GetExceptionCode()) + { + execute_eror(); + } + // We never really get here at all: + return false; +} + BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page() { #if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && defined(_MSC_VER) && (_MSC_VER >= 1300) @@ -118,12 +169,6 @@ BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page() } #endif -BOOST_REGEX_DECL void BOOST_REGEX_CALL raise_regex_exception(const std::string& msg) -{ - bad_expression e(msg); - throw_exception(e); -} - #if defined(BOOST_REGEX_NON_RECURSIVE) && !defined(BOOST_REGEX_V3) #if BOOST_REGEX_MAX_CACHE_BLOCKS == 0 @@ -140,7 +185,11 @@ BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void* p) #else +#ifdef BOOST_HAS_THREADS +mem_block_cache block_cache = { 0, 0, BOOST_STATIC_MUTEX_INIT, }; +#else mem_block_cache block_cache = { 0, 0, }; +#endif BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block() { diff --git a/boost/libs/regex/src/regex_debug.cpp b/boost/libs/regex/src/regex_debug.cpp index 883d0a5f66..9306a82e7e 100644 --- a/boost/libs/regex/src/regex_debug.cpp +++ b/boost/libs/regex/src/regex_debug.cpp @@ -1,7 +1,7 @@ /* * - * Copyright (c) 1998-2002 - * Dr John Maddock + * Copyright (c) 1998-2004 + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -21,199 +21,6 @@ #include -#ifdef BOOST_REGEX_DEBUG - -#ifdef BOOST_MSVC -#include -#endif - -#ifdef BOOST_REGEX_V3 -#include -#else -#include -#endif -#include - -#ifndef BOOST_RE_OLD_IOSTREAM -#include -#else -#include -#endif - -namespace boost { namespace re_detail { -std::ostream& operator<<(std::ostream& s, syntax_element_type x) -{ - return s << static_cast(x); -} -}} // namespace boost::re_detail - - -namespace { - -char b1[32] = {0,}; -char guard_pattern[32] -= { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, }; -char b2[32] = {0,}; - -static const int guard_size = 32; - -bool check_pattern(void* p) -{ - return p ? memcmp(p, guard_pattern, guard_size) : 0; -} - -inline unsigned maxi(unsigned i, unsigned j) -{ - return i < j ? j : i; -} - -unsigned int allocated = 0; - -struct init -{ - init(); - ~init(); -}; - -init::init() -{ -#ifdef BOOST_MSVC - _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_DELAY_FREE_MEM_DF|_CRTDBG_LEAK_CHECK_DF); -#endif -} - -init::~init() -{ -} - - -init i; - -void* get_mem(size_t n) -{ - ++allocated; - char* p = (char*)malloc(n + guard_size * 2 + maxi(sizeof(int) + sizeof(void*), boost::re_detail::padding_size) + boost::re_detail::padding_size); - char* base = p; - p = (char*)((std::ptrdiff_t)(p + boost::re_detail::padding_mask) & ~boost::re_detail::padding_mask); - std::memcpy(p + maxi(sizeof(int) + sizeof(void*), boost::re_detail::padding_size), guard_pattern, guard_size); - std::memcpy(p + maxi(sizeof(int) + sizeof(void*), boost::re_detail::padding_size) + guard_size + n, guard_pattern, guard_size); - *(int*)p = n; - *(void**)(p + sizeof(int)) = base; - return p + guard_size + maxi(sizeof(int) + sizeof(void*), boost::re_detail::padding_size); -} - -void free_mem(void* b) -{ - if(b) - { - char* p = (char*)b; - p -= (guard_size + maxi(sizeof(int) + sizeof(void*), boost::re_detail::padding_size)); - if(check_pattern(p + maxi(sizeof(int) + sizeof(void*), boost::re_detail::padding_size)) || check_pattern(p + maxi(sizeof(int) + sizeof(void*), boost::re_detail::padding_size) + guard_size + *(int*)p)) - { - cerr << "Error: freed memory has been written past end..." << endl; - } - free(*(void**)(p + sizeof(int))); - --allocated; - } -} - -} // namespace - -void* operator new(size_t n) -{ - return get_mem(n); -} - -void* operator new[](size_t n) -{ - return get_mem(n); -} - -void operator delete(void* p) -{ - free_mem(p); -} - -void operator delete[](void* p) -{ - free_mem(p); -} - -#include - -namespace boost{ - namespace re_detail{ - -std::set >* patterns = 0; - -int pattern_count = 0; - -void check_patterns(const char* f, int l) -{ - if(pattern_count) - { - std::set >::iterator i, j; - i = patterns->begin(); - j = patterns->end(); - while(i != j) - { - if(check_pattern((void*)(*i)->g1) || check_pattern((*i)->g2) || check_pattern((void*)(*i)->pc) || check_pattern((*i)->pnc)) - { - cerr << "Error: static memory corruption at " << hex << *i << dec << " in " << (*i)->file << "@" << (*i)->line << " called from " << f << "@" << l << endl; - } - ++i; - } - } -} - -debug_guard::debug_guard(const char* f, int l, const char* p1, char* p2) -{ - if(++pattern_count == 1) - patterns = new std::set >; - file = f; - line = l; - std::memcpy(g1, guard_pattern, guard_size); - std::memcpy(g2, guard_pattern, guard_size); - if(p1) - { - pc = p1; - } - else - pc = 0; - if(p2) - { - pnc = p2; - std::memcpy(pnc, guard_pattern, guard_size); - } - else - pnc = 0; - patterns->insert(this); -} - -debug_guard::~debug_guard() -{ - check_patterns(file, line); - if(check_pattern(g1) || check_pattern(g2)) - { - cerr << "Error: memory corruption " << file << "@" << line << endl; - } - patterns->erase(this); - if(--pattern_count == 0) - { - delete patterns; - patterns = 0; - } -} - - } // namespace re_detail - -} // namespace boost - - - -#endif - // // regex configuration information: this prints out the settings used diff --git a/boost/libs/regex/src/regex_raw_buffer.cpp b/boost/libs/regex/src/regex_raw_buffer.cpp new file mode 100644 index 0000000000..7a8de8033d --- /dev/null +++ b/boost/libs/regex/src/regex_raw_buffer.cpp @@ -0,0 +1,70 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_raw_buffer.cpp + * VERSION see + * DESCRIPTION: Member functions for class raw_storage. + */ + + +#define BOOST_REGEX_SOURCE +#include +#include +#include +#include + +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::memcpy; + using ::memmove; +} +#endif + + +namespace boost{ namespace re_detail{ + +void BOOST_REGEX_CALL raw_storage::resize(size_type n) +{ + register size_type newsize = start ? last - start : 1024; + while(newsize < n) + newsize *= 2; + register size_type datasize = end - start; + // extend newsize to WORD/DWORD boundary: + newsize = (newsize + padding_mask) & ~(padding_mask); + + // allocate and copy data: + register pointer ptr = static_cast(::operator new(newsize)); + BOOST_REGEX_NOEH_ASSERT(ptr) + std::memcpy(ptr, start, datasize); + + // get rid of old buffer: + ::operator delete(start); + + // and set up pointers: + start = ptr; + end = ptr + datasize; + last = ptr + newsize; +} + +void* BOOST_REGEX_CALL raw_storage::insert(size_type pos, size_type n) +{ + BOOST_ASSERT(pos <= size_type(end - start)); + if(size_type(last - end) < n) + resize(n + (end - start)); + register void* result = start + pos; + std::memmove(start + pos + n, start + pos, (end - start) - pos); + end += n; + return result; +} + +}} // namespaces diff --git a/boost/libs/regex/src/regex_synch.cpp b/boost/libs/regex/src/regex_synch.cpp deleted file mode 100644 index cf7d7d555e..0000000000 --- a/boost/libs/regex/src/regex_synch.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * Dr John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - - /* - * LOCATION: see http://www.boost.org for most recent version. - * FILE: regex_synch.cpp - * VERSION: see - * DESCRIPTION: Thread synch helper functions, for regular - * expression library. - */ - - -#define BOOST_REGEX_SOURCE - -#include -#ifdef BOOST_REGEX_V3 -#include -#else -#include -#endif - -namespace boost{ - namespace re_detail{ - -void BOOST_REGEX_CALL re_init_threads() -{ - BOOST_RE_GUARD_STACK -#ifdef BOOST_HAS_THREADS - if(p_re_lock == 0) - p_re_lock = new critical_section(); - cs_guard g(*p_re_lock); - ++re_lock_count; -#endif -} - -void BOOST_REGEX_CALL re_free_threads() -{ - BOOST_RE_GUARD_STACK -#ifdef BOOST_HAS_THREADS - cs_guard g(*p_re_lock); - --re_lock_count; - if(re_lock_count == 0) - { - g.acquire(false); - delete p_re_lock; - p_re_lock = 0; - } -#endif -} - -#ifdef BOOST_HAS_THREADS - -BOOST_REGEX_DECL critical_section* p_re_lock = 0; - -BOOST_REGEX_DECL unsigned int re_lock_count = 0; - -#endif - - } // namespace re_detail -} // namespace boost - - - - - - diff --git a/boost/libs/regex/src/regex_traits_defaults.cpp b/boost/libs/regex/src/regex_traits_defaults.cpp new file mode 100644 index 0000000000..8f5a980c72 --- /dev/null +++ b/boost/libs/regex/src/regex_traits_defaults.cpp @@ -0,0 +1,688 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_traits_defaults.cpp + * VERSION see + * DESCRIPTION: Declares API's for access to regex_traits default properties. + */ + +#define BOOST_REGEX_SOURCE +#include + +#include +#ifndef BOOST_NO_WREGEX +#include +#endif + +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::tolower; + using ::toupper; +#ifndef BOOST_NO_WREGEX + using ::towlower; + using ::towupper; +#endif +} +#endif + + +namespace boost{ namespace re_detail{ + +BOOST_REGEX_DECL const char* BOOST_REGEX_CALL get_default_syntax(regex_constants::syntax_type n) +{ + // if the user hasn't supplied a message catalog, then this supplies + // default "messages" for us to load in the range 1-100. + const char* messages[] = { + "", + "(", + ")", + "$", + "^", + ".", + "*", + "+", + "?", + "[", + "]", + "|", + "\\", + "#", + "-", + "{", + "}", + "0123456789", + "b", + "B", + "<", + ">", + "", + "", + "A`", + "z'", + "\n", + ",", + "a", + "f", + "n", + "r", + "t", + "v", + "x", + "c", + ":", + "=", + "e", + "", + "", + "", + "", + "", + "", + "", + "", + "E", + "Q", + "X", + "C", + "Z", + "G", + "!", + "p", + "P", + "N", + }; + + return ((n >= (sizeof(messages) / sizeof(messages[1]))) ? "" : messages[n]); +} + +BOOST_REGEX_DECL const char* BOOST_REGEX_CALL get_default_error_string(regex_constants::error_type n) +{ + static const char* const s_default_error_messages[] = { + "Success", /* REG_NOERROR */ + "No match", /* REG_NOMATCH */ + "Invalid regular expression", /* REG_BADPAT */ + "Invalid collation character", /* REG_ECOLLATE */ + "Invalid character class name", /* REG_ECTYPE */ + "Invalid or trailing backslash", /* REG_EESCAPE */ + "Invalid back reference", /* REG_ESUBREG */ + "Unmatched [ or [^", /* REG_EBRACK */ + "Unmatched ( or \\(", /* REG_EPAREN */ + "Unmatched { or \\{", /* REG_EBRACE */ + "Invalid content of repeat range", /* REG_BADBR */ + "Invalid range end", /* REG_ERANGE */ + "Memory exhausted", /* REG_ESPACE */ + "Invalid preceding regular expression", /* REG_BADRPT */ + "Premature end of regular expression", /* REG_EEND */ + "Regular expression too big", /* REG_ESIZE */ + "Unmatched ) or \\)", /* REG_ERPAREN */ + "Empty expression", /* REG_EMPTY */ + "Complexity requirements exceeded", /* REG_ECOMPLEXITY */ + "Out of stack space", /* REG_ESTACK */ + "Unknown error", /* REG_E_UNKNOWN */ + "", + "", + "", + }; + + return (n > ::boost::regex_constants::error_unknown) ? s_default_error_messages[ ::boost::regex_constants::error_unknown] : s_default_error_messages[n]; +} + +BOOST_REGEX_DECL bool BOOST_REGEX_CALL is_combining_implementation(boost::uint_least16_t c) +{ + const boost::uint_least16_t combining_ranges[] = { 0x0300, 0x0361, + 0x0483, 0x0486, + 0x0903, 0x0903, + 0x093E, 0x0940, + 0x0949, 0x094C, + 0x0982, 0x0983, + 0x09BE, 0x09C0, + 0x09C7, 0x09CC, + 0x09D7, 0x09D7, + 0x0A3E, 0x0A40, + 0x0A83, 0x0A83, + 0x0ABE, 0x0AC0, + 0x0AC9, 0x0ACC, + 0x0B02, 0x0B03, + 0x0B3E, 0x0B3E, + 0x0B40, 0x0B40, + 0x0B47, 0x0B4C, + 0x0B57, 0x0B57, + 0x0B83, 0x0B83, + 0x0BBE, 0x0BBF, + 0x0BC1, 0x0BCC, + 0x0BD7, 0x0BD7, + 0x0C01, 0x0C03, + 0x0C41, 0x0C44, + 0x0C82, 0x0C83, + 0x0CBE, 0x0CBE, + 0x0CC0, 0x0CC4, + 0x0CC7, 0x0CCB, + 0x0CD5, 0x0CD6, + 0x0D02, 0x0D03, + 0x0D3E, 0x0D40, + 0x0D46, 0x0D4C, + 0x0D57, 0x0D57, + 0x0F7F, 0x0F7F, + 0x20D0, 0x20E1, + 0x3099, 0x309A, + 0xFE20, 0xFE23, + 0xffff, 0xffff, }; + + const boost::uint_least16_t* p = combining_ranges + 1; + while(*p < c) p += 2; + --p; + if((c >= *p) && (c <= *(p+1))) + return true; + return false; +} + +// +// these are the POSIX collating names: +// +BOOST_REGEX_DECL const char* def_coll_names[] = { +"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "alert", "backspace", "tab", "newline", +"vertical-tab", "form-feed", "carriage-return", "SO", "SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", +"SYN", "ETB", "CAN", "EM", "SUB", "ESC", "IS4", "IS3", "IS2", "IS1", "space", "exclamation-mark", +"quotation-mark", "number-sign", "dollar-sign", "percent-sign", "ampersand", "apostrophe", +"left-parenthesis", "right-parenthesis", "asterisk", "plus-sign", "comma", "hyphen", +"period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", +"colon", "semicolon", "less-than-sign", "equals-sign", "greater-than-sign", +"question-mark", "commercial-at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", +"Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "left-square-bracket", "backslash", +"right-square-bracket", "circumflex", "underscore", "grave-accent", "a", "b", "c", "d", "e", "f", +"g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "left-curly-bracket", +"vertical-line", "right-curly-bracket", "tilde", "DEL", "", +}; + +// these multi-character collating elements +// should keep most Western-European locales +// happy - we should really localise these a +// little more - but this will have to do for +// now: + +BOOST_REGEX_DECL const char* def_multi_coll[] = { + "ae", + "Ae", + "AE", + "ch", + "Ch", + "CH", + "ll", + "Ll", + "LL", + "ss", + "Ss", + "SS", + "nj", + "Nj", + "NJ", + "dz", + "Dz", + "DZ", + "lj", + "Lj", + "LJ", + "", +}; + + + +BOOST_REGEX_DECL std::string BOOST_REGEX_CALL lookup_default_collate_name(const std::string& name) +{ + unsigned int i = 0; + while(*def_coll_names[i]) + { + if(def_coll_names[i] == name) + { + return std::string(1, char(i)); + } + ++i; + } + i = 0; + while(*def_multi_coll[i]) + { + if(def_multi_coll[i] == name) + { + return def_multi_coll[i]; + } + ++i; + } + return std::string(); +} + +BOOST_REGEX_DECL char BOOST_REGEX_CALL do_global_lower(char c) +{ + return static_cast((std::tolower)((unsigned char)c)); +} + +BOOST_REGEX_DECL char BOOST_REGEX_CALL do_global_upper(char c) +{ + return static_cast((std::toupper)((unsigned char)c)); +} +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL do_global_lower(wchar_t c) +{ + return (std::towlower)(c); +} + +BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL do_global_upper(wchar_t c) +{ + return (std::towupper)(c); +} +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL do_global_lower(unsigned short c) +{ + return (std::towlower)(c); +} + +BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL do_global_upper(unsigned short c) +{ + return (std::towupper)(c); +} +#endif + +#endif + +BOOST_REGEX_DECL regex_constants::escape_syntax_type BOOST_REGEX_CALL get_default_escape_syntax_type(char c) +{ + // + // char_syntax determines how the compiler treats a given character + // in a regular expression. + // + static regex_constants::escape_syntax_type char_syntax[] = { + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /* */ // 32 + regex_constants::escape_type_identity, /*!*/ + regex_constants::escape_type_identity, /*"*/ + regex_constants::escape_type_identity, /*#*/ + regex_constants::escape_type_identity, /*$*/ + regex_constants::escape_type_identity, /*%*/ + regex_constants::escape_type_identity, /*&*/ + regex_constants::escape_type_end_buffer, /*'*/ + regex_constants::syntax_open_mark, /*(*/ + regex_constants::syntax_close_mark, /*)*/ + regex_constants::escape_type_identity, /***/ + regex_constants::syntax_plus, /*+*/ + regex_constants::escape_type_identity, /*,*/ + regex_constants::escape_type_identity, /*-*/ + regex_constants::escape_type_identity, /*.*/ + regex_constants::escape_type_identity, /*/*/ + regex_constants::escape_type_decimal, /*0*/ + regex_constants::escape_type_backref, /*1*/ + regex_constants::escape_type_backref, /*2*/ + regex_constants::escape_type_backref, /*3*/ + regex_constants::escape_type_backref, /*4*/ + regex_constants::escape_type_backref, /*5*/ + regex_constants::escape_type_backref, /*6*/ + regex_constants::escape_type_backref, /*7*/ + regex_constants::escape_type_backref, /*8*/ + regex_constants::escape_type_backref, /*9*/ + regex_constants::escape_type_identity, /*:*/ + regex_constants::escape_type_identity, /*;*/ + regex_constants::escape_type_left_word, /*<*/ + regex_constants::escape_type_identity, /*=*/ + regex_constants::escape_type_right_word, /*>*/ + regex_constants::syntax_question, /*?*/ + regex_constants::escape_type_identity, /*@*/ + regex_constants::escape_type_start_buffer, /*A*/ + regex_constants::escape_type_not_word_assert, /*B*/ + regex_constants::escape_type_C, /*C*/ + regex_constants::escape_type_not_class, /*D*/ + regex_constants::escape_type_E, /*E*/ + regex_constants::escape_type_not_class, /*F*/ + regex_constants::escape_type_G, /*G*/ + regex_constants::escape_type_not_class, /*H*/ + regex_constants::escape_type_not_class, /*I*/ + regex_constants::escape_type_not_class, /*J*/ + regex_constants::escape_type_not_class, /*K*/ + regex_constants::escape_type_not_class, /*L*/ + regex_constants::escape_type_not_class, /*M*/ + regex_constants::escape_type_named_char, /*N*/ + regex_constants::escape_type_not_class, /*O*/ + regex_constants::escape_type_not_property, /*P*/ + regex_constants::escape_type_Q, /*Q*/ + regex_constants::escape_type_not_class, /*R*/ + regex_constants::escape_type_not_class, /*S*/ + regex_constants::escape_type_not_class, /*T*/ + regex_constants::escape_type_not_class, /*U*/ + regex_constants::escape_type_not_class, /*V*/ + regex_constants::escape_type_not_class, /*W*/ + regex_constants::escape_type_X, /*X*/ + regex_constants::escape_type_not_class, /*Y*/ + regex_constants::escape_type_Z, /*Z*/ + regex_constants::escape_type_identity, /*[*/ + regex_constants::escape_type_identity, /*\*/ + regex_constants::escape_type_identity, /*]*/ + regex_constants::escape_type_identity, /*^*/ + regex_constants::escape_type_identity, /*_*/ + regex_constants::escape_type_start_buffer, /*`*/ + regex_constants::escape_type_control_a, /*a*/ + regex_constants::escape_type_word_assert, /*b*/ + regex_constants::escape_type_ascii_control, /*c*/ + regex_constants::escape_type_class, /*d*/ + regex_constants::escape_type_e, /*e*/ + regex_constants::escape_type_control_f, /*f*/ + regex_constants::escape_type_class, /*g*/ + regex_constants::escape_type_class, /*h*/ + regex_constants::escape_type_class, /*i*/ + regex_constants::escape_type_class, /*j*/ + regex_constants::escape_type_class, /*k*/ + regex_constants::escape_type_class, /*l*/ + regex_constants::escape_type_class, /*m*/ + regex_constants::escape_type_control_n, /*n*/ + regex_constants::escape_type_class, /*o*/ + regex_constants::escape_type_property, /*p*/ + regex_constants::escape_type_class, /*q*/ + regex_constants::escape_type_control_r, /*r*/ + regex_constants::escape_type_class, /*s*/ + regex_constants::escape_type_control_t, /*t*/ + regex_constants::escape_type_class, /*u*/ + regex_constants::escape_type_control_v, /*v*/ + regex_constants::escape_type_class, /*w*/ + regex_constants::escape_type_hex, /*x*/ + regex_constants::escape_type_class, /*y*/ + regex_constants::escape_type_end_buffer, /*z*/ + regex_constants::syntax_open_brace, /*{*/ + regex_constants::syntax_or, /*|*/ + regex_constants::syntax_close_brace, /*}*/ + regex_constants::escape_type_identity, /*~*/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + }; + + return char_syntax[(unsigned char)c]; +} + +BOOST_REGEX_DECL regex_constants::syntax_type BOOST_REGEX_CALL get_default_syntax_type(char c) +{ + // + // char_syntax determines how the compiler treats a given character + // in a regular expression. + // + static regex_constants::syntax_type char_syntax[] = { + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_newline, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /* */ // 32 + regex_constants::syntax_not, /*!*/ + regex_constants::syntax_char, /*"*/ + regex_constants::syntax_hash, /*#*/ + regex_constants::syntax_dollar, /*$*/ + regex_constants::syntax_char, /*%*/ + regex_constants::syntax_char, /*&*/ + regex_constants::syntax_char, /*'*/ + regex_constants::syntax_open_mark, /*(*/ + regex_constants::syntax_close_mark, /*)*/ + regex_constants::syntax_star, /***/ + regex_constants::syntax_plus, /*+*/ + regex_constants::syntax_comma, /*,*/ + regex_constants::syntax_dash, /*-*/ + regex_constants::syntax_dot, /*.*/ + regex_constants::syntax_char, /*/*/ + regex_constants::syntax_digit, /*0*/ + regex_constants::syntax_digit, /*1*/ + regex_constants::syntax_digit, /*2*/ + regex_constants::syntax_digit, /*3*/ + regex_constants::syntax_digit, /*4*/ + regex_constants::syntax_digit, /*5*/ + regex_constants::syntax_digit, /*6*/ + regex_constants::syntax_digit, /*7*/ + regex_constants::syntax_digit, /*8*/ + regex_constants::syntax_digit, /*9*/ + regex_constants::syntax_colon, /*:*/ + regex_constants::syntax_char, /*;*/ + regex_constants::escape_type_left_word, /*<*/ + regex_constants::syntax_equal, /*=*/ + regex_constants::escape_type_right_word, /*>*/ + regex_constants::syntax_question, /*?*/ + regex_constants::syntax_char, /*@*/ + regex_constants::syntax_char, /*A*/ + regex_constants::syntax_char, /*B*/ + regex_constants::syntax_char, /*C*/ + regex_constants::syntax_char, /*D*/ + regex_constants::syntax_char, /*E*/ + regex_constants::syntax_char, /*F*/ + regex_constants::syntax_char, /*G*/ + regex_constants::syntax_char, /*H*/ + regex_constants::syntax_char, /*I*/ + regex_constants::syntax_char, /*J*/ + regex_constants::syntax_char, /*K*/ + regex_constants::syntax_char, /*L*/ + regex_constants::syntax_char, /*M*/ + regex_constants::syntax_char, /*N*/ + regex_constants::syntax_char, /*O*/ + regex_constants::syntax_char, /*P*/ + regex_constants::syntax_char, /*Q*/ + regex_constants::syntax_char, /*R*/ + regex_constants::syntax_char, /*S*/ + regex_constants::syntax_char, /*T*/ + regex_constants::syntax_char, /*U*/ + regex_constants::syntax_char, /*V*/ + regex_constants::syntax_char, /*W*/ + regex_constants::syntax_char, /*X*/ + regex_constants::syntax_char, /*Y*/ + regex_constants::syntax_char, /*Z*/ + regex_constants::syntax_open_set, /*[*/ + regex_constants::syntax_escape, /*\*/ + regex_constants::syntax_close_set, /*]*/ + regex_constants::syntax_caret, /*^*/ + regex_constants::syntax_char, /*_*/ + regex_constants::syntax_char, /*`*/ + regex_constants::syntax_char, /*a*/ + regex_constants::syntax_char, /*b*/ + regex_constants::syntax_char, /*c*/ + regex_constants::syntax_char, /*d*/ + regex_constants::syntax_char, /*e*/ + regex_constants::syntax_char, /*f*/ + regex_constants::syntax_char, /*g*/ + regex_constants::syntax_char, /*h*/ + regex_constants::syntax_char, /*i*/ + regex_constants::syntax_char, /*j*/ + regex_constants::syntax_char, /*k*/ + regex_constants::syntax_char, /*l*/ + regex_constants::syntax_char, /*m*/ + regex_constants::syntax_char, /*n*/ + regex_constants::syntax_char, /*o*/ + regex_constants::syntax_char, /*p*/ + regex_constants::syntax_char, /*q*/ + regex_constants::syntax_char, /*r*/ + regex_constants::syntax_char, /*s*/ + regex_constants::syntax_char, /*t*/ + regex_constants::syntax_char, /*u*/ + regex_constants::syntax_char, /*v*/ + regex_constants::syntax_char, /*w*/ + regex_constants::syntax_char, /*x*/ + regex_constants::syntax_char, /*y*/ + regex_constants::syntax_char, /*z*/ + regex_constants::syntax_open_brace, /*{*/ + regex_constants::syntax_or, /*|*/ + regex_constants::syntax_close_brace, /*}*/ + regex_constants::syntax_char, /*~*/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + }; + + return char_syntax[(unsigned char)c]; +} + + +} // re_detail +} // boost diff --git a/boost/libs/regex/src/w32_regex_traits.cpp b/boost/libs/regex/src/w32_regex_traits.cpp index b65c9866f7..20e84d150f 100644 --- a/boost/libs/regex/src/w32_regex_traits.cpp +++ b/boost/libs/regex/src/w32_regex_traits.cpp @@ -1,7 +1,7 @@ /* * - * Copyright (c) 1998-2002 - * Dr John Maddock + * Copyright (c) 2004 + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -11,1094 +11,458 @@ /* * LOCATION: see http://www.boost.org for most recent version. - * FILE: w32_regex_traits.cpp - * VERSION: see - * DESCRIPTION: Implements the w32_regex_traits traits class + * FILE w32_regex_traits.cpp + * VERSION see + * DESCRIPTION: Implements w32_regex_traits (and associated helper classes). */ #define BOOST_REGEX_SOURCE +#include -#include -#include -#include -#include -#include -#include #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) -#include -#ifdef BOOST_REGEX_V3 -#include -#include -#else -#include -#include -#endif -#include +#include +#include +#define WIN32_LEAN_AND_MEAN +#define NOMINMAX +#define NOGDI +#include -// -// VC6 needs to link to user32.lib, as do all compilers that -// claim to be VC6/7 compatible: -// -#if defined(_MSC_VER) && !defined(__BORLANDC__) +#ifdef _MSC_VER #pragma comment(lib, "user32.lib") #endif -namespace{ - -// -// character classes: - -boost::uint_fast32_t re_char_class_id[] = { - boost::re_detail::w32_traits_base::char_class_alnum, - boost::re_detail::w32_traits_base::char_class_alpha, - boost::re_detail::w32_traits_base::char_class_cntrl, - boost::re_detail::w32_traits_base::char_class_digit, - boost::re_detail::w32_traits_base::char_class_graph, - boost::re_detail::w32_traits_base::char_class_lower, - boost::re_detail::w32_traits_base::char_class_print, - boost::re_detail::w32_traits_base::char_class_punct, - boost::re_detail::w32_traits_base::char_class_space, - boost::re_detail::w32_traits_base::char_class_upper, - boost::re_detail::w32_traits_base::char_class_xdigit, - boost::re_detail::w32_traits_base::char_class_blank, - boost::re_detail::w32_traits_base::char_class_word, - boost::re_detail::w32_traits_base::char_class_unicode, -}; - -const char* re_char_class_names[] = { -"alnum", -"alpha", -"cntrl", -"digit", -"graph", -"lower", -"print", -"punct", -"space", -"upper", -"xdigit", -"blank", -"word", -"unicode", -}; - -std::string* pclasses = 0; -const unsigned int re_classes_max = 14; - -// -// collate names: - -struct collate_name_t -{ - std::string name; - std::string value; - collate_name_t(){} - collate_name_t(const char* p1, const char* p2, const char* p3, const char* p4) - : name(p1, p2), value(p3, p4) {} -}; - -std::list* pcoll_names = 0; - -// -// message handling: -#ifndef BOOST_RE_MESSAGE_BASE -#define BOOST_RE_MESSAGE_BASE 0 +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std{ + using ::memset; +} #endif -HINSTANCE hresmod = 0; +namespace boost{ namespace re_detail{ -char* re_custom_error_messages[] = { - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, -}; - -char re_zero; -char re_ten; - -unsigned int entry_count = 0; -bool is_init = false; - -enum syntax_map_size +void w32_regex_traits_char_layer::init() { - map_size = UCHAR_MAX + 1 -}; - -#ifndef BOOST_NO_WREGEX - -boost::regex_wchar_type re_zero_w; -boost::regex_wchar_type re_ten_w; - -bool isPlatformNT = false; - -struct syntax_map_t -{ - boost::regex_wchar_type c; - unsigned int type; -}; - -std::list* syntax; - -#endif - -std::size_t BOOST_REGEX_CALL _re_get_message(char* buf, std::size_t len, unsigned id); - -std::size_t BOOST_REGEX_CALL get_message(boost::regex_wchar_type* buf, std::size_t len, unsigned id) -{ - std::size_t size = _re_get_message(static_cast(0), 0, id); - if(len < size) - return size; - boost::scoped_array cb(new char[size]); - _re_get_message(cb.get(), size, id); - size = boost::w32_regex_traits::strwiden(buf, len, cb.get()); - return size; -} - -inline std::size_t BOOST_REGEX_CALL get_message(char* buf, std::size_t len, unsigned id) -{ - return _re_get_message(buf, len, id); -} - -std::size_t BOOST_REGEX_CALL _re_get_message(char* buf, std::size_t len, unsigned id) -{ - BOOST_RE_GUARD_STACK - // get the customised message if any: - if(len < 255) - return 255; - std::size_t size = 0; - if(hresmod) - size = LoadStringA(hresmod, BOOST_RE_MESSAGE_BASE + id, buf, 255); - if(size) - return size; - + // we need to start by initialising our syntax map so we know which + // character is used for which purpose: + std::memset(m_char_map, 0, sizeof(m_char_map)); + cat_type cat; + std::string cat_name(w32_regex_traits::get_catalog_name()); + if(cat_name.size()) + { + cat = ::boost::re_detail::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); + } + } // - // now get the default message if any: - return boost::re_detail::re_get_default_message(buf, len, id); -} - -const char* BOOST_REGEX_CALL re_get_error_str(unsigned int id) -{ - BOOST_RE_GUARD_STACK -#ifdef BOOST_HAS_THREADS - boost::re_detail::cs_guard g(*boost::re_detail::p_re_lock); -#endif - if(re_custom_error_messages[id] == 0) + // if we have a valid catalog then load our messages: + // + if(cat) { - char buf[256]; - _re_get_message(buf, 256, id + 200); - if(*buf) + for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i) { - re_custom_error_messages[id] = boost::re_detail::re_strdup(buf); - return re_custom_error_messages[id]; - } - return boost::re_detail::re_default_error_messages[id]; - } - return re_custom_error_messages[id]; -} - -} // namespace - -namespace boost{ - -namespace re_detail{ - -char w32_traits_base::regex_message_catalogue[BOOST_REGEX_MAX_PATH] = {0}; - -void BOOST_REGEX_CALL w32_traits_base::do_init() -{ - BOOST_RE_GUARD_STACK - if(is_init == 0) - { - // - // update the messages first: - is_init = true; - if(*regex_message_catalogue) - { - hresmod = LoadLibraryA(regex_message_catalogue); - if(hresmod == NULL) + string_type mss = ::boost::re_detail::w32_cat_get(cat, this->m_locale, i, get_default_syntax(i)); + for(string_type::size_type j = 0; j < mss.size(); ++j) { - std::string s("Unable to open dll: "); - std::runtime_error err(s + regex_message_catalogue); - boost::throw_exception(err); + m_char_map[static_cast(mss[j])] = i; } } - unsigned int i; - for(i = 0; i < REG_E_UNKNOWN; ++i) - { - if(re_custom_error_messages[i]) - { - re_detail::re_strfree(re_custom_error_messages[i]); - re_custom_error_messages[i] = 0; - } - } -#ifndef BOOST_NO_WREGEX - // - // wide character strings: - syntax = new std::list(); - OSVERSIONINFO VersionInformation = {0}; - VersionInformation.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&VersionInformation); - if(VersionInformation.dwPlatformId == VER_PLATFORM_WIN32_NT) - isPlatformNT = true; -#endif - // - // now the character classes: - pclasses = new std::string[re_classes_max]; - char buf[map_size+2]; - for(i = 0; i < re_classes_max; ++i) - { - get_message(buf, 256, i+300); - pclasses[i] = buf; - } - // start by updating the syntax map: - std::memset(syntax_map, syntax_char, map_size); - for(i = 1; i < syntax_max; ++i) - { - char* ptr = buf; - get_message(buf, map_size, i+100); - for(; *ptr; ++ptr) - { - syntax_map[(unsigned char)*ptr] = (unsigned char)i; - } - } - - // now update the character class map, - // and lower case map: - for(i = 0; i < map_size; ++i) - { - buf[i] = (char)i; - } - buf[map_size] = (char)0; - GetStringTypeA(GetUserDefaultLCID(), CT_CTYPE1, buf, map_size, class_map); - for(i = 0; i < map_size; ++i) - { - class_map[i] &= char_class_win; - } - class_map[(unsigned char)'_'] |= char_class_underscore; - LCMapStringA(GetUserDefaultLCID(), LCMAP_LOWERCASE, buf, map_size, lower_case_map, map_size); - // - // update our collating elements: - pcoll_names = new std::list(); - i = 400; - get_message(buf, 256, i); - while(*buf) - { - char* p1, *p2, *p3, *p4;; - p1 = buf; - while(*p1 && isspace(*p1))++p1; - p2 = p1; - while(*p2 && !isspace(*p2))++p2; - p3 = p2; - while(*p3 && isspace(*p3))++p3; - p4 = p3; - while(*p4 && !isspace(*p4))++p4; - pcoll_names->push_back(collate_name_t(p1, p2, p3, p4)); - ++i; - get_message(buf, 256, i); - } - std::string s; - const char* p = "zero"; - if(w32_regex_traits::lookup_collatename(s, p, p+4)) - { - jm_assert(s.size() == 1); - re_zero = *s.c_str(); - } - else - re_zero = '0'; - - p = "ten"; - if(w32_regex_traits::lookup_collatename(s, p, p+3)) - { - jm_assert(s.size() == 1); - re_ten = *s.c_str(); - } - else - re_ten = 'a'; -#ifndef BOOST_NO_WREGEX - // - // wide string data: - std::basic_string ws; - const regex_wchar_type* wp = (const regex_wchar_type*)L"zero"; - if(w32_regex_traits::lookup_collatename(ws, wp, wp+4)) - { - jm_assert(ws.size() == 1); - re_zero_w = *ws.c_str(); - } - else - re_zero_w = (regex_wchar_type)L'0'; - - wp = (const regex_wchar_type*)L"ten"; - if(w32_regex_traits::lookup_collatename(ws, wp, wp+3)) - { - jm_assert(ws.size() == 1); - re_ten_w = *ws.c_str(); - } - else - re_ten_w = L'a'; - - regex_wchar_type wbuf[256]; - syntax_map_t sm; - syntax->clear(); - for(i = 1; i < syntax_max; ++i) - { - regex_wchar_type* ptr = wbuf; - get_message(wbuf, 256, i+100); - for(; *ptr; ++ptr) - { - sm.c = *ptr; - sm.type = i; - syntax->push_back(sm); - } - } -#endif // BOOST_NO_WREGEX - } -} - -void BOOST_REGEX_CALL w32_traits_base::do_free() -{ - BOOST_RE_GUARD_STACK - delete[] pclasses; - pclasses = 0; - delete pcoll_names; - pcoll_names = 0; -#ifndef BOOST_NO_WREGEX - delete syntax; - syntax = 0; -#endif - if(hresmod) - { - FreeLibrary(hresmod); - hresmod = 0; - } - for(int i = 0; i < REG_E_UNKNOWN; ++i) - { - if(re_custom_error_messages[i]) - { - re_detail::re_strfree(re_custom_error_messages[i]); - re_custom_error_messages[i] = 0; - } - } - is_init = false; -} - -std::string BOOST_REGEX_CALL w32_traits_base::error_string(unsigned id) -{ - return re_get_error_str(id); -} - -boost::uint_fast32_t BOOST_REGEX_CALL w32_traits_base::do_lookup_class(const char* p) -{ - BOOST_RE_GUARD_STACK - unsigned int i; - for(i = 0; i < re_classes_max; ++i) - { - if(pclasses[i] == p) - { - return re_char_class_id[i]; - } - } - for(i = 0; i < re_classes_max; ++i) - { - if(std::strcmp(re_char_class_names[i], p) == 0) - { - return re_char_class_id[i]; - } - } - return 0; -} - -bool BOOST_REGEX_CALL w32_traits_base::do_lookup_collate(std::string& buf, const char* p) -{ - BOOST_RE_GUARD_STACK - std::list::iterator first, last; - first = pcoll_names->begin(); - last = pcoll_names->end(); - while(first != last) - { - if((*first).name == p) - { - buf = (*first).value; - return true; - } - ++first; - } - - bool result = re_detail::re_lookup_def_collate_name(buf, p); - if((result == 0) && (std::strlen(p) == 1)) - { - result = true; - buf = *p; - } - return result; -} - -std::string BOOST_REGEX_CALL w32_traits_base::set_message_catalogue(const std::string& l) -{ - BOOST_RE_GUARD_STACK - #ifdef BOOST_HAS_THREADS - re_detail::cs_guard g(*re_detail::p_re_lock); - #endif - if(sizeof(regex_message_catalogue) <= l.size()) - return l; - std::string old(regex_message_catalogue); - std::strcpy(regex_message_catalogue, l.c_str()); - return old; -} - -unsigned char w32_traits_base::syntax_map[map_size]; -unsigned short w32_traits_base::class_map[map_size]; -char w32_traits_base::lower_case_map[map_size]; - -} // namespace re_detail - -w32_regex_traits w32_regex_traits::i; - -void BOOST_REGEX_CALL w32_regex_traits::update() -{ - BOOST_RE_GUARD_STACK - #ifdef BOOST_HAS_THREADS - re_detail::cs_guard g(*re_detail::p_re_lock); - #endif - do_init(); -} - -w32_regex_traits::w32_regex_traits() -{ - BOOST_RE_GUARD_STACK - #ifdef BOOST_HAS_THREADS - re_detail::re_init_threads(); - re_detail::cs_guard g(*re_detail::p_re_lock); - #endif - ++entry_count; -} - -w32_regex_traits::~w32_regex_traits() -{ - BOOST_RE_GUARD_STACK -#ifdef BOOST_HAS_THREADS - re_detail::cs_guard g(*re_detail::p_re_lock); -#endif - // add reference to static member here to ensure - // that the linker includes it in the .exe: - if((--entry_count == 0) && (0 != &w32_regex_traits::i) && is_init) - do_free(); -#ifdef BOOST_HAS_THREADS - g.acquire(false); - re_detail::re_free_threads(); -#endif -} - -void BOOST_REGEX_CALL w32_regex_traits::transform(std::string& out, const std::string& in) -{ - BOOST_RE_GUARD_STACK - size_t n = LCMapStringA(GetUserDefaultLCID(), LCMAP_SORTKEY, in.c_str(), -1, 0, 0); - if(n == (size_t)(-1)) - { - out = in; - return; - } - scoped_array buf(new char[n+1]); - n = LCMapStringA(GetUserDefaultLCID(), LCMAP_SORTKEY, in.c_str(), -1, buf.get(), (int)n); - if(n == (size_t)(-1)) - { - out = in; - return; - } - out = buf.get(); -} - -void BOOST_REGEX_CALL w32_regex_traits::transform_primary(std::string& out, const std::string& in) -{ - transform(out, in); - for(unsigned int i = 0; i < out.size(); ++i) - { - if((out[i] == 1) && (i+1 < out.size())) - { - out.erase(i+1); - break; - } - } -} - - -int BOOST_REGEX_CALL w32_regex_traits::toi(char c) -{ - if(is_class(c, char_class_digit)) - return c - re_zero; - if(is_class(c, char_class_xdigit)) - return 10 + translate(c, true) - translate(re_ten, true); - return -1; // error!! -} - -int BOOST_REGEX_CALL w32_regex_traits::toi(const char*& first, const char* last, int radix) -{ - unsigned int maxval; - if(radix < 0) - { - // if radix is less than zero, then restrict - // return value to charT. NB assumes sizeof(charT) <= sizeof(int) - radix *= -1; - maxval = 1 << (sizeof(*first) * CHAR_BIT - 1); - maxval /= radix; - maxval *= 2; - maxval -= 1; } else { - maxval = (unsigned int)-1; - maxval /= radix; - } - - unsigned int result = 0; - unsigned int type = (radix > 10) ? char_class_xdigit : char_class_digit; - while((first != last) && is_class(*first, type) && (result <= maxval)) - { - result *= radix; - result += toi(*first); - ++first; - } - return result; -} - -#ifndef BOOST_NO_WREGEX - -bool BOOST_REGEX_CALL w32_regex_traits::lookup_collatename(std::basic_string& out, const regex_wchar_type* first, const regex_wchar_type* last) -{ - BOOST_RE_GUARD_STACK - std::basic_string s(first, last); - std::size_t len = strnarrow(static_cast(0), 0, s.c_str()); - scoped_array buf(new char[len]); - strnarrow(buf.get(), len, s.c_str()); - std::string t_out; - bool result = base_type::do_lookup_collate(t_out, buf.get()); - if(t_out.size() == 0) result = false; - if(result) - { - if(t_out[0]) + for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i) { - len = strwiden(static_cast(0), 0, t_out.c_str()); - scoped_array wb(new regex_wchar_type[len]); - strwiden(wb.get(), len, t_out.c_str()); - out = wb.get(); + const char* ptr = get_default_syntax(i); + while(ptr && *ptr) + { + m_char_map[static_cast(*ptr)] = i; + ++ptr; + } } - else - out.append(1,(regex_wchar_type)0); } - return result; -} - -unsigned int BOOST_REGEX_CALL w32_regex_traits::syntax_type(size_type c) -{ - BOOST_RE_GUARD_STACK - std::list::const_iterator first, last; - first = syntax->begin(); - last = syntax->end(); - while(first != last) + // + // finish off by calculating our escape types: + // + unsigned char i = 'A'; + do { - if((size_type)(uchar_type)((*first).c) == c) - return (*first).type; - ++first; - } - return 0; -} + if(m_char_map[i] == 0) + { + if(::boost::re_detail::w32_is(this->m_locale, 0x0002u, (char)i)) + m_char_map[i] = regex_constants::escape_type_class; + else if(::boost::re_detail::w32_is(this->m_locale, 0x0001u, (char)i)) + m_char_map[i] = regex_constants::escape_type_not_class; + } + }while(0xFF != i++); -bool BOOST_REGEX_CALL w32_regex_traits::do_lookup_collate(std::basic_string& out, const regex_wchar_type* first, const regex_wchar_type* last) -{ - BOOST_RE_GUARD_STACK - std::basic_string s(first, last); - std::size_t len = strnarrow(static_cast(0), 0, s.c_str()); - scoped_array buf(new char[len]); - strnarrow(buf.get(), len, s.c_str()); - std::string t_out; - bool result = base_type::do_lookup_collate(t_out, buf.get()); - if(result) + // + // fill in lower case map: + // + char char_map[1 << CHAR_BIT]; + for(int ii = 0; ii < (1 << CHAR_BIT); ++ii) + char_map[ii] = static_cast(ii); + int r = ::LCMapStringA(this->m_locale, LCMAP_LOWERCASE, char_map, 1 << CHAR_BIT, this->m_lower_map, 1 << CHAR_BIT); + BOOST_ASSERT(r != 0); + if(r < (1 << CHAR_BIT)) { - len = strwiden(static_cast(0), 0, t_out.c_str()); - scoped_array wb(new regex_wchar_type[len]); - strwiden(wb.get(), len, t_out.c_str()); - out = wb.get(); + // if we have multibyte characters then not all may have been given + // a lower case mapping: + for(int jj = r; jj < (1 << CHAR_BIT); ++jj) + this->m_lower_map[jj] = static_cast(jj); } - return result; + r = ::GetStringTypeExA(this->m_locale, CT_CTYPE1, char_map, 1 << CHAR_BIT, this->m_type_map); + BOOST_ASSERT(0 != r); } - -void BOOST_REGEX_CALL w32_regex_traits::update() +BOOST_REGEX_DECL lcid_type BOOST_REGEX_CALL w32_get_default_locale() { - BOOST_RE_GUARD_STACK -#ifdef BOOST_HAS_THREADS - re_detail::cs_guard g(*re_detail::p_re_lock); -#endif - do_init(); + return ::GetUserDefaultLCID(); } -w32_regex_traits::w32_regex_traits() +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(char c, lcid_type id) { - BOOST_RE_GUARD_STACK -#ifdef BOOST_HAS_THREADS - re_detail::re_init_threads(); - re_detail::cs_guard g(*re_detail::p_re_lock); -#endif - ++entry_count; -} - -w32_regex_traits::~w32_regex_traits() -{ - BOOST_RE_GUARD_STACK -#ifdef BOOST_HAS_THREADS - re_detail::cs_guard g(*re_detail::p_re_lock); -#endif - // add reference to static member here to ensure - // that the linker includes it in the .exe: - if((--entry_count == 0) && (0 != &w32_regex_traits::init_) && is_init) - do_free(); -#ifdef BOOST_HAS_THREADS - g.acquire(false); - re_detail::re_free_threads(); -#endif -} - -bool BOOST_REGEX_CALL w32_regex_traits::do_iswclass(regex_wchar_type c, boost::uint_fast32_t f) -{ - BOOST_RE_GUARD_STACK - if((c & ~0xFF) == 0) - return BOOST_REGEX_MAKE_BOOL(re_detail::wide_unicode_classes[(uchar_type)c] & f & char_class_win); WORD mask; - if(f & char_class_unicode) + if(::GetStringTypeExA(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER)) return true; - else if(isPlatformNT && GetStringTypeW(CT_CTYPE1, (const wchar_t*)&c, 1, &mask)) - return BOOST_REGEX_MAKE_BOOL(mask & f & char_class_win); - else if((f & char_class_graph) == char_class_graph) - return true; // all wide characters are considered "graphics" return false; } -void BOOST_REGEX_CALL w32_regex_traits::transform(std::basic_string& out, const std::basic_string& in) +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(wchar_t c, lcid_type id) { - BOOST_RE_GUARD_STACK - scoped_array alt; - size_t n; - if(isPlatformNT) - n = LCMapStringW(GetUserDefaultLCID(), LCMAP_SORTKEY, (const wchar_t*)in.c_str(), -1, 0, 0); - else - { - n = strnarrow(static_cast(0), 0, in.c_str()); - alt.reset(new char[n+1]); - strnarrow(alt.get(), n+1, in.c_str()); - n = LCMapStringA(GetUserDefaultLCID(), LCMAP_SORTKEY, alt.get(), -1, 0, 0); - } - if((n == (size_t)(-1)) || (n == 0)) - { - out = in; - return; - } - scoped_array buf(new regex_wchar_type[n+1]); - // under win32 we get mapped to an array of bytes - // not characters; since the underlying engine has to - // deal with chars we widen the bytes to regex_wchar_type to ensure - // the sort order remains unchanged when we compare. - scoped_array t(new char[n+1]); - if(isPlatformNT) - n = LCMapStringW(GetUserDefaultLCID(), LCMAP_SORTKEY, (const wchar_t*)in.c_str(), -1, reinterpret_cast(t.get()), (int)n); - else - n = LCMapStringA(GetUserDefaultLCID(), LCMAP_SORTKEY, alt.get(), -1, t.get(), (int)n); - int i = -1; - do - { - ++i; - buf[i] = (regex_wchar_type)(unsigned char)t[i]; - } while(t[i]); - if(n == (size_t)(-1)) - { - out = in; - return; - } - out = buf.get(); + WORD mask; + if(::GetStringTypeExW(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER)) + return true; + return false; +} +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(unsigned short ca, lcid_type id) +{ + WORD mask; + wchar_t c = ca; + if(::GetStringTypeExW(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER)) + return true; + return false; +} +#endif + +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(char c, lcid_type id) +{ + WORD mask; + if(::GetStringTypeExA(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_UPPER)) + return true; + return false; } -void BOOST_REGEX_CALL w32_regex_traits::transform_primary(std::basic_string& out, const std::basic_string& in) +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(wchar_t c, lcid_type id) { - transform(out, in); - for(unsigned int i = 0; i < out.size(); ++i) - { - if((out[i] == 1) && ((i + 1) < out.size())) - { - out.erase(i+1); - break; - } - } + WORD mask; + if(::GetStringTypeExW(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_UPPER)) + return true; + return false; +} +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(unsigned short ca, lcid_type id) +{ + WORD mask; + wchar_t c = ca; + if(::GetStringTypeExW(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_UPPER)) + return true; + return false; +} +#endif + +void free_module(void* mod) +{ + ::FreeLibrary(static_cast(mod)); } - -int BOOST_REGEX_CALL w32_regex_traits::toi(regex_wchar_type c) +BOOST_REGEX_DECL cat_type BOOST_REGEX_CALL w32_cat_open(const std::string& name) { - if(is_class(c, char_class_digit)) - return c - re_zero_w; - if(is_class(c, char_class_xdigit)) - return 10 + translate(c, true) - translate(re_ten_w, true); - return -1; // error!! + cat_type result(::LoadLibraryA(name.c_str()), &free_module); + return result; } -int BOOST_REGEX_CALL w32_regex_traits::toi(const regex_wchar_type*& first, const regex_wchar_type* last, int radix) +BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::string& def) { - unsigned int maxval; - if(radix < 0) + char buf[256]; + if(0 == ::LoadStringA( + static_cast(cat.get()), + i, + buf, + 256 + )) { - // if radix is less than zero, then restrict - // return value to charT. NB assumes sizeof(charT) <= sizeof(int) - radix *= -1; - maxval = 1 << (sizeof(*first) * CHAR_BIT - 1); - maxval /= radix; - maxval *= 2; - maxval -= 1; - } - else - { - maxval = (unsigned int)-1; - maxval /= radix; + return def; } + return std::string(buf); +} - unsigned int result = 0; - unsigned int type = (radix > 10) ? char_class_xdigit : char_class_digit; - while((first != last) && is_class(*first, type) && (result <= maxval)) +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::wstring& def) +{ + wchar_t buf[256]; + if(0 == ::LoadStringW( + static_cast(cat.get()), + i, + buf, + 256 + )) { - result *= radix; - result += toi(*first); - ++first; + return def; + } + return std::wstring(buf); +} +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL std::basic_string BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::basic_string& def) +{ + unsigned short buf[256]; + if(0 == ::LoadStringW( + static_cast(cat.get()), + i, + (LPWSTR)buf, + 256 + )) + { + return def; + } + return std::basic_string(buf); +} +#endif +#endif +BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type id, const char* p1, const char* p2) +{ + int bytes = ::LCMapStringA( + id, // locale identifier + LCMAP_SORTKEY, // mapping transformation type + p1, // source string + static_cast(p2 - p1), // number of characters in source string + 0, // destination buffer + 0 // size of destination buffer + ); + if(!bytes) + return std::string(p1, p2); + std::string result(++bytes, '\0'); + bytes = ::LCMapStringA( + id, // locale identifier + LCMAP_SORTKEY, // mapping transformation type + p1, // source string + static_cast(p2 - p1), // number of characters in source string + &*result.begin(), // destination buffer + bytes // size of destination buffer + ); + if(bytes > static_cast(result.size())) + return std::string(p1, p2); + while(result.size() && result[result.size()-1] == '\0') + { + result.erase(result.size()-1); } return result; } -boost::uint_fast32_t BOOST_REGEX_CALL w32_regex_traits::lookup_classname(const regex_wchar_type* first, const regex_wchar_type* last) +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_transform(lcid_type id, const wchar_t* p1, const wchar_t* p2) { - std::basic_string s(first, last); - std::size_t len = strnarrow(static_cast(0), 0, s.c_str()); - scoped_array buf(new char[len]); - strnarrow(buf.get(), len, s.c_str()); - boost::uint_fast32_t result = do_lookup_class(buf.get()); - return result; + int bytes = ::LCMapStringW( + id, // locale identifier + LCMAP_SORTKEY, // mapping transformation type + p1, // source string + static_cast(p2 - p1), // number of characters in source string + 0, // destination buffer + 0 // size of destination buffer + ); + if(!bytes) + return std::wstring(p1, p2); + std::string result(++bytes, '\0'); + bytes = ::LCMapStringW( + id, // locale identifier + LCMAP_SORTKEY, // mapping transformation type + p1, // source string + static_cast(p2 - p1), // number of characters in source string + reinterpret_cast(&*result.begin()), // destination buffer *of bytes* + bytes // size of destination buffer + ); + if(bytes > static_cast(result.size())) + return std::wstring(p1, p2); + while(result.size() && result[result.size()-1] == L'\0') + { + result.erase(result.size()-1); + } + std::wstring r2; + for(std::string::size_type i = 0; i < result.size(); ++i) + r2.append(1, static_cast(static_cast(result[i]))); + return r2; +} +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL std::basic_string BOOST_REGEX_CALL w32_transform(lcid_type id, const unsigned short* p1, const unsigned short* p2) +{ + int bytes = ::LCMapStringW( + id, // locale identifier + LCMAP_SORTKEY, // mapping transformation type + (LPCWSTR)p1, // source string + static_cast(p2 - p1), // number of characters in source string + 0, // destination buffer + 0 // size of destination buffer + ); + if(!bytes) + return std::basic_string(p1, p2); + std::string result(++bytes, '\0'); + bytes = ::LCMapStringW( + id, // locale identifier + LCMAP_SORTKEY, // mapping transformation type + (LPCWSTR)p1, // source string + static_cast(p2 - p1), // number of characters in source string + reinterpret_cast(&*result.begin()), // destination buffer *of bytes* + bytes // size of destination buffer + ); + if(bytes > static_cast(result.size())) + return std::basic_string(p1, p2); + while(result.size() && result[result.size()-1] == L'\0') + { + result.erase(result.size()-1); + } + std::basic_string r2; + for(std::string::size_type i = 0; i < result.size(); ++i) + r2.append(1, static_cast(static_cast(result[i]))); + return r2; +} +#endif +#endif +BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type id) +{ + char result[2]; + int b = ::LCMapStringA( + id, // locale identifier + LCMAP_LOWERCASE, // mapping transformation type + &c, // source string + 1, // number of characters in source string + result, // destination buffer + 1); // size of destination buffer + if(b == 0) + return c; + return result[0]; } -regex_wchar_type BOOST_REGEX_CALL w32_regex_traits::wtolower(regex_wchar_type c) +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_tolower(wchar_t c, lcid_type id) { - BOOST_RE_GUARD_STACK - if(isPlatformNT) - return LOWORD(CharLowerW(reinterpret_cast(static_cast(c)))); - return c; + wchar_t result[2]; + int b = ::LCMapStringW( + id, // locale identifier + LCMAP_LOWERCASE, // mapping transformation type + &c, // source string + 1, // number of characters in source string + result, // destination buffer + 1); // size of destination buffer + if(b == 0) + return c; + return result[0]; +} +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_tolower(unsigned short c, lcid_type id) +{ + wchar_t result[2]; + int b = ::LCMapStringW( + id, // locale identifier + LCMAP_LOWERCASE, // mapping transformation type + (wchar_t const*)&c, // source string + 1, // number of characters in source string + result, // destination buffer + 1); // size of destination buffer + if(b == 0) + return c; + return result[0]; +} +#endif +#endif +BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_toupper(char c, lcid_type id) +{ + char result[2]; + int b = ::LCMapStringA( + id, // locale identifier + LCMAP_UPPERCASE, // mapping transformation type + &c, // source string + 1, // number of characters in source string + result, // destination buffer + 1); // size of destination buffer + if(b == 0) + return c; + return result[0]; } - -w32_regex_traits w32_regex_traits::init_; - -std::size_t BOOST_REGEX_CALL w32_regex_traits::strnarrow(char *s1, std::size_t len, const regex_wchar_type *s2) +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_toupper(wchar_t c, lcid_type id) { - BOOST_RE_GUARD_STACK - std::size_t size = WideCharToMultiByte(CP_ACP, 0, (const wchar_t*)s2, -1, s1, 0, 0, 0); - if(size > len) - return size; - return WideCharToMultiByte(CP_ACP, 0, (const wchar_t*)s2, -1, s1, (int)len, 0, 0); + wchar_t result[2]; + int b = ::LCMapStringW( + id, // locale identifier + LCMAP_UPPERCASE, // mapping transformation type + &c, // source string + 1, // number of characters in source string + result, // destination buffer + 1); // size of destination buffer + if(b == 0) + return c; + return result[0]; +} +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_toupper(unsigned short c, lcid_type id) +{ + wchar_t result[2]; + int b = ::LCMapStringW( + id, // locale identifier + LCMAP_UPPERCASE, // mapping transformation type + (wchar_t const*)&c, // source string + 1, // number of characters in source string + result, // destination buffer + 1); // size of destination buffer + if(b == 0) + return c; + return result[0]; +} +#endif +#endif +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type id, boost::uint32_t m, char c) +{ + WORD mask; + if(::GetStringTypeExA(id, CT_CTYPE1, &c, 1, &mask) && (mask & m & w32_regex_traits_implementation::mask_base)) + return true; + if((m & w32_regex_traits_implementation::mask_word) && (c == '_')) + return true; + return false; } -std::size_t BOOST_REGEX_CALL w32_regex_traits::strwiden(regex_wchar_type *s1, std::size_t len, const char *s2) +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type id, boost::uint32_t m, wchar_t c) { - BOOST_RE_GUARD_STACK - std::size_t size = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, s2, -1, (wchar_t*)s1, 0); - if(size > len) - return size; - return MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, s2, -1, (wchar_t*)s1, (int)len); + WORD mask; + if(::GetStringTypeExW(id, CT_CTYPE1, &c, 1, &mask) && (mask & m & w32_regex_traits_implementation::mask_base)) + return true; + if((m & w32_regex_traits_implementation::mask_word) && (c == '_')) + return true; + if((m & w32_regex_traits_implementation::mask_unicode) && (c > 0xff)) + return true; + return false; } +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type id, boost::uint32_t m, unsigned short c) +{ + WORD mask; + if(::GetStringTypeExW(id, CT_CTYPE1, (wchar_t const*)&c, 1, &mask) && (mask & m & w32_regex_traits_implementation::mask_base)) + return true; + if((m & w32_regex_traits_implementation::mask_word) && (c == '_')) + return true; + if((m & w32_regex_traits_implementation::mask_unicode) && (c > 0xff)) + return true; + return false; +} +#endif +#endif -unsigned short w32_regex_traits::wide_unicode_classes[] = { - re_detail::w32_traits_base::char_class_cntrl, // '' 0 - re_detail::w32_traits_base::char_class_cntrl, // '' 1 - re_detail::w32_traits_base::char_class_cntrl, // '' 2 - re_detail::w32_traits_base::char_class_cntrl, // '' 3 - re_detail::w32_traits_base::char_class_cntrl, // '' 4 - re_detail::w32_traits_base::char_class_cntrl, // '' 5 - re_detail::w32_traits_base::char_class_cntrl, // '' 6 - re_detail::w32_traits_base::char_class_cntrl, // '' 7 - re_detail::w32_traits_base::char_class_cntrl, // '' 8 - re_detail::w32_traits_base::char_class_cntrl | re_detail::w32_traits_base::char_class_space | re_detail::w32_traits_base::char_class_blank, // '' 9 - re_detail::w32_traits_base::char_class_cntrl | re_detail::w32_traits_base::char_class_space, // '' 10 - re_detail::w32_traits_base::char_class_cntrl | re_detail::w32_traits_base::char_class_space, // '' 11 - re_detail::w32_traits_base::char_class_cntrl | re_detail::w32_traits_base::char_class_space, // '' 12 - re_detail::w32_traits_base::char_class_cntrl | re_detail::w32_traits_base::char_class_space, // '' 13 - re_detail::w32_traits_base::char_class_cntrl, // '.' 14 - re_detail::w32_traits_base::char_class_cntrl, // '.' 15 - re_detail::w32_traits_base::char_class_cntrl, // '.' 16 - re_detail::w32_traits_base::char_class_cntrl, // '.' 17 - re_detail::w32_traits_base::char_class_cntrl, // '.' 18 - re_detail::w32_traits_base::char_class_cntrl, // '.' 19 - re_detail::w32_traits_base::char_class_cntrl, // '.' 20 - re_detail::w32_traits_base::char_class_cntrl, // '.' 21 - re_detail::w32_traits_base::char_class_cntrl, // '.' 22 - re_detail::w32_traits_base::char_class_cntrl, // '.' 23 - re_detail::w32_traits_base::char_class_cntrl, // '.' 24 - re_detail::w32_traits_base::char_class_cntrl, // '' 25 - re_detail::w32_traits_base::char_class_cntrl, // '' 26 - re_detail::w32_traits_base::char_class_cntrl, // '' 27 - re_detail::w32_traits_base::char_class_cntrl, // '.' 28 - re_detail::w32_traits_base::char_class_cntrl, // '.' 29 - re_detail::w32_traits_base::char_class_cntrl, // '.' 30 - re_detail::w32_traits_base::char_class_cntrl, // '.' 31 - re_detail::w32_traits_base::char_class_space | re_detail::w32_traits_base::char_class_blank, // ' ' 32 - re_detail::w32_traits_base::char_class_punct, // '!' 33 - re_detail::w32_traits_base::char_class_punct, // '"' 34 - re_detail::w32_traits_base::char_class_punct, // '#' 35 - re_detail::w32_traits_base::char_class_punct, // '$' 36 - re_detail::w32_traits_base::char_class_punct, // '%' 37 - re_detail::w32_traits_base::char_class_punct, // '&' 38 - re_detail::w32_traits_base::char_class_punct, // ''' 39 - re_detail::w32_traits_base::char_class_punct, // '(' 40 - re_detail::w32_traits_base::char_class_punct, // ')' 41 - re_detail::w32_traits_base::char_class_punct, // '*' 42 - re_detail::w32_traits_base::char_class_punct, // '+' 43 - re_detail::w32_traits_base::char_class_punct, // ',' 44 - re_detail::w32_traits_base::char_class_punct, // '-' 45 - re_detail::w32_traits_base::char_class_punct, // '.' 46 - re_detail::w32_traits_base::char_class_punct, // '/' 47 - re_detail::w32_traits_base::char_class_digit | re_detail::w32_traits_base::char_class_xdigit, // '0' 48 - re_detail::w32_traits_base::char_class_digit | re_detail::w32_traits_base::char_class_xdigit, // '1' 49 - re_detail::w32_traits_base::char_class_digit | re_detail::w32_traits_base::char_class_xdigit, // '2' 50 - re_detail::w32_traits_base::char_class_digit | re_detail::w32_traits_base::char_class_xdigit, // '3' 51 - re_detail::w32_traits_base::char_class_digit | re_detail::w32_traits_base::char_class_xdigit, // '4' 52 - re_detail::w32_traits_base::char_class_digit | re_detail::w32_traits_base::char_class_xdigit, // '5' 53 - re_detail::w32_traits_base::char_class_digit | re_detail::w32_traits_base::char_class_xdigit, // '6' 54 - re_detail::w32_traits_base::char_class_digit | re_detail::w32_traits_base::char_class_xdigit, // '7' 55 - re_detail::w32_traits_base::char_class_digit | re_detail::w32_traits_base::char_class_xdigit, // '8' 56 - re_detail::w32_traits_base::char_class_digit | re_detail::w32_traits_base::char_class_xdigit, // '9' 57 - re_detail::w32_traits_base::char_class_punct, // ':' 58 - re_detail::w32_traits_base::char_class_punct, // ';' 59 - re_detail::w32_traits_base::char_class_punct, // '<' 60 - re_detail::w32_traits_base::char_class_punct, // '=' 61 - re_detail::w32_traits_base::char_class_punct, // '>' 62 - re_detail::w32_traits_base::char_class_punct, // '?' 63 - re_detail::w32_traits_base::char_class_punct, // '@' 64 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper | re_detail::w32_traits_base::char_class_xdigit, // 'A' 65 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper | re_detail::w32_traits_base::char_class_xdigit, // 'B' 66 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper | re_detail::w32_traits_base::char_class_xdigit, // 'C' 67 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper | re_detail::w32_traits_base::char_class_xdigit, // 'D' 68 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper | re_detail::w32_traits_base::char_class_xdigit, // 'E' 69 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper | re_detail::w32_traits_base::char_class_xdigit, // 'F' 70 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // 'G' 71 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // 'H' 72 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // 'I' 73 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // 'J' 74 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // 'K' 75 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // 'L' 76 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // 'M' 77 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // 'N' 78 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // 'O' 79 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // 'P' 80 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // 'Q' 81 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // 'R' 82 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // 'S' 83 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // 'T' 84 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // 'U' 85 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // 'V' 86 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // 'W' 87 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // 'X' 88 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // 'Y' 89 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // 'Z' 90 - re_detail::w32_traits_base::char_class_punct, // '[' 91 - re_detail::w32_traits_base::char_class_punct, // '\' 92 - re_detail::w32_traits_base::char_class_punct, // ']' 93 - re_detail::w32_traits_base::char_class_punct, // '^' 94 - re_detail::w32_traits_base::char_class_punct | re_detail::w32_traits_base::char_class_underscore, // '_' 95 - re_detail::w32_traits_base::char_class_punct, // '`' 96 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower | re_detail::w32_traits_base::char_class_xdigit, // 'a' 97 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower | re_detail::w32_traits_base::char_class_xdigit, // 'b' 98 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower | re_detail::w32_traits_base::char_class_xdigit, // 'c' 99 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower | re_detail::w32_traits_base::char_class_xdigit, // 'd' 100 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower | re_detail::w32_traits_base::char_class_xdigit, // 'e' 101 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower | re_detail::w32_traits_base::char_class_xdigit, // 'f' 102 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // 'g' 103 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // 'h' 104 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // 'i' 105 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // 'j' 106 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // 'k' 107 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // 'l' 108 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // 'm' 109 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // 'n' 110 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // 'o' 111 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // 'p' 112 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // 'q' 113 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // 'r' 114 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // 's' 115 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // 't' 116 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // 'u' 117 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // 'v' 118 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // 'w' 119 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // 'x' 120 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // 'y' 121 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // 'z' 122 - re_detail::w32_traits_base::char_class_punct, // '{' 123 - re_detail::w32_traits_base::char_class_punct, // '|' 124 - re_detail::w32_traits_base::char_class_punct, // '}' 125 - re_detail::w32_traits_base::char_class_punct, // '~' 126 - - re_detail::w32_traits_base::char_class_cntrl, // '' 127 - re_detail::w32_traits_base::char_class_cntrl, // '' 128 - re_detail::w32_traits_base::char_class_cntrl, // '' 129 - re_detail::w32_traits_base::char_class_cntrl, // '' 130 - re_detail::w32_traits_base::char_class_cntrl, // '' 131 - re_detail::w32_traits_base::char_class_cntrl, // '' 132 - re_detail::w32_traits_base::char_class_cntrl, // '' 133 - re_detail::w32_traits_base::char_class_cntrl, // '' 134 - re_detail::w32_traits_base::char_class_cntrl, // '' 135 - re_detail::w32_traits_base::char_class_cntrl, // '' 136 - re_detail::w32_traits_base::char_class_cntrl, // '' 137 - re_detail::w32_traits_base::char_class_cntrl, // '' 138 - re_detail::w32_traits_base::char_class_cntrl, // '' 139 - re_detail::w32_traits_base::char_class_cntrl, // '' 140 - re_detail::w32_traits_base::char_class_cntrl, // '' 141 - re_detail::w32_traits_base::char_class_cntrl, // '' 142 - re_detail::w32_traits_base::char_class_cntrl, // '' 143 - re_detail::w32_traits_base::char_class_cntrl, // '' 144 - re_detail::w32_traits_base::char_class_cntrl, // '' 145 - re_detail::w32_traits_base::char_class_cntrl, // '' 146 - re_detail::w32_traits_base::char_class_cntrl, // '' 147 - re_detail::w32_traits_base::char_class_cntrl, // '' 148 - re_detail::w32_traits_base::char_class_cntrl, // '' 149 - re_detail::w32_traits_base::char_class_cntrl, // '' 150 - re_detail::w32_traits_base::char_class_cntrl, // '' 151 - re_detail::w32_traits_base::char_class_cntrl, // '' 152 - re_detail::w32_traits_base::char_class_cntrl, // '' 153 - re_detail::w32_traits_base::char_class_cntrl, // '' 154 - re_detail::w32_traits_base::char_class_cntrl, // '' 155 - re_detail::w32_traits_base::char_class_cntrl, // '' 156 - re_detail::w32_traits_base::char_class_cntrl, // '' 157 - re_detail::w32_traits_base::char_class_cntrl, // '' 158 - re_detail::w32_traits_base::char_class_cntrl, // '' 159 - re_detail::w32_traits_base::char_class_space | re_detail::w32_traits_base::char_class_blank, // '' 160 - re_detail::w32_traits_base::char_class_punct, // '' 161 - re_detail::w32_traits_base::char_class_punct, // '' 162 - re_detail::w32_traits_base::char_class_punct, // '' 163 - re_detail::w32_traits_base::char_class_punct, // '' 164 - re_detail::w32_traits_base::char_class_punct, // '' 165 - re_detail::w32_traits_base::char_class_punct, // '' 166 - re_detail::w32_traits_base::char_class_punct, // '' 167 - re_detail::w32_traits_base::char_class_punct, // '' 168 - re_detail::w32_traits_base::char_class_punct, // '' 169 - re_detail::w32_traits_base::char_class_punct, // '' 170 - re_detail::w32_traits_base::char_class_punct, // '' 171 - re_detail::w32_traits_base::char_class_punct, // '' 172 - re_detail::w32_traits_base::char_class_punct, // '' 173 - re_detail::w32_traits_base::char_class_punct, // '' 174 - re_detail::w32_traits_base::char_class_punct, // '' 175 - re_detail::w32_traits_base::char_class_punct, // '' 176 - re_detail::w32_traits_base::char_class_punct, // '' 177 - re_detail::w32_traits_base::char_class_punct, // '' 178 - re_detail::w32_traits_base::char_class_punct, // '' 179 - re_detail::w32_traits_base::char_class_punct, // '' 180 - re_detail::w32_traits_base::char_class_punct, // '' 181 - re_detail::w32_traits_base::char_class_punct, // '' 182 - re_detail::w32_traits_base::char_class_punct, // '' 183 - re_detail::w32_traits_base::char_class_punct, // '' 184 - re_detail::w32_traits_base::char_class_punct, // '' 185 - re_detail::w32_traits_base::char_class_punct, // '' 186 - re_detail::w32_traits_base::char_class_punct, // '' 187 - re_detail::w32_traits_base::char_class_punct, // '' 188 - re_detail::w32_traits_base::char_class_punct, // '' 189 - re_detail::w32_traits_base::char_class_punct, // '' 190 - re_detail::w32_traits_base::char_class_punct, // '' 191 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 192 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 193 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 194 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 195 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 196 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 197 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 198 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 199 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 200 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 201 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 202 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 203 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 204 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 205 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 206 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 207 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 208 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 209 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 210 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 211 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 212 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 213 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 214 - re_detail::w32_traits_base::char_class_punct, // '' 215 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 216 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 217 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 218 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 219 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 220 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 221 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_upper, // '' 222 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 223 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 224 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 225 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 226 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 227 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 228 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 229 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 230 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 231 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 232 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 233 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 234 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 235 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 236 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 237 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 238 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 239 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 240 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 241 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 242 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 243 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 244 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 245 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 246 - re_detail::w32_traits_base::char_class_punct, // '' 247 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 248 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 249 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 250 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 251 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 252 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 253 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 254 - re_detail::w32_traits_base::char_class_alpha | re_detail::w32_traits_base::char_class_lower, // '' 255 -}; - - - -#endif // BOOST_NO_WREGEX - - -} // namespace boost - -#endif // #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) - - - - +} // re_detail +} // boost +#endif diff --git a/boost/libs/regex/src/wide_posix_api.cpp b/boost/libs/regex/src/wide_posix_api.cpp index fab55b1c28..97a2225d66 100644 --- a/boost/libs/regex/src/wide_posix_api.cpp +++ b/boost/libs/regex/src/wide_posix_api.cpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -22,12 +22,22 @@ #ifndef BOOST_NO_WREGEX +#include #include #include #include #include +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ +# ifndef BOOST_NO_SWPRINTF + using ::swprintf; +# endif +} +#endif + + namespace boost{ namespace { @@ -43,7 +53,6 @@ const wchar_t* wnames[] = {L"REG_NOERROR", L"REG_NOMATCH", L"REG_BADPAT", L"REG_ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wchar_t* ptr, int f) { - BOOST_RE_GUARD_STACK if(expression->re_magic != wmagic_value) { expression->guts = 0; @@ -62,7 +71,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha #endif } // set default flags: - boost::uint_fast32_t flags = (f & REG_EXTENDED) ? wregex::extended : wregex::basic; + boost::uint_fast32_t flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? wregex::extended : wregex::basic); expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : match_default; // and translate those that are actually set: @@ -75,20 +84,19 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha } if(f & REG_NOSUB) - expression->eflags |= match_any; + { + //expression->eflags |= match_any; + flags |= wregex::nosubs; + } if(f & REG_NOSPEC) flags |= wregex::literal; if(f & REG_ICASE) flags |= wregex::icase; if(f & REG_ESCAPE_IN_LISTS) - flags |= wregex::escape_in_lists; + flags &= ~wregex::no_escape_in_lists; if(f & REG_NEWLINE_ALT) flags |= wregex::newline_alt; -#ifndef BOOST_REGEX_V3 - if(f & REG_PERLEX) - flags |= wregex::perlex; -#endif const wchar_t* p2; if(f & REG_PEND) @@ -105,7 +113,12 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha expression->re_nsub = static_cast(expression->guts)->mark_count() - 1; result = static_cast(expression->guts)->error_code(); #ifndef BOOST_NO_EXCEPTIONS - } catch(...) + } + catch(const boost::regex_error& be) + { + result = be.code(); + } + catch(...) { result = REG_E_UNKNOWN; } @@ -118,16 +131,19 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW* e, wchar_t* buf, regsize_t buf_size) { - BOOST_RE_GUARD_STACK std::size_t result = 0; if(code & REG_ITOA) { code &= ~REG_ITOA; - if(code <= REG_E_UNKNOWN) + if((code <= (int)REG_E_UNKNOWN) && (code >= 0)) { result = std::wcslen(wnames[code]) + 1; if(buf_size >= result) +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) + ::wcscpy_s(buf, buf_size, wnames[code]); +#else std::wcscpy(buf, wnames[code]); +#endif return result; } return result; @@ -138,34 +154,43 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW* wchar_t localbuf[5]; if(e == 0) return 0; - for(int i = 0; i <= REG_E_UNKNOWN; ++i) + for(int i = 0; i <= (int)REG_E_UNKNOWN; ++i) { if(std::wcscmp(e->re_endp, wnames[i]) == 0) { - std::swprintf(localbuf, 5, L"%d", i); + (std::swprintf)(localbuf, 5, L"%d", i); if(std::wcslen(localbuf) < buf_size) +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) + ::wcscpy_s(buf, buf_size, localbuf); +#else std::wcscpy(buf, localbuf); +#endif return std::wcslen(localbuf) + 1; } } - std::swprintf(localbuf, 5, L"%d", 0); + (std::swprintf)(localbuf, 5, L"%d", 0); if(std::wcslen(localbuf) < buf_size) +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) + ::wcscpy_s(buf, buf_size, localbuf); +#else std::wcscpy(buf, localbuf); +#endif return std::wcslen(localbuf) + 1; } #endif - if(code <= REG_E_UNKNOWN) + if(code <= (int)REG_E_UNKNOWN) { - regex_traits rt; - const regex_traits* pt = &rt; - if(e && (e->re_magic == wmagic_value)) - pt = &static_cast(e->guts)->get_traits(); - (void)pt; // warning suppression - std::string p = pt->error_string(code); - std::size_t len = pt->strwiden(static_cast(0), 0, p.c_str()); + std::string p; + if((e) && (e->re_magic == wmagic_value)) + p = static_cast(e->guts)->get_traits().error_string(static_cast< ::boost::regex_constants::error_type>(code)); + else + { + p = re_detail::get_default_error_string(static_cast< ::boost::regex_constants::error_type>(code)); + } + std::size_t len = p.size(); if(len < buf_size) { - pt->strwiden(buf, buf_size, p.c_str()); + re_detail::copy(p.c_str(), p.c_str() + p.size() + 1, buf); } return len + 1; } @@ -176,7 +201,10 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW* BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW* expression, const wchar_t* buf, regsize_t n, regmatch_t* array, int eflags) { - BOOST_RE_GUARD_STACK +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4267) +#endif bool result = false; match_flag_type flags = match_default | expression->eflags; const wchar_t* end; @@ -216,7 +244,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW* expression, cons if(result) { // extract what matched: - unsigned int i; + std::size_t i; for(i = 0; (i < n) && (i < expression->re_nsub + 1); ++i) { array[i].rm_so = (m[i].matched == false) ? -1 : (m[i].first - buf); @@ -231,11 +259,13 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW* expression, cons return 0; } return REG_NOMATCH; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif } BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeW(regex_tW* expression) { - BOOST_RE_GUARD_STACK if(expression->re_magic == wmagic_value) { delete static_cast(expression->guts); diff --git a/boost/libs/regex/src/winstances.cpp b/boost/libs/regex/src/winstances.cpp index 34e71a00d9..1e0b859628 100644 --- a/boost/libs/regex/src/winstances.cpp +++ b/boost/libs/regex/src/winstances.cpp @@ -1,7 +1,7 @@ /* * * Copyright (c) 1998-2002 - * Dr John Maddock + * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -31,3 +31,5 @@ #endif + + diff --git a/boost/libs/signals/src/named_slot_map.cpp b/boost/libs/signals/src/named_slot_map.cpp index 2d8f6589db..88a0b6aff2 100644 --- a/boost/libs/signals/src/named_slot_map.cpp +++ b/boost/libs/signals/src/named_slot_map.cpp @@ -19,199 +19,122 @@ namespace boost { namespace BOOST_SIGNALS_NAMESPACE { namespace detail { typedef std::list group_list; typedef group_list::iterator slot_pair_iterator; -typedef std::map slot_container_type; +typedef std::map slot_container_type; typedef slot_container_type::iterator group_iterator; typedef slot_container_type::const_iterator const_group_iterator; -class named_slot_map::impl +named_slot_map_iterator::named_slot_map_iterator() : slot_assigned(false) {} + +named_slot_map_iterator:: +named_slot_map_iterator(const named_slot_map_iterator& other) + : group(other.group), last_group(other.last_group), + slot_assigned(other.slot_assigned) { -public: - impl(const compare_type& compare) : groups(compare) - { - clear(); - } - - void clear() - { - groups.clear(); - groups[front_type()]; - groups[back_type()]; - back = groups.end(); - --back; - } - - slot_container_type groups; - group_iterator back; - - bool empty(const_group_iterator group) const - { - return (group->second.empty() && group != groups.begin() && group != back); - } -}; - -class named_slot_map_iterator::impl -{ -public: - impl() : slot_assigned(false) {} - - impl(group_iterator group, group_iterator last_group) - : group(group), last_group(last_group), slot_assigned(false) - { init_next_group(); } - - impl(group_iterator group, group_iterator last_group, - slot_pair_iterator slot_) - : group(group), last_group(last_group), slot_(slot_), slot_assigned(true) - { } - - impl(const impl& other) - : group(other.group), last_group(other.last_group), - slot_assigned(other.slot_assigned) - { - if (slot_assigned) slot_ = other.slot_; - } - - impl& operator=(const impl& other) - { - group = other.group; - last_group = other.last_group; - slot_assigned = other.slot_assigned; - if (slot_assigned) slot_ = other.slot_; - return *this; - } - - void init_next_group() - { - while (group != last_group && group->second.empty()) ++group; - if (group != last_group) { - slot_ = group->second.begin(); - slot_assigned = true; - } - } - - group_iterator group; - group_iterator last_group; - slot_pair_iterator slot_; - bool slot_assigned; -}; - -named_slot_map_iterator::named_slot_map_iterator() {} - -named_slot_map_iterator::named_slot_map_iterator(std::auto_ptr impl_) - : impl_(impl_) {} - -named_slot_map_iterator - ::named_slot_map_iterator(const named_slot_map_iterator& other) -{ - impl_.reset(new impl(*other.impl_)); + if (slot_assigned) slot_ = other.slot_; } -named_slot_map_iterator::~named_slot_map_iterator() {} - named_slot_map_iterator& named_slot_map_iterator::operator=(const named_slot_map_iterator& other) { - if (impl_) *impl_ = *other.impl_; - else impl_.reset(new impl(*other.impl_)); + slot_assigned = other.slot_assigned; + group = other.group; + last_group = other.last_group; + if (slot_assigned) slot_ = other.slot_; return *this; } + connection_slot_pair& named_slot_map_iterator::dereference() const -{ return *impl_->slot_; } +{ return *slot_; } void named_slot_map_iterator::increment() { - ++impl_->slot_; - if (impl_->slot_ == impl_->group->second.end()) { - ++impl_->group; - impl_->init_next_group(); + ++slot_; + if (slot_ == group->second.end()) { + ++group; + init_next_group(); } } -bool +bool named_slot_map_iterator::equal(const named_slot_map_iterator& other) const { - return (impl_->group == other.impl_->group - && (impl_->group == impl_->last_group - || impl_->slot_ == other.impl_->slot_)); + return (group == other.group + && (group == last_group + || slot_ == other.slot_)); } -#if BOOST_WORKAROUND(BOOST_MSVC, <= 0x1701) +#if BOOST_WORKAROUND(_MSC_VER, <= 1400) void named_slot_map_iterator::decrement() { assert(false); } void named_slot_map_iterator::advance(difference_type) { assert(false); } #endif -named_slot_map::named_slot_map(const compare_type& compare) +named_slot_map::named_slot_map(const compare_type& compare) : groups(compare) { - impl_.reset(new impl(compare)); + clear(); } -named_slot_map::~named_slot_map() {} - -void named_slot_map::clear() { impl_->clear(); } +void named_slot_map::clear() +{ + groups.clear(); + groups[stored_group(stored_group::sk_front)]; + groups[stored_group(stored_group::sk_back)]; + back = groups.end(); + --back; +} named_slot_map::iterator named_slot_map::begin() { - typedef named_slot_map::iterator::impl iterator_impl; - - std::auto_ptr - it(new iterator_impl(impl_->groups.begin(), - impl_->groups.end())); - return named_slot_map::iterator(it); + return named_slot_map::iterator(groups.begin(), groups.end()); } named_slot_map::iterator named_slot_map::end() { - typedef named_slot_map::iterator::impl iterator_impl; - - std::auto_ptr - it(new iterator_impl(impl_->groups.end(), - impl_->groups.end())); - return named_slot_map::iterator(it); + return named_slot_map::iterator(groups.end(), groups.end()); } named_slot_map::iterator -named_slot_map::insert(const any& name, const connection& con, const any& slot, - connect_position at) +named_slot_map::insert(const stored_group& name, const connection& con, + const any& slot, connect_position at) { group_iterator group; if (name.empty()) { switch (at) { - case at_front: group = impl_->groups.begin(); break; - case at_back: group = impl_->back; break; + case at_front: group = groups.begin(); break; + case at_back: group = back; break; } } else { - group = impl_->groups.find(name); - if (group == impl_->groups.end()) { + group = groups.find(name); + if (group == groups.end()) { slot_container_type::value_type v(name, group_list()); - group = impl_->groups.insert(v).first; + group = groups.insert(v).first; } } - typedef named_slot_map::iterator::impl iterator_impl; - std::auto_ptr it(new iterator_impl); - it->group = group; - it->last_group = impl_->groups.end(); + iterator it; + it.group = group; + it.last_group = groups.end(); switch (at) { case at_back: group->second.push_back(connection_slot_pair(con, slot)); - it->slot_ = group->second.end(); - it->slot_assigned = true; - --(it->slot_); + it.slot_ = group->second.end(); + it.slot_assigned = true; + --(it.slot_); break; case at_front: group->second.push_front(connection_slot_pair(con, slot)); - it->slot_ = group->second.begin(); - it->slot_assigned = true; + it.slot_ = group->second.begin(); + it.slot_assigned = true; break; } - return iterator(it); + return it; } -void named_slot_map::disconnect(const any& name) +void named_slot_map::disconnect(const stored_group& name) { - group_iterator group = impl_->groups.find(name); - if (group != impl_->groups.end()) { + group_iterator group = groups.find(name); + if (group != groups.end()) { slot_pair_iterator i = group->second.begin(); while (i != group->second.end()) { slot_pair_iterator next = i; @@ -219,22 +142,22 @@ void named_slot_map::disconnect(const any& name) i->first.disconnect(); i = next; } - impl_->groups.erase(group); + groups.erase(group); } } void named_slot_map::erase(iterator pos) { // Erase the slot - pos.impl_->slot_->first.disconnect(); - // pos.impl_->group->second.erase(pos.impl_->slot_); ? + pos.slot_->first.disconnect(); + pos.group->second.erase(pos.slot_); } void named_slot_map::remove_disconnected_slots() { // Remove any disconnected slots - group_iterator g = impl_->groups.begin(); - while (g != impl_->groups.end()) { + group_iterator g = groups.begin(); + while (g != groups.end()) { slot_pair_iterator s = g->second.begin(); while (s != g->second.end()) { if (s->first.connected()) ++s; @@ -242,7 +165,7 @@ void named_slot_map::remove_disconnected_slots() } // Clear out empty groups - if (impl_->empty(g)) impl_->groups.erase(g++); + if (empty(g)) groups.erase(g++); else ++g; } } diff --git a/boost/libs/signals/src/signal_base.cpp b/boost/libs/signals/src/signal_base.cpp index e1f9bd7df9..759672d8cc 100644 --- a/boost/libs/signals/src/signal_base.cpp +++ b/boost/libs/signals/src/signal_base.cpp @@ -60,7 +60,7 @@ namespace boost { connection signal_base_impl:: connect_slot(const any& slot_, - const any& name, + const stored_group& name, shared_ptr data, connect_position at) { @@ -75,7 +75,7 @@ namespace boost { std::auto_ptr saved_iter(new iterator); // Add the slot to the list. - iterator pos = + iterator pos = slots_.insert(name, data->watch_bound_objects, slot_, at); // The assignment operation here absolutely must not throw, which @@ -87,9 +87,9 @@ namespace boost { // Fill out the connection object appropriately. None of these // operations can throw data->watch_bound_objects.get_connection()->signal = this; - data->watch_bound_objects.get_connection()->signal_data = + data->watch_bound_objects.get_connection()->signal_data = saved_iter.release(); - data->watch_bound_objects.get_connection()->signal_disconnect = + data->watch_bound_objects.get_connection()->signal_disconnect = &signal_base_impl::slot_disconnected; // Make the copy of the connection in the list disconnect when it is @@ -125,7 +125,7 @@ namespace boost { return count; } - void signal_base_impl::disconnect(const any& group) + void signal_base_impl::disconnect(const stored_group& group) { slots_.disconnect(group); } void signal_base_impl::slot_disconnected(void* obj, void* data) diff --git a/boost/libs/signals/src/slot.cpp b/boost/libs/signals/src/slot.cpp index 00fb43b4bf..7c296d6a48 100644 --- a/boost/libs/signals/src/slot.cpp +++ b/boost/libs/signals/src/slot.cpp @@ -24,6 +24,7 @@ namespace boost { // signal for the connection to be connected. con->signal = static_cast(this); con->signal_data = 0; + con->blocked_ = false ; con->signal_disconnect = &bound_object_destructed; } @@ -38,8 +39,8 @@ namespace boost { // Now notify each of the bound objects that they are connected to this // slot. - for(std::vector::iterator i = - data->bound_objects.begin(); + for(std::vector::iterator i = + data->bound_objects.begin(); i != data->bound_objects.end(); ++i) { // Notify the object that the slot is connecting to it BOOST_SIGNALS_NAMESPACE::detail::bound_object binding;