From 676e58601ea501ede70eeb4b9407d630197d2494 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Fri, 19 Aug 2005 16:10:11 +0000 Subject: [PATCH] Fixed VC7.1-STLport config setup so it works with /Zc:wchar_t Re-ordered code in static_mutex.hpp to satisfy SGI IRIX. Added some additional #includes to satisfy SGI Irix. Fixed strange bug where some non-greedy repeats could repeat more times than permitted. Fixed return value from basic_regex<>::empty(). Fixed return value from basic_regex<>::expression() and basic_regex<>::size() when the expression is invalid. [SVN r30604] --- include/boost/regex/config.hpp | 2 +- include/boost/regex/pending/static_mutex.hpp | 19 ++++++++----------- include/boost/regex/v4/basic_regex.hpp | 6 +++--- .../boost/regex/v4/basic_regex_creator.hpp | 8 ++++++++ include/boost/regex/v4/cpp_regex_traits.hpp | 2 ++ include/boost/regex/v4/fileiter.hpp | 1 + .../regex/v4/perl_matcher_non_recursive.hpp | 7 +++++-- 7 files changed, 28 insertions(+), 17 deletions(-) diff --git a/include/boost/regex/config.hpp b/include/boost/regex/config.hpp index 7b073784..a068b339 100644 --- a/include/boost/regex/config.hpp +++ b/include/boost/regex/config.hpp @@ -144,7 +144,7 @@ * of the non-inline functions in the library, so that users can still link to the lib, * irrespective of whether their own code is built with /Zc:wchar_t. */ -#if defined(__cplusplus) && (defined(BOOST_MSVC) || defined(__ICL)) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) && defined(BOOST_WINDOWS) +#if defined(__cplusplus) && (defined(BOOST_MSVC) || defined(__ICL)) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) && defined(BOOST_WINDOWS) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) # define BOOST_REGEX_HAS_OTHER_WCHAR_T # ifdef BOOST_MSVC # pragma warning(push) diff --git a/include/boost/regex/pending/static_mutex.hpp b/include/boost/regex/pending/static_mutex.hpp index 4984abca..8dbf48e7 100644 --- a/include/boost/regex/pending/static_mutex.hpp +++ b/include/boost/regex/pending/static_mutex.hpp @@ -52,8 +52,14 @@ class BOOST_REGEX_DECL scoped_static_mutex_lock public: scoped_static_mutex_lock(static_mutex& mut, bool lk = true); ~scoped_static_mutex_lock(); - operator void const*()const; - bool locked()const; + inline bool locked()const + { + return m_have_lock; + } + inline operator void const*()const + { + return locked() ? this : 0; + } void lock(); void unlock(); private: @@ -61,15 +67,6 @@ private: bool m_have_lock; }; -inline scoped_static_mutex_lock::operator void const*()const -{ - return locked() ? this : 0; -} - -inline bool scoped_static_mutex_lock::locked()const -{ - return m_have_lock; -} } // namespace boost #elif defined(BOOST_HAS_WINTHREADS) diff --git a/include/boost/regex/v4/basic_regex.hpp b/include/boost/regex/v4/basic_regex.hpp index f557e54f..29e69b1b 100644 --- a/include/boost/regex/v4/basic_regex.hpp +++ b/include/boost/regex/v4/basic_regex.hpp @@ -49,9 +49,9 @@ struct regex_data regex_data(const ::boost::shared_ptr< ::boost::regex_traits_wrapper >& t) - : m_ptraits(t) {} + : m_ptraits(t), m_expression(0), m_expression_len(0) {} regex_data() - : m_ptraits(new ::boost::regex_traits_wrapper()) {} + : m_ptraits(new ::boost::regex_traits_wrapper()), m_expression(0), m_expression_len(0) {} ::boost::shared_ptr< ::boost::regex_traits_wrapper @@ -375,7 +375,7 @@ public: // empty: bool BOOST_REGEX_CALL empty()const { - return (m_pimpl.get() ? 0 != m_pimpl->status() : 0); + return (m_pimpl.get() ? 0 != m_pimpl->status() : true); } size_type BOOST_REGEX_CALL mark_count()const diff --git a/include/boost/regex/v4/basic_regex_creator.hpp b/include/boost/regex/v4/basic_regex_creator.hpp index 89767569..86ce0594 100644 --- a/include/boost/regex/v4/basic_regex_creator.hpp +++ b/include/boost/regex/v4/basic_regex_creator.hpp @@ -734,6 +734,14 @@ void basic_regex_creator::create_startmaps(re_syntax_base* state) // Oops error: if(0 == this->m_pdata->m_status) // update the error code if not already set this->m_pdata->m_status = boost::regex_constants::error_brack; + // + // clear the expression, we should be empty: + // + this->m_pdata->m_expression = 0; + this->m_pdata->m_expression_len = 0; + // + // and throw if required: + // if(0 == (this->flags() & regex_constants::no_except)) { std::string message = this->m_pdata->m_ptraits->error_string(boost::regex_constants::error_brack); diff --git a/include/boost/regex/v4/cpp_regex_traits.hpp b/include/boost/regex/v4/cpp_regex_traits.hpp index 2df0ceb3..8911e69b 100644 --- a/include/boost/regex/v4/cpp_regex_traits.hpp +++ b/include/boost/regex/v4/cpp_regex_traits.hpp @@ -39,6 +39,8 @@ #include #endif +#include + #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX #endif diff --git a/include/boost/regex/v4/fileiter.hpp b/include/boost/regex/v4/fileiter.hpp index 6e243900..21a785ea 100644 --- a/include/boost/regex/v4/fileiter.hpp +++ b/include/boost/regex/v4/fileiter.hpp @@ -61,6 +61,7 @@ typedef HANDLE _fi_find_handle; #elif defined(BOOST_REGEX_FI_POSIX_DIR) +#include #include #include #include diff --git a/include/boost/regex/v4/perl_matcher_non_recursive.hpp b/include/boost/regex/v4/perl_matcher_non_recursive.hpp index 4d1af25b..dc6f1d09 100644 --- a/include/boost/regex/v4/perl_matcher_non_recursive.hpp +++ b/include/boost/regex/v4/perl_matcher_non_recursive.hpp @@ -517,8 +517,11 @@ bool perl_matcher::match_rep() // try and skip the repeat if we can: if(take_second) { - // store position in case we fail: - push_non_greedy_repeat(rep->next.p); + if((next_count->get_count() < rep->max) && take_first) + { + // store position in case we fail: + push_non_greedy_repeat(rep->next.p); + } pstate = rep->alt.p; return true; }