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
-4
View File
@@ -15,13 +15,11 @@
static HANDLE g_hInstanceMutex;
static bool g_bIsMultipleInstance = false;
#if _MSC_VER >= 1400 // VC8
void InvalidParameterHandler( const wchar_t *szExpression, const wchar_t *szFunction, const wchar_t *szFile,
unsigned int iLine, uintptr_t pReserved )
{
FAIL_M( "Invalid parameter" ); //TODO: Make this more informative
}
#endif
ArchHooks_Win32::ArchHooks_Win32()
{
@@ -34,9 +32,7 @@ ArchHooks_Win32::ArchHooks_Win32()
CrashHandler::CrashHandlerHandleArgs( g_argc, g_argv );
SetUnhandledExceptionFilter( CrashHandler::ExceptionHandler );
#if _MSC_VER >= 1400 // VC8
_set_invalid_parameter_handler( InvalidParameterHandler );
#endif
/* Windows boosts priority on keyboard input, among other things. Disable that for
* the main thread. */
@@ -29,9 +29,7 @@
#include "RageFileDriverDeflate.h"
#include "ver.h"
#if defined(_MSC_VER)
#pragma comment(lib, "dbghelp.lib")
#endif
// XXX: What happens when we *don't* have version info? Does that ever actually happen?
#include "ver.h"
@@ -7,9 +7,7 @@
#include <windows.h>
#include <tlhelp32.h>
#if defined(_MSC_VER)
#pragma comment(lib, "version.lib")
#endif
bool GetFileVersion( RString sFile, RString &sOut )
{
-2
View File
@@ -4,10 +4,8 @@
#include "RageUtil.h"
#include "archutils/Win32/ErrorStrings.h"
#if defined(_MSC_VER)
#pragma comment(lib, "setupapi.lib")
#pragma comment(lib, "hid.lib")
#endif
extern "C" {
#include "archutils/Win32/ddk/setupapi.h"
-25
View File
@@ -2,15 +2,9 @@
#define ARCH_SETUP_WINDOWS_H
#define SUPPORT_OPENGL
#if defined(_MSC_VER)
#define SUPPORT_D3D
#endif
#if defined(_MSC_VER)
#if _MSC_VER == 1400 // VC8 specific warnings
#pragma warning (disable : 4005) // macro redefinitions (ARRAYSIZE)
#endif
/*
The following warnings are disabled in all builds.
@@ -62,8 +56,6 @@ C4355: 'this' : used in base member initializer list
// If this isn't defined to 0, VC fails to define things like stat and alloca.
#define __STDC__ 0
#endif
#include <wchar.h> // needs to be included before our fixes below
#define lstat stat
@@ -77,10 +69,8 @@ struct tm *my_localtime_r( const time_t *timep, struct tm *result );
#define localtime_r my_localtime_r
struct tm *my_gmtime_r( const time_t *timep, struct tm *result );
#define gmtime_r my_gmtime_r
#if defined(_MSC_VER)
void my_usleep( unsigned long usec );
#define usleep my_usleep
#endif
// Missing stdint types:
typedef signed char int8_t;
@@ -94,20 +84,6 @@ typedef int int32_t;
typedef unsigned int uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#if defined(_MSC_VER)
#if _MSC_VER < 1700 // 1700 = VC++ 2011
#define INT64_C(i) i##i64
#ifndef UINT64_C
#define UINT64_C(i) i##ui64
#endif
#endif // #if _MSC_VER < 1700
#if (_MSC_VER >= 1400) && (_MSC_VER < 1800) // 1800 = VC++ 2013
#define llabs(i) _abs64(i)
#endif // #if (_MSC_VER >= 1400) && (_MSC_VER < 1800)
#if _MSC_VER < 1400 // 1400 = VC++ 2005
int64_t llabs( int64_t i ) { return i >= 0 ? i : -i; }
#endif // #if _MSC_VER < 1400
#endif // #if defined(_MSC_VER)
#undef min
#undef max
@@ -119,7 +95,6 @@ int64_t llabs( int64_t i ) { return i >= 0 ? i : -i; }
#define CRASH_HANDLER
#endif
#if defined(_MSC_VER) && (_MSC_VER >= 1310) // Byte swap functions were first implemented in Visual Studio .NET 2003
#define ArchSwap32(n) _byteswap_ulong(n)
#define ArchSwap24(n) _byteswap_ulong(n) >> 8
#define ArchSwap16(n) _byteswap_ushort(n)
+1 -17
View File
@@ -20,9 +20,7 @@ Revision History:
#ifndef _DBGHELP_
#define _DBGHELP_
#if _MSC_VER > 1020
#pragma once
#endif
// As a general principal always call the 64 bit version
@@ -46,7 +44,7 @@ extern "C" {
#define DBHLP_DEPRECIATED
#else
#define IMAGEAPI DECLSPEC_IMPORT __stdcall
#if (_MSC_VER >= 1300) && !defined(MIDL_PASS)
#if !defined(MIDL_PASS)
#define DBHLP_DEPRECIATED __declspec(deprecated)
#else
#define DBHLP_DEPRECIATED
@@ -2044,14 +2042,8 @@ typedef enum _MINIDUMP_STREAM_TYPE {
// Operating System specific information.
//
#if defined(_MSC_VER)
#if _MSC_VER >= 800
#if _MSC_VER >= 1200
#pragma warning(push)
#endif
#pragma warning(disable:4201) /* Nameless struct/union */
#endif
#endif
typedef struct _MINIDUMP_SYSTEM_INFO {
@@ -2161,15 +2153,7 @@ typedef struct _MINIDUMP_SYSTEM_INFO {
typedef union _CPU_INFORMATION CPU_INFORMATION, *PCPU_INFORMATION;
#if defined(_MSC_VER)
#if _MSC_VER >= 800
#if _MSC_VER >= 1200
#pragma warning(pop)
#else
#pragma warning(disable:4201) /* Nameless struct/union */
#endif
#endif
#endif
//
// The minidump thread contains standard thread
-2
View File
@@ -15,9 +15,7 @@ Abstract:
#ifndef _INC_SETUPAPI
#define _INC_SETUPAPI
#if _MSC_VER > 1000
#pragma once
#endif
//
// Define API decoration for direct importing of DLL references.
+2 -2
View File
@@ -3,9 +3,9 @@
#include "config.hpp"
#if _MSC_VER >= 1000
#if defined(_MSC_VER)
#pragma once
#endif // _MSC_VER >= 1000
#endif
/** @brief This macro is for INT8_MIN, etc. */
#define __STDC_LIMIT_MACROS
+2 -2
View File
@@ -1,9 +1,9 @@
#if !defined(AFX_CHANGEGAMESETTINGS_H__BFA59E6F_E70A_49A7_90A6_F04D3C321CA6__INCLUDED_)
#define AFX_CHANGEGAMESETTINGS_H__BFA59E6F_E70A_49A7_90A6_F04D3C321CA6__INCLUDED_
#if _MSC_VER > 1000
#if defined(_MSC_VER)
#pragma once
#endif // _MSC_VER > 1000
#endif
// ChangeGameSettings.h : header file
//
+2 -2
View File
@@ -1,9 +1,9 @@
#if !defined(AFX_EDITINSALLATIONS_H__CD328CB4_8E35_4B12_BCD1_ADF5CE7EABC7__INCLUDED_)
#define AFX_EDITINSALLATIONS_H__CD328CB4_8E35_4B12_BCD1_ADF5CE7EABC7__INCLUDED_
#if _MSC_VER > 1000
#if defined(_MSC_VER)
#pragma once
#endif // _MSC_VER > 1000
#endif
// EditInsallations.h : header file
/////////////////////////////////////////////////////////////////////////////
+2 -2
View File
@@ -2,9 +2,9 @@
#if !defined(AFX_ENTERCOMMENT_H__DE628EA8_0FE7_4594_B2A2_47BDB283FA1E__INCLUDED_)
#define AFX_ENTERCOMMENT_H__DE628EA8_0FE7_4594_B2A2_47BDB283FA1E__INCLUDED_
#if _MSC_VER > 1000
#if defined(_MSC_VER)
#pragma once
#endif // _MSC_VER > 1000
#endif
// EnterComment.h : header file
/////////////////////////////////////////////////////////////////////////////
+2 -2
View File
@@ -1,9 +1,9 @@
#if !defined(AFX_ENTERNAME_H__0AB99274_EB79_4A25_B95C_627E0A99C6BA__INCLUDED_)
#define AFX_ENTERNAME_H__0AB99274_EB79_4A25_B95C_627E0A99C6BA__INCLUDED_
#if _MSC_VER > 1000
#if defined(_MSC_VER)
#pragma once
#endif // _MSC_VER > 1000
#endif
// EnterName.h : header file
/////////////////////////////////////////////////////////////////////////////
+2 -2
View File
@@ -1,9 +1,9 @@
#if !defined(AFX_MAINMENUDLG_H__3CED6142_18E5_4267_B678_BE5B63735C6C__INCLUDED_)
#define AFX_MAINMENUDLG_H__3CED6142_18E5_4267_B678_BE5B63735C6C__INCLUDED_
#if _MSC_VER > 1000
#if defined(_MSC_VER)
#pragma once
#endif // _MSC_VER > 1000
#endif
// MainMenuDlg.h : header file
/////////////////////////////////////////////////////////////////////////////
+2 -2
View File
@@ -1,9 +1,9 @@
#if !defined(AFX_SMPACKAGEINSTALLDLG_H__5E362C4C_CA11_4071_A8AB_A0231E985DAF__INCLUDED_)
#define AFX_SMPACKAGEINSTALLDLG_H__5E362C4C_CA11_4071_A8AB_A0231E985DAF__INCLUDED_
#if _MSC_VER > 1000
#if defined(_MSC_VER)
#pragma once
#endif // _MSC_VER > 1000
#endif
// SMPackageInstallDlg.h : header file
/////////////////////////////////////////////////////////////////////////////
+2 -2
View File
@@ -1,9 +1,9 @@
#if !defined(AFX_SHOWCOMMENT_H__1FA603E3_5CCD_4D9E_9EC9_88AD55A06270__INCLUDED_)
#define AFX_SHOWCOMMENT_H__1FA603E3_5CCD_4D9E_9EC9_88AD55A06270__INCLUDED_
#if _MSC_VER > 1000
#if defined(_MSC_VER)
#pragma once
#endif // _MSC_VER > 1000
#endif
// ShowComment.h : header file
/////////////////////////////////////////////////////////////////////////////
+2 -2
View File
@@ -1,9 +1,9 @@
#if !defined(AFX_SMPACKAGEEXPORTDLG_H__3E19CBFB_E8F6_4C18_B0A4_636979B80A4D__INCLUDED_)
#define AFX_SMPACKAGEEXPORTDLG_H__3E19CBFB_E8F6_4C18_B0A4_636979B80A4D__INCLUDED_
#if _MSC_VER > 1000
#if defined(_MSC_VER)
#pragma once
#endif // _MSC_VER > 1000
#endif
#include "afxtempl.h"
+2 -2
View File
@@ -6,9 +6,9 @@
#if !defined(AFX_STDAFX_H__D450D5ED_5C49_4A8B_B887_076F62424F1F__INCLUDED_)
#define AFX_STDAFX_H__D450D5ED_5C49_4A8B_B887_076F62424F1F__INCLUDED_
#if _MSC_VER > 1000
#if defined(_MSC_VER)
#pragma once
#endif // _MSC_VER > 1000
#endif
#pragma warning (disable : 4786) // turn off broken debugger warning
+2 -2
View File
@@ -10,9 +10,9 @@
#if !defined(AFX_TREECTRLEX_H__5D969ED4_7DEA_4FB5_8C1D_E12D1CCF0989__INCLUDED_)
#define AFX_TREECTRLEX_H__5D969ED4_7DEA_4FB5_8C1D_E12D1CCF0989__INCLUDED_
#if _MSC_VER > 1000
#if defined(_MSC_VER)
#pragma once
#endif // _MSC_VER > 1000
#endif
#include <afxtempl.h>
+2 -2
View File
@@ -3,9 +3,9 @@
#if !defined(AFX_SMPACKAGE_H__FBCA9E6C_86A9_4271_8304_83CC34A31687__INCLUDED_)
#define AFX_SMPACKAGE_H__FBCA9E6C_86A9_4271_8304_83CC34A31687__INCLUDED_
#if _MSC_VER > 1000
#if defined(_MSC_VER)
#pragma once
#endif // _MSC_VER > 1000
#endif
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH