Changes for Linux.

This commit is contained in:
LuisAntonRebollo 2015-01-18 21:35:11 +01:00
parent aa35157eef
commit 3336bffad2
30 changed files with 99 additions and 173 deletions

View file

@ -391,9 +391,9 @@ void dPrintf(const char *format, ...)
vprintf(format, args);
}
S32 dVprintf(const char *format, void *arglist)
S32 dVprintf(const char *format, va_list arglist)
{
return vprintf(format, (char*)arglist);
return (S32)vprintf(format, arglist);
}
S32 dSprintf(char *buffer, U32 bufferSize, const char *format, ...)
@ -409,9 +409,9 @@ S32 dSprintf(char *buffer, U32 bufferSize, const char *format, ...)
}
S32 dVsprintf(char *buffer, U32 bufferSize, const char *format, void *arglist)
S32 dVsprintf(char *buffer, U32 bufferSize, const char *format, va_list arglist)
{
S32 len = vsnprintf(buffer, bufferSize, format, (char*)arglist);
S32 len = vsnprintf(buffer, bufferSize, format, arglist);
AssertWarn( len < bufferSize, "Buffer too small in call to dVsprintf!" );

View file

@ -26,6 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <cstdarg>
#ifndef _TORQUE_TYPES_H_
#include "platform/types.h"
@ -229,9 +230,9 @@ int dItoa(int n, char s[]);
// standard I/O functions [defined in platformString.cpp]
extern void dPrintf(const char *format, ...);
extern S32 dVprintf(const char *format, void *arglist);
extern S32 dVprintf(const char *format, va_list arglist);
extern S32 dSprintf(char *buffer, U32 bufferSize, const char *format, ...);
extern S32 dVsprintf(char *buffer, U32 bufferSize, const char *format, void *arglist);
extern S32 dVsprintf(char *buffer, U32 bufferSize, const char *format, va_list arglist);
extern S32 dSscanf(const char *buffer, const char *format, ...);
#endif

View file

@ -1434,19 +1434,19 @@ String::StrFormat::~StrFormat()
dFree( _dynamicBuffer );
}
S32 String::StrFormat::format( const char *format, void *args )
S32 String::StrFormat::format( const char *format, va_list args )
{
_len=0;
return formatAppend(format,args);
}
S32 String::StrFormat::formatAppend( const char *format, void *args )
S32 String::StrFormat::formatAppend( const char *format, va_list args )
{
// Format into the fixed buffer first.
S32 startLen = _len;
if (_dynamicBuffer == NULL)
{
_len += vsnprintf(_fixedBuffer + _len, sizeof(_fixedBuffer) - _len, format, *(va_list*)args);
_len += vsnprintf(_fixedBuffer + _len, sizeof(_fixedBuffer) - _len, format, args);
if (_len >= 0 && _len < sizeof(_fixedBuffer))
return _len;
@ -1535,9 +1535,9 @@ String String::ToString(const char *str, ...)
return ret;
}
String String::VToString(const char* str, void* args)
String String::VToString(const char* str, va_list args)
{
StrFormat format(str,&args);
StrFormat format(str,args);
// Copy it into a string
U32 len = format.length();

View file

@ -176,7 +176,7 @@ public:
/// @{
static String ToString(const char *format, ...);
static String VToString(const char* format, void* args);
static String VToString(const char* format, va_list args);
static String ToString( bool v );
static inline String ToString( U32 v ) { return ToString( "%u", v ); }
@ -245,7 +245,7 @@ public:
_fixedBuffer[0] = '\0';
}
StrFormat(const char *formatStr, void *args)
StrFormat(const char *formatStr, va_list args)
: _dynamicBuffer( NULL ),
_dynamicSize( 0 ),
_len( 0 )
@ -255,8 +255,8 @@ public:
~StrFormat();
S32 format( const char *format, void *args );
S32 formatAppend( const char *format, void *args );
S32 format( const char *format, va_list args );
S32 formatAppend( const char *format, va_list args );
S32 append(const char * str, S32 len);
S32 append(const char * str);
@ -357,7 +357,7 @@ class StringBuilder
{
va_list args;
va_start(args, fmt);
return mFormat.formatAppend(fmt, &args);
return mFormat.formatAppend(fmt, args);
}
};