return badTime;
#ifdef FEATURE_PAL
- int length = _snwprintf(buff, buffLen, W("%02d:%02d:%02d"), systemTime.wHour, systemTime.wMinute, systemTime.wSecond);
+ int length = _snwprintf_s(buff, buffLen, _TRUNCATE, W("%02d:%02d:%02d"), systemTime.wHour, systemTime.wMinute, systemTime.wSecond);
if (length <= 0)
return badTime;
#else // FEATURE_PAL
const char *timeStr = "";
#endif // FEATURE_PAL
- const char *logEntryFmtStr = "%s - %s [%s:%d] - %s - %s\r\n";
- size_t logEntryBuffSize = _snprintf(nullptr, 0, logEntryFmtStr,
- timeStr, function, file, line, logLevelStr, fullMsg) + 1;
+ const char logEntryFmtStr[] = "%s - %s [%s:%d] - %s - %s\r\n";
+ size_t logEntryBuffSize = sizeof(logEntryFmtStr) + strlen(timeStr) + strlen(function) +
+ strlen(file) + 10 + strlen(logLevelStr) + strlen(fullMsg);
char *logEntry = new char[logEntryBuffSize];
sprintf_s(logEntry, logEntryBuffSize, logEntryFmtStr,
const size_t minInstrBytes = 7;
size_t instrBytes = max(instrSize, minInstrBytes);
- size_t buffSize = _snprintf(nullptr, 0, "%p %s\n", (void*)((size_t)originalAddr+offset), instrMnemonic) + 3 * instrBytes + 1;
+ size_t buffSize = sizeof("%p %s\n") + 10 + count + 3 * instrBytes + 1;
char *buff = new char[buffSize];
int written = 0;
written += sprintf_s(buff, buffSize, "%p ", (void*)((size_t)originalAddr+offset));
LPCWSTR wszStubManagerName = pStubManager->GetStubManagerName(TO_TADDR(address));
_ASSERTE(wszStubManagerName != NULL);
- HRESULT hr = StringCchPrintfW(
+ int result = _snwprintf_s(
symbolBuf,
bufLen,
+ _TRUNCATE,
s_wszFormatNameWithStubManager,
wszStubManagerName, // Arg 1 = stub name
TO_TADDR(address)); // Arg 2 = stub hex address
- if (hr == S_OK)
+ if (result != -1)
{
// Printf succeeded, so we have an exact char count to return
if (symbolLen)
// XXX Microsoft - Should this case have a more specific name?
static WCHAR s_wszFormatNameAddressOnly[] = W("CLRStub@%I64x");
- HRESULT hr = StringCchPrintfW(
+ int result = _snwprintf_s(
symbolBuf,
bufLen,
+ _TRUNCATE,
s_wszFormatNameAddressOnly,
TO_TADDR(address));
- if (hr == S_OK)
+ if (result != -1)
{
// Printf succeeded, so we have an exact char count to return
if (symbolLen)
_wcsicmp
_stricmp
-_snprintf
-_snwprintf
-_vsnwprintf
+sprintf_s
+swprintf_s
+_snwprintf_s
+_vsnprintf_s
+_vsnwprintf_s
_itow_s
_i64tow_s
memcpy_s
_ZN25NativeExceptionHolderBaseC2Ev
_ZN25NativeExceptionHolderBaseD2Ev
_ZN28CatchHardwareExceptionHolderC1Ev
-_ZN28CatchHardwareExceptionHolderD1Ev
\ No newline at end of file
+_ZN28CatchHardwareExceptionHolderD1Ev
for(iFile = 0; iFile < NumDeltaFiles; iFile++)
{
wcscpy_s(wzNewOutputFilename,MAX_FILENAME_LENGTH+16,wzOutputFilename);
- exitval = (int)StringCchPrintfW(&wzNewOutputFilename[wcslen(wzNewOutputFilename)], 32,
+ exitval = _snwprintf_s(&wzNewOutputFilename[wcslen(wzNewOutputFilename)], 32, _TRUNCATE,
W(".%d"),iFile+1);
MakeProperSourceFileName(pwzDeltaFiles[iFile], uCodePage, wzInputFilename, szInputFilename);
if(pAsm->m_fReportProgress)
else
{
// The resource ID wasn't found in our array. Fall back on returning the ID as a string.
- len = _snwprintf(szBuffer, iMax - 1, W("[Undefined resource string ID:0x%X]"), iResourceID);
- if ((len < 0) || (len == (iMax - 1)))
- {
- // Add string terminator if the result of _snwprintf didn't fit the buffer.
- szBuffer[iMax - 1] = W('\0');
+ len = _snwprintf_s(szBuffer, iMax, _TRUNCATE, W("[Undefined resource string ID:0x%X]"), iResourceID);
+ if (len < 0)
+ {
+ // The only possible failure is that that string didn't fit the buffer. So the buffer contains
+ // partial string terminated by '\0'
len = iMax - 1;
}
}
extern int _snprintf_s( char *string, size_t sizeInBytes, size_t count, const char *format, ... );
extern int _snwprintf_s( WCHAR *string, size_t sizeInWords, size_t count, const WCHAR *format, ... );
-extern int _vsprintf_s( char* string, size_t sizeInBytes, const char* format, va_list arglist );
+extern int vsprintf_s( char* string, size_t sizeInBytes, const char* format, va_list arglist );
extern int _vsnprintf_s( char* string, size_t sizeInBytes, size_t count, const char* format, va_list arglist );
-extern int _vswprintf_s( WCHAR* string, size_t sizeInWords, const WCHAR* format, va_list arglist );
+extern int vswprintf_s( WCHAR* string, size_t sizeInWords, const WCHAR* format, va_list arglist );
extern int _vsnwprintf_s( WCHAR* string, size_t sizeInWords, size_t count, const WCHAR* format, va_list arglist );
extern int sscanf_s( const char *string, const char *format, ... );
#endif // PAL_STDCPP_COMPAT
+/* _TRUNCATE */
+#if !defined(_TRUNCATE)
+#define _TRUNCATE ((size_t)-1)
+#endif
+
PALIMPORT errno_t __cdecl memcpy_s(void *, size_t, const void *, size_t);
PALIMPORT errno_t __cdecl memmove_s(void *, size_t, const void *, size_t);
PALIMPORT char * __cdecl _strlwr(char *);
PALIMPORT int __cdecl _stricmp(const char *, const char *);
-PALIMPORT int __cdecl _snprintf(char *, size_t, const char *, ...);
+PALIMPORT int __cdecl vsprintf_s(char *, size_t, const char *, va_list);
PALIMPORT char * __cdecl _gcvt_s(char *, int, double, int);
PALIMPORT char * __cdecl _ecvt(double, int, int *, int *);
PALIMPORT int __cdecl __iscsym(int);
PALIMPORT int __cdecl _wcsicmp(const WCHAR *, const WCHAR*);
PALIMPORT int __cdecl _wcsnicmp(const WCHAR *, const WCHAR *, size_t);
PALIMPORT int __cdecl _vsnprintf(char *, size_t, const char *, va_list);
-PALIMPORT int __cdecl _vsnwprintf(WCHAR *, size_t, const WCHAR *, va_list);
+PALIMPORT int __cdecl _vsnprintf_s(char *, size_t, size_t, const char *, va_list);
+PALIMPORT int __cdecl _vsnwprintf_s(WCHAR *, size_t, size_t, const WCHAR *, va_list);
+PALIMPORT int __cdecl _snwprintf_s(WCHAR *, size_t, size_t, const WCHAR *, ...);
+PALIMPORT int __cdecl _snprintf_s(char *, size_t, size_t, const char *, ...);
+PALIMPORT int __cdecl sprintf_s(char *, size_t, const char *, ... );
+PALIMPORT int __cdecl swprintf_s(WCHAR *, size_t, const WCHAR *, ... );
+PALIMPORT int __cdecl _snwprintf_s(WCHAR *, size_t, size_t, const WCHAR *, ...);
+PALIMPORT int __cdecl vswprintf_s( WCHAR *, size_t, const WCHAR *, va_list);
PALIMPORT errno_t __cdecl _itow_s(int, WCHAR *, size_t, int);
PALIMPORT size_t __cdecl PAL_wcslen(const WCHAR *);
PALIMPORT int __cdecl PAL_swprintf(WCHAR *, const WCHAR *, ...);
PALIMPORT int __cdecl PAL_vswprintf(WCHAR *, const WCHAR *, va_list);
PALIMPORT int __cdecl PAL__vsnprintf(LPSTR Buffer, size_t Count, LPCSTR Format, va_list ap);
-PALIMPORT int __cdecl _snwprintf(WCHAR *, size_t, const WCHAR *, ...);
PALIMPORT int __cdecl PAL_swscanf(const WCHAR *, const WCHAR *, ...);
PALIMPORT LONG __cdecl PAL_wcstol(const WCHAR *, WCHAR **, int);
PALIMPORT ULONG __cdecl PAL_wcstoul(const WCHAR *, WCHAR **, int);
#define lstrcmpW PAL_wcscmp
#define lstrcmpiW _wcsicmp
-#define wnsprintfW _snwprintf // note: not 100% compatible (wsprintf should be subset of sprintf...)
-#define wvnsprintfW _vsnwprintf // note: not 100% compatible (wsprintf should be subset of sprintf...)
#ifdef UNICODE
#define StrCpy StrCpyW
#define lstrcmp lstrcmpW
#define lstrcmpi lstrcmpiW
-#define wnsprintf wnsprintfW
#endif
*/
#define _wcslwr_s _wcslwr_unsafe
-#define _snwprintf_s _snwprintf_unsafe
-#define _vsnwprintf_s _vsnwprintf_unsafe
#define _snprintf_s _snprintf_unsafe
-#define _vsnprintf_s _vsnprintf_unsafe
#define swscanf_s swscanf
#define sscanf_s sscanf
#define _strlwr_s _strlwr_unsafe
#define _vscprintf _vscprintf_unsafe
-#define _vscwprintf _vscwprintf_unsafe
-#define sprintf_s _snprintf
-#define swprintf_s _snwprintf
#define vsprintf_s _vsnprintf
-#define vswprintf_s _vsnwprintf
extern "C++" {
}
}
-inline int __cdecl _vscwprintf_unsafe(const WCHAR *_Format, va_list _ArgList)
-{
- int guess = 256;
-
- for (;;)
- {
- WCHAR *buf = (WCHAR *)malloc(guess * sizeof(WCHAR));
- if (buf == nullptr)
- return 0;
-
- va_list apcopy;
- va_copy(apcopy, _ArgList);
- int ret = _vsnwprintf(buf, guess, _Format, apcopy);
- free(buf);
- va_end(apcopy);
-
- if ((ret != -1) && (ret < guess))
- return ret;
-
- guess *= 2;
- }
-}
-
-inline int __cdecl _vsnwprintf_unsafe(WCHAR *_Dst, size_t _SizeInWords, size_t _Count, const WCHAR *_Format, va_list _ArgList)
-{
- if (_Count == _TRUNCATE) _Count = _SizeInWords - 1;
- int ret = _vsnwprintf(_Dst, _Count, _Format, _ArgList);
- _Dst[_SizeInWords - 1] = L'\0';
- if (ret < 0 && errno == 0)
- {
- errno = ERANGE;
- }
- return ret;
-}
-
-inline int __cdecl _snwprintf_unsafe(WCHAR *_Dst, size_t _SizeInWords, size_t _Count, const WCHAR *_Format, ...)
-{
- int ret;
- va_list _ArgList;
- va_start(_ArgList, _Format);
- ret = _vsnwprintf_unsafe(_Dst, _SizeInWords, _Count, _Format, _ArgList);
- va_end(_ArgList);
- return ret;
-}
-
inline int __cdecl _vsnprintf_unsafe(char *_Dst, size_t _SizeInWords, size_t _Count, const char *_Format, va_list _ArgList)
{
if (_Count == _TRUNCATE) _Count = _SizeInWords - 1;
#define _tmakepath_s _makepath_s
#define _tsplitpath_s _splitpath_s
#define _stprintf_s sprintf_s
-#define _vstprintf_s vsprintf_s
#define _sntprintf_s _snprintf_s
#define _vsntprintf_s _vsnprintf_s
#define _tscanf_s scanf_s
#define _tmakepath_s _wmakepath_s
#define _tsplitpath_s _wsplitpath_s
#define _stprintf_s swprintf_s
-#define _vstprintf_s vswprintf_s
-#define _sntprintf_s _snwprintf_s
#define _vsntprintf_s _vsnwprintf_s
#define _tscanf_s wscanf_s
#define _tsscanf_s swscanf_s
#define _tmakepath_s _makepath_s
#define _tsplitpath_s _splitpath_s
#define _stprintf_s sprintf_s
-#define _vstprintf_s vsprintf_s
#define _sntprintf_s _snprintf_s
-#define _vsntprintf_s _vsnprintf_s
#define _tscanf_s scanf_s
#define _tsscanf_s sscanf_s
#define _tsnscanf_s _snscanf_s
#if defined(__cplusplus) && _SAFECRT_USE_CPP_OVERLOADS
template <size_t _SizeInWords>
inline
-int __cdecl swprintf_s(char (&_Dst)[_SizeInWords], const char *_Format, ...)
+int __cdecl swprintf_s(WCHAR (&_Dst)[_SizeInWords], const WCHAR *_Format, ...)
{
int ret;
va_list _ArgList;
template <size_t _SizeInWords>
inline
-int __cdecl vswprintf_s(char (&_Dst)[_SizeInWords], const char *_Format, va_list _ArgList)
+int __cdecl vswprintf_s(WCHAR (&_Dst)[_SizeInWords], const WCHAR *_Format, va_list _ArgList)
{
return vswprintf_s(_Dst, _SizeInWords, _Format, _ArgList);
}
/* _snwprintf_s, _vsnwprintf_s */
_SAFECRT__EXTERN_C
-int __cdecl _snwprintf_s(WCHAR *_Dst, size_t _SizeInWords, size_t _Count, const WCHAR *_Format, ...);
-_SAFECRT__EXTERN_C
int __cdecl _vsnwprintf_s(WCHAR *_Dst, size_t _SizeInWords, size_t _Count, const WCHAR *_Format, va_list _ArgList);
#if defined(__cplusplus) && _SAFECRT_USE_CPP_OVERLOADS
template <size_t _SizeInWords>
inline
-int __cdecl _snwprintf_s(char (&_Dst)[_SizeInWords], size_t _Count, const char *_Format, ...)
+int __cdecl _snwprintf_s(WCHAR (&_Dst)[_SizeInWords], size_t _Count, const WCHAR *_Format, ...)
{
int ret;
va_list _ArgList;
#define _vsnprintf vsnprintf
#endif // defined(PLATFORM_UNIX) && !defined (FEATURE_PAL)
-#include <stdio.h> // for _vsnprintf, _vsnwprintf, getc, getwc
+#include <stdio.h> // for _vsnprintf, getc, getwc
#include <string.h> // for memset
#include <stdarg.h> // for va_start, etc.
STRSAFEAPI StringCatNWorkerW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc, size_t cchMaxAppend);
STRSAFEAPI StringCatNExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, size_t cchMaxAppend, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags);
STRSAFEAPI StringCatNExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, const WCHAR* pszSrc, size_t cchMaxAppend, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags);
-STRSAFEAPI StringVPrintfWorkerA(char* pszDest, size_t cchDest, const char* pszFormat, va_list argList);
-STRSAFEAPI StringVPrintfWorkerW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszFormat, va_list argList);
-STRSAFEAPI StringVPrintfExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const char* pszFormat, va_list argList);
-STRSAFEAPI StringVPrintfExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const WCHAR* pszFormat, va_list argList);
STRSAFEAPI StringLengthWorkerA(const char* psz, size_t cchMax, size_t* pcch);
STRSAFEAPI StringLengthWorkerW(const WCHAR* psz, size_t cchMax, size_t* pcch);
#endif // STRSAFE_INLINE
#ifndef STRSAFE_NO_CCH_FUNCTIONS
/*++
-STDAPI StringCchVPrintf(LPTSTR pszDest,
- size_t cchDest,
- LPCTSTR pszFormat,
- va_list argList);
-
-Routine Description:
-
- This routine is a safer version of the C built-in function 'vsprintf'.
- The size of the destination buffer (in characters) is a parameter and
- this function will not write past the end of this buffer and it will
- ALWAYS null terminate the destination buffer (unless it is zero length).
-
- This function returns a hresult, and not a pointer. It returns a S_OK
- if the string was printed without truncation and null terminated, otherwise
- it will return a failure code. In failure cases it will return a truncated
- version of the ideal result.
-
-Arguments:
-
- pszDest - destination string
-
- cchDest - size of destination buffer in characters
- length must be sufficient to hold the resulting formatted
- string, including the null terminator.
-
- pszFormat - format string which must be null terminated
-
- argList - va_list from the variable arguments according to the
- stdarg.h convention
-
-Notes:
- Behavior is undefined if destination, format strings or any arguments
- strings overlap.
-
- pszDest and pszFormat should not be NULL. See StringCchVPrintfEx if you
- require the handling of NULL values.
-
-Return Value:
-
- S_OK - if there was sufficient space in the dest buffer for
- the resultant string and it was null terminated.
-
- failure - you can use the macro HRESULT_CODE() to get a win32 error
- code for all falure cases
-
- STRSAFE_E_INSUFFICIENT_BUFFER /
- HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER
- - this return value is an indication that the print operation
- failed due to insufficient space. When this error occurs,
- the destination buffer is modified to contain a truncated
- version of the ideal result and is null terminated. This
- is useful for situations where truncation is ok.
-
- It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the
- return value of this function
-
---*/
-
-STRSAFEAPI StringCchVPrintfA(char* pszDest, size_t cchDest, const char* pszFormat, va_list argList);
-STRSAFEAPI StringCchVPrintfW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszFormat, va_list argList);
-#ifdef UNICODE
-#define StringCchVPrintf StringCchVPrintfW
-#else
-#define StringCchVPrintf StringCchVPrintfA
-#endif // !UNICODE
-
-#ifdef STRSAFE_INLINE
-STRSAFEAPI StringCchVPrintfA(char* pszDest, size_t cchDest, const char* pszFormat, va_list argList)
-{
- HRESULT hr;
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringVPrintfWorkerA(pszDest, cchDest, pszFormat, argList);
- }
-
- return hr;
-}
-
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFEAPI StringCchVPrintfW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszFormat, va_list argList)
-{
- HRESULT hr;
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringVPrintfWorkerW(pszDest, cchDest, pszFormat, argList);
- }
-
- return hr;
-}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
-#endif // STRSAFE_INLINE
-#endif // !STRSAFE_NO_CCH_FUNCTIONS
-
-
-#ifndef STRSAFE_NO_CB_FUNCTIONS
-/*++
-
-STDAPI StringCbVPrintf(LPTSTR pszDest,
- size_t cbDest,
- LPCTSTR pszFormat,
- va_list argList);
-
-Routine Description:
-
- This routine is a safer version of the C built-in function 'vsprintf'.
- The size of the destination buffer (in bytes) is a parameter and
- this function will not write past the end of this buffer and it will
- ALWAYS null terminate the destination buffer (unless it is zero length).
-
- This function returns a hresult, and not a pointer. It returns a S_OK
- if the string was printed without truncation and null terminated, otherwise
- it will return a failure code. In failure cases it will return a truncated
- version of the ideal result.
-
-Arguments:
-
- pszDest - destination string
-
- cbDest - size of destination buffer in bytes
- length must be sufficient to hold the resulting formatted
- string, including the null terminator.
-
- pszFormat - format string which must be null terminated
-
- argList - va_list from the variable arguments according to the
- stdarg.h convention
-
-Notes:
- Behavior is undefined if destination, format strings or any arguments
- strings overlap.
-
- pszDest and pszFormat should not be NULL. See StringCbVPrintfEx if you
- require the handling of NULL values.
-
-
-Return Value:
-
- S_OK - if there was sufficient space in the dest buffer for
- the resultant string and it was null terminated.
-
- failure - you can use the macro HRESULT_CODE() to get a win32 error
- code for all falure cases
-
- STRSAFE_E_INSUFFICIENT_BUFFER /
- HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER
- - this return value is an indication that the print operation
- failed due to insufficient space. When this error occurs,
- the destination buffer is modified to contain a truncated
- version of the ideal result and is null terminated. This
- is useful for situations where truncation is ok.
-
- It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the
- return value of this function
-
---*/
-
-STRSAFEAPI StringCbVPrintfA(char* pszDest, size_t cbDest, const char* pszFormat, va_list argList);
-STRSAFEAPI StringCbVPrintfW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszFormat, va_list argList);
-#ifdef UNICODE
-#define StringCbVPrintf StringCbVPrintfW
-#else
-#define StringCbVPrintf StringCbVPrintfA
-#endif // !UNICODE
-
-#ifdef STRSAFE_INLINE
-STRSAFEAPI StringCbVPrintfA(char* pszDest, size_t cbDest, const char* pszFormat, va_list argList)
-{
- HRESULT hr;
- size_t cchDest;
-
- cchDest = cbDest / sizeof(char);
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringVPrintfWorkerA(pszDest, cchDest, pszFormat, argList);
- }
-
- return hr;
-}
-
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFEAPI StringCbVPrintfW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszFormat, va_list argList)
-{
- HRESULT hr;
- size_t cchDest;
-
- cchDest = cbDest / sizeof(WCHAR);
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringVPrintfWorkerW(pszDest, cchDest, pszFormat, argList);
- }
-
- return hr;
-}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
-#endif // STRSAFE_INLINE
-#endif // !STRSAFE_NO_CB_FUNCTIONS
-
-
-#ifndef STRSAFE_NO_CCH_FUNCTIONS
-/*++
-
-STDAPI StringCchPrintf(LPTSTR pszDest,
- size_t cchDest,
- LPCTSTR pszFormat,
- ...);
-
-Routine Description:
-
- This routine is a safer version of the C built-in function 'sprintf'.
- The size of the destination buffer (in characters) is a parameter and
- this function will not write past the end of this buffer and it will
- ALWAYS null terminate the destination buffer (unless it is zero length).
-
- This function returns a hresult, and not a pointer. It returns a S_OK
- if the string was printed without truncation and null terminated, otherwise
- it will return a failure code. In failure cases it will return a truncated
- version of the ideal result.
-
-Arguments:
-
- pszDest - destination string
-
- cchDest - size of destination buffer in characters
- length must be sufficient to hold the resulting formatted
- string, including the null terminator.
-
- pszFormat - format string which must be null terminated
-
- ... - additional parameters to be formatted according to
- the format string
-
-Notes:
- Behavior is undefined if destination, format strings or any arguments
- strings overlap.
-
- pszDest and pszFormat should not be NULL. See StringCchPrintfEx if you
- require the handling of NULL values.
-
-Return Value:
-
- S_OK - if there was sufficient space in the dest buffer for
- the resultant string and it was null terminated.
-
- failure - you can use the macro HRESULT_CODE() to get a win32 error
- code for all falure cases
-
- STRSAFE_E_INSUFFICIENT_BUFFER /
- HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER
- - this return value is an indication that the print operation
- failed due to insufficient space. When this error occurs,
- the destination buffer is modified to contain a truncated
- version of the ideal result and is null terminated. This
- is useful for situations where truncation is ok.
-
- It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the
- return value of this function
-
---*/
-
-STRSAFEAPI StringCchPrintfA(char* pszDest, size_t cchDest, const char* pszFormat, ...);
-STRSAFEAPI StringCchPrintfW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszFormat, ...);
-#ifdef UNICODE
-#define StringCchPrintf StringCchPrintfW
-#else
-#define StringCchPrintf StringCchPrintfA
-#endif // !UNICODE
-
-#ifdef STRSAFE_INLINE
-STRSAFEAPI StringCchPrintfA(char* pszDest, size_t cchDest, const char* pszFormat, ...)
-{
- HRESULT hr;
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- va_list argList;
-
- va_start(argList, pszFormat);
-
- hr = StringVPrintfWorkerA(pszDest, cchDest, pszFormat, argList);
-
- va_end(argList);
- }
-
- return hr;
-}
-
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFEAPI StringCchPrintfW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszFormat, ...)
-{
- HRESULT hr;
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- va_list argList;
-
- va_start(argList, pszFormat);
-
- hr = StringVPrintfWorkerW(pszDest, cchDest, pszFormat, argList);
-
- va_end(argList);
- }
-
- return hr;
-}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
-#endif // STRSAFE_INLINE
-#endif // !STRSAFE_NO_CCH_FUNCTIONS
-
-
-#ifndef STRSAFE_NO_CB_FUNCTIONS
-/*++
-
-STDAPI StringCbPrintf(LPTSTR pszDest,
- size_t cbDest,
- LPCTSTR pszFormat,
- ...);
-
-Routine Description:
-
- This routine is a safer version of the C built-in function 'sprintf'.
- The size of the destination buffer (in bytes) is a parameter and
- this function will not write past the end of this buffer and it will
- ALWAYS null terminate the destination buffer (unless it is zero length).
-
- This function returns a hresult, and not a pointer. It returns a S_OK
- if the string was printed without truncation and null terminated, otherwise
- it will return a failure code. In failure cases it will return a truncated
- version of the ideal result.
-
-Arguments:
-
- pszDest - destination string
-
- cbDest - size of destination buffer in bytes
- length must be sufficient to hold the resulting formatted
- string, including the null terminator.
-
- pszFormat - format string which must be null terminated
-
- ... - additional parameters to be formatted according to
- the format string
-
-Notes:
- Behavior is undefined if destination, format strings or any arguments
- strings overlap.
-
- pszDest and pszFormat should not be NULL. See StringCbPrintfEx if you
- require the handling of NULL values.
-
-
-Return Value:
-
- S_OK - if there was sufficient space in the dest buffer for
- the resultant string and it was null terminated.
-
- failure - you can use the macro HRESULT_CODE() to get a win32 error
- code for all falure cases
-
- STRSAFE_E_INSUFFICIENT_BUFFER /
- HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER
- - this return value is an indication that the print operation
- failed due to insufficient space. When this error occurs,
- the destination buffer is modified to contain a truncated
- version of the ideal result and is null terminated. This
- is useful for situations where truncation is ok.
-
- It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the
- return value of this function
-
---*/
-
-STRSAFEAPI StringCbPrintfA(char* pszDest, size_t cbDest, const char* pszFormat, ...);
-STRSAFEAPI StringCbPrintfW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszFormat, ...);
-#ifdef UNICODE
-#define StringCbPrintf StringCbPrintfW
-#else
-#define StringCbPrintf StringCbPrintfA
-#endif // !UNICODE
-
-#ifdef STRSAFE_INLINE
-STRSAFEAPI StringCbPrintfA(char* pszDest, size_t cbDest, const char* pszFormat, ...)
-{
- HRESULT hr;
- size_t cchDest;
-
- cchDest = cbDest / sizeof(char);
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- va_list argList;
-
- va_start(argList, pszFormat);
-
- hr = StringVPrintfWorkerA(pszDest, cchDest, pszFormat, argList);
-
- va_end(argList);
- }
-
- return hr;
-}
-
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFEAPI StringCbPrintfW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszFormat, ...)
-{
- HRESULT hr;
- size_t cchDest;
-
- cchDest = cbDest / sizeof(WCHAR);
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- va_list argList;
-
- va_start(argList, pszFormat);
-
- hr = StringVPrintfWorkerW(pszDest, cchDest, pszFormat, argList);
-
- va_end(argList);
- }
-
- return hr;
-}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
-#endif // STRSAFE_INLINE
-#endif // !STRSAFE_NO_CB_FUNCTIONS
-
-
-#ifndef STRSAFE_NO_CCH_FUNCTIONS
-/*++
-
-STDAPI StringCchPrintfEx(LPTSTR pszDest,
- size_t cchDest,
- LPTSTR* ppszDestEnd,
- size_t* pcchRemaining,
- DWORD dwFlags,
- LPCTSTR pszFormat,
- ...);
-
-Routine Description:
-
- This routine is a safer version of the C built-in function 'sprintf' with
- some additional parameters. In addition to functionality provided by
- StringCchPrintf, this routine also returns a pointer to the end of the
- destination string and the number of characters left in the destination string
- including the null terminator. The flags parameter allows additional controls.
-
-Arguments:
-
- pszDest - destination string
-
- cchDest - size of destination buffer in characters.
- length must be sufficient to contain the resulting
- formatted string plus the null terminator.
-
- ppszDestEnd - if ppszDestEnd is non-null, the function will return a
- pointer to the end of the destination string. If the
- function printed any data, the result will point to the
- null termination character
-
- pcchRemaining - if pcchRemaining is non-null, the function will return
- the number of characters left in the destination string,
- including the null terminator
-
- dwFlags - controls some details of the string copy:
-
- STRSAFE_FILL_BEHIND_NULL
- if the function succeeds, the low byte of dwFlags will be
- used to fill the uninitialize part of destination buffer
- behind the null terminator
-
- STRSAFE_IGNORE_NULLS
- treat NULL string pointers like empty strings (TEXT(""))
-
- STRSAFE_FILL_ON_FAILURE
- if the function fails, the low byte of dwFlags will be
- used to fill all of the destination buffer, and it will
- be null terminated. This will overwrite any truncated
- string returned when the failure is
- STRSAFE_E_INSUFFICIENT_BUFFER
-
- STRSAFE_NO_TRUNCATION /
- STRSAFE_NULL_ON_FAILURE
- if the function fails, the destination buffer will be set
- to the empty string. This will overwrite any truncated string
- returned when the failure is STRSAFE_E_INSUFFICIENT_BUFFER.
-
- pszFormat - format string which must be null terminated
-
- ... - additional parameters to be formatted according to
- the format string
-
-Notes:
- Behavior is undefined if destination, format strings or any arguments
- strings overlap.
-
- pszDest and pszFormat should not be NULL unless the STRSAFE_IGNORE_NULLS
- flag is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and
- pszFormat may be NULL. An error may still be returned even though NULLS
- are ignored due to insufficient space.
-
-Return Value:
-
- S_OK - if there was source data and it was all concatenated and the
- resultant dest string was null terminated
-
- failure - you can use the macro HRESULT_CODE() to get a win32 error
- code for all falure cases
-
- STRSAFE_E_INSUFFICIENT_BUFFER /
- HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER
- - this return value is an indication that the print operation
- failed due to insufficient space. When this error occurs,
- the destination buffer is modified to contain a truncated
- version of the ideal result and is null terminated. This
- is useful for situations where truncation is ok.
-
- It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the
- return value of this function
-
---*/
-
-STRSAFEAPI StringCchPrintfExA(char* pszDest, size_t cchDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const char* pszFormat, ...);
-STRSAFEAPI StringCchPrintfExW(WCHAR* pszDest, size_t cchDest, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const WCHAR* pszFormat, ...);
-#ifdef UNICODE
-#define StringCchPrintfEx StringCchPrintfExW
-#else
-#define StringCchPrintfEx StringCchPrintfExA
-#endif // !UNICODE
-
-#ifdef STRSAFE_INLINE
-STRSAFEAPI StringCchPrintfExA(char* pszDest, size_t cchDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const char* pszFormat, ...)
-{
- HRESULT hr;
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- size_t cbDest;
- va_list argList;
-
- // safe to multiply cchDest * sizeof(char) since cchDest < STRSAFE_MAX_CCH and sizeof(char) is 1
- cbDest = cchDest * sizeof(char);
- va_start(argList, pszFormat);
-
- hr = StringVPrintfExWorkerA(pszDest, cchDest, cbDest, ppszDestEnd, pcchRemaining, dwFlags, pszFormat, argList);
-
- va_end(argList);
- }
-
- return hr;
-}
-
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFEAPI StringCchPrintfExW(WCHAR* pszDest, size_t cchDest, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const WCHAR* pszFormat, ...)
-{
- HRESULT hr;
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- size_t cbDest;
- va_list argList;
-
- // safe to multiply cchDest * sizeof(WCHAR) since cchDest < STRSAFE_MAX_CCH and sizeof(WCHAR) is 2
- cbDest = cchDest * sizeof(WCHAR);
- va_start(argList, pszFormat);
-
- hr = StringVPrintfExWorkerW(pszDest, cchDest, cbDest, ppszDestEnd, pcchRemaining, dwFlags, pszFormat, argList);
-
- va_end(argList);
- }
-
- return hr;
-}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
-#endif // STRSAFE_INLINE
-#endif // !STRSAFE_NO_CCH_FUNCTIONS
-
-
-#ifndef STRSAFE_NO_CB_FUNCTIONS
-/*++
-
-STDAPI StringCbPrintfEx(LPTSTR pszDest,
- size_t cbDest,
- LPTSTR* ppszDestEnd,
- size_t* pcbRemaining,
- DWORD dwFlags,
- LPCTSTR pszFormat,
- ...);
-
-Routine Description:
-
- This routine is a safer version of the C built-in function 'sprintf' with
- some additional parameters. In addition to functionality provided by
- StringCbPrintf, this routine also returns a pointer to the end of the
- destination string and the number of bytes left in the destination string
- including the null terminator. The flags parameter allows additional controls.
-
-Arguments:
-
- pszDest - destination string
-
- cbDest - size of destination buffer in bytes.
- length must be sufficient to contain the resulting
- formatted string plus the null terminator.
-
- ppszDestEnd - if ppszDestEnd is non-null, the function will return a
- pointer to the end of the destination string. If the
- function printed any data, the result will point to the
- null termination character
-
- pcbRemaining - if pcbRemaining is non-null, the function will return
- the number of bytes left in the destination string,
- including the null terminator
-
- dwFlags - controls some details of the string copy:
-
- STRSAFE_FILL_BEHIND_NULL
- if the function succeeds, the low byte of dwFlags will be
- used to fill the uninitialize part of destination buffer
- behind the null terminator
-
- STRSAFE_IGNORE_NULLS
- treat NULL string pointers like empty strings (TEXT(""))
-
- STRSAFE_FILL_ON_FAILURE
- if the function fails, the low byte of dwFlags will be
- used to fill all of the destination buffer, and it will
- be null terminated. This will overwrite any truncated
- string returned when the failure is
- STRSAFE_E_INSUFFICIENT_BUFFER
-
- STRSAFE_NO_TRUNCATION /
- STRSAFE_NULL_ON_FAILURE
- if the function fails, the destination buffer will be set
- to the empty string. This will overwrite any truncated string
- returned when the failure is STRSAFE_E_INSUFFICIENT_BUFFER.
-
- pszFormat - format string which must be null terminated
-
- ... - additional parameters to be formatted according to
- the format string
-
-Notes:
- Behavior is undefined if destination, format strings or any arguments
- strings overlap.
-
- pszDest and pszFormat should not be NULL unless the STRSAFE_IGNORE_NULLS
- flag is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and
- pszFormat may be NULL. An error may still be returned even though NULLS
- are ignored due to insufficient space.
-
-Return Value:
-
- S_OK - if there was source data and it was all concatenated and the
- resultant dest string was null terminated
-
- failure - you can use the macro HRESULT_CODE() to get a win32 error
- code for all falure cases
-
- STRSAFE_E_INSUFFICIENT_BUFFER /
- HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER
- - this return value is an indication that the print operation
- failed due to insufficient space. When this error occurs,
- the destination buffer is modified to contain a truncated
- version of the ideal result and is null terminated. This
- is useful for situations where truncation is ok.
-
- It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the
- return value of this function
-
---*/
-
-STRSAFEAPI StringCbPrintfExA(char* pszDest, size_t cbDest, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const char* pszFormat, ...);
-STRSAFEAPI StringCbPrintfExW(WCHAR* pszDest, size_t cbDest, WCHAR** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const WCHAR* pszFormat, ...);
-#ifdef UNICODE
-#define StringCbPrintfEx StringCbPrintfExW
-#else
-#define StringCbPrintfEx StringCbPrintfExA
-#endif // !UNICODE
-
-#ifdef STRSAFE_INLINE
-STRSAFEAPI StringCbPrintfExA(char* pszDest, size_t cbDest, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const char* pszFormat, ...)
-{
- HRESULT hr;
- size_t cchDest;
- size_t cchRemaining = 0;
-
- cchDest = cbDest / sizeof(char);
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- va_list argList;
-
- va_start(argList, pszFormat);
-
- hr = StringVPrintfExWorkerA(pszDest, cchDest, cbDest, ppszDestEnd, &cchRemaining, dwFlags, pszFormat, argList);
-
- va_end(argList);
- }
-
- if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER))
- {
- if (pcbRemaining)
- {
- // safe to multiply cchRemaining * sizeof(char) since cchRemaining < STRSAFE_MAX_CCH and sizeof(char) is 1
- *pcbRemaining = (cchRemaining * sizeof(char)) + (cbDest % sizeof(char));
- }
- }
-
- return hr;
-}
-
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFEAPI StringCbPrintfExW(WCHAR* pszDest, size_t cbDest, WCHAR** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const WCHAR* pszFormat, ...)
-{
- HRESULT hr;
- size_t cchDest;
- size_t cchRemaining = 0;
-
- cchDest = cbDest / sizeof(WCHAR);
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- va_list argList;
-
- va_start(argList, pszFormat);
-
- hr = StringVPrintfExWorkerW(pszDest, cchDest, cbDest, ppszDestEnd, &cchRemaining, dwFlags, pszFormat, argList);
-
- va_end(argList);
- }
-
- if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER))
- {
- if (pcbRemaining)
- {
- // safe to multiply cchRemaining * sizeof(WCHAR) since cchRemaining < STRSAFE_MAX_CCH and sizeof(WCHAR) is 2
- *pcbRemaining = (cchRemaining * sizeof(WCHAR)) + (cbDest % sizeof(WCHAR));
- }
- }
-
- return hr;
-}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
-#endif // STRSAFE_INLINE
-#endif // !STRSAFE_NO_CB_FUNCTIONS
-
-
-#ifndef STRSAFE_NO_CCH_FUNCTIONS
-/*++
-
-STDAPI StringCchVPrintfEx(LPTSTR pszDest,
- size_t cchDest,
- LPTSTR* ppszDestEnd,
- size_t* pcchRemaining,
- DWORD dwFlags,
- LPCTSTR pszFormat,
- va_list argList);
-
-Routine Description:
-
- This routine is a safer version of the C built-in function 'vsprintf' with
- some additional parameters. In addition to functionality provided by
- StringCchVPrintf, this routine also returns a pointer to the end of the
- destination string and the number of characters left in the destination string
- including the null terminator. The flags parameter allows additional controls.
-
-Arguments:
-
- pszDest - destination string
-
- cchDest - size of destination buffer in characters.
- length must be sufficient to contain the resulting
- formatted string plus the null terminator.
-
- ppszDestEnd - if ppszDestEnd is non-null, the function will return a
- pointer to the end of the destination string. If the
- function printed any data, the result will point to the
- null termination character
-
- pcchRemaining - if pcchRemaining is non-null, the function will return
- the number of characters left in the destination string,
- including the null terminator
-
- dwFlags - controls some details of the string copy:
-
- STRSAFE_FILL_BEHIND_NULL
- if the function succeeds, the low byte of dwFlags will be
- used to fill the uninitialize part of destination buffer
- behind the null terminator
-
- STRSAFE_IGNORE_NULLS
- treat NULL string pointers like empty strings (TEXT(""))
-
- STRSAFE_FILL_ON_FAILURE
- if the function fails, the low byte of dwFlags will be
- used to fill all of the destination buffer, and it will
- be null terminated. This will overwrite any truncated
- string returned when the failure is
- STRSAFE_E_INSUFFICIENT_BUFFER
-
- STRSAFE_NO_TRUNCATION /
- STRSAFE_NULL_ON_FAILURE
- if the function fails, the destination buffer will be set
- to the empty string. This will overwrite any truncated string
- returned when the failure is STRSAFE_E_INSUFFICIENT_BUFFER.
-
- pszFormat - format string which must be null terminated
-
- argList - va_list from the variable arguments according to the
- stdarg.h convention
-
-Notes:
- Behavior is undefined if destination, format strings or any arguments
- strings overlap.
-
- pszDest and pszFormat should not be NULL unless the STRSAFE_IGNORE_NULLS
- flag is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and
- pszFormat may be NULL. An error may still be returned even though NULLS
- are ignored due to insufficient space.
-
-Return Value:
-
- S_OK - if there was source data and it was all concatenated and the
- resultant dest string was null terminated
-
- failure - you can use the macro HRESULT_CODE() to get a win32 error
- code for all falure cases
-
- STRSAFE_E_INSUFFICIENT_BUFFER /
- HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER
- - this return value is an indication that the print operation
- failed due to insufficient space. When this error occurs,
- the destination buffer is modified to contain a truncated
- version of the ideal result and is null terminated. This
- is useful for situations where truncation is ok.
-
- It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the
- return value of this function
-
---*/
-
-STRSAFEAPI StringCchVPrintfExA(char* pszDest, size_t cchDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const char* pszFormat, va_list argList);
-STRSAFEAPI StringCchVPrintfExW(WCHAR* pszDest, size_t cchDest, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const WCHAR* pszFormat, va_list argList);
-#ifdef UNICODE
-#define StringCchVPrintfEx StringCchVPrintfExW
-#else
-#define StringCchVPrintfEx StringCchVPrintfExA
-#endif // !UNICODE
-
-#ifdef STRSAFE_INLINE
-STRSAFEAPI StringCchVPrintfExA(char* pszDest, size_t cchDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const char* pszFormat, va_list argList)
-{
- HRESULT hr;
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- size_t cbDest;
-
- // safe to multiply cchDest * sizeof(char) since cchDest < STRSAFE_MAX_CCH and sizeof(char) is 1
- cbDest = cchDest * sizeof(char);
-
- hr = StringVPrintfExWorkerA(pszDest, cchDest, cbDest, ppszDestEnd, pcchRemaining, dwFlags, pszFormat, argList);
- }
-
- return hr;
-}
-
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFEAPI StringCchVPrintfExW(WCHAR* pszDest, size_t cchDest, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const WCHAR* pszFormat, va_list argList)
-{
- HRESULT hr;
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- size_t cbDest;
-
- // safe to multiply cchDest * sizeof(WCHAR) since cchDest < STRSAFE_MAX_CCH and sizeof(WCHAR) is 2
- cbDest = cchDest * sizeof(WCHAR);
-
- hr = StringVPrintfExWorkerW(pszDest, cchDest, cbDest, ppszDestEnd, pcchRemaining, dwFlags, pszFormat, argList);
- }
-
- return hr;
-}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
-#endif // STRSAFE_INLINE
-#endif // !STRSAFE_NO_CCH_FUNCTIONS
-
-
-#ifndef STRSAFE_NO_CB_FUNCTIONS
-/*++
-
-STDAPI StringCbVPrintfEx(LPTSTR pszDest,
- size_t cbDest,
- LPTSTR* ppszDestEnd,
- size_t* pcbRemaining,
- DWORD dwFlags,
- LPCTSTR pszFormat,
- va_list argList);
-
-Routine Description:
-
- This routine is a safer version of the C built-in function 'vsprintf' with
- some additional parameters. In addition to functionality provided by
- StringCbVPrintf, this routine also returns a pointer to the end of the
- destination string and the number of characters left in the destination string
- including the null terminator. The flags parameter allows additional controls.
-
-Arguments:
-
- pszDest - destination string
-
- cbDest - size of destination buffer in bytes.
- length must be sufficient to contain the resulting
- formatted string plus the null terminator.
-
- ppszDestEnd - if ppszDestEnd is non-null, the function will return
- a pointer to the end of the destination string. If the
- function printed any data, the result will point to the
- null termination character
-
- pcbRemaining - if pcbRemaining is non-null, the function will return
- the number of bytes left in the destination string,
- including the null terminator
-
- dwFlags - controls some details of the string copy:
-
- STRSAFE_FILL_BEHIND_NULL
- if the function succeeds, the low byte of dwFlags will be
- used to fill the uninitialize part of destination buffer
- behind the null terminator
-
- STRSAFE_IGNORE_NULLS
- treat NULL string pointers like empty strings (TEXT(""))
-
- STRSAFE_FILL_ON_FAILURE
- if the function fails, the low byte of dwFlags will be
- used to fill all of the destination buffer, and it will
- be null terminated. This will overwrite any truncated
- string returned when the failure is
- STRSAFE_E_INSUFFICIENT_BUFFER
-
- STRSAFE_NO_TRUNCATION /
- STRSAFE_NULL_ON_FAILURE
- if the function fails, the destination buffer will be set
- to the empty string. This will overwrite any truncated string
- returned when the failure is STRSAFE_E_INSUFFICIENT_BUFFER.
-
- pszFormat - format string which must be null terminated
-
- argList - va_list from the variable arguments according to the
- stdarg.h convention
-
-Notes:
- Behavior is undefined if destination, format strings or any arguments
- strings overlap.
-
- pszDest and pszFormat should not be NULL unless the STRSAFE_IGNORE_NULLS
- flag is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and
- pszFormat may be NULL. An error may still be returned even though NULLS
- are ignored due to insufficient space.
-
-Return Value:
-
- S_OK - if there was source data and it was all concatenated and the
- resultant dest string was null terminated
-
- failure - you can use the macro HRESULT_CODE() to get a win32 error
- code for all falure cases
-
- STRSAFE_E_INSUFFICIENT_BUFFER /
- HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER
- - this return value is an indication that the print operation
- failed due to insufficient space. When this error occurs,
- the destination buffer is modified to contain a truncated
- version of the ideal result and is null terminated. This
- is useful for situations where truncation is ok.
-
- It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the
- return value of this function
-
---*/
-
-STRSAFEAPI StringCbVPrintfExA(char* pszDest, size_t cbDest, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const char* pszFormat, va_list argList);
-STRSAFEAPI StringCbVPrintfExW(WCHAR* pszDest, size_t cbDest, WCHAR** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const WCHAR* pszFormat, va_list argList);
-#ifdef UNICODE
-#define StringCbVPrintfEx StringCbVPrintfExW
-#else
-#define StringCbVPrintfEx StringCbVPrintfExA
-#endif // !UNICODE
-
-#ifdef STRSAFE_INLINE
-STRSAFEAPI StringCbVPrintfExA(char* pszDest, size_t cbDest, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const char* pszFormat, va_list argList)
-{
- HRESULT hr;
- size_t cchDest;
- size_t cchRemaining = 0;
-
- cchDest = cbDest / sizeof(char);
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringVPrintfExWorkerA(pszDest, cchDest, cbDest, ppszDestEnd, &cchRemaining, dwFlags, pszFormat, argList);
- }
-
- if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER))
- {
- if (pcbRemaining)
- {
- // safe to multiply cchRemaining * sizeof(char) since cchRemaining < STRSAFE_MAX_CCH and sizeof(char) is 1
- *pcbRemaining = (cchRemaining * sizeof(char)) + (cbDest % sizeof(char));
- }
- }
-
- return hr;
-}
-
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFEAPI StringCbVPrintfExW(WCHAR* pszDest, size_t cbDest, WCHAR** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags, const WCHAR* pszFormat, va_list argList)
-{
- HRESULT hr;
- size_t cchDest;
- size_t cchRemaining = 0;
-
- cchDest = cbDest / sizeof(WCHAR);
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringVPrintfExWorkerW(pszDest, cchDest, cbDest, ppszDestEnd, &cchRemaining, dwFlags, pszFormat, argList);
- }
-
- if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER))
- {
- if (pcbRemaining)
- {
- // safe to multiply cchRemaining * sizeof(WCHAR) since cchRemaining < STRSAFE_MAX_CCH and sizeof(WCHAR) is 2
- *pcbRemaining = (cchRemaining * sizeof(WCHAR)) + (cbDest % sizeof(WCHAR));
- }
- }
-
- return hr;
-}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
-#endif // STRSAFE_INLINE
-#endif // !STRSAFE_NO_CB_FUNCTIONS
-
-
-#ifndef STRSAFE_NO_CCH_FUNCTIONS
-/*++
-
STDAPI StringCchGets(LPTSTR pszDest,
size_t cchDest);
S_OK - psz is non-null and the length including the null terminator is
less than or equal to cbMax bytes
- failure - you can use the macro HRESULT_CODE() to get a win32 error
- code for all hresult falure cases
-
- It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the
- return value of this function.
-
---*/
-
-STRSAFEAPI StringCbLengthA(const char* psz, size_t cchMax, size_t* pcch);
-STRSAFEAPI StringCbLengthW(const WCHAR* psz, size_t cchMax, size_t* pcch);
-#ifdef UNICODE
-#define StringCbLength StringCbLengthW
-#else
-#define StringCbLength StringCbLengthA
-#endif // !UNICODE
-
-#ifdef STRSAFE_INLINE
-STRSAFEAPI StringCbLengthA(const char* psz, size_t cbMax, size_t* pcb)
-{
- HRESULT hr;
- size_t cchMax;
- size_t cch = 0;
-
- cchMax = cbMax / sizeof(char);
-
- if ((psz == NULL) || (cchMax > STRSAFE_MAX_CCH))
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringLengthWorkerA(psz, cchMax, &cch);
- }
-
- if (SUCCEEDED(hr) && pcb)
- {
- // safe to multiply cch * sizeof(char) since cch < STRSAFE_MAX_CCH and sizeof(char) is 1
- *pcb = cch * sizeof(char);
- }
-
- return hr;
-}
-
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFEAPI StringCbLengthW(const WCHAR* psz, size_t cbMax, size_t* pcb)
-{
- HRESULT hr;
- size_t cchMax;
- size_t cch = 0;
-
- cchMax = cbMax / sizeof(WCHAR);
-
- if ((psz == NULL) || (cchMax > STRSAFE_MAX_CCH))
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringLengthWorkerW(psz, cchMax, &cch);
- }
-
- if (SUCCEEDED(hr) && pcb)
- {
- // safe to multiply cch * sizeof(WCHAR) since cch < STRSAFE_MAX_CCH and sizeof(WCHAR) is 2
- *pcb = cch * sizeof(WCHAR);
- }
-
- return hr;
-}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
-#endif // STRSAFE_INLINE
-#endif // !STRSAFE_NO_CB_FUNCTIONS
-
-
-// these are the worker functions that actually do the work
-#ifdef STRSAFE_INLINE
-STRSAFEAPI StringCopyWorkerA(char* pszDest, size_t cchDest, const char* pszSrc)
-{
- HRESULT hr = S_OK;
-
- if (cchDest == 0)
- {
- // can not null terminate a zero-byte dest buffer
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- while (cchDest && (*pszSrc != '\0'))
- {
- *pszDest++ = *pszSrc++;
- cchDest--;
- }
-
- if (cchDest == 0)
- {
- // we are going to truncate pszDest
- pszDest--;
- hr = STRSAFE_E_INSUFFICIENT_BUFFER;
- }
-
- *pszDest= '\0';
- }
-
- return hr;
-}
-
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFEAPI StringCopyWorkerW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc)
-{
- HRESULT hr = S_OK;
-
- if (cchDest == 0)
- {
- // can not null terminate a zero-byte dest buffer
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- while (cchDest && (*pszSrc != L'\0'))
- {
- *pszDest++ = *pszSrc++;
- cchDest--;
- }
-
- if (cchDest == 0)
- {
- // we are going to truncate pszDest
- pszDest--;
- hr = STRSAFE_E_INSUFFICIENT_BUFFER;
- }
-
- *pszDest= L'\0';
- }
-
- return hr;
-}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
-
-STRSAFEAPI StringCopyExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
-{
- HRESULT hr = S_OK;
- char* pszDestEnd = pszDest;
- size_t cchRemaining = 0;
-
- // ASSERT(cbDest == (cchDest * sizeof(char)) ||
- // cbDest == (cchDest * sizeof(char)) + (cbDest % sizeof(char)));
-
- // only accept valid flags
- if (dwFlags & (~STRSAFE_VALID_FLAGS))
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- if (dwFlags & STRSAFE_IGNORE_NULLS)
- {
- if (pszDest == NULL)
- {
- if ((cchDest != 0) || (cbDest != 0))
- {
- // NULL pszDest and non-zero cchDest/cbDest is invalid
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- }
-
- if (pszSrc == NULL)
- {
- pszSrc = "";
- }
- }
-
- if (SUCCEEDED(hr))
- {
- if (cchDest == 0)
- {
- pszDestEnd = pszDest;
- cchRemaining = 0;
-
- // only fail if there was actually src data to copy
- if (*pszSrc != '\0')
- {
- if (pszDest == NULL)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = STRSAFE_E_INSUFFICIENT_BUFFER;
- }
- }
- }
- else
- {
- pszDestEnd = pszDest;
- cchRemaining = cchDest;
-
- while (cchRemaining && (*pszSrc != '\0'))
- {
- *pszDestEnd++= *pszSrc++;
- cchRemaining--;
- }
-
- if (cchRemaining > 0)
- {
- if (dwFlags & STRSAFE_FILL_BEHIND_NULL)
- {
- memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(char)) + (cbDest % sizeof(char)));
- }
- }
- else
- {
- // we are going to truncate pszDest
- pszDestEnd--;
- cchRemaining++;
-
- hr = STRSAFE_E_INSUFFICIENT_BUFFER;
- }
-
- *pszDestEnd = '\0';
- }
- }
- }
-
- if (FAILED(hr))
- {
- if (pszDest)
- {
- if (dwFlags & STRSAFE_FILL_ON_FAILURE)
- {
- memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest);
-
- if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0)
- {
- pszDestEnd = pszDest;
- cchRemaining = cchDest;
- }
- else if (cchDest > 0)
- {
- pszDestEnd = pszDest + cchDest - 1;
- cchRemaining = 1;
-
- // null terminate the end of the string
- *pszDestEnd = '\0';
- }
- }
-
- if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION))
- {
- if (cchDest > 0)
- {
- pszDestEnd = pszDest;
- cchRemaining = cchDest;
-
- // null terminate the beginning of the string
- *pszDestEnd = '\0';
- }
- }
- }
- }
+ failure - you can use the macro HRESULT_CODE() to get a win32 error
+ code for all hresult falure cases
- if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER))
- {
- if (ppszDestEnd)
- {
- *ppszDestEnd = pszDestEnd;
- }
+ It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the
+ return value of this function.
- if (pcchRemaining)
- {
- *pcchRemaining = cchRemaining;
- }
- }
+--*/
- return hr;
-}
+STRSAFEAPI StringCbLengthA(const char* psz, size_t cchMax, size_t* pcch);
+STRSAFEAPI StringCbLengthW(const WCHAR* psz, size_t cchMax, size_t* pcch);
+#ifdef UNICODE
+#define StringCbLength StringCbLengthW
+#else
+#define StringCbLength StringCbLengthA
+#endif // !UNICODE
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFEAPI StringCopyExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, const WCHAR* pszSrc, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
+#ifdef STRSAFE_INLINE
+STRSAFEAPI StringCbLengthA(const char* psz, size_t cbMax, size_t* pcb)
{
- HRESULT hr = S_OK;
- WCHAR* pszDestEnd = pszDest;
- size_t cchRemaining = 0;
+ HRESULT hr;
+ size_t cchMax;
+ size_t cch = 0;
- // ASSERT(cbDest == (cchDest * sizeof(WCHAR)) ||
- // cbDest == (cchDest * sizeof(WCHAR)) + (cbDest % sizeof(WCHAR)));
-
- // only accept valid flags
- if (dwFlags & (~STRSAFE_VALID_FLAGS))
+ cchMax = cbMax / sizeof(char);
+
+ if ((psz == NULL) || (cchMax > STRSAFE_MAX_CCH))
{
hr = STRSAFE_E_INVALID_PARAMETER;
}
else
{
- if (dwFlags & STRSAFE_IGNORE_NULLS)
- {
- if (pszDest == NULL)
- {
- if ((cchDest != 0) || (cbDest != 0))
- {
- // NULL pszDest and non-zero cchDest/cbDest is invalid
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- }
-
- if (pszSrc == NULL)
- {
- pszSrc = u"";
- }
- }
+ hr = StringLengthWorkerA(psz, cchMax, &cch);
+ }
- if (SUCCEEDED(hr))
- {
- if (cchDest == 0)
- {
- pszDestEnd = pszDest;
- cchRemaining = 0;
+ if (SUCCEEDED(hr) && pcb)
+ {
+ // safe to multiply cch * sizeof(char) since cch < STRSAFE_MAX_CCH and sizeof(char) is 1
+ *pcb = cch * sizeof(char);
+ }
- // only fail if there was actually src data to copy
- if (*pszSrc != u'\0')
- {
- if (pszDest == NULL)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = STRSAFE_E_INSUFFICIENT_BUFFER;
- }
- }
- }
- else
- {
- pszDestEnd = pszDest;
- cchRemaining = cchDest;
+ return hr;
+}
- while (cchRemaining && (*pszSrc != u'\0'))
- {
- *pszDestEnd++= *pszSrc++;
- cchRemaining--;
- }
-
- if (cchRemaining > 0)
- {
- if (dwFlags & STRSAFE_FILL_BEHIND_NULL)
- {
- memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(WCHAR)) + (cbDest % sizeof(WCHAR)));
- }
- }
- else
- {
- // we are going to truncate pszDest
- pszDestEnd--;
- cchRemaining++;
+#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
+STRSAFEAPI StringCbLengthW(const WCHAR* psz, size_t cbMax, size_t* pcb)
+{
+ HRESULT hr;
+ size_t cchMax;
+ size_t cch = 0;
- hr = STRSAFE_E_INSUFFICIENT_BUFFER;
- }
+ cchMax = cbMax / sizeof(WCHAR);
- *pszDestEnd = u'\0';
- }
- }
+ if ((psz == NULL) || (cchMax > STRSAFE_MAX_CCH))
+ {
+ hr = STRSAFE_E_INVALID_PARAMETER;
}
-
- if (FAILED(hr))
+ else
{
- if (pszDest)
- {
- if (dwFlags & STRSAFE_FILL_ON_FAILURE)
- {
- memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest);
-
- if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0)
- {
- pszDestEnd = pszDest;
- cchRemaining = cchDest;
- }
- else if (cchDest > 0)
- {
- pszDestEnd = pszDest + cchDest - 1;
- cchRemaining = 1;
-
- // null terminate the end of the string
- *pszDestEnd = L'\0';
- }
- }
-
- if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION))
- {
- if (cchDest > 0)
- {
- pszDestEnd = pszDest;
- cchRemaining = cchDest;
-
- // null terminate the beginning of the string
- *pszDestEnd = L'\0';
- }
- }
- }
+ hr = StringLengthWorkerW(psz, cchMax, &cch);
}
- if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER))
+ if (SUCCEEDED(hr) && pcb)
{
- if (ppszDestEnd)
- {
- *ppszDestEnd = pszDestEnd;
- }
-
- if (pcchRemaining)
- {
- *pcchRemaining = cchRemaining;
- }
+ // safe to multiply cch * sizeof(WCHAR) since cch < STRSAFE_MAX_CCH and sizeof(WCHAR) is 2
+ *pcb = cch * sizeof(WCHAR);
}
return hr;
}
#endif // FEATURE_PAL || !PLATFORM_UNIX
+#endif // STRSAFE_INLINE
+#endif // !STRSAFE_NO_CB_FUNCTIONS
-STRSAFEAPI StringCopyNWorkerA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchSrc)
+
+// these are the worker functions that actually do the work
+#ifdef STRSAFE_INLINE
+STRSAFEAPI StringCopyWorkerA(char* pszDest, size_t cchDest, const char* pszSrc)
{
HRESULT hr = S_OK;
}
else
{
- while (cchDest && cchSrc && (*pszSrc != '\0'))
+ while (cchDest && (*pszSrc != '\0'))
{
- *pszDest++= *pszSrc++;
+ *pszDest++ = *pszSrc++;
cchDest--;
- cchSrc--;
}
if (cchDest == 0)
}
#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFEAPI StringCopyNWorkerW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc, size_t cchSrc)
+STRSAFEAPI StringCopyWorkerW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc)
{
HRESULT hr = S_OK;
}
else
{
- while (cchDest && cchSrc && (*pszSrc != L'\0'))
+ while (cchDest && (*pszSrc != L'\0'))
{
- *pszDest++= *pszSrc++;
+ *pszDest++ = *pszSrc++;
cchDest--;
- cchSrc--;
}
if (cchDest == 0)
}
#endif // FEATURE_PAL || !PLATFORM_UNIX
-STRSAFEAPI StringCopyNExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, size_t cchSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
+STRSAFEAPI StringCopyExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr = S_OK;
char* pszDestEnd = pszDest;
pszDestEnd = pszDest;
cchRemaining = cchDest;
- while (cchRemaining && cchSrc && (*pszSrc != '\0'))
+ while (cchRemaining && (*pszSrc != '\0'))
{
*pszDestEnd++= *pszSrc++;
cchRemaining--;
- cchSrc--;
}
if (cchRemaining > 0)
}
#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFEAPI StringCopyNExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, const WCHAR* pszSrc, size_t cchSrc, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
+STRSAFEAPI StringCopyExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, const WCHAR* pszSrc, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr = S_OK;
WCHAR* pszDestEnd = pszDest;
cchRemaining = 0;
// only fail if there was actually src data to copy
- if (*pszSrc != L'\0')
+ if (*pszSrc != u'\0')
{
if (pszDest == NULL)
{
pszDestEnd = pszDest;
cchRemaining = cchDest;
- while (cchRemaining && cchSrc && (*pszSrc != L'\0'))
+ while (cchRemaining && (*pszSrc != u'\0'))
{
*pszDestEnd++= *pszSrc++;
cchRemaining--;
- cchSrc--;
}
if (cchRemaining > 0)
hr = STRSAFE_E_INSUFFICIENT_BUFFER;
}
- *pszDestEnd = L'\0';
+ *pszDestEnd = u'\0';
}
}
}
if (dwFlags & STRSAFE_FILL_ON_FAILURE)
{
memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest);
-
+
if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0)
{
pszDestEnd = pszDest;
}
#endif // FEATURE_PAL || !PLATFORM_UNIX
-STRSAFEAPI StringCatWorkerA(char* pszDest, size_t cchDest, const char* pszSrc)
+STRSAFEAPI StringCopyNWorkerA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchSrc)
{
- HRESULT hr;
- size_t cchDestCurrent;
+ HRESULT hr = S_OK;
- hr = StringLengthWorkerA(pszDest, cchDest, &cchDestCurrent);
+ if (cchDest == 0)
+ {
+ // can not null terminate a zero-byte dest buffer
+ hr = STRSAFE_E_INVALID_PARAMETER;
+ }
+ else
+ {
+ while (cchDest && cchSrc && (*pszSrc != '\0'))
+ {
+ *pszDest++= *pszSrc++;
+ cchDest--;
+ cchSrc--;
+ }
- if (SUCCEEDED(hr))
- {
- hr = StringCopyWorkerA(pszDest + cchDestCurrent,
- cchDest - cchDestCurrent,
- pszSrc);
- }
+ if (cchDest == 0)
+ {
+ // we are going to truncate pszDest
+ pszDest--;
+ hr = STRSAFE_E_INSUFFICIENT_BUFFER;
+ }
- return hr;
+ *pszDest= '\0';
+ }
+
+ return hr;
}
#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFEAPI StringCatWorkerW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc)
-{
- HRESULT hr;
- size_t cchDestCurrent;
+STRSAFEAPI StringCopyNWorkerW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc, size_t cchSrc)
+{
+ HRESULT hr = S_OK;
- hr = StringLengthWorkerW(pszDest, cchDest, &cchDestCurrent);
+ if (cchDest == 0)
+ {
+ // can not null terminate a zero-byte dest buffer
+ hr = STRSAFE_E_INVALID_PARAMETER;
+ }
+ else
+ {
+ while (cchDest && cchSrc && (*pszSrc != L'\0'))
+ {
+ *pszDest++= *pszSrc++;
+ cchDest--;
+ cchSrc--;
+ }
- if (SUCCEEDED(hr))
- {
- hr = StringCopyWorkerW(pszDest + cchDestCurrent,
- cchDest - cchDestCurrent,
- pszSrc);
- }
+ if (cchDest == 0)
+ {
+ // we are going to truncate pszDest
+ pszDest--;
+ hr = STRSAFE_E_INSUFFICIENT_BUFFER;
+ }
- return hr;
+ *pszDest= L'\0';
+ }
+
+ return hr;
}
#endif // FEATURE_PAL || !PLATFORM_UNIX
-STRSAFEAPI StringCatExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
+STRSAFEAPI StringCopyNExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, size_t cchSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr = S_OK;
char* pszDestEnd = pszDest;
// ASSERT(cbDest == (cchDest * sizeof(char)) ||
// cbDest == (cchDest * sizeof(char)) + (cbDest % sizeof(char)));
-
+
// only accept valid flags
if (dwFlags & (~STRSAFE_VALID_FLAGS))
{
}
else
{
- size_t cchDestCurrent;
-
if (dwFlags & STRSAFE_IGNORE_NULLS)
{
if (pszDest == NULL)
{
- if ((cchDest == 0) && (cbDest == 0))
- {
- cchDestCurrent = 0;
- }
- else
+ if ((cchDest != 0) || (cbDest != 0))
{
// NULL pszDest and non-zero cchDest/cbDest is invalid
hr = STRSAFE_E_INVALID_PARAMETER;
}
}
- else
- {
- hr = StringLengthWorkerA(pszDest, cchDest, &cchDestCurrent);
-
- if (SUCCEEDED(hr))
- {
- pszDestEnd = pszDest + cchDestCurrent;
- cchRemaining = cchDest - cchDestCurrent;
- }
- }
if (pszSrc == NULL)
{
pszSrc = "";
}
}
- else
- {
- hr = StringLengthWorkerA(pszDest, cchDest, &cchDestCurrent);
-
- if (SUCCEEDED(hr))
- {
- pszDestEnd = pszDest + cchDestCurrent;
- cchRemaining = cchDest - cchDestCurrent;
- }
- }
if (SUCCEEDED(hr))
{
if (cchDest == 0)
{
- // only fail if there was actually src data to append
+ pszDestEnd = pszDest;
+ cchRemaining = 0;
+
+ // only fail if there was actually src data to copy
if (*pszSrc != '\0')
{
if (pszDest == NULL)
}
else
{
- // we handle the STRSAFE_FILL_ON_FAILURE and STRSAFE_NULL_ON_FAILURE cases below, so do not pass
- // those flags through
- hr = StringCopyExWorkerA(pszDestEnd,
- cchRemaining,
- (cchRemaining * sizeof(char)) + (cbDest % sizeof(char)),
- pszSrc,
- &pszDestEnd,
- &cchRemaining,
- dwFlags & (~(STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE)));
+ pszDestEnd = pszDest;
+ cchRemaining = cchDest;
+
+ while (cchRemaining && cchSrc && (*pszSrc != '\0'))
+ {
+ *pszDestEnd++= *pszSrc++;
+ cchRemaining--;
+ cchSrc--;
+ }
+
+ if (cchRemaining > 0)
+ {
+ if (dwFlags & STRSAFE_FILL_BEHIND_NULL)
+ {
+ memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(char)) + (cbDest % sizeof(char)));
+ }
+ }
+ else
+ {
+ // we are going to truncate pszDest
+ pszDestEnd--;
+ cchRemaining++;
+
+ hr = STRSAFE_E_INSUFFICIENT_BUFFER;
+ }
+
+ *pszDestEnd = '\0';
}
}
}
-
+
if (FAILED(hr))
{
if (pszDest)
{
- // STRSAFE_NO_TRUNCATION is taken care of by StringCopyExWorkerA()
-
if (dwFlags & STRSAFE_FILL_ON_FAILURE)
{
memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest);
-
+
if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0)
{
pszDestEnd = pszDest;
cchRemaining = cchDest;
}
- else
- if (cchDest > 0)
+ else if (cchDest > 0)
{
pszDestEnd = pszDest + cchDest - 1;
cchRemaining = 1;
}
}
- if (dwFlags & STRSAFE_NULL_ON_FAILURE)
+ if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION))
{
if (cchDest > 0)
{
}
#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFEAPI StringCatExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, const WCHAR* pszSrc, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
+STRSAFEAPI StringCopyNExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, const WCHAR* pszSrc, size_t cchSrc, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr = S_OK;
WCHAR* pszDestEnd = pszDest;
// ASSERT(cbDest == (cchDest * sizeof(WCHAR)) ||
// cbDest == (cchDest * sizeof(WCHAR)) + (cbDest % sizeof(WCHAR)));
-
+
// only accept valid flags
if (dwFlags & (~STRSAFE_VALID_FLAGS))
{
}
else
{
- size_t cchDestCurrent;
-
if (dwFlags & STRSAFE_IGNORE_NULLS)
{
if (pszDest == NULL)
{
- if ((cchDest == 0) && (cbDest == 0))
- {
- cchDestCurrent = 0;
- }
- else
+ if ((cchDest != 0) || (cbDest != 0))
{
// NULL pszDest and non-zero cchDest/cbDest is invalid
hr = STRSAFE_E_INVALID_PARAMETER;
}
}
- else
- {
- hr = StringLengthWorkerW(pszDest, cchDest, &cchDestCurrent);
-
- if (SUCCEEDED(hr))
- {
- pszDestEnd = pszDest + cchDestCurrent;
- cchRemaining = cchDest - cchDestCurrent;
- }
- }
if (pszSrc == NULL)
{
pszSrc = u"";
}
}
- else
- {
- hr = StringLengthWorkerW(pszDest, cchDest, &cchDestCurrent);
-
- if (SUCCEEDED(hr))
- {
- pszDestEnd = pszDest + cchDestCurrent;
- cchRemaining = cchDest - cchDestCurrent;
- }
- }
if (SUCCEEDED(hr))
{
if (cchDest == 0)
{
- // only fail if there was actually src data to append
+ pszDestEnd = pszDest;
+ cchRemaining = 0;
+
+ // only fail if there was actually src data to copy
if (*pszSrc != L'\0')
{
if (pszDest == NULL)
}
else
{
- // we handle the STRSAFE_FILL_ON_FAILURE and STRSAFE_NULL_ON_FAILURE cases below, so do not pass
- // those flags through
- hr = StringCopyExWorkerW(pszDestEnd,
- cchRemaining,
- (cchRemaining * sizeof(WCHAR)) + (cbDest % sizeof(WCHAR)),
- pszSrc,
- &pszDestEnd,
- &cchRemaining,
- dwFlags & (~(STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE)));
+ pszDestEnd = pszDest;
+ cchRemaining = cchDest;
+
+ while (cchRemaining && cchSrc && (*pszSrc != L'\0'))
+ {
+ *pszDestEnd++= *pszSrc++;
+ cchRemaining--;
+ cchSrc--;
+ }
+
+ if (cchRemaining > 0)
+ {
+ if (dwFlags & STRSAFE_FILL_BEHIND_NULL)
+ {
+ memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(WCHAR)) + (cbDest % sizeof(WCHAR)));
+ }
+ }
+ else
+ {
+ // we are going to truncate pszDest
+ pszDestEnd--;
+ cchRemaining++;
+
+ hr = STRSAFE_E_INSUFFICIENT_BUFFER;
+ }
+
+ *pszDestEnd = L'\0';
}
}
}
{
if (pszDest)
{
- // STRSAFE_NO_TRUNCATION is taken care of by StringCopyExWorkerW()
-
if (dwFlags & STRSAFE_FILL_ON_FAILURE)
{
memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest);
}
}
- if (dwFlags & STRSAFE_NULL_ON_FAILURE)
+ if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION))
{
if (cchDest > 0)
{
}
#endif // FEATURE_PAL || !PLATFORM_UNIX
-STRSAFEAPI StringCatNWorkerA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchMaxAppend)
+STRSAFEAPI StringCatWorkerA(char* pszDest, size_t cchDest, const char* pszSrc)
{
- HRESULT hr;
- size_t cchDestCurrent;
+ HRESULT hr;
+ size_t cchDestCurrent;
- hr = StringLengthWorkerA(pszDest, cchDest, &cchDestCurrent);
+ hr = StringLengthWorkerA(pszDest, cchDest, &cchDestCurrent);
- if (SUCCEEDED(hr))
- {
- hr = StringCopyNWorkerA(pszDest + cchDestCurrent,
- cchDest - cchDestCurrent,
- pszSrc,
- cchMaxAppend);
- }
+ if (SUCCEEDED(hr))
+ {
+ hr = StringCopyWorkerA(pszDest + cchDestCurrent,
+ cchDest - cchDestCurrent,
+ pszSrc);
+ }
- return hr;
+ return hr;
}
#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFEAPI StringCatNWorkerW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc, size_t cchMaxAppend)
+STRSAFEAPI StringCatWorkerW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc)
{
- HRESULT hr;
- size_t cchDestCurrent;
+ HRESULT hr;
+ size_t cchDestCurrent;
- hr = StringLengthWorkerW(pszDest, cchDest, &cchDestCurrent);
+ hr = StringLengthWorkerW(pszDest, cchDest, &cchDestCurrent);
- if (SUCCEEDED(hr))
- {
- hr = StringCopyNWorkerW(pszDest + cchDestCurrent,
- cchDest - cchDestCurrent,
- pszSrc,
- cchMaxAppend);
- }
+ if (SUCCEEDED(hr))
+ {
+ hr = StringCopyWorkerW(pszDest + cchDestCurrent,
+ cchDest - cchDestCurrent,
+ pszSrc);
+ }
- return hr;
+ return hr;
}
#endif // FEATURE_PAL || !PLATFORM_UNIX
-STRSAFEAPI StringCatNExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, size_t cchMaxAppend, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
+STRSAFEAPI StringCatExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr = S_OK;
char* pszDestEnd = pszDest;
size_t cchRemaining = 0;
- size_t cchDestCurrent = 0;
// ASSERT(cbDest == (cchDest * sizeof(char)) ||
// cbDest == (cchDest * sizeof(char)) + (cbDest % sizeof(char)));
}
else
{
+ size_t cchDestCurrent;
+
if (dwFlags & STRSAFE_IGNORE_NULLS)
{
if (pszDest == NULL)
}
}
else
- {
- // we handle the STRSAFE_FILL_ON_FAILURE and STRSAFE_NULL_ON_FAILURE cases below, so do not pass
- // those flags through
- hr = StringCopyNExWorkerA(pszDestEnd,
- cchRemaining,
- (cchRemaining * sizeof(char)) + (cbDest % sizeof(char)),
- pszSrc,
- cchMaxAppend,
- &pszDestEnd,
- &cchRemaining,
- dwFlags & (~(STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE)));
+ {
+ // we handle the STRSAFE_FILL_ON_FAILURE and STRSAFE_NULL_ON_FAILURE cases below, so do not pass
+ // those flags through
+ hr = StringCopyExWorkerA(pszDestEnd,
+ cchRemaining,
+ (cchRemaining * sizeof(char)) + (cbDest % sizeof(char)),
+ pszSrc,
+ &pszDestEnd,
+ &cchRemaining,
+ dwFlags & (~(STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE)));
}
}
}
-
+
if (FAILED(hr))
{
if (pszDest)
{
- // STRSAFE_NO_TRUNCATION is taken care of by StringCopyNExWorkerA()
+ // STRSAFE_NO_TRUNCATION is taken care of by StringCopyExWorkerA()
if (dwFlags & STRSAFE_FILL_ON_FAILURE)
{
pszDestEnd = pszDest;
cchRemaining = cchDest;
}
- else if (cchDest > 0)
+ else
+ if (cchDest > 0)
{
pszDestEnd = pszDest + cchDest - 1;
cchRemaining = 1;
}
}
- if (dwFlags & (STRSAFE_NULL_ON_FAILURE))
+ if (dwFlags & STRSAFE_NULL_ON_FAILURE)
{
if (cchDest > 0)
{
if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER))
{
- if (ppszDestEnd)
+ if (ppszDestEnd)
{
*ppszDestEnd = pszDestEnd;
}
}
#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFEAPI StringCatNExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, const WCHAR* pszSrc, size_t cchMaxAppend, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
+STRSAFEAPI StringCatExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, const WCHAR* pszSrc, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr = S_OK;
WCHAR* pszDestEnd = pszDest;
size_t cchRemaining = 0;
- size_t cchDestCurrent = 0;
-
// ASSERT(cbDest == (cchDest * sizeof(WCHAR)) ||
// cbDest == (cchDest * sizeof(WCHAR)) + (cbDest % sizeof(WCHAR)));
}
else
{
+ size_t cchDestCurrent;
+
if (dwFlags & STRSAFE_IGNORE_NULLS)
{
if (pszDest == NULL)
{
// we handle the STRSAFE_FILL_ON_FAILURE and STRSAFE_NULL_ON_FAILURE cases below, so do not pass
// those flags through
- hr = StringCopyNExWorkerW(pszDestEnd,
- cchRemaining,
- (cchRemaining * sizeof(WCHAR)) + (cbDest % sizeof(WCHAR)),
- pszSrc,
- cchMaxAppend,
- &pszDestEnd,
- &cchRemaining,
- dwFlags & (~(STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE)));
+ hr = StringCopyExWorkerW(pszDestEnd,
+ cchRemaining,
+ (cchRemaining * sizeof(WCHAR)) + (cbDest % sizeof(WCHAR)),
+ pszSrc,
+ &pszDestEnd,
+ &cchRemaining,
+ dwFlags & (~(STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE)));
}
}
}
{
if (pszDest)
{
- // STRSAFE_NO_TRUNCATION is taken care of by StringCopyNExWorkerW()
+ // STRSAFE_NO_TRUNCATION is taken care of by StringCopyExWorkerW()
if (dwFlags & STRSAFE_FILL_ON_FAILURE)
{
memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest);
-
+
if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0)
{
pszDestEnd = pszDest;
}
}
- if (dwFlags & (STRSAFE_NULL_ON_FAILURE))
+ if (dwFlags & STRSAFE_NULL_ON_FAILURE)
{
if (cchDest > 0)
{
if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER))
{
- if (ppszDestEnd)
+ if (ppszDestEnd)
{
*ppszDestEnd = pszDestEnd;
}
}
#endif // FEATURE_PAL || !PLATFORM_UNIX
-STRSAFEAPI StringVPrintfWorkerA(char* pszDest, size_t cchDest, const char* pszFormat, va_list argList)
+STRSAFEAPI StringCatNWorkerA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchMaxAppend)
{
- HRESULT hr = S_OK;
-
- if (cchDest == 0)
- {
- // can not null terminate a zero-byte dest buffer
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- int iRet;
- size_t cchMax;
-
- // leave the last space for the null terminator
- cchMax = cchDest - 1;
-
- iRet = _vsnprintf(pszDest, cchMax, pszFormat, argList);
- // ASSERT((iRet < 0) || (((size_t)iRet) <= cchMax));
+ HRESULT hr;
+ size_t cchDestCurrent;
- if ((iRet < 0) || (((size_t)iRet) > cchMax))
- {
- // need to null terminate the string
- pszDest += cchMax;
- *pszDest = '\0';
+ hr = StringLengthWorkerA(pszDest, cchDest, &cchDestCurrent);
- // we have truncated pszDest
- hr = STRSAFE_E_INSUFFICIENT_BUFFER;
- }
- else if (((size_t)iRet) == cchMax)
- {
- // need to null terminate the string
- pszDest += cchMax;
- *pszDest = '\0';
- }
- }
+ if (SUCCEEDED(hr))
+ {
+ hr = StringCopyNWorkerA(pszDest + cchDestCurrent,
+ cchDest - cchDestCurrent,
+ pszSrc,
+ cchMaxAppend);
+ }
return hr;
}
#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFEAPI StringVPrintfWorkerW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszFormat, va_list argList)
+STRSAFEAPI StringCatNWorkerW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc, size_t cchMaxAppend)
{
- HRESULT hr = S_OK;
-
- if (cchDest == 0)
- {
- // can not null terminate a zero-byte dest buffer
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- int iRet;
- size_t cchMax;
-
- // leave the last space for the null terminator
- cchMax = cchDest - 1;
-
- iRet = _vsnwprintf(pszDest, cchMax, pszFormat, argList);
- // ASSERT((iRet < 0) || (((size_t)iRet) <= cchMax));
+ HRESULT hr;
+ size_t cchDestCurrent;
- if ((iRet < 0) || (((size_t)iRet) > cchMax))
- {
- // need to null terminate the string
- pszDest += cchMax;
- *pszDest = L'\0';
+ hr = StringLengthWorkerW(pszDest, cchDest, &cchDestCurrent);
- // we have truncated pszDest
- hr = STRSAFE_E_INSUFFICIENT_BUFFER;
- }
- else if (((size_t)iRet) == cchMax)
- {
- // need to null terminate the string
- pszDest += cchMax;
- *pszDest = L'\0';
- }
+ if (SUCCEEDED(hr))
+ {
+ hr = StringCopyNWorkerW(pszDest + cchDestCurrent,
+ cchDest - cchDestCurrent,
+ pszSrc,
+ cchMaxAppend);
}
return hr;
}
#endif // FEATURE_PAL || !PLATFORM_UNIX
-STRSAFEAPI StringVPrintfExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const char* pszFormat, va_list argList)
+STRSAFEAPI StringCatNExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, size_t cchMaxAppend, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr = S_OK;
char* pszDestEnd = pszDest;
size_t cchRemaining = 0;
+ size_t cchDestCurrent = 0;
// ASSERT(cbDest == (cchDest * sizeof(char)) ||
// cbDest == (cchDest * sizeof(char)) + (cbDest % sizeof(char)));
{
if (pszDest == NULL)
{
- if ((cchDest != 0) || (cbDest != 0))
+ if ((cchDest == 0) && (cbDest == 0))
+ {
+ cchDestCurrent = 0;
+ }
+ else
{
// NULL pszDest and non-zero cchDest/cbDest is invalid
hr = STRSAFE_E_INVALID_PARAMETER;
}
}
+ else
+ {
+ hr = StringLengthWorkerA(pszDest, cchDest, &cchDestCurrent);
+
+ if (SUCCEEDED(hr))
+ {
+ pszDestEnd = pszDest + cchDestCurrent;
+ cchRemaining = cchDest - cchDestCurrent;
+ }
+ }
- if (pszFormat == NULL)
+ if (pszSrc == NULL)
{
- pszFormat = "";
+ pszSrc = "";
}
}
-
+ else
+ {
+ hr = StringLengthWorkerA(pszDest, cchDest, &cchDestCurrent);
+
+ if (SUCCEEDED(hr))
+ {
+ pszDestEnd = pszDest + cchDestCurrent;
+ cchRemaining = cchDest - cchDestCurrent;
+ }
+ }
+
if (SUCCEEDED(hr))
{
if (cchDest == 0)
{
- pszDestEnd = pszDest;
- cchRemaining = 0;
-
- // only fail if there was actually a non-empty format string
- if (*pszFormat != '\0')
+ // only fail if there was actually src data to append
+ if (*pszSrc != '\0')
{
if (pszDest == NULL)
{
}
else
{
- int iRet;
- size_t cchMax;
-
- // leave the last space for the null terminator
- cchMax = cchDest - 1;
-
- iRet = _vsnprintf(pszDest, cchMax, pszFormat, argList);
- // ASSERT((iRet < 0) || (((size_t)iRet) <= cchMax));
-
- if ((iRet < 0) || (((size_t)iRet) > cchMax))
- {
- // we have truncated pszDest
- pszDestEnd = pszDest + cchMax;
- cchRemaining = 1;
-
- // need to null terminate the string
- *pszDestEnd = '\0';
-
- hr = STRSAFE_E_INSUFFICIENT_BUFFER;
- }
- else if (((size_t)iRet) == cchMax)
- {
- // string fit perfectly
- pszDestEnd = pszDest + cchMax;
- cchRemaining = 1;
-
- // need to null terminate the string
- *pszDestEnd = '\0';
- }
- else if (((size_t)iRet) < cchMax)
- {
- // there is extra room
- pszDestEnd = pszDest + iRet;
- cchRemaining = cchDest - iRet;
-
- if (dwFlags & STRSAFE_FILL_BEHIND_NULL)
- {
- memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(char)) + (cbDest % sizeof(char)));
- }
- }
+ // we handle the STRSAFE_FILL_ON_FAILURE and STRSAFE_NULL_ON_FAILURE cases below, so do not pass
+ // those flags through
+ hr = StringCopyNExWorkerA(pszDestEnd,
+ cchRemaining,
+ (cchRemaining * sizeof(char)) + (cbDest % sizeof(char)),
+ pszSrc,
+ cchMaxAppend,
+ &pszDestEnd,
+ &cchRemaining,
+ dwFlags & (~(STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE)));
}
}
}
{
if (pszDest)
{
+ // STRSAFE_NO_TRUNCATION is taken care of by StringCopyNExWorkerA()
+
if (dwFlags & STRSAFE_FILL_ON_FAILURE)
{
memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest);
}
}
- if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION))
+ if (dwFlags & (STRSAFE_NULL_ON_FAILURE))
{
if (cchDest > 0)
{
if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER))
{
- if (ppszDestEnd)
+ if (ppszDestEnd)
{
*ppszDestEnd = pszDestEnd;
}
}
#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFEAPI StringVPrintfExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags, const WCHAR* pszFormat, va_list argList)
+STRSAFEAPI StringCatNExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, const WCHAR* pszSrc, size_t cchMaxAppend, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr = S_OK;
WCHAR* pszDestEnd = pszDest;
size_t cchRemaining = 0;
+ size_t cchDestCurrent = 0;
+
// ASSERT(cbDest == (cchDest * sizeof(WCHAR)) ||
// cbDest == (cchDest * sizeof(WCHAR)) + (cbDest % sizeof(WCHAR)));
{
if (pszDest == NULL)
{
- if ((cchDest != 0) || (cbDest != 0))
+ if ((cchDest == 0) && (cbDest == 0))
+ {
+ cchDestCurrent = 0;
+ }
+ else
{
// NULL pszDest and non-zero cchDest/cbDest is invalid
hr = STRSAFE_E_INVALID_PARAMETER;
}
}
+ else
+ {
+ hr = StringLengthWorkerW(pszDest, cchDest, &cchDestCurrent);
+
+ if (SUCCEEDED(hr))
+ {
+ pszDestEnd = pszDest + cchDestCurrent;
+ cchRemaining = cchDest - cchDestCurrent;
+ }
+ }
+
+ if (pszSrc == NULL)
+ {
+ pszSrc = u"";
+ }
+ }
+ else
+ {
+ hr = StringLengthWorkerW(pszDest, cchDest, &cchDestCurrent);
- if (pszFormat == NULL)
+ if (SUCCEEDED(hr))
{
- pszFormat = u"";
+ pszDestEnd = pszDest + cchDestCurrent;
+ cchRemaining = cchDest - cchDestCurrent;
}
}
{
if (cchDest == 0)
{
- pszDestEnd = pszDest;
- cchRemaining = 0;
-
- // only fail if there was actually a non-empty format string
- if (*pszFormat != L'\0')
+ // only fail if there was actually src data to append
+ if (*pszSrc != L'\0')
{
if (pszDest == NULL)
{
}
else
{
- int iRet;
- size_t cchMax;
-
- // leave the last space for the null terminator
- cchMax = cchDest - 1;
-
- iRet = _vsnwprintf(pszDest, cchMax, pszFormat, argList);
- // ASSERT((iRet < 0) || (((size_t)iRet) <= cchMax));
-
- if ((iRet < 0) || (((size_t)iRet) > cchMax))
- {
- // we have truncated pszDest
- pszDestEnd = pszDest + cchMax;
- cchRemaining = 1;
-
- // need to null terminate the string
- *pszDestEnd = L'\0';
-
- hr = STRSAFE_E_INSUFFICIENT_BUFFER;
- }
- else if (((size_t)iRet) == cchMax)
- {
- // string fit perfectly
- pszDestEnd = pszDest + cchMax;
- cchRemaining = 1;
-
- // need to null terminate the string
- *pszDestEnd = L'\0';
- }
- else if (((size_t)iRet) < cchMax)
- {
- // there is extra room
- pszDestEnd = pszDest + iRet;
- cchRemaining = cchDest - iRet;
-
- if (dwFlags & STRSAFE_FILL_BEHIND_NULL)
- {
- memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(WCHAR)) + (cbDest % sizeof(WCHAR)));
- }
- }
+ // we handle the STRSAFE_FILL_ON_FAILURE and STRSAFE_NULL_ON_FAILURE cases below, so do not pass
+ // those flags through
+ hr = StringCopyNExWorkerW(pszDestEnd,
+ cchRemaining,
+ (cchRemaining * sizeof(WCHAR)) + (cbDest % sizeof(WCHAR)),
+ pszSrc,
+ cchMaxAppend,
+ &pszDestEnd,
+ &cchRemaining,
+ dwFlags & (~(STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE)));
}
}
}
-
+
if (FAILED(hr))
{
if (pszDest)
{
+ // STRSAFE_NO_TRUNCATION is taken care of by StringCopyNExWorkerW()
+
if (dwFlags & STRSAFE_FILL_ON_FAILURE)
{
memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest);
}
}
- if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION))
+ if (dwFlags & (STRSAFE_NULL_ON_FAILURE))
{
if (cchDest > 0)
{
if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER))
{
- if (ppszDestEnd)
+ if (ppszDestEnd)
{
*ppszDestEnd = pszDestEnd;
}
#cmakedefine01 HAVE_LOCALTIME_R
#cmakedefine01 HAVE_GMTIME_R
#cmakedefine01 HAVE_TIMEGM
-#cmakedefine01 HAVE__SNWPRINTF
#cmakedefine01 HAVE_POLL
#cmakedefine01 HAVE_STATVFS
#cmakedefine01 HAVE_THREAD_SELF
check_function_exists(localtime_r HAVE_LOCALTIME_R)
check_function_exists(gmtime_r HAVE_GMTIME_R)
check_function_exists(timegm HAVE_TIMEGM)
-check_function_exists(_snwprintf HAVE__SNWPRINTF)
check_function_exists(poll HAVE_POLL)
check_function_exists(statvfs HAVE_STATVFS)
check_function_exists(thread_self HAVE_THREAD_SELF)
/*++
Function:
- _snprintf
-
-See MSDN doc.
---*/
-int
-__cdecl
-_snprintf(
- char *buffer,
- size_t count,
- const char *format,
- ...)
-{
- LONG Length;
- va_list ap;
-
- PERF_ENTRY(_snprintf);
- ENTRY("_snprintf (buffer=%p, count=%lu, format=%p (%s))\n",
- buffer, (unsigned long) count, format, format);
-
- va_start(ap, format);
- Length = InternalVsnprintf(CorUnix::InternalGetCurrentThread(), buffer, count, format, ap);
- va_end(ap);
-
- LOGEXIT("_snprintf returns int %d\n", Length);
- PERF_EXIT(_snprintf);
- return Length;
-}
-
-
-/*++
-Function:
- _snwprintf
-
-See MSDN doc.
---*/
-int
-__cdecl
-_snwprintf(
- wchar_16 *buffer,
- size_t count,
- const wchar_16 *format,
- ...)
-{
- LONG Length;
- va_list ap;
-
- PERF_ENTRY(_snwprintf);
- ENTRY("_snwprintf (buffer=%p, count=%lu, format=%p (%S))\n",
- buffer, (unsigned long) count, format, format);
-
- va_start(ap, format);
- Length = PAL__wvsnprintf(buffer, count, format, ap);
- va_end(ap);
-
- LOGEXIT("_snwprintf returns int %d\n", Length);
- PERF_EXIT(_snwprintf);
- return Length;
-}
-
-/*++
-Function:
fwprintf
See MSDN doc.
}
-/*++
-Function:
- _vsnwprintf
-
-See MSDN doc.
---*/
-int
-__cdecl
-_vsnwprintf(wchar_16 *buffer,
- size_t count,
- const wchar_16 *format,
- va_list argptr)
-{
- LONG Length;
-
- PERF_ENTRY(_vsnwprintf);
- ENTRY("_vsnwprintf (buffer=%p, count=%lu, format=%p (%S), argptr=%p)\n",
- buffer, (unsigned long) count, format, format, argptr);
-
- Length = PAL__wvsnprintf(buffer, count, format, argptr);
-
- LOGEXIT("_vsnwprintf returns int %d\n", Length);
- PERF_EXIT(_vsnwprintf);
-
- return Length;
-}
-
#if SSCANF_CANNOT_HANDLE_MISSING_EXPONENT
/*++
Function:
#define strpbrk DUMMY_strpbrk
#define strtod DUMMY_strtod
#define strspn DUMMY_strspn
-#if HAVE__SNPRINTF
-#define _snprintf DUMMY__snprintf
-#endif /* HAVE__SNPRINTF */
-#if HAVE__SNWPRINTF
-#define _snwprintf DUMMY__snwprintf
-#endif /* HAVE__SNWPRINTF */
#define tolower DUMMY_tolower
#define toupper DUMMY_toupper
#define islower DUMMY_islower
#undef wprintf
#undef sprintf
#undef swprintf
-#undef _snprintf
-#if HAVE__SNWPRINTF
-#undef _snwprintf
-#endif /* HAVE__SNWPRINTF */
#undef sscanf
#undef wcstod
#undef wcstol
#undef vsprintf
#undef vswprintf
#undef _vsnprintf
-#undef _vsnwprintf
#undef vsnprintf
#undef wvsnprintf
/* routine used for floating-point output */
#define FORMATSIZE 30
-#define _snprintf snprintf
-
// taken from output.inl
#define FL_ALTERNATE 0x00080 /* alternate form requested */
format[formatlen] = 0;
buffer[sizeInBytes - 1] = 0;
- retvalue = _snprintf(buffer, sizeInBytes, format, *arg);
+ retvalue = snprintf(buffer, sizeInBytes, format, *arg);
if (buffer[sizeInBytes - 1] != 0 || retvalue <= 0)
{
buffer[0] = 0;
flags |= FL_LONG; /* 'l' => long int or wchar_t */
}
break;
+ case _T('L'):
+ if (*format == _T('p'))
+ {
+ flags |= FL_LONG;
+ }
+ break;
case _T('I'):
/*
#else /* _UNICODE */
if (flags & (FL_LONG|FL_WIDECHAR)) {
wchar = (wchar_t) get_int_arg(&argptr);
- no_output = 1;
+ textlen = snprintf(buffer.sz, BUFFERSIZE, "%lc", wchar);
+ if (textlen == 0)
+ {
+ no_output = 1;
+ }
} else {
/* format multibyte character */
/* this is an extension of ANSI */
precision = 2 * sizeof(void *); /* number of hex digits needed */
#if PTR_IS_INT64
- flags |= FL_I64; /* assume we're converting an int64 */
+ if (flags & (FL_LONG | FL_SHORT))
+ {
+ /* %lp, %Lp or %hp - these print 8 hex digits*/
+ precision = 2 * sizeof(int32_t);
+ }
+ else
+ {
+ flags |= FL_I64; /* assume we're converting an int64 */
+ }
#elif !PTR_IS_INT
flags |= FL_LONG; /* assume we're converting a long */
#endif /* !PTR_IS_INT */
/* write text */
#ifndef _UNICODE
if (bufferiswide && (textlen > 0)) {
- charsout = -1;
+ const WCHAR *p;
+ int mbCharCount;
+ int count;
+ char mbStr[5];
+
+ p = text.wz;
+ count = textlen;
+ while (count-- > 0) {
+ mbCharCount = snprintf(mbStr, sizeof(mbStr), "%lc", *p);
+ if (mbCharCount == 0) {
+ charsout = -1;
+ break;
+ }
+ WRITE_STRING(mbStr, mbCharCount, &charsout);
+ p++;
+ }
} else {
WRITE_STRING(text.sz, textlen, &charsout);
}
*
*Purpose:
-* The _snprintf() flavor takes a count argument that is
+* The sprintf_s() flavor takes a count argument that is
* the max number of bytes that should be written to the
* user's buffer.
*
*
*Purpose:
-* defines sprintf() and _snprintf() - print formatted data to string
+* defines sprintf_s() and _snprintf_s() - print formatted data to string
*
*******************************************************************************/
/***
*ifndef _COUNT_
-*int sprintf(string, format, ...) - print formatted data to string
+*int sprintf_s(string, format, ...) - print formatted data to string
*else
-*int _snprintf(string, cnt, format, ...) - print formatted data to string
+*int _snprintf_s(string, cnt, format, ...) - print formatted data to string
*endif
*
*Purpose:
* entries are in are in DGROUP and, thus, are near.
*
*ifdef _COUNT_
-* The _snprintf() flavor takes a count argument that is
+* The _snprintf_s() flavor takes a count argument that is
* the max number of bytes that should be written to the
* user's buffer.
*endif
int ret;
va_list arglist;
va_start(arglist, format);
- ret = _vsprintf_s(string, sizeInBytes, format, arglist);
+ ret = vsprintf_s(string, sizeInBytes, format, arglist);
va_end(arglist);
return ret;
}
va_start(arglist, format);
- ret = _vswprintf_s(string, sizeInWords, format, arglist);
+ ret = vswprintf_s(string, sizeInWords, format, arglist);
va_end(arglist);
return -1;
}
-int __cdecl _vsprintf_s (
+int __cdecl vsprintf_s (
char *string,
size_t sizeInBytes,
const char *format,
*vswprint.c - print formatted data into a string from var arg list
*
*Purpose:
-* defines vswprintf(), _vswprintf_c and _vsnwprintf() - print formatted output to
+* defines vswprintf_s() and _vsnwprintf_s() - print formatted output to
* a string, get the data from an argument ptr instead of explicit
* arguments.
*
typedef int (*WOUTPUTFN)(miniFILE *, const wchar_t *, va_list);
static int _vswprintf_helper( WOUTPUTFN outfn, wchar_t *string, size_t count, const wchar_t *format, va_list ap );
-static int _vscwprintf_helper (WOUTPUTFN outfn, const wchar_t *format, va_list ap );
/***
-*ifndef _COUNT_
-*int _vswprintf(string, format, ap) - print formatted data to string from arg ptr
-*else
-*ifndef _SWPRINTFS_ERROR_RETURN_FIX
-*int _vsnwprintf(string, cnt, format, ap) - print formatted data to string from arg ptr
-*else
-*int _vswprintf_c(string, cnt, format, ...) - print formatted data to string
-*endif
-*endif
-*
+*int vswprintf_s(string, sizeInWords, format, ap) - print formatted data to string from arg ptr
+*int _vsnwprintf_s(string, sizeInWords, cnt, format, ap) - print formatted data to string from arg ptr
*Purpose:
* Prints formatted data, but to a string and gets data from an argument
* pointer.
* the stack so that other routines can assume that _iob[] entries are in
* are in DGROUP and, thus, are near.
*
-*ifdef _COUNT_
-*ifndef _SWPRINTFS_ERROR_RETURN_FIX
-* The _vsnwprintf() flavor takes a count argument that is
+* The _vsnwprintf_s() flavor takes a count argument that is
* the max number of bytes that should be written to the
* user's buffer.
* We don't expose this function directly in the headers.
-*else
-* The _vswprintf_c() flavor does the same thing as the _snwprintf
-* above, but, it also fixes an issue in the return value in the case
-* when there isn't enough space to write the null terminator
-* We don't fix this issue in _vsnwprintf because of backward
-* compatibility. In new code, however, _vsnwprintf is #defined to
-* _vswprintf_c so users get the fix.
-*
-*endif
*
* Multi-thread: (1) Since there is no stream, this routine must never try
* to get the stream lock (i.e., there is no stream lock either). (2)
*
*Entry:
* wchar_t *string - place to put destination string
-*ifdef _COUNT_
+* size_t sizeInWords - size of the string buffer in wchar_t units
* size_t count - max number of bytes to put in buffer
-*endif
* wchar_t *format - format string, describes format of data
* va_list ap - varargs argument pointer
*
return -1;
}
-int __cdecl _vswprintf_s (
+int __cdecl vswprintf_s (
wchar_t *string,
size_t sizeInWords,
const wchar_t *format,
return (retvalue < 0 ? -1 : retvalue);
}
-
-/***
-* _vscwprintf() - counts the number of character needed to print the formatted
-* data
-*
-*Purpose:
-* Counts the number of characters in the fotmatted data.
-*
-*Entry:
-* wchar_t *format - format string, describes format of data
-* va_list ap - varargs argument pointer
-*
-*Exit:
-* returns number of characters needed to print formatted data.
-*
-*Exceptions:
-*
-*******************************************************************************/
-
-#ifndef _COUNT_
-
-int __cdecl _vscwprintf_helper (
- WOUTPUTFN woutfn,
- const wchar_t *format,
- va_list ap
- )
-{
- miniFILE str;
- miniFILE *outfile = &str;
- int retval;
-
- _VALIDATE_RETURN( (format != NULL), EINVAL, -1);
-
- outfile->_cnt = INT_MAX; //MAXSTR;
- outfile->_flag = _IOWRT|_IOSTRG;
- outfile->_ptr = outfile->_base = NULL;
-
- retval = woutfn(outfile, format, ap);
- return(retval);
-}
-
-int __cdecl _vscwprintf (
- const wchar_t *format,
- va_list ap
- )
-{
- return _vscwprintf_helper(_woutput_s, format, ap);
-}
-
-#endif /* _COUNT_ */
// also try to use 0 as the value.
_ASSERTE(ret == TRUE || disambiguationKey == 0);
- int chars = _snprintf(name, MAX_DEBUGGER_TRANSPORT_PIPE_NAME_LENGTH, PipeNameFormat, id, disambiguationKey, suffix);
+ int chars = snprintf(name, MAX_DEBUGGER_TRANSPORT_PIPE_NAME_LENGTH, PipeNameFormat, id, disambiguationKey, suffix);
_ASSERTE(chars > 0 && chars < MAX_DEBUGGER_TRANSPORT_PIPE_NAME_LENGTH);
}
add_subdirectory(_putw)
add_subdirectory(_rotl)
add_subdirectory(_rotr)
-add_subdirectory(_snprintf)
-add_subdirectory(_snwprintf)
+add_subdirectory(_snprintf_s)
+add_subdirectory(_snwprintf_s)
add_subdirectory(_stricmp)
add_subdirectory(_strlwr)
add_subdirectory(_strnicmp)
add_subdirectory(_vsnprintf)
-add_subdirectory(_vsnwprintf)
+add_subdirectory(_vsnwprintf_s)
add_subdirectory(_wcsicmp)
add_subdirectory(_wcslwr)
add_subdirectory(_wcsnicmp)
+++ /dev/null
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(SOURCES
- test5.cpp
-)
-
-add_executable(paltest_snprintf_test5
- ${SOURCES}
-)
-
-add_dependencies(paltest_snprintf_test5 coreclrpal)
-
-target_link_libraries(paltest_snprintf_test5
- pthread
- m
- coreclrpal
-)
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*============================================================================
-**
-** Source: test5.c
-**
-** Purpose: Tests _snprintf with the count specifier
-**
-**
-**==========================================================================*/
-
-
-
-#include <palsuite.h>
-#include "../_snprintf.h"
-
-/*
- * Notes: memcmp is used, as is strlen.
- */
-
-
-int __cdecl main(int argc, char *argv[])
-{
- char *longStr =
- "really-long-string-that-just-keeps-going-on-and-on-and-on.."
- "..................useless-filler.................................."
- "..................useless-filler.................................."
- "..................useless-filler.................................."
- "%n bar";
- char *longResult =
- "really-long-string-that-just-keeps-going-on-and-on-and-on.."
- "..................useless-filler.................................."
- "..................useless-filler.................................."
- "..................useless-filler.................................."
- " bar";
-
- if (PAL_Initialize(argc, argv) != 0)
- {
- return FAIL;
- }
-
- DoCountTest("foo %n bar", 4, "foo bar");
- DoCountTest(longStr, 257, longResult);
- DoCountTest("fo%n bar", 2, "fo bar");
- DoCountTest("%n", 0, "");
- DoCountTest("foo %#n bar", 4, "foo bar");
- DoCountTest("foo % n bar", 4, "foo bar");
- DoCountTest("foo %+n bar", 4, "foo bar");
- DoCountTest("foo %-n bar", 4, "foo bar");
- DoCountTest("foo %0n bar", 4, "foo bar");
- DoShortCountTest("foo %hn bar", 4, "foo bar");
- DoCountTest("foo %ln bar", 4, "foo bar");
- DoCountTest("foo %Ln bar", 4, "foo bar");
- DoCountTest("foo %I64n bar", 4, "foo bar");
- DoCountTest("foo %20.3n bar", 4, "foo bar");
-
- PAL_Terminate();
- return PASS;
-}
+++ /dev/null
-# Licensed to the .NET Foundation under one or more agreements.
-# The .NET Foundation licenses this file to you under the MIT license.
-# See the LICENSE file in the project root for more information.
-
-Version = 1.0
-Section = C Runtime
-Function = _snprintf
-Name = Positive Test for _snprintf
-TYPE = DEFAULT
-EXE1 = test5
-Description
-= Tests _snprintf with the count specifier
add_subdirectory(test2)
add_subdirectory(test3)
add_subdirectory(test4)
-add_subdirectory(test5)
add_subdirectory(test6)
add_subdirectory(test7)
add_subdirectory(test8)
/*============================================================================
**
-** Source: _snprintf.h
+** Source: sprintf_s.h
**
-** Purpose: Containts common testing functions for _snprintf
+** Purpose: Containts common testing functions for sprintf_s
**
**
**==========================================================================*/
{
char buf[256] = { 0 };
- _snprintf(buf, 256, formatstr, param);
+ _snprintf_s(buf, 256, _TRUNCATE, formatstr, param);
if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0)
{
Fail("ERROR: failed to insert string \"%s\" into \"%s\"\n"
{
char buf[256] = { 0 };
- _snprintf(buf, 256, formatstr, param);
+ _snprintf_s(buf, 256, _TRUNCATE, formatstr, param);
if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0)
{
Fail("ERROR: failed to insert wide string \"%s\" into \"%s\"\n"
{
char buf[256] = { 0 };
- _snprintf(buf, 256, formatstr, param);
+ _snprintf_s(buf, 256, _TRUNCATE, formatstr, param);
if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0)
{
Fail("ERROR: failed to insert %s into \"%s\"\n"
char buf[512] = { 0 };
int n = -1;
- _snprintf(buf, 512, formatstr, &n);
+ sprintf_s(buf, 512, formatstr, &n);
if (n != param)
{
char buf[256] = { 0 };
short int n = -1;
- _snprintf(buf, 256, formatstr, &n);
+ _snprintf_s(buf, 256, _TRUNCATE, formatstr, &n);
if (n != param)
{
{
char buf[256] = { 0 };
- _snprintf(buf, 256, formatstr, param);
+ _snprintf_s(buf, 256, _TRUNCATE, formatstr, param);
if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0)
{
Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n"
{
char buf[256] = { 0 };
- _snprintf(buf, 256, formatstr, param);
+ _snprintf_s(buf, 256, _TRUNCATE, formatstr, param);
if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0)
{
Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n"
{
char buf[256] = { 0 };
- _snprintf(buf, 256, formatstr, value);
+ _snprintf_s(buf, 256, _TRUNCATE, formatstr, value);
if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0)
{
Fail("ERROR: failed to insert %#x into \"%s\"\n"
{
char buf[256] = { 0 };
- _snprintf(buf, 256, formatstr, value);
+ _snprintf_s(buf, 256, _TRUNCATE, formatstr, value);
if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0)
{
Fail("ERROR: failed to insert %s into \"%s\"\n"
{
char buf[256] = { 0 };
- _snprintf(buf, 256, formatstr, value);
+ _snprintf_s(buf, 256, _TRUNCATE, formatstr, value);
if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0
&& memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0)
{
{
char buf[256];
- _snprintf(buf, 256, formatstr, precision, param);
+ _snprintf_s(buf, 256, _TRUNCATE, formatstr, precision, param);
if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 &&
memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0)
{
{
char buf[256];
- _snprintf(buf, 256, formatstr, precision, param);
+ _snprintf_s(buf, 256, _TRUNCATE, formatstr, precision, param);
if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 &&
memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0)
{
**
** Source: test1.c
**
-** Purpose: General test to see if _snprintf works correctly
+** Purpose: General test to see if sprintf_s works correctly
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snprintf.h"
+#include "../_snprintf_s.h"
/*
* Notes: memcmp is used, as is strlen.
}
- _snprintf(buf, 256, "hello world");
+ _snprintf_s(buf, 256, _TRUNCATE, "hello world");
if (memcmp(checkstr, buf, strlen(checkstr)+1) != 0)
{
Fail("ERROR: expected \"%s\" (up to %d chars), got \"%s\"\n",
checkstr, 256, buf);
}
- _snprintf(buf, 256, "xxxxxxxxxxxxxxxxx");
- ret = _snprintf(buf, 8, "hello world");
+ _snprintf_s(buf, 256, _TRUNCATE, "xxxxxxxxxxxxxxxxx");
+ ret = _snprintf_s(buf, 8, _TRUNCATE, "hello world");
if (ret >= 0)
{
Fail("ERROR: expected negative return value, got %d", ret);
}
- if (memcmp(checkstr, buf, 8) != 0 || buf[8] != 'x')
+ if (memcmp(checkstr, buf, 7) != 0 || buf[7] != 0 || buf[8] != 'x')
{
Fail("ERROR: expected %s (up to %d chars), got %s\n",
checkstr, 8, buf);
Version = 1.0
Section = C Runtime
-Function = _snprintf
-Name = Positive Test for _snprintf
+Function = sprintf_s
+Name = Positive Test for sprintf_s
TYPE = DEFAULT
EXE1 = test1
Description
-= General test to see if _snprintf works correctly
+= General test to see if sprintf_s works correctly
**
** Source: test10.c
**
-** Purpose: Tests _snprintf with octal numbers
+** Purpose: Tests sprintf_s with octal numbers
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snprintf.h"
+#include "../_snprintf_s.h"
/*
* Notes: memcmp is used, as is strlen.
Version = 1.0
Section = C Runtime
-Function = _snprintf
-Name = Positive Test for _snprintf
+Function = sprintf_s
+Name = Positive Test for sprintf_s
TYPE = DEFAULT
EXE1 = test10
Description
-= Tests _snprintf with octal numbers
+= Tests sprintf_s with octal numbers
**
** Source: test11.c
**
-** Purpose: Tests _snprintf with unsigned numbers
+** Purpose: Tests sprintf_s with unsigned numbers
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snprintf.h"
+#include "../_snprintf_s.h"
/*
* Notes: memcmp is used, as is strlen.
Version = 1.0
Section = C Runtime
-Function = _snprintf
-Name = Positive Test for _snprintf
+Function = sprintf_s
+Name = Positive Test for sprintf_s
TYPE = DEFAULT
EXE1 = test11
Description
-= Tests _snprintf with unsigned numbers
+= Tests sprintf_s with unsigned numbers
**
** Source: test12.c
**
-** Purpose: Tests _snprintf with hex numbers (lowercase)
+** Purpose: Tests sprintf_s with hex numbers (lowercase)
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snprintf.h"
+#include "../_snprintf_s.h"
/*
* Notes: memcmp is used, as is strlen.
Version = 1.0
Section = C Runtime
-Function = _snprintf
-Name = Positive Test for _snprintf
+Function = sprintf_s
+Name = Positive Test for sprintf_s
TYPE = DEFAULT
EXE1 = test12
Description
-= Tests _snprintf with hex numbers (lowercase)
+= Tests sprintf_s with hex numbers (lowercase)
**
** Source: test13.c
**
-** Purpose: Tests _snprintf with hex numbers (uppercase)
+** Purpose: Tests sprintf_s with hex numbers (uppercase)
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snprintf.h"
+#include "../_snprintf_s.h"
/*
* Notes: memcmp is used, as is strlen.
Version = 1.0
Section = C Runtime
-Function = _snprintf
-Name = Positive Test for _snprintf
+Function = sprintf_s
+Name = Positive Test for sprintf_s
TYPE = DEFAULT
EXE1 = test13
Description
-= Tests _snprintf with hex numbers (uppercase)
+= Tests sprintf_s with hex numbers (uppercase)
**
** Source: test14.c
**
-** Purpose: Tests _snprintf with exponential format doubles (lowercase)
+** Purpose: Tests sprintf_s with exponential format doubles (lowercase)
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snprintf.h"
+#include "../_snprintf_s.h"
/*
* Notes: memcmp is used, as is strlen.
Version = 1.0
Section = C Runtime
-Function = _snprintf
-Name = Positive Test for _snprintf
+Function = sprintf_s
+Name = Positive Test for sprintf_s
TYPE = DEFAULT
EXE1 = test14
Description
-= Tests _snprintf with exponential format doubles (lowercase)
+= Tests sprintf_s with exponential format doubles (lowercase)
**
** Source: test15.c
**
-** Purpose: Tests _snprintf with exponential format doubles (uppercase)
+** Purpose: Tests sprintf_s with exponential format doubles (uppercase)
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snprintf.h"
+#include "../_snprintf_s.h"
/*
* Notes: memcmp is used, as is strlen.
Version = 1.0
Section = C Runtime
-Function = _snprintf
-Name = Positive Test for _snprintf
+Function = sprintf_s
+Name = Positive Test for sprintf_s
TYPE = DEFAULT
EXE1 = test15
Description
-= Tests _snprintf with exponential format doubles (uppercase)
+= Tests sprintf_s with exponential format doubles (uppercase)
**
** Source: test16.c
**
-** Purpose: Test #15 for the _snprintf function
+** Purpose: Test #15 for the sprintf_s function
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snprintf.h"
+#include "../_snprintf_s.h"
/*
* Notes: memcmp is used, as is strlen.
Version = 1.0
Section = C Runtime
-Function = _snprintf
-Name = Positive Test for _snprintf
+Function = sprintf_s
+Name = Positive Test for sprintf_s
TYPE = DEFAULT
EXE1 = test16
Description
-= Tests _snprintf with decimal point format doubles
+= Tests sprintf_s with decimal point format doubles
**
** Source: test17.c
**
-** Purpose: Tests _snprintf with compact format doubles (lowercase)
+** Purpose: Tests sprintf_s with compact format doubles (lowercase)
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snprintf.h"
+#include "../_snprintf_s.h"
/*
* Notes: memcmp is used, as is strlen.
Version = 1.0
Section = C Runtime
-Function = _snprintf
-Name = Positive Test for _snprintf
+Function = sprintf_s
+Name = Positive Test for sprintf_s
TYPE = DEFAULT
EXE1 = test17
Description
-= Tests _snprintf with compact format doubles (lowercase)
+= Tests sprintf_s with compact format doubles (lowercase)
**
** Source: test18.c
**
-** Purpose: Tests _snprintf with compact format doubles (uppercase)
+** Purpose: Tests sprintf_s with compact format doubles (uppercase)
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snprintf.h"
+#include "../_snprintf_s.h"
/*
* Notes: memcmp is used, as is strlen.
Version = 1.0
Section = C Runtime
-Function = _snprintf
-Name = Positive Test for _snprintf
+Function = sprintf_s
+Name = Positive Test for sprintf_s
TYPE = DEFAULT
EXE1 = test18
Description
-= Tests _snprintf with compact format doubles (uppercase)
+= Tests sprintf_s with compact format doubles (uppercase)
**
** Source: test19.c
**
-** Purpose:Tests _snprintf with argument specified precision
+** Purpose:Tests sprintf_s with argument specified precision
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snprintf.h"
+#include "../_snprintf_s.h"
/*
* Notes: memcmp is used, as is strlen.
DoArgumentPrecTest("%.*s", 2, (void*)"bar", "bar", "ba", "ba");
DoArgumentPrecTest("%.*S", 2, (void*)convert("bar"), "bar", "ba", "ba");
- DoArgumentPrecTest("%.*n", 3, (void*)&n, "pointer to int", "", "");
- if (n != 0)
- {
- Fail("ERROR: Expected count parameter to resolve to %d, got %X\n",
- 0, n);
- }
DoArgumentPrecTest("%.*c", 0, (void*)'a', "a", "a", "a");
DoArgumentPrecTest("%.*c", 4, (void*)'a', "a", "a", "a");
Version = 1.0
Section = C Runtime
-Function = _snprintf
-Name = Positive Test for _snprintf
+Function = sprintf_s
+Name = Positive Test for sprintf_s
TYPE = DEFAULT
EXE1 = test19
Description
-= Tests _snprintf with argument specified precision
+= Tests sprintf_s with argument specified precision
**
** Source: test2.c
**
-** Purpose:Tests _snprintf with strings
+** Purpose:Tests sprintf_s with strings
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snprintf.h"
+#include "../_snprintf_s.h"
/*
* Notes: memcmp is used, as is strlen.
*/
Version = 1.0
Section = C Runtime
-Function = _snprintf
-Name = Positive Test for _snprintf
+Function = sprintf_s
+Name = Positive Test for sprintf_s
TYPE = DEFAULT
EXE1 = test2
Description
-= Tests _snprintf with strings
+= Tests sprintf_s with strings
**
** Source: test3.c
**
-** Purpose: Tests _snprintf with wide strings
+** Purpose: Tests sprintf_s with wide strings
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snprintf.h"
+#include "../_snprintf_s.h"
/*
* Notes: memcmp is used, as is strlen.
Version = 1.0
Section = C Runtime
-Function = _snprintf
-Name = Positive Test for _snprintf
+Function = sprintf_s
+Name = Positive Test for sprintf_s
TYPE = DEFAULT
EXE1 = test3
Description
-= Tests _snprintf with wide strings
+= Tests sprintf_s with wide strings
**
** Source: test4.c
**
-** Purpose: Tests _snprintf with pointers
+** Purpose: Tests sprintf_s with pointers
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snprintf.h"
+#include "../_snprintf_s.h"
/*
* Notes: memcmp is used, as is strlen.
Version = 1.0
Section = C Runtime
-Function = _snprintf
-Name = Positive Test for _snprintf
+Function = sprintf_s
+Name = Positive Test for sprintf_s
TYPE = DEFAULT
EXE1 = test4
Description
-= Tests _snprintf with pointers
+= Tests sprintf_s with pointers
**
** Source: test6.c
**
-** Purpose: Tests _snprintf with characters
+** Purpose: Tests sprintf_s with characters
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snprintf.h"
+#include "../_snprintf_s.h"
/*
* Notes: memcmp is used, as is strlen.
Version = 1.0
Section = C Runtime
-Function = _snprintf
-Name =Positive Test for _snprintf
+Function = sprintf_s
+Name =Positive Test for sprintf_s
TYPE = DEFAULT
EXE1 = test6
Description
-= Tests _snprintf with characters
+= Tests sprintf_s with characters
**
** Source: test7.c
**
-** Purpose: Tests _snprintf with wide characters
+** Purpose: Tests sprintf_s with wide characters
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snprintf.h"
+#include "../_snprintf_s.h"
/*
* Notes: memcmp is used, as is strlen.
*/
Version = 1.0
Section = C Runtime
-Function = _snprintf
-Name = Positive Test for _snprintf
+Function = sprintf_s
+Name = Positive Test for sprintf_s
TYPE = DEFAULT
EXE1 = test7
Description
-= Tests _snprintf with wide characters
+= Tests sprintf_s with wide characters
**
** Source: test8.c
**
-** Purpose: Tests _snprintf with decimal numbers
+** Purpose: Tests sprintf_s with decimal numbers
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snprintf.h"
+#include "../_snprintf_s.h"
/*
* Notes: memcmp is used, as is strlen.
Version = 1.0
Section = C Runtime
-Function = _snprintf
-Name = Positive Test for _snprintf
+Function = sprintf_s
+Name = Positive Test for sprintf_s
TYPE = DEFAULT
EXE1 = test8
Description
-= Tests _snprintf with decimal numbers
+= Tests sprintf_s with decimal numbers
**
** Source: test9.c
**
-** Purpose: Tests _snprintf with integer numbers
+** Purpose: Tests sprintf_s with integer numbers
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snprintf.h"
+#include "../_snprintf_s.h"
/*
* Notes: memcmp is used, as is strlen.
Version = 1.0
Section = C Runtime
-Function = _snprintf
-Name = Positive Test for _snprintf
+Function = sprintf_s
+Name = Positive Test for sprintf_s
TYPE = DEFAULT
EXE1 = test9
Description
-= Tests _snprintf with integer numbers
+= Tests sprintf_s with integer numbers
+++ /dev/null
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(SOURCES
- test5.cpp
-)
-
-add_executable(paltest_snwprintf_test5
- ${SOURCES}
-)
-
-add_dependencies(paltest_snwprintf_test5 coreclrpal)
-
-target_link_libraries(paltest_snwprintf_test5
- pthread
- m
- coreclrpal
-)
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*============================================================================
-**
-** Source: test5.c
-**
-** Purpose: Tests _snwprintf with the count specifier
-**
-**
-**==========================================================================*/
-
-
-
-#include <palsuite.h>
-#include "../_snwprintf.h"
-
-/* memcmp is used to verify the results, so this test is dependent on it. */
-/* ditto with wcslen */
-
-int __cdecl main(int argc, char *argv[])
-{
- WCHAR *longStr;
- WCHAR *longResult;
-
- if (PAL_Initialize(argc, argv) != 0)
- {
- return FAIL;
- }
-
- longStr = convert("really-long-string-that-just-keeps-going-on-and-on-and-on.."
- "..................useless-filler.................................."
- "..................useless-filler.................................."
- "..................useless-filler.................................."
- "%n bar");
- longResult = convert("really-long-string-that-just-keeps-going-on-and-on-and-on.."
- "..................useless-filler.................................."
- "..................useless-filler.................................."
- "..................useless-filler.................................."
- " bar");
- DoCountTest(convert("foo %n bar"), 4, convert("foo bar"));
- DoCountTest(longStr, 257, longResult);
- DoCountTest(convert("fo%n bar"), 2, convert("fo bar"));
- DoCountTest(convert("%n"), 0, convert(""));
- DoCountTest(convert("foo %#n bar"), 4, convert("foo bar"));
- DoCountTest(convert("foo % n bar"), 4, convert("foo bar"));
- DoCountTest(convert("foo %+n bar"), 4, convert("foo bar"));
- DoCountTest(convert("foo %-n bar"), 4, convert("foo bar"));
- DoCountTest(convert("foo %0n bar"), 4, convert("foo bar"));
- DoShortCountTest(convert("foo %hn bar"), 4, convert("foo bar"));
- DoCountTest(convert("foo %ln bar"), 4, convert("foo bar"));
- DoCountTest(convert("foo %Ln bar"), 4, convert("foo bar"));
- DoCountTest(convert("foo %I64n bar"), 4, convert("foo bar"));
- DoCountTest(convert("foo %20.3n bar"), 4, convert("foo bar"));
-
- free(longStr);
- free(longResult);
-
- PAL_Terminate();
-
- return PASS;
-}
+++ /dev/null
-# Licensed to the .NET Foundation under one or more agreements.
-# The .NET Foundation licenses this file to you under the MIT license.
-# See the LICENSE file in the project root for more information.
-
-Version = 1.0
-Section = C Runtime
-Function = _snwprintf
-Name = Positive Test for _snwprintf
-TYPE = DEFAULT
-EXE1 = test5
-Description
-= Tests _snwprintf with the count specifier
add_subdirectory(test2)
add_subdirectory(test3)
add_subdirectory(test4)
-add_subdirectory(test5)
add_subdirectory(test6)
add_subdirectory(test7)
add_subdirectory(test8)
/*============================================================================
**
-** Source: _snwprintf.h
+** Source: swprintf_s.h
**
-** Purpose: Containts common testing functions for _snwprintf
+** Purpose: Containts common testing functions for swprintf_s
**
**
**==========================================================================*/
{
WCHAR buf[256] = { 0 };
- _snwprintf(buf, 256, formatstr, param);
+ _snwprintf_s(buf, 256, _TRUNCATE, formatstr, param);
if (memcmp(buf, checkstr, wcslen(checkstr) * 2 + 2) != 0)
{
{
WCHAR buf[256] = { 0 };
- _snwprintf(buf, 256, formatstr, param);
+ _snwprintf_s(buf, 256, _TRUNCATE, formatstr, param);
if (memcmp(buf, checkstr, wcslen(checkstr) * 2 + 2) != 0)
{
{
WCHAR buf[256] = { 0 };
- _snwprintf(buf, 256, formatstr, param);
+ _snwprintf_s(buf, 256, _TRUNCATE, formatstr, param);
if (memcmp(buf, checkstr1, wcslen(checkstr1)*2 + 2) != 0)
{
Fail("ERROR: failed to insert pointer to %#p into \"%s\"\n"
WCHAR buf[512] = { 0 };
int n = -1;
- _snwprintf(buf, 512, formatstr, &n);
+ swprintf_s(buf, 512, formatstr, &n);
if (n != param)
{
WCHAR buf[256] = { 0 };
short int n = -1;
- _snwprintf(buf, 256, formatstr, &n);
+ _snwprintf_s(buf, 256, _TRUNCATE, formatstr, &n);
if (n != param)
{
{
WCHAR buf[256] = { 0 };
- _snwprintf(buf, 256, formatstr, param);
+ _snwprintf_s(buf, 256, _TRUNCATE, formatstr, param);
if (memcmp(buf, checkstr, wcslen(checkstr)*2 + 2) != 0)
{
Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n"
{
WCHAR buf[256] = { 0 };
- _snwprintf(buf, 256, formatstr, param);
+ _snwprintf_s(buf, 256, _TRUNCATE, formatstr, param);
if (memcmp(buf, checkstr, wcslen(checkstr)*2 + 2) != 0)
{
Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n"
{
WCHAR buf[256] = { 0 };
- _snwprintf(buf, 256, formatstr, value);
+ _snwprintf_s(buf, 256, _TRUNCATE, formatstr, value);
if (memcmp(buf, checkstr, wcslen(checkstr)* 2 + 2) != 0)
{
Fail("ERROR: failed to insert %#x into \"%s\"\n"
{
WCHAR buf[256] = { 0 };
- _snwprintf(buf, 256, formatstr, param);
+ _snwprintf_s(buf, 256, _TRUNCATE, formatstr, param);
if (memcmp(buf, checkstr1, wcslen(checkstr1)*2 + 2) != 0)
{
Fail("ERROR: failed to insert %s into \"%s\"\n"
{
WCHAR buf[256] = { 0 };
- _snwprintf(buf, 256, formatstr, value);
+ _snwprintf_s(buf, 256, _TRUNCATE, formatstr, value);
if (memcmp(buf, checkstr1, wcslen(checkstr1)*2 + 2) != 0 &&
memcmp(buf, checkstr2, wcslen(checkstr2)*2 + 2) != 0)
{
{
WCHAR buf[256];
- _snwprintf(buf, 256, formatstr, precision, param);
+ _snwprintf_s(buf, 256, _TRUNCATE, formatstr, precision, param);
if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 &&
memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0)
{
{
WCHAR buf[256];
- _snwprintf(buf, 256, formatstr, precision, param);
+ _snwprintf_s(buf, 256, _TRUNCATE, formatstr, precision, param);
if (memcmp(buf, checkstr, wcslen(checkstr) + 2) != 0)
{
Fail("ERROR: failed to insert %f into \"%s\" with precision %d\n"
**
** Source: test1.c
**
-** Purpose: General test to see if _snwprintf works correctly
+** Purpose: General test to see if swprintf_s works correctly
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snwprintf.h"
+#include "../_snwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
}
checkstr = convert("hello world");
- _snwprintf(buf, 256, checkstr);
+ _snwprintf_s(buf, 256, _TRUNCATE, checkstr);
if (memcmp(checkstr, buf, wcslen(checkstr)*2+2) != 0)
{
Fail("ERROR: Expected \"%s\", got \"%s\"\n",
convertC(checkstr), convertC(buf));
}
- _snwprintf(buf, 256, convert("xxxxxxxxxxxxxxxxx"));
- ret = _snwprintf(buf, 8, checkstr);
- if (memcmp(checkstr, buf, 16) != 0)
+ _snwprintf_s(buf, 256, _TRUNCATE, convert("xxxxxxxxxxxxxxxxx"));
+ ret = _snwprintf_s(buf, 8, _TRUNCATE, checkstr);
+ if ((memcmp(checkstr, buf, 14) != 0) || (buf[7] != 0))
{
Fail("ERROR: Expected \"%8s\", got \"%8s\"\n",
convertC(checkstr), convertC(buf));
Version = 1.0
Section = C Runtime
-Function = _snwprintf
-Name = Positive Test for _snwprintf
+Function = swprintf_s
+Name = Positive Test for swprintf_s
TYPE = DEFAULT
EXE1 = test1
Description
-= General test to see if _snwprintf works correctly
+= General test to see if swprintf_s works correctly
**
** Source: test10.c
**
-** Purpose: Tests _snwprintf with octal numbers
+** Purpose: Tests swprintf_s with octal numbers
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snwprintf.h"
+#include "../_snwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _snwprintf
-Name = Positive Test for _snwprintf
+Function = swprintf_s
+Name = Positive Test for swprintf_s
TYPE = DEFAULT
EXE1 = test10
Description
-= Tests _snwprintf with octal numbers
+= Tests swprintf_s with octal numbers
**
** Source: test11.c
**
-** Purpose: Tests _snwprintf with unsigned numbers
+** Purpose: Tests swprintf_s with unsigned numbers
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snwprintf.h"
+#include "../_snwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _snwprintf
-Name = Positive Test for _snwprintf
+Function = swprintf_s
+Name = Positive Test for swprintf_s
TYPE = DEFAULT
EXE1 = test11
Description
-= Tests _snwprintf with unsigned numbers
+= Tests swprintf_s with unsigned numbers
**
** Source: test12.c
**
-** Purpose: Tests _snwprintf with hex numbers (lowercase)
+** Purpose: Tests swprintf_s with hex numbers (lowercase)
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snwprintf.h"
+#include "../_snwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _snwprintf
-Name = Positive Test for _snwprintf
+Function = swprintf_s
+Name = Positive Test for swprintf_s
TYPE = DEFAULT
EXE1 = test12
Description
-= Tests _snwprintf with hex numbers (lowercase)
+= Tests swprintf_s with hex numbers (lowercase)
**
** Source: test13.c
**
-** Purpose: Tests _snwprintf with hex numbers (uppercase)
+** Purpose: Tests swprintf_s with hex numbers (uppercase)
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snwprintf.h"
+#include "../_snwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _snwprintf
-Name = Positive Test for _snwprintf
+Function = swprintf_s
+Name = Positive Test for swprintf_s
TYPE = DEFAULT
EXE1 = test13
Description
-= Tests _snwprintf with hex numbers (uppercase)
+= Tests swprintf_s with hex numbers (uppercase)
**
** Source: test14.c
**
-** Purpose: Tests _snwprintf with exponential format doubles (lowercase)
+** Purpose: Tests swprintf_s with exponential format doubles (lowercase)
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snwprintf.h"
+#include "../_snwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _snwprintf
-Name = Positive Test for _snwprintf
+Function = swprintf_s
+Name = Positive Test for swprintf_s
TYPE = DEFAULT
EXE1 = test14
Description
-= Tests _snwprintf with exponential format doubles (lowercase)
+= Tests swprintf_s with exponential format doubles (lowercase)
**
** Source: test15.c
**
-** Purpose: Tests _snwprintf with exponential format doubles (uppercase)
+** Purpose: Tests swprintf_s with exponential format doubles (uppercase)
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snwprintf.h"
+#include "../_snwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _snwprintf
-Name = Positive Test for _snwprintf
+Function = swprintf_s
+Name = Positive Test for swprintf_s
TYPE = DEFAULT
EXE1 = test15
Description
-= Tests _snwprintf with exponential format doubles (uppercase)
+= Tests swprintf_s with exponential format doubles (uppercase)
**
** Source: test16.c
**
-** Purpose: Tests _snwprintf with decimal point format doubles
+** Purpose: Tests swprintf_s with decimal point format doubles
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snwprintf.h"
+#include "../_snwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _snwprintf
-Name = Positive Test for _snwprintf
+Function = swprintf_s
+Name = Positive Test for swprintf_s
TYPE = DEFAULT
EXE1 = test16
Description
-= Tests _snwprintf with decimal point format doubles
+= Tests swprintf_s with decimal point format doubles
**
** Source: test17.c
**
-** Purpose: Tests _snwprintf with compact format doubles (lowercase)
+** Purpose: Tests swprintf_s with compact format doubles (lowercase)
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snwprintf.h"
+#include "../_snwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _snwprintf
-Name = Positive Test for _snwprintf
+Function = swprintf_s
+Name = Positive Test for swprintf_s
TYPE = DEFAULT
EXE1 = test17
Description
-= Tests _snwprintf with compact format doubles (lowercase)
+= Tests swprintf_s with compact format doubles (lowercase)
**
** Source: test18.c
**
-** Purpose: Tests _snwprintf with compact format doubles (uppercase)
+** Purpose: Tests swprintf_s with compact format doubles (uppercase)
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snwprintf.h"
+#include "../_snwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _snwprintf
-Name = Positive Test for _snwprintf
+Function = swprintf_s
+Name = Positive Test for swprintf_s
TYPE = DEFAULT
EXE1 = test18
Description
-= Tests _snwprintf with compact format doubles (uppercase)
+= Tests swprintf_s with compact format doubles (uppercase)
**
** Source: test19.c
**
-** Purpose: Tests _snwprintf with argument specified precision
+** Purpose: Tests swprintf_s with argument specified precision
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snwprintf.h"
+#include "../_snwprintf_s.h"
int __cdecl main(int argc, char *argv[])
{
convert("ba"), convert("ba"));
DoArgumentPrecTest(convert("%.*S"), 2, (void*)"bar", "bar",
convert("ba"), convert("ba"));
- DoArgumentPrecTest(convert("%.*n"), 3, (void*)&n, "pointer to int",
- convert(""), convert(""));
- if (n != 0)
- {
- Fail("ERROR: Expected count parameter to resolve to %d, got %X\n",
- 0, n);
- }
-
DoArgumentPrecTest(convert("%.*c"), 0, (void*)'a', "a",
convert("a"), convert("a"));
DoArgumentPrecTest(convert("%.*c"), 4, (void*)'a', "a",
Version = 1.0
Section = C Runtime
-Function = _snwprintf
-Name = Positive Test for _snwprintf
+Function = swprintf_s
+Name = Positive Test for swprintf_s
TYPE = DEFAULT
EXE1 = test19
Description
-= Tests _snwprintf with argument specified precision
+= Tests swprintf_s with argument specified precision
**
** Source: test2.c
**
-** Purpose:Tests _snwprintf with strings
+** Purpose:Tests swprintf_s with strings
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snwprintf.h"
+#include "../_snwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _snwprintf
-Name = Positive Test for _snwprintf
+Function = swprintf_s
+Name = Positive Test for swprintf_s
TYPE = DEFAULT
EXE1 = test2
Description
-= Tests _snwprintf with strings
+= Tests swprintf_s with strings
**
** Source: test3.c
**
-** Purpose: Tests _snwprintf with wide strings
+** Purpose: Tests swprintf_s with wide strings
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snwprintf.h"
+#include "../_snwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _snwprintf
-Name = Positive Test for _snwprintf
+Function = swprintf_s
+Name = Positive Test for swprintf_s
TYPE = DEFAULT
EXE1 = test3
Description
-= Tests _snwprintf with wide strings
+= Tests swprintf_s with wide strings
**
** Source: test4.c
**
-** Purpose: Tests _snwprintf with pointers
+** Purpose: Tests swprintf_s with pointers
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snwprintf.h"
+#include "../_snwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _snwprintf
-Name = Positive Test for _snwprintf
+Function = swprintf_s
+Name = Positive Test for swprintf_s
TYPE = DEFAULT
EXE1 = test4
Description
-= Tests _snwprintf with pointers
+= Tests swprintf_s with pointers
**
** Source: test6.c
**
-** Purpose: Tests _snwprintf with characters
+** Purpose: Tests swprintf_s with characters
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snwprintf.h"
+#include "../_snwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _snwprintf
-Name = Positive Test for _snwprintf
+Function = swprintf_s
+Name = Positive Test for swprintf_s
TYPE = DEFAULT
EXE1 = test6
Description
-= Tests _snwprintf with characters
+= Tests swprintf_s with characters
**
** Source: test7.c
**
-** Purpose: Tests _snwprintf with wide characters
+** Purpose: Tests swprintf_s with wide characters
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snwprintf.h"
+#include "../_snwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _snwprintf
-Name = Positive Test for _snwprintf
+Function = swprintf_s
+Name = Positive Test for swprintf_s
TYPE = DEFAULT
EXE1 = test7
Description
-= Tests _snwprintf with wide characters
+= Tests swprintf_s with wide characters
**
** Source: test8.c
**
-** Purpose: Tests _snwprintf with decimal numbers
+** Purpose: Tests swprintf_s with decimal numbers
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snwprintf.h"
+#include "../_snwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _snwprintf
-Name = Positive Test for _snwprintf
+Function = swprintf_s
+Name = Positive Test for swprintf_s
TYPE = DEFAULT
EXE1 = test8
Description
-= Tests _snwprintf with decimal numbers
+= Tests swprintf_s with decimal numbers
**
** Source: test9.c
**
-** Purpose: Tests _snwprintf with integer numbers
+** Purpose: Tests swprintf_s with integer numbers
**
**
**==========================================================================*/
#include <palsuite.h>
-#include "../_snwprintf.h"
+#include "../_snwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _snwprintf
-Name = Positive Test for _snwprintf
+Function = swprintf_s
+Name = Positive Test for swprintf_s
TYPE = DEFAULT
EXE1 = test9
Description
-= Tests _snwprintf with integer numbers
+= Tests swprintf_s with integer numbers
EXE1 = test1
Description
= Tests the PAL implementation of the _vsnprintf function.
-= This test is modeled after _snprintf.
+= This test is modeled after sprintf_s.
Description
= Tests the PAL implementation of the _vsnprintf function.
= Tests _vsnprintf with octal numbers.
-= This test is modeled after _snprintf.
+= This test is modeled after sprintf_s.
Description
= Tests the PAL implementation of the _vsnprintf function.
= Tests _vsnprintf with unsigned numbers.
-= This test is modeled after _snprintf.
+= This test is modeled after sprintf_s.
Description
= Tests the PAL implementation of the _vsnprintf function.
= Tests _vsnprintf with hex numbers (lowercase).
-= This test is modeled after _snprintf.
+= This test is modeled after sprintf_s.
Description
= Tests the PAL implementation of the _vsnprintf function.
= Tests _vsnprintf with hex numbers (uppercase).
-= This test is modeled after _snprintf.
+= This test is modeled after sprintf_s.
Description
= Tests the PAL implementation of the _vsnprintf function.
= Tests _vsnprintf with exponential format doubles (lowercase).
-= This test is modeled after _snprintf.
+= This test is modeled after sprintf_s.
Description
= Tests the PAL implementation of the _vsnprintf function.
= Tests _vsnprintf with exponential format doubles (uppercase).
-= This test is modeled after _snprintf.
+= This test is modeled after sprintf_s.
Description
= Tests the PAL implementation of the _vsnprintf function.
= Tests _vsnprintf with decimal point format doubles.
-= This test is modeled after _snprintf.
+= This test is modeled after sprintf_s.
Description
= Tests the PAL implementation of the _vsnprintf function.
= Tests _vsnprintf with compact format doubles (lowercase).
-= This test is modeled after _snprintf.
+= This test is modeled after sprintf_s.
Description
= Tests the PAL implementation of the _vsnprintf function.
= Tests _vsnprintf with compact format doubles (uppercase).
-= This test is modeled after _snprintf.
+= This test is modeled after sprintf_s.
Description
= Tests the PAL implementation of the _vsnprintf function.
= Tests _vsnprintf with argument specified precision.
-= This test is modeled after _snprintf.
+= This test is modeled after sprintf_s.
Description
= Tests the PAL implementation of the _vsnprintf function.
= Tests _vsnprintf with strings.
-= This test is modeled after _snprintf.
+= This test is modeled after sprintf_s.
Description
= Tests the PAL implementation of the _vsnprintf function.
= Tests _vsnprintf with wide strings.
-= This test is modeled after _snprintf.
+= This test is modeled after sprintf_s.
Description
= Tests the PAL implementation of the _vsnprintf function.
= Tests _vsnprintf with pointers.
-= This test is modeled after _snprintf.
+= This test is modeled after sprintf_s.
Description
= Tests the PAL implementation of the _vsnprintf function.
= Tests _vsnprintf with the count specifier.
-= This test is modeled after _snprintf.
+= This test is modeled after sprintf_s.
Description
= Tests the PAL implementation of the _vsnprintf function.
= Tests _vsnprintf with characters.
-= This test is modeled after _snprintf.
+= This test is modeled after sprintf_s.
Description
= Tests the PAL implementation of the _vsnprintf function.
= Tests _vsnprintf with wide characters.
-= This test is modeled after _snprintf.
+= This test is modeled after sprintf_s.
Description
= Tests the PAL implementation of the _vsnprintf function.
= Tests _vsnprintf with decimal numbers.
-= This test is modeled after _snprintf.
+= This test is modeled after sprintf_s.
Description
= Tests the PAL implementation of the _vsnprintf function.
= Tests _vsnprintf with integer numbers.
-= This test is modeled after _snprintf.
+= This test is modeled after sprintf_s.
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=====================================================================
-**
-** Source: test4.c
-**
-** Purpose: Test #4 for the _vsnwprintf function.
-**
-**
-**===================================================================*/
-
-#include <palsuite.h>
-#include "../_vsnwprintf.h"
-
-/* memcmp is used to verify the results, so this test is dependent on it. */
-/* ditto with wcslen */
-static void DoPointerTest(WCHAR *formatstr, void* param, WCHAR* paramstr,
- WCHAR *checkstr1)
-{
- WCHAR buf[256] = { 0 };
-
- TestVsnwprintf(buf, 256, formatstr, param);
- if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0)
-
- {
- Fail("ERROR: failed to insert pointer to %#p into \"%s\"\n"
- "Expected \"%s\" got \"%s\".\n",
- paramstr,
- convertC(formatstr),
- convertC(checkstr1),
- convertC(buf));
- }
-}
-
-static void DoI64DoubleTest(WCHAR *formatstr, INT64 value, WCHAR *valuestr,
- WCHAR *checkstr1)
-{
- WCHAR buf[256] = { 0 };
-
- TestVsnwprintf(buf, 256, formatstr, value);
- if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0)
- {
- Fail("ERROR: failed to insert %s into \"%s\"\n"
- "Expected \"%s\", got \"%s\".\n",
- value,
- convertC(formatstr),
- convertC(checkstr1),
- convertC(buf));
- }
-}
-
-int __cdecl main(int argc, char *argv[])
-{
- void *ptr = (void*) 0x123456;
- INT64 lptr = I64(0x1234567887654321);
-
- if (PAL_Initialize(argc, argv) != 0)
- {
- return(FAIL);
- }
-
-/*
-** Run only on 64 bit platforms
-*/
-#if defined(BIT64) && defined(PLATFORM_UNIX)
- Trace("Testing for 64 Bit Platforms \n");
- DoPointerTest(convert("%p"), NULL, convert("NULL"), convert("00000000"));
- DoPointerTest(convert("%p"), ptr, convert("pointer to 0x123456"),
- convert("0000000000123456"));
- DoPointerTest(convert("%17p"), ptr, convert("pointer to 0x123456"),
- convert(" 0000000000123456"));
- DoPointerTest(convert("%17p"), ptr, convert("pointer to 0x123456"),
- convert(" 0000000000123456"));
- DoPointerTest(convert("%-17p"), ptr, convert("pointer to 0x123456"),
- convert("0000000000123456 "));
- DoPointerTest(convert("%+p"), ptr, convert("pointer to 0x123456"),
- convert("0000000000123456"));
- DoPointerTest(convert("%#p"), ptr, convert("pointer to 0x123456"),
- convert("0X0000000000123456"));
- DoPointerTest(convert("%lp"), ptr, convert("pointer to 0x123456"),
- convert("00123456"));
- DoPointerTest(convert("%hp"), ptr, convert("pointer to 0x123456"),
- convert("00003456"));
- DoPointerTest(convert("%Lp"), ptr, convert("pointer to 0x123456"),
- convert("00123456"));
- DoI64DoubleTest(convert("%I64p"), lptr,
- convert("pointer to 0x1234567887654321"),
- convert("1234567887654321"));
-
-#else
- Trace("Testing for Non 64 Bit Platforms \n");
- DoPointerTest(convert("%p"), NULL, convert("NULL"), convert("00000000"));
- DoPointerTest(convert("%p"), ptr, convert("pointer to 0x123456"),
- convert("00123456"));
- DoPointerTest(convert("%9p"), ptr, convert("pointer to 0x123456"),
- convert(" 00123456"));
- DoPointerTest(convert("%09p"), ptr, convert("pointer to 0x123456"),
- convert(" 00123456"));
- DoPointerTest(convert("%-9p"), ptr, convert("pointer to 0x123456"),
- convert("00123456 "));
- DoPointerTest(convert("%+p"), ptr, convert("pointer to 0x123456"),
- convert("00123456"));
- DoPointerTest(convert("%#p"), ptr, convert("pointer to 0x123456"),
- convert("0X00123456"));
- DoPointerTest(convert("%lp"), ptr, convert("pointer to 0x123456"),
- convert("00123456"));
- DoPointerTest(convert("%hp"), ptr, convert("pointer to 0x123456"),
- convert("00003456"));
- DoPointerTest(convert("%Lp"), ptr, convert("pointer to 0x123456"),
- convert("00123456"));
- DoI64DoubleTest(convert("%I64p"), lptr,
- convert("pointer to 0x1234567887654321"),
- convert("1234567887654321"));
-#endif
-
- PAL_Terminate();
- return PASS;
-}
-
+++ /dev/null
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(SOURCES
- test5.cpp
-)
-
-add_executable(paltest_vsnwprintf_test5
- ${SOURCES}
-)
-
-add_dependencies(paltest_vsnwprintf_test5 coreclrpal)
-
-target_link_libraries(paltest_vsnwprintf_test5
- pthread
- m
- coreclrpal
-)
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=====================================================================
-**
-** Source: test5.c
-**
-** Purpose: Test #5 for the _vsnwprintf function.
-**
-**
-**===================================================================*/
-
-#include <palsuite.h>
-#include "../_vsnwprintf.h"
-
-/* memcmp is used to verify the results, so this test is dependent on it. */
-/* ditto with wcslen */
-
-static void DoTest(WCHAR *formatstr, int param, WCHAR *checkstr)
-{
- WCHAR buf[256] = { 0 };
- int n = -1;
-
- TestVsnwprintf(buf, 256, formatstr, &n);
-
- if (n != param)
- {
- Fail("ERROR: Expected count parameter to resolve to %d, got %d\n",
- param, n);
- }
-
- if (memcmp(buf, checkstr, wcslen(buf)*2 + 2) != 0)
- {
- Fail("ERROR: Expected \"%s\" got \"%s\".\n",
- convertC(checkstr), convertC(buf));
- }
-}
-
-static void DoShortTest(WCHAR *formatstr, int param, WCHAR *checkstr)
-{
- WCHAR buf[256] = { 0 };
- short int n = -1;
-
- TestVsnwprintf(buf, 256, formatstr, &n);
-
- if (n != param)
- {
- Fail("ERROR: Expected count parameter to resolve to %d, got %d\n",
- param, n);
- }
-
- if (memcmp(buf, checkstr, wcslen(buf)*2 + 2) != 0)
- {
- Fail("ERROR: Expected \"%s\" got \"%s\".\n",
- convertC(checkstr), convertC(buf));
- }
-}
-
-int __cdecl main(int argc, char *argv[])
-{
- if (PAL_Initialize(argc, argv) != 0)
- {
- return(FAIL);
- }
-
- DoTest(convert("foo %n bar"), 4, convert("foo bar"));
- DoTest(convert("foo %#n bar"), 4, convert("foo bar"));
- DoTest(convert("foo % n bar"), 4, convert("foo bar"));
- DoTest(convert("foo %+n bar"), 4, convert("foo bar"));
- DoTest(convert("foo %-n bar"), 4, convert("foo bar"));
- DoTest(convert("foo %0n bar"), 4, convert("foo bar"));
- DoShortTest(convert("foo %hn bar"), 4, convert("foo bar"));
- DoTest(convert("foo %ln bar"), 4, convert("foo bar"));
- DoTest(convert("foo %Ln bar"), 4, convert("foo bar"));
- DoTest(convert("foo %I64n bar"), 4, convert("foo bar"));
- DoTest(convert("foo %20.3n bar"), 4, convert("foo bar"));
-
- PAL_Terminate();
- return PASS;
-}
+++ /dev/null
-# Licensed to the .NET Foundation under one or more agreements.
-# The .NET Foundation licenses this file to you under the MIT license.
-# See the LICENSE file in the project root for more information.
-
-Version = 1.0
-Section = C Runtime
-Function = _vsnwprintf
-Name = Positive Test for _vsnwprintf
-TYPE = DEFAULT
-EXE1 = test5
-Description
-= Tests the PAL implementation of the _vsnwprintf function.
-= Tests _vsnwprintf with the count specifier.
-= This test is modeled after _snwprintf.
add_subdirectory(test2)
add_subdirectory(test3)
add_subdirectory(test4)
-add_subdirectory(test5)
add_subdirectory(test6)
add_subdirectory(test7)
add_subdirectory(test8)
/*============================================================================
**
-** Source: _vsnwprintf.h
+** Source: _vsnwprintf_s.h
**
-** Purpose: Containts common testing functions for _vsnwprintf
+** Purpose: Containts common testing functions for _vsnwprintf_s
**
**
**==========================================================================*/
#define ___VSNWPRINTF_H__
/* These functions leaks memory like crazy. C'est la vie. */
-int TestVsnwprintf(wchar_t* buf, size_t count, const wchar_t* format, ...)
+int TestVsnwprintf_s(wchar_t* buf, size_t count, const wchar_t* format, ...)
{
int retVal = 0;
va_list arglist;
va_start(arglist, format);
- retVal = _vsnwprintf(buf, count, format, arglist);
+ retVal = _vsnwprintf_s(buf, count, _TRUNCATE, format, arglist);
va_end(arglist);
return( retVal);
{
WCHAR buf[256] = { 0 };
- TestVsnwprintf(buf, 256, formatstr, param);
+ TestVsnwprintf_s(buf, 256, formatstr, param);
if (memcmp(buf, checkstr, wcslen(buf) * 2 + 2) != 0)
{
{
WCHAR buf[256] = { 0 };
- TestVsnwprintf(buf, 256, formatstr, param);
+ TestVsnwprintf_s(buf, 256, formatstr, param);
if (memcmp(buf, checkstr, wcslen(buf) * 2 + 2) != 0)
{
{
WCHAR buf[256] = { 0 };
- TestVsnwprintf(buf, 256, formatstr, param);
+ TestVsnwprintf_s(buf, 256, formatstr, param);
if (memcmp(buf, checkstr, wcslen(buf)*2 + 2) != 0)
{
Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n"
{
WCHAR buf[256] = { 0 };
- TestVsnwprintf(buf, 256, formatstr, param);
+ TestVsnwprintf_s(buf, 256, formatstr, param);
if (memcmp(buf, checkstr, wcslen(buf)*2 + 2) != 0)
{
Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n"
{
WCHAR buf[256] = { 0 };
- TestVsnwprintf(buf, 256, formatstr, value);
+ TestVsnwprintf_s(buf, 256, formatstr, value);
if (memcmp(buf, checkstr, wcslen(buf)* 2 + 2) != 0)
{
Fail("ERROR: failed to insert %#x into \"%s\"\n"
{
WCHAR buf[256] = { 0 };
- TestVsnwprintf(buf, 256, formatstr, value);
+ TestVsnwprintf_s(buf, 256, formatstr, value);
if (memcmp(buf, checkstr, wcslen(buf)* 2 + 2) != 0)
{
Fail("ERROR: failed to insert %s into \"%s\"\n"
{
WCHAR buf[256] = { 0 };
- TestVsnwprintf(buf, 256, formatstr, value);
+ TestVsnwprintf_s(buf, 256, formatstr, value);
if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 &&
memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0)
{
**
** Source: test1.c
**
-** Purpose: Test #1 for the _vsnwprintf function.
+** Purpose: Test #1 for the _vsnwprintf_s function.
**
**
**===================================================================*/
#include <palsuite.h>
-#include "../_vsnwprintf.h"
+#include "../_vsnwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
}
checkstr = convert("hello world");
- TestVsnwprintf(buf, 256, checkstr);
+ TestVsnwprintf_s(buf, 256, checkstr);
if (memcmp(checkstr, buf, wcslen(checkstr)*2+2) != 0)
{
Fail("ERROR: Expected \"%s\", got \"%s\"\n",
convertC(checkstr), convertC(buf));
}
- TestVsnwprintf(buf, 256, convert("xxxxxxxxxxxxxxxxx"));
- ret = TestVsnwprintf(buf, 8, checkstr);
- if (memcmp(checkstr, buf, 16) != 0)
+ TestVsnwprintf_s(buf, 256, convert("xxxxxxxxxxxxxxxxx"));
+ ret = TestVsnwprintf_s(buf, 8, checkstr);
+ if ((memcmp(checkstr, buf, 14)) != 0 || (buf[7] != 0))
{
Fail("ERROR: Expected \"%8s\", got \"%8s\"\n",
convertC(checkstr), convertC(buf));
Version = 1.0
Section = C Runtime
-Function = _vsnwprintf
-Name = Positive Test for _vsnwprintf
+Function = _vsnwprintf_s
+Name = Positive Test for _vsnwprintf_s
TYPE = DEFAULT
EXE1 = test1
Description
-= Tests the PAL implementation of the _vsnwprintf function.
-= General test to see if _vsnwprintf works correctly.
+= Tests the PAL implementation of the _vsnwprintf_s function.
+= General test to see if _vsnwprintf_s works correctly.
= This test is modeled after _snwprintf.
**
** Source: test10.c
**
-** Purpose: Test #10 for the _vsnwprintf function.
+** Purpose: Test #10 for the _vsnwprintf_s function.
**
**
**===================================================================*/
#include <palsuite.h>
-#include "../_vsnwprintf.h"
+#include "../_vsnwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _vsnwprintf
-Name = Positive Test for _vsnwprintf
+Function = _vsnwprintf_s
+Name = Positive Test for _vsnwprintf_s
TYPE = DEFAULT
EXE1 = test10
Description
-= Tests the PAL implementation of the _vsnwprintf function.
-= Tests _vsnwprintf with octal numbers.
+= Tests the PAL implementation of the _vsnwprintf_s function.
+= Tests _vsnwprintf_s with octal numbers.
= This test is modeled after _snwprintf.
**
** Source: test11.c
**
-** Purpose: Test #11 for the _vsnwprintf function.
+** Purpose: Test #11 for the _vsnwprintf_s function.
**
**
**===================================================================*/
#include <palsuite.h>
-#include "../_vsnwprintf.h"
+#include "../_vsnwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _vsnwprintf
-Name = Positive Test for _vsnwprintf
+Function = _vsnwprintf_s
+Name = Positive Test for _vsnwprintf_s
TYPE = DEFAULT
EXE1 = test11
Description
-= Tests the PAL implementation of the _vsnwprintf function.
-= Tests _vsnwprintf with unsigned numbers.
+= Tests the PAL implementation of the _vsnwprintf_s function.
+= Tests _vsnwprintf_s with unsigned numbers.
= This test is modeled after _snwprintf.
**
** Source: test12.c
**
-** Purpose: Test #12 for the _vsnwprintf function.
+** Purpose: Test #12 for the _vsnwprintf_s function.
**
**
**===================================================================*/
#include <palsuite.h>
-#include "../_vsnwprintf.h"
+#include "../_vsnwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _vsnwprintf
-Name = Positive Test for _vsnwprintf
+Function = _vsnwprintf_s
+Name = Positive Test for _vsnwprintf_s
TYPE = DEFAULT
EXE1 = test12
Description
-= Tests the PAL implementation of the _vsnwprintf function.
-= Tests _vsnwprintf with hex numbers (lowercase).
+= Tests the PAL implementation of the _vsnwprintf_s function.
+= Tests _vsnwprintf_s with hex numbers (lowercase).
= This test is modeled after _snwprintf.
**
** Source: test13.c
**
-** Purpose: Test #13 for the _vsnwprintf function.
+** Purpose: Test #13 for the _vsnwprintf_s function.
**
**
**===================================================================*/
#include <palsuite.h>
-#include "../_vsnwprintf.h"
+#include "../_vsnwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _vsnwprintf
-Name = Positive Test for _vsnwprintf
+Function = _vsnwprintf_s
+Name = Positive Test for _vsnwprintf_s
TYPE = DEFAULT
EXE1 = test13
Description
-= Tests the PAL implementation of the _vsnwprintf function.
-= Tests _vsnwprintf with hex numbers (uppercase).
+= Tests the PAL implementation of the _vsnwprintf_s function.
+= Tests _vsnwprintf_s with hex numbers (uppercase).
= This test is modeled after _snwprintf.
**
** Source: test14.c
**
-** Purpose: Test #14 for the _vsnwprintf function.
+** Purpose: Test #14 for the _vsnwprintf_s function.
**
**
**===================================================================*/
#include <palsuite.h>
-#include "../_vsnwprintf.h"
+#include "../_vsnwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _vsnwprintf
-Name = Positive Test for _vsnwprintf
+Function = _vsnwprintf_s
+Name = Positive Test for _vsnwprintf_s
TYPE = DEFAULT
EXE1 = test14
Description
-= Tests the PAL implementation of the _vsnwprintf function.
-= Tests _vsnwprintf with exponential format doubles (lowercase).
+= Tests the PAL implementation of the _vsnwprintf_s function.
+= Tests _vsnwprintf_s with exponential format doubles (lowercase).
= This test is modeled after _snwprintf.
**
** Source: test15.c
**
-** Purpose: Test #15 for the _vsnwprintf function.
+** Purpose: Test #15 for the _vsnwprintf_s function.
**
**
**===================================================================*/
#include <palsuite.h>
-#include "../_vsnwprintf.h"
+#include "../_vsnwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _vsnwprintf
-Name = Positive Test for _vsnwprintf
+Function = _vsnwprintf_s
+Name = Positive Test for _vsnwprintf_s
TYPE = DEFAULT
EXE1 = test15
Description
-= Tests the PAL implementation of the _vsnwprintf function.
-= Tests _vsnwprintf with exponential format doubles (uppercase).
+= Tests the PAL implementation of the _vsnwprintf_s function.
+= Tests _vsnwprintf_s with exponential format doubles (uppercase).
= This test is modeled after _snwprintf.
**
** Source: test16.c
**
-** Purpose: Test #16 for the _vsnwprintf function.
+** Purpose: Test #16 for the _vsnwprintf_s function.
**
**
**===================================================================*/
#include <palsuite.h>
-#include "../_vsnwprintf.h"
+#include "../_vsnwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _vsnwprintf
-Name = Positive Test for _vsnwprintf
+Function = _vsnwprintf_s
+Name = Positive Test for _vsnwprintf_s
TYPE = DEFAULT
EXE1 = test16
Description
-= Tests the PAL implementation of the _vsnwprintf function.
-= Tests _vsnwprintf with decimal point format doubles.
+= Tests the PAL implementation of the _vsnwprintf_s function.
+= Tests _vsnwprintf_s with decimal point format doubles.
= This test is modeled after _snwprintf.
**
** Source: test17.c
**
-** Purpose: Test #17 for the _vsnwprintf function.
+** Purpose: Test #17 for the _vsnwprintf_s function.
**
**
**===================================================================*/
#include <palsuite.h>
-#include "../_vsnwprintf.h"
+#include "../_vsnwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _vsnwprintf
-Name = Positive Test for _vsnwprintf
+Function = _vsnwprintf_s
+Name = Positive Test for _vsnwprintf_s
TYPE = DEFAULT
EXE1 = test17
Description
-= Tests the PAL implementation of the _vsnwprintf function.
-= Tests _vsnwprintf with compact format doubles (lowercase).
+= Tests the PAL implementation of the _vsnwprintf_s function.
+= Tests _vsnwprintf_s with compact format doubles (lowercase).
= This test is modeled after _snwprintf.
**
** Source: test18.c
**
-** Purpose: Test #18 for the _vsnwprintf function.
+** Purpose: Test #18 for the _vsnwprintf_s function.
**
**
**===================================================================*/
#include <palsuite.h>
-#include "../_vsnwprintf.h"
+#include "../_vsnwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _vsnwprintf
-Name = Positive Test for _vsnwprintf
+Function = _vsnwprintf_s
+Name = Positive Test for _vsnwprintf_s
TYPE = DEFAULT
EXE1 = test18
Description
-= Tests the PAL implementation of the _vsnwprintf function.
-= Tests _vsnwprintf with compact format doubles (uppercase).
+= Tests the PAL implementation of the _vsnwprintf_s function.
+= Tests _vsnwprintf_s with compact format doubles (uppercase).
= This test is modeled after _snwprintf.
**
** Source: test18.c
**
-** Purpose: Test #18 for the _vsnwprintf function.
+** Purpose: Test #18 for the _vsnwprintf_s function.
**
**
**===================================================================*/
#include <palsuite.h>
-#include "../_vsnwprintf.h"
+#include "../_vsnwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
{
WCHAR buf[256];
- TestVsnwprintf(buf, 256, formatstr, precision, param);
+ TestVsnwprintf_s(buf, 256, formatstr, precision, param);
if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 &&
memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0)
{
{
WCHAR buf[256];
- TestVsnwprintf(buf, 256, formatstr, precision, param);
+ TestVsnwprintf_s(buf, 256, formatstr, precision, param);
if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 &&
memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0)
{
Version = 1.0
Section = C Runtime
-Function = _vsnwprintf
-Name = Positive Test for _vsnwprintf
+Function = _vsnwprintf_s
+Name = Positive Test for _vsnwprintf_s
TYPE = DEFAULT
EXE1 = test19
Description
-= Tests the PAL implementation of the _vsnwprintf function.
-= Tests _vsnwprintf with argument specified precision.
+= Tests the PAL implementation of the _vsnwprintf_s function.
+= Tests _vsnwprintf_s with argument specified precision.
= This test is modeled after _snwprintf.
**
** Source: test2.c
**
-** Purpose: Test #2 for the _vsnwprintf function.
+** Purpose: Test #2 for the _vsnwprintf_s function.
**
**
**===================================================================*/
#include <palsuite.h>
-#include "../_vsnwprintf.h"
+#include "../_vsnwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _vsnwprintf
-Name = Positive Test for _vsnwprintf
+Function = _vsnwprintf_s
+Name = Positive Test for _vsnwprintf_s
TYPE = DEFAULT
EXE1 = test2
Description
-= Tests the PAL implementation of the _vsnwprintf function.
-= Tests _vsnwprintf with strings.
+= Tests the PAL implementation of the _vsnwprintf_s function.
+= Tests _vsnwprintf_s with strings.
= This test is modeled after _snwprintf.
**
** Source: test3.c
**
-** Purpose: Test #3 for the _vsnwprintf function.
+** Purpose: Test #3 for the _vsnwprintf_s function.
**
**
**===================================================================*/
#include <palsuite.h>
-#include "../_vsnwprintf.h"
+#include "../_vsnwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _vsnwprintf
-Name = Positive Test for _vsnwprintf
+Function = _vsnwprintf_s
+Name = Positive Test for _vsnwprintf_s
TYPE = DEFAULT
EXE1 = test3
Description
-= Tests the PAL implementation of the _vsnwprintf function.
-= Tests _vsnwprintf with wide strings.
+= Tests the PAL implementation of the _vsnwprintf_s function.
+= Tests _vsnwprintf_s with wide strings.
= This test is modeled after _snwprintf.
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/*=====================================================================
+**
+** Source: test4.c
+**
+** Purpose: Test #4 for the _vsnwprintf_s function.
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+#include "../_vsnwprintf_s.h"
+
+/* memcmp is used to verify the results, so this test is dependent on it. */
+/* ditto with wcslen */
+static void DoPointerTest(WCHAR *formatstr, void* param, WCHAR* paramstr,
+ WCHAR *checkstr1)
+{
+ WCHAR buf[256] = { 0 };
+
+ TestVsnwprintf_s(buf, 256, formatstr, param);
+ if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0)
+
+ {
+ Fail("ERROR: failed to insert pointer to %#p into \"%s\"\n"
+ "Expected \"%s\" got \"%s\".\n",
+ paramstr,
+ convertC(formatstr),
+ convertC(checkstr1),
+ convertC(buf));
+ }
+}
+
+static void DoI64DoubleTest(WCHAR *formatstr, INT64 value, WCHAR *valuestr,
+ WCHAR *checkstr1)
+{
+ WCHAR buf[256] = { 0 };
+
+ TestVsnwprintf_s(buf, 256, formatstr, value);
+ if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0)
+ {
+ Fail("ERROR: failed to insert %s into \"%s\"\n"
+ "Expected \"%s\", got \"%s\".\n",
+ value,
+ convertC(formatstr),
+ convertC(checkstr1),
+ convertC(buf));
+ }
+}
+
+int __cdecl main(int argc, char *argv[])
+{
+ void *ptr = (void*) 0x123456;
+ INT64 lptr = I64(0x1234567887654321);
+
+ if (PAL_Initialize(argc, argv) != 0)
+ {
+ return(FAIL);
+ }
+
+/*
+** Run only on 64 bit platforms
+*/
+#if defined(BIT64) && defined(PLATFORM_UNIX)
+ Trace("Testing for 64 Bit Platforms \n");
+ DoPointerTest(convert("%p"), NULL, convert("NULL"), convert("00000000"));
+ DoPointerTest(convert("%p"), ptr, convert("pointer to 0x123456"),
+ convert("0000000000123456"));
+ DoPointerTest(convert("%17p"), ptr, convert("pointer to 0x123456"),
+ convert(" 0000000000123456"));
+ DoPointerTest(convert("%17p"), ptr, convert("pointer to 0x123456"),
+ convert(" 0000000000123456"));
+ DoPointerTest(convert("%-17p"), ptr, convert("pointer to 0x123456"),
+ convert("0000000000123456 "));
+ DoPointerTest(convert("%+p"), ptr, convert("pointer to 0x123456"),
+ convert("0000000000123456"));
+ DoPointerTest(convert("%#p"), ptr, convert("pointer to 0x123456"),
+ convert("0X0000000000123456"));
+ DoPointerTest(convert("%lp"), ptr, convert("pointer to 0x123456"),
+ convert("00123456"));
+ DoPointerTest(convert("%hp"), ptr, convert("pointer to 0x123456"),
+ convert("00003456"));
+ DoPointerTest(convert("%Lp"), ptr, convert("pointer to 0x123456"),
+ convert("00123456"));
+ DoI64DoubleTest(convert("%I64p"), lptr,
+ convert("pointer to 0x1234567887654321"),
+ convert("1234567887654321"));
+
+#else
+ Trace("Testing for Non 64 Bit Platforms \n");
+ DoPointerTest(convert("%p"), NULL, convert("NULL"), convert("00000000"));
+ DoPointerTest(convert("%p"), ptr, convert("pointer to 0x123456"),
+ convert("00123456"));
+ DoPointerTest(convert("%9p"), ptr, convert("pointer to 0x123456"),
+ convert(" 00123456"));
+ DoPointerTest(convert("%09p"), ptr, convert("pointer to 0x123456"),
+ convert(" 00123456"));
+ DoPointerTest(convert("%-9p"), ptr, convert("pointer to 0x123456"),
+ convert("00123456 "));
+ DoPointerTest(convert("%+p"), ptr, convert("pointer to 0x123456"),
+ convert("00123456"));
+ DoPointerTest(convert("%#p"), ptr, convert("pointer to 0x123456"),
+ convert("0X00123456"));
+ DoPointerTest(convert("%lp"), ptr, convert("pointer to 0x123456"),
+ convert("00123456"));
+ DoPointerTest(convert("%hp"), ptr, convert("pointer to 0x123456"),
+ convert("00003456"));
+ DoPointerTest(convert("%Lp"), ptr, convert("pointer to 0x123456"),
+ convert("00123456"));
+ DoI64DoubleTest(convert("%I64p"), lptr,
+ convert("pointer to 0x1234567887654321"),
+ convert("1234567887654321"));
+#endif
+
+ PAL_Terminate();
+ return PASS;
+}
+
Version = 1.0
Section = C Runtime
-Function = _vsnwprintf
-Name = Positive Test for _vsnwprintf
+Function = _vsnwprintf_s
+Name = Positive Test for _vsnwprintf_s
TYPE = DEFAULT
EXE1 = test4
Description
-= Tests the PAL implementation of the _vsnwprintf function.
-= Tests _vsnwprintf with pointers.
+= Tests the PAL implementation of the _vsnwprintf_s function.
+= Tests _vsnwprintf_s with pointers.
= This test is modeled after _snwprintf.
**
** Source: test6.c
**
-** Purpose: Test #6 for the _vsnwprintf function.
+** Purpose: Test #6 for the _vsnwprintf_s function.
**
**
**===================================================================*/
#include <palsuite.h>
-#include "../_vsnwprintf.h"
+#include "../_vsnwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _vsnwprintf
-Name = Positive Test for _vsnwprintf
+Function = _vsnwprintf_s
+Name = Positive Test for _vsnwprintf_s
TYPE = DEFAULT
EXE1 = test6
Description
-= Tests the PAL implementation of the _vsnwprintf function.
-= Tests _vsnwprintf with characters.
+= Tests the PAL implementation of the _vsnwprintf_s function.
+= Tests _vsnwprintf_s with characters.
= This test is modeled after _snwprintf.
**
** Source: test7.c
**
-** Purpose: Test #7 for the _vsnwprintf function.
+** Purpose: Test #7 for the _vsnwprintf_s function.
**
**
**===================================================================*/
#include <palsuite.h>
-#include "../_vsnwprintf.h"
+#include "../_vsnwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _vsnwprintf
-Name = Positive Test for _vsnwprintf
+Function = _vsnwprintf_s
+Name = Positive Test for _vsnwprintf_s
TYPE = DEFAULT
EXE1 = test7
Description
-= Tests the PAL implementation of the _vsnwprintf function.
-= Tests _vsnwprintf with wide characters.
+= Tests the PAL implementation of the _vsnwprintf_s function.
+= Tests _vsnwprintf_s with wide characters.
= This test is modeled after _snwprintf.
**
** Source: test8.c
**
-** Purpose: Test #8 for the _vsnwprintf function.
+** Purpose: Test #8 for the _vsnwprintf_s function.
**
**
**===================================================================*/
#include <palsuite.h>
-#include "../_vsnwprintf.h"
+#include "../_vsnwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _vsnwprintf
-Name = Positive Test for _vsnwprintf
+Function = _vsnwprintf_s
+Name = Positive Test for _vsnwprintf_s
TYPE = DEFAULT
EXE1 = test8
Description
-= Tests the PAL implementation of the _vsnwprintf function.
-= Tests _vsnwprintf with decimal numbers.
+= Tests the PAL implementation of the _vsnwprintf_s function.
+= Tests _vsnwprintf_s with decimal numbers.
= This test is modeled after _snwprintf.
**
** Source: test9.c
**
-** Purpose: Test #9 for the _vsnwprintf function.
+** Purpose: Test #9 for the _vsnwprintf_s function.
**
**
**===================================================================*/
#include <palsuite.h>
-#include "../_vsnwprintf.h"
+#include "../_vsnwprintf_s.h"
/* memcmp is used to verify the results, so this test is dependent on it. */
/* ditto with wcslen */
Version = 1.0
Section = C Runtime
-Function = _vsnwprintf
-Name = Positive Test for _vsnwprintf
+Function = _vsnwprintf_s
+Name = Positive Test for _vsnwprintf_s
TYPE = DEFAULT
EXE1 = test9
Description
-= Tests the PAL implementation of the _vsnwprintf function.
-= Tests _vsnwprintf with integer numbers
+= Tests the PAL implementation of the _vsnwprintf_s function.
+= Tests _vsnwprintf_s with integer numbers
= This test is modeled after _snwprintf.
c_runtime/_putw/test1/paltest_putw_test1
c_runtime/_rotl/test1/paltest_rotl_test1
c_runtime/_rotr/test1/paltest_rotr_test1
-c_runtime/_snprintf/test1/paltest_snprintf_test1
-c_runtime/_snprintf/test10/paltest_snprintf_test10
-c_runtime/_snprintf/test11/paltest_snprintf_test11
-c_runtime/_snprintf/test12/paltest_snprintf_test12
-c_runtime/_snprintf/test13/paltest_snprintf_test13
-c_runtime/_snprintf/test14/paltest_snprintf_test14
-c_runtime/_snprintf/test15/paltest_snprintf_test15
-c_runtime/_snprintf/test16/paltest_snprintf_test16
-c_runtime/_snprintf/test17/paltest_snprintf_test17
-c_runtime/_snprintf/test18/paltest_snprintf_test18
-c_runtime/_snprintf/test19/paltest_snprintf_test19
-c_runtime/_snprintf/test2/paltest_snprintf_test2
-c_runtime/_snprintf/test3/paltest_snprintf_test3
-c_runtime/_snprintf/test4/paltest_snprintf_test4
-c_runtime/_snprintf/test5/paltest_snprintf_test5
-c_runtime/_snprintf/test6/paltest_snprintf_test6
-c_runtime/_snprintf/test7/paltest_snprintf_test7
-c_runtime/_snprintf/test8/paltest_snprintf_test8
-c_runtime/_snprintf/test9/paltest_snprintf_test9
-c_runtime/_snwprintf/test1/paltest_snwprintf_test1
-c_runtime/_snwprintf/test10/paltest_snwprintf_test10
-c_runtime/_snwprintf/test11/paltest_snwprintf_test11
-c_runtime/_snwprintf/test12/paltest_snwprintf_test12
-c_runtime/_snwprintf/test13/paltest_snwprintf_test13
-c_runtime/_snwprintf/test14/paltest_snwprintf_test14
-c_runtime/_snwprintf/test15/paltest_snwprintf_test15
-c_runtime/_snwprintf/test16/paltest_snwprintf_test16
-c_runtime/_snwprintf/test17/paltest_snwprintf_test17
-c_runtime/_snwprintf/test18/paltest_snwprintf_test18
-c_runtime/_snwprintf/test19/paltest_snwprintf_test19
-c_runtime/_snwprintf/test3/paltest_snwprintf_test3
-c_runtime/_snwprintf/test4/paltest_snwprintf_test4
-c_runtime/_snwprintf/test5/paltest_snwprintf_test5
-c_runtime/_snwprintf/test6/paltest_snwprintf_test6
-c_runtime/_snwprintf/test8/paltest_snwprintf_test8
-c_runtime/_snwprintf/test9/paltest_snwprintf_test9
+c_runtime/_snprintf_s/test1/paltest_snprintf_test1
+c_runtime/_snprintf_s/test10/paltest_snprintf_test10
+c_runtime/_snprintf_s/test11/paltest_snprintf_test11
+c_runtime/_snprintf_s/test12/paltest_snprintf_test12
+c_runtime/_snprintf_s/test13/paltest_snprintf_test13
+c_runtime/_snprintf_s/test14/paltest_snprintf_test14
+c_runtime/_snprintf_s/test15/paltest_snprintf_test15
+c_runtime/_snprintf_s/test16/paltest_snprintf_test16
+c_runtime/_snprintf_s/test17/paltest_snprintf_test17
+c_runtime/_snprintf_s/test18/paltest_snprintf_test18
+c_runtime/_snprintf_s/test19/paltest_snprintf_test19
+c_runtime/_snprintf_s/test2/paltest_snprintf_test2
+c_runtime/_snprintf_s/test3/paltest_snprintf_test3
+c_runtime/_snprintf_s/test4/paltest_snprintf_test4
+c_runtime/_snprintf_s/test6/paltest_snprintf_test6
+c_runtime/_snprintf_s/test7/paltest_snprintf_test7
+c_runtime/_snprintf_s/test8/paltest_snprintf_test8
+c_runtime/_snprintf_s/test9/paltest_snprintf_test9
+c_runtime/_snwprintf_s/test1/paltest_snwprintf_test1
+c_runtime/_snwprintf_s/test10/paltest_snwprintf_test10
+c_runtime/_snwprintf_s/test11/paltest_snwprintf_test11
+c_runtime/_snwprintf_s/test12/paltest_snwprintf_test12
+c_runtime/_snwprintf_s/test13/paltest_snwprintf_test13
+c_runtime/_snwprintf_s/test14/paltest_snwprintf_test14
+c_runtime/_snwprintf_s/test15/paltest_snwprintf_test15
+c_runtime/_snwprintf_s/test16/paltest_snwprintf_test16
+c_runtime/_snwprintf_s/test17/paltest_snwprintf_test17
+c_runtime/_snwprintf_s/test18/paltest_snwprintf_test18
+c_runtime/_snwprintf_s/test19/paltest_snwprintf_test19
+c_runtime/_snwprintf_s/test3/paltest_snwprintf_test3
+c_runtime/_snwprintf_s/test4/paltest_snwprintf_test4
+c_runtime/_snwprintf_s/test6/paltest_snwprintf_test6
+c_runtime/_snwprintf_s/test8/paltest_snwprintf_test8
+c_runtime/_snwprintf_s/test9/paltest_snwprintf_test9
c_runtime/_stricmp/test1/paltest_stricmp_test1
c_runtime/_strlwr/test1/paltest_strlwr_test1
c_runtime/_strnicmp/test1/paltest_strnicmp_test1
c_runtime/_vsnprintf/test7/paltest_vsnprintf_test7
c_runtime/_vsnprintf/test8/paltest_vsnprintf_test8
c_runtime/_vsnprintf/test9/paltest_vsnprintf_test9
-c_runtime/_vsnwprintf/test1/paltest_vsnwprintf_test1
-c_runtime/_vsnwprintf/test10/paltest_vsnwprintf_test10
-c_runtime/_vsnwprintf/test11/paltest_vsnwprintf_test11
-c_runtime/_vsnwprintf/test12/paltest_vsnwprintf_test12
-c_runtime/_vsnwprintf/test13/paltest_vsnwprintf_test13
-c_runtime/_vsnwprintf/test14/paltest_vsnwprintf_test14
-c_runtime/_vsnwprintf/test15/paltest_vsnwprintf_test15
-c_runtime/_vsnwprintf/test16/paltest_vsnwprintf_test16
-c_runtime/_vsnwprintf/test17/paltest_vsnwprintf_test17
-c_runtime/_vsnwprintf/test18/paltest_vsnwprintf_test18
-c_runtime/_vsnwprintf/test19/paltest_vsnwprintf_test19
-c_runtime/_vsnwprintf/test3/paltest_vsnwprintf_test3
-c_runtime/_vsnwprintf/test4/paltest_vsnwprintf_test4
-c_runtime/_vsnwprintf/test5/paltest_vsnwprintf_test5
-c_runtime/_vsnwprintf/test6/paltest_vsnwprintf_test6
-c_runtime/_vsnwprintf/test8/paltest_vsnwprintf_test8
-c_runtime/_vsnwprintf/test9/paltest_vsnwprintf_test9
+c_runtime/_vsnwprintf_s/test1/paltest_vsnwprintf_test1
+c_runtime/_vsnwprintf_s/test10/paltest_vsnwprintf_test10
+c_runtime/_vsnwprintf_s/test11/paltest_vsnwprintf_test11
+c_runtime/_vsnwprintf_s/test12/paltest_vsnwprintf_test12
+c_runtime/_vsnwprintf_s/test13/paltest_vsnwprintf_test13
+c_runtime/_vsnwprintf_s/test14/paltest_vsnwprintf_test14
+c_runtime/_vsnwprintf_s/test15/paltest_vsnwprintf_test15
+c_runtime/_vsnwprintf_s/test16/paltest_vsnwprintf_test16
+c_runtime/_vsnwprintf_s/test17/paltest_vsnwprintf_test17
+c_runtime/_vsnwprintf_s/test18/paltest_vsnwprintf_test18
+c_runtime/_vsnwprintf_s/test19/paltest_vsnwprintf_test19
+c_runtime/_vsnwprintf_s/test3/paltest_vsnwprintf_test3
+c_runtime/_vsnwprintf_s/test4/paltest_vsnwprintf_test4
+c_runtime/_vsnwprintf_s/test6/paltest_vsnwprintf_test6
+c_runtime/_vsnwprintf_s/test8/paltest_vsnwprintf_test8
+c_runtime/_vsnwprintf_s/test9/paltest_vsnwprintf_test9
c_runtime/_wcsicmp/test1/paltest_wcsicmp_test1
c_runtime/_wcslwr/test1/paltest_wcslwr_test1
c_runtime/_wcsnicmp/test1/paltest_wcsnicmp_test1
c_runtime/_gcvt/test1/paltest_gcvt_test1
c_runtime/_gcvt/test2/paltest_gcvt_test2
c_runtime/_getw/test1/paltest_getw_test1
-c_runtime/_snwprintf/test2/paltest_snwprintf_test2
-c_runtime/_snwprintf/test7/paltest_snwprintf_test7
-c_runtime/_vsnwprintf/test2/paltest_vsnwprintf_test2
-c_runtime/_vsnwprintf/test7/paltest_vsnwprintf_test7
+c_runtime/_snwprintf_s/test2/paltest_snwprintf_test2
+c_runtime/_snwprintf_s/test7/paltest_snwprintf_test7
+c_runtime/_vsnwprintf_s/test2/paltest_vsnwprintf_test2
+c_runtime/_vsnwprintf_s/test7/paltest_vsnwprintf_test7
debug_api/DebugBreak/test1/paltest_debugbreak_test1
debug_api/OutputDebugStringA/test1/paltest_outputdebugstringa_test1
debug_api/WriteProcessMemory/test1/paltest_writeprocessmemory_test1
c_runtime/_putw/test1,1
c_runtime/_rotl/test1,1
c_runtime/_rotr/test1,1
-c_runtime/_snprintf/test1,1
-c_runtime/_snprintf/test2,1
-c_runtime/_snprintf/test3,1
-c_runtime/_snprintf/test4,1
-c_runtime/_snprintf/test5,1
-c_runtime/_snprintf/test6,1
-c_runtime/_snprintf/test7,1
-c_runtime/_snprintf/test8,1
-c_runtime/_snprintf/test9,1
-c_runtime/_snprintf/test10,1
-c_runtime/_snprintf/test11,1
-c_runtime/_snprintf/test12,1
-c_runtime/_snprintf/test13,1
-c_runtime/_snprintf/test14,1
-c_runtime/_snprintf/test15,1
-c_runtime/_snprintf/test16,1
-c_runtime/_snprintf/test17,1
-c_runtime/_snprintf/test18,1
-c_runtime/_snprintf/test19,1
-c_runtime/_snwprintf/test1,1
-c_runtime/_snwprintf/test2,1
-c_runtime/_snwprintf/test3,1
-c_runtime/_snwprintf/test4,1
-c_runtime/_snwprintf/test5,1
-c_runtime/_snwprintf/test6,1
-c_runtime/_snwprintf/test7,1
-c_runtime/_snwprintf/test8,1
-c_runtime/_snwprintf/test9,1
-c_runtime/_snwprintf/test10,1
-c_runtime/_snwprintf/test11,1
-c_runtime/_snwprintf/test12,1
-c_runtime/_snwprintf/test13,1
-c_runtime/_snwprintf/test14,1
-c_runtime/_snwprintf/test15,1
-c_runtime/_snwprintf/test16,1
-c_runtime/_snwprintf/test17,1
-c_runtime/_snwprintf/test18,1
-c_runtime/_snwprintf/test19,1
+c_runtime/_snprintf_s/test1,1
+c_runtime/_snprintf_s/test2,1
+c_runtime/_snprintf_s/test3,1
+c_runtime/_snprintf_s/test4,1
+c_runtime/_snprintf_s/test6,1
+c_runtime/_snprintf_s/test7,1
+c_runtime/_snprintf_s/test8,1
+c_runtime/_snprintf_s/test9,1
+c_runtime/_snprintf_s/test10,1
+c_runtime/_snprintf_s/test11,1
+c_runtime/_snprintf_s/test12,1
+c_runtime/_snprintf_s/test13,1
+c_runtime/_snprintf_s/test14,1
+c_runtime/_snprintf_s/test15,1
+c_runtime/_snprintf_s/test16,1
+c_runtime/_snprintf_s/test17,1
+c_runtime/_snprintf_s/test18,1
+c_runtime/_snprintf_s/test19,1
+c_runtime/_snwprintf_s/test1,1
+c_runtime/_snwprintf_s/test2,1
+c_runtime/_snwprintf_s/test3,1
+c_runtime/_snwprintf_s/test4,1
+c_runtime/_snwprintf_s/test6,1
+c_runtime/_snwprintf_s/test7,1
+c_runtime/_snwprintf_s/test8,1
+c_runtime/_snwprintf_s/test9,1
+c_runtime/_snwprintf_s/test10,1
+c_runtime/_snwprintf_s/test11,1
+c_runtime/_snwprintf_s/test12,1
+c_runtime/_snwprintf_s/test13,1
+c_runtime/_snwprintf_s/test14,1
+c_runtime/_snwprintf_s/test15,1
+c_runtime/_snwprintf_s/test16,1
+c_runtime/_snwprintf_s/test17,1
+c_runtime/_snwprintf_s/test18,1
+c_runtime/_snwprintf_s/test19,1
c_runtime/_stricmp/test1,1
c_runtime/_strlwr/test1,1
c_runtime/_strnicmp/test1,1
c_runtime/_vsnprintf/test17,1
c_runtime/_vsnprintf/test18,1
c_runtime/_vsnprintf/test19,1
-c_runtime/_vsnwprintf/test1,1
-c_runtime/_vsnwprintf/test2,1
-c_runtime/_vsnwprintf/test3,1
-c_runtime/_vsnwprintf/test4,1
-c_runtime/_vsnwprintf/test5,1
-c_runtime/_vsnwprintf/test6,1
-c_runtime/_vsnwprintf/test7,1
-c_runtime/_vsnwprintf/test8,1
-c_runtime/_vsnwprintf/test9,1
-c_runtime/_vsnwprintf/test10,1
-c_runtime/_vsnwprintf/test11,1
-c_runtime/_vsnwprintf/test12,1
-c_runtime/_vsnwprintf/test13,1
-c_runtime/_vsnwprintf/test14,1
-c_runtime/_vsnwprintf/test15,1
-c_runtime/_vsnwprintf/test16,1
-c_runtime/_vsnwprintf/test17,1
-c_runtime/_vsnwprintf/test18,1
-c_runtime/_vsnwprintf/test19,1
+c_runtime/_vsnwprintf_s/test1,1
+c_runtime/_vsnwprintf_s/test2,1
+c_runtime/_vsnwprintf_s/test3,1
+c_runtime/_vsnwprintf_s/test4,1
+c_runtime/_vsnwprintf_s/test5,1
+c_runtime/_vsnwprintf_s/test6,1
+c_runtime/_vsnwprintf_s/test7,1
+c_runtime/_vsnwprintf_s/test8,1
+c_runtime/_vsnwprintf_s/test9,1
+c_runtime/_vsnwprintf_s/test10,1
+c_runtime/_vsnwprintf_s/test11,1
+c_runtime/_vsnwprintf_s/test12,1
+c_runtime/_vsnwprintf_s/test13,1
+c_runtime/_vsnwprintf_s/test14,1
+c_runtime/_vsnwprintf_s/test15,1
+c_runtime/_vsnwprintf_s/test16,1
+c_runtime/_vsnwprintf_s/test17,1
+c_runtime/_vsnwprintf_s/test18,1
+c_runtime/_vsnwprintf_s/test19,1
c_runtime/_wcsicmp/test1,1
c_runtime/_wcslwr/test1,1
c_runtime/_wcsnicmp/test1,1
}
ZeroMemory( lpCommandLine, MAX_PATH );
- if ( _snprintf( lpCommandLine, MAX_PATH-1, "childprocess ") < 0 )
+ if ( sprintf_s( lpCommandLine, MAX_PATH-1, "childprocess ") < 0 )
{
Fail ("Error: Insufficient lpCommandline for\n");
}
}
/* Open the event to tell test thread we are ready. */
- if (_snprintf(szEventName, MAX_LONGPATH-1, "%s%d", szcHelperProcessReadyEvName, dwProcessId) < 0)
+ if (sprintf_s(szEventName, MAX_LONGPATH-1, "%s%d", szcHelperProcessReadyEvName, dwProcessId) < 0)
{
Fail ("helper.main: Insufficient event name string length for pid=%d\n", dwProcessId);
}
}
/* Open the event to let test thread tell us to exit. */
- if (_snprintf(szEventName, MAX_LONGPATH-1, "%s%d", szcHelperProcessFinishEvName, dwProcessId) < 0)
+ if (sprintf_s(szEventName, MAX_LONGPATH-1, "%s%d", szcHelperProcessFinishEvName, dwProcessId) < 0)
{
Fail ("helper.main: Insufficient event name string length for pid=%d\n", dwProcessId);
}
}
/* Create the event to let helper process tell us it is ready. */
- if (_snprintf(szEventName, MAX_PATH-1, "%s%d",
+ if (sprintf_s(szEventName, MAX_PATH-1, "%s%d",
szcHelperProcessReadyEvName, helper_process[i].pi.dwProcessId) < 0)
{
Fail ("test5.Setup: Insufficient event name string length for %s\n", szcHelperProcessReadyEvName);
}
/* Create the event to tell helper process to exit. */
- if (_snprintf(szEventName, MAX_PATH-1, "%s%d",
+ if (sprintf_s(szEventName, MAX_PATH-1, "%s%d",
szcHelperProcessFinishEvName, helper_process[i].pi.dwProcessId) < 0)
{
Fail ("test5.Setup: Insufficient event name string length for %s\n", szcHelperProcessFinishEvName);
}
}
- _snprintf(szEventName, 128, "%s_Event", szTestName);
+ sprintf_s(szEventName, 128, "%s_Event", szTestName);
szEventName[127] = 0;
- _snprintf(szMutexName, 128, "%s_Mutex", szTestName);
+ sprintf_s(szMutexName, 128, "%s_Mutex", szTestName);
szMutexName[127] = 0;
- _snprintf(szSemName, 128, "%s_Semaphore", szTestName);
+ sprintf_s(szSemName, 128, "%s_Semaphore", szTestName);
szSemName[127] = 0;
iRet = MultiByteToWideChar(CP_ACP, 0, szEventName, strlen(szEventName)+1, wszEventName, 128);
dwThreadNum = (DWORD)pArg;
- _snprintf (szTestName, 128, "Test6_%u", dwThreadNum);
+ sprintf_s (szTestName, 128, "Test6_%u", dwThreadNum);
szTestName[127] = 0;
- _snprintf(szEventName, 128, "%s_Event", szTestName);
+ sprintf_s(szEventName, 128, "%s_Event", szTestName);
szEventName[127] = 0;
- _snprintf(szMutexName, 128, "%s_Mutex", szTestName);
+ sprintf_s(szMutexName, 128, "%s_Mutex", szTestName);
szMutexName[127] = 0;
- _snprintf(szSemName, 128, "%s_Semaphore", szTestName);
+ sprintf_s(szSemName, 128, "%s_Semaphore", szTestName);
szSemName[127] = 0;
iRet = MultiByteToWideChar(CP_ACP, 0, szEventName, strlen(szEventName)+1, wszEventName, 128);
si.cb = sizeof(si);
ZeroMemory ( &pi, sizeof(pi) );
- _snprintf (szCmd, 128, "child6 -event %s", szTestName);
+ sprintf_s (szCmd, 128, "child6 -event %s", szTestName);
szCmd[127] = 0;
bRet = CreateProcessA(NULL, szCmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
si.cb = sizeof(si);
ZeroMemory ( &pi, sizeof(pi) );
- _snprintf (szCmd, 128, "child6 -semaphore %s", szTestName);
+ sprintf_s (szCmd, 128, "child6 -semaphore %s", szTestName);
szCmd[127] = 0;
bRet = CreateProcessA(NULL, szCmd, NULL, NULL, FALSE,
si.cb = sizeof(si);
ZeroMemory ( &pi, sizeof(pi) );
- _snprintf (szCmd, 128, "child6 -mutex %s -exitcode %d", szTestName, iDesiredExitCode);
+ sprintf_s (szCmd, 128, "child6 -mutex %s -exitcode %d", szTestName, iDesiredExitCode);
szCmd[127] = 0;
bRet = CreateProcessA(NULL, szCmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
si.cb = sizeof(si);
ZeroMemory ( &pi, sizeof(pi) );
- _snprintf (szCmd, 128, "child6 -mutex_and_named_event %s", szTestName);
+ sprintf_s (szCmd, 128, "child6 -mutex_and_named_event %s", szTestName);
szCmd[127] = 0;
bRet = CreateProcessA(NULL, szCmd, NULL, NULL, FALSE,
else
if (errno!=0 && errno!=EBADF && errno!=ERANGE)
{
- CONSISTENCY_CHECK_MSG(FALSE, "_vsnwprintf failed. Potential globalization bug.");
+ CONSISTENCY_CHECK_MSG(FALSE, "_vsnwprintf_s failed. Potential globalization bug.");
ThrowHR(HRESULT_FROM_WIN32(ERROR_NO_UNICODE_TRANSLATION));
}
}
else
if (errno!=0 && errno!=EBADF && errno!=ERANGE)
{
- CONSISTENCY_CHECK_MSG(FALSE, "_vsnwprintf failed. Potential globalization bug.");
+ CONSISTENCY_CHECK_MSG(FALSE, "_vsnwprintf_s failed. Potential globalization bug.");
ThrowHR(HRESULT_FROM_WIN32(ERROR_NO_UNICODE_TRANSLATION));
}
}
if (*pNamespace != 0)
{
- if(FAILED(StringCchPrintfA(szBuffer, iBuffer, "%s.%s.%s", pNamespace, pClassName, pSigString)))
+ if (_snprintf_s(szBuffer, iBuffer, _TRUNCATE, "%s.%s.%s", pNamespace, pClassName, pSigString) == -1)
return false;
}
else
{
- if(FAILED(StringCchPrintfA(szBuffer, iBuffer, "%s.%s", pClassName, pSigString)))
+ if (_snprintf_s(szBuffer, iBuffer, _TRUNCATE, "%s.%s", pClassName, pSigString) == -1)
return false;
}