From c902bed6a301f7dbdd6e3b46dc02b6370447e389 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Fri, 4 Dec 2020 12:16:36 +0000 Subject: [PATCH] Remove more workarounds, start testing standalone mode. --- build/Jamfile.v2 | 3 + include/boost/regex/config.hpp | 14 ++ include/boost/regex/pattern_except.hpp | 8 + .../boost/regex/pending/unicode_iterator.hpp | 5 + include/boost/regex/v5/basic_regex.hpp | 5 + .../boost/regex/v5/basic_regex_creator.hpp | 6 +- include/boost/regex/v5/basic_regex_parser.hpp | 42 ++--- include/boost/regex/v5/c_regex_traits.hpp | 4 +- include/boost/regex/v5/cpp_regex_traits.hpp | 146 ------------------ include/boost/regex/v5/indexed_bit_flag.hpp | 10 +- include/boost/regex/v5/match_results.hpp | 4 + include/boost/regex/v5/perl_matcher.hpp | 4 + .../boost/regex/v5/perl_matcher_common.hpp | 4 + include/boost/regex/v5/regex_traits.hpp | 2 +- include/boost/regex/v5/regex_workaround.hpp | 8 +- include/boost/regex/v5/w32_regex_traits.hpp | 22 +-- test/Jamfile.v2 | 45 ++++-- test/concepts/concept_check.cpp | 13 +- 18 files changed, 129 insertions(+), 216 deletions(-) diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index 883aaebd..a74f9ed2 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -119,6 +119,9 @@ if ! $(disable-icu) exe has_icu : has_icu_test.cpp : $(ICU_OPTS) ; explicit has_icu ; +obj is_legacy_03 : is_legacy_03.cpp ; +explicit is_legacy_03 ; + alias icu_options : : : : [ check-target-builds has_icu : $(ICU_OPTS) : ] ; SOURCES = diff --git a/include/boost/regex/config.hpp b/include/boost/regex/config.hpp index eae56d41..9532d56f 100644 --- a/include/boost/regex/config.hpp +++ b/include/boost/regex/config.hpp @@ -90,6 +90,20 @@ # endif #endif + +/**************************************************************************** +* +* Legacy support: +* +*******************************************************************************/ + +#if defined(BOOST_NO_STD_LOCALE) || defined(BOOST_NO_CXX11_HDR_MUTEX) || defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) \ + || defined(BOOST_NO_CXX11_HDR_ATOMIC) || defined(BOOST_NO_CXX11_ALLOCATOR) || defined(BOOST_NO_CXX11_SMART_PTR) || defined(BOOST_NO_CXX11_STATIC_ASSERT) +#ifndef BOOST_REGEX_CXX03 +# define BOOST_REGEX_CXX03 +#endif +#endif + /***************************************************************************** * * Boilerplate regex config options: diff --git a/include/boost/regex/pattern_except.hpp b/include/boost/regex/pattern_except.hpp index e39553ea..213dd7d5 100644 --- a/include/boost/regex/pattern_except.hpp +++ b/include/boost/regex/pattern_except.hpp @@ -76,7 +76,11 @@ public: void raise()const { #ifndef BOOST_NO_EXCEPTIONS +#ifndef BOOST_REGEX_STANDALONE ::boost::throw_exception(*this); +#else + throw* this; +#endif #endif } private: @@ -91,7 +95,11 @@ namespace BOOST_REGEX_DETAIL_NS{ inline void BOOST_REGEX_CALL raise_runtime_error(const std::runtime_error& ex) { +#ifndef BOOST_REGEX_STANDALONE ::boost::throw_exception(ex); +#else + throw ex; +#endif } template diff --git a/include/boost/regex/pending/unicode_iterator.hpp b/include/boost/regex/pending/unicode_iterator.hpp index 2aabec61..37fa5102 100644 --- a/include/boost/regex/pending/unicode_iterator.hpp +++ b/include/boost/regex/pending/unicode_iterator.hpp @@ -72,6 +72,11 @@ Accepts UTF-32 code points and forwards them on as UTF-16 code points. #endif #include // CHAR_BIT +#ifdef BOOST_REGEX_CXX03 + +#else +#endif + namespace boost{ namespace detail{ diff --git a/include/boost/regex/v5/basic_regex.hpp b/include/boost/regex/v5/basic_regex.hpp index 63509f57..00e095ee 100644 --- a/include/boost/regex/v5/basic_regex.hpp +++ b/include/boost/regex/v5/basic_regex.hpp @@ -509,8 +509,13 @@ public: // begin, end, subexpression: std::pair subexpression(std::size_t n)const { +#ifdef BOOST_REGEX_STANDALONE + if (!m_pimpl.get()) + throw std::logic_error("Can't access subexpressions in an invalid regex."); +#else if(!m_pimpl.get()) boost::throw_exception(std::logic_error("Can't access subexpressions in an invalid regex.")); +#endif return m_pimpl->subexpression(n); } const_iterator begin()const diff --git a/include/boost/regex/v5/basic_regex_creator.hpp b/include/boost/regex/v5/basic_regex_creator.hpp index fd14132e..c5afc231 100644 --- a/include/boost/regex/v5/basic_regex_creator.hpp +++ b/include/boost/regex/v5/basic_regex_creator.hpp @@ -245,7 +245,7 @@ protected: unsigned m_repeater_id; // the state_id of the next repeater bool m_has_backrefs; // true if there are actually any backrefs indexed_bit_flag m_backrefs; // bitmask of permitted backrefs - boost::uintmax_t m_bad_repeats; // bitmask of repeats we can't deduce a startmap for; + std::uintmax_t m_bad_repeats; // bitmask of repeats we can't deduce a startmap for; bool m_has_recursions; // set when we have recursive expressions to fixup std::vector m_recursion_checks; // notes which recursions we've followed while analysing this expression typename traits::char_class_type m_word_mask; // mask used to determine if a character is a word character @@ -1456,7 +1456,7 @@ bool basic_regex_creator::is_bad_repeat(re_syntax_base* pt) unsigned state_id = static_cast(pt)->state_id; if(state_id >= sizeof(m_bad_repeats) * CHAR_BIT) return true; // run out of bits, assume we can't traverse this one. - static const boost::uintmax_t one = 1uL; + static const std::uintmax_t one = 1uL; return m_bad_repeats & (one << state_id); } default: @@ -1476,7 +1476,7 @@ void basic_regex_creator::set_bad_repeat(re_syntax_base* pt) case syntax_element_long_set_rep: { unsigned state_id = static_cast(pt)->state_id; - static const boost::uintmax_t one = 1uL; + static const std::uintmax_t one = 1uL; if(state_id <= sizeof(m_bad_repeats) * CHAR_BIT) m_bad_repeats |= (one << state_id); } diff --git a/include/boost/regex/v5/basic_regex_parser.hpp b/include/boost/regex/v5/basic_regex_parser.hpp index 2a13f2f5..107ceedb 100644 --- a/include/boost/regex/v5/basic_regex_parser.hpp +++ b/include/boost/regex/v5/basic_regex_parser.hpp @@ -44,19 +44,19 @@ namespace BOOST_REGEX_DETAIL_NS{ #endif #endif -inline boost::intmax_t umax(std::integral_constant const&) +inline std::intmax_t umax(std::integral_constant const&) { // Get out clause here, just in case numeric_limits is unspecialized: - return std::numeric_limits::is_specialized ? (std::numeric_limits::max)() : INT_MAX; + return std::numeric_limits::is_specialized ? (std::numeric_limits::max)() : INT_MAX; } -inline boost::intmax_t umax(std::integral_constant const&) +inline std::intmax_t umax(std::integral_constant const&) { return (std::numeric_limits::max)(); } -inline boost::intmax_t umax() +inline std::intmax_t umax() { - return umax(std::integral_constant::digits >= std::numeric_limits::digits>()); + return umax(std::integral_constant::digits >= std::numeric_limits::digits>()); } template @@ -911,7 +911,7 @@ escape_type_class_jump: return false; } const charT* pc = m_position; - boost::intmax_t i = this->m_traits.toi(pc, m_end, 10); + std::intmax_t i = this->m_traits.toi(pc, m_end, 10); if((i < 0) && syn_end) { // Check for a named capture, get the leftmost one if there is more than one: @@ -924,7 +924,7 @@ escape_type_class_jump: pc = m_position; } if(negative) - i = 1 + (static_cast(m_mark_count) - i); + i = 1 + (static_cast(m_mark_count) - i); if(((i < hash_value_mask) && (i > 0) && (this->m_backrefs.test(i))) || ((i >= hash_value_mask) && (this->m_pdata->get_id(i) > 0) && (this->m_backrefs.test(this->m_pdata->get_id(i))))) { m_position = pc; @@ -1151,7 +1151,7 @@ bool basic_regex_parser::parse_repeat_range(bool isbasic) // parse a repeat-range: // std::size_t min, max; - boost::intmax_t v; + std::intmax_t v; // skip whitespace: while((m_position != m_end) && this->m_traits.isctype(*m_position, this->m_mask_space)) ++m_position; @@ -1741,19 +1741,19 @@ digraph basic_regex_parser::get_next_set_literal(basic_cha // does a value fit in the specified charT type? // template -bool valid_value(charT, boost::intmax_t v, const std::integral_constant&) +bool valid_value(charT, std::intmax_t v, const std::integral_constant&) { return (v >> (sizeof(charT) * CHAR_BIT)) == 0; } template -bool valid_value(charT, boost::intmax_t, const std::integral_constant&) +bool valid_value(charT, std::intmax_t, const std::integral_constant&) { return true; // v will alsways fit in a charT } template -bool valid_value(charT c, boost::intmax_t v) +bool valid_value(charT c, std::intmax_t v) { - return valid_value(c, v, std::integral_constant()); + return valid_value(c, v, std::integral_constant()); } template @@ -1829,10 +1829,10 @@ charT basic_regex_parser::unescape_character() fail(regex_constants::error_escape, m_position - m_base, "Missing } in hexadecimal escape sequence."); return result; } - boost::intmax_t i = this->m_traits.toi(m_position, m_end, 16); + std::intmax_t i = this->m_traits.toi(m_position, m_end, 16); if((m_position == m_end) || (i < 0) - || ((std::numeric_limits::is_specialized) && (i > (boost::intmax_t)(std::numeric_limits::max)())) + || ((std::numeric_limits::is_specialized) && (i > (std::intmax_t)(std::numeric_limits::max)())) || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_brace)) { // Rewind to start of escape: @@ -1847,7 +1847,7 @@ charT basic_regex_parser::unescape_character() else { std::ptrdiff_t len = (std::min)(static_cast(2), static_cast(m_end - m_position)); - boost::intmax_t i = this->m_traits.toi(m_position, m_position + len, 16); + std::intmax_t i = this->m_traits.toi(m_position, m_position + len, 16); if((i < 0) || !valid_value(charT(0), i)) { @@ -1866,7 +1866,7 @@ charT basic_regex_parser::unescape_character() // followed by up to 3 octal digits: std::ptrdiff_t len = (std::min)(std::distance(m_position, m_end), static_cast(4)); const charT* bp = m_position; - boost::intmax_t val = this->m_traits.toi(bp, bp + 1, 8); + std::intmax_t val = this->m_traits.toi(bp, bp + 1, 8); if(val != 0) { // Rewind to start of escape: @@ -1877,7 +1877,7 @@ charT basic_regex_parser::unescape_character() return result; } val = this->m_traits.toi(m_position, m_position + len, 8); - if((val < 0) || (val > (boost::intmax_t)(std::numeric_limits::max)())) + if((val < 0) || (val > (std::intmax_t)(std::numeric_limits::max)())) { // Rewind to start of escape: --m_position; @@ -1950,7 +1950,7 @@ bool basic_regex_parser::parse_backref() { BOOST_REGEX_ASSERT(m_position != m_end); const charT* pc = m_position; - boost::intmax_t i = this->m_traits.toi(pc, pc + 1, 10); + std::intmax_t i = this->m_traits.toi(pc, pc + 1, 10); if((i == 0) || (((this->flags() & regbase::main_option_type) == regbase::perl_syntax_group) && (this->flags() & regbase::no_bk_refs))) { // not a backref at all but an octal escape sequence: @@ -2072,7 +2072,7 @@ bool basic_regex_parser::parse_perl_extension() int max_mark = m_max_mark; m_mark_reset = -1; m_max_mark = m_mark_count; - boost::intmax_t v; + std::intmax_t v; // // select the actual extension used: // @@ -2126,7 +2126,7 @@ insert_recursion: fail(regex_constants::error_perl_extension, m_position - m_base, "An invalid or unterminated recursive sub-expression."); return false; } - if ((std::numeric_limits::max)() - m_mark_count < v) + if ((std::numeric_limits::max)() - m_mark_count < v) { fail(regex_constants::error_perl_extension, m_position - m_base, "An invalid or unterminated recursive sub-expression."); return false; @@ -2145,7 +2145,7 @@ insert_recursion: // Oops not a relative recursion at all, but a (?-imsx) group: goto option_group_jump; } - v = static_cast(m_mark_count) + 1 - v; + v = static_cast(m_mark_count) + 1 - v; if(v <= 0) { // Rewind to start of (? sequence: diff --git a/include/boost/regex/v5/c_regex_traits.hpp b/include/boost/regex/v5/c_regex_traits.hpp index a853c9e8..5ea679c1 100644 --- a/include/boost/regex/v5/c_regex_traits.hpp +++ b/include/boost/regex/v5/c_regex_traits.hpp @@ -82,7 +82,7 @@ struct c_regex_traits typedef std::size_t size_type; typedef std::string string_type; struct locale_type{}; - typedef boost::uint32_t char_class_type; + typedef std::uint32_t char_class_type; static size_type length(const char_type* p) { @@ -127,7 +127,7 @@ struct c_regex_traits typedef std::size_t size_type; typedef std::wstring string_type; struct locale_type{}; - typedef boost::uint32_t char_class_type; + typedef std::uint32_t char_class_type; static size_type length(const char_type* p) { diff --git a/include/boost/regex/v5/cpp_regex_traits.hpp b/include/boost/regex/v5/cpp_regex_traits.hpp index 0a523ac6..f421e698 100644 --- a/include/boost/regex/v5/cpp_regex_traits.hpp +++ b/include/boost/regex/v5/cpp_regex_traits.hpp @@ -383,29 +383,6 @@ private: void init(); }; -#ifdef BOOST_REGEX_BUGGY_CTYPE_FACET -enum -{ - char_class_space=1<<0, - char_class_print=1<<1, - char_class_cntrl=1<<2, - char_class_upper=1<<3, - char_class_lower=1<<4, - char_class_alpha=1<<5, - char_class_digit=1<<6, - char_class_punct=1<<7, - char_class_xdigit=1<<8, - char_class_alnum=char_class_alpha|char_class_digit, - char_class_graph=char_class_alnum|char_class_punct, - char_class_blank=1<<9, - char_class_word=1<<10, - char_class_unicode=1<<11, - char_class_horizontal_space=1<<12, - char_class_vertical_space=1<<13 -}; - -#endif - // // class cpp_regex_traits_implementation: // provides pimpl implementation for cpp_regex_traits. @@ -417,13 +394,11 @@ public: typedef typename cpp_regex_traits::char_class_type char_class_type; typedef typename std::ctype::mask native_mask_type; typedef typename std::make_unsigned::type unsigned_native_mask_type; -#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET BOOST_STATIC_CONSTANT(char_class_type, mask_blank = 1u << 24); BOOST_STATIC_CONSTANT(char_class_type, mask_word = 1u << 25); BOOST_STATIC_CONSTANT(char_class_type, mask_unicode = 1u << 26); BOOST_STATIC_CONSTANT(char_class_type, mask_horizontal = 1u << 27); BOOST_STATIC_CONSTANT(char_class_type, mask_vertical = 1u << 28); -#endif typedef std::basic_string string_type; typedef charT char_type; @@ -472,15 +447,8 @@ private: // char_class_type lookup_classname_imp(const charT* p1, const charT* p2) const; void init(); -#ifdef BOOST_REGEX_BUGGY_CTYPE_FACET -public: - bool isctype(charT c, char_class_type m)const; -#endif }; -#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET -#if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION) - template typename cpp_regex_traits_implementation::char_class_type const cpp_regex_traits_implementation::mask_blank; template @@ -492,9 +460,6 @@ typename cpp_regex_traits_implementation::char_class_type const cpp_regex template typename cpp_regex_traits_implementation::char_class_type const cpp_regex_traits_implementation::mask_horizontal; -#endif -#endif - template typename cpp_regex_traits_implementation::string_type cpp_regex_traits_implementation::transform_primary(const charT* p1, const charT* p2) const @@ -609,20 +574,10 @@ typename cpp_regex_traits_implementation::string_type try{ #endif result = this->m_pcollate->transform(p1, p2); - // - // Borland's STLPort version returns a NULL-terminated - // string that has garbage at the end - each call to - // std::collate::transform returns a different string! - // So as a workaround, we'll truncate the string at the first NULL - // which _seems_ to work.... -#if BOOST_WORKAROUND(BOOST_BORLANDC, < 0x580) - result.erase(result.find(charT(0))); -#else // // some implementations (Dinkumware) append unnecessary trailing \0's: while((!result.empty()) && (charT(0) == *result.rbegin())) result.erase(result.size() - 1); -#endif // // We may have NULL's used as separators between sections of the collate string, // an example would be Boost.Locale. We have no way to detect this case via @@ -667,32 +622,10 @@ typename cpp_regex_traits_implementation::string_type if(pos != m_custom_collate_names.end()) return pos->second; } -#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\ - && !BOOST_WORKAROUND(BOOST_BORLANDC, <= 0x0551) std::string name(p1, p2); -#else - std::string name; - const charT* p0 = p1; - while(p0 != p2) - name.append(1, char(*p0++)); -#endif name = lookup_default_collate_name(name); -#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\ - && !BOOST_WORKAROUND(BOOST_BORLANDC, <= 0x0551) if(!name.empty()) return string_type(name.begin(), name.end()); -#else - if(!name.empty()) - { - string_type result; - typedef std::string::const_iterator iter; - iter b = name.begin(); - iter e = name.end(); - while(b != e) - result.append(1, charT(*b++)); - return result; - } -#endif if(p2 - p1 == 1) return string_type(1, *p1); return string_type(); @@ -701,7 +634,6 @@ typename cpp_regex_traits_implementation::string_type template void cpp_regex_traits_implementation::init() { -#ifndef BOOST_NO_STD_MESSAGES #ifndef __IBMCPP__ typename std::messages::catalog cat = static_cast::catalog>(-1); #else @@ -750,7 +682,6 @@ void cpp_regex_traits_implementation::init() // // Custom class names: // -#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET static const char_class_type masks[16] = { static_cast(std::ctype::alnum), @@ -770,27 +701,6 @@ void cpp_regex_traits_implementation::init() cpp_regex_traits_implementation::mask_word, cpp_regex_traits_implementation::mask_unicode, }; -#else - static const char_class_type masks[16] = - { - ::boost::BOOST_REGEX_DETAIL_NS::char_class_alnum, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_alpha, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_cntrl, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_digit, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_graph, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_horizontal_space, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_lower, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_print, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_punct, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_space, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_upper, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_vertical_space, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_xdigit, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_blank, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_word, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_unicode, - }; -#endif static const string_type null_string; for(unsigned int j = 0; j <= 13; ++j) { @@ -799,7 +709,6 @@ void cpp_regex_traits_implementation::init() this->m_custom_class_names[s] = masks[j]; } } -#endif // // get the collation format used by m_pcollate: // @@ -810,7 +719,6 @@ template typename cpp_regex_traits_implementation::char_class_type cpp_regex_traits_implementation::lookup_classname_imp(const charT* p1, const charT* p2) const { -#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET static const char_class_type masks[22] = { 0, @@ -836,33 +744,6 @@ typename cpp_regex_traits_implementation::char_class_type static_cast(std::ctype::alnum) | cpp_regex_traits_implementation::mask_word, static_cast(std::ctype::xdigit), }; -#else - static const char_class_type masks[22] = - { - 0, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_alnum, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_alpha, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_blank, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_cntrl, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_digit, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_digit, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_graph, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_horizontal_space, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_lower, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_lower, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_print, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_punct, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_space, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_space, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_upper, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_unicode, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_upper, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_vertical_space, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_alnum | ::boost::BOOST_REGEX_DETAIL_NS::char_class_word, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_alnum | ::boost::BOOST_REGEX_DETAIL_NS::char_class_word, - ::boost::BOOST_REGEX_DETAIL_NS::char_class_xdigit, - }; -#endif if(!m_custom_class_names.empty()) { typedef typename std::map, char_class_type>::const_iterator map_iter; @@ -875,29 +756,6 @@ typename cpp_regex_traits_implementation::char_class_type return masks[state_id]; } -#ifdef BOOST_REGEX_BUGGY_CTYPE_FACET -template -bool cpp_regex_traits_implementation::isctype(const charT c, char_class_type mask) const -{ - return - ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_space) && (this->m_pctype->is(std::ctype::space, c))) - || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_print) && (this->m_pctype->is(std::ctype::print, c))) - || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_cntrl) && (this->m_pctype->is(std::ctype::cntrl, c))) - || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_upper) && (this->m_pctype->is(std::ctype::upper, c))) - || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_lower) && (this->m_pctype->is(std::ctype::lower, c))) - || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_alpha) && (this->m_pctype->is(std::ctype::alpha, c))) - || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_digit) && (this->m_pctype->is(std::ctype::digit, c))) - || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_punct) && (this->m_pctype->is(std::ctype::punct, c))) - || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_xdigit) && (this->m_pctype->is(std::ctype::xdigit, c))) - || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_blank) && (this->m_pctype->is(std::ctype::space, c)) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c)) - || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_word) && (c == '_')) - || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_unicode) && ::boost::BOOST_REGEX_DETAIL_NS::is_extended(c)) - || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_vertical_space) && (is_separator(c) || (c == '\v'))) - || ((mask & ::boost::BOOST_REGEX_DETAIL_NS::char_class_horizontal_space) && this->m_pctype->is(std::ctype::space, c) && !(is_separator(c) || (c == '\v'))); -} -#endif - - template inline std::shared_ptr > create_cpp_regex_traits(const std::locale& l) { @@ -974,7 +832,6 @@ public: } bool isctype(charT c, char_class_type f) const { -#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET typedef typename std::ctype::mask ctype_mask; static const ctype_mask mask_base = @@ -1022,9 +879,6 @@ public: } #endif return false; -#else - return m_pimpl->isctype(c, f); -#endif } std::intmax_t toi(const charT*& p1, const charT* p2, int radix)const; int value(charT c, int radix)const diff --git a/include/boost/regex/v5/indexed_bit_flag.hpp b/include/boost/regex/v5/indexed_bit_flag.hpp index 2b17864e..b61e5cad 100644 --- a/include/boost/regex/v5/indexed_bit_flag.hpp +++ b/include/boost/regex/v5/indexed_bit_flag.hpp @@ -27,21 +27,21 @@ namespace BOOST_REGEX_DETAIL_NS{ class indexed_bit_flag { - boost::uint64_t low_mask; + std::uint64_t low_mask; std::set mask_set; public: indexed_bit_flag() : low_mask(0) {} void set(std::size_t i) { - if (i < std::numeric_limits::digits - 1) - low_mask |= static_cast(1u) << i; + if (i < std::numeric_limits::digits - 1) + low_mask |= static_cast(1u) << i; else mask_set.insert(i); } bool test(std::size_t i) { - if (i < std::numeric_limits::digits - 1) - return low_mask & static_cast(1u) << i ? true : false; + if (i < std::numeric_limits::digits - 1) + return low_mask & static_cast(1u) << i ? true : false; else return mask_set.find(i) != mask_set.end(); } diff --git a/include/boost/regex/v5/match_results.hpp b/include/boost/regex/v5/match_results.hpp index d51898d0..a450b704 100644 --- a/include/boost/regex/v5/match_results.hpp +++ b/include/boost/regex/v5/match_results.hpp @@ -551,7 +551,11 @@ private: static void raise_logic_error() { std::logic_error e("Attempt to access an uninitialized boost::match_results<> class."); +#ifndef BOOST_REGEX_STANDALONE boost::throw_exception(e); +#else + throw e; +#endif } diff --git a/include/boost/regex/v5/perl_matcher.hpp b/include/boost/regex/v5/perl_matcher.hpp index 6651a1b3..8bb75260 100644 --- a/include/boost/regex/v5/perl_matcher.hpp +++ b/include/boost/regex/v5/perl_matcher.hpp @@ -53,7 +53,11 @@ inline void verify_options(boost::regex_constants::syntax_option_type, match_fl if ((mf & match_extra) && (mf & match_posix)) { std::logic_error msg("Usage Error: Can't mix regular expression captures with POSIX matching rules"); +#ifndef BOOST_REGEX_STANDALONE throw_exception(msg); +#else + throw msg; +#endif } } // diff --git a/include/boost/regex/v5/perl_matcher_common.hpp b/include/boost/regex/v5/perl_matcher_common.hpp index 78feb8f9..deba9d46 100644 --- a/include/boost/regex/v5/perl_matcher_common.hpp +++ b/include/boost/regex/v5/perl_matcher_common.hpp @@ -61,7 +61,11 @@ void perl_matcher::construct_init(const basic_r { // precondition failure: e is not a valid regex. std::invalid_argument ex("Invalid regular expression object"); +#ifndef BOOST_REGEX_STANDALONE boost::throw_exception(ex); +#else + throw e; +#endif } pstate = 0; m_match_flags = f; diff --git a/include/boost/regex/v5/regex_traits.hpp b/include/boost/regex/v5/regex_traits.hpp index 8b1d5f84..bd4cf8ee 100644 --- a/include/boost/regex/v5/regex_traits.hpp +++ b/include/boost/regex/v5/regex_traits.hpp @@ -87,7 +87,7 @@ struct default_wrapper : public BaseT { return (char_type(c & 0x7f) == c) ? get_default_escape_syntax_type(static_cast(c)) : ::boost::regex_constants::escape_type_identity; } - boost::intmax_t toi(const char_type*& p1, const char_type* p2, int radix)const + std::intmax_t toi(const char_type*& p1, const char_type* p2, int radix)const { return ::boost::BOOST_REGEX_DETAIL_NS::global_toi(p1, p2, radix, *this); } diff --git a/include/boost/regex/v5/regex_workaround.hpp b/include/boost/regex/v5/regex_workaround.hpp index 3583050a..af56602b 100644 --- a/include/boost/regex/v5/regex_workaround.hpp +++ b/include/boost/regex/v5/regex_workaround.hpp @@ -70,9 +70,15 @@ inline void pointer_construct(T* p, const T& t) * ****************************************************************************/ +#if defined(BOOST_WORKAROUND) +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && defined(__STDC_WANT_SECURE_LIB__) && __STDC_WANT_SECURE_LIB__ +#define BOOST_REGEX_HAS_STRCPY_S +#endif +#endif + #ifdef __cplusplus namespace boost{ namespace BOOST_REGEX_DETAIL_NS{ -#if defined(BOOST_WORKAROUND) && BOOST_WORKAROUND(BOOST_MSVC,>=1400) && defined(__STDC_WANT_SECURE_LIB__) && __STDC_WANT_SECURE_LIB__ +#if defined(BOOST_REGEX_HAS_STRCPY_S) // use safe versions of strcpy etc: using ::strcpy_s; diff --git a/include/boost/regex/v5/w32_regex_traits.hpp b/include/boost/regex/v5/w32_regex_traits.hpp index dd1de0b5..330a4990 100644 --- a/include/boost/regex/v5/w32_regex_traits.hpp +++ b/include/boost/regex/v5/w32_regex_traits.hpp @@ -67,8 +67,8 @@ namespace BOOST_REGEX_DETAIL_NS{ // // start by typedeffing the types we'll need: // -typedef ::boost::uint32_t lcid_type; // placeholder for LCID. -typedef ::std::shared_ptr cat_type; // placeholder for dll HANDLE. +typedef std::uint32_t lcid_type; // placeholder for LCID. +typedef std::shared_ptr cat_type; // placeholder for dll HANDLE. // // then add wrappers around the actual Win32 API's (ie implementation hiding): @@ -99,9 +99,9 @@ char w32_toupper(char c, lcid_type); #ifndef BOOST_NO_WREGEX wchar_t w32_toupper(wchar_t c, lcid_type); #endif -bool w32_is(lcid_type, boost::uint32_t mask, char c); +bool w32_is(lcid_type, std::uint32_t mask, char c); #ifndef BOOST_NO_WREGEX -bool w32_is(lcid_type, boost::uint32_t mask, wchar_t c); +bool w32_is(lcid_type, std::uint32_t mask, wchar_t c); #endif // // class w32_regex_traits_base: @@ -158,7 +158,7 @@ public: { return ::boost::BOOST_REGEX_DETAIL_NS::w32_tolower(c, this->m_locale); } - bool isctype(boost::uint32_t mask, charT c)const + bool isctype(std::uint32_t mask, charT c)const { return ::boost::BOOST_REGEX_DETAIL_NS::w32_is(this->m_locale, mask, c); } @@ -255,7 +255,7 @@ public: { return m_lower_map[static_cast(c)]; } - bool isctype(boost::uint32_t mask, char c)const + bool isctype(std::uint32_t mask, char c)const { return m_type_map[static_cast(c)] & mask; } @@ -263,7 +263,7 @@ public: private: regex_constants::syntax_type m_char_map[1u << CHAR_BIT]; char m_lower_map[1u << CHAR_BIT]; - boost::uint16_t m_type_map[1u << CHAR_BIT]; + std::uint16_t m_type_map[1u << CHAR_BIT]; template void init(); }; @@ -529,7 +529,7 @@ public: typedef std::size_t size_type; typedef std::basic_string string_type; typedef ::boost::BOOST_REGEX_DETAIL_NS::lcid_type locale_type; - typedef boost::uint_least32_t char_class_type; + typedef std::uint_least32_t char_class_type; struct boost_extensions_tag{}; @@ -601,7 +601,7 @@ public: return true; return false; } - boost::intmax_t toi(const charT*& p1, const charT* p2, int radix)const + std::intmax_t toi(const charT*& p1, const charT* p2, int radix)const { return ::boost::BOOST_REGEX_DETAIL_NS::global_toi(p1, p2, radix, *this); } @@ -1134,7 +1134,7 @@ namespace BOOST_REGEX_DETAIL_NS { return result[0]; } #endif - inline bool w32_is(lcid_type idx, boost::uint32_t m, char c) + inline bool w32_is(lcid_type idx, std::uint32_t m, char c) { WORD mask; #ifndef BOOST_NO_ANSI_APIS @@ -1158,7 +1158,7 @@ namespace BOOST_REGEX_DETAIL_NS { } #ifndef BOOST_NO_WREGEX - inline bool w32_is(lcid_type idx, boost::uint32_t m, wchar_t c) + inline bool w32_is(lcid_type idx, std::uint32_t m, wchar_t c) { WORD mask; if (::GetStringTypeExW(idx, CT_CTYPE1, &c, 1, &mask) && (mask & m & w32_regex_traits_implementation::mask_base)) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index d461c7f5..c0393d7b 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -103,24 +103,29 @@ test-suite regex [ regex-test wide_posix_api_check_cpp : c_compiler_checks/wide_posix_api_check.cpp ] - [ run pathology/bad_expression_test.cpp - ../build//boost_regex + [ run pathology/bad_expression_test.cpp : : : + [ check-target-builds ../build//is_legacy_03 : : ../build//boost_regex ] ] - [ run pathology/recursion_test.cpp - ../build//boost_regex + [ run pathology/recursion_test.cpp : : : + [ check-target-builds ../build//is_legacy_03 : : ../build//boost_regex ] ] - [ run named_subexpressions/named_subexpressions_test.cpp - ../build//boost_regex + [ run named_subexpressions/named_subexpressions_test.cpp : : : + [ check-target-builds ../build//is_legacy_03 : : ../build//boost_regex ] ] - [ run unicode/unicode_iterator_test.cpp ../build//boost_regex : : : release TEST_UTF8 : unicode_iterator_test_utf8 ] - [ run unicode/unicode_iterator_test.cpp ../build//boost_regex : : : release TEST_UTF16 : unicode_iterator_test_utf16 ] + [ run unicode/unicode_iterator_test.cpp : : : + [ check-target-builds ../build//is_legacy_03 : : ../build//boost_regex ] + release TEST_UTF8 : unicode_iterator_test_utf8 ] + [ run unicode/unicode_iterator_test.cpp : : : + [ check-target-builds ../build//is_legacy_03 : : ../build//boost_regex ] + release TEST_UTF16 : unicode_iterator_test_utf16 ] [ run static_mutex/static_mutex_test.cpp ../../thread/build//boost_thread ../build//boost_regex ] - [ run object_cache/object_cache_test.cpp ../build//boost_regex + [ run object_cache/object_cache_test.cpp : : : + [ check-target-builds ../build//is_legacy_03 : : ../build//boost_regex ] ] [ run config_info/regex_config_info.cpp @@ -140,21 +145,33 @@ test-suite regex : : : always_show_run_output : test_collate_info ] - [ link concepts/concept_check.cpp ../build//boost_regex ] - [ link concepts/icu_concept_check.cpp ../build//boost_regex ] - [ link concepts/range_concept_check.cpp ../build//boost_regex ] - [ run concepts/test_bug_11988.cpp ../build//boost_regex ] + [ link concepts/concept_check.cpp : + [ check-target-builds ../build//is_legacy_03 : : ../build//boost_regex ] + ] + [ link concepts/concept_check.cpp : + BOOST_REGEX_STANDALONE [ check-target-builds ../build//is_legacy_03 : : ../build//boost_regex ] : standalone_concept_check + ] + [ link concepts/icu_concept_check.cpp : + [ check-target-builds ../build//is_legacy_03 : : ../build//boost_regex ] + ] + [ link concepts/range_concept_check.cpp : + [ check-target-builds ../build//is_legacy_03 : : ../build//boost_regex ] + ] + [ run concepts/test_bug_11988.cpp : : : + [ check-target-builds ../build//is_legacy_03 : : ../build//boost_regex ] + ] [ run # sources captures/captures_test.cpp - captures//boost_regex_extra ../build//icu_options + ../build//icu_options : # additional args : # test-files : # requirements multi BOOST_REGEX_MATCH_EXTRA=1 BOOST_REGEX_NO_LIB=1 + [ check-target-builds ../build//is_legacy_03 : : ../build//boost_regex ] : # test name captures_test ] diff --git a/test/concepts/concept_check.cpp b/test/concepts/concept_check.cpp index ed06feff..5d2792a8 100644 --- a/test/concepts/concept_check.cpp +++ b/test/concepts/concept_check.cpp @@ -9,6 +9,7 @@ * */ +#include #include #if defined(BOOST_MSVC) @@ -22,18 +23,11 @@ #pragma warning(disable:1418 981 983 595 383) #endif -#include -#include -#if !BOOST_WORKAROUND(_MSC_VER, < 1310) && !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__) && !BOOST_WORKAROUND(__GNUC__, < 3) #include -#endif int main() { - // VC6 and VC7 can't cope with the iterator architypes, - // don't bother testing as it doesn't work: -#if !BOOST_WORKAROUND(_MSC_VER, < 1310) && !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__) && !BOOST_WORKAROUND(__GNUC__, < 3) boost::function_requires< boost::RegexTraitsConcept< boost::regex_traits @@ -53,7 +47,6 @@ int main() >(); #endif #endif -#if !BOOST_WORKAROUND(BOOST_BORLANDC, < 0x560) boost::function_requires< boost::BoostRegexConcept< boost::basic_regex > @@ -66,7 +59,6 @@ int main() > >(); #endif -#endif #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) boost::function_requires< boost::BoostRegexConcept< @@ -90,15 +82,12 @@ int main() regex_traits_tester_type1 > >(); -#if !defined(__MWERKS__) && !defined(__SUNPRO_CC) // MWCW tries to instantiate std::basic_string, not sure whose bug this is.... typedef boost::basic_regex > regex_traits_tester_type2; boost::function_requires< boost::BaseRegexConcept< regex_traits_tester_type2 > >(); -#endif // __MWERKS__ -#endif return 0; }