From 75b6e20dbdfbf69424867dfdd3f00d3291e4af04 Mon Sep 17 00:00:00 2001 From: VemundH Date: Thu, 27 Feb 2020 08:56:58 +0100 Subject: [PATCH 01/49] Call correct overload in functions with icu UnicodeString argument --- include/boost/regex/icu.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/regex/icu.hpp b/include/boost/regex/icu.hpp index 1bf71cb4..0fb98b86 100644 --- a/include/boost/regex/icu.hpp +++ b/include/boost/regex/icu.hpp @@ -554,7 +554,7 @@ inline bool u32regex_match(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, match_flag_type flags = match_default) { - return BOOST_REGEX_DETAIL_NS::do_regex_match(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, static_cast const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_match(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, static_cast const*>(0)); } // // regex_match overloads that do not return what matched: @@ -618,7 +618,7 @@ inline bool u32regex_match(const U_NAMESPACE_QUALIFIER UnicodeString& s, match_flag_type flags = match_default) { match_results m; - return BOOST_REGEX_DETAIL_NS::do_regex_match(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, static_cast const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_match(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, static_cast const*>(0)); } // @@ -739,7 +739,7 @@ inline bool u32regex_search(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, match_flag_type flags = match_default) { - return BOOST_REGEX_DETAIL_NS::do_regex_search(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, s.getBuffer(), static_cast const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_search(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, s.getBuffer(), static_cast const*>(0)); } template inline bool u32regex_search(BidiIterator first, BidiIterator last, @@ -800,7 +800,7 @@ inline bool u32regex_search(const U_NAMESPACE_QUALIFIER UnicodeString& s, match_flag_type flags = match_default) { match_results m; - return BOOST_REGEX_DETAIL_NS::do_regex_search(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, s.getBuffer(), static_cast const*>(0)); + return BOOST_REGEX_DETAIL_NS::do_regex_search(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, s.getBuffer(), static_cast const*>(0)); } // From fd710a3bf0c483ebce61bdec4f41481bb2f8e605 Mon Sep 17 00:00:00 2001 From: Romain Geissler Date: Fri, 28 Feb 2020 02:05:31 +0000 Subject: [PATCH 02/49] Fix clang -Wdeprecated-copy warning in basic_regex_creator.hpp /data/mwrep/res/osp/Boost/19-0-0-18/include/boost/regex/v4/basic_regex_creator.hpp:52:4: error: definition of implicit copy assignment operator for 'digraph' is deprecated because it has a user-declared copy constructor [-Werror,-Wdeprecated-copy] digraph(const digraph& d) : std::pair(d.first, d.second){} ^ /data/mwrep/res/osp/Boost/19-0-0-18/include/boost/regex/v4/basic_regex_parser.hpp:1660:17: note: in implicit copy assignment operator for 'boost::re_detail_107000::digraph' first required here result = *m_position++; --- include/boost/regex/v4/basic_regex_creator.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/boost/regex/v4/basic_regex_creator.hpp b/include/boost/regex/v4/basic_regex_creator.hpp index f4b1660a..489a28f9 100644 --- a/include/boost/regex/v4/basic_regex_creator.hpp +++ b/include/boost/regex/v4/basic_regex_creator.hpp @@ -52,6 +52,9 @@ struct digraph : public std::pair digraph(charT c1, charT c2) : std::pair(c1, c2) {} digraph(const digraph& d) : std::pair(d.first, d.second){} +#ifndef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS + digraph& operator=(const digraph&) = default; +#endif template digraph(const Seq& s) : std::pair() { From c9d33026f3fe2bca9253ac06e0334bc2c9302294 Mon Sep 17 00:00:00 2001 From: Eugene Zelenko Date: Mon, 25 May 2020 17:04:15 -0700 Subject: [PATCH 03/49] Use BOOST_OVERRIDE to fix GCC -Wsuggest-override and Clang-tidy modernize-use-override warnings. Also fixed Clang-tidy modernize-redundant-void-arg, readability-container-size-empty, and some readability-simplify-boolean-expr warnings. Alphabetical order of STL headers. Fix some misspellings. --- include/boost/regex/icu.hpp | 2 +- include/boost/regex/pattern_except.hpp | 7 ++-- include/boost/regex/v4/basic_regex.hpp | 5 ++- .../boost/regex/v4/basic_regex_creator.hpp | 12 +++---- include/boost/regex/v4/basic_regex_parser.hpp | 20 +++++------ include/boost/regex/v4/cpp_regex_traits.hpp | 35 +++++++++---------- include/boost/regex/v4/perl_matcher.hpp | 5 ++- .../regex/v4/perl_matcher_non_recursive.hpp | 12 +++---- include/boost/regex/v4/protected_call.hpp | 4 ++- src/c_regex_traits.cpp | 3 +- src/cpp_regex_traits.cpp | 3 +- src/cregex.cpp | 24 +++---------- src/icu.cpp | 8 ++--- src/posix_api.cpp | 10 ++---- src/wc_regex_traits.cpp | 5 ++- src/wide_posix_api.cpp | 12 +++---- 16 files changed, 65 insertions(+), 102 deletions(-) diff --git a/include/boost/regex/icu.hpp b/include/boost/regex/icu.hpp index 1bf71cb4..fc6f5dd9 100644 --- a/include/boost/regex/icu.hpp +++ b/include/boost/regex/icu.hpp @@ -894,7 +894,7 @@ OutputIterator do_regex_replace(OutputIterator out, { if(!(flags & regex_constants::format_no_copy)) out = BOOST_REGEX_DETAIL_NS::copy(i->prefix().first, i->prefix().second, out); - if(f.size()) + if(!f.empty()) out = ::boost::BOOST_REGEX_DETAIL_NS::regex_format_imp(out, *i, &*f.begin(), &*f.begin() + f.size(), flags, e.get_traits()); else out = ::boost::BOOST_REGEX_DETAIL_NS::regex_format_imp(out, *i, static_cast(0), static_cast(0), flags, e.get_traits()); diff --git a/include/boost/regex/pattern_except.hpp b/include/boost/regex/pattern_except.hpp index 7ca409d8..a255d817 100644 --- a/include/boost/regex/pattern_except.hpp +++ b/include/boost/regex/pattern_except.hpp @@ -23,8 +23,8 @@ #include #endif -#include #include +#include #include namespace boost{ @@ -52,7 +52,7 @@ class BOOST_REGEX_DECL regex_error : public std::runtime_error public: explicit regex_error(const std::string& s, regex_constants::error_type err = regex_constants::error_unknown, std::ptrdiff_t pos = 0); explicit regex_error(regex_constants::error_type err); - ~regex_error() BOOST_NOEXCEPT_OR_NOTHROW; + ~regex_error() BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE; regex_constants::error_type code()const { return m_error_code; } std::ptrdiff_t position()const @@ -98,6 +98,3 @@ void raise_error(const traits& t, regex_constants::error_type code) } // namespace boost #endif - - - diff --git a/include/boost/regex/v4/basic_regex.hpp b/include/boost/regex/v4/basic_regex.hpp index c56dd8ef..c486c8d5 100644 --- a/include/boost/regex/v4/basic_regex.hpp +++ b/include/boost/regex/v4/basic_regex.hpp @@ -416,7 +416,7 @@ public: { typedef typename traits::string_type seq_type; seq_type a(arg_first, arg_last); - if(a.size()) + if(!a.empty()) assign(static_cast(&*a.begin()), static_cast(&*a.begin() + a.size()), f); else assign(static_cast(0), static_cast(0), f); @@ -657,7 +657,7 @@ private: // // out of line members; // these are the only members that mutate the basic_regex object, -// and are designed to provide the strong exception guarentee +// and are designed to provide the strong exception guarantee // (in the event of a throw, the state of the object remains unchanged). // template @@ -795,4 +795,3 @@ public: #endif #endif - diff --git a/include/boost/regex/v4/basic_regex_creator.hpp b/include/boost/regex/v4/basic_regex_creator.hpp index f4b1660a..b6108ea8 100644 --- a/include/boost/regex/v4/basic_regex_creator.hpp +++ b/include/boost/regex/v4/basic_regex_creator.hpp @@ -243,7 +243,7 @@ protected: 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; - bool m_has_recursions; // set when we have recursive expresisons to fixup + 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 typename traits::char_class_type m_mask_space; // mask used to determine if a character is a word character @@ -447,9 +447,9 @@ re_syntax_base* basic_regex_creator::append_set( charT a2[3] = { c2.first, c2.second, charT(0), }; s1 = this->m_traits.transform(a1, (a1[1] ? a1+2 : a1+1)); s2 = this->m_traits.transform(a2, (a2[1] ? a2+2 : a2+1)); - if(s1.size() == 0) + if(s1.empty()) s1 = string_type(1, charT(0)); - if(s2.size() == 0) + if(s2.empty()) s2 = string_type(1, charT(0)); } else @@ -951,7 +951,7 @@ void basic_regex_creator::create_startmaps(re_syntax_base* state) } // now work through our list, building all the maps as we go: - while(v.size()) + while(!v.empty()) { // Initialize m_recursion_checks if we need it: if(m_has_recursions) @@ -1516,7 +1516,7 @@ template void basic_regex_creator::probe_leading_repeat(re_syntax_base* state) { // enumerate our states, and see if we have a leading repeat - // for which failed search restarts can be optimised; + // for which failed search restarts can be optimized; do { switch(state->type) @@ -1573,7 +1573,6 @@ void basic_regex_creator::probe_leading_repeat(re_syntax_base* st }while(state); } - } // namespace BOOST_REGEX_DETAIL_NS } // namespace boost @@ -1594,4 +1593,3 @@ void basic_regex_creator::probe_leading_repeat(re_syntax_base* st #endif #endif - diff --git a/include/boost/regex/v4/basic_regex_parser.hpp b/include/boost/regex/v4/basic_regex_parser.hpp index 8bdb079f..77da995d 100644 --- a/include/boost/regex/v4/basic_regex_parser.hpp +++ b/include/boost/regex/v4/basic_regex_parser.hpp @@ -172,7 +172,7 @@ void basic_regex_parser::parse(const charT* p1, const charT* p2, m_parser_proc = &basic_regex_parser::parse_literal; break; default: - // Ooops, someone has managed to set more than one of the main option flags, + // Oops, 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; @@ -981,7 +981,7 @@ template bool basic_regex_parser::parse_repeat(std::size_t low, std::size_t high) { bool greedy = true; - bool pocessive = false; + bool possessive = false; std::size_t insert_point; // // when we get to here we may have a non-greedy ? mark still to come: @@ -1005,12 +1005,12 @@ bool basic_regex_parser::parse_repeat(std::size_t low, std::size_ greedy = false; ++m_position; } - // for perl regexes only check for pocessive ++ repeats. + // for perl regexes only check for possessive ++ repeats. if((m_position != m_end) && (0 == (this->flags() & regbase::main_option_type)) && (this->m_traits.syntax_type(*m_position) == regex_constants::syntax_plus)) { - pocessive = true; + possessive = true; ++m_position; } } @@ -1082,10 +1082,10 @@ bool basic_regex_parser::parse_repeat(std::size_t low, std::size_ rep = static_cast(this->getaddress(rep_off)); rep->alt.i = this->m_pdata->m_data.size() - rep_off; // - // If the repeat is pocessive then bracket the repeat with a (?>...) + // If the repeat is possessive then bracket the repeat with a (?>...) // independent sub-expression construct: // - if(pocessive) + if(possessive) { if(m_position != m_end) { @@ -1542,7 +1542,7 @@ bool basic_regex_parser::parse_inner_set(basic_char_set::parse_inner_set(basic_char_setm_traits.lookup_collatename(name_first, name_last); - if((0 == m.size()) || (m.size() > 2)) + if(m.empty() || (m.size() > 2)) { fail(regex_constants::error_collate, name_first - m_base); return false; @@ -3112,7 +3112,7 @@ bool basic_regex_parser::unwind_alts(std::ptrdiff_t last_paren_st // alternative then that's an error: // if((this->m_alt_insert_point == static_cast(this->m_pdata->m_data.size())) - && m_alt_jumps.size() && (m_alt_jumps.back() > last_paren_start) + && (!m_alt_jumps.empty()) && (m_alt_jumps.back() > last_paren_start) && !( ((this->flags() & regbase::main_option_type) == regbase::perl_syntax_group) @@ -3127,7 +3127,7 @@ bool basic_regex_parser::unwind_alts(std::ptrdiff_t last_paren_st // // Fix up our alternatives: // - while(m_alt_jumps.size() && (m_alt_jumps.back() > last_paren_start)) + while((!m_alt_jumps.empty()) && (m_alt_jumps.back() > last_paren_start)) { // // fix up the jump to point to the end of the states diff --git a/include/boost/regex/v4/cpp_regex_traits.hpp b/include/boost/regex/v4/cpp_regex_traits.hpp index 847f2ed7..fd2e6953 100644 --- a/include/boost/regex/v4/cpp_regex_traits.hpp +++ b/include/boost/regex/v4/cpp_regex_traits.hpp @@ -41,9 +41,9 @@ #include #endif -#include -#include #include +#include +#include #ifdef BOOST_MSVC #pragma warning(push) @@ -89,9 +89,9 @@ public: parser_buf() : base_type() { setbuf(0, 0); } const charT* getnext() { return this->gptr(); } protected: - std::basic_streambuf* setbuf(char_type* s, streamsize n); - typename parser_buf::pos_type seekpos(pos_type sp, ::std::ios_base::openmode which); - typename parser_buf::pos_type seekoff(off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which); + std::basic_streambuf* setbuf(char_type* s, streamsize n) BOOST_OVERRIDE; + typename parser_buf::pos_type seekpos(pos_type sp, ::std::ios_base::openmode which) BOOST_OVERRIDE; + typename parser_buf::pos_type seekoff(off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which) BOOST_OVERRIDE; private: parser_buf& operator=(const parser_buf&); parser_buf(const parser_buf&); @@ -225,7 +225,7 @@ std::locale cpp_regex_traits_base::imbue(const std::locale& l) // // class cpp_regex_traits_char_layer: -// implements methods that require specialisation for narrow characters: +// implements methods that require specialization for narrow characters: // template class cpp_regex_traits_char_layer : public cpp_regex_traits_base @@ -281,7 +281,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() && (this->m_pmessages != 0)) + if((!cat_name.empty()) && (this->m_pmessages != 0)) { cat = this->m_pmessages->open( cat_name, @@ -352,7 +352,7 @@ typename cpp_regex_traits_char_layer::string_type } // -// specialised version for narrow characters: +// specialized version for narrow characters: // template <> class BOOST_REGEX_DECL cpp_regex_traits_char_layer : public cpp_regex_traits_base @@ -566,7 +566,7 @@ typename cpp_regex_traits_implementation::string_type #ifndef BOOST_NO_EXCEPTIONS }catch(...){} #endif - while(result.size() && (charT(0) == *result.rbegin())) + while((!result.empty()) && (charT(0) == *result.rbegin())) result.erase(result.size() - 1); if(result.empty()) { @@ -621,7 +621,7 @@ typename cpp_regex_traits_implementation::string_type #else // // some implementations (Dinkumware) append unnecessary trailing \0's: - while(result.size() && (charT(0) == *result.rbegin())) + while((!result.empty()) && (charT(0) == *result.rbegin())) result.erase(result.size() - 1); #endif // @@ -662,7 +662,7 @@ typename cpp_regex_traits_implementation::string_type cpp_regex_traits_implementation::lookup_collatename(const charT* p1, const charT* p2) const { typedef typename std::map::const_iterator iter_type; - if(m_custom_collate_names.size()) + if(!m_custom_collate_names.empty()) { iter_type pos = m_custom_collate_names.find(string_type(p1, p2)); if(pos != m_custom_collate_names.end()) @@ -680,10 +680,10 @@ typename cpp_regex_traits_implementation::string_type name = lookup_default_collate_name(name); #if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\ && !BOOST_WORKAROUND(__BORLANDC__, <= 0x0551) - if(name.size()) + if(!name.empty()) return string_type(name.begin(), name.end()); #else - if(name.size()) + if(!name.empty()) { string_type result; typedef std::string::const_iterator iter; @@ -709,7 +709,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() && (this->m_pmessages != 0)) + if((!cat_name.empty()) && (this->m_pmessages != 0)) { cat = this->m_pmessages->open( cat_name, @@ -796,7 +796,7 @@ void cpp_regex_traits_implementation::init() for(unsigned int j = 0; j <= 13; ++j) { string_type s(this->m_pmessages->get(cat, 0, j+300, null_string)); - if(s.size()) + if(!s.empty()) this->m_custom_class_names[s] = masks[j]; } } @@ -864,7 +864,7 @@ typename cpp_regex_traits_implementation::char_class_type ::boost::BOOST_REGEX_DETAIL_NS::char_class_xdigit, }; #endif - if(m_custom_class_names.size()) + if(!m_custom_class_names.empty()) { typedef typename std::map, char_class_type>::const_iterator map_iter; map_iter pos = m_custom_class_names.find(string_type(p1, p2)); @@ -1129,7 +1129,6 @@ static_mutex& cpp_regex_traits::get_mutex_inst() } #endif - } // boost #ifdef BOOST_MSVC @@ -1150,5 +1149,3 @@ static_mutex& cpp_regex_traits::get_mutex_inst() #endif #endif - - diff --git a/include/boost/regex/v4/perl_matcher.hpp b/include/boost/regex/v4/perl_matcher.hpp index 05886b08..7d04ff26 100644 --- a/include/boost/regex/v4/perl_matcher.hpp +++ b/include/boost/regex/v4/perl_matcher.hpp @@ -88,7 +88,7 @@ inline bool can_start(unsigned int c, const unsigned char* map, unsigned char ma // // Unfortunately Rogue Waves standard library appears to have a bug -// in std::basic_string::compare that results in eroneous answers +// in std::basic_string::compare that results in erroneous answers // in some cases (tested with Borland C++ 5.1, Rogue Wave lib version // 0x020101) the test case was: // {39135,0} < {0xff,0} @@ -375,7 +375,7 @@ class perl_matcher public: typedef typename traits::char_type char_type; typedef perl_matcher self_type; - typedef bool (self_type::*matcher_proc_type)(void); + typedef bool (self_type::*matcher_proc_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; @@ -633,4 +633,3 @@ private: #include #endif - diff --git a/include/boost/regex/v4/perl_matcher_non_recursive.hpp b/include/boost/regex/v4/perl_matcher_non_recursive.hpp index eb470a78..c7955b13 100644 --- a/include/boost/regex/v4/perl_matcher_non_recursive.hpp +++ b/include/boost/regex/v4/perl_matcher_non_recursive.hpp @@ -217,7 +217,7 @@ bool perl_matcher::match_all_states() bool successful_unwind = unwind(false); if((m_match_flags & match_partial) && (position == last) && (position != search_base)) m_has_partial_match = true; - if(false == successful_unwind) + if(!successful_unwind) return m_recursive_result; } } @@ -348,7 +348,7 @@ inline void perl_matcher::push_repeater_count(i pmp = static_cast*>(m_backup_state); --pmp; } - (void) new (pmp)saved_repeater(i, s, position, this->recursion_stack.size() ? this->recursion_stack.back().idx : (INT_MIN + 3)); + (void) new (pmp)saved_repeater(i, s, position, this->recursion_stack.empty() ? (INT_MIN + 3) : this->recursion_stack.back().idx); m_backup_state = pmp; } @@ -705,7 +705,7 @@ bool perl_matcher::match_dot_repeat_slow() std::size_t count = 0; const re_repeat* rep = static_cast(pstate); re_syntax_base* psingle = rep->next.p; - // match compulsary repeats first: + // match compulsory repeats first: while(count < rep->min) { pstate = psingle; @@ -1224,7 +1224,7 @@ bool perl_matcher::skip_until_paren(int index, /**************************************************************************** -Unwind and associated proceedures follow, these perform what normal stack +Unwind and associated procedures follow, these perform what normal stack unwinding does in the recursive implementation. ****************************************************************************/ @@ -1296,7 +1296,7 @@ bool perl_matcher::unwind_paren(bool have_match { saved_matched_paren* pmp = static_cast*>(m_backup_state); // restore previous values if no match was found: - if(have_match == false) + if(!have_match) { m_presult->set_first(pmp->sub.first, pmp->index, pmp->index == 0); m_presult->set_second(pmp->sub.second, pmp->index, pmp->sub.matched, pmp->index == 0); @@ -1944,5 +1944,3 @@ inline void perl_matcher::push_parenthesis_push #endif #endif - - diff --git a/include/boost/regex/v4/protected_call.hpp b/include/boost/regex/v4/protected_call.hpp index 9d47514f..451b2e34 100644 --- a/include/boost/regex/v4/protected_call.hpp +++ b/include/boost/regex/v4/protected_call.hpp @@ -20,6 +20,8 @@ #ifndef BOOST_REGEX_V4_PROTECTED_CALL_HPP #define BOOST_REGEX_V4_PROTECTED_CALL_HPP +#include + #ifdef BOOST_MSVC #pragma warning(push) #pragma warning(disable: 4103) @@ -53,7 +55,7 @@ public: concrete_protected_call(T* o, proc_type p) : obj(o), proc(p) {} private: - virtual bool call()const; + bool call()const BOOST_OVERRIDE; T* obj; proc_type proc; }; diff --git a/src/c_regex_traits.cpp b/src/c_regex_traits.cpp index 09300666..2804f75a 100644 --- a/src/c_regex_traits.cpp +++ b/src/c_regex_traits.cpp @@ -16,7 +16,6 @@ * DESCRIPTION: Implements out of line c_regex_traits members */ - #define BOOST_REGEX_SOURCE #include @@ -105,7 +104,7 @@ c_regex_traits::string_type BOOST_REGEX_CALL c_regex_traits::transfo case ::boost::BOOST_REGEX_DETAIL_NS::sort_delim: // get a regular sort key, and then truncate everything after the delim: result = transform(p1, p2); - if(result.size() && (result[0] == s_delim)) + if((!result.empty()) && (result[0] == s_delim)) break; std::size_t i; for(i = 0; i < result.size(); ++i) diff --git a/src/cpp_regex_traits.cpp b/src/cpp_regex_traits.cpp index 05bbc50d..840cc5f7 100644 --- a/src/cpp_regex_traits.cpp +++ b/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() && (m_pmessages != 0)) + if((!cat_name.empty()) && (m_pmessages != 0)) { cat = this->m_pmessages->open( cat_name, @@ -114,4 +114,3 @@ void cpp_regex_traits_char_layer::init() } // BOOST_REGEX_DETAIL_NS } // boost #endif - diff --git a/src/cregex.cpp b/src/cregex.cpp index ece28204..00257289 100644 --- a/src/cregex.cpp +++ b/src/cregex.cpp @@ -22,11 +22,11 @@ #include #include #if !defined(BOOST_NO_STD_STRING) -#include +#include #include +#include #include typedef boost::match_flag_type match_flag_type; -#include #ifdef BOOST_MSVC #pragma warning(disable:4309) @@ -417,7 +417,7 @@ unsigned int RegEx::GrepFiles(GrepFileCallback cb, const char* files, bool recur result += r; ++start; pdata->clean(); - if(pred.ok == false) + if(!pred.ok) return result; } @@ -443,7 +443,7 @@ unsigned int RegEx::FindFiles(FindFilesCallback cb, const char* files, bool recu if(regex_search(map.begin(), map.end(), pdata->fm, pdata->e, flags)) { ++result; - if(false == cb((*start).c_str())) + if(!cb((*start).c_str())) return result; } //pdata->update(); @@ -649,19 +649,3 @@ basic_string::replace(wchar_t* f1, wchar_t* f2, const w #endif #endif - - - - - - - - - - - - - - - - diff --git a/src/icu.cpp b/src/icu.cpp index cb11f323..dde20ccb 100644 --- a/src/icu.cpp +++ b/src/icu.cpp @@ -44,14 +44,14 @@ icu_regex_traits_implementation::string_type icu_regex_traits_implementation::do #endif ::uint8_t result[100]; ::int32_t len; - if(t.size()) + if(!t.empty()) len = pcoll->getSortKey(&*t.begin(), static_cast< ::int32_t>(t.size()), result, sizeof(result)); else len = pcoll->getSortKey(static_cast(0), static_cast< ::int32_t>(0), result, sizeof(result)); if(std::size_t(len) > sizeof(result)) { scoped_array< ::uint8_t> presult(new ::uint8_t[len+1]); - if(t.size()) + if(!t.empty()) len = pcoll->getSortKey(&*t.begin(), static_cast< ::int32_t>(t.size()), presult.get(), len+1); else len = pcoll->getSortKey(static_cast(0), static_cast< ::int32_t>(0), presult.get(), len+1); @@ -414,11 +414,11 @@ icu_regex_traits::char_class_type icu_regex_traits::lookup_classname(const char_ ++i; } } - if(s.size()) + if(!s.empty()) idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(&*s.begin(), &*s.begin() + s.size()); if(idx >= 0) return masks[idx+1]; - if(s.size()) + if(!s.empty()) result = lookup_icu_mask(&*s.begin(), &*s.begin() + s.size()); if(result != 0) return result; diff --git a/src/posix_api.cpp b/src/posix_api.cpp index 47133fa0..95978e43 100644 --- a/src/posix_api.cpp +++ b/src/posix_api.cpp @@ -19,9 +19,9 @@ #define BOOST_REGEX_SOURCE #include -#include #include #include +#include #if defined(BOOST_NO_STDC_NAMESPACE) namespace std{ @@ -269,8 +269,8 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA* expression, cons std::size_t i; for(i = 0; (i < n) && (i < expression->re_nsub + 1); ++i) { - array[i].rm_so = (m[i].matched == false) ? -1 : (m[i].first - buf); - array[i].rm_eo = (m[i].matched == false) ? -1 : (m[i].second - buf); + array[i].rm_so = m[i].matched ? (m[i].first - buf) : -1; + array[i].rm_eo = m[i].matched ? (m[i].second - buf) : -1; } // and set anything else to -1: for(i = expression->re_nsub + 1; i < n; ++i) @@ -296,7 +296,3 @@ BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeA(regex_tA* expression) } } // namespace boost - - - - diff --git a/src/wc_regex_traits.cpp b/src/wc_regex_traits.cpp index e7fcfb8e..78dac89b 100644 --- a/src/wc_regex_traits.cpp +++ b/src/wc_regex_traits.cpp @@ -145,7 +145,7 @@ c_regex_traits::string_type BOOST_REGEX_CALL c_regex_traits::t case ::boost::BOOST_REGEX_DETAIL_NS::sort_delim: // get a regular sort key, and then truncate everything after the delim: result = c_regex_traits::transform(&*result.begin(), &*result.begin() + result.size()); - if(result.size() && (result[0] == s_delim)) + if((!result.empty()) && (result[0] == s_delim)) break; std::size_t i; for(i = 0; i < result.size(); ++i) @@ -236,7 +236,7 @@ c_regex_traits::string_type BOOST_REGEX_CALL c_regex_traits::l #if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\ && !BOOST_WORKAROUND(BOOST_MSVC, < 1300)\ && !BOOST_WORKAROUND(__BORLANDC__, <= 0x0551) - if(name.size()) + if(!name.empty()) return string_type(name.begin(), name.end()); #else if(name.size()) @@ -311,4 +311,3 @@ int BOOST_REGEX_CALL c_regex_traits::value(unsigned short c, int #endif // BOOST_NO_WREGEX #endif // __BORLANDC__ - diff --git a/src/wide_posix_api.cpp b/src/wide_posix_api.cpp index c675104b..abd68c59 100644 --- a/src/wide_posix_api.cpp +++ b/src/wide_posix_api.cpp @@ -25,9 +25,9 @@ #include #include -#include -#include #include +#include +#include #ifdef BOOST_INTEL #pragma warning(disable:981) @@ -284,8 +284,8 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW* expression, cons std::size_t i; for(i = 0; (i < n) && (i < expression->re_nsub + 1); ++i) { - array[i].rm_so = (m[i].matched == false) ? -1 : (m[i].first - buf); - array[i].rm_eo = (m[i].matched == false) ? -1 : (m[i].second - buf); + array[i].rm_so = m[i].matched ? (m[i].first - buf) : -1; + array[i].rm_eo = m[i].matched ? (m[i].second - buf) : -1; } // and set anything else to -1: for(i = expression->re_nsub + 1; i < n; ++i) @@ -313,7 +313,3 @@ BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeW(regex_tW* expression) } // namespace boost; #endif - - - - From 9eabbbedcf4bcf4760bb21103d591b402942e2a1 Mon Sep 17 00:00:00 2001 From: Peter Klotz Date: Thu, 1 Oct 2020 16:07:35 +0200 Subject: [PATCH 04/49] Fixed typos (mainly in comments) --- include/boost/regex/v4/basic_regex_creator.hpp | 2 +- include/boost/regex/v4/match_flags.hpp | 10 +++++----- include/boost/regex/v4/primary_transform.hpp | 2 +- include/boost/regex/v4/states.hpp | 2 +- performance/performance.cpp | 2 +- test/regress/test_deprecated.cpp | 4 ++-- test/regress/test_replace.cpp | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/boost/regex/v4/basic_regex_creator.hpp b/include/boost/regex/v4/basic_regex_creator.hpp index f4b1660a..cf64fc4a 100644 --- a/include/boost/regex/v4/basic_regex_creator.hpp +++ b/include/boost/regex/v4/basic_regex_creator.hpp @@ -303,7 +303,7 @@ re_syntax_base* basic_regex_creator::append_state(syntax_element_ // set the offset to the next state in our last one: if(m_last_state) m_last_state->next.i = m_pdata->m_data.size() - getoffset(m_last_state); - // now actually extent our data: + // now actually extend our data: m_last_state = static_cast(m_pdata->m_data.extend(s)); // fill in boilerplate options in the new state: m_last_state->next.i = 0; diff --git a/include/boost/regex/v4/match_flags.hpp b/include/boost/regex/v4/match_flags.hpp index 1f7ed255..5dc72655 100644 --- a/include/boost/regex/v4/match_flags.hpp +++ b/include/boost/regex/v4/match_flags.hpp @@ -51,7 +51,7 @@ typedef enum _match_flags 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 */ + /* uninterrupted from the previous one */ match_partial = match_continuous << 1, /* find partial matches */ match_stop = match_partial << 1, /* stop after first match (grep) V3 only */ @@ -61,7 +61,7 @@ typedef enum _match_flags 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_single_line = match_extra << 1, /* treat text as single line and ignore 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 */ @@ -70,9 +70,9 @@ typedef enum _match_flags 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_all = format_sed << 1, /* enable all extensions to syntax. */ format_no_copy = format_all << 1, /* don't copy non-matching segments. */ - format_first_only = format_no_copy << 1, /* Only replace first occurance. */ + format_first_only = format_no_copy << 1, /* Only replace first occurrence. */ format_is_if = format_first_only << 1, /* internal use only. */ format_literal = format_is_if << 1, /* treat string as a literal */ @@ -116,7 +116,7 @@ inline match_flags& operator^=(match_flags& m1, match_flags m2) #ifdef __cplusplus } /* namespace regex_constants */ /* - * import names into boost for backwards compatiblity: + * import names into boost for backwards compatibility: */ using regex_constants::match_flag_type; using regex_constants::match_default; diff --git a/include/boost/regex/v4/primary_transform.hpp b/include/boost/regex/v4/primary_transform.hpp index 3e7cac54..47d172aa 100644 --- a/include/boost/regex/v4/primary_transform.hpp +++ b/include/boost/regex/v4/primary_transform.hpp @@ -46,7 +46,7 @@ template unsigned count_chars(const S& s, charT c) { // - // Count how many occurances of character c occur + // Count how many occurrences of character c occur // in string s: if c is a delimeter between collation // fields, then this should be the same value for all // sort keys: diff --git a/include/boost/regex/v4/states.hpp b/include/boost/regex/v4/states.hpp index b56d0134..86eb02b1 100644 --- a/include/boost/regex/v4/states.hpp +++ b/include/boost/regex/v4/states.hpp @@ -161,7 +161,7 @@ A marked parenthesis. struct re_brace : public re_syntax_base { // The index to match, can be zero (don't mark the sub-expression) - // or negative (for perl style (?...) extentions): + // or negative (for perl style (?...) extensions): int index; bool icase; }; diff --git a/performance/performance.cpp b/performance/performance.cpp index 798aa330..3fb22535 100644 --- a/performance/performance.cpp +++ b/performance/performance.cpp @@ -148,7 +148,7 @@ void test_search(const char* expression, const char* text, bool isperl = false, { double time = exec_timed_test([&]() { return (*i)->find_all(text); }); report_execution_time(time, table, row, heading); - std::cout << "Search with library: " << heading << " found " << last_value_returned << " occurances.\n"; + std::cout << "Search with library: " << heading << " found " << last_value_returned << " occurrences.\n"; } } } diff --git a/test/regress/test_deprecated.cpp b/test/regress/test_deprecated.cpp index 493c02b2..d2389a2d 100644 --- a/test/regress/test_deprecated.cpp +++ b/test/regress/test_deprecated.cpp @@ -99,7 +99,7 @@ void test_deprecated(const char&, const test_regex_search_tag&) BOOST_REGEX_TEST_ERROR("Expression : \"" << expression.c_str() << "\" did not compile with the POSIX C API.", char); return; } - // try and find the first occurance: + // try and find the first occurrence: static const unsigned max_subs = 100; boost::regmatch_t matches[max_subs]; if(boost::regexecA(&re, search_text.c_str(), max_subs, matches, posix_match_options) == 0) @@ -227,7 +227,7 @@ void test_deprecated(const wchar_t&, const test_regex_search_tag&) BOOST_REGEX_TEST_ERROR("Expression : \"" << expression.c_str() << "\" did not compile with the POSIX C API.", wchar_t); return; } - // try and find the first occurance: + // try and find the first occurrence: static const unsigned max_subs = 100; boost::regmatch_t matches[max_subs]; if(boost::regexecW(&re, search_text.c_str(), max_subs, matches, posix_match_options) == 0) diff --git a/test/regress/test_replace.cpp b/test/regress/test_replace.cpp index 635e6e30..cd434e18 100644 --- a/test/regress/test_replace.cpp +++ b/test/regress/test_replace.cpp @@ -98,7 +98,7 @@ void test_replace() TEST_REGEX_REPLACE("(?a+)|(?b+)", perl, "...aaabb,,,ab*abbb?", match_default|format_all, "(?{one}A:B)C", "...ACBC,,,ACBC*ACBC?"); TEST_REGEX_REPLACE("(?a+)|(?b+)", perl, "...aaabb,,,ab*abbb?", match_default|format_all, "?{one}:B", "...B,,,B*B?"); - // move to copying unmatched data, but replace first occurance only: + // move to copying unmatched data, but replace first occurrence only: TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_all|format_first_only, "bbb", "...bbb,,,"); TEST_REGEX_REPLACE("a+(b+)", perl, "...aaabb,,,", match_default|format_all|format_first_only, "$1", "...bb,,,"); TEST_REGEX_REPLACE("a+(b+)", perl, "...aaabb,,,ab*abbb?", match_default|format_all|format_first_only, "$1", "...bb,,,ab*abbb?"); From 21e1ea087705813a5daf5e8a9ef35b2f3570bd2a Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Sun, 11 Oct 2020 17:22:32 +0200 Subject: [PATCH 05/49] Fix typo in copyright headers. --- example/snippets/regex_token_iterator_eg_1.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/snippets/regex_token_iterator_eg_1.cpp b/example/snippets/regex_token_iterator_eg_1.cpp index 74fcbf1a..4bf5c62f 100644 --- a/example/snippets/regex_token_iterator_eg_1.cpp +++ b/example/snippets/regex_token_iterator_eg_1.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 12003 + * Copyright (c) 2003 * John Maddock * * Use, modification and distribution are subject to the From a703ab2c596b70044d4a4563b8d167ce9f29e9a7 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Mon, 12 Oct 2020 18:22:57 +0100 Subject: [PATCH 06/49] Fix syntax formatting in docs. Replaces https://github.com/boostorg/regex/pull/107. --- doc/html/boost_regex/background.html | 4 ++-- .../background/acknowledgements.html | 8 ++++---- doc/html/boost_regex/background/examples.html | 4 ++-- doc/html/boost_regex/background/faq.html | 4 ++-- doc/html/boost_regex/background/futher.html | 4 ++-- doc/html/boost_regex/background/headers.html | 4 ++-- doc/html/boost_regex/background/history.html | 11 +++++------ doc/html/boost_regex/background/locale.html | 4 ++-- .../boost_regex/background/performance.html | 4 ++-- .../performance/section_id1378460593.html | 6 +++--- .../performance/section_id1675827111.html | 6 +++--- .../performance/section_id3141719723.html | 6 +++--- .../performance/section_id3258595385.html | 6 +++--- .../performance/section_id3261825021.html | 6 +++--- .../performance/section_id3752650613.html | 6 +++--- .../performance/section_id4128344975.html | 6 +++--- .../performance/section_id4148872883.html | 6 +++--- doc/html/boost_regex/background/redist.html | 4 ++-- doc/html/boost_regex/background/standards.html | 8 ++++---- .../boost_regex/background/thread_safety.html | 4 ++-- doc/html/boost_regex/captures.html | 4 ++-- doc/html/boost_regex/configuration.html | 4 ++-- .../boost_regex/configuration/algorithm.html | 4 ++-- .../boost_regex/configuration/compiler.html | 4 ++-- .../boost_regex/configuration/linkage.html | 4 ++-- doc/html/boost_regex/configuration/locale.html | 4 ++-- doc/html/boost_regex/configuration/tuning.html | 4 ++-- doc/html/boost_regex/format.html | 4 ++-- .../format/boost_format_syntax.html | 4 ++-- doc/html/boost_regex/format/perl_format.html | 4 ++-- doc/html/boost_regex/format/sed_format.html | 4 ++-- doc/html/boost_regex/install.html | 4 ++-- doc/html/boost_regex/intro.html | 4 ++-- doc/html/boost_regex/partial_matches.html | 4 ++-- doc/html/boost_regex/ref.html | 4 ++-- doc/html/boost_regex/ref/bad_expression.html | 4 ++-- doc/html/boost_regex/ref/basic_regex.html | 18 +++++++++--------- doc/html/boost_regex/ref/concepts.html | 4 ++-- .../ref/concepts/charT_concept.html | 4 ++-- .../ref/concepts/iterator_concepts.html | 4 ++-- .../ref/concepts/traits_concept.html | 4 ++-- doc/html/boost_regex/ref/deprecated.html | 4 ++-- .../boost_regex/ref/deprecated/old_regex.html | 4 ++-- .../ref/deprecated/regex_format.html | 4 ++-- .../boost_regex/ref/deprecated/regex_grep.html | 4 ++-- .../ref/deprecated/regex_split.html | 4 ++-- doc/html/boost_regex/ref/error_type.html | 4 ++-- doc/html/boost_regex/ref/internals.html | 4 ++-- .../boost_regex/ref/internals/uni_iter.html | 4 ++-- doc/html/boost_regex/ref/match_flag_type.html | 4 ++-- doc/html/boost_regex/ref/match_results.html | 4 ++-- doc/html/boost_regex/ref/non_std_strings.html | 4 ++-- .../boost_regex/ref/non_std_strings/icu.html | 4 ++-- .../ref/non_std_strings/icu/intro.html | 4 ++-- .../ref/non_std_strings/icu/unicode_algo.html | 4 ++-- .../ref/non_std_strings/icu/unicode_iter.html | 8 ++++---- .../ref/non_std_strings/icu/unicode_types.html | 4 ++-- .../ref/non_std_strings/mfc_strings.html | 4 ++-- .../non_std_strings/mfc_strings/mfc_algo.html | 4 ++-- .../non_std_strings/mfc_strings/mfc_intro.html | 4 ++-- .../non_std_strings/mfc_strings/mfc_iter.html | 4 ++-- .../mfc_strings/mfc_regex_create.html | 4 ++-- .../mfc_strings/mfc_regex_types.html | 4 ++-- doc/html/boost_regex/ref/posix.html | 4 ++-- doc/html/boost_regex/ref/regex_iterator.html | 4 ++-- doc/html/boost_regex/ref/regex_match.html | 4 ++-- doc/html/boost_regex/ref/regex_replace.html | 4 ++-- doc/html/boost_regex/ref/regex_search.html | 4 ++-- .../boost_regex/ref/regex_token_iterator.html | 4 ++-- doc/html/boost_regex/ref/regex_traits.html | 4 ++-- doc/html/boost_regex/ref/sub_match.html | 4 ++-- .../boost_regex/ref/syntax_option_type.html | 4 ++-- .../syntax_option_type_basic.html | 4 ++-- .../syntax_option_type_extended.html | 4 ++-- .../syntax_option_type_literal.html | 4 ++-- .../syntax_option_type_overview.html | 4 ++-- .../syntax_option_type_perl.html | 4 ++-- .../syntax_option_type_synopsis.html | 4 ++-- doc/html/boost_regex/syntax.html | 4 ++-- .../boost_regex/syntax/basic_extended.html | 12 ++++++------ doc/html/boost_regex/syntax/basic_syntax.html | 12 ++++++------ .../boost_regex/syntax/character_classes.html | 4 ++-- .../optional_char_class_names.html | 4 ++-- .../character_classes/std_char_classes.html | 4 ++-- .../boost_regex/syntax/collating_names.html | 4 ++-- .../syntax/collating_names/digraphs.html | 4 ++-- .../syntax/collating_names/named_unicode.html | 4 ++-- .../collating_names/posix_symbolic_names.html | 4 ++-- .../syntax/leftmost_longest_rule.html | 4 ++-- doc/html/boost_regex/syntax/perl_syntax.html | 12 ++++++------ doc/html/boost_regex/unicode.html | 4 ++-- doc/html/index.html | 6 +++--- doc/syntax_basic.qbk | 2 +- doc/syntax_extended.qbk | 2 +- doc/syntax_perl.qbk | 2 +- 95 files changed, 224 insertions(+), 225 deletions(-) diff --git a/doc/html/boost_regex/background.html b/doc/html/boost_regex/background.html index 74e1dcd4..426e00dc 100644 --- a/doc/html/boost_regex/background.html +++ b/doc/html/boost_regex/background.html @@ -1,6 +1,6 @@ - + Background Information @@ -66,7 +66,7 @@ -
-
-
-
-
-

- New issues should be submitted at svn.boost.org - - don't forget to include your email address in the ticket! + New issues should be submitted at https://github.com/boostorg/regex/issues

- Currently open issues can be viewed here. + Currently open issues can be viewed here.

- All issues including closed ones can be viewed here. + All issues including closed ones can be viewed here.

@@ -512,7 +511,7 @@ -
-
-
-

Table 8. Testing simple leftmost-longest matches (platform = linux, compiler +

Table 8. Testing simple leftmost-longest matches (platform = linux, compiler = GNU C++ version 6.3.0)

@@ -390,7 +390,7 @@
-
-

Table 9. Testing Perl searches (platform = linux, compiler = GNU C++ version +

Table 9. Testing Perl searches (platform = linux, compiler = GNU C++ version 6.3.0)

@@ -437,7 +437,7 @@
-
-

Table 10. Testing simple leftmost-longest matches (platform = Windows x64, +

Table 10. Testing simple leftmost-longest matches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.1)

@@ -314,7 +314,7 @@
-
-

Table 11. Testing leftmost-longest searches (platform = Windows x64, compiler +

Table 11. Testing leftmost-longest searches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.1)

@@ -116,7 +116,7 @@
-
-

Table 12. Testing simple Perl matches (platform = linux, compiler = GNU C++ +

Table 12. Testing simple Perl matches (platform = linux, compiler = GNU C++ version 6.3.0)

@@ -465,7 +465,7 @@
-
-

Table 13. Testing Perl searches (platform = Windows x64, compiler = Microsoft +

Table 13. Testing Perl searches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.1)

@@ -509,7 +509,7 @@
-
-

Table 14. Testing simple Perl matches (platform = Windows x64, compiler = +

Table 14. Testing simple Perl matches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.1)

@@ -542,7 +542,7 @@
-
-

Table 15. Testing leftmost-longest searches (platform = linux, compiler = +

Table 15. Testing leftmost-longest searches (platform = linux, compiler = GNU C++ version 6.3.0)

@@ -136,7 +136,7 @@
-
- @@ -306,7 +306,7 @@ Not supported.

- +
  
@@ -559,7 +559,7 @@ -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-