From a388804b3e9b0f47d2af1605fa8d4a8c2c22b9b6 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Fri, 5 Sep 2008 04:13:30 +0000 Subject: [PATCH] merged from trunk [SVN r48605] --- build/Jamfile.v2 | 4 +- include/boost/regex/concepts.hpp | 10 +-- include/boost/regex/icu.hpp | 10 +-- include/boost/regex/v4/basic_regex.hpp | 2 +- include/boost/regex/v4/perl_matcher.hpp | 2 +- .../regex/v4/perl_matcher_non_recursive.hpp | 4 +- include/boost/regex/v4/u32regex_iterator.hpp | 2 +- .../regex/v4/u32regex_token_iterator.hpp | 6 +- src/usinstances.cpp | 83 +++++++++++-------- test/pathology/bad_expression_test.cpp | 3 +- test/regress/test_tricky_cases.cpp | 3 + 11 files changed, 75 insertions(+), 54 deletions(-) diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index 47f3de94..6a21561d 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -169,7 +169,8 @@ rule check-icu-config ( ) if [ check-icu-config ] { - BOOST_REGEX_ICU_OPTS = "BOOST_HAS_ICU=1" ; + BOOST_REGEX_ICU_OPTS = "freebsd:/usr/local/include" ; + BOOST_REGEX_ICU_OPTS += "BOOST_HAS_ICU=1" ; if $(ICU_PATH) { @@ -259,3 +260,4 @@ boost-install boost_regex ; + diff --git a/include/boost/regex/concepts.hpp b/include/boost/regex/concepts.hpp index 99c6eea5..0a22aebd 100644 --- a/include/boost/regex/concepts.hpp +++ b/include/boost/regex/concepts.hpp @@ -87,12 +87,12 @@ struct regex_traits_architype public: regex_traits_architype(); typedef charT char_type; - typedef std::size_t size_type; + // typedef std::size_t size_type; typedef std::vector string_type; typedef copy_constructible_archetype > locale_type; typedef bitmask_archetype char_class_type; - static size_type length(const char_type* ) { return 0; } + static std::size_t length(const char_type* ) { return 0; } charT translate(charT ) const { return charT(); } charT translate_nocase(charT ) const { return static_object::get(); } @@ -163,21 +163,21 @@ struct RegexTraitsConcept RegexTraitsConcept(); // required typedefs: typedef typename traits::char_type char_type; - typedef typename traits::size_type size_type; + // typedef typename traits::size_type size_type; typedef typename traits::string_type string_type; typedef typename traits::locale_type locale_type; typedef typename traits::char_class_type char_class_type; void constraints() { - function_requires >(); + //function_requires >(); function_requires >(); function_requires >(); function_requires >(); function_requires >(); function_requires >(); - size_type n = traits::length(m_pointer); + std::size_t n = traits::length(m_pointer); ignore_unused_variable_warning(n); char_type c = m_ctraits.translate(m_char); diff --git a/include/boost/regex/icu.hpp b/include/boost/regex/icu.hpp index 53941b64..7af1d678 100644 --- a/include/boost/regex/icu.hpp +++ b/include/boost/regex/icu.hpp @@ -355,7 +355,7 @@ inline u32regex make_u32regex(const wchar_t* p, boost::regex_constants::syntax_o return re_detail::do_make_u32regex(p, p + std::wcslen(p), opt, static_cast const*>(0)); } #endif -#ifndef U_WCHAR_IS_UTF16 +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) inline u32regex make_u32regex(const UChar* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) { return re_detail::do_make_u32regex(p, p + u_strlen(p), opt, static_cast const*>(0)); @@ -455,7 +455,7 @@ inline bool u32regex_match(const UChar* p, { return re_detail::do_regex_match(p, p+u_strlen(p), m, e, flags, static_cast const*>(0)); } -#if !defined(U_WCHAR_IS_UTF16) && !defined(BOOST_NO_WREGEX) +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) && !defined(BOOST_NO_WREGEX) inline bool u32regex_match(const wchar_t* p, match_results& m, const u32regex& e, @@ -519,7 +519,7 @@ inline bool u32regex_match(const UChar* p, match_results m; return re_detail::do_regex_match(p, p+u_strlen(p), m, e, flags, static_cast const*>(0)); } -#if !defined(U_WCHAR_IS_UTF16) && !defined(BOOST_NO_WREGEX) +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) && !defined(BOOST_NO_WREGEX) inline bool u32regex_match(const wchar_t* p, const u32regex& e, match_flag_type flags = match_default) @@ -640,7 +640,7 @@ inline bool u32regex_search(const UChar* p, { return re_detail::do_regex_search(p, p+u_strlen(p), m, e, flags, p, static_cast const*>(0)); } -#if !defined(U_WCHAR_IS_UTF16) && !defined(BOOST_NO_WREGEX) +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) && !defined(BOOST_NO_WREGEX) inline bool u32regex_search(const wchar_t* p, match_results& m, const u32regex& e, @@ -701,7 +701,7 @@ inline bool u32regex_search(const UChar* p, match_results m; return re_detail::do_regex_search(p, p+u_strlen(p), m, e, flags, p, static_cast const*>(0)); } -#if !defined(U_WCHAR_IS_UTF16) && !defined(BOOST_NO_WREGEX) +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) && !defined(BOOST_NO_WREGEX) inline bool u32regex_search(const wchar_t* p, const u32regex& e, match_flag_type flags = match_default) diff --git a/include/boost/regex/v4/basic_regex.hpp b/include/boost/regex/v4/basic_regex.hpp index 2a8c0c6c..018a30f9 100644 --- a/include/boost/regex/v4/basic_regex.hpp +++ b/include/boost/regex/v4/basic_regex.hpp @@ -191,7 +191,7 @@ class basic_regex : public regbase { public: // typedefs: - typedef typename traits::size_type traits_size_type; + typedef std::size_t traits_size_type; typedef typename traits::string_type traits_string_type; typedef charT char_type; typedef traits traits_type; diff --git a/include/boost/regex/v4/perl_matcher.hpp b/include/boost/regex/v4/perl_matcher.hpp index 547cb24a..66c2d007 100644 --- a/include/boost/regex/v4/perl_matcher.hpp +++ b/include/boost/regex/v4/perl_matcher.hpp @@ -331,7 +331,7 @@ public: typedef typename traits::char_type char_type; typedef perl_matcher self_type; typedef bool (self_type::*matcher_proc_type)(void); - typedef typename traits::size_type traits_size_type; + typedef std::size_t traits_size_type; typedef typename is_byte::width_type width_type; typedef typename regex_iterator_traits::difference_type difference_type; diff --git a/include/boost/regex/v4/perl_matcher_non_recursive.hpp b/include/boost/regex/v4/perl_matcher_non_recursive.hpp index e6bf1bba..2a6207fc 100644 --- a/include/boost/regex/v4/perl_matcher_non_recursive.hpp +++ b/include/boost/regex/v4/perl_matcher_non_recursive.hpp @@ -477,7 +477,9 @@ bool perl_matcher::match_rep() take_second = can_start(*position, rep->_map, (unsigned char)mask_skip); } - if(take_first || (next_count->get_id() != rep->id)) + if((m_backup_state->id != saved_state_repeater_count) + || (static_cast*>(m_backup_state)->count.get_id() != rep->id) + || (next_count->get_id() != rep->id)) { // we're moving to a different repeat from the last // one, so set up a counter object: diff --git a/include/boost/regex/v4/u32regex_iterator.hpp b/include/boost/regex/v4/u32regex_iterator.hpp index 9e49c6f3..7e893e69 100644 --- a/include/boost/regex/v4/u32regex_iterator.hpp +++ b/include/boost/regex/v4/u32regex_iterator.hpp @@ -166,7 +166,7 @@ inline u32regex_iterator make_u32regex_iterator(const wchar_t* p return u32regex_iterator(p, p+std::wcslen(p), e, m); } #endif -#ifndef U_WCHAR_IS_UTF16 +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) inline u32regex_iterator make_u32regex_iterator(const UChar* p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default) { return u32regex_iterator(p, p+u_strlen(p), e, m); diff --git a/include/boost/regex/v4/u32regex_token_iterator.hpp b/include/boost/regex/v4/u32regex_token_iterator.hpp index a8d394e4..d8833575 100644 --- a/include/boost/regex/v4/u32regex_token_iterator.hpp +++ b/include/boost/regex/v4/u32regex_token_iterator.hpp @@ -282,7 +282,7 @@ inline u32regex_token_iterator make_u32regex_token_iterator(cons return u32regex_token_iterator(p, p+std::wcslen(p), e, submatch, m); } #endif -#ifndef U_WCHAR_IS_UTF16 +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) inline u32regex_token_iterator make_u32regex_token_iterator(const UChar* p, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) { return u32regex_token_iterator(p, p+u_strlen(p), e, m); @@ -313,7 +313,7 @@ inline u32regex_token_iterator make_u32regex_token_iterator(cons return u32regex_token_iterator(p, p+std::wcslen(p), e, submatch, m); } #endif -#ifndef U_WCHAR_IS_UTF16 +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) template inline u32regex_token_iterator make_u32regex_token_iterator(const UChar* p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) { @@ -344,7 +344,7 @@ inline u32regex_token_iterator make_u32regex_token_iterator(cons return u32regex_token_iterator(p, p+std::wcslen(p), e, submatch, m); } #endif -#ifndef U_WCHAR_IS_UTF16 +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) inline u32regex_token_iterator make_u32regex_token_iterator(const UChar* p, const u32regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default) { return u32regex_token_iterator(p, p+u_strlen(p), e, m); diff --git a/src/usinstances.cpp b/src/usinstances.cpp index e633659e..390cd254 100644 --- a/src/usinstances.cpp +++ b/src/usinstances.cpp @@ -18,46 +18,59 @@ #define BOOST_REGEX_SOURCE +#include +#include +#include + +#if defined(_DLL_CPPLIB) && !defined(_M_CEE_PURE) \ + && !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) || defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER)) +// +// This is a horrible workaround, but without declaring these symbols extern we get +// duplicate symbol errors when linking if the application is built without +// /Zc:wchar_t +// +#ifdef _CRTIMP2_PURE +# define BOOST_REGEX_STDLIB_DECL _CRTIMP2_PURE +#else +# define BOOST_REGEX_STDLIB_DECL _CRTIMP2 +#endif + +namespace std{ + +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +template class BOOST_REGEX_STDLIB_DECL allocator; +template class BOOST_REGEX_STDLIB_DECL _String_val >; +template class BOOST_REGEX_STDLIB_DECL basic_string, + allocator >; +#endif + +#if BOOST_WORKAROUND(BOOST_MSVC, > 1300) && BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400)) +template<> BOOST_REGEX_STDLIB_DECL std::size_t __cdecl char_traits::length(unsigned short const*); +#endif + +template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==( + const basic_string, allocator >&, + const basic_string, allocator >&); +template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==( + const unsigned short *, + const basic_string, allocator >&); +template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==( + const basic_string, allocator >&, + const unsigned short *); +template BOOST_REGEX_STDLIB_DECL bool __cdecl operator<( + const basic_string, allocator >&, + const basic_string, allocator >&); +template BOOST_REGEX_STDLIB_DECL bool __cdecl operator>( + const basic_string, allocator >&, + const basic_string, allocator >&); +} +#endif + #include #if !defined(BOOST_NO_WREGEX) && defined(BOOST_REGEX_HAS_OTHER_WCHAR_T) && !defined(BOOST_REGEX_NO_EXTERNAL_TEMPLATES) #define BOOST_REGEX_US_INSTANTIATE -#ifdef _DLL_CPPLIB -#include -#include -#include -// -// This is a horrible workaround, without declaring these symbols extern we get -// duplicate symbol errors when linking if the application is built without -// /Zc:wchar_t -// -namespace std{ -template _CRTIMP2 bool __cdecl operator==( - const basic_string, allocator >&, - const basic_string, allocator >&); -template _CRTIMP2 bool __cdecl operator==( - const unsigned short *, - const basic_string, allocator >&); -template _CRTIMP2 bool __cdecl operator==( - const basic_string, allocator >&, - const unsigned short *); -template _CRTIMP2 bool __cdecl operator<( - const basic_string, allocator >&, - const basic_string, allocator >&); -template _CRTIMP2 bool __cdecl operator>( - const basic_string, allocator >&, - const basic_string, allocator >&); -#if BOOST_WORKAROUND(BOOST_MSVC, > 1300) && BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400)) -template<> _CRTIMP2 std::size_t __cdecl char_traits::length(unsigned short const*); -#endif -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -template _CRTIMP2 allocator::allocator(); -#endif -} -#endif - - #include #endif diff --git a/test/pathology/bad_expression_test.cpp b/test/pathology/bad_expression_test.cpp index 308df422..34f21c22 100644 --- a/test/pathology/bad_expression_test.cpp +++ b/test/pathology/bad_expression_test.cpp @@ -46,7 +46,7 @@ int test_main( int , char* [] ) bad_text.assign((std::string::size_type)500000, 'a'); e2.assign("aaa*@"); - BOOST_CHECK_THROW(0 == boost::regex_search(bad_text, what, e2), std::runtime_error); + BOOST_CHECK_THROW(boost::regex_search(bad_text, what, e2), std::runtime_error); good_text.assign((std::string::size_type)5000, 'a'); BOOST_CHECK(0 == boost::regex_search(good_text, what, e2)); @@ -54,3 +54,4 @@ int test_main( int , char* [] ) } #include + diff --git a/test/regress/test_tricky_cases.cpp b/test/regress/test_tricky_cases.cpp index a0c1e532..e025dc43 100644 --- a/test/regress/test_tricky_cases.cpp +++ b/test/regress/test_tricky_cases.cpp @@ -377,6 +377,9 @@ void test_tricky_cases3() TEST_REGEX_SEARCH("(?:\\d{9}.*){2}", perl, "123456789dfsdfsdfsfsdfds123456789b", match_default, make_array(0, 34, -2, -2)); TEST_REGEX_SEARCH("(?:\\d{9}.*){2}", perl, "123456789dfsdfsdfsfsdfds12345678", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("(?:\\d{9}.*){2}", perl, "123456789dfsdfsdfsfsdfds", match_default, make_array(-2, -2)); + TEST_REGEX_SEARCH("^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])(\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])){3}$", perl, "1.2.03", match_default, make_array(-2, -2)); + TEST_REGEX_SEARCH("^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])(\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])){3,4}$", perl, "1.2.03", match_default, make_array(-2, -2)); + TEST_REGEX_SEARCH("^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])(\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])){3,4}?$", perl, "1.2.03", match_default, make_array(-2, -2)); //