From eee966a7d81dbe6bea11c8a808e942021d180716 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Peter=20K=C3=BCmmel?= Date: Wed, 17 Feb 2010 20:54:47 +0000 Subject: [PATCH] boost: update to 1.42.0 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33490 a592a061-630c-0410-9148-cb99ea01b6c8 --- boost/boost/array.hpp | 12 + boost/boost/bind/bind.hpp | 20 +- boost/boost/bind/mem_fn_template.hpp | 81 ++- boost/boost/config/compiler/borland.hpp | 2 +- boost/boost/config/compiler/codegear.hpp | 21 +- boost/boost/config/compiler/visualc.hpp | 2 +- boost/boost/cstdint.hpp | 96 ++-- boost/boost/detail/interlocked.hpp | 16 +- boost/boost/detail/sp_typeinfo.hpp | 54 +- boost/boost/exception/all.hpp | 9 + .../exception/current_exception_cast.hpp | 9 + .../exception/detail/attribute_noreturn.hpp | 4 +- .../exception/detail/error_info_impl.hpp | 10 +- .../boost/exception/detail/exception_ptr.hpp | 490 ++++++++++++++++++ .../exception/detail/is_output_streamable.hpp | 9 + .../exception/detail/object_hex_dump.hpp | 14 +- boost/boost/exception/detail/type_info.hpp | 79 +-- .../exception/diagnostic_information.hpp | 136 +++-- boost/boost/exception/errinfo_errno.hpp | 9 + .../exception/errinfo_nested_exception.hpp | 17 + boost/boost/exception/exception.hpp | 74 ++- boost/boost/exception/get_error_info.hpp | 9 + boost/boost/exception/info.hpp | 16 +- boost/boost/exception/info_tuple.hpp | 9 + boost/boost/exception/to_string.hpp | 9 + boost/boost/exception/to_string_stub.hpp | 9 + boost/boost/function/function_base.hpp | 52 +- .../hash/detail/float_functions.hpp | 6 +- boost/boost/functional/hash/hash.hpp | 27 +- boost/boost/integer.hpp | 214 ++++++-- boost/boost/integer/integer_mask.hpp | 9 + boost/boost/integer/static_log2.hpp | 11 +- boost/boost/integer/static_min_max.hpp | 20 +- boost/boost/integer_fwd.hpp | 46 +- boost/boost/integer_traits.hpp | 27 +- boost/boost/memory_order.hpp | 22 +- boost/boost/regex/concepts.hpp | 94 ++++ boost/boost/regex/config.hpp | 6 + boost/boost/regex/icu.hpp | 26 +- boost/boost/regex/pending/object_cache.hpp | 2 + boost/boost/regex/pending/static_mutex.hpp | 2 +- boost/boost/regex/v4/basic_regex_creator.hpp | 119 ++++- boost/boost/regex/v4/basic_regex_parser.hpp | 406 +++++++++++---- boost/boost/regex/v4/cpp_regex_traits.hpp | 16 +- boost/boost/regex/v4/cregex.hpp | 43 +- boost/boost/regex/v4/error_type.hpp | 13 +- boost/boost/regex/v4/match_flags.hpp | 90 ++-- boost/boost/regex/v4/match_results.hpp | 190 +++++-- boost/boost/regex/v4/perl_matcher.hpp | 13 +- .../regex/v4/perl_matcher_non_recursive.hpp | 9 +- .../boost/regex/v4/perl_matcher_recursive.hpp | 2 +- boost/boost/regex/v4/regex_format.hpp | 485 +++++++++++++---- boost/boost/regex/v4/regex_replace.hpp | 33 +- .../boost/regex/v4/regex_traits_defaults.hpp | 4 +- boost/boost/regex/v4/states.hpp | 8 + boost/boost/regex/v4/u32regex_iterator.hpp | 2 +- .../regex/v4/u32regex_token_iterator.hpp | 6 +- boost/boost/smart_ptr/detail/lwm_pthreads.hpp | 11 +- .../smart_ptr/detail/quick_allocator.hpp | 5 +- .../boost/smart_ptr/detail/sp_convertible.hpp | 2 +- .../detail/sp_counted_base_gcc_sparc.hpp | 6 +- boost/boost/smart_ptr/detail/sp_has_sync.hpp | 2 +- boost/boost/smart_ptr/intrusive_ptr.hpp | 4 +- boost/boost/smart_ptr/make_shared.hpp | 4 +- boost/boost/smart_ptr/shared_ptr.hpp | 10 +- boost/boost/smart_ptr/weak_ptr.hpp | 16 +- boost/boost/throw_exception.hpp | 3 +- boost/boost/type_traits/has_new_operator.hpp | 47 +- boost/boost/type_traits/intrinsics.hpp | 2 +- boost/boost/type_traits/is_base_of_tr1.hpp | 50 ++ boost/boost/type_traits/is_signed.hpp | 10 +- boost/boost/type_traits/is_unsigned.hpp | 11 +- boost/boost/utility/value_init.hpp | 2 - boost/boost/version.hpp | 4 +- boost/libs/regex/src/cpp_regex_traits.cpp | 2 +- boost/libs/regex/src/cregex.cpp | 6 +- boost/libs/regex/src/fileiter.cpp | 21 +- boost/libs/regex/src/posix_api.cpp | 1 + .../libs/regex/src/regex_traits_defaults.cpp | 49 +- boost/libs/regex/src/static_mutex.cpp | 6 +- boost/libs/regex/src/usinstances.cpp | 3 + boost/libs/regex/src/wide_posix_api.cpp | 1 + 82 files changed, 2681 insertions(+), 816 deletions(-) create mode 100644 boost/boost/exception/detail/exception_ptr.hpp create mode 100644 boost/boost/exception/errinfo_nested_exception.hpp create mode 100644 boost/boost/type_traits/is_base_of_tr1.hpp diff --git a/boost/boost/array.hpp b/boost/boost/array.hpp index 8ef73c4250..d58b93ad54 100644 --- a/boost/boost/array.hpp +++ b/boost/boost/array.hpp @@ -24,6 +24,13 @@ #ifndef BOOST_ARRAY_HPP #define BOOST_ARRAY_HPP +#include + +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +# pragma warning(push) +# pragma warning(disable:4996) // 'std::equal': Function call with parameters that may be unsafe +#endif + #include #include #include @@ -320,4 +327,9 @@ namespace boost { } /* namespace boost */ + +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +# pragma warning(pop) +#endif + #endif /*BOOST_ARRAY_HPP*/ diff --git a/boost/boost/bind/bind.hpp b/boost/boost/bind/bind.hpp index 1e5c9e0324..a63d2a026b 100644 --- a/boost/boost/bind/bind.hpp +++ b/boost/boost/bind/bind.hpp @@ -207,6 +207,13 @@ public: } }; +#ifdef BOOST_MSVC +// MSVC is bright enough to realise that the parameter rhs +// in operator==may be unused for some template argument types: +#pragma warning(push) +#pragma warning(disable:4100) +#endif + template< class A1 > class list1: private storage1< A1 > { private: @@ -846,6 +853,10 @@ public: } }; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + // bind_t #ifndef BOOST_NO_VOID_RETURNS @@ -1629,7 +1640,7 @@ template _bi::bind_t< R, _mfi::dm, typename _bi::list_av_1::type > @@ -1654,7 +1665,14 @@ template< class M, class T > struct add_cref< M T::*, 0 > template< class M, class T > struct add_cref< M T::*, 1 > { +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4180) +#endif typedef M const & type; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif }; template< class R, class T > struct add_cref< R (T::*) (), 1 > diff --git a/boost/boost/bind/mem_fn_template.hpp b/boost/boost/bind/mem_fn_template.hpp index 1db0713b77..b26d585dbc 100644 --- a/boost/boost/bind/mem_fn_template.hpp +++ b/boost/boost/bind/mem_fn_template.hpp @@ -51,14 +51,16 @@ public: template R operator()(U & u) const { - BOOST_MEM_FN_RETURN call(u, &u); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template R operator()(U const & u) const { - BOOST_MEM_FN_RETURN call(u, &u); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p); } #endif @@ -109,7 +111,8 @@ public: template R operator()(U const & u) const { - BOOST_MEM_FN_RETURN call(u, &u); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p); } R operator()(T const & t) const @@ -164,14 +167,16 @@ public: template R operator()(U & u, A1 a1) const { - BOOST_MEM_FN_RETURN call(u, &u, a1); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template R operator()(U const & u, A1 a1) const { - BOOST_MEM_FN_RETURN call(u, &u, a1); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1); } #endif @@ -223,7 +228,8 @@ public: template R operator()(U const & u, A1 a1) const { - BOOST_MEM_FN_RETURN call(u, &u, a1); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1); } R operator()(T const & t, A1 a1) const @@ -276,14 +282,16 @@ public: template R operator()(U & u, A1 a1, A2 a2) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template R operator()(U const & u, A1 a1, A2 a2) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2); } #endif @@ -333,7 +341,8 @@ public: template R operator()(U const & u, A1 a1, A2 a2) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2); } R operator()(T const & t, A1 a1, A2 a2) const @@ -386,14 +395,16 @@ public: template R operator()(U & u, A1 a1, A2 a2, A3 a3) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template R operator()(U const & u, A1 a1, A2 a2, A3 a3) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3); } #endif @@ -443,7 +454,8 @@ public: template R operator()(U const & u, A1 a1, A2 a2, A3 a3) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3); } R operator()(T const & t, A1 a1, A2 a2, A3 a3) const @@ -496,14 +508,16 @@ public: template R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4); } #endif @@ -553,7 +567,8 @@ public: template R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4); } R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4) const @@ -606,14 +621,16 @@ public: template R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5); } #endif @@ -663,7 +680,8 @@ public: template R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5); } R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const @@ -716,14 +734,16 @@ public: template R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6); } #endif @@ -773,7 +793,8 @@ public: template R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6); } R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const @@ -826,14 +847,16 @@ public: template R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7); } #endif @@ -883,7 +906,8 @@ public: template R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7); } R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const @@ -936,14 +960,16 @@ public: template R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7, a8); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7, a8); } #ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS template R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7, a8); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7, a8); } #endif @@ -998,7 +1024,8 @@ public: template R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const { - BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7, a8); + U const * p = 0; + BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7, a8); } R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const diff --git a/boost/boost/config/compiler/borland.hpp b/boost/boost/config/compiler/borland.hpp index 91f064c68e..6a7b988d16 100644 --- a/boost/boost/config/compiler/borland.hpp +++ b/boost/boost/config/compiler/borland.hpp @@ -66,7 +66,6 @@ // Borland C++ Builder 6 and below: #if (__BORLANDC__ <= 0x564) -# define BOOST_NO_INTEGRAL_INT64_T # ifdef NDEBUG // fix broken so that Boost.test works: @@ -121,6 +120,7 @@ #endif // Borland C++ Builder 2008 and below: +# define BOOST_NO_INTEGRAL_INT64_T # define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL # define BOOST_NO_DEPENDENT_NESTED_DERIVATIONS # define BOOST_NO_MEMBER_TEMPLATE_FRIENDS diff --git a/boost/boost/config/compiler/codegear.hpp b/boost/boost/config/compiler/codegear.hpp index 3915cd54f9..698624ece2 100644 --- a/boost/boost/config/compiler/codegear.hpp +++ b/boost/boost/config/compiler/codegear.hpp @@ -19,8 +19,8 @@ #endif // // versions check: -// last known and checked version is 0x610 -#if (__CODEGEARC__ > 0x613) +// last known and checked version is 0x620 +#if (__CODEGEARC__ > 0x620) # if defined(BOOST_ASSERT_CONFIG) # error "Unknown compiler version - please run the configure tests and report the results" # else @@ -30,20 +30,24 @@ // CodeGear C++ Builder 2009 #if (__CODEGEARC__ <= 0x613) -# define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL +# define BOOST_NO_INTEGRAL_INT64_T # define BOOST_NO_DEPENDENT_NESTED_DERIVATIONS -# define BOOST_NO_MEMBER_TEMPLATE_FRIENDS # define BOOST_NO_PRIVATE_IN_AGGREGATE -# define BOOST_NO_TWO_PHASE_NAME_LOOKUP # define BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE -# define BOOST_NO_USING_TEMPLATE // we shouldn't really need this - but too many things choke // without it, this needs more investigation: # define BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS -# define BOOST_NO_TYPENAME_WITH_CTOR // Cannot use typename keyword when making temporaries of a dependant type -# define BOOST_NO_NESTED_FRIENDSHIP // TC1 gives nested classes access rights as any other member # define BOOST_SP_NO_SP_CONVERTIBLE +#endif +// CodeGear C++ Builder 2010 +#if (__CODEGEARC__ <= 0x620) +# define BOOST_NO_TYPENAME_WITH_CTOR // Cannot use typename keyword when making temporaries of a dependant type +# define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL +# define BOOST_NO_MEMBER_TEMPLATE_FRIENDS +# define BOOST_NO_NESTED_FRIENDSHIP // TC1 gives nested classes access rights as any other member +# define BOOST_NO_USING_TEMPLATE +# define BOOST_NO_TWO_PHASE_NAME_LOOKUP // Temporary hack, until specific MPL preprocessed headers are generated # define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS @@ -59,7 +63,6 @@ # endif #endif - // // C++0x macros: // diff --git a/boost/boost/config/compiler/visualc.hpp b/boost/boost/config/compiler/visualc.hpp index fd21f26bab..990901f048 100644 --- a/boost/boost/config/compiler/visualc.hpp +++ b/boost/boost/config/compiler/visualc.hpp @@ -125,7 +125,7 @@ #if (_MSC_VER >= 1200) # define BOOST_HAS_MS_INT64 #endif -#if (_MSC_VER >= 1310) && defined(_MSC_EXTENSIONS) +#if (_MSC_VER >= 1310) && (defined(_MSC_EXTENSIONS) || (_MSC_VER >= 1500)) # define BOOST_HAS_LONG_LONG #else # define BOOST_NO_LONG_LONG diff --git a/boost/boost/cstdint.hpp b/boost/boost/cstdint.hpp index d55a4840b9..47e6a160c6 100644 --- a/boost/boost/cstdint.hpp +++ b/boost/boost/cstdint.hpp @@ -23,10 +23,25 @@ #ifndef BOOST_CSTDINT_HPP #define BOOST_CSTDINT_HPP -#include +// +// Since we always define the INT#_C macros as per C++0x, +// define __STDC_CONSTANT_MACROS so that does the right +// thing if possible, and so that the user knows that the macros +// are actually defined as per C99. +// +#ifndef __STDC_CONSTANT_MACROS +# define __STDC_CONSTANT_MACROS +#endif +#include -#ifdef BOOST_HAS_STDINT_H +// +// Note that GLIBC is a bit inconsistent about whether int64_t is defined or not +// depending upon what headers happen to have been included first... +// so we disable use of stdint.h when GLIBC does not define __GLIBC_HAVE_LONG_LONG. +// See https://svn.boost.org/trac/boost/ticket/3548 and http://sources.redhat.com/bugzilla/show_bug.cgi?id=10990 +// +#if defined(BOOST_HAS_STDINT_H) && (!defined(__GLIBC__) || defined(__GLIBC_HAVE_LONG_LONG)) // The following #include is an implementation artifact; not part of interface. # ifdef __hpux @@ -220,6 +235,15 @@ namespace boost typedef unsigned short uint_least16_t; typedef unsigned short uint_fast16_t; # endif +# elif (USHRT_MAX == 0xffffffff) && defined(__MTA__) + // On MTA / XMT short is 32 bits unless the -short16 compiler flag is specified + // MTA / XMT does support the following non-standard integer types + typedef __short16 int16_t; + typedef __short16 int_least16_t; + typedef __short16 int_fast16_t; + typedef unsigned __short16 uint16_t; + typedef unsigned __short16 uint_least16_t; + typedef unsigned __short16 uint_fast16_t; # elif (USHRT_MAX == 0xffffffff) && defined(CRAY) // no 16-bit types on Cray: typedef short int_least16_t; @@ -246,6 +270,14 @@ namespace boost typedef unsigned int uint32_t; typedef unsigned int uint_least32_t; typedef unsigned int uint_fast32_t; +# elif (UINT_MAX == 0xffffffffffffffff) && defined(__MTA__) + // Integers are 64 bits on the MTA / XMT + typedef __int32 int32_t; + typedef __int32 int_least32_t; + typedef __int32 int_fast32_t; + typedef unsigned __int32 uint32_t; + typedef unsigned __int32 uint_least32_t; + typedef unsigned __int32 uint_fast32_t; # else # error defaults not correct; you must hand modify boost/cstdint.hpp # endif @@ -326,19 +358,16 @@ namespace boost Macro definition section: -Define various INTXX_C macros only if -__STDC_CONSTANT_MACROS is defined. - -Undefine the macros if __STDC_CONSTANT_MACROS is -not defined and the macros are (cf ). - Added 23rd September 2000 (John Maddock). Modified 11th September 2001 to be excluded when BOOST_HAS_STDINT_H is defined (John Maddock). +Modified 11th Dec 2009 to always define the +INT#_C macros if they're not already defined (John Maddock). ******************************************************/ -#if defined(__STDC_CONSTANT_MACROS) && !defined(BOOST__STDC_CONSTANT_MACROS_DEFINED) && !defined(BOOST_HAS_STDINT_H) +#if !defined(BOOST__STDC_CONSTANT_MACROS_DEFINED) && !defined(INT8_C) +#include # define BOOST__STDC_CONSTANT_MACROS_DEFINED # if defined(BOOST_HAS_MS_INT64) // @@ -390,27 +419,40 @@ BOOST_HAS_STDINT_H is defined (John Maddock). // 64-bit types + intmax_t and uintmax_t ----------------------------------// # if defined(BOOST_HAS_LONG_LONG) && \ - (defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX)) + (defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX) || defined(_LLONG_MAX)) # if defined(__hpux) - // HP-UX's value of ULONG_LONG_MAX is unusable in preprocessor expressions -# elif (defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615U) || \ - (defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615U) || \ - (defined(ULONGLONG_MAX) && ULONGLONG_MAX == 18446744073709551615U) - + // HP-UX's value of ULONG_LONG_MAX is unusable in preprocessor expressions +# define INT64_C(value) value##LL +# define UINT64_C(value) value##uLL +# elif (defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615ULL) || \ + (defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615ULL) || \ + (defined(ULONGLONG_MAX) && ULONGLONG_MAX == 18446744073709551615ULL) || \ + (defined(_LLONG_MAX) && _LLONG_MAX == 18446744073709551615ULL) + +# define INT64_C(value) value##LL +# define UINT64_C(value) value##uLL # else # error defaults not correct; you must hand modify boost/cstdint.hpp # endif -# define INT64_C(value) value##LL -# define UINT64_C(value) value##uLL # elif ULONG_MAX != 0xffffffff -# if ULONG_MAX == 18446744073709551615 // 2**64 - 1 +# if ULONG_MAX == 18446744073709551615U // 2**64 - 1 # define INT64_C(value) value##L # define UINT64_C(value) value##uL # else # error defaults not correct; you must hand modify boost/cstdint.hpp # endif +# elif defined(BOOST_HAS_LONG_LONG) + // Usual macros not defined, work things out for ourselves: +# if(~0uLL == 18446744073709551615ULL) +# define INT64_C(value) value##LL +# define UINT64_C(value) value##uLL +# else +# error defaults not correct; you must hand modify boost/cstdint.hpp +# endif +# else +# error defaults not correct; you must hand modify boost/cstdint.hpp # endif # ifdef BOOST_NO_INT64_T @@ -423,23 +465,7 @@ BOOST_HAS_STDINT_H is defined (John Maddock). # endif // Borland/Microsoft specific width suffixes - -#elif defined(BOOST__STDC_CONSTANT_MACROS_DEFINED) && !defined(__STDC_CONSTANT_MACROS) && !defined(BOOST_HAS_STDINT_H) -// -// undef all the macros: -// -# undef INT8_C -# undef INT16_C -# undef INT32_C -# undef INT64_C -# undef UINT8_C -# undef UINT16_C -# undef UINT32_C -# undef UINT64_C -# undef INTMAX_C -# undef UINTMAX_C - -#endif // __STDC_CONSTANT_MACROS_DEFINED etc. +#endif // INT#_C macros. diff --git a/boost/boost/detail/interlocked.hpp b/boost/boost/detail/interlocked.hpp index b6c8d75001..fccebc3f70 100644 --- a/boost/boost/detail/interlocked.hpp +++ b/boost/boost/detail/interlocked.hpp @@ -54,11 +54,23 @@ extern "C" long __cdecl InterlockedExchangeAdd( long*, long ); #elif defined( BOOST_MSVC ) || defined( BOOST_INTEL_WIN ) +#if defined( __CLRCALL_PURE_OR_CDECL ) + +extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedIncrement( long volatile * ); +extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedDecrement( long volatile * ); +extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedCompareExchange( long volatile *, long, long ); +extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedExchange( long volatile *, long ); +extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedExchangeAdd( long volatile *, long ); + +#else + extern "C" long __cdecl _InterlockedIncrement( long volatile * ); extern "C" long __cdecl _InterlockedDecrement( long volatile * ); extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long ); -extern "C" long __cdecl _InterlockedExchange( long volatile *, long); -extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long); +extern "C" long __cdecl _InterlockedExchange( long volatile *, long ); +extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long ); + +#endif # pragma intrinsic( _InterlockedIncrement ) # pragma intrinsic( _InterlockedDecrement ) diff --git a/boost/boost/detail/sp_typeinfo.hpp b/boost/boost/detail/sp_typeinfo.hpp index e78c94316a..636fe277bc 100755 --- a/boost/boost/detail/sp_typeinfo.hpp +++ b/boost/boost/detail/sp_typeinfo.hpp @@ -19,20 +19,66 @@ #if defined( BOOST_NO_TYPEID ) +#include +#include + namespace boost { namespace detail { -typedef void* sp_typeinfo; +class sp_typeinfo +{ +private: + + sp_typeinfo( sp_typeinfo const& ); + sp_typeinfo& operator=( sp_typeinfo const& ); + + char const * name_; + +public: + + explicit sp_typeinfo( char const * name ): name_( name ) + { + } + + bool operator==( sp_typeinfo const& rhs ) const + { + return this == &rhs; + } + + bool operator!=( sp_typeinfo const& rhs ) const + { + return this != &rhs; + } + + bool before( sp_typeinfo const& rhs ) const + { + return std::less< sp_typeinfo const* >()( this, &rhs ); + } + + char const* name() const + { + return name_; + } +}; template struct sp_typeid_ { - static char v_; + static sp_typeinfo ti_; + + static char const * name() + { + return BOOST_CURRENT_FUNCTION; + } }; -template char sp_typeid_< T >::v_; +template sp_typeinfo sp_typeid_< T >::ti_( sp_typeid_< T >::name() ); + +template struct sp_typeid_< T & >: sp_typeid_< T > +{ +}; template struct sp_typeid_< T const >: sp_typeid_< T > { @@ -50,7 +96,7 @@ template struct sp_typeid_< T const volatile >: sp_typeid_< T > } // namespace boost -#define BOOST_SP_TYPEID(T) (&boost::detail::sp_typeid_::v_) +#define BOOST_SP_TYPEID(T) (boost::detail::sp_typeid_::ti_) #else diff --git a/boost/boost/exception/all.hpp b/boost/boost/exception/all.hpp index c47738b2c6..9ffe42a9d0 100644 --- a/boost/boost/exception/all.hpp +++ b/boost/boost/exception/all.hpp @@ -5,6 +5,12 @@ #ifndef UUID_316FDA946C0D11DEA9CBAE5255D89593 #define UUID_316FDA946C0D11DEA9CBAE5255D89593 +#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma GCC system_header +#endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(push,1) +#endif #include #include @@ -24,4 +30,7 @@ #include #endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(pop) +#endif #endif diff --git a/boost/boost/exception/current_exception_cast.hpp b/boost/boost/exception/current_exception_cast.hpp index 228b6ea10e..af2f153113 100644 --- a/boost/boost/exception/current_exception_cast.hpp +++ b/boost/boost/exception/current_exception_cast.hpp @@ -5,6 +5,12 @@ #ifndef UUID_7E83C166200811DE885E826156D89593 #define UUID_7E83C166200811DE885E826156D89593 +#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma GCC system_header +#endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(push,1) +#endif namespace boost @@ -31,4 +37,7 @@ boost } } +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(pop) +#endif #endif diff --git a/boost/boost/exception/detail/attribute_noreturn.hpp b/boost/boost/exception/detail/attribute_noreturn.hpp index 1cb0763efd..f6a0b5903e 100644 --- a/boost/boost/exception/detail/attribute_noreturn.hpp +++ b/boost/boost/exception/detail/attribute_noreturn.hpp @@ -6,9 +6,7 @@ #ifndef UUID_61531AB0680611DEADD5846855D89593 #define UUID_61531AB0680611DEADD5846855D89593 -#include - -#if defined(BOOST_MSVC) +#if defined(_MSC_VER) #define BOOST_ATTRIBUTE_NORETURN __declspec(noreturn) #elif defined(__GNUC__) #define BOOST_ATTRIBUTE_NORETURN __attribute__((noreturn)) diff --git a/boost/boost/exception/detail/error_info_impl.hpp b/boost/boost/exception/detail/error_info_impl.hpp index a25d066fd1..32113b1391 100644 --- a/boost/boost/exception/detail/error_info_impl.hpp +++ b/boost/boost/exception/detail/error_info_impl.hpp @@ -5,6 +5,12 @@ #ifndef UUID_CE6983AC753411DDA764247956D89593 #define UUID_CE6983AC753411DDA764247956D89593 +#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma GCC system_header +#endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(push,1) +#endif #include @@ -24,7 +30,6 @@ boost protected: - virtual ~error_info_base() throw() { } @@ -64,4 +69,7 @@ boost }; } +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(pop) +#endif #endif diff --git a/boost/boost/exception/detail/exception_ptr.hpp b/boost/boost/exception/detail/exception_ptr.hpp new file mode 100644 index 0000000000..78db17c065 --- /dev/null +++ b/boost/boost/exception/detail/exception_ptr.hpp @@ -0,0 +1,490 @@ +//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. + +//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 UUID_618474C2DE1511DEB74A388C56D89593 +#define UUID_618474C2DE1511DEB74A388C56D89593 +#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma GCC system_header +#endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(push,1) +#endif + +#include +#ifdef BOOST_NO_EXCEPTIONS +#error This header requires exception handling to be enabled. +#endif +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +boost + { +#ifndef BOOST_NO_RTTI + typedef error_info original_exception_type; + + inline + std::string + to_string( original_exception_type const & x ) + { + return x.value()->name(); + } +#endif + + class exception_ptr; + exception_ptr current_exception(); + void rethrow_exception( exception_ptr const & ); + + class + exception_ptr + { + typedef bool exception_ptr::*unspecified_bool_type; + friend exception_ptr current_exception(); + friend void rethrow_exception( exception_ptr const & ); + + shared_ptr c_; + bool bad_alloc_; + + struct + bad_alloc_tag + { + }; + + explicit + exception_ptr( bad_alloc_tag ): + bad_alloc_(true) + { + } + + explicit + exception_ptr( shared_ptr const & c ): + c_(c), + bad_alloc_(false) + { + BOOST_ASSERT(c); + } + + void + rethrow() const + { + BOOST_ASSERT(*this); + if( bad_alloc_ ) + throw enable_current_exception(std::bad_alloc()); + else + c_->rethrow(); + } + + bool + empty() const + { + return !bad_alloc_ && !c_; + } + + public: + + exception_ptr(): + bad_alloc_(false) + { + } + + ~exception_ptr() throw() + { + } + + operator unspecified_bool_type() const + { + return empty() ? 0 : &exception_ptr::bad_alloc_; + } + + friend + bool + operator==( exception_ptr const & a, exception_ptr const & b ) + { + return a.c_==b.c_ && a.bad_alloc_==b.bad_alloc_; + } + + friend + bool + operator!=( exception_ptr const & a, exception_ptr const & b ) + { + return !(a==b); + } + }; + + class + unknown_exception: + public exception, + public std::exception, + public exception_detail::clone_base + { + public: + + unknown_exception() + { + } + + explicit + unknown_exception( std::exception const & e ) + { + add_original_type(e); + } + + explicit + unknown_exception( boost::exception const & e ): + boost::exception(e) + { + add_original_type(e); + } + + ~unknown_exception() throw() + { + } + + private: + + exception_detail::clone_base const * + clone() const + { + return new unknown_exception(*this); + } + + void + rethrow() const + { + throw*this; + } + + template + void + add_original_type( E const & e ) + { +#ifndef BOOST_NO_RTTI + (*this) << original_exception_type(&typeid(e)); +#endif + } + }; + + namespace + exception_detail + { + template + class + current_exception_std_exception_wrapper: + public T, + public boost::exception, + public clone_base + { + public: + + explicit + current_exception_std_exception_wrapper( T const & e1 ): + T(e1) + { + add_original_type(e1); + } + + current_exception_std_exception_wrapper( T const & e1, boost::exception const & e2 ): + T(e1), + boost::exception(e2) + { + add_original_type(e1); + } + + ~current_exception_std_exception_wrapper() throw() + { + } + + private: + + clone_base const * + clone() const + { + return new current_exception_std_exception_wrapper(*this); + } + + void + rethrow() const + { + throw *this; + } + + template + void + add_original_type( E const & e ) + { +#ifndef BOOST_NO_RTTI + (*this) << original_exception_type(&typeid(e)); +#endif + } + }; + +#ifdef BOOST_NO_RTTI + template + exception const * + get_boost_exception( T const * ) + { + try + { + throw; + } + catch( + exception & x ) + { + return &x; + } + catch(...) + { + return 0; + } + } +#else + template + exception const * + get_boost_exception( T const * x ) + { + return dynamic_cast(x); + } +#endif + + template + inline + shared_ptr + current_exception_std_exception( T const & e1 ) + { + if( boost::exception const * e2 = get_boost_exception(&e1) ) + return shared_ptr const>(new current_exception_std_exception_wrapper(e1,*e2)); + else + return shared_ptr const>(new current_exception_std_exception_wrapper(e1)); + } + + inline + shared_ptr + current_exception_unknown_exception() + { + return shared_ptr(new unknown_exception()); + } + + inline + shared_ptr + current_exception_unknown_boost_exception( boost::exception const & e ) + { + return shared_ptr(new unknown_exception(e)); + } + + inline + shared_ptr + current_exception_unknown_std_exception( std::exception const & e ) + { + if( boost::exception const * be = get_boost_exception(&e) ) + return current_exception_unknown_boost_exception(*be); + else + return shared_ptr(new unknown_exception(e)); + } + + inline + shared_ptr + current_exception_impl() + { + try + { + throw; + } + catch( + exception_detail::clone_base & e ) + { + return shared_ptr(e.clone()); + } + catch( + std::domain_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::invalid_argument & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::length_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::out_of_range & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::logic_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::range_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::overflow_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::underflow_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::ios_base::failure & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::runtime_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::bad_alloc & e ) + { + return exception_detail::current_exception_std_exception(e); + } +#ifndef BOOST_NO_TYPEID + catch( + std::bad_cast & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::bad_typeid & e ) + { + return exception_detail::current_exception_std_exception(e); + } +#endif + catch( + std::bad_exception & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::exception & e ) + { + return exception_detail::current_exception_unknown_std_exception(e); + } + catch( + boost::exception & e ) + { + return exception_detail::current_exception_unknown_boost_exception(e); + } + catch( + ... ) + { + return exception_detail::current_exception_unknown_exception(); + } + } + } + + inline + exception_ptr + current_exception() + { + try + { + return exception_ptr(exception_detail::current_exception_impl()); + } + catch( + std::bad_alloc & ) + { + } + catch( + ... ) + { + try + { + return exception_ptr(exception_detail::current_exception_std_exception(std::bad_exception())); + } + catch( + std::bad_alloc & ) + { + } + catch( + ... ) + { + BOOST_ASSERT(0); + } + } + return exception_ptr(exception_ptr::bad_alloc_tag()); + } + + template + inline + exception_ptr + copy_exception( T const & e ) + { + try + { + throw enable_current_exception(e); + } + catch( + ... ) + { + return current_exception(); + } + } + + inline + void + rethrow_exception( exception_ptr const & p ) + { + p.rethrow(); + } + + inline + std::string + diagnostic_information( exception_ptr const & p ) + { + if( p ) + try + { + rethrow_exception(p); + } + catch( + ... ) + { + return current_exception_diagnostic_information(); + } + return ""; + } + + inline + std::string + to_string( exception_ptr const & p ) + { + std::string s='\n'+diagnostic_information(p); + std::string padding(" "); + std::string r; + bool f=false; + for( std::string::const_iterator i=s.begin(),e=s.end(); i!=e; ++i ) + { + if( f ) + r+=padding; + char c=*i; + r+=c; + f=(c=='\n'); + } + return r; + } + } + +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(pop) +#endif +#endif diff --git a/boost/boost/exception/detail/is_output_streamable.hpp b/boost/boost/exception/detail/is_output_streamable.hpp index af59cb8d2f..5eb1695d2a 100755 --- a/boost/boost/exception/detail/is_output_streamable.hpp +++ b/boost/boost/exception/detail/is_output_streamable.hpp @@ -5,6 +5,12 @@ #ifndef UUID_898984B4076411DD973EDFA055D89593 #define UUID_898984B4076411DD973EDFA055D89593 +#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma GCC system_header +#endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(push,1) +#endif #include @@ -35,4 +41,7 @@ boost }; } +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(pop) +#endif #endif diff --git a/boost/boost/exception/detail/object_hex_dump.hpp b/boost/boost/exception/detail/object_hex_dump.hpp index f535944ea2..ccf1bac3f7 100755 --- a/boost/boost/exception/detail/object_hex_dump.hpp +++ b/boost/boost/exception/detail/object_hex_dump.hpp @@ -5,12 +5,19 @@ #ifndef UUID_6F463AC838DF11DDA3E6909F56D89593 #define UUID_6F463AC838DF11DDA3E6909F56D89593 +#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma GCC system_header +#endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(push,1) +#endif #include #include #include #include #include +#include namespace boost @@ -21,11 +28,11 @@ boost template inline std::string - object_hex_dump( T const & x, size_t max_size=16 ) + object_hex_dump( T const & x, std::size_t max_size=16 ) { std::ostringstream s; s << "type: " << type_name() << ", size: " << sizeof(T) << ", dump: "; - size_t n=sizeof(T)>max_size?max_size:sizeof(T); + std::size_t n=sizeof(T)>max_size?max_size:sizeof(T); s.fill('0'); s.width(2); unsigned char const * b=reinterpret_cast(&x); @@ -37,4 +44,7 @@ boost } } +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(pop) +#endif #endif diff --git a/boost/boost/exception/detail/type_info.hpp b/boost/boost/exception/detail/type_info.hpp index ac0960db68..60709a1f6c 100644 --- a/boost/boost/exception/detail/type_info.hpp +++ b/boost/boost/exception/detail/type_info.hpp @@ -5,9 +5,16 @@ #ifndef UUID_C3E1741C754311DDB2834CCA55D89593 #define UUID_C3E1741C754311DDB2834CCA55D89593 +#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma GCC system_header +#endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(push,1) +#endif #include #include +#include namespace boost @@ -39,92 +46,34 @@ boost namespace exception_detail { -#ifdef BOOST_NO_TYPEID struct type_info_ { - detail::sp_typeinfo type_; - char const * name_; - - explicit - type_info_( detail::sp_typeinfo type, char const * name ): - type_(type), - name_(name) - { - } - - friend - bool - operator==( type_info_ const & a, type_info_ const & b ) - { - return a.type_==b.type_; - } - - friend - bool - operator<( type_info_ const & a, type_info_ const & b ) - { - return a.type_before(*b.type_)); - } - - char const * - name() const - { - return type_->name(); + return 0!=(a.type_.before(b.type_)); } }; -#endif - - inline - bool - operator!=( type_info_ const & a, type_info_ const & b ) - { - return !(a==b); - } } } -#define BOOST_EXCEPTION_STATIC_TYPEID(T) ::boost::exception_detail::type_info_(BOOST_SP_TYPEID(T),::boost::tag_type_name()) +#define BOOST_EXCEPTION_STATIC_TYPEID(T) ::boost::exception_detail::type_info_(BOOST_SP_TYPEID(T)) #ifndef BOOST_NO_RTTI #define BOOST_EXCEPTION_DYNAMIC_TYPEID(x) ::boost::exception_detail::type_info_(typeid(x)) #endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(pop) +#endif #endif diff --git a/boost/boost/exception/diagnostic_information.hpp b/boost/boost/exception/diagnostic_information.hpp index 1ea9dc1bab..632a5a3339 100755 --- a/boost/boost/exception/diagnostic_information.hpp +++ b/boost/boost/exception/diagnostic_information.hpp @@ -5,42 +5,79 @@ #ifndef UUID_0552D49838DD11DD90146B8956D89593 #define UUID_0552D49838DD11DD90146B8956D89593 +#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma GCC system_header +#endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(push,1) +#endif #include #include -#include #include +#include #include #include #include +#ifndef BOOST_NO_EXCEPTIONS +#include namespace boost { namespace exception_detail { - template - struct - enable_boost_exception_overload + std::string diagnostic_information_impl( boost::exception const *, std::exception const *, bool ); + } + + inline + std::string + current_exception_diagnostic_information() + { + boost::exception const * be=current_exception_cast(); + std::exception const * se=current_exception_cast(); + if( be || se ) + return exception_detail::diagnostic_information_impl(be,se,true); + else + return "No diagnostic information available."; + } + } +#endif + +namespace +boost + { + namespace + exception_detail + { + inline + exception const * + get_boost_exception( exception const * e ) { - struct yes { char q[100]; }; - typedef char no; - static yes check(exception const *); - static no check(...); - enum e { value=sizeof(check((T*)0))==sizeof(yes) }; - }; + return e; + } - template - struct - enable_std_exception_overload + inline + exception const * + get_boost_exception( ... ) + { + return 0; + } + + inline + std::exception const * + get_std_exception( std::exception const * e ) + { + return e; + } + + inline + std::exception const * + get_std_exception( ... ) { - struct yes { char q[100]; }; - typedef char no; - static yes check(std::exception const *); - static no check(...); - enum e { value = !enable_boost_exception_overload::value && sizeof(check((T*)0))==sizeof(yes) }; - }; + return 0; + } inline char const * @@ -65,12 +102,13 @@ boost std::string diagnostic_information_impl( boost::exception const * be, std::exception const * se, bool with_what ) { - BOOST_ASSERT(be||se); + if( !be && !se ) + return "Unknown exception."; #ifndef BOOST_NO_RTTI - if( !se ) - se = dynamic_cast(be); if( !be ) - be = dynamic_cast(se); + be=dynamic_cast(se); + if( !se ) + se=dynamic_cast(be); #endif char const * wh=0; if( with_what && se ) @@ -97,7 +135,7 @@ boost } #ifndef BOOST_NO_RTTI tmp << std::string("Dynamic exception type: ") << - (be?BOOST_EXCEPTION_DYNAMIC_TYPEID(*be):BOOST_EXCEPTION_DYNAMIC_TYPEID(*se)).name() << '\n'; + (be?BOOST_EXCEPTION_DYNAMIC_TYPEID(*be):BOOST_EXCEPTION_DYNAMIC_TYPEID(*se)).type_.name() << '\n'; #endif if( with_what && se ) tmp << "std::exception::what: " << wh << '\n'; @@ -110,19 +148,10 @@ boost } template - inline - typename enable_if,std::string>::type - diagnostic_information( T const & e ) - { - return exception_detail::diagnostic_information_impl(&e,0,true); - } - - template - inline - typename enable_if,std::string>::type + std::string diagnostic_information( T const & e ) { - return exception_detail::diagnostic_information_impl(0,&e,true); + return exception_detail::diagnostic_information_impl(exception_detail::get_boost_exception(&e),exception_detail::get_std_exception(&e),true); } inline @@ -147,40 +176,7 @@ boost } } -#ifndef BOOST_NO_EXCEPTIONS -#include -namespace -boost - { - inline - std::string - current_exception_diagnostic_information() - { - boost::exception const * be=current_exception_cast(); - std::exception const * se=current_exception_cast(); - if( be || se ) - return exception_detail::diagnostic_information_impl(be,se,true); - else - return "No diagnostic information available."; - } - - inline - std::string - diagnostic_information( exception_detail::exception_ptr_base const & p ) - { - if( !p._empty() ) - try - { - p._rethrow(); - } - catch( - ... ) - { - return current_exception_diagnostic_information(); - } - return ""; - } - } +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(pop) #endif - #endif diff --git a/boost/boost/exception/errinfo_errno.hpp b/boost/boost/exception/errinfo_errno.hpp index 310ceb78d0..ea74010c94 100644 --- a/boost/boost/exception/errinfo_errno.hpp +++ b/boost/boost/exception/errinfo_errno.hpp @@ -5,6 +5,12 @@ #ifndef UUID_F0EE17BE6C1211DE87FF459155D89593 #define UUID_F0EE17BE6C1211DE87FF459155D89593 +#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma GCC system_header +#endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(push,1) +#endif #include "boost/exception/info.hpp" #include @@ -32,4 +38,7 @@ boost } } +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(pop) +#endif #endif diff --git a/boost/boost/exception/errinfo_nested_exception.hpp b/boost/boost/exception/errinfo_nested_exception.hpp new file mode 100644 index 0000000000..de055e035f --- /dev/null +++ b/boost/boost/exception/errinfo_nested_exception.hpp @@ -0,0 +1,17 @@ +//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. + +//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 UUID_45CC9A82B77511DEB330FC4956D89593 +#define UUID_45CC9A82B77511DEB330FC4956D89593 + +namespace +boost + { + template class error_info; + class exception_ptr; + typedef error_info errinfo_nested_exception; + } + +#endif diff --git a/boost/boost/exception/exception.hpp b/boost/boost/exception/exception.hpp index e7faf594c4..79b273999c 100755 --- a/boost/boost/exception/exception.hpp +++ b/boost/boost/exception/exception.hpp @@ -5,6 +5,12 @@ #ifndef UUID_274DA366004E11DCB1DDFE2E56D89593 #define UUID_274DA366004E11DCB1DDFE2E56D89593 +#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma GCC system_header +#endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(push,1) +#endif namespace boost @@ -129,6 +135,15 @@ boost template E const & operator<<( E const &, error_info const & ); + template + E const & operator<<( E const &, throw_function const & ); + + template + E const & operator<<( E const &, throw_file const & ); + + template + E const & operator<<( E const &, throw_line const & ); + class exception; template @@ -151,7 +166,6 @@ boost protected: - virtual ~error_info_container() throw() { } @@ -202,34 +216,19 @@ boost #endif ; +#if defined(__MWERKS__) && __MWERKS__<=0x3207 + public: +#else private: template - friend - E const & - operator<<( E const & x, throw_function const & y ) - { - x.throw_function_=y.v_; - return x; - } + friend E const & operator<<( E const &, throw_function const & ); template - friend - E const & - operator<<( E const & x, throw_file const & y ) - { - x.throw_file_=y.v_; - return x; - } + friend E const & operator<<( E const &, throw_file const & ); template - friend - E const & - operator<<( E const & x, throw_line const & y ) - { - x.throw_line_=y.v_; - return x; - } + friend E const & operator<<( E const &, throw_line const & ); friend char const * exception_detail::get_diagnostic_information( exception const &, char const * ); @@ -241,7 +240,7 @@ boost friend struct exception_detail::get_info; friend struct exception_detail::get_info; friend struct exception_detail::get_info; - +#endif mutable exception_detail::refcount_ptr data_; mutable char const * throw_function_; mutable char const * throw_file_; @@ -254,6 +253,30 @@ boost { } + template + E const & + operator<<( E const & x, throw_function const & y ) + { + x.throw_function_=y.v_; + return x; + } + + template + E const & + operator<<( E const & x, throw_file const & y ) + { + x.throw_file_=y.v_; + return x; + } + + template + E const & + operator<<( E const & x, throw_line const & y ) + { + x.throw_line_=y.v_; + return x; + } + //////////////////////////////////////////////////////////////////////// namespace @@ -303,7 +326,7 @@ boost struct enable_error_info_return_type { - typedef typename enable_error_info_helper::type type; + typedef typename enable_error_info_helper::type type; }; } @@ -393,4 +416,7 @@ boost } } +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(pop) +#endif #endif diff --git a/boost/boost/exception/get_error_info.hpp b/boost/boost/exception/get_error_info.hpp index 640a612f3d..046f05aeef 100644 --- a/boost/boost/exception/get_error_info.hpp +++ b/boost/boost/exception/get_error_info.hpp @@ -5,6 +5,12 @@ #ifndef UUID_1A590226753311DD9E4CCF6156D89593 #define UUID_1A590226753311DD9E4CCF6156D89593 +#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma GCC system_header +#endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(push,1) +#endif #include #include @@ -118,4 +124,7 @@ boost #endif } +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(pop) +#endif #endif diff --git a/boost/boost/exception/info.hpp b/boost/boost/exception/info.hpp index c1b76c02cf..cbbc2c0b2f 100755 --- a/boost/boost/exception/info.hpp +++ b/boost/boost/exception/info.hpp @@ -5,11 +5,18 @@ #ifndef UUID_8D22C4CA9CC811DCAA9133D256D89593 #define UUID_8D22C4CA9CC811DCAA9133D256D89593 +#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma GCC system_header +#endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(push,1) +#endif #include #include #include #include +#include #include namespace @@ -90,7 +97,7 @@ boost { shared_ptr const & p = i->second; #ifndef BOOST_NO_RTTI - BOOST_ASSERT( BOOST_EXCEPTION_DYNAMIC_TYPEID(*p)==ti ); + BOOST_ASSERT( BOOST_EXCEPTION_DYNAMIC_TYPEID(*p).type_==ti.type_ ); #endif return p; } @@ -146,12 +153,15 @@ boost { typedef error_info error_info_tag_t; shared_ptr p( new error_info_tag_t(v) ); - exception_detail::error_info_container * c; - if( !(c=x.data_.get()) ) + exception_detail::error_info_container * c=x.data_.get(); + if( !c ) x.data_.adopt(c=new exception_detail::error_info_container_impl); c->set(p,BOOST_EXCEPTION_STATIC_TYPEID(error_info_tag_t)); return x; } } +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(pop) +#endif #endif diff --git a/boost/boost/exception/info_tuple.hpp b/boost/boost/exception/info_tuple.hpp index 38b2512626..34afe421b1 100755 --- a/boost/boost/exception/info_tuple.hpp +++ b/boost/boost/exception/info_tuple.hpp @@ -5,6 +5,12 @@ #ifndef UUID_63EE924290FB11DC87BB856555D89593 #define UUID_63EE924290FB11DC87BB856555D89593 +#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma GCC system_header +#endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(push,1) +#endif #include #include @@ -64,4 +70,7 @@ boost } } +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(pop) +#endif #endif diff --git a/boost/boost/exception/to_string.hpp b/boost/boost/exception/to_string.hpp index 5d88efa467..59bf83d4c0 100755 --- a/boost/boost/exception/to_string.hpp +++ b/boost/boost/exception/to_string.hpp @@ -5,6 +5,12 @@ #ifndef UUID_7E48761AD92811DC9011477D56D89593 #define UUID_7E48761AD92811DC9011477D56D89593 +#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma GCC system_header +#endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(push,1) +#endif #include #include @@ -71,4 +77,7 @@ boost } } +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(pop) +#endif #endif diff --git a/boost/boost/exception/to_string_stub.hpp b/boost/boost/exception/to_string_stub.hpp index 4b7028144f..e41d369775 100755 --- a/boost/boost/exception/to_string_stub.hpp +++ b/boost/boost/exception/to_string_stub.hpp @@ -5,6 +5,12 @@ #ifndef UUID_E788439ED9F011DCB181F25B55D89593 #define UUID_E788439ED9F011DCB181F25B55D89593 +#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma GCC system_header +#endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(push,1) +#endif #include #include @@ -97,4 +103,7 @@ boost } } +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(pop) +#endif #endif diff --git a/boost/boost/function/function_base.hpp b/boost/boost/function/function_base.hpp index c4663c35a8..eb201a80e9 100644 --- a/boost/boost/function/function_base.hpp +++ b/boost/boost/function/function_base.hpp @@ -15,8 +15,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -54,7 +54,9 @@ // Borrowed from Boost.Python library: determines the cases where we // need to use std::type_info::name to compare instead of operator==. -# if (defined(__GNUC__) && __GNUC__ >= 3) \ +#if defined( BOOST_NO_TYPEID ) +# define BOOST_FUNCTION_COMPARE_TYPE_ID(X,Y) ((X)==(Y)) +#elif (defined(__GNUC__) && __GNUC__ >= 3) \ || defined(_AIX) \ || ( defined(__sgi) && defined(__host_mips)) # include @@ -103,7 +105,7 @@ namespace boost { // For pointers to std::type_info objects struct type_t { // (get_functor_type_tag, check_functor_type_tag). - const BOOST_FUNCTION_STD_NS::type_info* type; + const detail::sp_typeinfo* type; // Whether the type is const-qualified. bool const_qualified; @@ -215,12 +217,12 @@ namespace boost { case check_functor_type_tag: { - const BOOST_FUNCTION_STD_NS::type_info& check_type + const detail::sp_typeinfo& check_type = *out_buffer.type.type; // Check whether we have the same type. We can add // cv-qualifiers, but we can't take them away. - if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, typeid(F)) + if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, BOOST_SP_TYPEID(F)) && (!in_buffer.obj_ref.is_const_qualified || out_buffer.type.const_qualified) && (!in_buffer.obj_ref.is_volatile_qualified @@ -232,7 +234,7 @@ namespace boost { return; case get_functor_type_tag: - out_buffer.type.type = &typeid(F); + out_buffer.type.type = &BOOST_SP_TYPEID(F); out_buffer.type.const_qualified = in_buffer.obj_ref.is_const_qualified; out_buffer.type.volatile_qualified = in_buffer.obj_ref.is_volatile_qualified; return; @@ -292,14 +294,14 @@ namespace boost { } else if (op == destroy_functor_tag) out_buffer.func_ptr = 0; else if (op == check_functor_type_tag) { - const BOOST_FUNCTION_STD_NS::type_info& check_type + const detail::sp_typeinfo& check_type = *out_buffer.type.type; - if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, typeid(Functor))) + if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, BOOST_SP_TYPEID(Functor))) out_buffer.obj_ptr = &in_buffer.func_ptr; else out_buffer.obj_ptr = 0; } else /* op == get_functor_type_tag */ { - out_buffer.type.type = &typeid(Functor); + out_buffer.type.type = &BOOST_SP_TYPEID(Functor); out_buffer.type.const_qualified = false; out_buffer.type.volatile_qualified = false; } @@ -322,14 +324,14 @@ namespace boost { // Some compilers (Borland, vc6, ...) are unhappy with ~functor_type. reinterpret_cast(&out_buffer.data)->~Functor(); } else if (op == check_functor_type_tag) { - const BOOST_FUNCTION_STD_NS::type_info& check_type + const detail::sp_typeinfo& check_type = *out_buffer.type.type; - if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, typeid(Functor))) + if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, BOOST_SP_TYPEID(Functor))) out_buffer.obj_ptr = &in_buffer.data; else out_buffer.obj_ptr = 0; } else /* op == get_functor_type_tag */ { - out_buffer.type.type = &typeid(Functor); + out_buffer.type.type = &BOOST_SP_TYPEID(Functor); out_buffer.type.const_qualified = false; out_buffer.type.volatile_qualified = false; } @@ -381,14 +383,14 @@ namespace boost { delete f; out_buffer.obj_ptr = 0; } else if (op == check_functor_type_tag) { - const BOOST_FUNCTION_STD_NS::type_info& check_type + const detail::sp_typeinfo& check_type = *out_buffer.type.type; - if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, typeid(Functor))) + if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, BOOST_SP_TYPEID(Functor))) out_buffer.obj_ptr = in_buffer.obj_ptr; else out_buffer.obj_ptr = 0; } else /* op == get_functor_type_tag */ { - out_buffer.type.type = &typeid(Functor); + out_buffer.type.type = &BOOST_SP_TYPEID(Functor); out_buffer.type.const_qualified = false; out_buffer.type.volatile_qualified = false; } @@ -423,7 +425,7 @@ namespace boost { typedef typename get_function_tag::type tag_type; switch (op) { case get_functor_type_tag: - out_buffer.type.type = &typeid(functor_type); + out_buffer.type.type = &BOOST_SP_TYPEID(functor_type); out_buffer.type.const_qualified = false; out_buffer.type.volatile_qualified = false; return; @@ -492,14 +494,14 @@ namespace boost { wrapper_allocator.deallocate(victim,1); out_buffer.obj_ptr = 0; } else if (op == check_functor_type_tag) { - const BOOST_FUNCTION_STD_NS::type_info& check_type + const detail::sp_typeinfo& check_type = *out_buffer.type.type; - if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, typeid(Functor))) + if (BOOST_FUNCTION_COMPARE_TYPE_ID(check_type, BOOST_SP_TYPEID(Functor))) out_buffer.obj_ptr = in_buffer.obj_ptr; else out_buffer.obj_ptr = 0; } else /* op == get_functor_type_tag */ { - out_buffer.type.type = &typeid(Functor); + out_buffer.type.type = &BOOST_SP_TYPEID(Functor); out_buffer.type.const_qualified = false; out_buffer.type.volatile_qualified = false; } @@ -526,7 +528,7 @@ namespace boost { typedef typename get_function_tag::type tag_type; switch (op) { case get_functor_type_tag: - out_buffer.type.type = &typeid(functor_type); + out_buffer.type.type = &BOOST_SP_TYPEID(functor_type); out_buffer.type.const_qualified = false; out_buffer.type.volatile_qualified = false; return; @@ -627,11 +629,11 @@ public: /** Determine if the function is empty (i.e., has no target). */ bool empty() const { return !vtable; } - /** Retrieve the type of the stored function object, or typeid(void) + /** Retrieve the type of the stored function object, or BOOST_SP_TYPEID(void) if this is empty. */ - const BOOST_FUNCTION_STD_NS::type_info& target_type() const + const detail::sp_typeinfo& target_type() const { - if (!vtable) return typeid(void); + if (!vtable) return BOOST_SP_TYPEID(void); detail::function::function_buffer type; get_vtable()->manager(functor, type, detail::function::get_functor_type_tag); @@ -644,7 +646,7 @@ public: if (!vtable) return 0; detail::function::function_buffer type_result; - type_result.type.type = &typeid(Functor); + type_result.type.type = &BOOST_SP_TYPEID(Functor); type_result.type.const_qualified = is_const::value; type_result.type.volatile_qualified = is_volatile::value; get_vtable()->manager(functor, type_result, @@ -662,7 +664,7 @@ public: if (!vtable) return 0; detail::function::function_buffer type_result; - type_result.type.type = &typeid(Functor); + type_result.type.type = &BOOST_SP_TYPEID(Functor); type_result.type.const_qualified = true; type_result.type.volatile_qualified = is_volatile::value; get_vtable()->manager(functor, type_result, diff --git a/boost/boost/functional/hash/detail/float_functions.hpp b/boost/boost/functional/hash/detail/float_functions.hpp index 01cac09722..ae03ff091e 100644 --- a/boost/boost/functional/hash/detail/float_functions.hpp +++ b/boost/boost/functional/hash/detail/float_functions.hpp @@ -84,7 +84,7 @@ namespace boost { // the boost namespace they'll always be preferable to any other function // (since the arguments are built in types, ADL can't be used). -namespace BOOST_HASH_DETECT_FLOAT_FUNCTIONS { +namespace boost_hash_detect_float_functions { template boost::hash_detail::not_found ldexp(Float, int); template boost::hash_detail::not_found frexp(Float, int*); } @@ -103,7 +103,7 @@ namespace BOOST_HASH_DETECT_FLOAT_FUNCTIONS { // happen mainly when there's a template in the same namesapce. #define BOOST_HASH_CALL_FLOAT_FUNC(cpp_func, c99_func, type1, type2) \ -namespace BOOST_HASH_DETECT_FLOAT_FUNCTIONS { \ +namespace boost_hash_detect_float_functions { \ template \ boost::hash_detail::not_found c99_func(Float, type2); \ } \ @@ -112,7 +112,7 @@ namespace boost { \ namespace hash_detail { \ namespace c99_func##_detect { \ using namespace std; \ - using namespace BOOST_HASH_DETECT_FLOAT_FUNCTIONS; \ + using namespace boost_hash_detect_float_functions; \ \ struct check { \ static type1 x; \ diff --git a/boost/boost/functional/hash/hash.hpp b/boost/boost/functional/hash/hash.hpp index 6784f3ef6b..1f33b9ea9d 100644 --- a/boost/boost/functional/hash/hash.hpp +++ b/boost/boost/functional/hash/hash.hpp @@ -20,7 +20,8 @@ #include #endif -#if BOOST_WORKAROUND(__GNUC__, < 3) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) +#if BOOST_WORKAROUND(__GNUC__, < 3) \ + && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) #define BOOST_HASH_CHAR_TRAITS string_char_traits #else #define BOOST_HASH_CHAR_TRAITS char_traits @@ -67,7 +68,8 @@ namespace boost std::size_t hash_value(long double v); template - std::size_t hash_value(std::basic_string, A> const&); + std::size_t hash_value( + std::basic_string, A> const&); // Implementation @@ -197,6 +199,16 @@ namespace boost return x + (x >> 3); } +#if defined(BOOST_MSVC) +#pragma warning(push) +#if BOOST_MSVC <= 1400 +#pragma warning(disable:4267) // 'argument' : conversion from 'size_t' to + // 'unsigned int', possible loss of data + // A misguided attempt to detect 64-bit + // incompatability. +#endif +#endif + #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) template inline void hash_combine(std::size_t& seed, T& v) @@ -209,6 +221,10 @@ namespace boost seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2); } +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif + template inline std::size_t hash_range(It first, It last) { @@ -272,7 +288,8 @@ namespace boost #endif template - inline std::size_t hash_value(std::basic_string, A> const& v) + inline std::size_t hash_value( + std::basic_string, A> const& v) { return hash_range(v.begin(), v.end()); } @@ -297,8 +314,8 @@ namespace boost // // Define the specializations required by the standard. The general purpose - // boost::hash is defined later in extensions.hpp if BOOST_HASH_NO_EXTENSIONS - // is not defined. + // boost::hash is defined later in extensions.hpp if + // BOOST_HASH_NO_EXTENSIONS is not defined. // BOOST_HASH_SPECIALIZE - define a specialization for a type which is // passed by copy. diff --git a/boost/boost/integer.hpp b/boost/boost/integer.hpp index dc57dff778..3393c81ea8 100644 --- a/boost/boost/integer.hpp +++ b/boost/boost/integer.hpp @@ -17,8 +17,21 @@ #include // self include -#include // for boost::integer_traits -#include // for std::numeric_limits +#include // for boost::::boost::integer_traits +#include // for ::std::numeric_limits +#include // for boost::int64_t and BOOST_NO_INTEGRAL_INT64_T + +// +// We simply cannot include this header on gcc without getting copious warnings of the kind: +// +// boost/integer.hpp:77:30: warning: use of C99 long long integer constant +// +// And yet there is no other reasonable implementation, so we declare this a system header +// to suppress these warnings. +// +#if defined(__GNUC__) && (__GNUC__ >= 4) +#pragma GCC system_header +#endif namespace boost { @@ -28,7 +41,13 @@ namespace boost // fast integers from least integers // int_fast_t<> works correctly for unsigned too, in spite of the name. template< typename LeastInt > - struct int_fast_t { typedef LeastInt fast; }; // imps may specialize + struct int_fast_t + { + typedef LeastInt fast; + typedef fast type; + }; // imps may specialize + + namespace detail{ // convert category to type template< int Category > struct int_least_helper {}; // default is empty @@ -36,89 +55,196 @@ namespace boost // specializatons: 1=long, 2=int, 3=short, 4=signed char, // 6=unsigned long, 7=unsigned int, 8=unsigned short, 9=unsigned char // no specializations for 0 and 5: requests for a type > long are in error - template<> struct int_least_helper<1> { typedef long least; }; - template<> struct int_least_helper<2> { typedef int least; }; - template<> struct int_least_helper<3> { typedef short least; }; - template<> struct int_least_helper<4> { typedef signed char least; }; - template<> struct int_least_helper<6> { typedef unsigned long least; }; - template<> struct int_least_helper<7> { typedef unsigned int least; }; - template<> struct int_least_helper<8> { typedef unsigned short least; }; - template<> struct int_least_helper<9> { typedef unsigned char least; }; +#ifdef BOOST_HAS_LONG_LONG + template<> struct int_least_helper<1> { typedef boost::long_long_type least; }; +#endif + template<> struct int_least_helper<2> { typedef long least; }; + template<> struct int_least_helper<3> { typedef int least; }; + template<> struct int_least_helper<4> { typedef short least; }; + template<> struct int_least_helper<5> { typedef signed char least; }; +#ifdef BOOST_HAS_LONG_LONG + template<> struct int_least_helper<6> { typedef boost::ulong_long_type least; }; +#endif + template<> struct int_least_helper<7> { typedef unsigned long least; }; + template<> struct int_least_helper<8> { typedef unsigned int least; }; + template<> struct int_least_helper<9> { typedef unsigned short least; }; + template<> struct int_least_helper<10> { typedef unsigned char least; }; + + template + struct exact_signed_base_helper{}; + template + struct exact_unsigned_base_helper{}; + + template <> struct exact_signed_base_helper { typedef signed char exact; }; + template <> struct exact_unsigned_base_helper { typedef unsigned char exact; }; +#if USHRT_MAX != UCHAR_MAX + template <> struct exact_signed_base_helper { typedef short exact; }; + template <> struct exact_unsigned_base_helper { typedef unsigned short exact; }; +#endif +#if UINT_MAX != USHRT_MAX + template <> struct exact_signed_base_helper { typedef int exact; }; + template <> struct exact_unsigned_base_helper { typedef unsigned int exact; }; +#endif +#if ULONG_MAX != UINT_MAX + template <> struct exact_signed_base_helper { typedef long exact; }; + template <> struct exact_unsigned_base_helper { typedef unsigned long exact; }; +#endif +#if defined(BOOST_HAS_LONG_LONG) &&\ + ((defined(ULLONG_MAX) && (ULLONG_MAX != ULONG_MAX)) ||\ + (defined(ULONG_LONG_MAX) && (ULONG_LONG_MAX != ULONG_MAX)) ||\ + (defined(ULONGLONG_MAX) && (ULONGLONG_MAX != ULONG_MAX)) ||\ + (defined(_ULLONG_MAX) && (_ULLONG_MAX != ULONG_MAX))) + template <> struct exact_signed_base_helper { typedef boost::long_long_type exact; }; + template <> struct exact_unsigned_base_helper { typedef boost::ulong_long_type exact; }; +#endif + + + } // namespace detail // integer templates specifying number of bits ---------------------------// // signed template< int Bits > // bits (including sign) required - struct int_t + struct int_t : public detail::exact_signed_base_helper { - typedef typename int_least_helper + typedef typename detail::int_least_helper < - (Bits-1 <= std::numeric_limits::digits) + - (Bits-1 <= std::numeric_limits::digits) + - (Bits-1 <= std::numeric_limits::digits) + - (Bits-1 <= std::numeric_limits::digits) +#ifdef BOOST_HAS_LONG_LONG + (Bits-1 <= (int)(sizeof(boost::long_long_type) * CHAR_BIT)) + +#else + 1 + +#endif + (Bits-1 <= ::std::numeric_limits::digits) + + (Bits-1 <= ::std::numeric_limits::digits) + + (Bits-1 <= ::std::numeric_limits::digits) + + (Bits-1 <= ::std::numeric_limits::digits) >::least least; - typedef typename int_fast_t::fast fast; + typedef typename int_fast_t::type fast; }; // unsigned template< int Bits > // bits required - struct uint_t + struct uint_t : public detail::exact_unsigned_base_helper { - typedef typename int_least_helper +#if (defined(__BORLANDC__) || defined(__CODEGEAR__)) && defined(BOOST_NO_INTEGRAL_INT64_T) + // It's really not clear why this workaround should be needed... shrug I guess! JM + BOOST_STATIC_CONSTANT(int, s = + 6 + + (Bits <= ::std::numeric_limits::digits) + + (Bits <= ::std::numeric_limits::digits) + + (Bits <= ::std::numeric_limits::digits) + + (Bits <= ::std::numeric_limits::digits)); + typedef typename detail::int_least_helper< ::boost::uint_t::s>::least least; +#else + typedef typename detail::int_least_helper < 5 + - (Bits <= std::numeric_limits::digits) + - (Bits <= std::numeric_limits::digits) + - (Bits <= std::numeric_limits::digits) + - (Bits <= std::numeric_limits::digits) +#ifdef BOOST_HAS_LONG_LONG + (Bits-1 <= (int)(sizeof(boost::long_long_type) * CHAR_BIT)) + +#else + 1 + +#endif + (Bits <= ::std::numeric_limits::digits) + + (Bits <= ::std::numeric_limits::digits) + + (Bits <= ::std::numeric_limits::digits) + + (Bits <= ::std::numeric_limits::digits) >::least least; - typedef typename int_fast_t::fast fast; +#endif + typedef typename int_fast_t::type fast; // int_fast_t<> works correctly for unsigned too, in spite of the name. }; // integer templates specifying extreme value ----------------------------// // signed +#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG) + template< boost::long_long_type MaxValue > // maximum value to require support +#else template< long MaxValue > // maximum value to require support +#endif struct int_max_value_t { - typedef typename int_least_helper + typedef typename detail::int_least_helper < - (MaxValue <= integer_traits::const_max) + - (MaxValue <= integer_traits::const_max) + - (MaxValue <= integer_traits::const_max) + - (MaxValue <= integer_traits::const_max) +#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG) + (MaxValue <= ::boost::integer_traits::const_max) + +#else + 1 + +#endif + (MaxValue <= ::boost::integer_traits::const_max) + + (MaxValue <= ::boost::integer_traits::const_max) + + (MaxValue <= ::boost::integer_traits::const_max) + + (MaxValue <= ::boost::integer_traits::const_max) >::least least; - typedef typename int_fast_t::fast fast; + typedef typename int_fast_t::type fast; }; +#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG) + template< boost::long_long_type MinValue > // minimum value to require support +#else template< long MinValue > // minimum value to require support +#endif struct int_min_value_t { - typedef typename int_least_helper + typedef typename detail::int_least_helper < - (MinValue >= integer_traits::const_min) + - (MinValue >= integer_traits::const_min) + - (MinValue >= integer_traits::const_min) + - (MinValue >= integer_traits::const_min) +#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG) + (MinValue >= ::boost::integer_traits::const_min) + +#else + 1 + +#endif + (MinValue >= ::boost::integer_traits::const_min) + + (MinValue >= ::boost::integer_traits::const_min) + + (MinValue >= ::boost::integer_traits::const_min) + + (MinValue >= ::boost::integer_traits::const_min) >::least least; - typedef typename int_fast_t::fast fast; + typedef typename int_fast_t::type fast; }; // unsigned - template< unsigned long Value > // maximum value to require support +#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG) + template< boost::ulong_long_type MaxValue > // minimum value to require support +#else + template< unsigned long MaxValue > // minimum value to require support +#endif struct uint_value_t { - typedef typename int_least_helper +#if (defined(__BORLANDC__) || defined(__CODEGEAR__)) + // It's really not clear why this workaround should be needed... shrug I guess! JM +#if defined(BOOST_NO_INTEGRAL_INT64_T) + BOOST_STATIC_CONSTANT(unsigned, which = + 6 + + (MaxValue <= ::boost::integer_traits::const_max) + + (MaxValue <= ::boost::integer_traits::const_max) + + (MaxValue <= ::boost::integer_traits::const_max) + + (MaxValue <= ::boost::integer_traits::const_max)); + typedef typename detail::int_least_helper< ::boost::uint_value_t::which>::least least; +#else // BOOST_NO_INTEGRAL_INT64_T + BOOST_STATIC_CONSTANT(unsigned, which = + 5 + + (MaxValue <= ::boost::integer_traits::const_max) + + (MaxValue <= ::boost::integer_traits::const_max) + + (MaxValue <= ::boost::integer_traits::const_max) + + (MaxValue <= ::boost::integer_traits::const_max) + + (MaxValue <= ::boost::integer_traits::const_max)); + typedef typename detail::int_least_helper< ::boost::uint_value_t::which>::least least; +#endif // BOOST_NO_INTEGRAL_INT64_T +#else + typedef typename detail::int_least_helper < 5 + - (Value <= integer_traits::const_max) + - (Value <= integer_traits::const_max) + - (Value <= integer_traits::const_max) + - (Value <= integer_traits::const_max) +#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG) + (MaxValue <= ::boost::integer_traits::const_max) + +#else + 1 + +#endif + (MaxValue <= ::boost::integer_traits::const_max) + + (MaxValue <= ::boost::integer_traits::const_max) + + (MaxValue <= ::boost::integer_traits::const_max) + + (MaxValue <= ::boost::integer_traits::const_max) >::least least; - typedef typename int_fast_t::fast fast; +#endif + typedef typename int_fast_t::type fast; }; diff --git a/boost/boost/integer/integer_mask.hpp b/boost/boost/integer/integer_mask.hpp index 0a092d3850..8c4e1bb1c4 100644 --- a/boost/boost/integer/integer_mask.hpp +++ b/boost/boost/integer/integer_mask.hpp @@ -70,6 +70,11 @@ struct low_bits_mask_t BOOST_STATIC_CONSTANT( std::size_t, bit_count = limits_type::digits ); \ } +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4245) // 'initializing' : conversion from 'int' to 'const boost::low_bits_mask_t<8>::least', signed/unsigned mismatch +#endif + BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned char ); #if USHRT_MAX > UCHAR_MAX @@ -84,6 +89,10 @@ BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned int ); BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned long ); #endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + #undef BOOST_LOW_BITS_MASK_SPECIALIZE diff --git a/boost/boost/integer/static_log2.hpp b/boost/boost/integer/static_log2.hpp index 219a48e341..56c7a00125 100644 --- a/boost/boost/integer/static_log2.hpp +++ b/boost/boost/integer/static_log2.hpp @@ -16,7 +16,7 @@ #ifndef BOOST_INTEGER_STATIC_LOG2_HPP #define BOOST_INTEGER_STATIC_LOG2_HPP -#include "boost/config.hpp" // for BOOST_STATIC_CONSTANT +#include "boost/integer_fwd.hpp" // for boost::intmax_t namespace boost { @@ -41,9 +41,8 @@ namespace boost { // terminates with x = 1 and n = 0 (see the algorithm's // invariant). - typedef unsigned long argument_type; - typedef int result_type; - + typedef boost::static_log2_argument_type argument_type; + typedef boost::static_log2_result_type result_type; template struct choose_initial_n { @@ -107,10 +106,6 @@ namespace boost { // static_log2 // ---------------------------------------- - typedef detail::static_log2_impl::argument_type static_log2_argument_type; - typedef detail::static_log2_impl::result_type static_log2_result_type; - - template struct static_log2 { diff --git a/boost/boost/integer/static_min_max.hpp b/boost/boost/integer/static_min_max.hpp index 264603727f..ee76fd424a 100644 --- a/boost/boost/integer/static_min_max.hpp +++ b/boost/boost/integer/static_min_max.hpp @@ -12,39 +12,35 @@ #include // self include -#include // for BOOST_STATIC_CONSTANT - - namespace boost { - // Compile-time extrema class declarations ---------------------------------// // Get the minimum or maximum of two values, signed or unsigned. -template < long Value1, long Value2 > +template struct static_signed_min { - BOOST_STATIC_CONSTANT( long, value = (Value1 > Value2) ? Value2 : Value1 ); + BOOST_STATIC_CONSTANT(static_min_max_signed_type, value = (Value1 > Value2) ? Value2 : Value1 ); }; -template < long Value1, long Value2 > +template struct static_signed_max { - BOOST_STATIC_CONSTANT( long, value = (Value1 < Value2) ? Value2 : Value1 ); + BOOST_STATIC_CONSTANT(static_min_max_signed_type, value = (Value1 < Value2) ? Value2 : Value1 ); }; -template < unsigned long Value1, unsigned long Value2 > +template struct static_unsigned_min { - BOOST_STATIC_CONSTANT( unsigned long, value + BOOST_STATIC_CONSTANT(static_min_max_unsigned_type, value = (Value1 > Value2) ? Value2 : Value1 ); }; -template < unsigned long Value1, unsigned long Value2 > +template struct static_unsigned_max { - BOOST_STATIC_CONSTANT( unsigned long, value + BOOST_STATIC_CONSTANT(static_min_max_unsigned_type, value = (Value1 < Value2) ? Value2 : Value1 ); }; diff --git a/boost/boost/integer_fwd.hpp b/boost/boost/integer_fwd.hpp index 33cfc9986f..01b0a0844f 100644 --- a/boost/boost/integer_fwd.hpp +++ b/boost/boost/integer_fwd.hpp @@ -14,11 +14,23 @@ #include // for BOOST_NO_INTRINSIC_WCHAR_T #include // for std::numeric_limits +#include // For intmax_t namespace boost { +#ifdef BOOST_NO_INTEGRAL_INT64_T + typedef unsigned long static_log2_argument_type; + typedef int static_log2_result_type; + typedef long static_min_max_signed_type; + typedef unsigned long static_min_max_unsigned_type; +#else + typedef boost::uintmax_t static_min_max_unsigned_type; + typedef boost::intmax_t static_min_max_signed_type; + typedef boost::uintmax_t static_log2_argument_type; + typedef int static_log2_result_type; +#endif // From ------------------------------------------------// @@ -65,7 +77,7 @@ template < > template < > class integer_traits< unsigned long >; -#ifdef ULLONG_MAX +#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && (defined(BOOST_HAS_LONG_LONG) || defined(BOOST_HAS_MS_INT64)) template < > class integer_traits< ::boost::long_long_type>; @@ -85,13 +97,25 @@ template< int Bits > template< int Bits > struct uint_t; -template< long MaxValue > +#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG) + template< boost::long_long_type MaxValue > // maximum value to require support +#else + template< long MaxValue > // maximum value to require support +#endif struct int_max_value_t; -template< long MinValue > +#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG) + template< boost::long_long_type MinValue > // minimum value to require support +#else + template< long MinValue > // minimum value to require support +#endif struct int_min_value_t; -template< unsigned long Value > +#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG) + template< boost::ulong_long_type MaxValue > // maximum value to require support +#else + template< unsigned long MaxValue > // maximum value to require support +#endif struct uint_value_t; @@ -124,28 +148,26 @@ template < > // From ------------------------------------// -template < unsigned long Value > +template struct static_log2; -template < > - struct static_log2< 0ul >; +template <> struct static_log2<0u>; // From ---------------------------------// -template < long Value1, long Value2 > +template struct static_signed_min; -template < long Value1, long Value2 > +template struct static_signed_max; -template < unsigned long Value1, unsigned long Value2 > +template struct static_unsigned_min; -template < unsigned long Value1, unsigned long Value2 > +template struct static_unsigned_max; - } // namespace boost diff --git a/boost/boost/integer_traits.hpp b/boost/boost/integer_traits.hpp index ac4ef32f30..129ce82c65 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 32576 2006-02-05 10:19:42Z johnmaddock $ + * $Id: integer_traits.hpp 58381 2009-12-14 18:14:48Z johnmaddock $ * * Idea by Beman Dawes, Ed Brey, Steve Cleary, and Nathan Myers */ @@ -27,6 +27,17 @@ #include #endif +// +// We simply cannot include this header on gcc without getting copious warnings of the kind: +// +// ../../../boost/integer_traits.hpp:164:66: warning: use of C99 long long integer constant +// +// And yet there is no other reasonable implementation, so we declare this a system header +// to suppress these warnings. +// +#if defined(__GNUC__) && (__GNUC__ >= 4) +#pragma GCC system_header +#endif namespace boost { template @@ -225,6 +236,20 @@ class integer_traits< ::boost::ulong_long_type> public detail::integer_traits_base< ::boost::ulong_long_type, 0, ~0uLL> { }; +#elif defined(BOOST_HAS_MS_INT64) + +template<> +class integer_traits< __int64> + : public std::numeric_limits< __int64>, + public detail::integer_traits_base< __int64, _I64_MIN, _I64_MAX> +{ }; + +template<> +class integer_traits< unsigned __int64> + : public std::numeric_limits< unsigned __int64>, + public detail::integer_traits_base< unsigned __int64, 0, _UI64_MAX> +{ }; + #endif #endif diff --git a/boost/boost/memory_order.hpp b/boost/boost/memory_order.hpp index 2524e8aa43..4945af623b 100755 --- a/boost/boost/memory_order.hpp +++ b/boost/boost/memory_order.hpp @@ -11,7 +11,7 @@ // // Defines enum boost::memory_order per the C++0x working draft // -// Copyright (c) 2008 Peter Dimov +// Copyright (c) 2008, 2009 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at @@ -21,13 +21,31 @@ namespace boost { +// +// Enum values are chosen so that code that needs to insert +// a trailing fence for acquire semantics can use a single +// test such as: +// +// if( mo & memory_order_acquire ) { ...fence... } +// +// For leading fences one can use: +// +// if( mo & memory_order_release ) { ...fence... } +// +// Architectures such as Alpha that need a fence on consume +// can use: +// +// if( mo & ( memory_order_acquire | memory_order_consume ) ) { ...fence... } +// + enum memory_order { memory_order_relaxed = 0, memory_order_acquire = 1, memory_order_release = 2, memory_order_acq_rel = 3, // acquire | release - memory_order_seq_cst = 7 // acq_rel | 4 + memory_order_seq_cst = 7, // acq_rel | 4 + memory_order_consume = 8 }; } // namespace boost diff --git a/boost/boost/regex/concepts.hpp b/boost/boost/regex/concepts.hpp index 98fd59413f..fa2ea48c92 100644 --- a/boost/boost/regex/concepts.hpp +++ b/boost/boost/regex/concepts.hpp @@ -747,6 +747,46 @@ struct RegexConcept }; #ifndef BOOST_REGEX_TEST_STD + +template +struct functor1 +{ + typedef typename M::char_type char_type; + const char_type* operator()(const M&) + { + static const char_type c = static_cast(0); + return &c; + } +}; +template +struct functor1b +{ + typedef typename M::char_type char_type; + std::vector operator()(const M&) + { + static const std::vector c; + return c; + } +}; +template +struct functor2 +{ + template + O operator()(const M& /*m*/, O i) + { + return i; + } +}; +template +struct functor3 +{ + template + O operator()(const M& /*m*/, O i, regex_constants::match_flag_type) + { + return i; + } +}; + // // BoostRegexConcept: // Test every interface in the Boost implementation: @@ -764,6 +804,7 @@ struct BoostRegexConcept typedef std::basic_string string_type; typedef typename Regex::const_iterator const_iterator; typedef bidirectional_iterator_archetype BidiIterator; + typedef output_iterator_archetype OutputIterator; typedef global_regex_namespace::sub_match sub_match_type; typedef global_regex_namespace::match_results match_results_type; @@ -884,6 +925,58 @@ struct BoostRegexConcept m_stream << m_sub; m_stream << m_cresults; #endif + // + // Extended formatting with a functor: + // + regex_constants::match_flag_type f = regex_constants::match_default; + OutputIterator out = static_object::get(); + functor3 func3; + out = regex_format(out, m_cresults, func3, f); + out = regex_format(out, m_cresults, func3); + functor2 func2; + out = regex_format(out, m_cresults, func2, f); + out = regex_format(out, m_cresults, func2); + functor1 func1; + out = regex_format(out, m_cresults, func1, f); + out = regex_format(out, m_cresults, func1); + + m_string += regex_format(m_cresults, func3, f); + m_string += regex_format(m_cresults, func3); + m_string += regex_format(m_cresults, func2, f); + m_string += regex_format(m_cresults, func2); + m_string += regex_format(m_cresults, func1, f); + m_string += regex_format(m_cresults, func1); + + out = m_cresults.format(out, func3, f); + out = m_cresults.format(out, func3); + out = m_cresults.format(out, func2, f); + out = m_cresults.format(out, func2); + out = m_cresults.format(out, func1, f); + out = m_cresults.format(out, func1); + + m_string += m_cresults.format(func3, f); + m_string += m_cresults.format(func3); + m_string += m_cresults.format(func2, f); + m_string += m_cresults.format(func2); + m_string += m_cresults.format(func1, f); + m_string += m_cresults.format(func1); + + out = regex_replace(out, m_in, m_in, ce, func3, f); + out = regex_replace(out, m_in, m_in, ce, func3); + out = regex_replace(out, m_in, m_in, ce, func2, f); + out = regex_replace(out, m_in, m_in, ce, func2); + out = regex_replace(out, m_in, m_in, ce, func1, f); + out = regex_replace(out, m_in, m_in, ce, func1); + + functor3 > func3s; + functor2 > func2s; + functor1 > func1s; + m_string += regex_replace(m_string, ce, func3s, f); + m_string += regex_replace(m_string, ce, func3s); + m_string += regex_replace(m_string, ce, func2s, f); + m_string += regex_replace(m_string, ce, func2s); + m_string += regex_replace(m_string, ce, func1s, f); + m_string += regex_replace(m_string, ce, func1s); } std::basic_ostream m_stream; @@ -893,6 +986,7 @@ struct BoostRegexConcept const value_type m_char; match_results_type m_results; const match_results_type m_cresults; + BidiIterator m_in; BoostRegexConcept(); BoostRegexConcept(const BoostRegexConcept&); diff --git a/boost/boost/regex/config.hpp b/boost/boost/regex/config.hpp index 8306f3ff9a..e4b21384b5 100644 --- a/boost/boost/regex/config.hpp +++ b/boost/boost/regex/config.hpp @@ -92,6 +92,12 @@ #if defined(_MSC_VER) && !defined(_MSC_EXTENSIONS) # define BOOST_REGEX_NO_EXTERNAL_TEMPLATES #endif +/* + * Shared regex lib will crash without this, frankly it looks a lot like a gcc bug: + */ +#if defined(__MINGW32__) +# define BOOST_REGEX_NO_EXTERNAL_TEMPLATES +#endif /* * If there isn't good enough wide character support then there will diff --git a/boost/boost/regex/icu.hpp b/boost/boost/regex/icu.hpp index 247155724e..c8770c6d16 100644 --- a/boost/boost/regex/icu.hpp +++ b/boost/boost/regex/icu.hpp @@ -376,7 +376,7 @@ inline u32regex make_u32regex(const std::basic_string& s, boost::regex_ // // Construction from ICU string type: // -inline u32regex make_u32regex(const UnicodeString& s, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) +inline u32regex make_u32regex(const U_NAMESPACE_QUALIFIER UnicodeString& s, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) { return re_detail::do_make_u32regex(s.getBuffer(), s.getBuffer() + s.length(), opt, static_cast const*>(0)); } @@ -498,7 +498,7 @@ inline bool u32regex_match(const std::wstring& s, return re_detail::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast const*>(0)); } #endif -inline bool u32regex_match(const UnicodeString& s, +inline bool u32regex_match(const U_NAMESPACE_QUALIFIER UnicodeString& s, match_results& m, const u32regex& e, match_flag_type flags = match_default) @@ -562,7 +562,7 @@ inline bool u32regex_match(const std::wstring& s, return re_detail::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast const*>(0)); } #endif -inline bool u32regex_match(const UnicodeString& s, +inline bool u32regex_match(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, match_flag_type flags = match_default) { @@ -683,7 +683,7 @@ inline bool u32regex_search(const std::wstring& s, return re_detail::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast const*>(0)); } #endif -inline bool u32regex_search(const UnicodeString& s, +inline bool u32regex_search(const U_NAMESPACE_QUALIFIER UnicodeString& s, match_results& m, const u32regex& e, match_flag_type flags = match_default) @@ -744,7 +744,7 @@ inline bool u32regex_search(const std::wstring& s, return re_detail::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast const*>(0)); } #endif -inline bool u32regex_search(const UnicodeString& s, +inline bool u32regex_search(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, match_flag_type flags = match_default) { @@ -921,7 +921,7 @@ inline OutputIterator u32regex_replace(OutputIterator out, Iterator first, Iterator last, const u32regex& e, - const UnicodeString& fmt, + const U_NAMESPACE_QUALIFIER UnicodeString& fmt, match_flag_type flags = match_default) { return re_detail::extract_output_base @@ -966,9 +966,9 @@ namespace re_detail{ class unicode_string_out_iterator { - UnicodeString* out; + U_NAMESPACE_QUALIFIER UnicodeString* out; public: - unicode_string_out_iterator(UnicodeString& s) : out(&s) {} + unicode_string_out_iterator(U_NAMESPACE_QUALIFIER UnicodeString& s) : out(&s) {} unicode_string_out_iterator& operator++() { return *this; } unicode_string_out_iterator& operator++(int) { return *this; } unicode_string_out_iterator& operator*() { return *this; } @@ -986,23 +986,23 @@ public: } -inline UnicodeString u32regex_replace(const UnicodeString& s, +inline U_NAMESPACE_QUALIFIER UnicodeString u32regex_replace(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, const UChar* fmt, match_flag_type flags = match_default) { - UnicodeString result; + U_NAMESPACE_QUALIFIER UnicodeString result; re_detail::unicode_string_out_iterator i(result); u32regex_replace(i, s.getBuffer(), s.getBuffer()+s.length(), e, fmt, flags); return result; } -inline UnicodeString u32regex_replace(const UnicodeString& s, +inline U_NAMESPACE_QUALIFIER UnicodeString u32regex_replace(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, - const UnicodeString& fmt, + const U_NAMESPACE_QUALIFIER UnicodeString& fmt, match_flag_type flags = match_default) { - UnicodeString result; + U_NAMESPACE_QUALIFIER UnicodeString result; re_detail::unicode_string_out_iterator i(result); re_detail::do_regex_replace( re_detail::make_utf32_out(i, static_cast const*>(0)), diff --git a/boost/boost/regex/pending/object_cache.hpp b/boost/boost/regex/pending/object_cache.hpp index 2a7e00bc0a..e1aa191da2 100644 --- a/boost/boost/regex/pending/object_cache.hpp +++ b/boost/boost/regex/pending/object_cache.hpp @@ -73,7 +73,9 @@ boost::shared_ptr object_cache::get(const Key& k, siz // for now just throw, but we should never really get here... // ::boost::throw_exception(std::runtime_error("Error in thread safety code: could not acquire a lock")); +#ifdef BOOST_NO_UNREACHABLE_RETURN_DETECTION return boost::shared_ptr(); +#endif #else return do_get(k, max_cache_size); #endif diff --git a/boost/boost/regex/pending/static_mutex.hpp b/boost/boost/regex/pending/static_mutex.hpp index 218169c3c8..334ef27d32 100644 --- a/boost/boost/regex/pending/static_mutex.hpp +++ b/boost/boost/regex/pending/static_mutex.hpp @@ -140,7 +140,7 @@ inline bool scoped_static_mutex_lock::locked()const namespace boost{ class BOOST_REGEX_DECL scoped_static_mutex_lock; -extern "C" BOOST_REGEX_DECL void free_static_mutex(); +extern "C" BOOST_REGEX_DECL void boost_regex_free_static_mutex(); class BOOST_REGEX_DECL static_mutex { diff --git a/boost/boost/regex/v4/basic_regex_creator.hpp b/boost/boost/regex/v4/basic_regex_creator.hpp index 6f0050542d..ee207d0874 100644 --- a/boost/boost/regex/v4/basic_regex_creator.hpp +++ b/boost/boost/regex/v4/basic_regex_creator.hpp @@ -677,6 +677,8 @@ re_syntax_base* basic_regex_creator::append_set( template void basic_regex_creator::finalize(const charT* p1, const charT* p2) { + if(this->m_pdata->m_status) + return; // we've added all the states we need, now finish things off. // start by adding a terminating state: append_state(syntax_element_match); @@ -698,6 +700,8 @@ void basic_regex_creator::finalize(const charT* p1, const charT* { m_pdata->m_has_recursions = true; fixup_recursions(m_pdata->m_first_state); + if(this->m_pdata->m_status) + return; } else m_pdata->m_has_recursions = false; @@ -787,7 +791,7 @@ void basic_regex_creator::fixup_recursions(re_syntax_base* state) // if(0 == (this->flags() & regex_constants::no_except)) { - std::string message = this->m_pdata->m_ptraits->error_string(boost::regex_constants::error_bad_pattern); + std::string message = "Encountered a forward reference to a marked sub-expression that does not exist."; boost::regex_error e(message, boost::regex_constants::error_bad_pattern, 0); e.raise(); } @@ -807,8 +811,43 @@ void basic_regex_creator::fixup_recursions(re_syntax_base* state) { if((p->type == syntax_element_startmark) && (static_cast(p)->index == id)) { + // + // We've found the target of the recursion, set the jump target: + // static_cast(state)->alt.p = p; ok = true; + // + // Now scan the target for nested repeats: + // + p = p->next.p; + int next_rep_id = 0; + while(p) + { + switch(p->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: + next_rep_id = static_cast(p)->state_id; + break; + case syntax_element_endmark: + if(static_cast(p)->index == id) + next_rep_id = -1; + break; + default: + break; + } + if(next_rep_id) + break; + p = p->next.p; + } + if(next_rep_id > 0) + { + static_cast(state)->state_id = next_rep_id - 1; + } + break; } p = p->next.p; @@ -828,7 +867,7 @@ void basic_regex_creator::fixup_recursions(re_syntax_base* state) // if(0 == (this->flags() & regex_constants::no_except)) { - std::string message = this->m_pdata->m_ptraits->error_string(boost::regex_constants::error_bad_pattern); + std::string message = "Encountered a forward reference to a recursive sub-expression that does not exist."; boost::regex_error e(message, boost::regex_constants::error_bad_pattern, 0); e.raise(); } @@ -893,7 +932,7 @@ void basic_regex_creator::create_startmaps(re_syntax_base* state) // if(0 == (this->flags() & regex_constants::no_except)) { - std::string message = this->m_pdata->m_ptraits->error_string(boost::regex_constants::error_bad_pattern); + std::string message = "Invalid lookbehind assertion encountered in the regular expression."; boost::regex_error e(message, boost::regex_constants::error_bad_pattern, 0); e.raise(); } @@ -1012,6 +1051,9 @@ 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; + re_syntax_base* recursion_start = 0; + int recursion_sub = 0; + re_syntax_base* recursion_restart = 0; // track case sensitivity: bool l_icase = m_icase; @@ -1057,6 +1099,40 @@ void basic_regex_creator::create_startmap(re_syntax_base* state, return; } case syntax_element_recurse: + { + if(recursion_start == state) + { + // Infinite recursion!! + 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 = "Encountered an infinite recursion."; + boost::regex_error e(message, boost::regex_constants::error_bad_pattern, 0); + e.raise(); + } + } + else if(recursion_start == 0) + { + recursion_start = state; + recursion_restart = state->next.p; + state = static_cast(state)->alt.p; + if(state->type == syntax_element_startmark) + recursion_sub = static_cast(state)->index; + else + recursion_sub = 0; + break; + } + // fall through, can't handle nested recursion here... + } case syntax_element_backref: // can be null, and any character can match: if(pnull) @@ -1215,12 +1291,45 @@ void basic_regex_creator::create_startmap(re_syntax_base* state, *pnull |= mask; return; } - else + else if(recursion_start && (recursion_sub != 0) && (recursion_sub == static_cast(state)->index)) { - state = state->next.p; + // recursion termination: + recursion_start = 0; + state = recursion_restart; break; } + // + // Normally we just go to the next state... but if this sub-expression is + // the target of a recursion, then we might be ending a recursion, in which + // case we should check whatever follows that recursion, as well as whatever + // follows this state: + // + if(m_pdata->m_has_recursions && static_cast(state)->index) + { + bool ok = false; + re_syntax_base* p = m_pdata->m_first_state; + while(p) + { + if((p->type == syntax_element_recurse)) + { + re_brace* p2 = static_cast(static_cast(p)->alt.p); + if((p2->type == syntax_element_startmark) && (p2->index == static_cast(state)->index)) + { + ok = true; + break; + } + } + p = p->next.p; + } + if(ok) + { + create_startmap(p->next.p, l_map, pnull, mask); + } + } + state = state->next.p; + break; + case syntax_element_startmark: // need to handle independent subs as a special case: if(static_cast(state)->index == -3) diff --git a/boost/boost/regex/v4/basic_regex_parser.hpp b/boost/boost/regex/v4/basic_regex_parser.hpp index ebec35b60d..3ea4d6453d 100644 --- a/boost/boost/regex/v4/basic_regex_parser.hpp +++ b/boost/boost/regex/v4/basic_regex_parser.hpp @@ -45,6 +45,11 @@ 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); + void fail(regex_constants::error_type error_code, std::ptrdiff_t position, std::string message, std::ptrdiff_t start_pos); + void fail(regex_constants::error_type error_code, std::ptrdiff_t position, const std::string& message) + { + fail(error_code, position, message, position); + } bool parse_all(); bool parse_basic(); @@ -141,6 +146,11 @@ void basic_regex_parser::parse(const charT* p1, const charT* p2, case regbase::literal: m_parser_proc = &basic_regex_parser::parse_literal; break; + default: + // Ooops, someone has managed to set more than one of the main option flags, + // so this must be an error: + fail(regex_constants::error_unknown, 0, "An invalid combination of regular expression syntax flags was used."); + return; } // parse all our characters: @@ -155,7 +165,7 @@ void basic_regex_parser::parse(const charT* p1, const charT* p2, // have had an unexpected ')' : if(!result) { - fail(regex_constants::error_paren, ::boost::re_detail::distance(m_base, m_position)); + fail(regex_constants::error_paren, ::boost::re_detail::distance(m_base, m_position), "Found a closing ) with no corresponding openening parenthesis."); return; } // if an error has been set then give up now: @@ -168,13 +178,40 @@ void basic_regex_parser::parse(const charT* p1, const charT* p2, template void basic_regex_parser::fail(regex_constants::error_type error_code, std::ptrdiff_t position) +{ + // get the error message: + std::string message = this->m_pdata->m_ptraits->error_string(error_code); + fail(error_code, position, message); +} + +template +void basic_regex_parser::fail(regex_constants::error_type error_code, std::ptrdiff_t position, std::string message, std::ptrdiff_t start_pos) { if(0 == this->m_pdata->m_status) // update the error code if not already set this->m_pdata->m_status = error_code; m_position = m_end; // don't bother parsing anything else - // get the error message: - std::string message = this->m_pdata->m_ptraits->error_string(error_code); - // and raise the exception, this will do nothing if exceptions are disabled: + + // + // Augment error message with the regular expression text: + // + if(start_pos == position) + start_pos = (std::max)(static_cast(0), position - static_cast(10)); + std::ptrdiff_t end_pos = (std::min)(position + static_cast(10), static_cast(m_end - m_base)); + if(error_code != regex_constants::error_empty) + { + if((start_pos != 0) || (end_pos != (m_end - m_base))) + message += " The error occured while parsing the regular expression fragment: '"; + else + message += " The error occured while parsing the regular expression: '"; + if(start_pos != end_pos) + { + message += std::string(m_base + start_pos, m_base + position); + message += ">>>HERE>>>"; + message += std::string(m_base + position, m_base + end_pos); + } + message += "'."; + } + #ifndef BOOST_NO_EXCEPTIONS if(0 == (this->flags() & regex_constants::no_except)) { @@ -282,7 +319,7 @@ bool basic_regex_parser::parse_extended() case regex_constants::syntax_star: if(m_position == this->m_base) { - fail(regex_constants::error_badrepeat, 0); + fail(regex_constants::error_badrepeat, 0, "The repeat operator \"*\" cannot start a regular expression."); return false; } ++m_position; @@ -290,7 +327,7 @@ bool basic_regex_parser::parse_extended() case regex_constants::syntax_question: if(m_position == this->m_base) { - fail(regex_constants::error_badrepeat, 0); + fail(regex_constants::error_badrepeat, 0, "The repeat operator \"?\" cannot start a regular expression."); return false; } ++m_position; @@ -298,7 +335,7 @@ bool basic_regex_parser::parse_extended() case regex_constants::syntax_plus: if(m_position == this->m_base) { - fail(regex_constants::error_badrepeat, 0); + fail(regex_constants::error_badrepeat, 0, "The repeat operator \"+\" cannot start a regular expression."); return false; } ++m_position; @@ -307,7 +344,7 @@ bool basic_regex_parser::parse_extended() ++m_position; return parse_repeat_range(false); case regex_constants::syntax_close_brace: - fail(regex_constants::error_brace, this->m_position - this->m_end); + fail(regex_constants::error_brace, this->m_position - this->m_base, "Found a closing repetition operator } with no corresponding {."); return false; case regex_constants::syntax_or: return parse_alt(); @@ -512,7 +549,7 @@ bool basic_regex_parser::parse_basic_escape() case regex_constants::syntax_close_brace: if(this->flags() & regbase::no_intervals) return parse_literal(); - fail(regex_constants::error_brace, this->m_position - this->m_base); + fail(regex_constants::error_brace, this->m_position - this->m_base, "Found a closing repetition operator } with no corresponding {."); return false; case regex_constants::syntax_or: if(this->flags() & regbase::bk_vbar) @@ -607,7 +644,7 @@ bool basic_regex_parser::parse_basic_escape() case 'c': case 'C': // not supported yet: - fail(regex_constants::error_escape, m_position - m_base); + fail(regex_constants::error_escape, m_position - m_base, "The \\c and \\C escape sequences are not supported by POSIX basic regular expressions: try the Perl syntax instead."); return false; default: break; @@ -705,7 +742,7 @@ escape_type_class_jump: char_class_type m; if(m_position == m_end) { - fail(regex_constants::error_escape, m_position - m_base); + fail(regex_constants::error_escape, m_position - m_base, "Incomplete property escape found."); return false; } // maybe have \p{ddd} @@ -717,7 +754,7 @@ escape_type_class_jump: ++m_position; if(m_position == m_end) { - fail(regex_constants::error_escape, m_position - m_base); + fail(regex_constants::error_escape, m_position - m_base, "Closing } missing from property escape sequence."); return false; } m = this->m_traits.lookup_classname(++base, m_position++); @@ -740,7 +777,7 @@ escape_type_class_jump: } return true; } - fail(regex_constants::error_ctype, m_position - m_base); + fail(regex_constants::error_ctype, m_position - m_base, "Escape sequence was neither a valid property nor a valid character class name."); return false; } case regex_constants::escape_type_reset_start_mark: @@ -776,9 +813,10 @@ escape_type_class_jump: { bool have_brace = false; bool negative = false; + static const char* incomplete_message = "Incomplete \\g escape found."; if(++m_position == m_end) { - fail(regex_constants::error_escape, m_position - m_base); + fail(regex_constants::error_escape, m_position - m_base, incomplete_message); return false; } // maybe have \g{ddd} @@ -786,7 +824,7 @@ escape_type_class_jump: { if(++m_position == m_end) { - fail(regex_constants::error_escape, m_position - m_base); + fail(regex_constants::error_escape, m_position - m_base, incomplete_message); return false; } have_brace = true; @@ -794,7 +832,7 @@ escape_type_class_jump: negative = (*m_position == static_cast('-')); if((negative) && (++m_position == m_end)) { - fail(regex_constants::error_escape, m_position - m_base); + fail(regex_constants::error_escape, m_position - m_base, incomplete_message); return false; } const charT* pc = m_position; @@ -819,7 +857,7 @@ escape_type_class_jump: } else { - fail(regex_constants::error_backref, m_position - m_end); + fail(regex_constants::error_backref, m_position - m_base); return false; } m_position = pc; @@ -827,7 +865,7 @@ escape_type_class_jump: { if((m_position == m_end) || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_brace)) { - fail(regex_constants::error_escape, m_position - m_base); + fail(regex_constants::error_escape, m_position - m_base, incomplete_message); return false; } ++m_position; @@ -894,7 +932,7 @@ bool basic_regex_parser::parse_repeat(std::size_t low, std::size_ } if(0 == this->m_last_state) { - fail(regex_constants::error_badrepeat, ::boost::re_detail::distance(m_base, m_position)); + fail(regex_constants::error_badrepeat, ::boost::re_detail::distance(m_base, m_position), "Nothing to repeat."); return false; } if(this->m_last_state->type == syntax_element_endmark) @@ -968,7 +1006,7 @@ bool basic_regex_parser::parse_repeat(std::size_t low, std::size_ re_brace* pb = static_cast(this->insert_state(insert_point, syntax_element_startmark, sizeof(re_brace))); pb->index = -3; pb->icase = this->flags() & regbase::icase; - re_jump* jmp = static_cast(this->insert_state(insert_point + sizeof(re_brace), syntax_element_jump, sizeof(re_jump))); + jmp = static_cast(this->insert_state(insert_point + sizeof(re_brace), syntax_element_jump, sizeof(re_jump))); this->m_pdata->m_data.align(); jmp->alt.i = this->m_pdata->m_data.size() - this->getoffset(jmp); pb = static_cast(this->append_state(syntax_element_endmark, sizeof(re_brace))); @@ -981,6 +1019,7 @@ bool basic_regex_parser::parse_repeat(std::size_t low, std::size_ template bool basic_regex_parser::parse_repeat_range(bool isbasic) { + static const char* incomplete_message = "Missing } in quantified repetition."; // // parse a repeat-range: // @@ -992,7 +1031,7 @@ bool basic_regex_parser::parse_repeat_range(bool isbasic) // fail if at end: if(this->m_position == this->m_end) { - fail(regex_constants::error_brace, this->m_position - this->m_base); + fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message); return false; } // get min: @@ -1007,7 +1046,7 @@ bool basic_regex_parser::parse_repeat_range(bool isbasic) } else if(this->m_position == this->m_end) { - fail(regex_constants::error_brace, this->m_position - this->m_base); + fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message); return false; } min = v; @@ -1021,7 +1060,7 @@ bool basic_regex_parser::parse_repeat_range(bool isbasic) ++m_position; if(this->m_position == this->m_end) { - fail(regex_constants::error_brace, this->m_position - this->m_base); + fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message); return false; } // get the value if any: @@ -1039,7 +1078,7 @@ bool basic_regex_parser::parse_repeat_range(bool isbasic) // OK now check trailing }: if(this->m_position == this->m_end) { - fail(regex_constants::error_brace, this->m_position - this->m_base); + fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message); return false; } if(isbasic) @@ -1049,13 +1088,13 @@ bool basic_regex_parser::parse_repeat_range(bool isbasic) ++m_position; if(this->m_position == this->m_end) { - fail(regex_constants::error_brace, this->m_position - this->m_base); + fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message); return false; } } else { - fail(regex_constants::error_badbrace, this->m_position - this->m_base); + fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message); return false; } } @@ -1063,7 +1102,7 @@ bool basic_regex_parser::parse_repeat_range(bool isbasic) ++m_position; else { - fail(regex_constants::error_badbrace, this->m_position - this->m_base); + fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message); return false; } // @@ -1071,7 +1110,11 @@ bool basic_regex_parser::parse_repeat_range(bool isbasic) // if(min > max) { - fail(regex_constants::error_badbrace, this->m_position - this->m_base); + // Backtrack to error location: + m_position -= 2; + while(this->m_traits.isctype(*m_position, this->m_word_mask)) --m_position; + ++m_position; + fail(regex_constants::error_badbrace, m_position - m_base); return false; } return parse_repeat(min, max); @@ -1094,7 +1137,7 @@ bool basic_regex_parser::parse_alt() ) ) { - fail(regex_constants::error_empty, this->m_position - this->m_base); + fail(regex_constants::error_empty, this->m_position - this->m_base, "A regular expression can start with the alternation operator |."); return false; } // @@ -1146,10 +1189,11 @@ bool basic_regex_parser::parse_alt() template bool basic_regex_parser::parse_set() { + static const char* incomplete_message = "Character set declaration starting with [ terminated prematurely - either no ] was found or the set had no content."; ++m_position; if(m_position == m_end) { - fail(regex_constants::error_brack, m_position - m_base); + fail(regex_constants::error_brack, m_position - m_base, incomplete_message); return false; } basic_char_set char_set; @@ -1182,7 +1226,7 @@ bool basic_regex_parser::parse_set() ++m_position; if(0 == this->append_set(char_set)) { - fail(regex_constants::error_range, m_position - m_base); + fail(regex_constants::error_ctype, m_position - m_base); return false; } } @@ -1237,6 +1281,7 @@ bool basic_regex_parser::parse_set() template bool basic_regex_parser::parse_inner_set(basic_char_set& char_set) { + static const char* incomplete_message = "Character class declaration starting with [ terminated prematurely - either no ] was found or the set had no content."; // // we have either a character class [:name:] // a collating element [.name.] @@ -1244,7 +1289,7 @@ bool basic_regex_parser::parse_inner_set(basic_char_setm_traits.syntax_type(*m_position)) @@ -1269,14 +1314,14 @@ bool basic_regex_parser::parse_inner_set(basic_char_set::parse_inner_set(basic_char_setm_traits.syntax_type(*m_position) != regex_constants::syntax_close_set)) { - fail(regex_constants::error_brack, m_position - m_base); + fail(regex_constants::error_brack, m_position - m_base, incomplete_message); return false; } // @@ -1346,14 +1391,14 @@ bool basic_regex_parser::parse_inner_set(basic_char_set::parse_inner_set(basic_char_setm_traits.syntax_type(*m_position) != regex_constants::syntax_close_set)) { - fail(regex_constants::error_brack, m_position - m_base); + fail(regex_constants::error_brack, m_position - m_base, incomplete_message); return false; } string_type m = this->m_traits.lookup_collatename(name_first, name_last); @@ -1558,7 +1603,7 @@ charT basic_regex_parser::unescape_character() charT result(0); if(m_position == m_end) { - fail(regex_constants::error_escape, m_position - m_base); + fail(regex_constants::error_escape, m_position - m_base, "Escape sequence terminated prematurely."); return false; } switch(this->m_traits.escape_syntax_type(*m_position)) @@ -1591,24 +1636,22 @@ charT basic_regex_parser::unescape_character() ++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); + // Rewind to start of escape: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position; + fail(regex_constants::error_escape, m_position - m_base, "ASCII escape sequence terminated prematurely."); return result; } - */ 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); + // Rewind to start of escape: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position; + fail(regex_constants::error_escape, m_position - m_base, "Hexadecimal escape sequence terminated prematurely."); return result; } // maybe have \x{ddd} @@ -1617,7 +1660,10 @@ charT basic_regex_parser::unescape_character() ++m_position; if(m_position == m_end) { - fail(regex_constants::error_escape, m_position - m_base); + // Rewind to start of escape: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position; + fail(regex_constants::error_escape, m_position - m_base, "Missing } in hexadecimal escape sequence."); return result; } int i = this->m_traits.toi(m_position, m_end, 16); @@ -1626,7 +1672,10 @@ charT basic_regex_parser::unescape_character() || ((std::numeric_limits::is_specialized) && (i > (int)(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); + // Rewind to start of escape: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position; + fail(regex_constants::error_badbrace, m_position - m_base, "Hexadecimal escape sequence was invalid."); return result; } ++m_position; @@ -1634,12 +1683,15 @@ charT basic_regex_parser::unescape_character() } else { - std::ptrdiff_t len = (std::min)(static_cast(2), m_end - m_position); + std::ptrdiff_t len = (std::min)(static_cast(2), static_cast(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); + // Rewind to start of escape: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position; + fail(regex_constants::error_escape, m_position - m_base, "Escape sequence did not encode a valid character."); return result; } result = charT(i); @@ -1654,14 +1706,20 @@ charT basic_regex_parser::unescape_character() int val = this->m_traits.toi(bp, bp + 1, 8); if(val != 0) { + // Rewind to start of escape: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position; // Oops not an octal escape after all: - fail(regex_constants::error_escape, m_position - m_base); + fail(regex_constants::error_escape, m_position - m_base, "Invalid octal escape sequence."); return result; } val = this->m_traits.toi(m_position, m_position + len, 8); if(val < 0) { - fail(regex_constants::error_escape, m_position - m_base); + // Rewind to start of escape: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position; + fail(regex_constants::error_escape, m_position - m_base, "Octal escape sequence is invalid."); return result; } return static_cast(val); @@ -1671,6 +1729,9 @@ charT basic_regex_parser::unescape_character() ++m_position; if(m_position == m_end) { + // Rewind to start of escape: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position; fail(regex_constants::error_escape, m_position - m_base); return false; } @@ -1683,12 +1744,18 @@ charT basic_regex_parser::unescape_character() ++m_position; if(m_position == m_end) { + // Rewind to start of escape: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position; fail(regex_constants::error_escape, m_position - m_base); return false; } string_type s = this->m_traits.lookup_collatename(++base, m_position++); if(s.empty()) { + // Rewind to start of escape: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position; fail(regex_constants::error_collate, m_position - m_base); return false; } @@ -1698,6 +1765,9 @@ charT basic_regex_parser::unescape_character() } } // fall through is a failure: + // Rewind to start of escape: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position; fail(regex_constants::error_escape, m_position - m_base); return false; } @@ -1733,7 +1803,10 @@ bool basic_regex_parser::parse_backref() } else { - fail(regex_constants::error_backref, m_position - m_end); + // Rewind to start of escape: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position; + fail(regex_constants::error_backref, m_position - m_base); return false; } return true; @@ -1765,7 +1838,7 @@ bool basic_regex_parser::parse_QE() } if(++m_position == m_end) // skip the escape { - fail(regex_constants::error_escape, m_position - m_base); + fail(regex_constants::error_escape, m_position - m_base, "Unterminated \\Q...\\E sequence."); return false; } // check to see if it's a \E: @@ -1796,7 +1869,10 @@ bool basic_regex_parser::parse_perl_extension() { if(++m_position == m_end) { - fail(regex_constants::error_badrepeat, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } // @@ -1855,12 +1931,17 @@ bool basic_regex_parser::parse_perl_extension() v = this->m_traits.toi(m_position, m_end, 10); if((v < 0) || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark)) { - fail(regex_constants::error_backref, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base, "The recursive sub-expression refers to an invalid marking group, or is unterminated."); return false; } insert_recursion: pb->index = markid = 0; - static_cast(this->append_state(syntax_element_recurse, sizeof(re_jump)))->alt.i = v; + re_recurse* pr = static_cast(this->append_state(syntax_element_recurse, sizeof(re_recurse))); + pr->alt.i = v; + pr->state_id = 0; static_cast( this->append_state(syntax_element_toggle_case, sizeof(re_case)) )->icase = this->flags() & regbase::icase; @@ -1874,7 +1955,10 @@ insert_recursion: v = this->m_traits.toi(m_position, m_end, 10); if((v <= 0) || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark)) { - fail(regex_constants::error_backref, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base, "An invalid or unterminated recursive sub-expression."); return false; } v += m_mark_count; @@ -1894,7 +1978,10 @@ insert_recursion: v = m_mark_count + 1 - v; if(v <= 0) { - fail(regex_constants::error_backref, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base, "An invalid or unterminated recursive sub-expression."); return false; } goto insert_recursion; @@ -1917,7 +2004,10 @@ insert_recursion: // a lookbehind assertion: if(++m_position == m_end) { - fail(regex_constants::error_badrepeat, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } regex_constants::syntax_type t = this->m_traits.syntax_type(*m_position); @@ -1955,15 +2045,21 @@ insert_recursion: pb->index = markid = -4; if(++m_position == m_end) { - fail(regex_constants::error_badrepeat, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } - int v = this->m_traits.toi(m_position, m_end, 10); + v = this->m_traits.toi(m_position, m_end, 10); if(*m_position == charT('R')) { if(++m_position == m_end) { - fail(regex_constants::error_badrepeat, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } if(*m_position == charT('&')) @@ -1973,7 +2069,10 @@ insert_recursion: ++m_position; if(m_position == m_end) { - fail(regex_constants::error_badrepeat, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } v = -static_cast(hash_value_from_capture_name(base, m_position)); @@ -1986,12 +2085,18 @@ insert_recursion: br->index = v < 0 ? (v - 1) : 0; if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark) { - fail(regex_constants::error_badrepeat, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } if(++m_position == m_end) { - fail(regex_constants::error_badrepeat, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } } @@ -2002,7 +2107,10 @@ insert_recursion: ++m_position; if(m_position == m_end) { - fail(regex_constants::error_badrepeat, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } v = static_cast(hash_value_from_capture_name(base, m_position)); @@ -2010,17 +2118,26 @@ insert_recursion: br->index = v; if(((*m_position != charT('>')) && (*m_position != charT('\''))) || (++m_position == m_end)) { - fail(regex_constants::error_badrepeat, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base, "Unterminated named capture."); return false; } if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark) { - fail(regex_constants::error_badrepeat, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } if(++m_position == m_end) { - fail(regex_constants::error_badrepeat, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } } @@ -2031,19 +2148,28 @@ insert_recursion: ++m_position, ++def; if((m_position == m_end) || *def) { - fail(regex_constants::error_badrepeat, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } re_brace* br = static_cast(this->append_state(syntax_element_assert_backref, sizeof(re_brace))); br->index = 9999; // special magic value! if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark) { - fail(regex_constants::error_badrepeat, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } if(++m_position == m_end) { - fail(regex_constants::error_badrepeat, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } } @@ -2053,12 +2179,18 @@ insert_recursion: br->index = v; if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark) { - fail(regex_constants::error_badrepeat, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } if(++m_position == m_end) { - fail(regex_constants::error_badrepeat, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } } @@ -2067,25 +2199,37 @@ insert_recursion: // verify that we have a lookahead or lookbehind assert: if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_question) { - fail(regex_constants::error_badrepeat, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } if(++m_position == m_end) { - fail(regex_constants::error_badrepeat, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } if(this->m_traits.syntax_type(*m_position) == regex_constants::escape_type_left_word) { if(++m_position == m_end) { - fail(regex_constants::error_badrepeat, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } if((this->m_traits.syntax_type(*m_position) != regex_constants::syntax_equal) && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_not)) { - fail(regex_constants::error_badrepeat, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } m_position -= 3; @@ -2095,7 +2239,10 @@ insert_recursion: if((this->m_traits.syntax_type(*m_position) != regex_constants::syntax_equal) && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_not)) { - fail(regex_constants::error_paren, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } m_position -= 2; @@ -2104,7 +2251,10 @@ insert_recursion: break; } case regex_constants::syntax_close_mark: - fail(regex_constants::error_badrepeat, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; case regex_constants::escape_type_end_buffer: { @@ -2126,14 +2276,20 @@ named_capture_jump: const charT* base = ++m_position; if(m_position == m_end) { - fail(regex_constants::error_paren, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } while((m_position != m_end) && (*m_position != name_delim)) ++m_position; if(m_position == m_end) { - fail(regex_constants::error_paren, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } this->m_pdata->set_name(base, m_position, markid); @@ -2147,7 +2303,10 @@ named_capture_jump: v = 0; if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark) { - fail(regex_constants::error_backref, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } goto insert_recursion; @@ -2160,7 +2319,10 @@ named_capture_jump: ++m_position; if(m_position == m_end) { - fail(regex_constants::error_backref, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } v = static_cast(hash_value_from_capture_name(base, m_position)); @@ -2171,7 +2333,10 @@ named_capture_jump: ++m_position; if(m_position == m_end) { - fail(regex_constants::error_backref, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } if(*m_position == charT('>')) @@ -2182,7 +2347,10 @@ named_capture_jump: ++m_position; if(m_position == m_end) { - fail(regex_constants::error_backref, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } v = static_cast(hash_value_from_capture_name(base, m_position)); @@ -2195,7 +2363,13 @@ named_capture_jump: option_group_jump: regex_constants::syntax_option_type opts = parse_options(); if(m_position == m_end) + { + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; + } // make a note of whether we have a case change: m_has_case_change = ((opts & regbase::icase) != (this->flags() & regbase::icase)); pb->index = markid = 0; @@ -2214,7 +2388,10 @@ option_group_jump: } else { - fail(regex_constants::error_badrepeat, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); return false; } @@ -2236,12 +2413,21 @@ option_group_jump: // Unwind alternatives: // if(0 == unwind_alts(last_paren_start)) + { + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base, "Invalid alternation operators within (?...) block."); return false; + } // // we either have a ')' or we have run out of characters prematurely: // if(m_position == m_end) { + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; this->fail(regex_constants::error_paren, ::boost::re_detail::distance(m_base, m_end)); return false; } @@ -2272,7 +2458,10 @@ option_group_jump: if(this->m_last_state == jmp) { // Oops... we didn't have anything inside the assertion: - fail(regex_constants::error_empty, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base, "Invalid or empty zero width assertion."); return false; } } @@ -2292,7 +2481,10 @@ option_group_jump: else if(this->getaddress(static_cast(b)->alt.i, b)->type == syntax_element_alt) { // Can't have seen more than one alternative: - fail(regex_constants::error_bad_pattern, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_bad_pattern, m_position - m_base, "More than one alternation operator | was encountered inside a conditional expression."); return false; } else @@ -2301,7 +2493,10 @@ option_group_jump: b = this->getaddress(b->next.i, b); if((b->type == syntax_element_assert_backref) && (static_cast(b)->index == 9999)) { - fail(regex_constants::error_bad_pattern, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_bad_pattern, m_position - m_base, "Alternation operators are not allowed inside a DEFINE block."); return false; } } @@ -2311,7 +2506,10 @@ option_group_jump: if((b->type != syntax_element_assert_backref) && (b->type != syntax_element_startmark)) { - fail(regex_constants::error_badrepeat, m_position - m_base); + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_badrepeat, m_position - m_base, "A repetition operator cannot be applied to a zero-width assertion."); return false; } } @@ -2366,6 +2564,9 @@ bool basic_regex_parser::add_emacs_code(bool negate) // if(++m_position == m_end) { + // Rewind to start of sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape) --m_position; fail(regex_constants::error_escape, m_position - m_base); return false; } @@ -2466,6 +2667,9 @@ regex_constants::syntax_option_type basic_regex_parser::parse_opt } if(++m_position == m_end) { + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; fail(regex_constants::error_paren, m_position - m_base); return false; } @@ -2476,6 +2680,9 @@ regex_constants::syntax_option_type basic_regex_parser::parse_opt { if(++m_position == m_end) { + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; fail(regex_constants::error_paren, m_position - m_base); return false; } @@ -2502,6 +2709,9 @@ regex_constants::syntax_option_type basic_regex_parser::parse_opt } if(++m_position == m_end) { + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; fail(regex_constants::error_paren, m_position - m_base); return false; } @@ -2528,7 +2738,7 @@ bool basic_regex_parser::unwind_alts(std::ptrdiff_t last_paren_st ) ) { - fail(regex_constants::error_empty, this->m_position - this->m_base); + fail(regex_constants::error_empty, this->m_position - this->m_base, "Can't terminate a sub-expression with an alternation operator |."); return false; } // diff --git a/boost/boost/regex/v4/cpp_regex_traits.hpp b/boost/boost/regex/v4/cpp_regex_traits.hpp index 7ce3ed300e..bb40aa1ed8 100644 --- a/boost/boost/regex/v4/cpp_regex_traits.hpp +++ b/boost/boost/regex/v4/cpp_regex_traits.hpp @@ -187,6 +187,7 @@ struct cpp_regex_traits_base #ifndef BOOST_NO_STD_MESSAGES if(m_pmessages == b.m_pmessages) { + return m_pcollate < b.m_pcollate; } return m_pmessages < b.m_pmessages; #else @@ -212,7 +213,7 @@ std::locale cpp_regex_traits_base::imbue(const std::locale& l) m_locale = l; m_pctype = &BOOST_USE_FACET(std::ctype, l); #ifndef BOOST_NO_STD_MESSAGES - m_pmessages = &BOOST_USE_FACET(std::messages, l); + m_pmessages = BOOST_HAS_FACET(std::messages, l) ? &BOOST_USE_FACET(std::messages, l) : 0; #endif m_pcollate = &BOOST_USE_FACET(std::collate, l); return result; @@ -276,7 +277,7 @@ void cpp_regex_traits_char_layer::init() typename std::messages::catalog cat = reinterpret_cast::catalog>(-1); #endif std::string cat_name(cpp_regex_traits::get_catalog_name()); - if(cat_name.size()) + if(cat_name.size() && (this->m_pmessages != 0)) { cat = this->m_pmessages->open( cat_name, @@ -309,7 +310,8 @@ void cpp_regex_traits_char_layer::init() } catch(...) { - this->m_pmessages->close(cat); + if(this->m_pmessages) + this->m_pmessages->close(cat); throw; } #endif @@ -653,7 +655,7 @@ void cpp_regex_traits_implementation::init() typename std::messages::catalog cat = reinterpret_cast::catalog>(-1); #endif std::string cat_name(cpp_regex_traits::get_catalog_name()); - if(cat_name.size()) + if(cat_name.size() && (this->m_pmessages != 0)) { cat = this->m_pmessages->open( cat_name, @@ -716,7 +718,7 @@ void cpp_regex_traits_implementation::init() cpp_regex_traits_implementation::mask_unicode, }; #else - static const char_class_type masks[14] = + static const char_class_type masks[16] = { ::boost::re_detail::char_class_alnum, ::boost::re_detail::char_class_alpha, @@ -837,8 +839,8 @@ bool cpp_regex_traits_implementation::isctype(const charT c, char_class_t || ((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)) - || ((mask & ::boost::re_detail::char_class_vertical) && (is_separator(c) || (c == '\v'))) - || ((mask & ::boost::re_detail::char_class_horizontal) && m_pctype->is(std::ctype::space, c) && !(is_separator(c) || (c == '\v'))); + || ((mask & ::boost::re_detail::char_class_vertical_space) && (is_separator(c) || (c == '\v'))) + || ((mask & ::boost::re_detail::char_class_horizontal_space) && m_pctype->is(std::ctype::space, c) && !(is_separator(c) || (c == '\v'))); } #endif diff --git a/boost/boost/regex/v4/cregex.hpp b/boost/boost/regex/v4/cregex.hpp index cafe396cd9..7b3df1e510 100644 --- a/boost/boost/regex/v4/cregex.hpp +++ b/boost/boost/regex/v4/cregex.hpp @@ -124,11 +124,11 @@ typedef enum{ REG_STARTEND = 00004 } reg_exec_flags; -// -// POSIX error codes: -// +/* + * POSIX error codes: + */ typedef unsigned reg_error_t; -typedef reg_error_t reg_errcode_t; // backwards compatibility +typedef reg_error_t reg_errcode_t; /* backwards compatibility */ static const reg_error_t REG_NOERROR = 0; /* Success. */ static const reg_error_t REG_NOMATCH = 1; /* Didn't find a match (for regexec). */ @@ -154,8 +154,9 @@ static const reg_error_t REG_EMPTY = 17; /* empty expression */ static const reg_error_t REG_E_MEMORY = 15; /* = REG_ESIZE : out of memory */ static const reg_error_t REG_ECOMPLEXITY = 18; /* complexity too high */ static const reg_error_t REG_ESTACK = 19; /* out of stack space */ -static const reg_error_t REG_E_UNKNOWN = 20; /* unknown error */ -static const reg_error_t REG_ENOSYS = 20; /* = REG_E_UNKNOWN : Reserved. */ +static const reg_error_t REG_E_PERL = 20; /* Perl (?...) error */ +static const reg_error_t REG_E_UNKNOWN = 21; /* unknown error */ +static const reg_error_t REG_ENOSYS = 21; /* = REG_E_UNKNOWN : Reserved. */ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA*, const char*, int); BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int, const regex_tA*, char*, regsize_t); @@ -195,14 +196,14 @@ BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeW(regex_tW*); #endif #ifdef __cplusplus -} // extern "C" -} // namespace +} /* extern "C" */ +} /* namespace */ #endif -// -// C++ high level wrapper goes here: -// #if defined(__cplusplus) +/* + * C++ high level wrapper goes here: + */ #include #include namespace boost{ @@ -228,7 +229,7 @@ struct pred2; struct pred3; struct pred4; -} // namespace re_detail +} /* namespace re_detail */ #if (defined(BOOST_MSVC) || defined(__BORLANDC__)) && !defined(BOOST_DISABLE_WIN32) typedef bool (__cdecl *GrepCallback)(const RegEx& expression); @@ -257,9 +258,9 @@ public: unsigned int SetExpression(const std::string& s, bool icase = false){ return SetExpression(s.c_str(), icase); } std::string Expression()const; unsigned int error_code()const; - // - // now matching operators: - // + /* + * now matching operators: + */ bool Match(const char* p, match_flag_type flags = match_default); bool Match(const std::string& s, match_flag_type flags = match_default) { return Match(s.c_str(), flags); } bool Search(const char* p, match_flag_type flags = match_default); @@ -283,9 +284,9 @@ public: bool copy = true, match_flag_type flags = match_default); std::size_t Split(std::vector& v, std::string& s, match_flag_type flags = match_default, unsigned max_count = ~0); - // - // now operators for returning what matched in more detail: - // + /* + * now operators for returning what matched in more detail: + */ std::size_t Position(int i = 0)const; std::size_t Length(int i = 0)const; bool Matched(int i = 0)const; @@ -312,11 +313,11 @@ public: #pragma warning(pop) #endif -} // namespace boost +} /* namespace boost */ -#endif +#endif /* __cplusplus */ -#endif // include guard +#endif /* include guard */ diff --git a/boost/boost/regex/v4/error_type.hpp b/boost/boost/regex/v4/error_type.hpp index b6633a0092..afcc71e3d8 100644 --- a/boost/boost/regex/v4/error_type.hpp +++ b/boost/boost/regex/v4/error_type.hpp @@ -28,8 +28,8 @@ namespace regex_constants{ enum error_type{ - error_ok = 0, // not used - error_no_match = 1, // not used + error_ok = 0, /* not used */ + error_no_match = 1, /* not used */ error_bad_pattern = 2, error_collate = 3, error_ctype = 4, @@ -42,17 +42,18 @@ enum error_type{ error_range = 11, error_space = 12, error_badrepeat = 13, - error_end = 14, // not used + error_end = 14, /* not used */ error_size = 15, - error_right_paren = 16, // not used + error_right_paren = 16, /* not used */ error_empty = 17, error_complexity = 18, error_stack = 19, - error_unknown = 20 + error_perl_extension = 20, + error_unknown = 21 }; } } -#endif // __cplusplus +#endif /* __cplusplus */ #endif diff --git a/boost/boost/regex/v4/match_flags.hpp b/boost/boost/regex/v4/match_flags.hpp index 9585aca8b2..26bde9a51b 100644 --- a/boost/boost/regex/v4/match_flags.hpp +++ b/boost/boost/regex/v4/match_flags.hpp @@ -31,43 +31,43 @@ namespace boost{ typedef enum _match_flags { match_default = 0, - match_not_bol = 1, // first is not start of line - match_not_eol = match_not_bol << 1, // last is not end of line - match_not_bob = match_not_eol << 1, // first is not start of buffer - match_not_eob = match_not_bob << 1, // last is not end of buffer - match_not_bow = match_not_eob << 1, // first is not start of word - match_not_eow = match_not_bow << 1, // last is not end of word - match_not_dot_newline = match_not_eow << 1, // \n is not matched by '.' - match_not_dot_null = match_not_dot_newline << 1, // '\0' is not matched by '.' - match_prev_avail = match_not_dot_null << 1, // *--first is a valid expression - match_init = match_prev_avail << 1, // internal use - match_any = match_init << 1, // don't care what we match - match_not_null = match_any << 1, // string can't be null - match_continuous = match_not_null << 1, // each grep match must continue from - // uninterupted from the previous one - match_partial = match_continuous << 1, // find partial matches + match_not_bol = 1, /* first is not start of line */ + match_not_eol = match_not_bol << 1, /* last is not end of line */ + match_not_bob = match_not_eol << 1, /* first is not start of buffer */ + match_not_eob = match_not_bob << 1, /* last is not end of buffer */ + match_not_bow = match_not_eob << 1, /* first is not start of word */ + match_not_eow = match_not_bow << 1, /* last is not end of word */ + match_not_dot_newline = match_not_eow << 1, /* \n is not matched by '.' */ + match_not_dot_null = match_not_dot_newline << 1, /* '\0' is not matched by '.' */ + match_prev_avail = match_not_dot_null << 1, /* *--first is a valid expression */ + match_init = match_prev_avail << 1, /* internal use */ + match_any = match_init << 1, /* don't care what we match */ + match_not_null = match_any << 1, /* string can't be null */ + match_continuous = match_not_null << 1, /* each grep match must continue from */ + /* uninterupted from the previous one */ + match_partial = match_continuous << 1, /* find partial matches */ - match_stop = match_partial << 1, // stop after first match (grep) V3 only - match_not_initial_null = match_stop, // don't match initial null, V4 only - match_all = match_stop << 1, // must find the whole of input even if match_any is set - match_perl = match_all << 1, // Use perl matching rules - match_posix = match_perl << 1, // Use POSIX matching rules - match_nosubs = match_posix << 1, // don't trap marked subs - match_extra = match_nosubs << 1, // include full capture information for repeated captures - match_single_line = match_extra << 1, // treat text as single line and ignor any \n's when matching ^ and $. - match_unused1 = match_single_line << 1, // unused - match_unused2 = match_unused1 << 1, // unused - match_unused3 = match_unused2 << 1, // unused + match_stop = match_partial << 1, /* stop after first match (grep) V3 only */ + match_not_initial_null = match_stop, /* don't match initial null, V4 only */ + match_all = match_stop << 1, /* must find the whole of input even if match_any is set */ + match_perl = match_all << 1, /* Use perl matching rules */ + match_posix = match_perl << 1, /* Use POSIX matching rules */ + match_nosubs = match_posix << 1, /* don't trap marked subs */ + match_extra = match_nosubs << 1, /* include full capture information for repeated captures */ + match_single_line = match_extra << 1, /* treat text as single line and ignor any \n's when matching ^ and $. */ + match_unused1 = match_single_line << 1, /* unused */ + match_unused2 = match_unused1 << 1, /* unused */ + match_unused3 = match_unused2 << 1, /* unused */ match_max = match_unused3, - format_perl = 0, // perl style replacement - format_default = 0, // ditto. - format_sed = match_max << 1, // sed style replacement. - format_all = format_sed << 1, // enable all extentions to sytax. - format_no_copy = format_all << 1, // don't copy non-matching segments. - format_first_only = format_no_copy << 1, // Only replace first occurance. - format_is_if = format_first_only << 1, // internal use only. - format_literal = format_is_if << 1 // treat string as a literal + format_perl = 0, /* perl style replacement */ + format_default = 0, /* ditto. */ + format_sed = match_max << 1, /* sed style replacement. */ + format_all = format_sed << 1, /* enable all extentions to sytax. */ + format_no_copy = format_all << 1, /* don't copy non-matching segments. */ + format_first_only = format_no_copy << 1, /* Only replace first occurance. */ + format_is_if = format_first_only << 1, /* internal use only. */ + format_literal = format_is_if << 1 /* treat string as a literal */ } match_flags; @@ -96,10 +96,10 @@ inline match_flags& operator^=(match_flags& m1, match_flags m2) #endif #ifdef __cplusplus -} // namespace regex_constants -// -// import names into boost for backwards compatiblity: -// +} /* namespace regex_constants */ +/* + * import names into boost for backwards compatiblity: + */ using regex_constants::match_flag_type; using regex_constants::match_default; using regex_constants::match_not_bol; @@ -111,28 +111,28 @@ using regex_constants::match_not_eow; using regex_constants::match_not_dot_newline; using regex_constants::match_not_dot_null; using regex_constants::match_prev_avail; -//using regex_constants::match_init; +/* using regex_constants::match_init; */ using regex_constants::match_any; using regex_constants::match_not_null; using regex_constants::match_continuous; using regex_constants::match_partial; -//using regex_constants::match_stop; +/*using regex_constants::match_stop; */ using regex_constants::match_all; using regex_constants::match_perl; using regex_constants::match_posix; using regex_constants::match_nosubs; using regex_constants::match_extra; using regex_constants::match_single_line; -//using regex_constants::match_max; +/*using regex_constants::match_max; */ using regex_constants::format_all; using regex_constants::format_sed; using regex_constants::format_perl; using regex_constants::format_default; using regex_constants::format_no_copy; using regex_constants::format_first_only; -//using regex_constants::format_is_if; +/*using regex_constants::format_is_if;*/ -} // namespace boost -#endif // __cplusplus -#endif // include guard +} /* namespace boost */ +#endif /* __cplusplus */ +#endif /* include guard */ diff --git a/boost/boost/regex/v4/match_results.hpp b/boost/boost/regex/v4/match_results.hpp index 09dd31f009..cd6b9eb556 100644 --- a/boost/boost/regex/v4/match_results.hpp +++ b/boost/boost/regex/v4/match_results.hpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 1998-2002 + * Copyright (c) 1998-2009 * John Maddock * * Use, modification and distribution are subject to the @@ -74,16 +74,30 @@ public: // construct/copy/destroy: explicit match_results(const Allocator& a = Allocator()) #ifndef BOOST_NO_STD_ALLOCATOR - : m_subs(a), m_base(), m_last_closed_paren(0) {} + : m_subs(a), m_base(), m_last_closed_paren(0), m_is_singular(true) {} #else - : m_subs(), m_base(), m_last_closed_paren(0) { (void)a; } + : m_subs(), m_base(), m_last_closed_paren(0), m_is_singular(true) { (void)a; } #endif match_results(const match_results& m) - : m_subs(m.m_subs), m_base(m.m_base) {} + : m_subs(m.m_subs), m_named_subs(m.m_named_subs), m_last_closed_paren(m.m_last_closed_paren), m_is_singular(m.m_is_singular) + { + if(!m_is_singular) + { + m_base = m.m_base; + m_null = m.m_null; + } + } match_results& operator=(const match_results& m) { m_subs = m.m_subs; - m_base = m.m_base; + m_named_subs = m.m_named_subs; + m_last_closed_paren = m.m_last_closed_paren; + m_is_singular = m.m_is_singular; + if(!m_is_singular) + { + m_base = m.m_base; + m_null = m.m_null; + } return *this; } ~match_results(){} @@ -98,6 +112,8 @@ public: // element access: difference_type length(int sub = 0) const { + if(m_is_singular) + raise_logic_error(); sub += 2; if((sub < (int)m_subs.size()) && (sub > 0)) return m_subs[sub].length(); @@ -105,16 +121,20 @@ public: } difference_type length(const char_type* sub) const { - const char_type* end = sub; - while(*end) ++end; - return length(named_subexpression_index(sub, end)); + if(m_is_singular) + raise_logic_error(); + const char_type* sub_end = sub; + while(*sub_end) ++sub_end; + return length(named_subexpression_index(sub, sub_end)); } template difference_type length(const charT* sub) const { - const charT* end = sub; - while(*end) ++end; - return length(named_subexpression_index(sub, end)); + if(m_is_singular) + raise_logic_error(); + const charT* sub_end = sub; + while(*sub_end) ++sub_end; + return length(named_subexpression_index(sub, sub_end)); } template difference_type length(const std::basic_string& sub) const @@ -123,6 +143,8 @@ public: } difference_type position(size_type sub = 0) const { + if(m_is_singular) + raise_logic_error(); sub += 2; if(sub < m_subs.size()) { @@ -136,16 +158,16 @@ public: } difference_type position(const char_type* sub) const { - const char_type* end = sub; - while(*end) ++end; - return position(named_subexpression_index(sub, end)); + const char_type* sub_end = sub; + while(*sub_end) ++sub_end; + return position(named_subexpression_index(sub, sub_end)); } template difference_type position(const charT* sub) const { - const charT* end = sub; - while(*end) ++end; - return position(named_subexpression_index(sub, end)); + const charT* sub_end = sub; + while(*sub_end) ++sub_end; + return position(named_subexpression_index(sub, sub_end)); } template difference_type position(const std::basic_string& sub) const @@ -154,6 +176,8 @@ public: } string_type str(int sub = 0) const { + if(m_is_singular) + raise_logic_error(); sub += 2; string_type result; if(sub < (int)m_subs.size() && (sub > 0)) @@ -187,6 +211,8 @@ public: } const_reference operator[](int sub) const { + if(m_is_singular && m_subs.empty()) + raise_logic_error(); sub += 2; if(sub < (int)m_subs.size() && (sub >= 0)) { @@ -199,6 +225,8 @@ public: // const_reference named_subexpression(const char_type* i, const char_type* j) const { + if(m_is_singular) + raise_logic_error(); int index = m_named_subs->get_id(i, j); return index > 0 ? (*this)[index] : m_null; } @@ -215,6 +243,8 @@ public: } int named_subexpression_index(const char_type* i, const char_type* j) const { + if(m_is_singular) + raise_logic_error(); int index = m_named_subs->get_id(i, j); return index > 0 ? index : -20; } @@ -266,11 +296,15 @@ public: const_reference prefix() const { + if(m_is_singular) + raise_logic_error(); return (*this)[-1]; } const_reference suffix() const { + if(m_is_singular) + raise_logic_error(); return (*this)[-2]; } const_iterator begin() const @@ -282,44 +316,67 @@ public: return m_subs.end(); } // format: - template + template OutputIterator format(OutputIterator out, - const string_type& fmt, + Functor fmt, match_flag_type flags = format_default) const { - re_detail::trivial_format_traits traits; - return re_detail::regex_format_imp(out, *this, fmt.data(), fmt.data() + fmt.size(), flags, traits); + if(m_is_singular) + raise_logic_error(); + typedef typename re_detail::compute_functor_type, OutputIterator>::type F; + F func(fmt); + return func(*this, out, flags); } - string_type format(const string_type& fmt, - match_flag_type flags = format_default) const + template + string_type format(Functor fmt, match_flag_type flags = format_default) const { - 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); + if(m_is_singular) + raise_logic_error(); + std::basic_string result; + re_detail::string_out_iterator > i(result); + + typedef typename re_detail::compute_functor_type, re_detail::string_out_iterator > >::type F; + F func(fmt); + + func(*this, i, flags); return result; } // format with locale: - template + template OutputIterator format(OutputIterator out, - const string_type& fmt, + Functor 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()); + if(m_is_singular) + raise_logic_error(); + typedef ::boost::regex_traits_wrapper traits_type; + typedef typename re_detail::compute_functor_type, OutputIterator, traits_type>::type F; + F func(fmt); + return func(*this, out, flags, re.get_traits()); } - template - string_type format(const string_type& fmt, + template + string_type format(Functor 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()); + if(m_is_singular) + raise_logic_error(); + typedef ::boost::regex_traits_wrapper traits_type; + std::basic_string result; + re_detail::string_out_iterator > i(result); + + typedef typename re_detail::compute_functor_type, re_detail::string_out_iterator >, traits_type >::type F; + F func(fmt); + + func(*this, i, flags, re.get_traits()); return result; } + const_reference get_last_closed_paren()const { + if(m_is_singular) + raise_logic_error(); return m_last_closed_paren == 0 ? m_null : (*this)[m_last_closed_paren]; } @@ -334,11 +391,39 @@ public: void swap(match_results& that) { std::swap(m_subs, that.m_subs); - std::swap(m_base, that.m_base); + std::swap(m_named_subs, that.m_named_subs); + std::swap(m_last_closed_paren, that.m_last_closed_paren); + std::swap(m_is_singular, that.m_is_singular); + if(m_is_singular) + { + if(!that.m_is_singular) + { + m_base = that.m_base; + m_null = that.m_null; + } + } + else if(that.m_is_singular) + { + that.m_base = m_base; + that.m_null = m_null; + } + else + { + std::swap(m_base, that.m_base); + std::swap(m_null, that.m_null); + } } bool operator==(const match_results& that)const { - return (m_subs == that.m_subs) && (m_base == that.m_base); + if(m_is_singular) + { + return that.m_is_singular; + } + else if(that.m_is_singular) + { + return false; + } + return (m_subs == that.m_subs) && (m_base == that.m_base) && (m_last_closed_paren == that.m_last_closed_paren); } bool operator!=(const match_results& that)const { return !(*this == that); } @@ -348,6 +433,8 @@ public: const capture_sequence_type& captures(int i)const { + if(m_is_singular) + raise_logic_error(); return (*this)[i].captures(); } #endif @@ -364,6 +451,7 @@ public: m_null.first = i; m_null.second = i; m_null.matched = false; + m_is_singular = false; } void BOOST_REGEX_CALL set_second(BidiIterator i, size_type pos, bool m = true, bool escape_k = false) @@ -381,6 +469,7 @@ public: m_null.first = i; m_null.second = i; m_null.matched = false; + m_is_singular = false; } } void BOOST_REGEX_CALL set_size(size_type n, BidiIterator i, BidiIterator j) @@ -411,6 +500,7 @@ public: } void BOOST_REGEX_CALL set_first(BidiIterator i) { + BOOST_ASSERT(m_subs.size() > 2); // set up prefix: m_subs[1].second = i; m_subs[1].matched = (m_subs[1].first != i); @@ -446,16 +536,32 @@ public: } private: - vector_type m_subs; // subexpressions - BidiIterator m_base; // where the search started from - sub_match m_null; // a null match - boost::shared_ptr m_named_subs; - int m_last_closed_paren; + // + // Error handler called when an uninitialized match_results is accessed: + // + static void raise_logic_error() + { + std::logic_error e("Attempt to access an uninitialzed boost::match_results<> class."); + boost::throw_exception(e); + } + + + vector_type m_subs; // subexpressions + BidiIterator m_base; // where the search started from + sub_match m_null; // a null match + boost::shared_ptr m_named_subs; // Shared copy of named subs in the regex object + int m_last_closed_paren; // Last ) to be seen - used for formatting + bool m_is_singular; // True if our stored iterators are singular }; template void BOOST_REGEX_CALL match_results::maybe_assign(const match_results& m) { + if(m_is_singular) + { + *this = m; + return; + } const_iterator p1, p2; p1 = begin(); p2 = m.begin(); diff --git a/boost/boost/regex/v4/perl_matcher.hpp b/boost/boost/regex/v4/perl_matcher.hpp index 726c2881e5..52e0bcecb5 100644 --- a/boost/boost/regex/v4/perl_matcher.hpp +++ b/boost/boost/regex/v4/perl_matcher.hpp @@ -61,7 +61,7 @@ inline bool can_start(unsigned short c, const unsigned char* map, unsigned char { return ((c >= (1 << CHAR_BIT)) ? true : map[c] & mask); } -#if !defined(__hpux) // WCHAR_MIN not usable in pp-directives. +#if !defined(__hpux) && !defined(__WINSCW__)// WCHAR_MIN not usable in pp-directives. #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) { @@ -277,10 +277,15 @@ public: else { repeater_count* p = next; - while(p->state_id != state_id) + while(p && (p->state_id != state_id)) p = p->next; - count = p->count; - start_pos = p->start_pos; + if(p) + { + count = p->count; + start_pos = p->start_pos; + } + else + count = 0; } } ~repeater_count() diff --git a/boost/boost/regex/v4/perl_matcher_non_recursive.hpp b/boost/boost/regex/v4/perl_matcher_non_recursive.hpp index 2ce7ebe034..0fcd45482a 100644 --- a/boost/boost/regex/v4/perl_matcher_non_recursive.hpp +++ b/boost/boost/regex/v4/perl_matcher_non_recursive.hpp @@ -188,7 +188,7 @@ bool perl_matcher::match_all_states() if(!(this->*proc)()) { if(state_count > max_state_count) - raise_error(traits_inst, regex_constants::error_space); + raise_error(traits_inst, regex_constants::error_complexity); if((m_match_flags & match_partial) && (position == last) && (position != search_base)) m_has_partial_match = true; bool successful_unwind = unwind(false); @@ -219,7 +219,7 @@ void perl_matcher::extend_stack() m_backup_state = block; } else - raise_error(traits_inst, regex_constants::error_size); + raise_error(traits_inst, regex_constants::error_stack); } template @@ -904,10 +904,15 @@ bool perl_matcher::match_recursion() } recursion_stack[recursion_stack_position].preturn_address = pstate->next.p; recursion_stack[recursion_stack_position].results = *m_presult; + if(static_cast(pstate)->state_id > 0) + { + push_repeater_count(static_cast(pstate)->state_id, &next_count); + } pstate = static_cast(pstate)->alt.p; recursion_stack[recursion_stack_position].id = static_cast(pstate)->index; ++recursion_stack_position; //BOOST_ASSERT(recursion_stack[recursion_stack_position-1].id); + return true; } diff --git a/boost/boost/regex/v4/perl_matcher_recursive.hpp b/boost/boost/regex/v4/perl_matcher_recursive.hpp index 48f08b7b8d..d0de8025ee 100644 --- a/boost/boost/regex/v4/perl_matcher_recursive.hpp +++ b/boost/boost/regex/v4/perl_matcher_recursive.hpp @@ -99,7 +99,7 @@ bool perl_matcher::match_all_states() }; if(state_count > max_state_count) - raise_error(traits_inst, regex_constants::error_space); + raise_error(traits_inst, regex_constants::error_complexity); while(pstate) { matcher_proc_type proc = s_match_vtable[pstate->type]; diff --git a/boost/boost/regex/v4/regex_format.hpp b/boost/boost/regex/v4/regex_format.hpp index 4e95112f90..0ca9baa7ae 100644 --- a/boost/boost/regex/v4/regex_format.hpp +++ b/boost/boost/regex/v4/regex_format.hpp @@ -1,7 +1,7 @@ /* * - * Copyright (c) 1998-2002 - * John Maddock + * Copyright (c) 1998-2009 John Maddock + * Copyright 2008 Eric Niebler. * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -21,6 +21,19 @@ #ifndef BOOST_REGEX_FORMAT_HPP #define BOOST_REGEX_FORMAT_HPP +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef BOOST_NO_SFINAE +#include +#endif namespace boost{ @@ -76,15 +89,15 @@ struct trivial_format_traits } }; -template +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_restore_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) + OutputIterator format(ForwardIter p1, ForwardIter p2, match_flag_type f); + OutputIterator format(ForwardIter p1, match_flag_type f) { return format(p1, p1 + m_traits.length(p1), f); } @@ -109,22 +122,75 @@ private: void format_until_scope_end(); bool handle_perl_verb(bool have_brace); - 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 - output_state m_restore_state; // what state to restore to. - bool m_have_conditional; // we are parsing a conditional + inline typename Results::value_type const& get_named_sub(ForwardIter i, ForwardIter j, const mpl::false_&) + { + std::vector v(i, j); + return (i != j) ? this->m_results.named_subexpression(&v[0], &v[0] + v.size()) + : this->m_results.named_subexpression(static_cast(0), static_cast(0)); + } + inline typename Results::value_type const& get_named_sub(ForwardIter i, ForwardIter j, const mpl::true_&) + { + return this->m_results.named_subexpression(i, j); + } + inline typename Results::value_type const& get_named_sub(ForwardIter i, ForwardIter j) + { + typedef typename boost::is_convertible::type tag_type; + return get_named_sub(i, j, tag_type()); + } + inline int get_named_sub_index(ForwardIter i, ForwardIter j, const mpl::false_&) + { + std::vector v(i, j); + return (i != j) ? this->m_results.named_subexpression_index(&v[0], &v[0] + v.size()) + : this->m_results.named_subexpression_index(static_cast(0), static_cast(0)); + } + inline int get_named_sub_index(ForwardIter i, ForwardIter j, const mpl::true_&) + { + return this->m_results.named_subexpression_index(i, j); + } + inline int get_named_sub_index(ForwardIter i, ForwardIter j) + { + typedef typename boost::is_convertible::type tag_type; + return get_named_sub_index(i, j, tag_type()); + } + inline int toi(ForwardIter& i, ForwardIter j, int base, const boost::mpl::false_&) + { + if(i != j) + { + std::vector v(i, j); + const char_type* start = &v[0]; + const char_type* pos = start; + int r = m_traits.toi(pos, &v[0] + v.size(), base); + std::advance(i, pos - start); + return r; + } + return -1; + } + inline int toi(ForwardIter& i, ForwardIter j, int base, const boost::mpl::true_&) + { + return m_traits.toi(i, j, base); + } + inline int toi(ForwardIter& i, ForwardIter j, int base) + { + typedef typename boost::is_convertible::type tag_type; + return toi(i, j, base, tag_type()); + } + + 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. + ForwardIter m_position; // format string, current position + ForwardIter 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 + output_state m_restore_state; // what state to restore to. + 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) +template +OutputIterator basic_regex_formatter::format(ForwardIter p1, ForwardIter p2, match_flag_type f) { m_position = p1; m_end = p2; @@ -133,8 +199,8 @@ OutputIterator basic_regex_formatter::format(co return m_out; } -template -void basic_regex_formatter::format_all() +template +void basic_regex_formatter::format_all() { // over and over: while(m_position != m_end) @@ -211,8 +277,8 @@ void basic_regex_formatter::format_all() } } -template -void basic_regex_formatter::format_perl() +template +void basic_regex_formatter::format_perl() { // // On entry *m_position points to a '$' character @@ -233,7 +299,7 @@ void basic_regex_formatter::format_perl() // OK find out what kind it is: // bool have_brace = false; - const char_type* save_position = m_position; + ForwardIter save_position = m_position; switch(*m_position) { case '&': @@ -254,12 +320,12 @@ void basic_regex_formatter::format_perl() case '+': if((++m_position != m_end) && (*m_position == '{')) { - const char_type* base = ++m_position; + ForwardIter base = ++m_position; while((m_position != m_end) && (*m_position != '}')) ++m_position; if(m_position != m_end) { // Named sub-expression: - put(this->m_results.named_subexpression(base, m_position)); + put(get_named_sub(base, m_position)); ++m_position; break; } @@ -279,7 +345,7 @@ void basic_regex_formatter::format_perl() { std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end); //len = (std::min)(static_cast(2), len); - int v = m_traits.toi(m_position, m_position + len, 10); + int v = this->toi(m_position, m_position + len, 10); if((v < 0) || (have_brace && ((m_position == m_end) || (*m_position != '}')))) { // Look for a Perl-5.10 verb: @@ -300,8 +366,8 @@ void basic_regex_formatter::format_perl() } } -template -bool basic_regex_formatter::handle_perl_verb(bool have_brace) +template +bool basic_regex_formatter::handle_perl_verb(bool have_brace) { // // We may have a capitalised string containing a Perl action: @@ -313,6 +379,8 @@ bool basic_regex_formatter::handle_perl_verb(bo static const char_type LAST_SUBMATCH_RESULT[] = { 'L', 'A', 'S', 'T', '_', 'S', 'U', 'B', 'M', 'A', 'T', 'C', 'H', '_', 'R', 'E', 'S', 'U', 'L', 'T' }; static const char_type LAST_SUBMATCH_RESULT_ALT[] = { '^', 'N' }; + if(m_position == m_end) + return false; if(have_brace && (*m_position == '^')) ++m_position; @@ -323,7 +391,7 @@ bool basic_regex_formatter::handle_perl_verb(bo m_position += 5; if(have_brace) { - if(*m_position == '}') + if((m_position != m_end) && (*m_position == '}')) ++m_position; else { @@ -339,7 +407,7 @@ bool basic_regex_formatter::handle_perl_verb(bo m_position += 8; if(have_brace) { - if(*m_position == '}') + if((m_position != m_end) && (*m_position == '}')) ++m_position; else { @@ -355,7 +423,7 @@ bool basic_regex_formatter::handle_perl_verb(bo m_position += 9; if(have_brace) { - if(*m_position == '}') + if((m_position != m_end) && (*m_position == '}')) ++m_position; else { @@ -371,7 +439,7 @@ bool basic_regex_formatter::handle_perl_verb(bo m_position += 16; if(have_brace) { - if(*m_position == '}') + if((m_position != m_end) && (*m_position == '}')) ++m_position; else { @@ -387,7 +455,7 @@ bool basic_regex_formatter::handle_perl_verb(bo m_position += 20; if(have_brace) { - if(*m_position == '}') + if((m_position != m_end) && (*m_position == '}')) ++m_position; else { @@ -403,7 +471,7 @@ bool basic_regex_formatter::handle_perl_verb(bo m_position += 2; if(have_brace) { - if(*m_position == '}') + if((m_position != m_end) && (*m_position == '}')) ++m_position; else { @@ -417,8 +485,8 @@ bool basic_regex_formatter::handle_perl_verb(bo return false; } -template -void basic_regex_formatter::format_escape() +template +void basic_regex_formatter::format_escape() { // skip the escape and check for trailing escape: if(++m_position == m_end) @@ -463,7 +531,7 @@ void basic_regex_formatter::format_escape() if(*m_position == static_cast('{')) { ++m_position; - int val = m_traits.toi(m_position, m_end, 16); + int val = this->toi(m_position, m_end, 16); if(val < 0) { // invalid value treat everything as literals: @@ -471,8 +539,9 @@ void basic_regex_formatter::format_escape() put(static_cast('{')); return; } - if(*m_position != static_cast('}')) + if((m_position == m_end) || (*m_position != static_cast('}'))) { + --m_position; while(*m_position != static_cast('\\')) --m_position; ++m_position; @@ -487,7 +556,7 @@ void basic_regex_formatter::format_escape() { std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end); len = (std::min)(static_cast(2), len); - int val = m_traits.toi(m_position, m_position + len, 16); + int val = this->toi(m_position, m_position + len, 16); if(val < 0) { --m_position; @@ -549,7 +618,9 @@ void basic_regex_formatter::format_escape() break; } // see if we have a \n sed style backreference: - int v = m_traits.toi(m_position, m_position+1, 10); + std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end); + len = (std::min)(static_cast(1), len); + int v = this->toi(m_position, m_position+len, 10); if((v > 0) || ((v == 0) && (m_flags & ::boost::regex_constants::format_sed))) { put(m_results[v]); @@ -559,9 +630,9 @@ void basic_regex_formatter::format_escape() { // octal ecape sequence: --m_position; - std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end); + len = ::boost::re_detail::distance(m_position, m_end); len = (std::min)(static_cast(4), len); - v = m_traits.toi(m_position, m_position + len, 8); + v = this->toi(m_position, m_position + len, 8); BOOST_ASSERT(v >= 0); put(static_cast(v)); break; @@ -572,8 +643,8 @@ void basic_regex_formatter::format_escape() } } -template -void basic_regex_formatter::format_conditional() +template +void basic_regex_formatter::format_conditional() { if(m_position == m_end) { @@ -584,15 +655,15 @@ void basic_regex_formatter::format_conditional( int v; if(*m_position == '{') { - const char_type* base = m_position; + ForwardIter base = m_position; ++m_position; - v = m_traits.toi(m_position, m_end, 10); + v = this->toi(m_position, m_end, 10); if(v < 0) { // Try a named subexpression: while((m_position != m_end) && (*m_position != '}')) ++m_position; - v = m_results.named_subexpression_index(base + 1, m_position); + v = this->get_named_sub_index(base + 1, m_position); } if((v < 0) || (*m_position != '}')) { @@ -608,7 +679,7 @@ void basic_regex_formatter::format_conditional( { std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end); len = (std::min)(static_cast(2), len); - v = m_traits.toi(m_position, m_position + len, 10); + v = this->toi(m_position, m_position + len, 10); } if(v < 0) { @@ -657,8 +728,8 @@ void basic_regex_formatter::format_conditional( } } -template -void basic_regex_formatter::format_until_scope_end() +template +void basic_regex_formatter::format_until_scope_end() { do { @@ -669,8 +740,8 @@ void basic_regex_formatter::format_until_scope_ }while(m_position != m_end); } -template -void basic_regex_formatter::put(char_type c) +template +void basic_regex_formatter::put(char_type c) { // write a single character to output // according to which case translation mode we are in: @@ -699,8 +770,8 @@ void basic_regex_formatter::put(char_type c) ++m_out; } -template -void basic_regex_formatter::put(const sub_match_type& sub) +template +void basic_regex_formatter::put(const sub_match_type& sub) { typedef typename sub_match_type::iterator iterator_type; iterator_type i = sub.first; @@ -738,10 +809,10 @@ public: #endif }; -template +template OutputIterator regex_format_imp(OutputIterator out, const match_results& m, - const charT* p1, const charT* p2, + ForwardIter p1, ForwardIter p2, match_flag_type flags, const traits& t ) @@ -754,57 +825,289 @@ OutputIterator regex_format_imp(OutputIterator out, re_detail::basic_regex_formatter< OutputIterator, match_results, - traits > f(out, m, t); + traits, ForwardIter> f(out, m, t); return f.format(p1, p2, flags); } +#ifndef BOOST_NO_SFINAE -} // namespace re_detail +BOOST_MPL_HAS_XXX_TRAIT_DEF(const_iterator) -template -OutputIterator regex_format(OutputIterator out, - const match_results& m, - const charT* fmt, - match_flag_type flags = format_all - ) +struct any_type { any_type(...); }; +typedef char no_type; +typedef char (&unary_type)[2]; +typedef char (&binary_type)[3]; +typedef char (&ternary_type)[4]; + +no_type check_is_formatter(unary_type, binary_type, ternary_type); +template +unary_type check_is_formatter(T const &, binary_type, ternary_type); +template +binary_type check_is_formatter(unary_type, T const &, ternary_type); +template +binary_type check_is_formatter(T const &, U const &, ternary_type); +template +ternary_type check_is_formatter(unary_type, binary_type, T const &); +template +ternary_type check_is_formatter(T const &, binary_type, U const &); +template +ternary_type check_is_formatter(unary_type, T const &, U const &); +template +ternary_type check_is_formatter(T const &, U const &, V const &); + +struct unary_binary_ternary { - re_detail::trivial_format_traits traits; - return re_detail::regex_format_imp(out, m, fmt, fmt + traits.length(fmt), flags, traits); -} + typedef unary_type (*unary_fun)(any_type); + typedef binary_type (*binary_fun)(any_type, any_type); + typedef ternary_type (*ternary_fun)(any_type, any_type, any_type); + operator unary_fun(); + operator binary_fun(); + operator ternary_fun(); +}; -template -OutputIterator regex_format(OutputIterator out, - const match_results& m, - const std::basic_string& fmt, - match_flag_type flags = format_all - ) +template::value> +struct formatter_wrapper + : Formatter + , unary_binary_ternary { - re_detail::trivial_format_traits traits; - return re_detail::regex_format_imp(out, m, fmt.data(), fmt.data() + fmt.size(), flags, traits); -} + formatter_wrapper(){} +}; -template -std::basic_string regex_format(const match_results& m, - const charT* fmt, - match_flag_type flags = format_all) +template +struct formatter_wrapper + : unary_binary_ternary +{ + operator Formatter *(); +}; + +template +struct formatter_wrapper + : unary_binary_ternary +{ + operator Formatter *(); +}; + +template +struct format_traits_imp +{ +private: + // + // F must be a pointer, a function, or a class with a function call operator: + // + BOOST_STATIC_ASSERT((::boost::is_pointer::value || ::boost::is_function::value || ::boost::is_class::value)); + static formatter_wrapper f; + static M m; + static O out; + static boost::regex_constants::match_flag_type flags; +public: + BOOST_STATIC_CONSTANT(int, value = sizeof(check_is_formatter(f(m), f(m, out), f(m, out, flags)))); +}; + +template +struct format_traits +{ +public: + // + // Type is mpl::int_ where N is one of: + // + // 0 : F is a pointer to a presumably null-terminated string. + // 1 : F is a character-container such as a std::string. + // 2 : F is a Unary Functor. + // 3 : F is a Binary Functor. + // 4 : F is a Ternary Functor. + // + typedef typename boost::mpl::if_< + boost::mpl::and_, boost::mpl::not_::type> > >, + boost::mpl::int_<0>, + typename boost::mpl::if_< + has_const_iterator, + boost::mpl::int_<1>, + boost::mpl::int_::value> + >::type + >::type type; + // + // This static assertion will fail if the functor passed does not accept + // the same type of arguments passed. + // + BOOST_STATIC_ASSERT( boost::is_class::value && !has_const_iterator::value ? (type::value > 1) : true); +}; + +#else // BOOST_NO_SFINAE + +template +struct format_traits +{ +public: + // + // Type is mpl::int_ where N is one of: + // + // 0 : F is a pointer to a presumably null-terminated string. + // 1 : F is a character-container such as a std::string. + // + // Other options such as F being a Functor are not supported without + // SFINAE support. + // + typedef typename boost::mpl::if_< + boost::is_pointer, + boost::mpl::int_<0>, + boost::mpl::int_<1> + >::type type; +}; + +#endif // BOOST_NO_SFINAE + +template +struct format_functor3 +{ + format_functor3(Base b) : func(b) {} + template + OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f) + { + return func(m, i, f); + } + template + OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f, const Traits&) + { + return (*this)(m, i, f); + } +private: + Base func; + format_functor3(const format_functor3&); + format_functor3& operator=(const format_functor3&); +}; + +template +struct format_functor2 +{ + format_functor2(Base b) : func(b) {} + template + OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type /*f*/) + { + return func(m, i); + } + template + OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f, const Traits&) + { + return (*this)(m, i, f); + } +private: + Base func; + format_functor2(const format_functor2&); + format_functor2& operator=(const format_functor2&); +}; + +template +struct format_functor1 +{ + format_functor1(Base b) : func(b) {} + + template + OutputIter do_format_string(const S& s, OutputIter i) + { + return re_detail::copy(s.begin(), s.end(), i); + } + template + inline OutputIter do_format_string(const S* s, OutputIter i) + { + while(s && *s) + { + *i = *s; + ++i; + ++s; + } + return i; + } + template + OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type /*f*/) + { + return do_format_string(func(m), i); + } + template + OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f, const Traits&) + { + return (*this)(m, i, f); + } +private: + Base func; + format_functor1(const format_functor1&); + format_functor1& operator=(const format_functor1&); +}; + +template +struct format_functor_c_string +{ + format_functor_c_string(const charT* ps) : func(ps) {} + + template + OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f, const Traits& t = Traits()) + { + typedef typename Match::char_type char_type; + const charT* end = func; + while(*end) ++end; + return regex_format_imp(i, m, func, end, f, t); + } +private: + const charT* func; + format_functor_c_string(const format_functor_c_string&); + format_functor_c_string& operator=(const format_functor_c_string&); +}; + +template +struct format_functor_container +{ + format_functor_container(const Container& c) : func(c) {} + + template + OutputIter operator()(const Match& m, OutputIter i, boost::regex_constants::match_flag_type f, const Traits& t = Traits()) + { + typedef typename Match::char_type char_type; + return re_detail::regex_format_imp(i, m, func.begin(), func.end(), f, t); + } +private: + const Container& func; + format_functor_container(const format_functor_container&); + format_functor_container& operator=(const format_functor_container&); +}; + +template > +struct compute_functor_type +{ + typedef typename format_traits::type tag; + typedef typename boost::remove_cv< typename boost::remove_pointer::type>::type maybe_char_type; + + typedef typename mpl::if_< + ::boost::is_same >, format_functor_c_string, + typename mpl::if_< + ::boost::is_same >, format_functor_container, + typename mpl::if_< + ::boost::is_same >, format_functor1, + typename mpl::if_< + ::boost::is_same >, format_functor2, + format_functor3 + >::type + >::type + >::type + >::type type; +}; + +} // namespace re_detail + +template +inline OutputIterator regex_format(OutputIterator out, + const match_results& m, + Functor fmt, + match_flag_type flags = format_all + ) { - std::basic_string result; - re_detail::string_out_iterator > i(result); - re_detail::trivial_format_traits traits; - re_detail::regex_format_imp(i, m, fmt, fmt + traits.length(fmt), flags, traits); - return result; + return m.format(out, fmt, flags); } -template -std::basic_string regex_format(const match_results& m, - const std::basic_string& fmt, +template +inline std::basic_string::char_type> regex_format(const match_results& m, + Functor fmt, match_flag_type flags = format_all) { - std::basic_string result; - re_detail::string_out_iterator > i(result); - re_detail::trivial_format_traits traits; - re_detail::regex_format_imp(i, m, fmt.data(), fmt.data() + fmt.size(), flags, traits); - return result; + return m.format(fmt, flags); } #ifdef BOOST_MSVC diff --git a/boost/boost/regex/v4/regex_replace.hpp b/boost/boost/regex/v4/regex_replace.hpp index c4544c05b9..ac8e3c81e2 100644 --- a/boost/boost/regex/v4/regex_replace.hpp +++ b/boost/boost/regex/v4/regex_replace.hpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 1998-2002 + * Copyright (c) 1998-2009 * John Maddock * * Use, modification and distribution are subject to the @@ -35,12 +35,12 @@ namespace boost{ #pragma warning(pop) #endif -template +template OutputIterator regex_replace(OutputIterator out, BidirectionalIterator first, BidirectionalIterator last, const basic_regex& e, - const charT* fmt, + Formatter fmt, match_flag_type flags = match_default) { regex_iterator i(first, last, e, flags); @@ -69,21 +69,10 @@ OutputIterator regex_replace(OutputIterator out, return out; } -template -inline OutputIterator regex_replace(OutputIterator out, - Iterator first, - Iterator last, - 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 basic_regex& e, - const charT* fmt, + Formatter fmt, match_flag_type flags = match_default) { std::basic_string result; @@ -92,18 +81,6 @@ std::basic_string regex_replace(const std::basic_string& s, return result; } -template -std::basic_string regex_replace(const std::basic_string& s, - const basic_regex& e, - const std::basic_string& fmt, - match_flag_type flags = match_default) -{ - std::basic_string result; - re_detail::string_out_iterator > i(result); - regex_replace(i, s.begin(), s.end(), e, fmt.c_str(), flags); - return result; -} - #ifdef BOOST_MSVC #pragma warning(push) #pragma warning(disable: 4103) diff --git a/boost/boost/regex/v4/regex_traits_defaults.hpp b/boost/boost/regex/v4/regex_traits_defaults.hpp index 5b2c6bc338..ca13f195dc 100644 --- a/boost/boost/regex/v4/regex_traits_defaults.hpp +++ b/boost/boost/regex/v4/regex_traits_defaults.hpp @@ -84,7 +84,7 @@ inline bool is_combining(unsigned char) { return false; } -#ifndef __hpux // can't use WCHAR_MAX/MIN in pp-directives +#if !defined(__hpux) && !defined(__WINSCW__) // can't use WCHAR_MAX/MIN in pp-directives #ifdef _MSC_VER template<> inline bool is_combining(wchar_t c) @@ -322,7 +322,7 @@ inline const charT* get_escape_R_string() { #ifdef BOOST_MSVC # pragma warning(push) -# pragma warning(disable:4309) +# pragma warning(disable:4309 4245) #endif static const charT e1[] = { '(', '?', '>', '\x0D', '\x0A', '?', '|', '[', '\x0A', '\x0B', '\x0C', '\x85', '\\', 'x', '{', '2', '0', '2', '8', '}', diff --git a/boost/boost/regex/v4/states.hpp b/boost/boost/regex/v4/states.hpp index efdebbe59f..38690b2299 100644 --- a/boost/boost/regex/v4/states.hpp +++ b/boost/boost/regex/v4/states.hpp @@ -248,6 +248,14 @@ struct re_repeat : public re_alt bool greedy; // True if this is a greedy repeat }; +/*** struct re_recurse ************************************************ +Recurse to a particular subexpression. +**********************************************************************/ +struct re_recurse : public re_jump +{ + int state_id; // identifier of first nested repeat within the recursion. +}; + /*** enum re_jump_size_type ******************************************* Provides compiled size of re_jump structure (allowing for trailing alignment). We provide this so we know how manybytes to insert when constructing the machine diff --git a/boost/boost/regex/v4/u32regex_iterator.hpp b/boost/boost/regex/v4/u32regex_iterator.hpp index 7e893e6951..65ebd7f8ea 100644 --- a/boost/boost/regex/v4/u32regex_iterator.hpp +++ b/boost/boost/regex/v4/u32regex_iterator.hpp @@ -178,7 +178,7 @@ inline u32regex_iterator::const typedef typename std::basic_string::const_iterator iter_type; return u32regex_iterator(p.begin(), p.end(), e, m); } -inline u32regex_iterator make_u32regex_iterator(const UnicodeString& s, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default) +inline u32regex_iterator make_u32regex_iterator(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default) { return u32regex_iterator(s.getBuffer(), s.getBuffer() + s.length(), e, m); } diff --git a/boost/boost/regex/v4/u32regex_token_iterator.hpp b/boost/boost/regex/v4/u32regex_token_iterator.hpp index 2726d486fd..c47a2192c7 100644 --- a/boost/boost/regex/v4/u32regex_token_iterator.hpp +++ b/boost/boost/regex/v4/u32regex_token_iterator.hpp @@ -294,7 +294,7 @@ inline u32regex_token_iterator: typedef typename std::basic_string::const_iterator iter_type; return u32regex_token_iterator(p.begin(), p.end(), e, m); } -inline u32regex_token_iterator make_u32regex_token_iterator(const UnicodeString& s, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) +inline u32regex_token_iterator make_u32regex_token_iterator(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) { return u32regex_token_iterator(s.getBuffer(), s.getBuffer() + s.length(), e, submatch, m); } @@ -327,7 +327,7 @@ inline u32regex_token_iterator: return u32regex_token_iterator(p.begin(), p.end(), e, m); } template -inline u32regex_token_iterator make_u32regex_token_iterator(const UnicodeString& s, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) +inline u32regex_token_iterator make_u32regex_token_iterator(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) { return u32regex_token_iterator(s.getBuffer(), s.getBuffer() + s.length(), e, submatch, m); } @@ -356,7 +356,7 @@ inline u32regex_token_iterator: typedef typename std::basic_string::const_iterator iter_type; return u32regex_token_iterator(p.begin(), p.end(), e, m); } -inline u32regex_token_iterator make_u32regex_token_iterator(const UnicodeString& s, const u32regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default) +inline u32regex_token_iterator make_u32regex_token_iterator(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default) { return u32regex_token_iterator(s.getBuffer(), s.getBuffer() + s.length(), e, submatch, m); } diff --git a/boost/boost/smart_ptr/detail/lwm_pthreads.hpp b/boost/boost/smart_ptr/detail/lwm_pthreads.hpp index fc20dbb145..8eda518233 100644 --- a/boost/boost/smart_ptr/detail/lwm_pthreads.hpp +++ b/boost/boost/smart_ptr/detail/lwm_pthreads.hpp @@ -17,6 +17,7 @@ // http://www.boost.org/LICENSE_1_0.txt) // +#include #include namespace boost @@ -42,15 +43,15 @@ public: // HPUX 10.20 / DCE has a nonstandard pthread_mutex_init #if defined(__hpux) && defined(_DECTHREADS_) - pthread_mutex_init(&m_, pthread_mutexattr_default); + BOOST_VERIFY( pthread_mutex_init( &m_, pthread_mutexattr_default ) == 0 ); #else - pthread_mutex_init(&m_, 0); + BOOST_VERIFY( pthread_mutex_init( &m_, 0 ) == 0 ); #endif } ~lightweight_mutex() { - pthread_mutex_destroy(&m_); + BOOST_VERIFY( pthread_mutex_destroy( &m_ ) == 0 ); } class scoped_lock; @@ -69,12 +70,12 @@ public: scoped_lock(lightweight_mutex & m): m_(m.m_) { - pthread_mutex_lock(&m_); + BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); } ~scoped_lock() { - pthread_mutex_unlock(&m_); + BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); } }; }; diff --git a/boost/boost/smart_ptr/detail/quick_allocator.hpp b/boost/boost/smart_ptr/detail/quick_allocator.hpp index 6d136f82d7..159bd5e7aa 100644 --- a/boost/boost/smart_ptr/detail/quick_allocator.hpp +++ b/boost/boost/smart_ptr/detail/quick_allocator.hpp @@ -74,8 +74,9 @@ template struct allocator_impl static lightweight_mutex & mutex() { - static lightweight_mutex m; - return m; + static freeblock< sizeof( lightweight_mutex ), boost::alignment_of< lightweight_mutex >::value > fbm; + static lightweight_mutex * pm = new( &fbm ) lightweight_mutex; + return *pm; } static lightweight_mutex * mutex_init; diff --git a/boost/boost/smart_ptr/detail/sp_convertible.hpp b/boost/boost/smart_ptr/detail/sp_convertible.hpp index 66e5ec7338..b7f0ea8f2d 100644 --- a/boost/boost/smart_ptr/detail/sp_convertible.hpp +++ b/boost/boost/smart_ptr/detail/sp_convertible.hpp @@ -25,7 +25,7 @@ # define BOOST_SP_NO_SP_CONVERTIBLE #endif -#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( __BORLANDC__ ) && ( __BORLANDC__ <= 0x610 ) +#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( __BORLANDC__ ) && ( __BORLANDC__ <= 0x620 ) # define BOOST_SP_NO_SP_CONVERTIBLE #endif diff --git a/boost/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp b/boost/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp index 8af6f0a972..21fa59dcc4 100644 --- a/boost/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp +++ b/boost/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp @@ -30,9 +30,9 @@ namespace detail inline int32_t compare_and_swap( int32_t * dest_, int32_t compare_, int32_t swap_ ) { - __asm__ __volatile__( "cas %0, %2, %1" - : "+m" (*dest_), "+r" (swap_) - : "r" (compare_) + __asm__ __volatile__( "cas [%1], %2, %0" + : "+r" (swap_) + : "r" (dest_), "r" (compare_) : "memory" ); return swap_; diff --git a/boost/boost/smart_ptr/detail/sp_has_sync.hpp b/boost/boost/smart_ptr/detail/sp_has_sync.hpp index cb0282dbad..7fcd09ef08 100644 --- a/boost/boost/smart_ptr/detail/sp_has_sync.hpp +++ b/boost/boost/smart_ptr/detail/sp_has_sync.hpp @@ -40,7 +40,7 @@ #undef BOOST_SP_HAS_SYNC #endif -#if defined( __INTEL_COMPILER ) && !defined( __ia64__ ) +#if defined( __INTEL_COMPILER ) && !defined( __ia64__ ) && ( __INTEL_COMPILER < 1100 ) #undef BOOST_SP_HAS_SYNC #endif diff --git a/boost/boost/smart_ptr/intrusive_ptr.hpp b/boost/boost/smart_ptr/intrusive_ptr.hpp index 6927a59185..e72eb21869 100644 --- a/boost/boost/smart_ptr/intrusive_ptr.hpp +++ b/boost/boost/smart_ptr/intrusive_ptr.hpp @@ -77,7 +77,7 @@ public: template #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) - intrusive_ptr( intrusive_ptr const & rhs, typename detail::sp_enable_if_convertible::type = detail::sp_empty() ) + intrusive_ptr( intrusive_ptr const & rhs, typename boost::detail::sp_enable_if_convertible::type = boost::detail::sp_empty() ) #else @@ -122,7 +122,7 @@ public: intrusive_ptr & operator=(intrusive_ptr && rhs) { - this_type(std::move(rhs)).swap(*this); + this_type( static_cast< intrusive_ptr && >( rhs ) ).swap(*this); return *this; } diff --git a/boost/boost/smart_ptr/make_shared.hpp b/boost/boost/smart_ptr/make_shared.hpp index 7e1e793e19..d47718808c 100644 --- a/boost/boost/smart_ptr/make_shared.hpp +++ b/boost/boost/smart_ptr/make_shared.hpp @@ -86,10 +86,12 @@ public: } }; -template< class T > T forward( T t ) +#if defined( BOOST_HAS_RVALUE_REFS ) +template< class T > T&& forward( T &&t ) { return t; } +#endif } // namespace detail diff --git a/boost/boost/smart_ptr/shared_ptr.hpp b/boost/boost/smart_ptr/shared_ptr.hpp index 1b367f0f4d..609cce9032 100644 --- a/boost/boost/smart_ptr/shared_ptr.hpp +++ b/boost/boost/smart_ptr/shared_ptr.hpp @@ -228,7 +228,7 @@ public: template #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) - shared_ptr( shared_ptr const & r, typename detail::sp_enable_if_convertible::type = detail::sp_empty() ) + shared_ptr( shared_ptr const & r, typename boost::detail::sp_enable_if_convertible::type = boost::detail::sp_empty() ) #else @@ -353,7 +353,7 @@ public: template #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) - shared_ptr( shared_ptr && r, typename detail::sp_enable_if_convertible::type = detail::sp_empty() ) + shared_ptr( shared_ptr && r, typename boost::detail::sp_enable_if_convertible::type = boost::detail::sp_empty() ) #else @@ -368,14 +368,14 @@ public: shared_ptr & operator=( shared_ptr && r ) // never throws { - this_type( std::move( r ) ).swap( *this ); + this_type( static_cast< shared_ptr && >( r ) ).swap( *this ); return *this; } template shared_ptr & operator=( shared_ptr && r ) // never throws { - this_type( std::move( r ) ).swap( *this ); + this_type( static_cast< shared_ptr && >( r ) ).swap( *this ); return *this; } @@ -448,7 +448,7 @@ public: return pn < rhs.pn; } - void * _internal_get_deleter( detail::sp_typeinfo const & ti ) const + void * _internal_get_deleter( boost::detail::sp_typeinfo const & ti ) const { return pn.get_deleter( ti ); } diff --git a/boost/boost/smart_ptr/weak_ptr.hpp b/boost/boost/smart_ptr/weak_ptr.hpp index 621c433a03..d314b0df3e 100644 --- a/boost/boost/smart_ptr/weak_ptr.hpp +++ b/boost/boost/smart_ptr/weak_ptr.hpp @@ -63,7 +63,7 @@ public: template #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) - weak_ptr( weak_ptr const & r, typename detail::sp_enable_if_convertible::type = detail::sp_empty() ) + weak_ptr( weak_ptr const & r, typename boost::detail::sp_enable_if_convertible::type = boost::detail::sp_empty() ) #else @@ -79,20 +79,20 @@ public: template #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) - weak_ptr( weak_ptr && r, typename detail::sp_enable_if_convertible::type = detail::sp_empty() ) + weak_ptr( weak_ptr && r, typename boost::detail::sp_enable_if_convertible::type = boost::detail::sp_empty() ) #else weak_ptr( weak_ptr && r ) #endif - : px(r.lock().get()), pn(std::move(r.pn)) // never throws + : px( r.lock().get() ), pn( static_cast< boost::detail::weak_count && >( r.pn ) ) // never throws { r.px = 0; } // for better efficiency in the T == Y case - weak_ptr( weak_ptr && r ): px( r.px ), pn(std::move(r.pn)) // never throws + weak_ptr( weak_ptr && r ): px( r.px ), pn( static_cast< boost::detail::weak_count && >( r.pn ) ) // never throws { r.px = 0; } @@ -100,7 +100,7 @@ public: // for better efficiency in the T == Y case weak_ptr & operator=( weak_ptr && r ) // never throws { - this_type( std::move( r ) ).swap( *this ); + this_type( static_cast< weak_ptr && >( r ) ).swap( *this ); return *this; } @@ -110,7 +110,7 @@ public: template #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) - weak_ptr( shared_ptr const & r, typename detail::sp_enable_if_convertible::type = detail::sp_empty() ) + weak_ptr( shared_ptr const & r, typename boost::detail::sp_enable_if_convertible::type = boost::detail::sp_empty() ) #else @@ -134,9 +134,9 @@ public: #if defined( BOOST_HAS_RVALUE_REFS ) template - weak_ptr & operator=(weak_ptr && r) + weak_ptr & operator=( weak_ptr && r ) { - this_type( std::move( r ) ).swap( *this ); + this_type( static_cast< weak_ptr && >( r ) ).swap( *this ); return *this; } diff --git a/boost/boost/throw_exception.hpp b/boost/boost/throw_exception.hpp index a5a5f9ea0b..656b8de31e 100644 --- a/boost/boost/throw_exception.hpp +++ b/boost/boost/throw_exception.hpp @@ -22,6 +22,7 @@ #include #include +#include #include #if !defined( BOOST_EXCEPTION_DISABLE ) && defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x593) ) @@ -38,7 +39,7 @@ # define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(::boost::enable_error_info(x) <<\ ::boost::throw_function(BOOST_CURRENT_FUNCTION) <<\ ::boost::throw_file(__FILE__) <<\ - ::boost::throw_line((int)__LINE__)) + ::boost::throw_line(__LINE__)) #else # define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(x) #endif diff --git a/boost/boost/type_traits/has_new_operator.hpp b/boost/boost/type_traits/has_new_operator.hpp index 6d5351e080..2c2c32228f 100644 --- a/boost/boost/type_traits/has_new_operator.hpp +++ b/boost/boost/type_traits/has_new_operator.hpp @@ -26,7 +26,7 @@ namespace detail { template struct has_new_operator_impl { template - static type_traits::yes_type check_sig( + static type_traits::yes_type check_sig1( U*, test< void *(*)(std::size_t), @@ -34,7 +34,10 @@ namespace detail { >* = NULL ); template - static type_traits::yes_type check_sig( + static type_traits::no_type check_sig1(...); + + template + static type_traits::yes_type check_sig2( U*, test< void *(*)(std::size_t, const std::nothrow_t&), @@ -42,7 +45,10 @@ namespace detail { >* = NULL ); template - static type_traits::yes_type check_sig( + static type_traits::no_type check_sig2(...); + + template + static type_traits::yes_type check_sig3( U*, test< void *(*)(std::size_t, void*), @@ -50,10 +56,11 @@ namespace detail { >* = NULL ); template - static type_traits::no_type check_sig(...); + static type_traits::no_type check_sig3(...); + template - static type_traits::yes_type check_sig2( + static type_traits::yes_type check_sig4( U*, test< void *(*)(std::size_t), @@ -61,7 +68,10 @@ namespace detail { >* = NULL ); template - static type_traits::yes_type check_sig2( + static type_traits::no_type check_sig4(...); + + template + static type_traits::yes_type check_sig5( U*, test< void *(*)(std::size_t, const std::nothrow_t&), @@ -69,7 +79,10 @@ namespace detail { >* = NULL ); template - static type_traits::yes_type check_sig2( + static type_traits::no_type check_sig5(...); + + template + static type_traits::yes_type check_sig6( U*, test< void *(*)(std::size_t, void*), @@ -77,21 +90,29 @@ namespace detail { >* = NULL ); template - static type_traits::no_type check_sig2(...); + static type_traits::no_type check_sig6(...); // 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(has_new_operator_impl::template check_sig(0))); + BOOST_STATIC_CONSTANT(unsigned, s1 = sizeof(has_new_operator_impl::template check_sig1(0))); BOOST_STATIC_CONSTANT(unsigned, s2 = sizeof(has_new_operator_impl::template check_sig2(0))); + BOOST_STATIC_CONSTANT(unsigned, s3 = sizeof(has_new_operator_impl::template check_sig3(0))); + BOOST_STATIC_CONSTANT(unsigned, s4 = sizeof(has_new_operator_impl::template check_sig4(0))); + BOOST_STATIC_CONSTANT(unsigned, s5 = sizeof(has_new_operator_impl::template check_sig5(0))); + BOOST_STATIC_CONSTANT(unsigned, s6 = sizeof(has_new_operator_impl::template check_sig6(0))); #else #if BOOST_WORKAROUND(BOOST_MSVC_FULL_VER, >= 140050000) #pragma warning(push) #pragma warning(disable:6334) #endif - BOOST_STATIC_CONSTANT(unsigned, s1 = sizeof(check_sig(0))); + BOOST_STATIC_CONSTANT(unsigned, s1 = sizeof(check_sig1(0))); BOOST_STATIC_CONSTANT(unsigned, s2 = sizeof(check_sig2(0))); + BOOST_STATIC_CONSTANT(unsigned, s3 = sizeof(check_sig3(0))); + BOOST_STATIC_CONSTANT(unsigned, s4 = sizeof(check_sig4(0))); + BOOST_STATIC_CONSTANT(unsigned, s5 = sizeof(check_sig5(0))); + BOOST_STATIC_CONSTANT(unsigned, s6 = sizeof(check_sig6(0))); #if BOOST_WORKAROUND(BOOST_MSVC_FULL_VER, >= 140050000) #pragma warning(pop) @@ -100,7 +121,11 @@ namespace detail { BOOST_STATIC_CONSTANT(bool, value = (::boost::type_traits::ice_or< (s1 == sizeof(type_traits::yes_type)), - (s2 == sizeof(type_traits::yes_type)) + (s2 == sizeof(type_traits::yes_type)), + (s3 == sizeof(type_traits::yes_type)), + (s4 == sizeof(type_traits::yes_type)), + (s5 == sizeof(type_traits::yes_type)), + (s6 == sizeof(type_traits::yes_type)) >::value) ); }; diff --git a/boost/boost/type_traits/intrinsics.hpp b/boost/boost/type_traits/intrinsics.hpp index 74b64a7d43..8f88036e20 100644 --- a/boost/boost/type_traits/intrinsics.hpp +++ b/boost/boost/type_traits/intrinsics.hpp @@ -149,7 +149,7 @@ # define BOOST_IS_CLASS(T) __is_class(T) # define BOOST_IS_ENUM(T) __is_enum(T) # define BOOST_IS_POLYMORPHIC(T) __is_polymorphic(T) -# if !defined(unix) || defined(__LP64__) +# if (!defined(unix) && !defined(__unix__)) || defined(__LP64__) // GCC sometimes lies about alignment requirements // of type double on 32-bit unix platforms, use the // old implementation instead in that case: diff --git a/boost/boost/type_traits/is_base_of_tr1.hpp b/boost/boost/type_traits/is_base_of_tr1.hpp new file mode 100644 index 0000000000..177e62b0f9 --- /dev/null +++ b/boost/boost/type_traits/is_base_of_tr1.hpp @@ -0,0 +1,50 @@ + +// (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_TR1_HPP_INCLUDED +#define BOOST_TT_IS_BASE_OF_TR1_HPP_INCLUDED + +#include +#include +#include +#include + +// should be the last #include +#include + +namespace boost { namespace tr1{ + + namespace detail{ + template + struct is_base_of_imp + { + typedef typename remove_cv::type ncvB; + typedef typename remove_cv::type ncvD; + BOOST_STATIC_CONSTANT(bool, value = (::boost::type_traits::ice_or< + (::boost::detail::is_base_and_derived_impl::value), + (::boost::is_same::value)>::value)); + }; + } + +BOOST_TT_AUX_BOOL_TRAIT_DEF2( + is_base_of + , Base + , Derived + , (::boost::tr1::detail::is_base_of_imp::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 + +#endif // BOOST_TT_IS_BASE_OF_TR1_HPP_INCLUDED diff --git a/boost/boost/type_traits/is_signed.hpp b/boost/boost/type_traits/is_signed.hpp index e06b47cc85..bf7bbfdb76 100644 --- a/boost/boost/type_traits/is_signed.hpp +++ b/boost/boost/type_traits/is_signed.hpp @@ -26,11 +26,19 @@ namespace detail{ #if !(defined(__EDG_VERSION__) && __EDG_VERSION__ <= 238) +template +struct is_signed_values +{ + typedef typename remove_cv::type no_cv_t; + BOOST_STATIC_CONSTANT(no_cv_t, minus_one = (static_cast(-1))); + BOOST_STATIC_CONSTANT(no_cv_t, zero = (static_cast(0))); +}; + template struct is_signed_helper { typedef typename remove_cv::type no_cv_t; - BOOST_STATIC_CONSTANT(bool, value = (!(static_cast(-1) > 0))); + BOOST_STATIC_CONSTANT(bool, value = (!(::boost::detail::is_signed_values::minus_one > boost::detail::is_signed_values::zero))); }; template diff --git a/boost/boost/type_traits/is_unsigned.hpp b/boost/boost/type_traits/is_unsigned.hpp index 486648692f..98baf4e94e 100644 --- a/boost/boost/type_traits/is_unsigned.hpp +++ b/boost/boost/type_traits/is_unsigned.hpp @@ -27,10 +27,17 @@ namespace detail{ #if !(defined(__EDG_VERSION__) && __EDG_VERSION__ <= 238) template -struct is_ununsigned_helper +struct is_unsigned_values { typedef typename remove_cv::type no_cv_t; - BOOST_STATIC_CONSTANT(bool, value = (static_cast(-1) > 0)); + BOOST_STATIC_CONSTANT(no_cv_t, minus_one = (static_cast(-1))); + BOOST_STATIC_CONSTANT(no_cv_t, zero = (static_cast(0))); +}; + +template +struct is_ununsigned_helper +{ + BOOST_STATIC_CONSTANT(bool, value = (::boost::detail::is_unsigned_values::minus_one > ::boost::detail::is_unsigned_values::zero)); }; template diff --git a/boost/boost/utility/value_init.hpp b/boost/boost/utility/value_init.hpp index 177fe74345..5aefac928d 100644 --- a/boost/boost/utility/value_init.hpp +++ b/boost/boost/utility/value_init.hpp @@ -114,8 +114,6 @@ class value_initialized - - template T const& get ( value_initialized const& x ) { diff --git a/boost/boost/version.hpp b/boost/boost/version.hpp index ad3435917b..e95ff85e71 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 104100 +#define BOOST_VERSION 104200 // // BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION @@ -27,7 +27,7 @@ // number, y is the minor version number, and z is the patch level if not 0. // This is used by to select which library version to link to. -#define BOOST_LIB_VERSION "1_41" +#define BOOST_LIB_VERSION "1_42" #endif diff --git a/boost/libs/regex/src/cpp_regex_traits.cpp b/boost/libs/regex/src/cpp_regex_traits.cpp index 9ed66be646..1d24cc1a5f 100644 --- a/boost/libs/regex/src/cpp_regex_traits.cpp +++ b/boost/libs/regex/src/cpp_regex_traits.cpp @@ -42,7 +42,7 @@ void cpp_regex_traits_char_layer::init() std::messages::catalog cat = reinterpret_cast::catalog>(-1); #endif std::string cat_name(cpp_regex_traits::get_catalog_name()); - if(cat_name.size()) + if(cat_name.size() && (m_pmessages != 0)) { cat = this->m_pmessages->open( cat_name, diff --git a/boost/libs/regex/src/cregex.cpp b/boost/libs/regex/src/cregex.cpp index fb12373a2f..f67d37185a 100644 --- a/boost/libs/regex/src/cregex.cpp +++ b/boost/libs/regex/src/cregex.cpp @@ -563,11 +563,7 @@ std::string RegEx::What(int i)const return result; } -#ifdef BOOST_HAS_LONG_LONG -const std::size_t RegEx::npos = static_cast(~0ULL); -#else -const std::size_t RegEx::npos = static_cast(~0UL); -#endif +const std::size_t RegEx::npos = ~static_cast(0); } // namespace boost diff --git a/boost/libs/regex/src/fileiter.cpp b/boost/libs/regex/src/fileiter.cpp index 7d9c7f8847..ff1d11198f 100644 --- a/boost/libs/regex/src/fileiter.cpp +++ b/boost/libs/regex/src/fileiter.cpp @@ -258,11 +258,22 @@ void mapfile::lock(pointer* node)const *p = 0; *(reinterpret_cast(*node)) = 1; } - std::fseek(hfile, (node - _first) * buf_size, SEEK_SET); - if(node == _last - 1) - std::fread(*node + sizeof(int), _size % buf_size, 1, hfile); - else - std::fread(*node + sizeof(int), buf_size, 1, hfile); + + std::size_t read_size = 0; + int read_pos = std::fseek(hfile, (node - _first) * buf_size, SEEK_SET); + + if(0 == read_pos && node == _last - 1) + read_size = std::fread(*node + sizeof(int), _size % buf_size, 1, hfile); + else + read_size = std::fread(*node + sizeof(int), buf_size, 1, hfile); +#ifndef BOOST_NO_EXCEPTIONS + if((read_size == 0) || (std::ferror(hfile))) + { + throw std::runtime_error("Unable to read file."); + } +#else + BOOST_REGEX_NOEH_ASSERT((0 == std::ferror(hfile)) && (read_size != 0)); +#endif } else { diff --git a/boost/libs/regex/src/posix_api.cpp b/boost/libs/regex/src/posix_api.cpp index 1564cedb0d..37ed4221be 100644 --- a/boost/libs/regex/src/posix_api.cpp +++ b/boost/libs/regex/src/posix_api.cpp @@ -58,6 +58,7 @@ const char* names[] = { "REG_EMPTY", "REG_ECOMPLEXITY", "REG_ESTACK", + "REG_E_PERL", "REG_E_UNKNOWN", }; } // namespace diff --git a/boost/libs/regex/src/regex_traits_defaults.cpp b/boost/libs/regex/src/regex_traits_defaults.cpp index c9596a3daf..31b79184ec 100644 --- a/boost/libs/regex/src/regex_traits_defaults.cpp +++ b/boost/libs/regex/src/regex_traits_defaults.cpp @@ -111,30 +111,31 @@ BOOST_REGEX_DECL const char* BOOST_REGEX_CALL get_default_syntax(regex_constants 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 */ - "", - "", - "", + "Success", /* REG_NOERROR 0 error_ok */ + "No match", /* REG_NOMATCH 1 error_no_match */ + "Invalid regular expression.", /* REG_BADPAT 2 error_bad_pattern */ + "Invalid collation character.", /* REG_ECOLLATE 3 error_collate */ + "Invalid character class name, collating name, or character range.", /* REG_ECTYPE 4 error_ctype */ + "Invalid or unterminated escape sequence.", /* REG_EESCAPE 5 error_escape */ + "Invalid back reference: specified capturing group does not exist.", /* REG_ESUBREG 6 error_backref */ + "Unmatched [ or [^ in character class declaration.", /* REG_EBRACK 7 error_brack */ + "Unmatched marking parenthesis ( or \\(.", /* REG_EPAREN 8 error_paren */ + "Unmatched quantified repeat operator { or \\{.", /* REG_EBRACE 9 error_brace */ + "Invalid content of repeat range.", /* REG_BADBR 10 error_badbrace */ + "Invalid range end in character class", /* REG_ERANGE 11 error_range */ + "Out of memory.", /* REG_ESPACE 12 error_space NOT USED */ + "Invalid preceding regular expression prior to repetition operator.", /* REG_BADRPT 13 error_badrepeat */ + "Premature end of regular expression", /* REG_EEND 14 error_end NOT USED */ + "Regular expression is too large.", /* REG_ESIZE 15 error_size NOT USED */ + "Unmatched ) or \\)", /* REG_ERPAREN 16 error_right_paren NOT USED */ + "Empty regular expression.", /* REG_EMPTY 17 error_empty */ + "The complexity of matching the regular expression exceeded predefined bounds. " + "Try refactoring the regular expression to make each choice made by the state machine unambiguous. " + "This exception is thrown to prevent \"eternal\" matches that take an " + "indefinite period time to locate.", /* REG_ECOMPLEXITY 18 error_complexity */ + "Ran out of stack space trying to match the regular expression.", /* REG_ESTACK 19 error_stack */ + "Invalid or unterminated Perl (?...) sequence.", /* REG_E_PERL 20 error_perl */ + "Unknown error.", /* REG_E_UNKNOWN 21 error_unknown */ }; return (n > ::boost::regex_constants::error_unknown) ? s_default_error_messages[ ::boost::regex_constants::error_unknown] : s_default_error_messages[n]; diff --git a/boost/libs/regex/src/static_mutex.cpp b/boost/libs/regex/src/static_mutex.cpp index cef76783bf..d14feb1e9b 100755 --- a/boost/libs/regex/src/static_mutex.cpp +++ b/boost/libs/regex/src/static_mutex.cpp @@ -124,7 +124,7 @@ void scoped_static_mutex_lock::unlock() boost::recursive_mutex* static_mutex::m_pmutex = 0; boost::once_flag static_mutex::m_once = BOOST_ONCE_INIT; -extern "C" BOOST_REGEX_DECL void free_static_mutex() +extern "C" BOOST_REGEX_DECL void boost_regex_free_static_mutex() { delete static_mutex::m_pmutex; static_mutex::m_pmutex = 0; @@ -133,7 +133,7 @@ extern "C" BOOST_REGEX_DECL void free_static_mutex() void static_mutex::init() { m_pmutex = new boost::recursive_mutex(); - int r = atexit(free_static_mutex); + int r = atexit(boost_regex_free_static_mutex); BOOST_ASSERT(0 == r); } @@ -157,7 +157,7 @@ void scoped_static_mutex_lock::lock() { boost::call_once(static_mutex::m_once,&static_mutex::init); if(0 == m_plock) - m_plock = new boost::recursive_mutex::scoped_lock(*static_mutex::m_pmutex, false); + m_plock = new boost::recursive_mutex::scoped_lock(*static_mutex::m_pmutex, boost::defer_lock); m_plock->lock(); m_have_lock = true; } diff --git a/boost/libs/regex/src/usinstances.cpp b/boost/libs/regex/src/usinstances.cpp index ca7b1dc94c..44ebd28dfb 100755 --- a/boost/libs/regex/src/usinstances.cpp +++ b/boost/libs/regex/src/usinstances.cpp @@ -17,6 +17,9 @@ */ #define BOOST_REGEX_SOURCE +#ifdef _MSC_VER +#pragma warning(disable:4506) // 'no definition for inline function' +#endif #include #include diff --git a/boost/libs/regex/src/wide_posix_api.cpp b/boost/libs/regex/src/wide_posix_api.cpp index c8a919027b..bdb7580e15 100644 --- a/boost/libs/regex/src/wide_posix_api.cpp +++ b/boost/libs/regex/src/wide_posix_api.cpp @@ -65,6 +65,7 @@ const wchar_t* wnames[] = { L"REG_EMPTY", L"REG_ECOMPLEXITY", L"REG_ESTACK", + L"REG_E_PERL", L"REG_E_UNKNOWN", }; } -- 2.39.2