1
0
forked from 0ad/0ad

add missing vswprintf_s for non-Windows platforms

This was SVN commit r7060.
This commit is contained in:
janwas 2009-08-01 12:14:39 +00:00
parent 4d1ad62e81
commit 46c437ad50
2 changed files with 20 additions and 9 deletions

View File

@ -52,8 +52,9 @@ ERROR_ASSOCIATE(ERR::STRING_NOT_TERMINATED, "Invalid string (no 0 terminator fou
# define tcat_s wcscat_s
# define tcmp wcscmp
# define tcpy wcscpy
# define tprintf_s swprintf_s
# define vtnprintf vswprintf // private
# define tvsnprintf vswprintf // used by implementation
# define tvsprintf_s vswprintf_s
# define tsprintf_s swprintf_s
#else
# define tchar char
# define T(string_literal) string_literal
@ -64,8 +65,9 @@ ERROR_ASSOCIATE(ERR::STRING_NOT_TERMINATED, "Invalid string (no 0 terminator fou
# define tcat_s strcat_s
# define tcmp strcmp
# define tcpy strcpy
# define tprintf_s sprintf_s
# define vtnprintf vsnprintf // private
# define tvsnprintf vsnprintf // used by implementation
# define tvsprintf_s vsprintf_s
# define tsprintf_s sprintf_s
#endif // #ifdef WSECURE_CRT
@ -216,15 +218,22 @@ int tcat_s(tchar* dst, size_t max_dst_chars, const tchar* src)
}
int tprintf_s(tchar* buf, size_t max_chars, const tchar* fmt, ...)
int tvsprintf_s(tchar* dst, size_t max_dst_chars, const tchar* fmt, va_list ap)
{
va_list args;
va_start(args, fmt);
int len = vtnprintf(buf, max_chars, fmt, args);
va_end(args);
return tvsnprintf(dst, max_dst_chars, fmt, ap);
}
int tsprintf_s(tchar* buf, size_t max_chars, const tchar* fmt, ...)
{
va_list ap;
va_start(ap, fmt);
int len = tvsprintf_s(buf, max_chars, fmt, ap);
va_end(ap);
return len;
}
// note: there is no portable wfopen, so we need separate implementations
// of tfopen_s. (the Unicode version just converts to UTF8)
#if defined(WSECURE_CRT)

View File

@ -83,6 +83,8 @@ extern int wcsncat_s(wchar_t* dst, size_t max_dst_chars, const wchar_t* src, siz
extern int strcat_s(char* dst, size_t max_dst_chars, const char* src);
extern int wcscat_s(wchar_t* dst, size_t max_dst_chars, const wchar_t* src);
extern int vsprintf_s(char* dst, size_t max_dst_chars, const char* fmt, va_list ap);
extern int vswprintf_s(wchar_t* dst, size_t max_dst_chars, const wchar_t* fmt, va_list ap);
extern int sprintf_s(char* buf, size_t max_chars, const char* fmt, ...);
extern int swprintf_s(wchar_t* buf, size_t max_chars, const wchar_t* fmt, ...);