mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2025-09-19 12:06:07 +08:00
Sync with upstream (Issue #30).
Recompiled tier1 and mathlib for all platforms will come in next commit.
This commit is contained in:
@ -609,17 +609,19 @@ int CUtlBuffer::PeekDelimitedStringLength( CUtlCharConversion *pConv, bool bActu
|
||||
//-----------------------------------------------------------------------------
|
||||
// Reads a null-terminated string
|
||||
//-----------------------------------------------------------------------------
|
||||
void CUtlBuffer::GetString( char* pString, int nMaxChars )
|
||||
void CUtlBuffer::GetStringInternal( char *pString, size_t maxLenInChars )
|
||||
{
|
||||
if (!IsValid())
|
||||
if ( !IsValid() )
|
||||
{
|
||||
*pString = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( nMaxChars == 0 )
|
||||
Assert( maxLenInChars != 0 );
|
||||
|
||||
if ( maxLenInChars == 0 )
|
||||
{
|
||||
nMaxChars = INT_MAX;
|
||||
return;
|
||||
}
|
||||
|
||||
// Remember, this *includes* the null character
|
||||
@ -631,24 +633,21 @@ void CUtlBuffer::GetString( char* pString, int nMaxChars )
|
||||
EatWhiteSpace();
|
||||
}
|
||||
|
||||
if ( nLen == 0 )
|
||||
if ( nLen <= 0 )
|
||||
{
|
||||
*pString = 0;
|
||||
m_Error |= GET_OVERFLOW;
|
||||
return;
|
||||
}
|
||||
|
||||
// Strip off the terminating NULL
|
||||
if ( nLen <= nMaxChars )
|
||||
|
||||
const size_t nCharsToRead = min( (size_t)nLen, maxLenInChars ) - 1;
|
||||
|
||||
Get( pString, nCharsToRead );
|
||||
pString[nCharsToRead] = 0;
|
||||
|
||||
if ( (size_t)nLen > (nCharsToRead + 1) )
|
||||
{
|
||||
Get( pString, nLen - 1 );
|
||||
pString[ nLen - 1 ] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Get( pString, nMaxChars - 1 );
|
||||
pString[ nMaxChars - 1 ] = 0;
|
||||
SeekGet( SEEK_CURRENT, nLen - 1 - nMaxChars );
|
||||
SeekGet( SEEK_CURRENT, nLen - (nCharsToRead + 1) );
|
||||
}
|
||||
|
||||
// Read the terminating NULL in binary formats
|
||||
@ -733,7 +732,7 @@ void CUtlBuffer::GetDelimitedString( CUtlCharConversion *pConv, char *pString, i
|
||||
{
|
||||
if ( !IsText() || !pConv )
|
||||
{
|
||||
GetString( pString, nMaxChars );
|
||||
GetStringInternal( pString, nMaxChars );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1045,7 +1044,7 @@ int CUtlBuffer::VaScanf( const char* pFmt, va_list list )
|
||||
case 's':
|
||||
{
|
||||
char* s = va_arg( list, char * );
|
||||
GetString( s );
|
||||
GetStringInternal( s, 256 );
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1736,7 +1735,6 @@ void CUtlBuffer::Swap( CUtlMemory<uint8> &mem )
|
||||
CUtlInplaceBuffer::CUtlInplaceBuffer( int growSize /* = 0 */, int initSize /* = 0 */, int nFlags /* = 0 */ ) :
|
||||
CUtlBuffer( growSize, initSize, nFlags )
|
||||
{
|
||||
NULL;
|
||||
}
|
||||
|
||||
bool CUtlInplaceBuffer::InplaceGetLinePtr( char **ppszInBufferPtr, int *pnLineLength )
|
||||
|
Reference in New Issue
Block a user