diff --git a/src/cregex.cpp b/src/cregex.cpp index ca134265..2a9adc26 100644 --- a/src/cregex.cpp +++ b/src/cregex.cpp @@ -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 @@ const std::size_t RegEx::npos = static_cast(~0UL); // 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 @@ basic_string::replace(char* f1, char* f2, const char* i1, con } 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 diff --git a/src/w32_regex_traits.cpp b/src/w32_regex_traits.cpp index 7d850653..20e84d15 100644 --- a/src/w32_regex_traits.cpp +++ b/src/w32_regex_traits.cpp @@ -105,7 +105,14 @@ void w32_regex_traits_char_layer::init() for(int ii = 0; ii < (1 << CHAR_BIT); ++ii) char_map[ii] = static_cast(ii); int r = ::LCMapStringA(this->m_locale, LCMAP_LOWERCASE, char_map, 1 << CHAR_BIT, this->m_lower_map, 1 << CHAR_BIT); - BOOST_ASSERT(r == 1 << CHAR_BIT); + BOOST_ASSERT(r != 0); + if(r < (1 << CHAR_BIT)) + { + // if we have multibyte characters then not all may have been given + // a lower case mapping: + for(int jj = r; jj < (1 << CHAR_BIT); ++jj) + this->m_lower_map[jj] = static_cast(jj); + } r = ::GetStringTypeExA(this->m_locale, CT_CTYPE1, char_map, 1 << CHAR_BIT, this->m_type_map); BOOST_ASSERT(0 != r); } diff --git a/test/collate_info/collate_info.cpp b/test/collate_info/collate_info.cpp index 58750951..c07fbd3c 100644 --- a/test/collate_info/collate_info.cpp +++ b/test/collate_info/collate_info.cpp @@ -223,12 +223,14 @@ int cpp_main(int /*argc*/, char * /*argv*/[]) 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");