From 2a248d1f8746155378db81037db306ffce9cdc0c Mon Sep 17 00:00:00 2001 From: John Maddock Date: Tue, 18 Jan 2005 12:52:40 +0000 Subject: [PATCH] Changed assert's to BOOST_ASSERT's. Made array sizes explicit to fix MWCW problems. [SVN r26723] --- include/boost/regex/concepts.hpp | 2 +- include/boost/regex/config/allocator.hpp | 14 ++--- .../boost/regex/pending/unicode_iterator.hpp | 2 +- include/boost/regex/v4/basic_regex.hpp | 12 ++-- .../boost/regex/v4/basic_regex_creator.hpp | 8 +-- include/boost/regex/v4/basic_regex_parser.hpp | 2 +- include/boost/regex/v4/cpp_regex_traits.hpp | 10 ++-- include/boost/regex/v4/fileiter.hpp | 5 +- include/boost/regex/v4/match_results.hpp | 12 ++-- .../regex/v4/perl_matcher_non_recursive.hpp | 56 +++++++++---------- .../boost/regex/v4/perl_matcher_recursive.hpp | 4 +- include/boost/regex/v4/w32_regex_traits.hpp | 6 +- 12 files changed, 67 insertions(+), 66 deletions(-) diff --git a/include/boost/regex/concepts.hpp b/include/boost/regex/concepts.hpp index de3e5c9f..ad819215 100644 --- a/include/boost/regex/concepts.hpp +++ b/include/boost/regex/concepts.hpp @@ -509,7 +509,7 @@ struct BaseRegexConcept ignore_unused_variable_warning(ti4); regex_token_iterator_type ti5(m_in, m_in, e, subs, m_mft); ignore_unused_variable_warning(ti5); - static const int i_array[] = { 1, 2, 3, }; + static const int i_array[3] = { 1, 2, 3, }; regex_token_iterator_type ti6(m_in, m_in, e, i_array); ignore_unused_variable_warning(ti6); regex_token_iterator_type ti7(m_in, m_in, e, i_array, m_mft); diff --git a/include/boost/regex/config/allocator.hpp b/include/boost/regex/config/allocator.hpp index 458b6d29..2f3e7db1 100644 --- a/include/boost/regex/config/allocator.hpp +++ b/include/boost/regex/config/allocator.hpp @@ -12,10 +12,10 @@ #ifndef BOOST_DETAIL_ALLOCATOR_HPP #define BOOST_DETAIL_ALLOCATOR_HPP -#include #include #include -#include +#include +#include #if defined(BOOST_NO_STDC_NAMESPACE) namespace std{ using ::ptrdiff_t; @@ -133,11 +133,11 @@ public: void deallocate(pointer p, size_type n) { #ifdef BOOST_HAVE_SGI_ALLOCATOR - assert( (p == 0) == (n == 0) ); + BOOST_ASSERT( (p == 0) == (n == 0) ); if (p != 0) alloc_type::deallocate((void*)p, n); #else - assert( (p == 0) == (n == 0) ); + BOOST_ASSERT( (p == 0) == (n == 0) ); if (p != 0) ::operator delete((void*)p); #endif @@ -204,11 +204,11 @@ public: void deallocate(pointer p, size_type n) { #ifdef BOOST_HAVE_SGI_ALLOCATOR - assert( (p == 0) == (n == 0) ); + BOOST_ASSERT( (p == 0) == (n == 0) ); if (p != 0) alloc_type::deallocate((void*)p, n); #else - assert( (p == 0) == (n == 0) ); + BOOST_ASSERT( (p == 0) == (n == 0) ); if (p != 0) ::operator delete((void*)p); #endif @@ -252,7 +252,7 @@ public: void deallocate(pointer p, size_type n) { - assert( (p == 0) == (n == 0) ); + BOOST_ASSERT( (p == 0) == (n == 0) ); if (p != 0) static_cast(this)->deallocate((void*)p, n * sizeof(value_type)); } diff --git a/include/boost/regex/pending/unicode_iterator.hpp b/include/boost/regex/pending/unicode_iterator.hpp index 11e81001..e39582ad 100644 --- a/include/boost/regex/pending/unicode_iterator.hpp +++ b/include/boost/regex/pending/unicode_iterator.hpp @@ -522,7 +522,7 @@ private: } // we now need to remove a few of the leftmost bits, but how many depends // upon how many extra bytes we've extracted: - static const boost::uint32_t masks[] = + static const boost::uint32_t masks[4] = { 0x7Fu, 0x7FFu, diff --git a/include/boost/regex/v4/basic_regex.hpp b/include/boost/regex/v4/basic_regex.hpp index 013efb59..061a6f8c 100644 --- a/include/boost/regex/v4/basic_regex.hpp +++ b/include/boost/regex/v4/basic_regex.hpp @@ -453,32 +453,32 @@ public: // const re_detail::re_syntax_base* get_first_state()const { - assert(0 != m_pimpl.get()); + BOOST_ASSERT(0 != m_pimpl.get()); return m_pimpl->get_first_state(); } unsigned get_restart_type()const { - assert(0 != m_pimpl.get()); + BOOST_ASSERT(0 != m_pimpl.get()); return m_pimpl->get_restart_type(); } const unsigned char* get_map()const { - assert(0 != m_pimpl.get()); + BOOST_ASSERT(0 != m_pimpl.get()); return m_pimpl->get_map(); } const ::boost::regex_traits_wrapper& get_traits()const { - assert(0 != m_pimpl.get()); + BOOST_ASSERT(0 != m_pimpl.get()); return m_pimpl->get_traits(); } bool can_be_null()const { - assert(0 != m_pimpl.get()); + BOOST_ASSERT(0 != m_pimpl.get()); return m_pimpl->can_be_null(); } const re_detail::regex_data& get_data()const { - assert(0 != m_pimpl.get()); + BOOST_ASSERT(0 != m_pimpl.get()); return m_pimpl->get_data(); } diff --git a/include/boost/regex/v4/basic_regex_creator.hpp b/include/boost/regex/v4/basic_regex_creator.hpp index 17f619d8..c3a7cd1a 100644 --- a/include/boost/regex/v4/basic_regex_creator.hpp +++ b/include/boost/regex/v4/basic_regex_creator.hpp @@ -246,9 +246,9 @@ basic_regex_creator::basic_regex_creator(regex_datam_status = ::boost::regex_constants::error_ok; static const charT w = 'w'; static const charT s = 's'; - static const charT l[] = { 'l', 'o', 'w', 'e', 'r', }; - static const charT u[] = { 'u', 'p', 'p', 'e', 'r', }; - static const charT a[] = { 'a', 'l', 'p', 'h', 'a', }; + static const charT l[5] = { 'l', 'o', 'w', 'e', 'r', }; + static const charT u[5] = { 'u', 'p', 'p', 'e', 'r', }; + static const charT a[5] = { 'a', 'l', 'p', 'h', 'a', }; m_word_mask = m_traits.lookup_classname(&w, &w +1); m_mask_space = m_traits.lookup_classname(&s, &s +1); m_lower_mask = m_traits.lookup_classname(l, l + 5); @@ -538,7 +538,7 @@ re_syntax_base* basic_regex_creator::append_set( } for(unsigned i = 0; i < (1u << CHAR_BIT); ++i) { - charT c3[] = { static_cast(i), charT(0), }; + charT c3[2] = { static_cast(i), charT(0), }; string_type s3 = this->m_traits.transform(c3, c3 +1); if((s1 <= s3) && (s3 <= s2)) result->_map[i] = true; diff --git a/include/boost/regex/v4/basic_regex_parser.hpp b/include/boost/regex/v4/basic_regex_parser.hpp index f6b01bcf..71086070 100644 --- a/include/boost/regex/v4/basic_regex_parser.hpp +++ b/include/boost/regex/v4/basic_regex_parser.hpp @@ -1848,7 +1848,7 @@ bool basic_regex_parser::add_emacs_code(bool negate) if(negate) char_set.negate(); - static const charT s_punct[] = { 'p', 'u', 'n', 'c', 't', }; + static const charT s_punct[5] = { 'p', 'u', 'n', 'c', 't', }; switch(*m_position) { diff --git a/include/boost/regex/v4/cpp_regex_traits.hpp b/include/boost/regex/v4/cpp_regex_traits.hpp index 8c0cb911..cbd699da 100644 --- a/include/boost/regex/v4/cpp_regex_traits.hpp +++ b/include/boost/regex/v4/cpp_regex_traits.hpp @@ -665,7 +665,7 @@ void cpp_regex_traits_implementation::init() // Custom class names: // #ifndef BOOST_REGEX_BUGGY_CTYPE_FACET - static const char_class_type masks[] = + static const char_class_type masks[14] = { std::ctype::alnum, std::ctype::alpha, @@ -683,7 +683,7 @@ void cpp_regex_traits_implementation::init() cpp_regex_traits_implementation::mask_unicode, }; #else - static const char_class_type masks[] = + static const char_class_type masks[14] = { ::boost::re_detail::char_class_alnum, ::boost::re_detail::char_class_alpha, @@ -721,7 +721,7 @@ 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[] = + static const char_class_type masks[20] = { 0, std::ctype::alnum, @@ -745,7 +745,7 @@ typename cpp_regex_traits_implementation::char_class_type std::ctype::xdigit, }; #else - static const char_class_type masks[] = + static const char_class_type masks[20] = { 0, ::boost::re_detail::char_class_alnum, @@ -777,7 +777,7 @@ typename cpp_regex_traits_implementation::char_class_type return pos->second; } std::size_t id = 1 + re_detail::get_default_class_id(p1, p2); - assert(id < sizeof(masks) / sizeof(masks[0])); + BOOST_ASSERT(id < sizeof(masks) / sizeof(masks[0])); return masks[id]; } diff --git a/include/boost/regex/v4/fileiter.hpp b/include/boost/regex/v4/fileiter.hpp index 341ce53b..03aef029 100644 --- a/include/boost/regex/v4/fileiter.hpp +++ b/include/boost/regex/v4/fileiter.hpp @@ -24,6 +24,7 @@ #ifndef BOOST_REGEX_CONFIG_HPP #include #endif +#include #ifndef BOOST_REGEX_NO_FILEITER @@ -239,8 +240,8 @@ public: mapfile_iterator& operator = (const mapfile_iterator& i); char operator* ()const { - assert(node >= file->_first); - assert(node < file->_last); + BOOST_ASSERT(node >= file->_first); + BOOST_ASSERT(node < file->_last); return file ? *(*node + sizeof(int) + offset) : char(0); } char operator[] (long off)const diff --git a/include/boost/regex/v4/match_results.hpp b/include/boost/regex/v4/match_results.hpp index 94202a01..7be53158 100644 --- a/include/boost/regex/v4/match_results.hpp +++ b/include/boost/regex/v4/match_results.hpp @@ -49,11 +49,11 @@ public: typedef typename vector_type::const_iterator const_iterator; typedef const_iterator iterator; typedef typename re_detail::regex_iterator_traits< - BidiIterator>::difference_type difference_type; + BidiIterator>::difference_type difference_type; typedef typename Allocator::size_type size_type; typedef Allocator allocator_type; typedef typename re_detail::regex_iterator_traits< - BidiIterator>::value_type char_type; + BidiIterator>::value_type char_type; typedef std::basic_string string_type; // construct/copy/destroy: @@ -153,7 +153,7 @@ public: string_type format(const string_type& fmt, match_flag_type flags = format_default) const { - return regex_format(*this, fmt, flags); + return ::boost::regex_format(*this, fmt, flags); } // format with locale: template @@ -208,7 +208,7 @@ public: // private access functions: void BOOST_REGEX_CALL set_second(BidiIterator i) { - assert(m_subs.size() > 2); + BOOST_ASSERT(m_subs.size() > 2); m_subs[2].second = i; m_subs[2].matched = true; m_subs[0].first = i; @@ -221,7 +221,7 @@ public: void BOOST_REGEX_CALL set_second(BidiIterator i, size_type pos, bool m = true) { pos += 2; - assert(m_subs.size() > pos); + BOOST_ASSERT(m_subs.size() > pos); m_subs[pos].second = i; m_subs[pos].matched = m; if(pos == 2) @@ -274,7 +274,7 @@ public: } void BOOST_REGEX_CALL set_first(BidiIterator i, size_type pos) { - assert(pos+2 < m_subs.size()); + BOOST_ASSERT(pos+2 < m_subs.size()); if(pos) m_subs[pos+2].first = i; else diff --git a/include/boost/regex/v4/perl_matcher_non_recursive.hpp b/include/boost/regex/v4/perl_matcher_non_recursive.hpp index 663ba6c9..691f2c30 100644 --- a/include/boost/regex/v4/perl_matcher_non_recursive.hpp +++ b/include/boost/regex/v4/perl_matcher_non_recursive.hpp @@ -97,7 +97,7 @@ struct save_state_init *end = reinterpret_cast(reinterpret_cast(*base)+BOOST_REGEX_BLOCKSIZE); --(*end); (void) new (*end)saved_state(0); - assert(*end > *base); + BOOST_ASSERT(*end > *base); } ~save_state_init() { @@ -195,7 +195,7 @@ void perl_matcher::extend_stack() template inline void perl_matcher::push_matched_paren(int index, const sub_match& sub) { - assert(index); + BOOST_ASSERT(index); saved_matched_paren* pmp = static_cast*>(m_backup_state); --pmp; if(pmp < m_stack_base) @@ -388,7 +388,7 @@ bool perl_matcher::match_startmark() } default: { - assert(index > 0); + BOOST_ASSERT(index > 0); if((m_match_flags & match_nosubs) == 0) { push_matched_paren(index, (*m_presult)[index]); @@ -634,7 +634,7 @@ bool perl_matcher::match_char_repeat() #pragma option push -w-8008 -w-8066 -w-8004 #endif const re_repeat* rep = static_cast(pstate); - assert(1 == static_cast(rep->next.p)->length); + BOOST_ASSERT(1 == static_cast(rep->next.p)->length); const char_type what = *reinterpret_cast(static_cast(rep->next.p) + 1); std::size_t count = 0; // @@ -982,15 +982,15 @@ bool perl_matcher::unwind_greedy_single_repeat( const re_repeat* rep = pmp->rep; std::size_t count = pmp->count; - assert(rep->next.p != 0); - assert(rep->alt.p != 0); + BOOST_ASSERT(rep->next.p != 0); + BOOST_ASSERT(rep->alt.p != 0); count -= rep->min; if((m_match_flags & match_partial) && (position == last)) m_has_partial_match = true; - assert(count); + BOOST_ASSERT(count); position = pmp->last_position; // backtrack till we can skip out: @@ -1031,12 +1031,12 @@ bool perl_matcher::unwind_slow_dot_repeat(bool const re_repeat* rep = pmp->rep; std::size_t count = pmp->count; - assert(rep->type == syntax_element_dot_rep); - assert(rep->next.p != 0); - assert(rep->alt.p != 0); - assert(rep->next.p->type == syntax_element_wild); + BOOST_ASSERT(rep->type == syntax_element_dot_rep); + BOOST_ASSERT(rep->next.p != 0); + BOOST_ASSERT(rep->alt.p != 0); + BOOST_ASSERT(rep->next.p->type == syntax_element_wild); - assert(count < rep->max); + BOOST_ASSERT(count < rep->max); pstate = rep->next.p; position = pmp->last_position; @@ -1094,7 +1094,7 @@ bool perl_matcher::unwind_fast_dot_repeat(bool const re_repeat* rep = pmp->rep; std::size_t count = pmp->count; - assert(count < rep->max); + BOOST_ASSERT(count < rep->max); position = pmp->last_position; if(position != last) { @@ -1149,11 +1149,11 @@ bool perl_matcher::unwind_char_repeat(bool r) const char_type what = *reinterpret_cast(static_cast(pstate) + 1); position = pmp->last_position; - assert(rep->type == syntax_element_char_rep); - assert(rep->next.p != 0); - assert(rep->alt.p != 0); - assert(rep->next.p->type == syntax_element_literal); - assert(count < rep->max); + BOOST_ASSERT(rep->type == syntax_element_char_rep); + BOOST_ASSERT(rep->next.p != 0); + BOOST_ASSERT(rep->alt.p != 0); + BOOST_ASSERT(rep->next.p->type == syntax_element_literal); + BOOST_ASSERT(count < rep->max); if(position != last) { @@ -1213,11 +1213,11 @@ bool perl_matcher::unwind_short_set_repeat(bool const unsigned char* map = static_cast(rep->next.p)->_map; position = pmp->last_position; - assert(rep->type == syntax_element_short_set_rep); - assert(rep->next.p != 0); - assert(rep->alt.p != 0); - assert(rep->next.p->type == syntax_element_set); - assert(count < rep->max); + BOOST_ASSERT(rep->type == syntax_element_short_set_rep); + BOOST_ASSERT(rep->next.p != 0); + BOOST_ASSERT(rep->alt.p != 0); + BOOST_ASSERT(rep->next.p->type == syntax_element_set); + BOOST_ASSERT(count < rep->max); if(position != last) { @@ -1278,11 +1278,11 @@ bool perl_matcher::unwind_long_set_repeat(bool const re_set_long* set = static_cast*>(pstate); position = pmp->last_position; - assert(rep->type == syntax_element_long_set_rep); - assert(rep->next.p != 0); - assert(rep->alt.p != 0); - assert(rep->next.p->type == syntax_element_long_set); - assert(count < rep->max); + BOOST_ASSERT(rep->type == syntax_element_long_set_rep); + BOOST_ASSERT(rep->next.p != 0); + BOOST_ASSERT(rep->alt.p != 0); + BOOST_ASSERT(rep->next.p->type == syntax_element_long_set); + BOOST_ASSERT(count < rep->max); if(position != last) { diff --git a/include/boost/regex/v4/perl_matcher_recursive.hpp b/include/boost/regex/v4/perl_matcher_recursive.hpp index d78e9af1..6898cb6d 100644 --- a/include/boost/regex/v4/perl_matcher_recursive.hpp +++ b/include/boost/regex/v4/perl_matcher_recursive.hpp @@ -195,7 +195,7 @@ bool perl_matcher::match_startmark() } default: { - assert(index > 0); + BOOST_ASSERT(index > 0); if((m_match_flags & match_nosubs) == 0) { backup_subex sub(*m_presult, index); @@ -499,7 +499,7 @@ bool perl_matcher::match_char_repeat() #pragma option push -w-8008 -w-8066 -w-8004 #endif const re_repeat* rep = static_cast(pstate); - assert(1 == static_cast(rep->next.p)->length); + BOOST_ASSERT(1 == static_cast(rep->next.p)->length); const char_type what = *reinterpret_cast(static_cast(rep->next.p) + 1); unsigned count = 0; // diff --git a/include/boost/regex/v4/w32_regex_traits.hpp b/include/boost/regex/v4/w32_regex_traits.hpp index 8a3049b7..1a0d1ee0 100644 --- a/include/boost/regex/v4/w32_regex_traits.hpp +++ b/include/boost/regex/v4/w32_regex_traits.hpp @@ -465,7 +465,7 @@ w32_regex_traits_implementation::w32_regex_traits_implementation(::boost: // // Custom class names: // - static const char_class_type masks[] = + static const char_class_type masks[14] = { 0x0104u, // C1_ALPHA | C1_DIGIT 0x0100u, // C1_ALPHA @@ -500,7 +500,7 @@ template typename w32_regex_traits_implementation::char_class_type w32_regex_traits_implementation::lookup_classname_imp(const charT* p1, const charT* p2) const { - static const char_class_type masks[] = + static const char_class_type masks[20] = { 0, 0x0104u, // C1_ALPHA | C1_DIGIT @@ -531,7 +531,7 @@ typename w32_regex_traits_implementation::char_class_type return pos->second; } std::size_t id = 1 + re_detail::get_default_class_id(p1, p2); - assert(id < sizeof(masks) / sizeof(masks[0])); + BOOST_ASSERT(id < sizeof(masks) / sizeof(masks[0])); return masks[id]; }