return retVal;
}
-int CoreVfwprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const wchar_16 *format, va_list ap)
+int CoreVfwprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const wchar_16 *format, va_list aparg)
{
CHAR TempBuff[1024]; /* used to hold a single %<foo> format string */
LPCWSTR Fmt = format;
int written=0;
int paddingReturnValue;
int ret;
+ va_list ap;
/* fwprintf for now in the PAL is always used on file opened
in text mode. In those case the output should be ANSI not Unicode */
PERF_ENTRY(vfwprintf);
ENTRY("vfwprintf (stream=%p, format=%p (%S))\n",
stream, format, format);
+
+ va_copy(ap, aparg);
while (*Fmt)
{
ERROR( "InternalMalloc failed.\n" );
LOGEXIT("vfwprintf returns int -1\n");
PERF_EXIT(vfwprintf);
+ va_end(ap);
return -1;
}
}
" to wide char.\n" );
LOGEXIT("vfwprintf returns int -1\n");
PERF_EXIT(vfwprintf);
+ va_end(ap);
return -1;
}
}
{
InternalFree(pthrCurrent, TempWStr);
}
+ va_end(ap);
return -1;
}
if (PRECISION_DOT == Precision)
InternalFree(pthrCurrent, WorkingWStr);
LOGEXIT("wcsncpy_s failed!\n");
PERF_EXIT(vfwprintf);
+ va_end(ap);
return (-1);
}
InternalFree(pthrCurrent, WorkingWStr);
LOGEXIT("vfwprintf returns int -1\n");
PERF_EXIT(vfwprintf);
+ va_end(ap);
return (-1);
}
written += paddingReturnValue;
ERROR("Internal_AddPaddingVfwprintf failed\n");
LOGEXIT("vfwprintf returns int -1\n");
PERF_EXIT(vfwprintf);
+ va_end(ap);
return(-1);
}
written += paddingReturnValue;
LOGEXIT("vfwprintf returns int -1\n");
PERF_EXIT(vfwprintf);
pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ va_end(ap);
return -1;
}
LOGEXIT("vfwprintf returns int -1\n");
PERF_EXIT(vfwprintf);
pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ va_end(ap);
return -1;
}
va_copy(apcopy, ap);
TempInt = NativeVsnprintf(pthrCurrent, TempSprintfStr, TEMP_COUNT, TempBuff, apcopy);
+ va_end(apcopy);
+ PAL_printf_arg_remover(&ap, Precision, Type, Prefix);
if (TempInt < 0 || static_cast<size_t>(TempInt) >= TEMP_COUNT)
{
LOGEXIT("vfwprintf returns int -1\n");
PERF_EXIT(vfwprintf);
pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ va_end(ap);
return -1;
}
TempSprintfStr = TempSprintfStrPtr;
- va_end(apcopy);
va_copy(apcopy, ap);
NativeVsnprintf(pthrCurrent, TempSprintfStr, TempInt, TempBuff, apcopy);
+ va_end(apcopy);
+ PAL_printf_arg_remover(&ap, Precision, Type, Prefix);
}
-
- va_copy(ap, apcopy);
- va_end(apcopy);
}
mbtowcResult = MultiByteToWideChar(CP_ACP, 0,
}
LOGEXIT("vfwprintf returns int -1\n");
PERF_EXIT(vfwprintf);
+ va_end(ap);
return -1;
}
{
InternalFree(pthrCurrent, TempSprintfStrPtr);
}
+ va_end(ap);
return -1;
}
{
InternalFree(pthrCurrent, TempSprintfStrPtr);
}
+ va_end(ap);
return -1;
}
if(TempSprintfStrPtr)
ERROR("fwrite() failed with errno == %d\n", errno);
LOGEXIT("vfwprintf returns int -1\n");
PERF_EXIT(vfwprintf);
+ va_end(ap);
return -1;
}
++written;
LOGEXIT("vfwprintf returns int %d\n", written);
PERF_EXIT(vfwprintf);
+ va_end(ap);
return (written);
}
-int CoreVsnprintf(CPalThread *pthrCurrent, LPSTR Buffer, size_t Count, LPCSTR Format, va_list ap)
+int CoreVsnprintf(CPalThread *pthrCurrent, LPSTR Buffer, size_t Count, LPCSTR Format, va_list aparg)
{
BOOL BufferRanOut = FALSE;
CHAR TempBuff[1024]; /* used to hold a single %<foo> format string */
INT Length;
INT TempInt;
int wctombResult;
+ va_list ap;
+
+ va_copy(ap, aparg);
while (*Fmt)
{
{
ASSERT("WideCharToMultiByte failed. Error is %d\n",
GetLastError());
+ va_end(ap);
return -1;
}
TempStr = (LPSTR) InternalMalloc(pthrCurrent, Length);
{
ERROR("InternalMalloc failed\n");
pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ va_end(ap);
return -1;
}
if (PRECISION_DOT == Precision)
ASSERT("WideCharToMultiByte failed. Error is %d\n",
GetLastError());
InternalFree(pthrCurrent, TempStr);
+ va_end(ap);
return -1;
}
TempStr[Length] = 0;
ASSERT("WideCharToMultiByte failed. Error is %d\n",
GetLastError());
InternalFree(pthrCurrent, TempStr);
+ va_end(ap);
return -1;
}
--Length; /* exclude null char */
{
ASSERT("WideCharToMultiByte failed. Error is %d\n",
GetLastError());
+ va_end(ap);
return -1;
}
TempBuffer[Length] = 0;
}
else
{
- TempInt = NativeVsnprintf(pthrCurrent, BufferPtr, TempCount, TempBuff, ap);
+ va_list apcopy;
+ va_copy(apcopy, ap);
+ TempInt = NativeVsnprintf(pthrCurrent, BufferPtr, TempCount, TempBuff, apcopy);
+ va_end(apcopy);
+ PAL_printf_arg_remover(&ap, Precision, Type, Prefix);
}
if (TempInt < 0 || static_cast<size_t>(TempInt) >= TempCount) /* buffer not long enough */
*BufferPtr = 0; /* end the string */
}
+ va_end(ap);
+
if (BufferRanOut)
{
errno = ERANGE;
}
}
-int CoreWvsnprintf(CPalThread *pthrCurrent, LPWSTR Buffer, size_t Count, LPCWSTR Format, va_list ap)
+int CoreWvsnprintf(CPalThread *pthrCurrent, LPWSTR Buffer, size_t Count, LPCWSTR Format, va_list aparg)
{
BOOL BufferRanOut = FALSE;
CHAR TempBuff[1024]; /* used to hold a single %<foo> format string */
INT TempInt;
LPSTR TempNumberBuffer;
int mbtowcResult;
+ va_list(ap);
PERF_ENTRY(wvsnprintf);
ENTRY("wvsnprintf (buffer=%p, count=%u, format=%p (%S))\n",
Buffer, Count, Format, Format);
+
+ va_copy(ap, aparg);
while (*Fmt)
{
else
{
ERROR( "InternalMalloc failed.\n" );
+ va_end(ap);
return -1;
}
}
{
ASSERT( "Unable to convert from multibyte "
" to wide char.\n" );
+ va_end(ap);
return -1;
}
{
InternalFree(pthrCurrent, TempWStr);
}
+ va_end(ap);
return -1;
}
if (PRECISION_DOT == Precision)
InternalFree(pthrCurrent, WorkingWStr);
LOGEXIT("wcsncpy_s failed!\n");
PERF_EXIT(wvsnprintf);
+ va_end(ap);
return (-1);
}
}
else
{
- TempInt = NativeVsnprintf(pthrCurrent, (LPSTR) BufferPtr, TempCount, TempBuff, ap);
+ va_list apcopy;
+ va_copy(apcopy, ap);
+ TempInt = NativeVsnprintf(pthrCurrent, (LPSTR) BufferPtr, TempCount, TempBuff, apcopy);
+ va_end(apcopy);
+ PAL_printf_arg_remover(&ap, Precision, Type, Prefix);
}
if (TempInt == 0)
ERROR("InternalMalloc failed\n");
pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY);
errno = ENOMEM;
+ va_end(ap);
return -1;
}
{
ASSERT("strncpy_s failed!\n");
InternalFree(pthrCurrent, TempNumberBuffer);
+ va_end(ap);
return -1;
}
ASSERT("MultiByteToWideChar failed. Error is %d\n",
GetLastError());
InternalFree(pthrCurrent, TempNumberBuffer);
+ va_end(ap);
return -1;
}
BufferPtr += TempCount;
{
ERROR("InternalMalloc failed\n");
pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ va_end(ap);
return -1;
}
{
ASSERT("strncpy_s failed!\n");
InternalFree(pthrCurrent, TempNumberBuffer);
+ va_end(ap);
return -1;
}
ASSERT("MultiByteToWideChar failed. Error is %d\n",
GetLastError());
InternalFree(pthrCurrent, TempNumberBuffer);
+ va_end(ap);
return -1;
}
BufferPtr += TempInt;
{
*BufferPtr = 0; /* end the string */
}
+
+ va_end(ap);
if (BufferRanOut)
{
}
}
-int CoreVfprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const char *format, va_list ap)
+int CoreVfprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const char *format, va_list aparg)
{
CHAR TempBuff[1024]; /* used to hold a single %<foo> format string */
LPCSTR Fmt = format;
int wctombResult;
int written = 0;
int paddingReturnValue;
+ va_list ap;
PERF_ENTRY(vfprintf);
+
+ va_copy(ap, aparg);
while (*Fmt)
{
ASSERT("WideCharToMultiByte failed. Error is %d\n",
GetLastError());
PERF_EXIT(vfprintf);
+ va_end(ap);
return -1;
}
TempStr = (LPSTR) InternalMalloc(pthrCurrent, Length);
ERROR("InternalMalloc failed\n");
pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY);
PERF_EXIT(vfprintf);
+ va_end(ap);
return -1;
}
if (PRECISION_DOT == Precision)
GetLastError());
InternalFree(pthrCurrent, TempStr);
PERF_EXIT(vfprintf);
+ va_end(ap);
return -1;
}
TempStr[Length] = 0;
GetLastError());
InternalFree(pthrCurrent, TempStr);
PERF_EXIT(vfprintf);
+ va_end(ap);
return -1;
}
--Length; /* exclude null char */
ERROR("Internal_AddPaddingVfprintf failed\n");
InternalFree(pthrCurrent, TempStr);
PERF_EXIT(vfprintf);
+ va_end(ap);
return -1;
}
written += paddingReturnValue;
ASSERT("WideCharToMultiByte failed. Error is %d\n",
GetLastError());
PERF_EXIT(vfprintf);
+ va_end(ap);
return -1;
}
TempBuffer[Length] = 0;
{
ERROR("Internal_AddPaddingVfprintf failed\n");
PERF_EXIT(vfprintf);
+ va_end(ap);
return -1;
}
written += paddingReturnValue;
{
ERROR("Internal_AddPaddingVfprintf failed\n");
PERF_EXIT(vfprintf);
+ va_end(ap);
return -1;
}
written += paddingReturnValue;
{
ERROR("Internal_AddPaddingVfprintf failed\n");
PERF_EXIT(vfprintf);
+ va_end(ap);
return -1;
}
written += paddingReturnValue;
}
else
{
- TempInt = NativeVfprintf(pthrCurrent, stream->bsdFilePtr, TempBuff, ap);
+ va_list apcopy;
+ va_copy(apcopy, ap);
+ TempInt = NativeVfprintf(pthrCurrent, stream->bsdFilePtr, TempBuff, apcopy);
+ va_end(apcopy);
+ PAL_printf_arg_remover(&ap, Precision, Type, Prefix);
}
if (-1 == TempInt)
{
ERROR("fwrite() failed with errno == %d\n", errno);
PERF_EXIT(vfprintf);
+ va_end(ap);
return -1;
}
++written;
}
}
+ va_end(ap);
+
PERF_EXIT(vfprintf);
return written;
}
PAL_vsnprintf (silent version)
for more details, see PAL_vsnprintf in printf.c
*******************************************************************************/
-INT Silent_PAL_vsnprintf(LPSTR Buffer, INT Count, LPCSTR Format, va_list ap)
+INT Silent_PAL_vsnprintf(LPSTR Buffer, INT Count, LPCSTR Format, va_list aparg)
{
BOOL BufferRanOut = FALSE;
CHAR TempBuff[1024]; /* used to hold a single %<foo> format string */
INT Length;
INT TempInt;
int wctombResult;
+ va_list ap;
+
+ va_copy(ap, aparg);
while (*Fmt)
{
Length = Silent_WideCharToMultiByte(TempWStr, -1, 0, 0);
if (!Length)
{
+ va_end(ap);
return -1;
}
TempStr, Length);
if (!Length)
{
+ va_end(ap);
return -1;
}
TempStr[Length] = 0;
if (!wctombResult)
{
PAL_free(TempStr);
+ va_end(ap);
return -1;
}
--Length; /* exclude null char */
Length = Silent_WideCharToMultiByte(&TempWChar, 1, TempBuffer, 4);
if (!Length)
{
+ va_end(ap);
return -1;
}
TempBuffer[Length] = 0;
{
if (strcpy_s(TempBuff, sizeof(TempBuff), "%.300s") != SAFECRT_SUCCESS)
{
+ va_end(ap);
return -1;
}
}
-
- TempInt = PAL__vsnprintf(BufferPtr, TempCount, TempBuff, ap);
+ va_list apcopy;
+ va_copy(apcopy, ap);
+ TempInt = PAL__vsnprintf(BufferPtr, TempCount, TempBuff, apcopy);
+ va_end(apcopy);
+ PAL_printf_arg_remover(&ap, Precision, Type, Prefix);
}
if (TempInt < 0 || static_cast<size_t>(TempInt) >= TempCount) /* buffer not long enough */
*BufferPtr = 0; /* end the string */
}
+ va_end(ap);
+
if (BufferRanOut)
{
return -1;
for more details, see PAL_vfprintf in printf.c
--*/
-int Silent_PAL_vfprintf(PAL_FILE *stream, const char *format, va_list ap)
+int Silent_PAL_vfprintf(PAL_FILE *stream, const char *format, va_list aparg)
{
CHAR TempBuff[1024]; /* used to hold a single %<foo> format string */
LPCSTR Fmt = format;
int wctombResult;
int written = 0;
int paddingReturnValue;
+ va_list ap;
+
+ va_copy(ap, aparg);
while (*Fmt)
{
Length = Silent_WideCharToMultiByte(TempWStr, -1, 0, 0);
if (!Length)
{
+ va_end(ap);
return -1;
}
TempStr = (LPSTR) PAL_malloc(Length);
if (!TempStr)
{
+ va_end(ap);
return -1;
}
if (PRECISION_DOT == Precision)
if (!Length)
{
PAL_free(TempStr);
+ va_end(ap);
return -1;
}
TempStr[Length] = 0;
if (!wctombResult)
{
PAL_free(TempStr);
+ va_end(ap);
return -1;
}
--Length; /* exclude null char */
if (-1 == paddingReturnValue)
{
PAL_free(TempStr);
+ va_end(ap);
return -1;
}
written += paddingReturnValue;
Length = Silent_WideCharToMultiByte(&TempWChar, 1, TempBuffer, 4);
if (!Length)
{
+ va_end(ap);
return -1;
}
TempBuffer[Length] = 0;
Width - Length, Flags);
if (-1 == paddingReturnValue)
{
+ va_end(ap);
return -1;
}
written += paddingReturnValue;
}
else
{
- TempInt = PAL_vfprintf(stream, TempBuff, ap);
+ va_list apcopy;
+ va_copy(apcopy, ap);
+ TempInt = PAL_vfprintf(stream, TempBuff, apcopy);
+ va_end(apcopy);
+ PAL_printf_arg_remover(&ap, Precision, Type, Prefix);
}
if (-1 != TempInt)
PAL_fwrite(Fmt++, 1, 1, stream); /* copy regular chars into buffer */
if (stream->PALferrorCode == PAL_FILE_ERROR)
{
+ va_end(ap);
return -1;
}
++written;
}
}
+ va_end(ap);
return written;
}