From e79458b0e33c57c27c41df2ee9ea117135dc13b2 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sun, 7 Dec 2003 12:52:18 +0000 Subject: [PATCH] Added ugly workaround for linker errors from bcb5 [SVN r21167] --- test/regress/tests.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/regress/tests.cpp b/test/regress/tests.cpp index f210b4fa..78a6e11d 100644 --- a/test/regress/tests.cpp +++ b/test/regress/tests.cpp @@ -907,6 +907,48 @@ void reset_error() last_line = 0; } +#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x550) && (__BORLANDC__ <= 0x551) && !defined(_RWSTD_COMPILE_INSTANTIATE) +// +// this is an ugly hack to work around an ugly problem: +// by default this file will produce unresolved externals during +// linking unless _RWSTD_COMPILE_INSTANTIATE is defined (Borland bug). +// However if _RWSTD_COMPILE_INSTANTIATE is defined then we get separate +// copies of basic_string's static data in the RTL and this DLL, this messes +// with basic_string's memory management and results in run-time crashes, +// Oh sweet joy of Catch 22.... +// +namespace std{ +template<> template<> +basic_string& +basic_string + ::replace >( + string_type::iterator f1, + string_type::iterator f2, + debug_iterator i1, + debug_iterator 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; +} +} +#endif + + #endif