Merge branch 'development' of https://github.com/GarageGames/Torque3D into memberMess

# Conflicts:
#	Engine/source/console/consoleFunctions.cpp
This commit is contained in:
Azaezel 2018-03-28 15:42:34 -05:00
commit cbce2ee805
154 changed files with 2950 additions and 705 deletions

View file

@ -185,7 +185,7 @@ public:
/// the FrameAllocator. For example:
/// @code
/// FrameTemp<char> tempStr(32); // NOTE! This parameter is NOT THE SIZE IN BYTES. See constructor docs.
/// dStrcat( tempStr, SomeOtherString );
/// dStrcat( tempStr, SomeOtherString, 32 * sizeof(char) );
/// tempStr[2] = 'l';
/// Con::printf( tempStr );
/// Con::printf( "Foo: %s", ~tempStr );

View file

@ -668,13 +668,13 @@ void BitStream::readString(char buf[256])
{
S32 offset = readInt(8);
HuffmanProcessor::g_huffProcessor.readHuffBuffer(this, stringBuffer + offset);
dStrcpy(buf, stringBuffer);
dStrcpy(buf, stringBuffer, 256);
return;
}
}
HuffmanProcessor::g_huffProcessor.readHuffBuffer(this, buf);
if(stringBuffer)
dStrcpy(stringBuffer, buf);
dStrcpy(stringBuffer, buf, 256);
}
void BitStream::writeString(const char *string, S32 maxLen)

View file

@ -142,10 +142,11 @@ StringTableEntry _StringTable::insert(const char* _val, const bool caseSens)
}
char *ret = 0;
if(!*walk) {
dsize_t valLen = dStrlen(val) + 1;
*walk = (Node *) mempool.alloc(sizeof(Node));
(*walk)->next = 0;
(*walk)->val = (char *) mempool.alloc(dStrlen(val) + 1);
dStrcpy((*walk)->val, val);
(*walk)->val = (char *) mempool.alloc(valLen);
dStrcpy((*walk)->val, val, valLen);
ret = (*walk)->val;
itemCount ++;
}

View file

@ -71,8 +71,9 @@ void FindMatch::setExpression( const char *_expression )
{
delete [] expression;
expression = new char[dStrlen(_expression) + 1];
dStrcpy(expression, _expression);
dsize_t expressionLen = dStrlen(_expression) + 1;
expression = new char[expressionLen];
dStrcpy(expression, _expression, expressionLen);
dStrupr(expression);
}
@ -82,7 +83,7 @@ bool FindMatch::findMatch( const char *str, bool caseSensitive )
return false;
char nstr[512];
dStrcpy( nstr,str );
dStrcpy( nstr,str,512 );
dStrupr(nstr);
if ( isMatch( expression, nstr, caseSensitive ) )
{
@ -143,7 +144,7 @@ bool FindMatch::isMatchMultipleExprs( const char *exps, const char *str, bool ca
S32 len = dStrlen(exps);
char *e = new char[len+1];
dStrcpy(e,exps);
dStrcpy(e,exps,len+1);
// [tom, 12/18/2006] This no longer supports space separated expressions as
// they don't work when the paths have spaces in.

View file

@ -215,8 +215,9 @@ S32 dStrnatcasecmp(const nat_char* a, const nat_char* b) {
char *dStrdup_r(const char *src, const char *fileName, dsize_t lineNumber)
{
char *buffer = (char *) dMalloc_r(dStrlen(src) + 1, fileName, lineNumber);
dStrcpy(buffer, src);
dsize_t bufferLen = dStrlen(src) + 1;
char *buffer = (char *) dMalloc_r(bufferLen, fileName, lineNumber);
dStrcpy(buffer, src, bufferLen);
return buffer;
}
@ -381,6 +382,67 @@ char* dStrlwr(char *str)
#endif
}
//------------------------------------------------------------------------------
S32 dStrlcat(char *dst, const char *src, dsize_t dstSize)
{
//TODO: Do other platforms support strlcat in their libc
#ifdef TORQUE_OS_MAC
S32 len = strlcat(dst, src, dstSize);
AssertWarn(len < dstSize, "Buffer too small in call to dStrlcat!");
return len;
#else //TORQUE_OS_MAC
S32 dstLen = dStrlen(dst);
S32 srcLen = dStrlen(src);
S32 copyLen = srcLen;
//Check for buffer overflow and don't allow it. Warn on debug so we can fix it
AssertWarn(dstLen + copyLen < dstSize, "Buffer too small in call to dStrlcat!");
if (dstLen + copyLen + 1 > dstSize)
{
copyLen = dstSize - dstLen - 1;
}
//Copy src after dst and null terminate
memcpy(dst + dstLen, src, copyLen);
dst[dstLen + copyLen] = 0;
//Return the length of the string we would have generated
return dstLen + srcLen;
#endif //TORQUE_OS_MAC
}
S32 dStrlcpy(char *dst, const char *src, dsize_t dstSize)
{
//TODO: Do other platforms support strlcpy in their libc
#ifdef TORQUE_OS_MAC
S32 len = strlcpy(dst, src, dstSize);
AssertWarn(len < dstSize, "Buffer too small in call to dStrlcpy!");
return len;
#else //TORQUE_OS_MAC
S32 srcLen = dStrlen(src);
S32 copyLen = srcLen;
//Check for buffer overflow and don't allow it. Warn on debug so we can fix it
AssertWarn(copyLen < dstSize, "Buffer too small in call to dStrlcpy!");
if (srcLen + 1 > dstSize)
{
copyLen = dstSize - 1;
}
//Copy src and null terminate
memcpy(dst, src, copyLen);
dst[copyLen] = 0;
//Return the length of the string we would have generated
return srcLen;
#endif //TORQUE_OS_MAC
}
//------------------------------------------------------------------------------
// standard I/O functions

View file

@ -32,6 +32,10 @@
#include "platform/types.h"
#endif
#ifndef _PLATFORMASSERT_H_
#include "platform/platformAssert.h"
#endif
#if defined(TORQUE_OS_WIN)
// These standard functions are not defined on Win32 and other Microsoft platforms...
#define strcasecmp _stricmp
@ -43,18 +47,37 @@
#endif // defined(TORQUE_OS_WIN)
//------------------------------------------------------------------------------
// standard string functions [defined in platformString.cpp]
// Buffer size bounds checking "safe" versions of strcat and strcpy. Ideally you
// should use these and check if they return >= dstSize and throw an error if so.
extern S32 dStrlcat(char *dst, const char *src, dsize_t dstSize);
extern S32 dStrlcpy(char *dst, const char *src, dsize_t dstSize);
#ifdef UNSAFE_STRING_FUNCTIONS
/// @deprecated Use dStrcat(char *, const char *, dsize_t) instead
inline char *dStrcat(char *dst, const char *src)
{
AssertFatal(false, "dStrcat without length is deprecated");
return strcat(dst,src);
}
#endif
/// Concatenate strings.
/// @note The third parameter is the size of the destination buffer like strlcat
/// instead of the number of characters to copy like strncat. This is done
/// under the assumption that being easier to use will make this safer.
/// If you want the original behavior use dStrncat.
inline char *dStrcat(char *dst, const char *src, dsize_t dstSize)
{
dStrlcat(dst, src, dstSize);
return dst;
}
inline char *dStrncat(char *dst, const char *src, dsize_t len)
{
return strncat(dst,src,len);
return strncat(dst, src, len);
}
inline S32 dStrcmp(const char *str1, const char *str2)
@ -82,9 +105,19 @@ inline S32 dStrnicmp(const char *str1, const char *str2, dsize_t len)
return strncasecmp( str1, str2, len );
}
#ifdef UNSAFE_STRING_FUNCTIONS
/// @deprecated Use strcpy(char *, const char *, dsize_t) instead
inline char *dStrcpy(char *dst, const char *src)
{
AssertFatal(false, "dStrcpy without length is deprecated");
return strcpy(dst,src);
}
#endif
inline char *dStrcpy(char *dst, const char *src, dsize_t dstSize)
{
dStrlcpy(dst, src, dstSize);
return dst;
}
inline char *dStrncpy(char *dst, const char *src, dsize_t len)

View file

@ -164,7 +164,7 @@ namespace StringUnit
// replace this unit
ret[sz] = '\0';
dStrcat(ret, replace);
dStrcat(ret, replace, 2048);
// copy remaining chunks
sz = dStrcspn(string, set); // skip chunk we're replacing
@ -172,7 +172,7 @@ namespace StringUnit
return ret;
string += sz;
dStrcat(ret, string);
dStrcat(ret, string, 2048);
return ret;
}
@ -211,7 +211,7 @@ namespace StringUnit
}
string += sz + 1; // skip the extra field delimiter
dStrcat(ret, string);
dStrcat(ret, string, 2048);
return ret;
}
}

View file

@ -61,7 +61,7 @@ bool Tokenizer::openFile(const char* pFileName)
delete pStream;
return false;
}
dStrcpy(mFileName, pFileName);
dStrcpy(mFileName, pFileName, 1024);
mBufferSize = pStream->getStreamSize();
mpBuffer = new char[mBufferSize];
@ -99,7 +99,7 @@ void Tokenizer::setBuffer(const char* buffer, U32 bufferSize)
mBufferSize = bufferSize;
mpBuffer = new char[mBufferSize + 1];
dStrcpy(mpBuffer, buffer);
dStrcpy(mpBuffer, buffer, mBufferSize + 1);
reset();
@ -634,4 +634,4 @@ bool Tokenizer::endOfFile()
return false;
else
return true;
}
}

View file

@ -177,8 +177,9 @@ bool CentralDir::write(Stream *stream)
void CentralDir::setFileComment(const char *comment)
{
SAFE_DELETE_ARRAY(mFileComment);
mFileComment = new char [dStrlen(comment)+1];
dStrcpy(mFileComment, comment);
dsize_t commentLen = dStrlen(comment) + 1;
mFileComment = new char [commentLen];
dStrcpy(mFileComment, comment, commentLen);
}
//-----------------------------------------------------------------------------

View file

@ -95,7 +95,7 @@ private:
{
// Find a unique filename
U32 count = 1;
dStrcpy(fileBuf, filename);
dStrcpy(fileBuf, filename, bufSize);
while(zip->findFileInfo(fileBuf))
{
@ -109,7 +109,7 @@ private:
}
}
else if(fileBuf && bufSize > 0)
dStrcpy(fileBuf, filename);
dStrcpy(fileBuf, filename, bufSize);
// Try and write to the file
Stream * stream = zip->openFile(fileBuf ? fileBuf : filename, ZipArchive::Write);