Remove workarounds for ancient MSVC versions

This commit is contained in:
Martin Natano
2022-06-07 22:49:05 +02:00
parent 838de6fb81
commit c40985122e
20 changed files with 32 additions and 239 deletions
+7 -161
View File
@@ -72,7 +72,7 @@
// Turn off unavoidable compiler warnings
#if defined(_MSC_VER) && (_MSC_VER > 1100)
#if defined(_MSC_VER)
#pragma component(browser, off, references, "CStdString")
#pragma warning (push)
#pragma warning (disable : 4290) // C++ Exception Specification ignored
@@ -103,16 +103,6 @@ typedef char* PSTR;
#include <cstdarg>
#include <cstring>
// a very shorthand way of applying the fix for KB problem Q172398
// (basic_string assignment bug)
#if defined ( _MSC_VER ) && ( _MSC_VER < 1200 )
#define HAVE_ASSIGN_FIX
#define Q172398(x) (x).erase()
#else
#define Q172398(x)
#endif
/* In RageUtil: */
void MakeUpper( char *p, size_t iLen );
void MakeLower( char *p, size_t iLen );
@@ -191,27 +181,7 @@ inline void ssasn(std::string& sDst, const std::string& sSrc)
*/
inline void ssasn(std::string& sDst, PCSTR pA)
{
#if defined(HAVE_ASSIGN_FIX)
// If pA actually points to part of sDst, we must NOT erase(), but
// rather take a substring
if ( pA >= sDst.c_str() && pA <= sDst.c_str() + sDst.size() )
{
sDst =sDst.substr(static_cast<SS_SIZETYPE>(pA-sDst.c_str()));
}
// Otherwise (most cases) apply the assignment bug fix, if applicable
// and do the assignment
else
{
Q172398(sDst);
sDst.assign(pA);
}
else
#else
sDst.assign(pA);
#endif
}
#undef StrSizeType
@@ -448,8 +418,7 @@ public:
{
}
// CStdStr inline assignment operators -- the ssasn function now takes care
// of fixing the MSVC assignment bug (see knowledge base article Q172398).
// CStdStr inline assignment operators
MYTYPE& operator=(const MYTYPE& str)
{
ssasn(*this, str);
@@ -470,126 +439,10 @@ public:
MYTYPE& operator=(CT t)
{
Q172398(*this);
this->assign(1, t);
return *this;
}
// Overloads also needed to fix the MSVC assignment bug (KB: Q172398)
// *** Thanks to Pete The Plumber for catching this one ***
// They also are compiled if you have explicitly turned off refcounting
#if ( defined(_MSC_VER) && ( _MSC_VER < 1200 ) )
MYTYPE& assign(const MYTYPE& str)
{
ssasn(*this, str);
return *this;
}
MYTYPE& assign(const MYTYPE& str, MYSIZE nStart, MYSIZE nChars)
{
// This overload of basic_string::assign is supposed to assign up to
// <nChars> or the NULL terminator, whichever comes first. Since we
// are about to call a less forgiving overload (in which <nChars>
// must be a valid length), we must adjust the length here to a safe
// value. Thanks to Ullrich Pollähne for catching this bug
nChars = min(nChars, str.length() - nStart);
// Watch out for assignment to self
if ( this == &str )
{
MYTYPE strTemp(str.c_str()+nStart, nChars);
MYBASE::assign(strTemp);
}
else
{
Q172398(*this);
MYBASE::assign(str.c_str()+nStart, nChars);
}
return *this;
}
MYTYPE& assign(const MYBASE& str)
{
ssasn(*this, str);
return *this;
}
MYTYPE& assign(const MYBASE& str, MYSIZE nStart, MYSIZE nChars)
{
// This overload of basic_string::assign is supposed to assign up to
// <nChars> or the NULL terminator, whichever comes first. Since we
// are about to call a less forgiving overload (in which <nChars>
// must be a valid length), we must adjust the length here to a safe
// value. Thanks to Ullrich Pollähne for catching this bug
nChars = min(nChars, str.length() - nStart);
// Watch out for assignment to self
if ( this == &str ) // watch out for assignment to self
{
MYTYPE strTemp(str.c_str() + nStart, nChars);
MYBASE::assign(strTemp);
}
else
{
Q172398(*this);
MYBASE::assign(str.c_str()+nStart, nChars);
}
return *this;
}
MYTYPE& assign(const CT* pC, MYSIZE nChars)
{
// Q172398 only fix -- erase before assigning, but not if we're
// assigning from our own buffer
#if defined ( _MSC_VER ) && ( _MSC_VER < 1200 )
if ( !this->empty() &&
( pC < this->data() || pC > this->data() + this->capacity() ) )
{
this->erase();
}
#endif
MYBASE::assign(pC, nChars);
return *this;
}
MYTYPE& assign(MYSIZE nChars, MYVAL val)
{
Q172398(*this);
MYBASE::assign(nChars, val);
return *this;
}
MYTYPE& assign(const CT* pT)
{
return this->assign(pT, MYBASE::traits_type::length(pT));
}
MYTYPE& assign(MYCITER iterFirst, MYCITER iterLast)
{
#if defined ( _MSC_VER ) && ( _MSC_VER < 1200 )
// Q172398 fix. don't call erase() if we're assigning from ourself
if ( iterFirst < this->begin() || iterFirst > this->begin() + this->size() )
this->erase()
#endif
this->replace(this->begin(), this->end(), iterFirst, iterLast);
return *this;
}
#endif
/* VC6 string is missing clear(). */
#if defined(_MSC_VER) && ( _MSC_VER < 1300 ) /* VC6, not VC7 */
void clear()
{
this->erase();
}
#endif
// -------------------------------------------------------------------------
// CStdStr inline concatenation.
// -------------------------------------------------------------------------
@@ -619,17 +472,10 @@ public:
// addition operators -- global friend functions.
#if defined(_MSC_VER) && _MSC_VER < 1300 /* VC6, not VC7 */
/* work around another stupid vc6 bug */
#define EMP_TEMP
#else
#define EMP_TEMP <>
#endif
friend MYTYPE operator+ EMP_TEMP(const MYTYPE& str1, const MYTYPE& str2);
friend MYTYPE operator+ EMP_TEMP(const MYTYPE& str, CT t);
friend MYTYPE operator+ EMP_TEMP(const MYTYPE& str, PCSTR sz);
friend MYTYPE operator+ EMP_TEMP(PCSTR pA, const MYTYPE& str);
friend MYTYPE operator+ <>(const MYTYPE& str1, const MYTYPE& str2);
friend MYTYPE operator+ <>(const MYTYPE& str, CT t);
friend MYTYPE operator+ <>(const MYTYPE& str, PCSTR sz);
friend MYTYPE operator+ <>(PCSTR pA, const MYTYPE& str);
// -------------------------------------------------------------------------
// Case changing functions
@@ -833,7 +679,7 @@ struct StdStringEqualsNoCase
} // namespace StdString
#if defined(_MSC_VER) && (_MSC_VER > 1100)
#if defined(_MSC_VER)
#pragma warning (pop)
#endif