Index: boost/regex/v4/basic_regex_creator.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/regex/v4/basic_regex_creator.hpp,v retrieving revision 1.11 diff -u -r1.11 basic_regex_creator.hpp --- boost/regex/v4/basic_regex_creator.hpp 27 Oct 2005 10:24:50 -0000 1.11 +++ boost/regex/v4/basic_regex_creator.hpp 11 Dec 2005 10:43:37 -0000 @@ -572,9 +572,10 @@ // Oops error: return 0; } + BOOST_ASSERT(c3[1] == 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; @@ -796,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); @@ -1181,7 +1183,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; @@ -1200,8 +1203,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/regex_traits_defaults.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/regex/v4/regex_traits_defaults.hpp,v retrieving revision 1.9 diff -u -r1.9 regex_traits_defaults.hpp --- 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 10:43:39 -0000 @@ -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.6 diff -u -r1.6 regex_workaround.hpp --- boost/regex/v4/regex_workaround.hpp 27 Aug 2005 10:25:15 -0000 1.6 +++ boost/regex/v4/regex_workaround.hpp 11 Dec 2005 10:43:39 -0000 @@ -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: libs/regex/src/posix_api.cpp =================================================================== RCS file: /cvsroot/boost/boost/libs/regex/src/posix_api.cpp,v retrieving revision 1.22 diff -u -r1.22 posix_api.cpp --- libs/regex/src/posix_api.cpp 30 Mar 2005 11:38:32 -0000 1.22 +++ libs/regex/src/posix_api.cpp 11 Dec 2005 10:43:39 -0000 @@ -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 diff -u -r1.26 wide_posix_api.cpp --- 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 10:43:40 -0000 @@ -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) 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 diff -u -r1.3 test_deprecated.cpp --- 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 10:43:40 -0000 @@ -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,19 +100,23 @@ 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(results[2*i] != matches[i].rm_so) - { - BOOST_REGEX_TEST_ERROR("Mismatch in start of subexpression " << i << " found with the POSIX C API.", char); - } - if(results[2*i+1] != matches[i].rm_eo) + if(max_subs > i) { - BOOST_REGEX_TEST_ERROR("Mismatch in end of subexpression " << i << " found with the POSIX C API.", char); + 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); + } + if(results[2*i+1] != matches[i].rm_eo) + { + BOOST_REGEX_TEST_ERROR("Mismatch in end of subexpression " << i << " found with the POSIX C API.", char); + } } ++i; } @@ -213,19 +224,23 @@ 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(results[2*i] != matches[i].rm_so) + if(max_subs > i) { - BOOST_REGEX_TEST_ERROR("Mismatch in start of subexpression " << i << " found with the POSIX C API.", wchar_t); - } - if(results[2*i+1] != matches[i].rm_eo) - { - BOOST_REGEX_TEST_ERROR("Mismatch in end of subexpression " << i << " found with the POSIX C API.", wchar_t); + 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); + } + if(results[2*i+1] != matches[i].rm_eo) + { + 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_tricky_cases.cpp =================================================================== RCS file: /cvsroot/boost/boost/libs/regex/test/regress/test_tricky_cases.cpp,v retrieving revision 1.6 diff -u -r1.6 test_tricky_cases.cpp --- 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 10:43:41 -0000 @@ -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));