cvs diff: Diffing boost/regex Index: boost/regex/concepts.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/regex/concepts.hpp,v retrieving revision 1.7 retrieving revision 1.9 diff -u -b -r1.7 -r1.9 --- boost/regex/concepts.hpp 28 Feb 2005 10:54:12 -0000 1.7 +++ boost/regex/concepts.hpp 13 Dec 2005 18:30:53 -0000 1.9 @@ -205,6 +205,8 @@ const traits m_ctraits; const char_type* m_pointer; char_type m_char; +private: + RegexTraitsConcept& operator=(RegexTraitsConcept&); }; // @@ -403,6 +405,8 @@ match_results_type m3(m1); m1 = m2; + int ival = 0; + mr_size_type mrs = m_cresults.size(); ignore_unused_variable_warning(mrs); mrs = m_cresults.max_size(); @@ -411,14 +415,14 @@ ignore_unused_variable_warning(b); mr_difference_type mrd = m_cresults.length(); ignore_unused_variable_warning(mrd); - mrd = m_cresults.length(mrs); + mrd = m_cresults.length(ival); ignore_unused_variable_warning(mrd); mrd = m_cresults.position(); ignore_unused_variable_warning(mrd); mrd = m_cresults.position(mrs); ignore_unused_variable_warning(mrd); - mr_const_reference mrcr = m_cresults[m_size]; + mr_const_reference mrcr = m_cresults[ival]; ignore_unused_variable_warning(mrcr); mr_const_reference mrcr2 = m_cresults.prefix(); ignore_unused_variable_warning(mrcr2); @@ -738,6 +742,7 @@ RegexConcept& operator=(const RegexConcept&); }; +#ifndef BOOST_REGEX_TEST_STD // // BoostRegexConcept: // Test every interface in the Boost implementation: @@ -777,6 +782,8 @@ | global_regex_namespace::regex_constants::format_no_copy | global_regex_namespace::regex_constants::format_first_only; + (void)mopts; + function_requires >(); const global_regex_namespace::regex_error except(global_regex_namespace::regex_constants::error_collate); std::ptrdiff_t pt = except.position(); @@ -850,6 +857,8 @@ BoostRegexConcept& operator=(const BoostRegexConcept&); }; +#endif // BOOST_REGEX_TEST_STD + } #endif Index: boost/regex/icu.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/regex/icu.hpp,v retrieving revision 1.5.2.3 retrieving revision 1.7 diff -u -b -r1.5.2.3 -r1.7 cvs diff: Diffing boost/regex/config cvs diff: Diffing boost/regex/pending Index: boost/regex/pending/object_cache.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/regex/pending/object_cache.hpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -b -r1.6 -r1.7 --- boost/regex/pending/object_cache.hpp 20 Jun 2005 11:48:37 -0000 1.6 +++ boost/regex/pending/object_cache.hpp 30 Nov 2005 13:56:54 -0000 1.7 @@ -83,7 +83,7 @@ boost::shared_ptr object_cache::do_get(const Key& k, size_type max_cache_size) { typedef typename object_cache::data object_data; - typedef typename list_type::size_type list_size_type; + typedef typename map_type::size_type map_size_type; static object_data s_data; // @@ -122,7 +122,7 @@ s_data.cont.push_back(value_type(result, 0)); s_data.index.insert(std::make_pair(k, --(s_data.cont.end()))); s_data.cont.back().second = &(s_data.index.find(k)->first); - list_size_type s = s_data.cont.size(); + map_size_type s = s_data.index.size(); BOOST_ASSERT(s_data.index[k]->first.get() == result.get()); BOOST_ASSERT(&(s_data.index.find(k)->first) == s_data.cont.back().second); BOOST_ASSERT(s_data.index.find(k)->first == k); cvs diff: Diffing boost/regex/v4 Index: boost/regex/v4/basic_regex.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/regex/v4/basic_regex.hpp,v retrieving revision 1.15.2.3 retrieving revision 1.19 diff -u -b -r1.15.2.3 -r1.19 --- boost/regex/v4/basic_regex.hpp 14 Sep 2005 12:20:41 -0000 1.15.2.3 +++ boost/regex/v4/basic_regex.hpp 27 Oct 2005 10:24:50 -0000 1.19 @@ -66,6 +66,7 @@ unsigned char m_startmap[1 << CHAR_BIT]; // which characters can start a match unsigned int m_can_be_null; // whether we can match a null string re_detail::raw_storage m_data; // the buffer in which our states are constructed + typename traits::char_class_type m_word_mask; // mask used to determine if a character is a word character }; // // class basic_regex_implementation Index: boost/regex/v4/basic_regex_creator.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/regex/v4/basic_regex_creator.hpp,v retrieving revision 1.7.2.4 retrieving revision 1.14 diff -u -b -r1.7.2.4 -r1.14 --- boost/regex/v4/basic_regex_creator.hpp 16 Oct 2005 18:12:58 -0000 1.7.2.4 +++ boost/regex/v4/basic_regex_creator.hpp 13 Dec 2005 18:30:53 -0000 1.14 @@ -265,6 +265,7 @@ m_lower_mask = m_traits.lookup_classname(l, l + 5); m_upper_mask = m_traits.lookup_classname(u, u + 5); m_alpha_mask = m_traits.lookup_classname(a, a + 5); + m_pdata->m_word_mask = m_word_mask; BOOST_ASSERT(m_word_mask != 0); BOOST_ASSERT(m_mask_space != 0); BOOST_ASSERT(m_lower_mask != 0); @@ -571,9 +572,10 @@ // Oops error: return 0; } + BOOST_ASSERT(c3[1] == charT(0)); for(unsigned i = 0; i < (1u << CHAR_BIT); ++i) { - charT c3[2] = { static_cast(i), charT(0), }; + c3[0] = static_cast(i); string_type s3 = this->m_traits.transform(c3, c3 +1); if((s1 <= s3) && (s3 <= s2)) result->_map[i] = true; @@ -795,6 +797,7 @@ v.pop_back(); // Build maps: + m_bad_repeats = 0; create_startmap(state->next.p, static_cast(state)->_map, &static_cast(state)->can_be_null, mask_take); m_bad_repeats = 0; create_startmap(static_cast(state)->alt.p, static_cast(state)->_map, &static_cast(state)->can_be_null, mask_skip); @@ -1062,6 +1065,8 @@ if(is_bad_repeat(state)) { set_all_masks(l_map, mask); + if(pnull) + *pnull |= mask; return; } set_bad_repeat(state); @@ -1180,7 +1185,8 @@ unsigned id = static_cast(pt)->id; if(id > sizeof(m_bad_repeats) * CHAR_BIT) return true; // run out of bits, assume we can't traverse this one. - return m_bad_repeats & static_cast(1uL << id); + static const boost::uintmax_t one = 1uL; + return m_bad_repeats & (one << id); } default: return false; @@ -1199,8 +1205,9 @@ case syntax_element_long_set_rep: { unsigned id = static_cast(pt)->id; + static const boost::uintmax_t one = 1uL; if(id <= sizeof(m_bad_repeats) * CHAR_BIT) - m_bad_repeats |= static_cast(1uL << id); + m_bad_repeats |= (one << id); } default: break; Index: boost/regex/v4/basic_regex_parser.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/regex/v4/basic_regex_parser.hpp,v retrieving revision 1.9.2.6 retrieving revision 1.14 diff -u -b -r1.9.2.6 -r1.14 --- boost/regex/v4/basic_regex_parser.hpp 1 Dec 2005 15:00:34 -0000 1.9.2.6 +++ boost/regex/v4/basic_regex_parser.hpp 30 Nov 2005 13:56:54 -0000 1.14 @@ -889,7 +889,7 @@ // if(min > max) { - fail(regex_constants::error_range, this->m_position - this->m_base); + fail(regex_constants::error_badbrace, this->m_position - this->m_base); return false; } return parse_repeat(min, max); Index: boost/regex/v4/match_results.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/regex/v4/match_results.hpp,v retrieving revision 1.21 retrieving revision 1.22 diff -u -b -r1.21 -r1.22 --- boost/regex/v4/match_results.hpp 15 Apr 2005 15:39:25 -0000 1.21 +++ boost/regex/v4/match_results.hpp 13 Dec 2005 18:30:53 -0000 1.22 @@ -88,7 +88,7 @@ return m_subs[sub].length(); return 0; } - difference_type position(unsigned int sub = 0) const + difference_type position(size_type sub = 0) const { sub += 2; if(sub < m_subs.size()) Index: boost/regex/v4/perl_matcher.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/regex/v4/perl_matcher.hpp,v retrieving revision 1.19.2.4 retrieving revision 1.23 diff -u -b -r1.19.2.4 -r1.23 --- boost/regex/v4/perl_matcher.hpp 11 Oct 2005 14:27:56 -0000 1.19.2.4 +++ boost/regex/v4/perl_matcher.hpp 27 Oct 2005 10:24:50 -0000 1.23 @@ -29,7 +29,7 @@ // function can_start: // template -bool can_start(charT c, const unsigned char* map, unsigned char mask) +inline bool can_start(charT c, const unsigned char* map, unsigned char mask) { return ((c < static_cast(0)) ? true : ((c >= static_cast(1 << CHAR_BIT)) ? true : map[c] & mask)); } @@ -327,7 +327,13 @@ match_results& what, const basic_regex& e, match_flag_type f, - BidiIterator base); + BidiIterator base) + : m_result(what), base(first), last(end), + position(first), backstop(base), re(e), traits_inst(e.get_traits()), + m_independent(false), next_count(&rep_obj), rep_obj(&next_count) + { + construct_init(e, f); + } bool match(); bool find(); @@ -339,6 +345,7 @@ private: void construct_init(const basic_regex& e, match_flag_type f); + bool find_imp(); bool match_imp(); #ifdef BOOST_REGEX_HAS_MS_STACK_GUARD Index: boost/regex/v4/perl_matcher_common.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/regex/v4/perl_matcher_common.hpp,v retrieving revision 1.26.2.4 retrieving revision 1.30 diff -u -b -r1.26.2.4 -r1.30 --- boost/regex/v4/perl_matcher_common.hpp 1 Nov 2005 17:36:42 -0000 1.26.2.4 +++ boost/regex/v4/perl_matcher_common.hpp 1 Nov 2005 18:06:19 -0000 1.30 @@ -32,22 +32,10 @@ namespace re_detail{ template -perl_matcher::perl_matcher(BidiIterator first, BidiIterator end, - match_results& what, - const basic_regex& e, - match_flag_type f, - BidiIterator b) - : m_result(what), base(first), last(end), - position(first), backstop(b), re(e), traits_inst(e.get_traits()), - m_independent(false), next_count(&rep_obj), rep_obj(&next_count) -{ - construct_init(e, f); -} - -template void perl_matcher::construct_init(const basic_regex& e, match_flag_type f) { typedef typename regex_iterator_traits::iterator_category category; + typedef typename basic_regex::flag_type expression_flag_type; if(e.empty()) { @@ -57,13 +45,14 @@ } pstate = 0; m_match_flags = f; - icase = re.flags() & regex_constants::icase; estimate_max_state_count(static_cast(0)); + expression_flag_type re_f = re.flags(); + icase = re_f & regex_constants::icase; if(!(m_match_flags & (match_perl|match_posix))) { - if((re.flags() & (regbase::main_option_type|regbase::no_perl_ex)) == 0) + if((re_f & (regbase::main_option_type|regbase::no_perl_ex)) == 0) m_match_flags |= match_perl; - else if((re.flags() & (regbase::main_option_type|regbase::emacs_ex)) == (regbase::basic_syntax_group|regbase::emacs_ex)) + else if((re_f & (regbase::main_option_type|regbase::emacs_ex)) == (regbase::basic_syntax_group|regbase::emacs_ex)) m_match_flags |= match_perl; else m_match_flags |= match_posix; @@ -80,8 +69,7 @@ m_backup_state = 0; #endif // find the value to use for matching word boundaries: - const char_type w = static_cast('w'); - m_word_mask = traits_inst.lookup_classname(&w, &w+1); + m_word_mask = re.get_data().m_word_mask; // find bitmask to use for matching '.': match_any_mask = static_cast((f & match_not_dot_newline) ? re_detail::test_not_newline : re_detail::test_newline); } @@ -101,7 +89,7 @@ } template -void perl_matcher::estimate_max_state_count(void*) +inline void perl_matcher::estimate_max_state_count(void*) { // we don't know how long the sequence is: max_state_count = BOOST_REGEX_MAX_STATE_COUNT; @@ -109,21 +97,9 @@ #ifdef BOOST_REGEX_HAS_MS_STACK_GUARD template -bool perl_matcher::protected_call( +inline bool perl_matcher::protected_call( protected_proc_type proc) { - /* - __try{ - return (this->*proc)(); - }__except(EXCEPTION_STACK_OVERFLOW == GetExceptionCode()) - { - reset_stack_guard_page(); - } - // we only get here after a stack overflow: - raise_error(traits_inst, regex_constants::error_size); - // and we never really get here at all: - return false; - */ ::boost::re_detail::concrete_protected_call > obj(this, proc); @@ -133,7 +109,7 @@ #endif template -bool perl_matcher::match() +inline bool perl_matcher::match() { #ifdef BOOST_REGEX_HAS_MS_STACK_GUARD return protected_call(&perl_matcher::match_imp); @@ -182,7 +158,7 @@ } template -bool perl_matcher::find() +inline bool perl_matcher::find() { #ifdef BOOST_REGEX_HAS_MS_STACK_GUARD return protected_call(&perl_matcher::find_imp); Index: boost/regex/v4/perl_matcher_recursive.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/regex/v4/perl_matcher_recursive.hpp,v retrieving revision 1.18.2.1 retrieving revision 1.21 diff -u -b -r1.18.2.1 -r1.21 --- boost/regex/v4/perl_matcher_recursive.hpp 11 Oct 2005 14:27:56 -0000 1.18.2.1 +++ boost/regex/v4/perl_matcher_recursive.hpp 11 Dec 2005 17:33:38 -0000 1.21 @@ -494,6 +494,7 @@ #ifdef BOOST_MSVC #pragma warning(push) #pragma warning(disable:4127) +#pragma warning(disable:4267) #endif #ifdef __BORLANDC__ #pragma option push -w-8008 -w-8066 -w-8004 @@ -501,25 +502,39 @@ const re_repeat* rep = static_cast(pstate); BOOST_ASSERT(1 == static_cast(rep->next.p)->length); const char_type what = *reinterpret_cast(static_cast(rep->next.p) + 1); - unsigned count = 0; // // start by working out how much we can skip: // bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); - std::size_t desired = greedy ? rep->max : rep->min; + std::size_t count, desired; if(::boost::is_random_access_iterator::value) { - BidiIterator end = position; - std::advance(end, (std::min)((std::size_t)::boost::re_detail::distance(position, last), desired)); - BidiIterator origin(position); - while((position != end) && (traits_inst.translate(*position, icase) == what)) + desired = + (std::min)( + (std::size_t)(greedy ? rep->max : rep->min), + (std::size_t)::boost::re_detail::distance(position, last)); + count = desired; + ++desired; + if(icase) + { + while(--desired && (traits_inst.translate_nocase(*position) == what)) { ++position; } - count = (unsigned)::boost::re_detail::distance(origin, position); } else { + while(--desired && (traits_inst.translate(*position) == what)) + { + ++position; + } + } + count = count - desired; + } + else + { + count = 0; + desired = greedy ? rep->max : rep->min; while((count < desired) && (position != last) && (traits_inst.translate(*position, icase) == what)) { ++position; Index: boost/regex/v4/regex_replace.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/regex/v4/regex_replace.hpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -b -r1.10 -r1.11 --- boost/regex/v4/regex_replace.hpp 30 Mar 2005 11:38:17 -0000 1.10 +++ boost/regex/v4/regex_replace.hpp 13 Dec 2005 18:30:53 -0000 1.11 @@ -45,7 +45,7 @@ } else { - BidirectionalIterator last_m = first; + BidirectionalIterator last_m(first); while(i != j) { if(!(flags & regex_constants::format_no_copy)) Index: boost/regex/v4/regex_traits_defaults.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/regex/v4/regex_traits_defaults.hpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -b -r1.9 -r1.10 --- boost/regex/v4/regex_traits_defaults.hpp 18 May 2005 11:44:12 -0000 1.9 +++ boost/regex/v4/regex_traits_defaults.hpp 11 Dec 2005 17:33:38 -0000 1.10 @@ -142,7 +142,11 @@ } bool operator == (const character_pointer_range& r)const { - return ((p2 - p1) == (r.p2 - r.p1)) && std::equal(p1, p2, r.p1); + // Not only do we check that the ranges are of equal size before + // calling std::equal, but there is no other algorithm available: + // not even a non-standard MS one. So forward to unchecked_equal + // in the MS case. + return ((p2 - p1) == (r.p2 - r.p1)) && re_detail::equal(p1, p2, r.p1); } }; template Index: boost/regex/v4/regex_workaround.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/regex/v4/regex_workaround.hpp,v retrieving revision 1.5.2.1 retrieving revision 1.7 diff -u -b -r1.5.2.1 -r1.7 --- boost/regex/v4/regex_workaround.hpp 27 Aug 2005 10:24:31 -0000 1.5.2.1 +++ boost/regex/v4/regex_workaround.hpp 11 Dec 2005 17:33:38 -0000 1.7 @@ -128,7 +128,7 @@ #ifdef __cplusplus namespace boost{ namespace re_detail{ -#if BOOST_WORKAROUND(BOOST_MSVC,>=1400) +#if BOOST_WORKAROUND(BOOST_MSVC,>=1400) && defined(_CPPLIB_VER) && !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) // // MSVC 8 will either emit warnings or else refuse to compile // code that makes perfectly legitimate use of std::copy, when @@ -144,12 +144,22 @@ { return stdext::unchecked_copy(first, last, dest); } + template + inline bool equal( + InputIterator1 first, + InputIterator1 last, + InputIterator2 with + ) + { + return stdext::unchecked_equal(first, last, with); + } // use safe versions of strcpy etc: using ::strcpy_s; using ::strcat_s; #else using std::copy; + using std::equal; inline std::size_t strcpy_s( char *strDestination, Index: boost/regex/v4/w32_regex_traits.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/regex/v4/w32_regex_traits.hpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -b -r1.8 -r1.9 --- boost/regex/v4/w32_regex_traits.hpp 12 Jul 2005 09:49:11 -0000 1.8 +++ boost/regex/v4/w32_regex_traits.hpp 13 Dec 2005 17:24:28 -0000 1.9 @@ -533,8 +533,9 @@ return pos->second; } std::size_t id = 1 + re_detail::get_default_class_id(p1, p2); - BOOST_ASSERT(id < sizeof(masks) / sizeof(masks[0])); + if(id < sizeof(masks) / sizeof(masks[0])) return masks[id]; + return masks[0]; } Index: libs/regex/performance/command_line.cpp =================================================================== RCS file: /cvsroot/boost/boost/libs/regex/performance/command_line.cpp,v retrieving revision 1.7 retrieving revision 1.9 diff -u -b -r1.7 -r1.9 --- libs/regex/performance/command_line.cpp 21 Jan 2005 17:26:03 -0000 1.7 +++ libs/regex/performance/command_line.cpp 18 Sep 2005 16:31:56 -0000 1.9 @@ -54,12 +54,14 @@ double locale_boost_total = 0; double posix_total = 0; double pcre_total = 0; +double xpressive_total = 0; unsigned greta_test_count = 0; unsigned safe_greta_test_count = 0; unsigned boost_test_count = 0; unsigned locale_boost_test_count = 0; unsigned posix_test_count = 0; unsigned pcre_test_count = 0; +unsigned xpressive_test_count = 0; int handle_argument(const std::string& what) { @@ -82,7 +84,7 @@ time_pcre = true; #endif #ifdef BOOST_HAS_XPRESSIVE - else if(what == "-xpressive") + else if(what == "-xpressive" || what == "-dxpr") time_xpressive = true; #endif else if(what == "-all") @@ -159,6 +161,9 @@ #ifdef BOOST_HAS_PCRE " -pcre Apply tests to PCRE library\n" #endif +#ifdef BOOST_HAS_XPRESSIVE + " -dxpr Apply tests to dynamic xpressive library\n" +#endif " -all Apply tests to all libraries\n\n" " test options:\n" " -test-matches Test short matches\n" @@ -262,6 +267,10 @@ if(time_pcre == true) os << "PCRE"; #endif +#ifdef BOOST_HAS_XPRESSIVE + if(time_xpressive == true) + os << "Dynamic Xpressive"; +#endif os << "\n"; // @@ -305,6 +314,7 @@ ++boost_test_count; } } +#endif if(time_localised_boost == true) { print_result(os, first->localised_boost_time, first->factor); @@ -314,7 +324,6 @@ ++locale_boost_test_count; } } -#endif if(time_posix == true) { print_result(os, first->posix_time, first->factor); @@ -335,6 +344,17 @@ } } #endif +#if defined(BOOST_HAS_XPRESSIVE) + if(time_xpressive == true) + { + print_result(os, first->xpressive_time, first->factor); + if(first->xpressive_time > 0) + { + xpressive_total += first->xpressive_time / first->factor; + ++xpressive_test_count; + } + } +#endif os << "\n"; ++first; } @@ -401,6 +421,12 @@ os << "PCRE"; } #endif +#ifdef BOOST_HAS_XPRESSIVE + if(time_xpressive == true) + { + os << "Dynamic Xpressive"; + } +#endif os << "\n"; // @@ -416,15 +442,19 @@ #if defined(BOOST_HAS_POSIX) if(time_boost == true) os << "" << (boost_total / boost_test_count) << "\n"; +#endif if(time_localised_boost == true) os << "" << (locale_boost_total / locale_boost_test_count) << "\n"; -#endif if(time_posix == true) os << "" << (posix_total / posix_test_count) << "\n"; #if defined(BOOST_HAS_PCRE) if(time_pcre == true) os << "" << (pcre_total / pcre_test_count) << "\n"; #endif +#if defined(BOOST_HAS_XPRESSIVE) + if(time_xpressive == true) + os << "" << (xpressive_total / xpressive_test_count) << "\n"; +#endif os << "\n"; os << "\n"; return os.str(); Index: libs/regex/performance/time_boost.cpp =================================================================== RCS file: /cvsroot/boost/boost/libs/regex/performance/time_boost.cpp,v retrieving revision 1.9 retrieving revision 1.11 diff -u -b -r1.9 -r1.11 --- libs/regex/performance/time_boost.cpp 9 Feb 2005 12:33:17 -0000 1.9 +++ libs/regex/performance/time_boost.cpp 18 Sep 2005 16:31:56 -0000 1.11 @@ -10,6 +10,7 @@ */ #include "regex_comparison.hpp" +#include #include #include @@ -17,6 +18,7 @@ double time_match(const std::string& re, const std::string& text, bool icase) { + try{ boost::regex e(re, (icase ? boost::regex::perl | boost::regex::icase : boost::regex::perl)); boost::smatch what; boost::timer tim; @@ -48,13 +50,27 @@ result = (std::min)(run, result); } return result / iter; + } + catch(const std::exception& e) + { + std::cout << "Exception: " << e.what() << std::endl; + return -1; + } } bool dummy_grep_proc(const boost::smatch&) { return true; } +struct noop +{ + void operator()( boost::smatch const & ) const + { + } +}; + double time_find_all(const std::string& re, const std::string& text, bool icase) { + try{ boost::regex e(re, (icase ? boost::regex::perl | boost::regex::icase : boost::regex::perl)); boost::smatch what; boost::timer tim; @@ -67,7 +83,9 @@ tim.restart(); for(counter = 0; counter < iter; ++counter) { - boost::regex_grep(&dummy_grep_proc, text, e); + boost::sregex_iterator begin( text.begin(), text.end(), e ), end; + std::for_each( begin, end, noop() ); + //boost::regex_grep(&dummy_grep_proc, text, e); } result = tim.elapsed(); iter *= 2; @@ -89,6 +107,12 @@ result = (std::min)(run, result); } return result / iter; + } + catch(const std::exception& e) + { + std::cout << "Exception: " << e.what() << std::endl; + return -1; + } } } Index: libs/regex/performance/time_dynamic_xpressive.cpp =================================================================== RCS file: /cvsroot/boost/boost/libs/regex/performance/time_dynamic_xpressive.cpp,v retrieving revision 1.4 retrieving revision 1.6 diff -u -b -r1.4 -r1.6 --- libs/regex/performance/time_dynamic_xpressive.cpp 11 May 2005 14:31:10 -0000 1.4 +++ libs/regex/performance/time_dynamic_xpressive.cpp 18 Sep 2005 16:31:56 -0000 1.6 @@ -13,6 +13,7 @@ #ifdef BOOST_HAS_XPRESSIVE #include +#include #include #include @@ -21,10 +22,11 @@ double time_match(const std::string& re, const std::string& text, bool icase) { - boost::xpressive::sregex e; - e = (icase ? - boost::xpressive::sregex(boost::xpressive::sregex::compile(re)) - : boost::xpressive::sregex(boost::xpressive::sregex::compile(re, boost::xpressive::regex_constants::icase))); + try{ + boost::xpressive::regex_constants::syntax_option_type flags = boost::xpressive::regex_constants::optimize; + if(icase) + flags = flags | boost::xpressive::regex_constants::icase; + boost::xpressive::sregex e(boost::xpressive::sregex::compile(re, flags)); boost::xpressive::smatch what; boost::timer tim; int iter = 1; @@ -56,6 +58,12 @@ result = (std::min)(run, result); } return result / iter; + } + catch(const std::exception& e) + { + std::cout << "Exception: " << e.what() << std::endl; + return -1; + } } struct noop @@ -67,10 +75,11 @@ double time_find_all(const std::string& re, const std::string& text, bool icase) { - boost::xpressive::sregex e; - e = (icase ? - boost::xpressive::sregex(boost::xpressive::sregex::compile(re)) - : boost::xpressive::sregex(boost::xpressive::sregex::compile(re, boost::xpressive::regex_constants::icase))); + try{ + boost::xpressive::regex_constants::syntax_option_type flags = boost::xpressive::regex_constants::optimize; + if(icase) + flags = flags | boost::xpressive::regex_constants::icase; + boost::xpressive::sregex e(boost::xpressive::sregex::compile(re, flags)); boost::xpressive::smatch what; boost::timer tim; int iter = 1; @@ -106,6 +115,12 @@ result = (std::min)(run, result); } return result / iter; + } + catch(const std::exception& e) + { + std::cout << "Exception: " << e.what() << std::endl; + return -1; + } } } Index: libs/regex/performance/time_localised_boost.cpp =================================================================== RCS file: /cvsroot/boost/boost/libs/regex/performance/time_localised_boost.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -b -r1.10 -r1.11 --- libs/regex/performance/time_localised_boost.cpp 9 Feb 2005 12:33:18 -0000 1.10 +++ libs/regex/performance/time_localised_boost.cpp 18 Sep 2005 09:25:14 -0000 1.11 @@ -53,6 +53,13 @@ bool dummy_grep_proc(const boost::smatch&) { return true; } +struct noop +{ + void operator()( boost::smatch const & ) const + { + } +}; + double time_find_all(const std::string& re, const std::string& text, bool icase) { boost::basic_regex > e(re, (icase ? boost::regex::perl | boost::regex::icase : boost::regex::perl)); @@ -67,7 +74,12 @@ tim.restart(); for(counter = 0; counter < iter; ++counter) { - boost::regex_grep(&dummy_grep_proc, text, e); + boost::regex_iterator< + std::string::const_iterator, + char, + boost::cpp_regex_traits > begin( text.begin(), text.end(), e ), end; + std::for_each( begin, end, noop() ); + //boost::regex_grep(&dummy_grep_proc, text, e); } result = tim.elapsed(); iter *= 2; cvs diff: Diffing libs/regex/src Index: libs/regex/src/cregex.cpp =================================================================== RCS file: /cvsroot/boost/boost/libs/regex/src/cregex.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -u -b -r1.33 -r1.34 --- libs/regex/src/cregex.cpp 30 Mar 2005 11:38:32 -0000 1.33 +++ libs/regex/src/cregex.cpp 24 Nov 2005 16:37:05 -0000 1.34 @@ -24,13 +24,8 @@ #if !defined(BOOST_NO_STD_STRING) #include #include -#ifdef BOOST_REGEX_V3 -#include -typedef unsigned match_flag_type; -#else #include typedef boost::match_flag_type match_flag_type; -#endif #include namespace boost{ @@ -584,7 +579,7 @@ // namespace std{ template<> template<> -basic_string& +basic_string& BOOST_REGEX_DECL basic_string::replace(char* f1, char* f2, const char* i1, const char* i2) { unsigned insert_pos = f1 - begin(); @@ -605,7 +600,29 @@ } return *this; } +template<> template<> +basic_string& BOOST_REGEX_DECL +basic_string::replace(wchar_t* f1, wchar_t* f2, const wchar_t* i1, const wchar_t* i2) +{ + unsigned insert_pos = f1 - begin(); + unsigned remove_len = f2 - f1; + unsigned insert_len = i2 - i1; + unsigned org_size = size(); + if(insert_len > remove_len) + { + append(insert_len-remove_len, ' '); + std::copy_backward(begin() + insert_pos + remove_len, begin() + org_size, end()); + std::copy(i1, i2, begin() + insert_pos); + } + else + { + std::copy(begin() + insert_pos + remove_len, begin() + org_size, begin() + insert_pos + insert_len); + std::copy(i1, i2, begin() + insert_pos); + erase(size() + insert_len - remove_len); + } + return *this; } +} // namespace std #endif #endif Index: libs/regex/src/posix_api.cpp =================================================================== RCS file: /cvsroot/boost/boost/libs/regex/src/posix_api.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -u -b -r1.22 -r1.23 --- libs/regex/src/posix_api.cpp 30 Mar 2005 11:38:32 -0000 1.22 +++ libs/regex/src/posix_api.cpp 11 Dec 2005 17:34:32 -0000 1.23 @@ -37,10 +37,29 @@ unsigned int magic_value = 25631; -const char* names[] = {"REG_NOERROR", "REG_NOMATCH", "REG_BADPAT", "REG_ECOLLATE", - "REG_ECTYPE", "REG_EESCAPE", "REG_ESUBREG", "REG_EBRACK", - "REG_EPAREN", "REG_EBRACE", "REG_BADBR", "REG_ERANGE", - "REG_ESPACE", "REG_BADRPT", "REG_EMPTY", "REG_E_UNKNOWN"}; +const char* names[] = { + "REG_NOERROR", + "REG_NOMATCH", + "REG_BADPAT", + "REG_ECOLLATE", + "REG_ECTYPE", + "REG_EESCAPE", + "REG_ESUBREG", + "REG_EBRACK", + "REG_EPAREN", + "REG_EBRACE", + "REG_BADBR", + "REG_ERANGE", + "REG_ESPACE", + "REG_BADRPT", + "REG_EEND", + "REG_ESIZE", + "REG_ERPAREN", + "REG_EMPTY", + "REG_ECOMPLEXITY", + "REG_ESTACK", + "REG_E_UNKNOWN", +}; } // namespace BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char* ptr, int f) Index: libs/regex/src/wide_posix_api.cpp =================================================================== RCS file: /cvsroot/boost/boost/libs/regex/src/wide_posix_api.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -u -b -r1.26 -r1.27 --- libs/regex/src/wide_posix_api.cpp 30 Mar 2005 11:38:51 -0000 1.26 +++ libs/regex/src/wide_posix_api.cpp 11 Dec 2005 17:34:32 -0000 1.27 @@ -44,11 +44,29 @@ unsigned int wmagic_value = 28631; -const wchar_t* wnames[] = {L"REG_NOERROR", L"REG_NOMATCH", L"REG_BADPAT", L"REG_ECOLLATE", - L"REG_ECTYPE", L"REG_EESCAPE", L"REG_ESUBREG", L"REG_EBRACK", - L"REG_EPAREN", L"REG_EBRACE", L"REG_BADBR", L"REG_ERANGE", - L"REG_ESPACE", L"REG_BADRPT", L"REG_EMPTY", L"REG_E_UNKNOWN"}; - +const wchar_t* wnames[] = { + L"REG_NOERROR", + L"REG_NOMATCH", + L"REG_BADPAT", + L"REG_ECOLLATE", + L"REG_ECTYPE", + L"REG_EESCAPE", + L"REG_ESUBREG", + L"REG_EBRACK", + L"REG_EPAREN", + L"REG_EBRACE", + L"REG_BADBR", + L"REG_ERANGE", + L"REG_ESPACE", + L"REG_BADRPT", + L"REG_EEND", + L"REG_ESIZE", + L"REG_ERPAREN", + L"REG_EMPTY", + L"REG_ECOMPLEXITY", + L"REG_ESTACK", + L"REG_E_UNKNOWN", +}; } BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wchar_t* ptr, int f) cvs diff: Diffing libs/regex/test cvs diff: Diffing libs/regex/test/auto-link-test cvs diff: Diffing libs/regex/test/c_compiler_checks cvs diff: Diffing libs/regex/test/captures cvs diff: Diffing libs/regex/test/collate_info Index: libs/regex/test/collate_info/collate_info.cpp =================================================================== RCS file: /cvsroot/boost/boost/libs/regex/test/collate_info/collate_info.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -b -r1.9 -r1.10 --- libs/regex/test/collate_info/collate_info.cpp 20 May 2005 15:35:43 -0000 1.9 +++ libs/regex/test/collate_info/collate_info.cpp 24 Nov 2005 16:37:05 -0000 1.10 @@ -223,12 +223,14 @@ print_cpp_info(wchar_t(0), "wchar_t"); #endif +#if !BOOST_WORKAROUND(__BORLANDC__, < 0x560) boost::c_regex_traits a; print_sort_syntax(a, "boost::c_regex_traits"); #ifndef BOOST_NO_WREGEX boost::c_regex_traits b; print_sort_syntax(b, "boost::c_regex_traits"); #endif +#endif #ifndef BOOST_NO_STD_LOCALE boost::cpp_regex_traits c; print_sort_syntax(c, "boost::cpp_regex_traits"); cvs diff: Diffing libs/regex/test/concepts cvs diff: Diffing libs/regex/test/config_info cvs diff: Diffing libs/regex/test/object_cache cvs diff: Diffing libs/regex/test/pathology cvs diff: Diffing libs/regex/test/profile cvs diff: Diffing libs/regex/test/regress Index: libs/regex/test/regress/test_deprecated.cpp =================================================================== RCS file: /cvsroot/boost/boost/libs/regex/test/regress/test_deprecated.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -b -r1.3 -r1.4 --- libs/regex/test/regress/test_deprecated.cpp 21 Jan 2005 17:26:27 -0000 1.3 +++ libs/regex/test/regress/test_deprecated.cpp 11 Dec 2005 17:34:32 -0000 1.4 @@ -23,6 +23,13 @@ #pragma warning(disable:4267) #endif +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std{ + using ::atoi; + using ::wcstol; +} +#endif + int get_posix_compile_options(boost::regex_constants::syntax_option_type opts) { using namespace boost; @@ -93,12 +100,15 @@ return; } // try and find the first occurance: - boost::regmatch_t matches[50]; - if(boost::regexecA(&re, search_text.c_str(), 50, matches, posix_match_options) == 0) + 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) { int i = 0; while(results[2*i] != -2) { + if(max_subs > i) + { if(results[2*i] != matches[i].rm_so) { BOOST_REGEX_TEST_ERROR("Mismatch in start of subexpression " << i << " found with the POSIX C API.", char); @@ -107,6 +117,7 @@ { BOOST_REGEX_TEST_ERROR("Mismatch in end of subexpression " << i << " found with the POSIX C API.", char); } + } ++i; } } @@ -213,12 +224,15 @@ return; } // try and find the first occurance: - boost::regmatch_t matches[50]; - if(boost::regexecW(&re, search_text.c_str(), 50, matches, posix_match_options) == 0) + 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) { int i = 0; while(results[2*i] != -2) { + if(max_subs > i) + { if(results[2*i] != matches[i].rm_so) { BOOST_REGEX_TEST_ERROR("Mismatch in start of subexpression " << i << " found with the POSIX C API.", wchar_t); @@ -227,6 +241,7 @@ { BOOST_REGEX_TEST_ERROR("Mismatch in end of subexpression " << i << " found with the POSIX C API.", wchar_t); } + } ++i; } } @@ -253,11 +268,34 @@ // OK try and compile the expression: boost::regex_tA re; - if(boost::regcompA(&re, expression.c_str(), posix_options) == 0) + int code = boost::regcompA(&re, expression.c_str(), posix_options); + if(code == 0) { boost::regfreeA(&re); BOOST_REGEX_TEST_ERROR("Expression : \"" << expression.c_str() << "\" unexpectedly compiled with the POSIX C API.", char); } + else + { + char buf[100]; + int s = boost::regerrorA(code, &re, 0, 0); + if(s < 100) + s = boost::regerrorA(code, &re, buf, 100); + s = boost::regerrorA(code | boost::REG_ITOA, &re, 0, 0); + if(s < 100) + { + s = boost::regerrorA(code | boost::REG_ITOA, &re, buf, 100); + re.re_endp = buf; + s = boost::regerrorA(code | boost::REG_ATOI, &re, buf, 100); + if(s) + { + int code2 = std::atoi(buf); + if(code2 != code) + { + BOOST_REGEX_TEST_ERROR("Got a bad error code from regerrA with REG_ATOI set: ", char); + } + } + } + } // // now try the RegEx class: // @@ -307,10 +345,33 @@ // OK try and compile the expression: boost::regex_tW re; - if(boost::regcompW(&re, expression.c_str(), posix_options) == 0) + int code = boost::regcompW(&re, expression.c_str(), posix_options); + if(code == 0) { boost::regfreeW(&re); BOOST_REGEX_TEST_ERROR("Expression : \"" << expression.c_str() << "\" unexpectedly compiled with the POSIX C API.", wchar_t); } + else + { + wchar_t buf[100]; + int s = boost::regerrorW(code, &re, 0, 0); + if(s < 100) + s = boost::regerrorW(code, &re, buf, 100); + s = boost::regerrorW(code | boost::REG_ITOA, &re, 0, 0); + if(s < 100) + { + s = boost::regerrorW(code | boost::REG_ITOA, &re, buf, 100); + re.re_endp = buf; + s = boost::regerrorW(code | boost::REG_ATOI, &re, buf, 100); + if(s) + { + long code2 = std::wcstol(buf, 0, 10); + if(code2 != code) + { + BOOST_REGEX_TEST_ERROR("Got a bad error code from regerrW with REG_ATOI set: ", char); + } + } + } + } #endif } Index: libs/regex/test/regress/test_locale.cpp =================================================================== RCS file: /cvsroot/boost/boost/libs/regex/test/regress/test_locale.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -b -r1.7 -r1.8 --- libs/regex/test/regress/test_locale.cpp 17 May 2005 10:31:53 -0000 1.7 +++ libs/regex/test/regress/test_locale.cpp 25 Aug 2005 16:27:27 -0000 1.8 @@ -156,7 +156,7 @@ // VC6 seems to have problems with std::setlocale, I've never // gotten to the bottem of this as the program runs fine under the // debugger, but hangs when run from bjam: -#if !BOOST_WORKAROUND(BOOST_MSVC, <=1200) && !(defined(__ICL) && defined(_MSC_VER) && (_MSC_VER == 1200)) +#if !BOOST_WORKAROUND(BOOST_MSVC, <1300) && !(defined(__ICL) && defined(_MSC_VER) && (_MSC_VER == 1200)) test_en_locale("en_US", 0x09 | 0x01 << 10); test_en_locale("en_UK", 0x09 | 0x02 << 10); test_en_locale("en", 0x09); Index: libs/regex/test/regress/test_tricky_cases.cpp =================================================================== RCS file: /cvsroot/boost/boost/libs/regex/test/regress/test_tricky_cases.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -b -r1.6 -r1.7 --- libs/regex/test/regress/test_tricky_cases.cpp 12 Jul 2005 10:08:10 -0000 1.6 +++ libs/regex/test/regress/test_tricky_cases.cpp 11 Dec 2005 17:34:32 -0000 1.7 @@ -75,6 +75,30 @@ TEST_REGEX_SEARCH("a(bbb+|bb+|b)bb", perl, "abbb", match_default, make_array(0, 4, 1, 2, -2, -2)); TEST_REGEX_SEARCH("(.*).*", perl, "abcdef", match_default, make_array(0, 6, 0, 6, -2, 6, 6, 6, 6, -2, -2)); TEST_REGEX_SEARCH("(a*)*", perl, "bc", match_default, make_array(0, 0, 0, 0, -2, 1, 1, 1, 1, -2, 2, 2, 2, 2, -2, -2)); + TEST_REGEX_SEARCH("Z(((((((a+)+)+)+)+)+)+)+|Y(((((((a+)+)+)+)+)+)+)+|X(((((((a+)+)+)+)+)+)+)+|W(((((((a+)+)+)+)+)+)+)+|V(((((((a+)+)+)+)+)+)+)+|CZ(((((((a+)+)+)+)+)+)+)+|CY(((((((a+)+)+)+)+)+)+)+|CX(((((((a+)+)+)+)+)+)+)+|CW(((((((a+)+)+)+)+)+)+)+|CV(((((((a+)+)+)+)+)+)+)+|(a+)+", perl, "bc", match_default, make_array(-2, -2)); + TEST_REGEX_SEARCH("Z(((((((a+)+)+)+)+)+)+)+|Y(((((((a+)+)+)+)+)+)+)+|X(((((((a+)+)+)+)+)+)+)+|W(((((((a+)+)+)+)+)+)+)+|V(((((((a+)+)+)+)+)+)+)+|CZ(((((((a+)+)+)+)+)+)+)+|CY(((((((a+)+)+)+)+)+)+)+|CX(((((((a+)+)+)+)+)+)+)+|CW(((((((a+)+)+)+)+)+)+)+|CV(((((((a+)+)+)+)+)+)+)+|(a+)+", perl, "aaa", match_default, + make_array(0, 3, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 3, + -2, -2)); + TEST_REGEX_SEARCH("Z(((((((a+)+)+)+)+)+)+)+|Y(((((((a+)+)+)+)+)+)+)+|X(((((((a+)+)+)+)+)+)+)+|W(((((((a+)+)+)+)+)+)+)+|V(((((((a+)+)+)+)+)+)+)+|CZ(((((((a+)+)+)+)+)+)+)+|CY(((((((a+)+)+)+)+)+)+)+|CX(((((((a+)+)+)+)+)+)+)+|CW(((((((a+)+)+)+)+)+)+)+|CV(((((((a+)+)+)+)+)+)+)+|(a+)+", + perl, "Zaaa", match_default, + make_array(0, 4, + 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, + -2, -2)); TEST_REGEX_SEARCH("xyx*xz", perl, "xyxxxxyxxxz", match_default, make_array(5, 11, -2, -2)); // do we get the right subexpression when it is used more than once? TEST_REGEX_SEARCH("a(b|c)*d", perl, "ad", match_default, make_array(0, 2, -1, -1, -2, -2)); cvs diff: Diffing libs/regex/test/static_mutex cvs diff: Diffing libs/regex/test/unicode cvs diff: Diffing libs/regex/tools cvs diff: Diffing libs/regex/tools/generate