From eea4d13b8239154520e210e15a9831442e57661a Mon Sep 17 00:00:00 2001 From: Ted Wang Date: Wed, 25 Aug 2021 15:34:39 -0700 Subject: [PATCH] Fixed compilation of tier1 caused by min/max. --- tier1/KeyValues.cpp | 4 ++-- tier1/diff.cpp | 10 +++++----- tier1/mempool.cpp | 2 +- tier1/strtools.cpp | 18 +++++++++--------- tier1/utlbuffer.cpp | 2 +- tier1/utlsymbol.cpp | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/tier1/KeyValues.cpp b/tier1/KeyValues.cpp index b8d2b6db..7123be59 100644 --- a/tier1/KeyValues.cpp +++ b/tier1/KeyValues.cpp @@ -106,7 +106,7 @@ public: m_errorStack[m_errorIndex] = symName; } m_errorIndex++; - m_maxErrorIndex = max( m_maxErrorIndex, (m_errorIndex-1) ); + m_maxErrorIndex = V_max( m_maxErrorIndex, (m_errorIndex-1) ); return m_errorIndex-1; } @@ -3211,4 +3211,4 @@ bool CKeyValuesDumpContextAsDevMsg::KvWriteText( char const *szText ) Msg( "%s", szText ); } return true; -} \ No newline at end of file +} diff --git a/tier1/diff.cpp b/tier1/diff.cpp index 42deb231..5c0a8200 100644 --- a/tier1/diff.cpp +++ b/tier1/diff.cpp @@ -219,8 +219,8 @@ int FindDiffsForLargeFiles(uint8 const *NewBlock, uint8 const *OldBlock, int match_of=b->dataptr-lastmatchend; if ((match_of>-32768) && (match_of<32767)) { - int max_mlength=min(65535,OldBlock+OldSize-b->dataptr); - max_mlength=min(max_mlength,NewBlock+NewSize-walk); + int max_mlength=V_min(65535,OldBlock+OldSize-b->dataptr); + max_mlength=V_min(max_mlength,NewBlock+NewSize-walk); int i; for(i=0;idataptr[i]) @@ -355,8 +355,8 @@ int FindDiffs(uint8 const *NewBlock, uint8 const *OldBlock, int match_of=b->dataptr-lastmatchend; if ((match_of>-32768) && (match_of<32767)) { - int max_mlength=min(65535,OldBlock+OldSize-b->dataptr); - max_mlength=min(max_mlength,NewBlock+NewSize-walk); + int max_mlength=V_min(65535,OldBlock+OldSize-b->dataptr); + max_mlength=V_min(max_mlength,NewBlock+NewSize-walk); int i; for(i=0;idataptr[i]) @@ -467,7 +467,7 @@ int FindDiffsLowMemory(uint8 const *NewBlock, uint8 const *OldBlock, uint16 hash1=(walk[0]+walk[1]+walk[2]+walk[3]) & (NELEMS(old_data_hash)-1); if (old_data_hash[hash1]) { - int max_bytes_to_compare=min(NewBlock+NewSize-walk,OldBlock+OldSize-old_data_hash[hash1]); + int max_bytes_to_compare=V_min(NewBlock+NewSize-walk,OldBlock+OldSize-old_data_hash[hash1]); int nmatches; for(nmatches=0;nmatches= destBufferSize ) @@ -960,7 +960,7 @@ wchar_t *V_wcsncat( INOUT_Z_CAP(cchDest) wchar_t *pDest, const wchar_t *pSrc, si } else { - charstocopy = (size_t)min( max_chars_to_copy, (int)srclen ); + charstocopy = (size_t)V_min( max_chars_to_copy, (int)srclen ); } if ( len + charstocopy >= cchDest ) @@ -1020,7 +1020,7 @@ char *V_pretifymem( float value, int digitsafterdecimal /*= 2*/, bool usebinaryo char val[ 32 ]; // Clamp to >= 0 - digitsafterdecimal = max( digitsafterdecimal, 0 ); + digitsafterdecimal = V_max( digitsafterdecimal, 0 ); // If it's basically integral, don't do any decimals if ( FloatMakePositive( value - (int)value ) < 0.00001 ) @@ -1439,7 +1439,7 @@ int _V_UnicodeToUCS2( const wchar_t *pUnicode, int cubSrcInBytes, char *pUCS2, i #ifdef _WIN32 // Figure out which buffer is smaller and convert from bytes to character // counts. - int cchResult = min( (size_t)cubSrcInBytes/sizeof(wchar_t), cubDestSizeInBytes/sizeof(wchar_t) ); + int cchResult = V_min( (size_t)cubSrcInBytes/sizeof(wchar_t), cubDestSizeInBytes/sizeof(wchar_t) ); wchar_t *pDest = (wchar_t*)pUCS2; wcsncpy( pDest, pUnicode, cchResult ); // Make sure we NULL-terminate. @@ -1599,7 +1599,7 @@ unsigned char V_nibble( char c ) void V_hextobinary( char const *in, int numchars, byte *out, int maxoutputbytes ) { int len = V_strlen( in ); - numchars = min( len, numchars ); + numchars = V_min( len, numchars ); // Make sure it's even numchars = ( numchars ) & ~0x1; @@ -1710,7 +1710,7 @@ void V_FileBase( const char *in, char *out, int maxlen ) // Length of new sting len = end - start + 1; - int maxcopy = min( len + 1, maxlen ); + int maxcopy = V_min( len + 1, maxlen ); // Copy partial string V_strncpy( out, &in[start], maxcopy ); @@ -1754,7 +1754,7 @@ void V_StripExtension( const char *in, char *out, int outSize ) if (end > 0 && !PATHSEPARATOR( in[end] ) && end < outSize) { - int nChars = min( end, outSize-1 ); + int nChars = V_min( end, outSize-1 ); if ( out != in ) { memcpy( out, in, nChars ); @@ -2001,7 +2001,7 @@ bool V_ExtractFilePath (const char *path, char *dest, int destSize ) src--; } - int copysize = min( src - path, destSize - 1 ); + int copysize = V_min( src - path, destSize - 1 ); memcpy( dest, path, copysize ); dest[copysize] = 0; @@ -2392,7 +2392,7 @@ char* AllocString( const char *pStr, int nMaxChars ) if ( nMaxChars == -1 ) allocLen = strlen( pStr ) + 1; else - allocLen = min( (int)strlen(pStr), nMaxChars ) + 1; + allocLen = V_min( (int)strlen(pStr), nMaxChars ) + 1; char *pOut = new char[allocLen]; V_strncpy( pOut, pStr, allocLen ); diff --git a/tier1/utlbuffer.cpp b/tier1/utlbuffer.cpp index 9458faa9..77cf4065 100644 --- a/tier1/utlbuffer.cpp +++ b/tier1/utlbuffer.cpp @@ -640,7 +640,7 @@ void CUtlBuffer::GetStringInternal( char *pString, size_t maxLenInChars ) return; } - const size_t nCharsToRead = min( (size_t)nLen, maxLenInChars ) - 1; + const size_t nCharsToRead = V_min( (size_t)nLen, maxLenInChars ) - 1; Get( pString, nCharsToRead ); pString[nCharsToRead] = 0; diff --git a/tier1/utlsymbol.cpp b/tier1/utlsymbol.cpp index 7d862b85..f96494c6 100644 --- a/tier1/utlsymbol.cpp +++ b/tier1/utlsymbol.cpp @@ -234,7 +234,7 @@ CUtlSymbol CUtlSymbolTable::AddString( const char* pString ) if ( iPool == -1 ) { // Add a new pool. - int newPoolSize = max( len, MIN_STRING_POOL_SIZE ); + int newPoolSize = V_max( len, MIN_STRING_POOL_SIZE ); StringPool_t *pPool = (StringPool_t*)malloc( sizeof( StringPool_t ) + newPoolSize - 1 ); pPool->m_TotalLen = newPoolSize; pPool->m_SpaceUsed = 0;