From: Aaron Robinson Date: Sat, 28 Jan 2023 16:43:56 +0000 (-0800) Subject: Remove `printf` implementation (#81243) X-Git-Tag: accepted/tizen/unified/riscv/20231226.055536~4359 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cd3f357e5425e5305824045c0c7da2d9b292a32e;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Remove `printf` implementation (#81243) * Remove PAL_printf and PAL_vprintf Replace implementation of file related printfs using the platform implementation (PAL_fprintf and PAL_vfprintf). Remove tests for PAL_printf, PAL_vprintf, PAL_fprintf and PAL_vfprintf since they are all now supplied by the platform. * Remove underlying printf impl Left _vsnprintf_s tests to ensure the _TRUNCATE logic is validated. --- diff --git a/src/coreclr/dlls/mscordac/mscordac_unixexports.src b/src/coreclr/dlls/mscordac/mscordac_unixexports.src index 2168a5d..760228f 100644 --- a/src/coreclr/dlls/mscordac/mscordac_unixexports.src +++ b/src/coreclr/dlls/mscordac/mscordac_unixexports.src @@ -51,7 +51,6 @@ nativeStringResourceTable_mscorrc #PAL_Random #PAL_malloc #PAL_realloc -#PAL_printf #PAL_qsort #PAL_fprintf #PAL__wcstoui64 diff --git a/src/coreclr/inc/stresslog.h b/src/coreclr/inc/stresslog.h index a4e441c..e19fadc 100644 --- a/src/coreclr/inc/stresslog.h +++ b/src/coreclr/inc/stresslog.h @@ -379,8 +379,9 @@ public: Volatile logs; // the list of logs for every thread. uint64_t tickFrequency; // number of ticks per second uint64_t startTimeStamp; // start time from when tick counter started - uint64_t threadsWithNoLog; // threads that didn't get a log - uint64_t reserved[15]; // for future expansion + uint32_t threadsWithNoLog; // threads that didn't get a log + uint32_t reserved1; + uint64_t reserved2[15]; // for future expansion ModuleDesc modules[MAX_MODULES]; // descriptor of the modules images uint8_t moduleImage[64*1024*1024];// copy of the module images described by modules field }; diff --git a/src/coreclr/pal/inc/pal.h b/src/coreclr/pal/inc/pal.h index 9d1b166..88dcd4e 100644 --- a/src/coreclr/pal/inc/pal.h +++ b/src/coreclr/pal/inc/pal.h @@ -3921,8 +3921,6 @@ PAL_GetCurrentThreadAffinitySet(SIZE_T size, UINT_PTR* data); defines */ #ifndef PAL_STDCPP_COMPAT #define exit PAL_exit -#define printf PAL_printf -#define vprintf PAL_vprintf #define wcstod PAL_wcstod #define wcstoul PAL_wcstoul #define wcscat PAL_wcscat @@ -3993,6 +3991,10 @@ PAL_GetCurrentThreadAffinitySet(SIZE_T size, UINT_PTR* data); #define _mm_setcsr PAL__mm_setcsr #endif // HOST_AMD64 +// Forward declare functions that are in header files we can't include yet +int printf(const char *, ...); +int vprintf(const char *, va_list); + #endif // !PAL_STDCPP_COMPAT #ifndef _CONST_RETURN @@ -4069,14 +4071,13 @@ PALIMPORT int remove(const char*); PALIMPORT DLLEXPORT errno_t __cdecl memcpy_s(void *, size_t, const void *, size_t) THROW_DECL; PALIMPORT errno_t __cdecl memmove_s(void *, size_t, const void *, size_t); PALIMPORT DLLEXPORT int __cdecl _stricmp(const char *, const char *); -PALIMPORT DLLEXPORT int __cdecl vsprintf_s(char *, size_t, const char *, va_list); PALIMPORT char * __cdecl _gcvt_s(char *, int, double, int); PALIMPORT int __cdecl __iscsym(int); PALIMPORT DLLEXPORT 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 DLLEXPORT int __cdecl _vsnprintf_s(char *, size_t, size_t, const char *, va_list); PALIMPORT DLLEXPORT int __cdecl _snprintf_s(char *, size_t, size_t, const char *, ...); +PALIMPORT DLLEXPORT int __cdecl vsprintf_s(char *, size_t, const char *, va_list); PALIMPORT DLLEXPORT int __cdecl sprintf_s(char *, size_t, const char *, ... ); PALIMPORT DLLEXPORT int __cdecl sscanf_s(const char *, const char *, ...); PALIMPORT DLLEXPORT errno_t __cdecl _itow_s(int, WCHAR *, size_t, int); @@ -4342,9 +4343,6 @@ PALIMPORT PAL_FILE * __cdecl _wfopen(const WCHAR *, const WCHAR *); PALIMPORT int __cdecl rand(void); PALIMPORT void __cdecl srand(unsigned int); -PALIMPORT DLLEXPORT int __cdecl printf(const char *, ...); -PALIMPORT int __cdecl vprintf(const char *, va_list); - #ifdef _MSC_VER #define PAL_get_caller _MSC_VER #else diff --git a/src/coreclr/pal/src/CMakeLists.txt b/src/coreclr/pal/src/CMakeLists.txt index c28563f..74fc5d3 100644 --- a/src/coreclr/pal/src/CMakeLists.txt +++ b/src/coreclr/pal/src/CMakeLists.txt @@ -132,9 +132,7 @@ set(SOURCES cruntime/malloc.cpp cruntime/math.cpp cruntime/misc.cpp - cruntime/printf.cpp cruntime/printfcpp.cpp - cruntime/silent_printf.cpp cruntime/string.cpp cruntime/stringtls.cpp cruntime/thread.cpp @@ -179,10 +177,7 @@ set(SOURCES safecrt/memmove_s.cpp safecrt/mbusafecrt.cpp safecrt/safecrt_input_s.cpp - safecrt/safecrt_output_l.cpp - safecrt/safecrt_output_s.cpp safecrt/safecrt_winput_s.cpp - safecrt/safecrt_woutput_s.cpp safecrt/splitpath_s.cpp safecrt/sprintf_s.cpp safecrt/sscanf_s.cpp diff --git a/src/coreclr/pal/src/cruntime/printf.cpp b/src/coreclr/pal/src/cruntime/printf.cpp deleted file mode 100644 index 0ae63e5..0000000 --- a/src/coreclr/pal/src/cruntime/printf.cpp +++ /dev/null @@ -1,249 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*++ - - - -Module Name: - - printf.c - -Abstract: - - Implementation of the printf family functions. - -Revision History: - - - ---*/ - -#include "pal/palinternal.h" -#include "pal/dbgmsg.h" -#include "pal/cruntime.h" -#include "pal/thread.hpp" -#include "pal/threadsusp.hpp" -#include "pal/printfcpp.hpp" - -/* needs to be included after "palinternal.h" to avoid name - collision for va_start and va_end */ -#include -#include - -SET_DEFAULT_DEBUG_CHANNEL(CRT); - -#if SSCANF_SUPPORT_ll -const static char *scanf_longlongfmt = "ll"; -#else -const static char *scanf_longlongfmt = "q"; -#endif - -#if SSCANF_CANNOT_HANDLE_MISSING_EXPONENT -static int SscanfFloatCheckExponent(LPCSTR buff, LPCSTR floatFmt, - void * voidPtr, int * pn); -#endif // SSCANF_CANNOT_HANDLE_MISSING_EXPONENT - -/******************************************************************************* -Function: - PAL_printf_arg_remover - -Parameters: - ap - - pointer to the va_list from which to remove arguments - Width - - the width of the current format operation - Precision - - the precision of the current format option - Type - - the type of the argument for the current format option - Prefix - - the prefix for the current format option -*******************************************************************************/ -void PAL_printf_arg_remover(va_list *ap, INT Width, INT Precision, INT Type, INT Prefix) -{ - /* remove arg and precision if needed */ - if (PRECISION_STAR == Precision || - PRECISION_INVALID == Precision) - { - (void)va_arg(*ap, int); - } - if (WIDTH_STAR == Width || - WIDTH_INVALID == Width) - { - (void)va_arg(*ap, int); - } - if (Type == PFF_TYPE_FLOAT) - { - (void)va_arg(*ap, double); - } - else if (Type == PFF_TYPE_INT && Prefix == PFF_PREFIX_LONGLONG) - { - (void)va_arg(*ap, INT64); - } - else if (Type == PFF_TYPE_INT || Type == PFF_TYPE_CHAR) - { - (void)va_arg(*ap, int); - } - else - { - (void)va_arg(*ap, void *); - } -} - -/*++ -Function: - PAL_printf - -See MSDN doc. ---*/ -int -__cdecl -PAL_printf( - const char *format, - ...) -{ - LONG Length; - va_list ap; - - PERF_ENTRY(printf); - ENTRY("PAL_printf (format=%p (%s))\n", format, format); - - va_start(ap, format); - Length = PAL_vprintf(format, ap); - va_end(ap); - - LOGEXIT("PAL_printf returns int %d\n", Length); - PERF_EXIT(printf); - return Length; -} - -/*++ -Function: - PAL_fprintf - -See MSDN doc. ---*/ -int -__cdecl -PAL_fprintf(PAL_FILE *stream,const char *format,...) -{ - LONG Length = 0; - va_list ap; - - PERF_ENTRY(fprintf); - ENTRY("PAL_fprintf(stream=%p,format=%p (%s))\n",stream, format, format); - - va_start(ap, format); - Length = PAL_vfprintf( stream, format, ap); - va_end(ap); - - LOGEXIT("PAL_fprintf returns int %d\n", Length); - PERF_EXIT(fprintf); - return Length; -} - -/*++ -Function: - PAL_vprintf - -See MSDN doc. ---*/ -int -__cdecl -PAL_vprintf( - const char *format, - va_list ap) -{ - LONG Length; - - PERF_ENTRY(vprintf); - ENTRY("PAL_vprintf (format=%p (%s))\n", format, format); - - Length = PAL_vfprintf( PAL_get_stdout(PAL_get_caller), format, ap); - - LOGEXIT("PAL_vprintf returns int %d\n", Length); - PERF_EXIT(vprintf); - return Length; -} - -#if SSCANF_CANNOT_HANDLE_MISSING_EXPONENT -/*++ -Function: - SscanfFloatCheckExponent - - Parameters: - buff: pointer to the buffer to be parsed; the target float must be at - the beginning of the buffer, except for any number of leading - spaces - floatFmt: must be "%e%n" (or "%f%n" or "%g%n") - voidptr: optional pointer to output variable (which should be a float) - pn: pointer to an int to receive the number of bytes parsed. - - Notes: - On some platforms (specifically AIX) sscanf fails to parse a float from - a string such as 12.34e (while it succeeds for e.g. 12.34a). Sscanf - initially interprets the 'e' as the keyword for the beginning of a - 10-exponent of a floating point in scientific notation (as in 12.34e5), - but then it fails to parse the actual exponent. At this point sscanf should - be able to fall back on the narrower pattern, and parse the floating point - in common decimal notation (i.e. 12.34). However AIX's sscanf fails to do - so and it does not parse any number. - This function checks the given string for a such case and removes - the 'e' before parsing the float. - ---*/ - -static int SscanfFloatCheckExponent(LPCSTR buff, LPCSTR floatFmt, - void * voidPtr, int * pn) -{ - int ret = 0; - int digits = 0; - int points = 0; - LPCSTR pos = buff; - - /* skip initial spaces */ - while (*pos && isspace(*pos)) - pos++; - - /* go to the end of a float, if there is one */ - while (*pos) - { - if (isdigit(*pos)) - digits++; - else if (*pos == '.') - { - if (++points > 1) - break; - } - else - break; - - pos++; - } - - /* check if it is something like 12.34e and the trailing 'e' is not - the suffix of a valid exponent of 10, such as 12.34e+5 */ - if ( digits > 0 && *pos && tolower(*pos) == 'e' && - !( *(pos+1) && - ( isdigit(*(pos+1)) || - ( (*(pos+1) == '+' || *(pos+1) == '-') && isdigit(*(pos+2)) ) - ) - ) - ) - { - CHAR * pLocBuf = (CHAR *)PAL_malloc((pos-buff+1)*sizeof(CHAR)); - if (pLocBuf) - { - memcpy(pLocBuf, buff, (pos-buff)*sizeof(CHAR)); - pLocBuf[pos-buff] = 0; - if (voidPtr) - ret = sscanf_s(pLocBuf, floatFmt, voidPtr, pn); - else - ret = sscanf_s(pLocBuf, floatFmt, pn); - PAL_free (pLocBuf); - } - } - return ret; -} -#endif // SSCANF_CANNOT_HANDLE_MISSING_EXPONENT diff --git a/src/coreclr/pal/src/cruntime/printfcpp.cpp b/src/coreclr/pal/src/cruntime/printfcpp.cpp index 002441a..b9c1c92 100644 --- a/src/coreclr/pal/src/cruntime/printfcpp.cpp +++ b/src/coreclr/pal/src/cruntime/printfcpp.cpp @@ -32,456 +32,35 @@ Revision History: SET_DEFAULT_DEBUG_CHANNEL(CRT); -using namespace CorUnix; - -static const char __nullstring[] = "(null)"; /* string to print on null ptr */ -static const WCHAR __wnullstring[] = W("(null)"); /* string to print on null ptr */ - -int CoreVfprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const char *format, va_list ap); - extern "C" { -/******************************************************************************* -Function: - Internal_ExtractFormatA - -Parameters: - Fmt - - format string to parse - - first character must be a '%' - - parameter gets updated to point to the character after - the % format string - Out - - buffer will contain the % format string - Flags - - parameter will be set with the PRINTF_FORMAT_FLAGS defined above - Width - - will contain the width specified by the format string - - -1 if none given - Precision - - will contain the precision specified in the format string - - -1 if none given - Prefix - - an enumeration of the type prefix - Type - - an enumeration of the type value - -Notes: - - I'm also handling the undocumented %ws, %wc, %w... - - %#10x, when we have a width greater than the length (i.e padding) the - length of the padding is not consistent with MS's wsprintf - (MS adds an extra 2 padding chars, length of "0x") - - MS's wsprintf seems to ignore a 'h' prefix for number types - - MS's "%p" is different than gcc's - e.g. printf("%p", NULL); - MS --> 00000000 - gcc --> 0x0 - - the length of the exponent (precision) for floating types is different - between MS and gcc - e.g. printf("%E", 256.0); - MS --> 2.560000E+002 - gcc --> 2.560000E+02 -*******************************************************************************/ -BOOL Internal_ExtractFormatA(CPalThread *pthrCurrent, LPCSTR *Fmt, LPSTR Out, LPINT Flags, - LPINT Width, LPINT Precision, LPINT Prefix, LPINT Type) -{ - BOOL Result = FALSE; - LPSTR TempStr; - LPSTR TempStrPtr; - - *Width = WIDTH_DEFAULT; - *Precision = PRECISION_DEFAULT; - *Flags = PFF_NONE; - *Prefix = PFF_PREFIX_DEFAULT; - *Type = PFF_TYPE_DEFAULT; - - if (*Fmt && **Fmt == '%') - { - *Out++ = *(*Fmt)++; - } - else - { - return Result; - } - - /* we'll never need a temp string longer than the original */ - TempStrPtr = TempStr = (LPSTR) InternalMalloc(strlen(*Fmt)+1); - if (!TempStr) - { - ERROR("InternalMalloc failed\n"); - pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return Result; - } - - /* parse flags */ - while (**Fmt && (**Fmt == '-' || **Fmt == '+' || - **Fmt == '0' || **Fmt == ' ' || **Fmt == '#')) - { - switch (**Fmt) - { - case '-': - *Flags |= PFF_MINUS; break; - case '+': - *Flags |= PFF_PLUS; break; - case '0': - *Flags |= PFF_ZERO; break; - case ' ': - *Flags |= PFF_SPACE; break; - case '#': - *Flags |= PFF_POUND; break; - } - *Out++ = *(*Fmt)++; - } - /* '-' flag negates '0' flag */ - if ((*Flags & PFF_MINUS) && (*Flags & PFF_ZERO)) - { - *Flags -= PFF_ZERO; - } - - /* grab width specifier */ - if (isdigit((unsigned char) **Fmt)) - { - TempStrPtr = TempStr; - while (isdigit((unsigned char) **Fmt)) - { - *TempStrPtr++ = **Fmt; - *Out++ = *(*Fmt)++; - } - *TempStrPtr = 0; /* end string */ - *Width = atoi(TempStr); - if (*Width < 0) - { - ERROR("atoi returned a negative value indicative of an overflow.\n"); - pthrCurrent->SetLastError(ERROR_INTERNAL_ERROR); - goto EXIT; - } - } - else if (**Fmt == '*') - { - *Width = WIDTH_STAR; - *Out++ = *(*Fmt)++; - if (isdigit((unsigned char) **Fmt)) - { - /* this is an invalid width because we have a * then a number */ - /* printf handles this by just printing the whole string */ - *Width = WIDTH_INVALID; - while (isdigit((unsigned char) **Fmt)) - { - *Out++ = *(*Fmt)++; - } - } - } - - - /* grab precision specifier */ - if (**Fmt == '.') - { - *Out++ = *(*Fmt)++; - if (isdigit((unsigned char) **Fmt)) - { - TempStrPtr = TempStr; - while (isdigit((unsigned char) **Fmt)) - { - *TempStrPtr++ = **Fmt; - *Out++ = *(*Fmt)++; - } - *TempStrPtr = 0; /* end string */ - *Precision = atoi(TempStr); - if (*Precision < 0) - { - ERROR("atoi returned a negative value indicative of an overflow.\n"); - pthrCurrent->SetLastError(ERROR_INTERNAL_ERROR); - goto EXIT; - } - } - else if (**Fmt == '*') - { - *Precision = PRECISION_STAR; - *Out++ = *(*Fmt)++; - if (isdigit((unsigned char) **Fmt)) - { - /* this is an invalid precision because we have a .* then a number */ - /* printf handles this by just printing the whole string */ - *Precision = PRECISION_INVALID; - while (isdigit((unsigned char) **Fmt)) - { - *Out++ = *(*Fmt)++; - } - } - } - else - { - *Precision = PRECISION_DOT; - } - } +// Forward declare functions that are in header files we can't include yet +int vfprintf(FILE* stream, const char* format, va_list ap); -#ifdef HOST_64BIT - if (**Fmt == 'p') - { - *Prefix = PFF_PREFIX_LONGLONG; - } -#endif - if ((*Fmt)[0] == 'I' || (*Fmt)[0] == 'z') - { - /* grab prefix of 'I64' for __int64 */ - if ((*Fmt)[1] == '6' && (*Fmt)[2] == '4') - { - /* convert to 'll' so that Unix snprintf can handle it */ - *Fmt += 3; - *Prefix = PFF_PREFIX_LONGLONG; - } - /* grab prefix of 'I32' for __int32 */ - else if ((*Fmt)[1] == '3' && (*Fmt)[2] == '2') - { - *Fmt += 3; - } - else - { - ++(*Fmt); - #ifdef HOST_64BIT - /* convert to 'll' so that Unix snprintf can handle it */ - *Prefix = PFF_PREFIX_LONGLONG; - #endif - } - } - /* grab a prefix of 'h' */ - else if (**Fmt == 'h') - { - *Prefix = PFF_PREFIX_SHORT; - ++(*Fmt); - } - /* grab prefix of 'l' or the undocumented 'w' (at least in MSDN) */ - else if (**Fmt == 'l' || **Fmt == 'w') - { - ++(*Fmt); -#ifdef HOST_64BIT - // Only want to change the prefix on 64 bit when printing characters. - if (**Fmt == 'c' || **Fmt == 's') -#endif - { - *Prefix = PFF_PREFIX_LONG; - } - if (**Fmt == 'l') - { - *Prefix = PFF_PREFIX_LONGLONG; - ++(*Fmt); - } - } - else if (**Fmt == 'L') - { - /* a prefix of 'L' seems to be ignored */ - ++(*Fmt); - } - - /* grab type 'c' */ - if (**Fmt == 'c' || **Fmt == 'C') - { - *Type = PFF_TYPE_CHAR; - if (*Prefix != PFF_PREFIX_SHORT && **Fmt == 'C') - { - *Prefix = PFF_PREFIX_LONG; /* give it a wide prefix */ - } - if (*Prefix == PFF_PREFIX_LONG) - { - *Out++ = 'l'; - } - *Out++ = 'c'; - ++(*Fmt); - Result = TRUE; - } - /* grab type 's' */ - else if (**Fmt == 's' || **Fmt == 'S') - { - *Type = PFF_TYPE_STRING; - if (*Prefix != PFF_PREFIX_SHORT && **Fmt == 'S') - { - *Prefix = PFF_PREFIX_LONG; /* give it a wide prefix */ - } - if (*Prefix == PFF_PREFIX_LONG) - { - *Out++ = 'l'; - } - *Out++ = 's'; - ++(*Fmt); - Result = TRUE; - } - /* grab int types */ - else if (**Fmt == 'd' || **Fmt == 'i' || **Fmt == 'o' || - **Fmt == 'u' || **Fmt == 'x' || **Fmt == 'X') - { - *Type = PFF_TYPE_INT; - if (*Prefix == PFF_PREFIX_SHORT) - { - *Out++ = 'h'; - } - else if (*Prefix == PFF_PREFIX_LONG) - { - *Out++ = 'l'; - } - else if (*Prefix == PFF_PREFIX_LONGLONG) - { - *Out++ = 'l'; - *Out++ = 'l'; - } - *Out++ = *(*Fmt)++; - Result = TRUE; - } - else if (**Fmt == 'e' || **Fmt == 'E' || **Fmt == 'f' || - **Fmt == 'g' || **Fmt == 'G') - { - /* we can safely ignore the prefixes and only add the type*/ - *Type = PFF_TYPE_FLOAT; - *Out++ = *(*Fmt)++; - Result = TRUE; - } - else if (**Fmt == 'n') - { - if (*Prefix == PFF_PREFIX_SHORT) - { - *Out++ = 'h'; - } - *Out++ = *(*Fmt)++; - *Type = PFF_TYPE_N; - Result = TRUE; - } - else if (**Fmt == 'p') - { - *Type = PFF_TYPE_P; - (*Fmt)++; - - if (*Prefix == PFF_PREFIX_LONGLONG) - { - if (*Precision == PRECISION_DEFAULT) - { - *Precision = 16; - *Out++ = '.'; - *Out++ = '1'; - *Out++ = '6'; - } - *Out++ = 'l'; - *Out++ = 'l'; - } - else - { - if (*Precision == PRECISION_DEFAULT) - { - *Precision = 8; - *Out++ = '.'; - *Out++ = '8'; - } - } - *Out++ = 'X'; - Result = TRUE; - } - - *Out = 0; /* end the string */ - -EXIT: - free(TempStr); - return Result; -} - -/******************************************************************************* +/*++ Function: - Internal_AddPaddingVfprintf + PAL_fprintf -Parameters: - stream - - file stream to place padding and given string (In) - In - - string to place into (Out) accompanied with padding - Padding - - number of padding chars to add - Flags - - padding style flags (PRINTF_FORMAT_FLAGS) -*******************************************************************************/ - -INT Internal_AddPaddingVfprintf(CPalThread *pthrCurrent, PAL_FILE *stream, LPCSTR In, - INT Padding, INT Flags) +See MSDN doc. +--*/ +int +__cdecl +PAL_fprintf(PAL_FILE *stream,const char *format,...) { - LPSTR Out; - INT LengthInStr; - INT Length; - LPSTR OutOriginal; - INT Written; - - LengthInStr = strlen(In); - Length = LengthInStr; - - if (Padding > 0) - { - Length += Padding; - } - Out = (LPSTR) InternalMalloc(Length+1); - int iLength = Length+1; - if (!Out) - { - ERROR("InternalMalloc failed\n"); - pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return -1; - } - OutOriginal = Out; - - if (Flags & PFF_MINUS) /* pad on right */ - { - if (strcpy_s(Out, iLength, In) != SAFECRT_SUCCESS) - { - ERROR("strcpy_s failed\n"); - pthrCurrent->SetLastError(ERROR_INSUFFICIENT_BUFFER); - Written = -1; - goto Done; - } - - Out += LengthInStr; - iLength -= LengthInStr; - } - if (Padding > 0) - { - iLength -= Padding; - if (Flags & PFF_ZERO) /* '0', pad with zeros */ - { - while (Padding--) - { - *Out++ = '0'; - } - } - else /* pad with spaces */ - { - while (Padding--) - { - *Out++ = ' '; - } - } - } - if (!(Flags & PFF_MINUS)) /* put 'In' after padding */ - { - if (strcpy_s(Out, iLength, In) != SAFECRT_SUCCESS) - { - ERROR("strcpy_s failed\n"); - pthrCurrent->SetLastError(ERROR_INSUFFICIENT_BUFFER); - Written = -1; - goto Done; - } - - Out += LengthInStr; - iLength -= LengthInStr; - } - -#if FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL - clearerr (stream->bsdFilePtr); -#endif + LONG Length = 0; + va_list ap; - Written = InternalFwrite(OutOriginal, 1, Length, stream->bsdFilePtr, &stream->PALferrorCode); - if (stream->PALferrorCode == PAL_FILE_ERROR) - { - ERROR("fwrite() failed with errno == %d\n", errno); - } + PERF_ENTRY(fprintf); + ENTRY("PAL_fprintf(stream=%p,format=%p (%s))\n",stream, format, format); -Done: - free(OutOriginal); + va_start(ap, format); + Length = vfprintf(stream->bsdFilePtr, format, ap); + va_end(ap); - return Written; + LOGEXIT("PAL_fprintf returns int %d\n", Length); + PERF_EXIT(fprintf); + return Length; } /******************************************************************************* @@ -499,331 +78,7 @@ Parameters: int __cdecl PAL_vfprintf(PAL_FILE *stream, const char *format, va_list ap) { - return CoreVfprintf(InternalGetCurrentThread(), stream, format, ap); + return vfprintf(stream->bsdFilePtr, format, ap); } } // end extern "C" - -int CoreVfprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const char *format, va_list aparg) -{ - CHAR TempBuff[1024]; /* used to hold a single % format string */ - LPCSTR Fmt = format; - LPCWSTR TempWStr; - LPSTR TempStr; - WCHAR TempWChar; - INT Flags; - INT Width; - INT Precision; - INT Prefix; - INT Type; - INT Length; - INT TempInt; - int wctombResult; - int written = 0; - int paddingReturnValue; - va_list ap; - - PERF_ENTRY(vfprintf); - - va_copy(ap, aparg); - - while (*Fmt) - { - if (*Fmt == '%' && - TRUE == Internal_ExtractFormatA(pthrCurrent, &Fmt, TempBuff, &Flags, - &Width, &Precision, - &Prefix, &Type)) - { - if (Prefix == PFF_PREFIX_LONG && Type == PFF_TYPE_STRING) - { - if (WIDTH_STAR == Width) - { - Width = va_arg(ap, INT); - } - else if (WIDTH_INVALID == Width) - { - /* both a '*' and a number, ignore, but remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - - if (PRECISION_STAR == Precision) - { - Precision = va_arg(ap, INT); - } - else if (PRECISION_INVALID == Precision) - { - /* both a '*' and a number, ignore, but remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - - TempWStr = va_arg(ap, LPWSTR); - if (TempWStr == NULL)\ - { - TempWStr = __wnullstring; - } - Length = WideCharToMultiByte(CP_ACP, 0, TempWStr, -1, 0, - 0, 0, 0); - if (!Length) - { - ASSERT("WideCharToMultiByte failed. Error is %d\n", - GetLastError()); - PERF_EXIT(vfprintf); - va_end(ap); - return -1; - } - TempStr = (LPSTR) InternalMalloc(Length); - if (!TempStr) - { - ERROR("InternalMalloc failed\n"); - pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY); - PERF_EXIT(vfprintf); - va_end(ap); - return -1; - } - if (PRECISION_DOT == Precision) - { - /* copy nothing */ - *TempStr = 0; - Length = 0; - } - else if (Precision > 0 && Precision < Length - 1) - { - Length = WideCharToMultiByte(CP_ACP, 0, TempWStr, - Precision, TempStr, Length, - 0, 0); - if (!Length) - { - ASSERT("WideCharToMultiByte failed. Error is %d\n", - GetLastError()); - free(TempStr); - PERF_EXIT(vfprintf); - va_end(ap); - return -1; - } - TempStr[Length] = 0; - Length = Precision; - } - /* copy everything */ - else - { - wctombResult = WideCharToMultiByte(CP_ACP, 0, TempWStr, -1, - TempStr, Length, 0, 0); - if (!wctombResult) - { - ASSERT("WideCharToMultiByte failed. Error is %d\n", - GetLastError()); - free(TempStr); - PERF_EXIT(vfprintf); - va_end(ap); - return -1; - } - --Length; /* exclude null char */ - } - - /* do the padding (if needed)*/ - paddingReturnValue = - Internal_AddPaddingVfprintf(pthrCurrent, stream, TempStr, - Width - Length, Flags); - if (-1 == paddingReturnValue) - { - ERROR("Internal_AddPaddingVfprintf failed\n"); - free(TempStr); - PERF_EXIT(vfprintf); - va_end(ap); - return -1; - } - written += paddingReturnValue; - - free(TempStr); - } - else if (Prefix == PFF_PREFIX_LONG && Type == PFF_TYPE_CHAR) - { - CHAR TempBuffer[5]; - if (WIDTH_STAR == Width || - WIDTH_INVALID == Width) - { - /* ignore (because it's a char), and remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - if (PRECISION_STAR == Precision || - PRECISION_INVALID == Precision) - { - /* ignore (because it's a char), and remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - - TempWChar = (WCHAR)va_arg(ap, int); - Length = WideCharToMultiByte(CP_ACP, 0, &TempWChar, 1, - TempBuffer, sizeof(TempBuffer), - 0, 0); - if (!Length) - { - ASSERT("WideCharToMultiByte failed. Error is %d\n", - GetLastError()); - PERF_EXIT(vfprintf); - va_end(ap); - return -1; - } - TempBuffer[Length] = W('\0'); - - /* do the padding (if needed)*/ - paddingReturnValue = - Internal_AddPaddingVfprintf(pthrCurrent, stream, TempBuffer, - Width - Length, Flags); - if (-1 == paddingReturnValue) - { - ERROR("Internal_AddPaddingVfprintf failed\n"); - PERF_EXIT(vfprintf); - va_end(ap); - return -1; - } - written += paddingReturnValue; - - } - /* this places the number of bytes written to the buffer in the - next arg */ - else if (Type == PFF_TYPE_N) - { - if (WIDTH_STAR == Width) - { - Width = va_arg(ap, INT); - } - if (PRECISION_STAR == Precision) - { - Precision = va_arg(ap, INT); - } - - if (Prefix == PFF_PREFIX_SHORT) - { - *(va_arg(ap, short *)) = (short)written; - } - else - { - *(va_arg(ap, LPLONG)) = written; - } - } - else if (Type == PFF_TYPE_CHAR && (Flags & PFF_ZERO) != 0) - { - // Some versions of fprintf don't support 0-padded chars, - // so we handle them here. - char ch[2]; - - ch[0] = (char) va_arg(ap, int); - ch[1] = '\0'; - Length = 1; - paddingReturnValue = Internal_AddPaddingVfprintf( - pthrCurrent, - stream, - ch, - Width - Length, - Flags); - if (-1 == paddingReturnValue) - { - ERROR("Internal_AddPaddingVfprintf failed\n"); - PERF_EXIT(vfprintf); - va_end(ap); - return -1; - } - written += paddingReturnValue; - } - else if (Type == PFF_TYPE_STRING && (Flags & PFF_ZERO) != 0) - { - // Some versions of fprintf don't support 0-padded strings, - // so we handle them here. - const char *tempStr; - - tempStr = va_arg(ap, char *); - if (tempStr == NULL) - { - tempStr = __nullstring; - } - Length = strlen(tempStr); - paddingReturnValue = Internal_AddPaddingVfprintf( - pthrCurrent, - stream, - tempStr, - Width - Length, - Flags); - if (-1 == paddingReturnValue) - { - ERROR("Internal_AddPaddingVfprintf failed\n"); - PERF_EXIT(vfprintf); - va_end(ap); - return -1; - } - written += paddingReturnValue; - } - else - { - // Types that fprintf can handle. - TempInt = 0; - - // %h (short) doesn't seem to be handled properly by local sprintf, - // so we do the truncation ourselves for some cases. - if (Type == PFF_TYPE_P && Prefix == PFF_PREFIX_SHORT) - { - // Convert from pointer -> int -> short to avoid warnings. - long trunc1; - short trunc2; - - trunc1 = va_arg(ap, LONG); - trunc2 = (short)trunc1; - trunc1 = trunc2; - - TempInt = fprintf(stream->bsdFilePtr, TempBuff, trunc1); - } - else if (Type == PFF_TYPE_INT && Prefix == PFF_PREFIX_SHORT) - { - // Convert explicitly from int to short to get - // correct sign extension for shorts on all systems. - int n; - short s; - - n = va_arg(ap, int); - s = (short) n; - - TempInt = fprintf( stream->bsdFilePtr, TempBuff, s); - } - else - { - va_list apcopy; - va_copy(apcopy, ap); - TempInt = vfprintf(stream->bsdFilePtr, TempBuff, apcopy); - va_end(apcopy); - PAL_printf_arg_remover(&ap, Width, Precision, Type, Prefix); - } - - if (-1 == TempInt) - { - ERROR("vfprintf returned an error\n"); - } - else - { - written += TempInt; - } - } - } - else - { - -#if FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL - clearerr (stream->bsdFilePtr); -#endif - - InternalFwrite(Fmt++, 1, 1, stream->bsdFilePtr, &stream->PALferrorCode); /* copy regular chars into buffer */ - if (stream->PALferrorCode == PAL_FILE_ERROR) - { - 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; -} diff --git a/src/coreclr/pal/src/cruntime/silent_printf.cpp b/src/coreclr/pal/src/cruntime/silent_printf.cpp deleted file mode 100644 index 04f74f1..0000000 --- a/src/coreclr/pal/src/cruntime/silent_printf.cpp +++ /dev/null @@ -1,718 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*++ - - - -Module Name: - - silent_printf.c - -Abstract: - - Implementation of a silent version of PAL_vsprintf and PAL_vfprintf function. - (without any reference to TRACE/ERROR/... macros, needed by the tracing macros) - -Revision History: - - - ---*/ - - -#include "pal/palinternal.h" -#include "pal/cruntime.h" -#include "pal/printfcpp.hpp" -#include "pal/thread.hpp" - -/* clip strings (%s, %S) at this number of characters */ -#define MAX_STR_LEN 300 - -static int Silent_WideCharToMultiByte(LPCWSTR lpWideCharStr, int cchWideChar, - LPSTR lpMultiByteStr, int cbMultiByte); -static BOOL Silent_ExtractFormatA(LPCSTR *Fmt, LPSTR Out, LPINT Flags, LPINT Width, - LPINT Precision, LPINT Prefix, LPINT Type); -static INT Silent_AddPaddingVfprintf(PAL_FILE *stream, LPSTR In, INT Padding, - INT Flags); - -static size_t Silent_PAL_wcslen(const wchar_16 *string); - -/*++ -Function: - PAL_vfprintf (silent version) - - for more details, see PAL_vfprintf in printf.c ---*/ -int Silent_PAL_vfprintf(PAL_FILE *stream, const char *format, va_list aparg) -{ - CHAR TempBuff[1024]; /* used to hold a single % format string */ - LPCSTR Fmt = format; - LPWSTR TempWStr; - LPSTR TempStr; - WCHAR TempWChar; - INT Flags; - INT Width; - INT Precision; - INT Prefix; - INT Type; - INT Length; - INT TempInt; - int wctombResult; - int written = 0; - int paddingReturnValue; - va_list ap; - - va_copy(ap, aparg); - - while (*Fmt) - { - if (*Fmt == '%' && - TRUE == Silent_ExtractFormatA(&Fmt, TempBuff, &Flags, &Width, - &Precision, &Prefix, &Type)) - { - if (Prefix == PFF_PREFIX_LONG && Type == PFF_TYPE_STRING) - { - if (WIDTH_STAR == Width) - { - Width = va_arg(ap, INT); - } - else if (WIDTH_INVALID == Width) - { - /* both a '*' and a number, ignore, but remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - - if (PRECISION_STAR == Precision) - { - Precision = va_arg(ap, INT); - } - else if (PRECISION_INVALID == Precision) - { - /* both a '*' and a number, ignore, but remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - - TempWStr = va_arg(ap, LPWSTR); - 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) - { - /* copy nothing */ - *TempStr = 0; - Length = 0; - } - else if (Precision > 0 && Precision < Length - 1) - { - Length = Silent_WideCharToMultiByte(TempWStr, Precision, - TempStr, Length); - if (!Length) - { - PAL_free(TempStr); - va_end(ap); - return -1; - } - TempStr[Length] = 0; - Length = Precision; - } - /* copy everything */ - else - { - wctombResult = Silent_WideCharToMultiByte(TempWStr, -1, - TempStr, Length); - if (!wctombResult) - { - PAL_free(TempStr); - va_end(ap); - return -1; - } - --Length; /* exclude null char */ - } - - /* do the padding (if needed)*/ - paddingReturnValue = - Silent_AddPaddingVfprintf(stream, TempStr, Width - Length, Flags); - if (-1 == paddingReturnValue) - { - PAL_free(TempStr); - va_end(ap); - return -1; - } - written += paddingReturnValue; - - PAL_free(TempStr); - } - else if (Prefix == PFF_PREFIX_LONG && Type == PFF_TYPE_CHAR) - { - CHAR TempBuffer[4]; - if (WIDTH_STAR == Width || - WIDTH_INVALID == Width) - { - /* ignore (because it's a char), and remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - if (PRECISION_STAR == Precision || - PRECISION_INVALID == Precision) - { - /* ignore (because it's a char), and remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - - TempWChar = (WCHAR)va_arg(ap, int); - Length = Silent_WideCharToMultiByte(&TempWChar, 1, TempBuffer, 4); - if (!Length) - { - va_end(ap); - return -1; - } - TempBuffer[Length] = 0; - - /* do the padding (if needed)*/ - paddingReturnValue = - Silent_AddPaddingVfprintf(stream, TempBuffer, - Width - Length, Flags); - if (-1 == paddingReturnValue) - { - va_end(ap); - return -1; - } - written += paddingReturnValue; - - } - /* this places the number of bytes written to the buffer in the - next arg */ - else if (Type == PFF_TYPE_N) - { - if (WIDTH_STAR == Width) - { - Width = va_arg(ap, INT); - } - if (PRECISION_STAR == Precision) - { - Precision = va_arg(ap, INT); - } - - if (Prefix == PFF_PREFIX_SHORT) - { - *(va_arg(ap, short *)) = (short)written; - } - else - { - *(va_arg(ap, LPLONG)) = written; - } - } - /* types that sprintf can handle */ - else - { - TempInt = 0; - - /* %h (short) doesn't seem to be handled properly by local sprintf, - so lets do the truncation ourselves. (ptr -> int -> short to avoid - warnings */ - if (Type == PFF_TYPE_P && Prefix == PFF_PREFIX_SHORT) - { - long trunc1; - short trunc2; - - trunc1 = va_arg(ap, LONG); - trunc2 = (short)trunc1; - - TempInt = fprintf((FILE*)stream, TempBuff, trunc2); - } - else if (Type == PFF_TYPE_INT && Prefix == PFF_PREFIX_SHORT) - { - // Convert explicitly from int to short to get - // correct sign extension for shorts on all systems. - int n; - short s; - - n = va_arg(ap, int); - s = (short)n; - - TempInt = fprintf((FILE*)stream, TempBuff, s); - } - else - { - va_list apcopy; - va_copy(apcopy, ap); - TempInt = PAL_vfprintf(stream, TempBuff, apcopy); - va_end(apcopy); - PAL_printf_arg_remover(&ap, Width, Precision, Type, Prefix); - } - - if (-1 != TempInt) - { - written += TempInt; - } - } - } - else - { -#if FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL - clearerr((FILE*)stream); -#endif - - 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; -} - -/*++ -Function: - WideCharToMultiByte (reduced and silent version) - -See MSDN doc. ---*/ -int Silent_WideCharToMultiByte(LPCWSTR lpWideCharStr, int cchWideChar, - LPSTR lpMultiByteStr, int cbMultiByte) -{ - INT retval =0; - - if ((lpWideCharStr == NULL)|| - (lpWideCharStr == (LPCWSTR) lpMultiByteStr)) - { - goto EXIT; - } - - if (cchWideChar == -1) - { - cchWideChar = Silent_PAL_wcslen(lpWideCharStr) + 1; - } - - if (cbMultiByte == 0) - { - retval = cchWideChar; - goto EXIT; - } - else if(cbMultiByte < cchWideChar) - { - retval = 0; - goto EXIT; - } - - retval = cchWideChar; - while(cchWideChar > 0) - { - if(*lpWideCharStr > 255) - { - *lpMultiByteStr = '?'; - } - else - { - *lpMultiByteStr = (unsigned char)*lpWideCharStr; - } - lpMultiByteStr++; - lpWideCharStr++; - cchWideChar--; - } - -EXIT: - return retval; -} - -/******************************************************************************* -Function: - Internal_ExtractFormatA (silent version) - - see Internal_ExtractFormatA function in printf.c -*******************************************************************************/ -BOOL Silent_ExtractFormatA(LPCSTR *Fmt, LPSTR Out, LPINT Flags, LPINT Width, LPINT Precision, LPINT Prefix, LPINT Type) -{ - BOOL Result = FALSE; - LPSTR TempStr; - LPSTR TempStrPtr; - - *Width = WIDTH_DEFAULT; - *Precision = PRECISION_DEFAULT; - *Flags = PFF_NONE; - *Prefix = PFF_PREFIX_DEFAULT; - *Type = PFF_TYPE_DEFAULT; - - if (*Fmt && **Fmt == '%') - { - *Out++ = *(*Fmt)++; - } - else - { - return Result; - } - - /* we'll never need a temp string longer than the original */ - TempStrPtr = TempStr = (LPSTR) PAL_malloc(strlen(*Fmt)+1); - if (!TempStr) - { - return Result; - } - - /* parse flags */ - while (**Fmt && (**Fmt == '-' || **Fmt == '+' || - **Fmt == '0' || **Fmt == ' ' || **Fmt == '#')) - { - switch (**Fmt) - { - case '-': - *Flags |= PFF_MINUS; break; - case '+': - *Flags |= PFF_PLUS; break; - case '0': - *Flags |= PFF_ZERO; break; - case ' ': - *Flags |= PFF_SPACE; break; - case '#': - *Flags |= PFF_POUND; break; - } - *Out++ = *(*Fmt)++; - } - /* '-' flag negates '0' flag */ - if ((*Flags & PFF_MINUS) && (*Flags & PFF_ZERO)) - { - *Flags -= PFF_ZERO; - } - - /* grab width specifier */ - if (isdigit((unsigned char) **Fmt)) - { - TempStrPtr = TempStr; - while (isdigit((unsigned char) **Fmt)) - { - *TempStrPtr++ = **Fmt; - *Out++ = *(*Fmt)++; - } - *TempStrPtr = 0; /* end string */ - *Width = atoi(TempStr); - if (*Width < 0) - { - SetLastError(ERROR_INTERNAL_ERROR); - goto EXIT; - } - } - else if (**Fmt == '*') - { - *Width = WIDTH_STAR; - *Out++ = *(*Fmt)++; - if (isdigit((unsigned char) **Fmt)) - { - /* this is an invalid width because we have a * then a number */ - /* printf handles this by just printing the whole string */ - *Width = WIDTH_INVALID; - while (isdigit((unsigned char) **Fmt)) - { - *Out++ = *(*Fmt)++; - } - } - } - - - /* grab precision specifier */ - if (**Fmt == '.') - { - *Out++ = *(*Fmt)++; - if (isdigit((unsigned char) **Fmt)) - { - TempStrPtr = TempStr; - while (isdigit((unsigned char) **Fmt)) - { - *TempStrPtr++ = **Fmt; - *Out++ = *(*Fmt)++; - } - *TempStrPtr = 0; /* end string */ - *Precision = atoi(TempStr); - if (*Precision < 0) - { - SetLastError(ERROR_INTERNAL_ERROR); - goto EXIT; - } - } - else if (**Fmt == '*') - { - *Precision = PRECISION_STAR; - *Out++ = *(*Fmt)++; - if (isdigit((unsigned char) **Fmt)) - { - /* this is an invalid precision because we have a .* then a - number */ - /* printf handles this by just printing the whole string */ - *Precision = PRECISION_INVALID; - while (isdigit((unsigned char) **Fmt)) - { - *Out++ = *(*Fmt)++; - } - } - } - else - { - *Precision = PRECISION_DOT; - } - } - -#ifdef HOST_64BIT - if (**Fmt == 'p') - { - *Prefix = PFF_PREFIX_LONGLONG; - } -#endif - /* grab prefix of 'I64' for __int64 */ - if ((*Fmt)[0] == 'I' && (*Fmt)[1] == '6' && (*Fmt)[2] == '4') - { - /* convert to 'll' so BSD's snprintf can handle it */ - *Fmt += 3; - *Prefix = PFF_PREFIX_LONGLONG; - } - /* grab a prefix of 'z' */ - else if (**Fmt == 'z') - { -#ifdef HOST_64BIT - *Prefix = PFF_PREFIX_LONGLONG; -#endif - ++(*Fmt); - } - /* grab a prefix of 'h' */ - else if (**Fmt == 'h') - { - *Prefix = PFF_PREFIX_SHORT; - ++(*Fmt); - } - /* grab prefix of 'l' or the undocumented 'w' (at least in MSDN) */ - else if (**Fmt == 'l' || **Fmt == 'w') - { - ++(*Fmt); -#ifdef HOST_64BIT - // Only want to change the prefix on 64 bit when printing characters. - if (**Fmt == 'c' || **Fmt == 's') -#endif - { - *Prefix = PFF_PREFIX_LONG; - } - } - else if (**Fmt == 'L') - { - /* a prefix of 'L' seems to be ignored */ - ++(*Fmt); - } - - /* grab type 'c' */ - if (**Fmt == 'c' || **Fmt == 'C') - { - *Type = PFF_TYPE_CHAR; - if (*Prefix != PFF_PREFIX_SHORT && **Fmt == 'C') - { - *Prefix = PFF_PREFIX_LONG; /* give it a wide prefix */ - } - if (*Prefix == PFF_PREFIX_LONG) - { - *Out++ = 'l'; - } - *Out++ = 'c'; - ++(*Fmt); - Result = TRUE; - } - /* grab type 's' */ - else if (**Fmt == 's' || **Fmt == 'S') - { - *Type = PFF_TYPE_STRING; - if (*Prefix != PFF_PREFIX_SHORT && **Fmt == 'S') - { - *Prefix = PFF_PREFIX_LONG; /* give it a wide prefix */ - } - if (*Prefix == PFF_PREFIX_LONG) - { - *Out++ = 'l'; - } - *Out++ = 's'; - ++(*Fmt); - Result = TRUE; - } - /* grab int types types */ - else if (**Fmt == 'd' || **Fmt == 'i' || **Fmt == 'o' || - **Fmt == 'u' || **Fmt == 'x' || **Fmt == 'X') - { - *Type = PFF_TYPE_INT; - if (*Prefix == PFF_PREFIX_SHORT) - { - *Out++ = 'h'; - } - else if (*Prefix == PFF_PREFIX_LONG) - { - *Out++ = 'l'; - } - else if (*Prefix == PFF_PREFIX_LONGLONG) - { - *Out++ = 'l'; - *Out++ = 'l'; - } - *Out++ = *(*Fmt)++; - Result = TRUE; - } - else if (**Fmt == 'e' || **Fmt == 'E' || **Fmt == 'f' || - **Fmt == 'g' || **Fmt == 'G') - { - /* we can safely ignore the prefixes and only add the type*/ - *Type = PFF_TYPE_FLOAT; - *Out++ = *(*Fmt)++; - Result = TRUE; - } - else if (**Fmt == 'n') - { - if (*Prefix == PFF_PREFIX_SHORT) - { - *Out++ = 'h'; - } - *Out++ = *(*Fmt)++; - *Type = PFF_TYPE_N; - Result = TRUE; - } - else if (**Fmt == 'p') - { - *Type = PFF_TYPE_P; - *Out++ = *(*Fmt)++; - - if (*Prefix == PFF_PREFIX_LONGLONG) - { - if (*Precision == PRECISION_DEFAULT) - { - *Precision = 16; - } - } - else - { - if (*Precision == PRECISION_DEFAULT) - { - *Precision = 8; - } - } - Result = TRUE; - } - - *Out = 0; /* end the string */ - -EXIT: - PAL_free(TempStr); - return Result; -} - -/******************************************************************************* -Function: - AddPaddingVfprintf (silent version) - see Internal_AddPaddingVfprintf in printf.c -*******************************************************************************/ -INT Silent_AddPaddingVfprintf(PAL_FILE *stream, LPSTR In, INT Padding, INT Flags) -{ - LPSTR Out; - INT LengthInStr; - INT Length; - LPSTR OutOriginal; - INT Written; - - LengthInStr = strlen(In); - Length = LengthInStr; - - - if (Padding > 0) - { - Length += Padding; - } - Out = (LPSTR) PAL_malloc(Length+1); - int iLen = Length+1; - if (!Out) - { - return -1; - } - OutOriginal = Out; - - if (Flags & PFF_MINUS) /* pad on right */ - { - if (strcpy_s(Out, iLen, In) != SAFECRT_SUCCESS) - { - Written = -1; - goto Done; - } - - Out += LengthInStr; - iLen -= LengthInStr; - } - if (Padding > 0) - { - iLen -= Padding; - if (Flags & PFF_ZERO) /* '0', pad with zeros */ - { - while (Padding--) - { - *Out++ = '0'; - } - } - else /* pad with spaces */ - { - while (Padding--) - { - *Out++ = ' '; - } - } - } - if (!(Flags & PFF_MINUS)) /* put 'In' after padding */ - { - if (strcpy_s(Out, Length+1, In) != SAFECRT_SUCCESS) - { - Written = -1; - goto Done; - } - - Out += LengthInStr; - iLen -= LengthInStr; - } - -#if FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL - clearerr((FILE*)stream); -#endif - - Written = PAL_fwrite(OutOriginal, 1, Length, stream); - if (stream->PALferrorCode == PAL_FILE_ERROR) - { - Written = -1; - } - -Done: - PAL_free(OutOriginal); - return Written; -} - -/*++ -Function: - PAL_wcslen (silent version) - -See MSDN or the man page for wcslen. - ---*/ -size_t Silent_PAL_wcslen(const wchar_16 *string) -{ - size_t nChar = 0; - - if ( !string ) - { - return 0; - } - while (*string++) - { - nChar++; - } - - return nChar; -} diff --git a/src/coreclr/pal/src/include/pal/cruntime.h b/src/coreclr/pal/src/include/pal/cruntime.h index 6d5bd75..a2ce278 100644 --- a/src/coreclr/pal/src/include/pal/cruntime.h +++ b/src/coreclr/pal/src/include/pal/cruntime.h @@ -95,43 +95,6 @@ typedef enum SCANF_TYPE_SPACE = 7 }SCANF_TYPES; -/******************************************************************************* -Function: - PAL_printf_arg_remover - -Parameters: - ap - - pointer to the va_list from which to remove arguments - Width - - the width of the current format option - Precision - - the precision of the current format option - Type - - the type of the argument for the current format option - Prefix - - the prefix for the current format option -*******************************************************************************/ -void PAL_printf_arg_remover(va_list *ap, INT Width, INT Precision, INT Type, INT Prefix); - -/*++ -Function: - Silent_PAL_vsnprintf - -See MSDN doc. ---*/ -INT Silent_PAL_vsnprintf(LPSTR Buffer, INT Count, LPCSTR Format, va_list ap); - -/*++ -Function: - Silent_PAL_vfprintf - -See MSDN doc. ---*/ -int Silent_PAL_vfprintf(PAL_FILE *stream, const char *format, va_list ap); - - - - /*++ struct PAL_FILE. diff --git a/src/coreclr/pal/src/include/pal/palinternal.h b/src/coreclr/pal/src/include/pal/palinternal.h index 32fdfad..d1036b9 100644 --- a/src/coreclr/pal/src/include/pal/palinternal.h +++ b/src/coreclr/pal/src/include/pal/palinternal.h @@ -230,6 +230,8 @@ function_name() to call the system's implementation #define tanhf DUMMY_tanhf #define truncf DUMMY_truncf #define remove DUMMY_remove +#define printf DUMMY_printf +#define vprintf DUMMY_vprintf /* RAND_MAX needed to be renamed to avoid duplicate definition when including stdlib.h header files. PAL_RAND_MAX should have the same value as RAND_MAX @@ -494,16 +496,15 @@ function_name() to call the system's implementation #undef open #undef glob #undef remove +#undef printf +#undef vprintf #undef ptrdiff_t #undef intptr_t #undef uintptr_t #undef timeval - -#undef printf #undef fprintf #undef vfprintf -#undef vprintf #undef wcstod #undef wcstoul #undef _wcstoui64 diff --git a/src/coreclr/pal/src/safecrt/mbusafecrt_internal.h b/src/coreclr/pal/src/safecrt/mbusafecrt_internal.h index 591e213..9929ae2 100644 --- a/src/coreclr/pal/src/safecrt/mbusafecrt_internal.h +++ b/src/coreclr/pal/src/safecrt/mbusafecrt_internal.h @@ -87,9 +87,6 @@ void _safecrt_wfassign(int flag, void* argument, char16_t * number ); int _minimal_chartowchar( char16_t* outWChar, const char* inChar ); -int _output_s( miniFILE* outfile, const char* _Format, va_list _ArgList); -int _output( miniFILE *outfile, const char* _Format, va_list _ArgList); - int __tinput_s( miniFILE* inFile, const unsigned char * inFormat, va_list inArgList ); int __twinput_s( miniFILE* inFile, const char16_t * inFormat, va_list inArgList ); diff --git a/src/coreclr/pal/src/safecrt/output.inl b/src/coreclr/pal/src/safecrt/output.inl deleted file mode 100644 index d22de4a..0000000 --- a/src/coreclr/pal/src/safecrt/output.inl +++ /dev/null @@ -1,1575 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*** -*output.c - printf style output to a FILE -* - -* -*Purpose: -* This file contains the code that does all the work for the -* printf family of functions. It should not be called directly, only -* by the *printf functions. We don't make any assumtions about the -* sizes of ints, longs, shorts, or long doubles, but if types do overlap, -* we also try to be efficient. We do assume that pointers are the same -* size as either ints or longs. -* If CPRFLAG is defined, defines _cprintf instead. -* **** DOESN'T CURRENTLY DO MTHREAD LOCKING **** -* -*Note: -* this file is included in safecrt.lib build directly, plese refer -* to safecrt_[w]output_s.c -* -*******************************************************************************/ - - -//typedef __int64_t __int64; - - -#define FORMAT_VALIDATIONS - -typedef double _CRT_DOUBLE; - -//typedef int* intptr_t; - -/* -Buffer size required to be passed to _gcvt, fcvt and other fp conversion routines -*/ -#define _CVTBUFSIZE (309+40) /* # of digits in max. dp value + slop */ - -/* temporary work-around for compiler without 64-bit support */ -#ifndef _INTEGRAL_MAX_BITS -#define _INTEGRAL_MAX_BITS 64 -#endif /* _INTEGRAL_MAX_BITS */ - -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include - -#define _MBTOWC(x,y,z) _minimal_chartowchar( x, y ) - -#ifndef _WCTOMB_S -#define _WCTOMB_S wctomb_s -#endif /* _WCTOMB_S */ - -#undef _malloc_crt -#define _malloc_crt malloc - -#undef _free_crt -#define _free_crt free - -#ifndef _CFLTCVT -#define _CFLTCVT _cfltcvt -#endif /* _CFLTCVT */ - -#ifndef _CLDCVT -#define _CLDCVT _cldcvt -#endif /* _CLDCVT */ - -/* this macro defines a function which is private and as fast as possible: */ -/* for example, in C 6.0, it might be static _fastcall near. */ -#define LOCAL(x) static x __cdecl - -/* int/long/short/pointer sizes */ - -/* the following should be set depending on the sizes of various types */ -#if __LP64__ - #define LONG_IS_INT 0 - CASSERT(sizeof(long) > sizeof(int)); -#else - #define LONG_IS_INT 1 /* 1 means long is same size as int */ - CASSERT(sizeof(long) == sizeof(int)); -#endif - -#define SHORT_IS_INT 0 /* 1 means short is same size as int */ -#define LONGLONG_IS_INT64 1 /* 1 means long long is same as int64 */ -#if defined (HOST_64BIT) - #define PTR_IS_INT 0 /* 1 means ptr is same size as int */ - CASSERT(sizeof(void *) != sizeof(int)); - #if __LP64__ - #define PTR_IS_LONG 1 /* 1 means ptr is same size as long */ - CASSERT(sizeof(void *) == sizeof(long)); - #else - #define PTR_IS_LONG 0 /* 1 means ptr is same size as long */ - CASSERT(sizeof(void *) != sizeof(long)); - #endif - #define PTR_IS_INT64 1 /* 1 means ptr is same size as int64 */ - CASSERT(sizeof(void *) == sizeof(int64_t)); -#else /* defined (HOST_64BIT) */ - #define PTR_IS_INT 1 /* 1 means ptr is same size as int */ - CASSERT(sizeof(void *) == sizeof(int)); - #define PTR_IS_LONG 1 /* 1 means ptr is same size as long */ - CASSERT(sizeof(void *) == sizeof(long)); - #define PTR_IS_INT64 0 /* 1 means ptr is same size as int64 */ - CASSERT(sizeof(void *) != sizeof(int64_t)); -#endif /* defined (HOST_64BIT) */ - -/* CONSTANTS */ - -/* size of conversion buffer (ANSI-specified minimum is 509) */ - -#define BUFFERSIZE 512 -#define MAXPRECISION BUFFERSIZE - -#if BUFFERSIZE < _CVTBUFSIZE + 6 -/* - * Buffer needs to be big enough for default minimum precision - * when converting floating point needs bigger buffer, and malloc - * fails - */ -#error Conversion buffer too small for max double. -#endif /* BUFFERSIZE < _CVTBUFSIZE + 6 */ - -/* flag definitions */ -#define FL_SIGN 0x00001 /* put plus or minus in front */ -#define FL_SIGNSP 0x00002 /* put space or minus in front */ -#define FL_LEFT 0x00004 /* left justify */ -#define FL_LEADZERO 0x00008 /* pad with leading zeros */ -#define FL_LONG 0x00010 /* long value given */ -#define FL_SHORT 0x00020 /* short value given */ -#define FL_SIGNED 0x00040 /* signed data given */ -#define FL_ALTERNATE 0x00080 /* alternate form requested */ -#define FL_NEGATIVE 0x00100 /* value is negative */ -#define FL_FORCEOCTAL 0x00200 /* force leading '0' for octals */ -#define FL_LONGDOUBLE 0x00400 /* long double value given */ -#define FL_WIDECHAR 0x00800 /* wide characters */ -#define FL_LONGLONG 0x01000 /* long long value given */ -#define FL_I64 0x08000 /* __int64 value given */ - -/* state definitions */ -enum STATE { - ST_NORMAL, /* normal state; outputting literal chars */ - ST_PERCENT, /* just read '%' */ - ST_FLAG, /* just read flag character */ - ST_WIDTH, /* just read width specifier */ - ST_DOT, /* just read '.' */ - ST_PRECIS, /* just read precision specifier */ - ST_SIZE, /* just read size specifier */ - ST_TYPE /* just read type specifier */ -#ifdef FORMAT_VALIDATIONS - ,ST_INVALID /* Invalid format */ -#endif /* FORMAT_VALIDATIONS */ - -}; - -#ifdef FORMAT_VALIDATIONS -#define NUMSTATES (ST_INVALID + 1) -#else /* FORMAT_VALIDATIONS */ -#define NUMSTATES (ST_TYPE + 1) -#endif /* FORMAT_VALIDATIONS */ - -/* character type values */ -enum CHARTYPE { - CH_OTHER, /* character with no special meaning */ - CH_PERCENT, /* '%' */ - CH_DOT, /* '.' */ - CH_STAR, /* '*' */ - CH_ZERO, /* '0' */ - CH_DIGIT, /* '1'..'9' */ - CH_FLAG, /* ' ', '+', '-', '#' */ - CH_SIZE, /* 'h', 'l', 'L', 'N', 'F', 'w' */ - CH_TYPE /* type specifying character */ -}; - -/* static data (read only, since we are re-entrant) */ -//#if defined (_UNICODE) || defined (CPRFLAG) || defined (FORMAT_VALIDATIONS) -//extern const char __nullstring[]; /* string to print on null ptr */ -//extern const char16_t __wnullstring[]; /* string to print on null ptr */ -//#else /* defined (_UNICODE) || defined (CPRFLAG) || defined (FORMAT_VALIDATIONS) */ -static const char __nullstring[] = "(null)"; /* string to print on null ptr */ -static const char16_t __wnullstring[] = {'(', 'n', 'u', 'l', 'l', ')', '\0'};/* string to print on null ptr */ -//#endif /* defined (_UNICODE) || defined (CPRFLAG) || defined (FORMAT_VALIDATIONS) */ - -/* The state table. This table is actually two tables combined into one. */ -/* The lower nybble of each byte gives the character class of any */ -/* character; while the uper nybble of the byte gives the next state */ -/* to enter. See the macros below the table for details. */ -/* */ -/* The table is generated by maketabc.c -- use this program to make */ -/* changes. */ - -#ifndef FORMAT_VALIDATIONS - -//#if defined (_UNICODE) || defined (CPRFLAG) -//extern const char __lookuptable[]; -//#else /* defined (_UNICODE) || defined (CPRFLAG) */ -extern const char __lookuptable[] = { - /* ' ' */ 0x06, - /* '!' */ 0x00, - /* '"' */ 0x00, - /* '#' */ 0x06, - /* '$' */ 0x00, - /* '%' */ 0x01, - /* '&' */ 0x00, - /* ''' */ 0x00, - /* '(' */ 0x10, - /* ')' */ 0x00, - /* '*' */ 0x03, - /* '+' */ 0x06, - /* ',' */ 0x00, - /* '-' */ 0x06, - /* '.' */ 0x02, - /* '/' */ 0x10, - /* '0' */ 0x04, - /* '1' */ 0x45, - /* '2' */ 0x45, - /* '3' */ 0x45, - /* '4' */ 0x05, - /* '5' */ 0x05, - /* '6' */ 0x05, - /* '7' */ 0x05, - /* '8' */ 0x05, - /* '9' */ 0x35, - /* ':' */ 0x30, - /* ';' */ 0x00, - /* '<' */ 0x50, - /* '=' */ 0x00, - /* '>' */ 0x00, - /* '?' */ 0x00, - /* '@' */ 0x00, - /* 'A' */ 0x20, // Disable %A format - /* 'B' */ 0x20, - /* 'C' */ 0x38, - /* 'D' */ 0x50, - /* 'E' */ 0x58, - /* 'F' */ 0x07, - /* 'G' */ 0x08, - /* 'H' */ 0x00, - /* 'I' */ 0x37, - /* 'J' */ 0x30, - /* 'K' */ 0x30, - /* 'L' */ 0x57, - /* 'M' */ 0x50, - /* 'N' */ 0x07, - /* 'O' */ 0x00, - /* 'P' */ 0x00, - /* 'Q' */ 0x20, - /* 'R' */ 0x20, - /* 'S' */ 0x08, - /* 'T' */ 0x00, - /* 'U' */ 0x00, - /* 'V' */ 0x00, - /* 'W' */ 0x00, - /* 'X' */ 0x08, - /* 'Y' */ 0x60, - /* 'Z' */ 0x68, - /* '[' */ 0x60, - /* '\' */ 0x60, - /* ']' */ 0x60, - /* '^' */ 0x60, - /* '_' */ 0x00, - /* '`' */ 0x00, - /* 'a' */ 0x70, // Disable %a format - /* 'b' */ 0x70, - /* 'c' */ 0x78, - /* 'd' */ 0x78, - /* 'e' */ 0x78, - /* 'f' */ 0x78, - /* 'g' */ 0x08, - /* 'h' */ 0x07, - /* 'i' */ 0x08, - /* 'j' */ 0x00, - /* 'k' */ 0x00, - /* 'l' */ 0x07, - /* 'm' */ 0x00, - /* 'n' */ 0x00, // Disable %n format - /* 'o' */ 0x08, - /* 'p' */ 0x08, - /* 'q' */ 0x00, - /* 'r' */ 0x00, - /* 's' */ 0x08, - /* 't' */ 0x00, - /* 'u' */ 0x08, - /* 'v' */ 0x00, - /* 'w' */ 0x07, - /* 'x' */ 0x08 -}; - -//#endif /* defined (_UNICODE) || defined (CPRFLAG) */ - -#else /* FORMAT_VALIDATIONS */ - -//#if defined (_UNICODE) || defined (CPRFLAG) -//extern const unsigned char __lookuptable_s[]; -//#else /* defined (_UNICODE) || defined (CPRFLAG) */ -static const unsigned char __lookuptable_s[] = { - /* ' ' */ 0x06, - /* '!' */ 0x80, - /* '"' */ 0x80, - /* '#' */ 0x86, - /* '$' */ 0x80, - /* '%' */ 0x81, - /* '&' */ 0x80, - /* ''' */ 0x00, - /* '(' */ 0x00, - /* ')' */ 0x10, - /* '*' */ 0x03, - /* '+' */ 0x86, - /* ',' */ 0x80, - /* '-' */ 0x86, - /* '.' */ 0x82, - /* '/' */ 0x80, - /* '0' */ 0x14, - /* '1' */ 0x05, - /* '2' */ 0x05, - /* '3' */ 0x45, - /* '4' */ 0x45, - /* '5' */ 0x45, - /* '6' */ 0x85, - /* '7' */ 0x85, - /* '8' */ 0x85, - /* '9' */ 0x05, - /* ':' */ 0x00, - /* ';' */ 0x00, - /* '<' */ 0x30, - /* '=' */ 0x30, - /* '>' */ 0x80, - /* '?' */ 0x50, - /* '@' */ 0x80, - /* 'A' */ 0x80, // Disable %A format - /* 'B' */ 0x00, - /* 'C' */ 0x08, - /* 'D' */ 0x00, - /* 'E' */ 0x28, - /* 'F' */ 0x27, - /* 'G' */ 0x38, - /* 'H' */ 0x50, - /* 'I' */ 0x57, - /* 'J' */ 0x80, - /* 'K' */ 0x00, - /* 'L' */ 0x07, - /* 'M' */ 0x00, - /* 'N' */ 0x37, - /* 'O' */ 0x30, - /* 'P' */ 0x30, - /* 'Q' */ 0x50, - /* 'R' */ 0x50, - /* 'S' */ 0x88, - /* 'T' */ 0x00, - /* 'U' */ 0x00, - /* 'V' */ 0x00, - /* 'W' */ 0x20, - /* 'X' */ 0x28, - /* 'Y' */ 0x80, - /* 'Z' */ 0x88, - /* '[' */ 0x80, - /* '\' */ 0x80, - /* ']' */ 0x00, - /* '^' */ 0x00, - /* '_' */ 0x00, - /* '`' */ 0x60, - /* 'a' */ 0x60, // Disable %a format - /* 'b' */ 0x60, - /* 'c' */ 0x68, - /* 'd' */ 0x68, - /* 'e' */ 0x68, - /* 'f' */ 0x08, - /* 'g' */ 0x08, - /* 'h' */ 0x07, - /* 'i' */ 0x78, - /* 'j' */ 0x70, - /* 'k' */ 0x70, - /* 'l' */ 0x77, - /* 'm' */ 0x70, - /* 'n' */ 0x70, - /* 'o' */ 0x08, - /* 'p' */ 0x08, - /* 'q' */ 0x00, - /* 'r' */ 0x00, - /* 's' */ 0x08, - /* 't' */ 0x00, - /* 'u' */ 0x08, - /* 'v' */ 0x00, - /* 'w' */ 0x07, - /* 'x' */ 0x08, - /* 'y' */ 0x00, - /* 'z' */ 0x57 -}; -//#endif /* defined (_UNICODE) || defined (CPRFLAG) */ - -#endif /* FORMAT_VALIDATIONS */ - -#define FIND_CHAR_CLASS(lookuptbl, c) \ - ((c) < _T(' ') || (c) > _T('z') ? \ - CH_OTHER \ - : \ - (enum CHARTYPE)(lookuptbl[(c)-_T(' ')] & 0xF)) - -#define FIND_NEXT_STATE(lookuptbl, class, state) \ - (enum STATE)(lookuptbl[(class) * NUMSTATES + (state)] >> 4) - -/* - * Note: CPRFLAG and _UNICODE cases are currently mutually exclusive. - */ - -/* prototypes */ - -#ifdef CPRFLAG - -#define WRITE_CHAR(ch, pnw) write_char(ch, pnw) -#define WRITE_MULTI_CHAR(ch, num, pnw) write_multi_char(ch, num, pnw) -#define WRITE_STRING(s, len, pnw) write_string(s, len, pnw) - -LOCAL(void) write_char(_TCHAR ch, int *pnumwritten); -LOCAL(void) write_multi_char(_TCHAR ch, int num, int *pnumwritten); -LOCAL(void) write_string(const _TCHAR *string, int len, int *numwritten); - -#else /* CPRFLAG */ - -#define WRITE_CHAR(ch, pnw) write_char(ch, stream, pnw) -#define WRITE_MULTI_CHAR(ch, num, pnw) write_multi_char(ch, num, stream, pnw) -#define WRITE_STRING(s, len, pnw) write_string(s, len, stream, pnw) - -LOCAL(void) write_char(_TCHAR ch, miniFILE *f, int *pnumwritten); -LOCAL(void) write_multi_char(_TCHAR ch, int num, miniFILE *f, int *pnumwritten); -LOCAL(void) write_string(const _TCHAR *string, int len, miniFILE *f, int *numwritten); - -#endif /* CPRFLAG */ - -#define get_int_arg(list) va_arg(*list, int) -#define get_long_arg(list) va_arg(*list, long) -#define get_long_long_arg(list) va_arg(*list, long long) -#define get_int64_arg(list) va_arg(*list, __int64) -#define get_crtdouble_arg(list) va_arg(*list, _CRT_DOUBLE) -#define get_ptr_arg(list) va_arg(*list, void *) - -#ifdef CPRFLAG -LOCAL(int) output(const _TCHAR *, _locale_t , va_list); -_CRTIMP int __cdecl _vtcprintf_l (const _TCHAR *, _locale_t, va_list); -_CRTIMP int __cdecl _vtcprintf_s_l (const _TCHAR *, _locale_t, va_list); -_CRTIMP int __cdecl _vtcprintf_p_l (const _TCHAR *, _locale_t, va_list); - - -/*** -*int _cprintf(format, arglist) - write formatted output directly to console -* -*Purpose: -* Writes formatted data like printf, but uses console I/O functions. -* -*Entry: -* char *format - format string to determine data formats -* arglist - list of POINTERS to where to put data -* -*Exit: -* returns number of characters written -* -*Exceptions: -* -*******************************************************************************/ -#ifndef FORMAT_VALIDATIONS -_CRTIMP int __cdecl _tcprintf_l ( - const _TCHAR * format, - _locale_t plocinfo, - ... - ) -#else /* FORMAT_VALIDATIONS */ -_CRTIMP int __cdecl _tcprintf_s_l ( - const _TCHAR * format, - _locale_t plocinfo, - ... - ) -#endif /* FORMAT_VALIDATIONS */ - -{ - int ret; - va_list arglist; - va_start(arglist, plocinfo); - -#ifndef FORMAT_VALIDATIONS - ret = _vtcprintf_l(format, plocinfo, arglist); -#else /* FORMAT_VALIDATIONS */ - ret = _vtcprintf_s_l(format, plocinfo, arglist); - -#endif /* FORMAT_VALIDATIONS */ - - va_end(arglist); - - return ret; -} - -#ifndef FORMAT_VALIDATIONS -_CRTIMP int __cdecl _tcprintf ( - const _TCHAR * format, - ... - ) -#else /* FORMAT_VALIDATIONS */ -_CRTIMP int __cdecl _tcprintf_s ( - const _TCHAR * format, - ... - ) -#endif /* FORMAT_VALIDATIONS */ - -{ - int ret; - va_list arglist; - - va_start(arglist, format); - -#ifndef FORMAT_VALIDATIONS - ret = _vtcprintf_l(format, NULL, arglist); -#else /* FORMAT_VALIDATIONS */ - ret = _vtcprintf_s_l(format, NULL, arglist); - -#endif /* FORMAT_VALIDATIONS */ - - va_end(arglist); - - return ret; -} - -#endif /* CPRFLAG */ - - -/*** -*int _output(stream, format, argptr), static int output(format, argptr) -* -*Purpose: -* Output performs printf style output onto a stream. It is called by -* printf/fprintf/sprintf/vprintf/vfprintf/vsprintf to so the dirty -* work. In multi-thread situations, _output assumes that the given -* stream is already locked. -* -* Algorithm: -* The format string is parsed by using a finite state automaton -* based on the current state and the current character read from -* the format string. Thus, looping is on a per-character basis, -* not a per conversion specifier basis. Once the format specififying -* character is read, output is performed. -* -*Entry: -* FILE *stream - stream for output -* char *format - printf style format string -* va_list argptr - pointer to list of subsidiary arguments -* -*Exit: -* Returns the number of characters written, or -1 if an output error -* occurs. -*ifdef _UNICODE -* The wide-character flavour returns the number of wide-characters written. -*endif -* -*Exceptions: -* -*******************************************************************************/ -#ifdef CPRFLAG -#ifndef FORMAT_VALIDATIONS -_CRTIMP int __cdecl _vtcprintf ( - const _TCHAR *format, - va_list argptr - ) -{ - return _vtcprintf_l(format, NULL, argptr); -} - -#else /* FORMAT_VALIDATIONS */ -_CRTIMP int __cdecl _vtcprintf_s ( - const _TCHAR *format, - va_list argptr - ) -{ - return _vtcprintf_s_l(format, NULL, argptr); -} - -#endif /* FORMAT_VALIDATIONS */ -#endif /* CPRFLAG */ - -#ifdef CPRFLAG -#ifndef FORMAT_VALIDATIONS -_CRTIMP int __cdecl _vtcprintf_l ( -#else /* FORMAT_VALIDATIONS */ -_CRTIMP int __cdecl _vtcprintf_s_l ( -#endif /* FORMAT_VALIDATIONS */ -#else /* CPRFLAG */ - -#ifdef _UNICODE -#ifndef FORMAT_VALIDATIONS -int __cdecl _woutput ( - miniFILE *stream, -#else /* FORMAT_VALIDATIONS */ -int __cdecl _woutput_s ( - miniFILE *stream, -#endif /* FORMAT_VALIDATIONS */ -#else /* _UNICODE */ -#ifndef FORMAT_VALIDATIONS -int __cdecl _output ( - miniFILE *stream, -#else /* FORMAT_VALIDATIONS */ - int __cdecl _output_s ( - miniFILE *stream, - -#endif /* FORMAT_VALIDATIONS */ -#endif /* _UNICODE */ - -#endif /* CPRFLAG */ - const _TCHAR *format, - va_list argptr - ) -{ - int hexadd=0; /* offset to add to number to get 'a'..'f' */ - TCHAR ch; /* character just read */ - int flags=0; /* flag word -- see #defines above for flag values */ - enum STATE state; /* current state */ - enum CHARTYPE chclass; /* class of current character */ - int radix; /* current conversion radix */ - int charsout; /* characters currently written so far, -1 = IO error */ - int fldwidth = 0; /* selected field width -- 0 means default */ - int precision = 0; /* selected precision -- -1 means default */ - TCHAR prefix[2]; /* numeric prefix -- up to two characters */ - int prefixlen=0; /* length of prefix -- 0 means no prefix */ - int capexp = 0; /* non-zero = 'E' exponent signifient, zero = 'e' */ - int no_output=0; /* non-zero = prodcue no output for this specifier */ - union { - const char *sz; /* pointer text to be printed, not zero terminated */ - const char16_t *wz; - } text; - - int textlen; /* length of the text in bytes/wchars to be printed. - textlen is in multibyte or wide chars if _UNICODE */ - union { - char sz[BUFFERSIZE]; -#ifdef _UNICODE - char16_t wz[BUFFERSIZE]; -#endif /* _UNICODE */ - } buffer; - char16_t wchar; /* temp char16_t */ - int buffersize; /* size of text.sz (used only for the call to _cfltcvt) */ - int bufferiswide=0; /* non-zero = buffer contains wide chars already */ - -#ifndef CPRFLAG - _VALIDATE_RETURN( (stream != NULL), EINVAL, -1); -#endif /* CPRFLAG */ - _VALIDATE_RETURN( (format != NULL), EINVAL, -1); - - charsout = 0; /* no characters written yet */ - textlen = 0; /* no text yet */ - state = ST_NORMAL; /* starting state */ - buffersize = 0; - - /* main loop -- loop while format character exist and no I/O errors */ - while ((ch = *format++) != _T('\0') && charsout >= 0) { -#ifndef FORMAT_VALIDATIONS - chclass = FIND_CHAR_CLASS(__lookuptable, ch); /* find character class */ - state = FIND_NEXT_STATE(__lookuptable, chclass, state); /* find next state */ -#else /* FORMAT_VALIDATIONS */ - chclass = FIND_CHAR_CLASS(__lookuptable_s, ch); /* find character class */ - state = FIND_NEXT_STATE(__lookuptable_s, chclass, state); /* find next state */ - - _VALIDATE_RETURN((state != ST_INVALID), EINVAL, -1); - -#endif /* FORMAT_VALIDATIONS */ - - /* execute code for each state */ - switch (state) { - - case ST_NORMAL: - - NORMAL_STATE: - - /* normal state -- just write character */ -#ifdef _UNICODE - bufferiswide = 1; -#else /* _UNICODE */ - bufferiswide = 0; -#endif /* _UNICODE */ - WRITE_CHAR(ch, &charsout); - break; - - case ST_PERCENT: - /* set default value of conversion parameters */ - prefixlen = fldwidth = no_output = capexp = 0; - flags = 0; - precision = -1; - bufferiswide = 0; /* default */ - break; - - case ST_FLAG: - /* set flag based on which flag character */ - switch (ch) { - case _T('-'): - flags |= FL_LEFT; /* '-' => left justify */ - break; - case _T('+'): - flags |= FL_SIGN; /* '+' => force sign indicator */ - break; - case _T(' '): - flags |= FL_SIGNSP; /* ' ' => force sign or space */ - break; - case _T('#'): - flags |= FL_ALTERNATE; /* '#' => alternate form */ - break; - case _T('0'): - flags |= FL_LEADZERO; /* '0' => pad with leading zeros */ - break; - } - break; - - case ST_WIDTH: - /* update width value */ - if (ch == _T('*')) { - /* get width from arg list */ - fldwidth = get_int_arg(&argptr); - if (fldwidth < 0) { - /* ANSI says neg fld width means '-' flag and pos width */ - flags |= FL_LEFT; - fldwidth = -fldwidth; - } - } - else { - /* add digit to current field width */ - fldwidth = fldwidth * 10 + (ch - _T('0')); - } - break; - - case ST_DOT: - /* zero the precision, since dot with no number means 0 - not default, according to ANSI */ - precision = 0; - break; - - case ST_PRECIS: - /* update precision value */ - if (ch == _T('*')) { - /* get precision from arg list */ - precision = get_int_arg(&argptr); - if (precision < 0) - precision = -1; /* neg precision means default */ - } - else { - /* add digit to current precision */ - precision = precision * 10 + (ch - _T('0')); - } - break; - - case ST_SIZE: - /* just read a size specifier, set the flags based on it */ - switch (ch) { - case _T('l'): - /* - * In order to handle the ll case, we depart from the - * simple deterministic state machine. - */ - if (*format == _T('l')) - { - ++format; - flags |= FL_LONGLONG; /* 'll' => long long */ - } - else - { - flags |= FL_LONG; /* 'l' => long int or char16_t */ - } - break; - case _T('L'): - if (*format == _T('p')) - { - flags |= FL_LONG; - } - break; - - case _T('z'): - case _T('I'): - /* - * In order to handle the I, I32, and I64 size modifiers, we - * depart from the simple deterministic state machine. The - * code below scans for characters following the 'I', - * and defaults to 64 bit on WIN64 and 32 bit on WIN32 - */ -#if PTR_IS_INT64 - flags |= FL_I64; /* 'I' => __int64 on WIN64 systems */ -#endif /* PTR_IS_INT64 */ - if ( (*format == _T('6')) && (*(format + 1) == _T('4')) ) - { - format += 2; - flags |= FL_I64; /* I64 => __int64 */ - } - else if ( (*format == _T('3')) && (*(format + 1) == _T('2')) ) - { - format += 2; - flags &= ~FL_I64; /* I32 => __int32 */ - } - else if ( (*format == _T('d')) || - (*format == _T('i')) || - (*format == _T('o')) || - (*format == _T('u')) || - (*format == _T('x')) || - (*format == _T('X')) ) - { - /* - * Nothing further needed. %Id (et al) is - * handled just like %d, except that it defaults to 64 bits - * on WIN64. Fall through to the next iteration. - */ - } - else { - state = ST_NORMAL; - goto NORMAL_STATE; - } - break; - - case _T('h'): - flags |= FL_SHORT; /* 'h' => short int or char */ - break; - - case _T('w'): - flags |= FL_WIDECHAR; /* 'w' => wide character */ - break; - - } - break; - - case ST_TYPE: - /* we have finally read the actual type character, so we */ - /* now format and "print" the output. We use a big switch */ - /* statement that sets 'text' to point to the text that should */ - /* be printed, and 'textlen' to the length of this text. */ - /* Common code later on takes care of justifying it and */ - /* other miscellaneous chores. Note that cases share code, */ - /* in particular, all integer formatting is done in one place. */ - /* Look at those funky goto statements! */ - - switch (ch) { - - case _T('C'): /* ISO wide character */ - if (!(flags & (FL_SHORT|FL_LONG|FL_WIDECHAR))) -#ifdef _UNICODE - flags |= FL_SHORT; -#else /* _UNICODE */ - flags |= FL_WIDECHAR; /* ISO std. */ -#endif /* _UNICODE */ - /* fall into 'c' case */ - - FALLTHROUGH; - case _T('c'): { - /* print a single character specified by int argument */ -#ifdef _UNICODE - bufferiswide = 1; - wchar = (char16_t) get_int_arg(&argptr); - if (flags & FL_SHORT) { - /* format multibyte character */ - /* this is an extension of ANSI */ - char tempchar[2]; - { - tempchar[0] = (char)(wchar & 0x00ff); - tempchar[1] = '\0'; - } - - if (_MBTOWC(buffer.wz,tempchar, MB_CUR_MAX) < 0) - { - /* ignore if conversion was unsuccessful */ - no_output = 1; - } - } else { - buffer.wz[0] = wchar; - } - text.wz = buffer.wz; - textlen = 1; /* print just a single character */ -#else /* _UNICODE */ - if (flags & (FL_LONG|FL_WIDECHAR)) { - wchar = (char16_t) get_int_arg(&argptr); - textlen = snprintf(buffer.sz, BUFFERSIZE, "%lc", wchar); - if (textlen == 0) - { - no_output = 1; - } - } else { - /* format multibyte character */ - /* this is an extension of ANSI */ - unsigned short temp; - wchar = (char16_t)get_int_arg(&argptr); - temp = (unsigned short)wchar; - { - buffer.sz[0] = (char) temp; - textlen = 1; - } - } - text.sz = buffer.sz; -#endif /* _UNICODE */ - } - break; - - case _T('Z'): { - /* print a Counted String */ - struct _count_string { - short Length; - short MaximumLength; - char *Buffer; - } *pstr; - - pstr = (struct _count_string *)get_ptr_arg(&argptr); - if (pstr == NULL || pstr->Buffer == NULL) { - /* null ptr passed, use special string */ - text.sz = __nullstring; - textlen = (int)strlen(text.sz); - } else { - if (flags & FL_WIDECHAR) { - text.wz = (char16_t *)pstr->Buffer; - textlen = pstr->Length / (int)sizeof(char16_t); - bufferiswide = 1; - } else { - bufferiswide = 0; - text.sz = pstr->Buffer; - textlen = pstr->Length; - } - } - } - break; - - case _T('S'): /* ISO wide character string */ -#ifndef _UNICODE - if (!(flags & (FL_SHORT|FL_LONG|FL_WIDECHAR))) - flags |= FL_WIDECHAR; -#else /* _UNICODE */ - if (!(flags & (FL_SHORT|FL_LONG|FL_WIDECHAR))) - flags |= FL_SHORT; -#endif /* _UNICODE */ - FALLTHROUGH; - - case _T('s'): { - /* print a string -- */ - /* ANSI rules on how much of string to print: */ - /* all if precision is default, */ - /* min(precision, length) if precision given. */ - /* prints '(null)' if a null string is passed */ - - int i; - const char *p; /* temps */ - const char16_t *pwch; - - /* At this point it is tempting to use strlen(), but */ - /* if a precision is specified, we're not allowed to */ - /* scan past there, because there might be no null */ - /* at all. Thus, we must do our own scan. */ - - i = (precision == -1) ? INT_MAX : precision; - text.sz = (char *)get_ptr_arg(&argptr); - - /* scan for null upto i characters */ -#ifdef _UNICODE - if (flags & FL_SHORT) { - if (text.sz == NULL) /* NULL passed, use special string */ - text.sz = __nullstring; - p = text.sz; - for (textlen=0; textlen MAXPRECISION) - precision = MAXPRECISION; - - if (precision > BUFFERSIZE - _CVTBUFSIZE) { - /* cap precision further */ - precision = BUFFERSIZE - _CVTBUFSIZE; - } - - /* for safecrt, we pass along the FL_ALTERNATE flag to _safecrt_cfltcvt */ - if (flags & FL_ALTERNATE) - { - capexp |= FL_ALTERNATE; - } - - _CRT_DOUBLE tmp; - tmp=va_arg(argptr, _CRT_DOUBLE); - /* Note: assumes ch is in ASCII range */ - /* In safecrt, we provide a special version of _cfltcvt which internally calls printf (see safecrt_output_s.c) */ - _CFLTCVT(&tmp, buffer.sz, buffersize, (char)ch, precision, capexp); - - /* check if result was negative, save '-' for later */ - /* and point to positive part (this is for '0' padding) */ - if (*text.sz == '-') { - flags |= FL_NEGATIVE; - ++text.sz; - } - - textlen = (int)strlen(text.sz); /* compute length of text */ - } - break; - - case _T('d'): - case _T('i'): - /* signed decimal output */ - flags |= FL_SIGNED; - radix = 10; - goto COMMON_INT; - - case _T('u'): - radix = 10; - goto COMMON_INT; - - case _T('p'): - /* write a pointer -- this is like an integer or long */ - /* except we force precision to pad with zeros and */ - /* output in big hex. */ - - precision = 2 * sizeof(void *); /* number of hex digits needed */ -#if PTR_IS_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 */ - /* DROP THROUGH to hex formatting */ - FALLTHROUGH; - - case _T('X'): - /* unsigned upper hex output */ - hexadd = _T('A') - _T('9') - 1; /* set hexadd for uppercase hex */ - goto COMMON_HEX; - - case _T('x'): - /* unsigned lower hex output */ - hexadd = _T('a') - _T('9') - 1; /* set hexadd for lowercase hex */ - /* DROP THROUGH TO COMMON_HEX */ - - COMMON_HEX: - radix = 16; - if (flags & FL_ALTERNATE) { - /* alternate form means '0x' prefix */ - prefix[0] = _T('0'); - prefix[1] = (TCHAR)(_T('x') - _T('a') + _T('9') + 1 + hexadd); /* 'x' or 'X' */ - prefixlen = 2; - } - goto COMMON_INT; - - case _T('o'): - /* unsigned octal output */ - radix = 8; - if (flags & FL_ALTERNATE) { - /* alternate form means force a leading 0 */ - flags |= FL_FORCEOCTAL; - } - /* DROP THROUGH to COMMON_INT */ - - COMMON_INT: { - /* This is the general integer formatting routine. */ - /* Basically, we get an argument, make it positive */ - /* if necessary, and convert it according to the */ - /* correct radix, setting text and textlen */ - /* appropriately. */ - -#if _INTEGRAL_MAX_BITS >= 64 - uint64_t number; /* number to convert */ - int digit; /* ascii value of digit */ - __int64 l; /* temp long value */ -#else /* _INTEGRAL_MAX_BITS >= 64 */ - unsigned long number; /* number to convert */ - int digit; /* ascii value of digit */ - long l; /* temp long value */ -#endif /* _INTEGRAL_MAX_BITS >= 64 */ - - /* 1. read argument into l, sign extend as needed */ -#if _INTEGRAL_MAX_BITS >= 64 - if (flags & FL_I64) - l = get_int64_arg(&argptr); - else -#endif /* _INTEGRAL_MAX_BITS >= 64 */ - - if (flags & FL_LONGLONG) - l = get_long_long_arg(&argptr); - - else - -#if !LONG_IS_INT - if (flags & FL_LONG) - l = get_long_arg(&argptr); - else -#endif /* !LONG_IS_INT */ - -#if !SHORT_IS_INT - if (flags & FL_SHORT) { - if (flags & FL_SIGNED) - l = (short) get_int_arg(&argptr); /* sign extend */ - else - l = (unsigned short) get_int_arg(&argptr); /* zero-extend*/ - - } else -#endif /* !SHORT_IS_INT */ - { - if (flags & FL_SIGNED) - l = get_int_arg(&argptr); /* sign extend */ - else - l = (unsigned int) get_int_arg(&argptr); /* zero-extend*/ - } - - /* 2. check for negative; copy into number */ - if ( (flags & FL_SIGNED) && l < 0) { - number = -l; - flags |= FL_NEGATIVE; /* remember negative sign */ - } else { - number = l; - } - -#if _INTEGRAL_MAX_BITS >= 64 - if ( (flags & FL_I64) == 0 && (flags & FL_LONGLONG) == 0 ) { - /* - * Unless printing a full 64-bit value, insure values - * here are not in cananical longword format to prevent - * the sign extended upper 32-bits from being printed. - */ - number &= 0xffffffff; - } -#endif /* _INTEGRAL_MAX_BITS >= 64 */ - - /* 3. check precision value for default; non-default */ - /* turns off 0 flag, according to ANSI. */ - if (precision < 0) - precision = 1; /* default precision */ - else { - flags &= ~FL_LEADZERO; - if (precision > MAXPRECISION) - precision = MAXPRECISION; - } - - /* 4. Check if data is 0; if so, turn off hex prefix */ - if (number == 0) - prefixlen = 0; - - /* 5. Convert data to ASCII -- note if precision is zero */ - /* and number is zero, we get no digits at all. */ - - char *sz; - sz = &buffer.sz[BUFFERSIZE-1]; /* last digit at end of buffer */ - - while (precision-- > 0 || number != 0) { - digit = (int)(number % radix) + '0'; - number /= radix; /* reduce number */ - if (digit > '9') { - /* a hex digit, make it a letter */ - digit += hexadd; - } - *sz-- = (char)digit; /* store the digit */ - } - - textlen = (int)((char *)&buffer.sz[BUFFERSIZE-1] - sz); /* compute length of number */ - ++sz; /* text points to first digit now */ - - - /* 6. Force a leading zero if FORCEOCTAL flag set */ - if ((flags & FL_FORCEOCTAL) && (textlen == 0 || sz[0] != '0')) { - *--sz = '0'; - ++textlen; /* add a zero */ - } - - text.sz = sz; - } - break; - } - - - /* At this point, we have done the specific conversion, and */ - /* 'text' points to text to print; 'textlen' is length. Now we */ - /* justify it, put on prefixes, leading zeros, and then */ - /* print it. */ - - if (!no_output) { - int padding; /* amount of padding, negative means zero */ - - if (flags & FL_SIGNED) { - if (flags & FL_NEGATIVE) { - /* prefix is a '-' */ - prefix[0] = _T('-'); - prefixlen = 1; - } - else if (flags & FL_SIGN) { - /* prefix is '+' */ - prefix[0] = _T('+'); - prefixlen = 1; - } - else if (flags & FL_SIGNSP) { - /* prefix is ' ' */ - prefix[0] = _T(' '); - prefixlen = 1; - } - } - - /* calculate amount of padding -- might be negative, */ - /* but this will just mean zero */ - padding = fldwidth - textlen - prefixlen; - - /* put out the padding, prefix, and text, in the correct order */ - - if (!(flags & (FL_LEFT | FL_LEADZERO))) { - /* pad on left with blanks */ - WRITE_MULTI_CHAR(_T(' '), padding, &charsout); - } - - /* write prefix */ - WRITE_STRING(prefix, prefixlen, &charsout); - - if ((flags & FL_LEADZERO) && !(flags & FL_LEFT)) { - /* write leading zeros */ - WRITE_MULTI_CHAR(_T('0'), padding, &charsout); - } - - /* write text */ -#ifndef _UNICODE - if (bufferiswide && (textlen > 0)) { - 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); - } -#else /* _UNICODE */ - if (!bufferiswide && textlen > 0) { - const char *p; - int retval = 0; - int count; - - p = text.sz; - count = textlen; - while (count-- > 0) { - retval = _MBTOWC(&wchar, p, MB_CUR_MAX); - if (retval <= 0) { - charsout = -1; - break; - } - WRITE_CHAR(wchar, &charsout); - p += retval; - } - } else { - WRITE_STRING(text.wz, textlen, &charsout); - } -#endif /* _UNICODE */ - - if (charsout >= 0 && (flags & FL_LEFT)) { - /* pad on right with blanks */ - WRITE_MULTI_CHAR(_T(' '), padding, &charsout); - } - - /* we're done! */ - } - break; - case ST_INVALID: - _VALIDATE_RETURN(0 /* FALSE */, EINVAL, -1); - break; - } - } - -#ifdef FORMAT_VALIDATIONS - /* The format string shouldn't be incomplete - i.e. when we are finished - with the format string, the last thing we should have encountered - should have been a regular char to be output or a type specifier. Else - the format string was incomplete */ - _VALIDATE_RETURN(((state == ST_NORMAL) || (state == ST_TYPE)), EINVAL, -1); -#endif /* FORMAT_VALIDATIONS */ - - return charsout; /* return value = number of characters written */ -} - -/* - * Future Optimizations for swprintf: - * - Don't free the memory used for converting the buffer to wide chars. - * Use realloc if the memory is not sufficient. Free it at the end. - */ - -/*** -*void write_char(char ch, int *pnumwritten) -*ifdef _UNICODE -*void write_char(char16_t ch, FILE *f, int *pnumwritten) -*endif -*void write_char(char ch, FILE *f, int *pnumwritten) -* -*Purpose: -* Writes a single character to the given file/console. If no error occurs, -* then *pnumwritten is incremented; otherwise, *pnumwritten is set -* to -1. -* -*Entry: -* _TCHAR ch - character to write -* FILE *f - file to write to -* int *pnumwritten - pointer to integer to update with total chars written -* -*Exit: -* No return value. -* -*Exceptions: -* -*******************************************************************************/ - -#ifdef CPRFLAG - -LOCAL(void) write_char ( - _TCHAR ch, - int *pnumwritten - ) -{ -#ifdef _UNICODE - if (_putwch_nolock(ch) == WEOF) -#else /* _UNICODE */ - if (_putch_nolock(ch) == EOF) -#endif /* _UNICODE */ - *pnumwritten = -1; - else - ++(*pnumwritten); -} - -#else /* CPRFLAG */ - -LOCAL(void) write_char ( - _TCHAR ch, - miniFILE *f, - int *pnumwritten - ) -{ - if ( (f->_flag & _IOSTRG) && f->_base == NULL) - { - ++(*pnumwritten); - return; - } -#ifdef _UNICODE - if (_putwc_nolock(ch, f) == WEOF) -#else /* _UNICODE */ - if (_putc_nolock(ch, f) == EOF) -#endif /* _UNICODE */ - *pnumwritten = -1; - else - ++(*pnumwritten); -} - -#endif /* CPRFLAG */ - -/*** -*void write_multi_char(char ch, int num, int *pnumwritten) -*ifdef _UNICODE -*void write_multi_char(char16_t ch, int num, FILE *f, int *pnumwritten) -*endif -*void write_multi_char(char ch, int num, FILE *f, int *pnumwritten) -* -*Purpose: -* Writes num copies of a character to the given file/console. If no error occurs, -* then *pnumwritten is incremented by num; otherwise, *pnumwritten is set -* to -1. If num is negative, it is treated as zero. -* -*Entry: -* _TCHAR ch - character to write -* int num - number of times to write the characters -* FILE *f - file to write to -* int *pnumwritten - pointer to integer to update with total chars written -* -*Exit: -* No return value. -* -*Exceptions: -* -*******************************************************************************/ - -#ifdef CPRFLAG -LOCAL(void) write_multi_char ( - _TCHAR ch, - int num, - int *pnumwritten - ) -{ - while (num-- > 0) { - write_char(ch, pnumwritten); - if (*pnumwritten == -1) - break; - } -} - -#else /* CPRFLAG */ - -LOCAL(void) write_multi_char ( - _TCHAR ch, - int num, - miniFILE *f, - int *pnumwritten - ) -{ - while (num-- > 0) { - write_char(ch, f, pnumwritten); - if (*pnumwritten == -1) - break; - } -} - -#endif /* CPRFLAG */ - -/*** -*void write_string(const char *string, int len, int *pnumwritten) -*void write_string(const char *string, int len, FILE *f, int *pnumwritten) -*ifdef _UNICODE -*void write_string(const char16_t *string, int len, FILE *f, int *pnumwritten) -*endif -* -*Purpose: -* Writes a string of the given length to the given file. If no error occurs, -* then *pnumwritten is incremented by len; otherwise, *pnumwritten is set -* to -1. If len is negative, it is treated as zero. -* -*Entry: -* _TCHAR *string - string to write (NOT null-terminated) -* int len - length of string -* FILE *f - file to write to -* int *pnumwritten - pointer to integer to update with total chars written -* -*Exit: -* No return value. -* -*Exceptions: -* -*******************************************************************************/ - -#ifdef CPRFLAG - -LOCAL(void) write_string ( - const _TCHAR *string, - int len, - int *pnumwritten - ) -{ - while (len-- > 0) { - write_char(*string++, pnumwritten); - if (*pnumwritten == -1) - { - if (errno == EILSEQ) - write_char(_T('?'), pnumwritten); - else - break; - } - } -} - -#else /* CPRFLAG */ - -LOCAL(void) write_string ( - const _TCHAR *string, - int len, - miniFILE *f, - int *pnumwritten - ) -{ - if ( (f->_flag & _IOSTRG) && f->_base == NULL) - { - (*pnumwritten) += len; - return; - } - while (len-- > 0) { - write_char(*string++, f, pnumwritten); - if (*pnumwritten == -1) - { - if (errno == EILSEQ) - write_char(_T('?'), f, pnumwritten); - else - break; - } - } -} -#endif /* CPRFLAG */ diff --git a/src/coreclr/pal/src/safecrt/safecrt_output_l.cpp b/src/coreclr/pal/src/safecrt/safecrt_output_l.cpp deleted file mode 100644 index b690336..0000000 --- a/src/coreclr/pal/src/safecrt/safecrt_output_l.cpp +++ /dev/null @@ -1,1466 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*** -*safecrt_output_l.c - implementation of the _output family for safercrt.lib -* - -* -*Purpose: -* This file contains the implementation of the _output family for safercrt.lib. -* -*Revision History: -* 07-08-04 SJ Stub module created. -* 07-13-04 AC Added support for floating-point types. -* 07-29-04 AC Added macros for a safecrt version of mctowc and wctomb, which target ntdll.dll or msvcrt.dll -* based on the _NTSUBSET_ #define -* 09-24-04 MSL Prefix disallow NULL deref -* -****/ - -#define _SAFECRT_IMPL - -#define __STDC_LIMIT_MACROS -#include "pal/palinternal.h" -#include -#include -#include -#include -#include -#include "internal_securecrt.h" - -#include "mbusafecrt_internal.h" - -#define _CFLTCVT _safecrt_cfltcvt - -//typedef __int64_t __int64; -typedef double _CRT_DOUBLE; -typedef char _TCHAR; -typedef char TCHAR; -#define _T(x) x -/* -Buffer size required to be passed to _gcvt, fcvt and other fp conversion routines -*/ -#define _CVTBUFSIZE (309+40) /* # of digits in max. dp value + slop */ - -//------------------------------------------------------------------------------ -// This code was taken from the 'output.c' file located in Visual Studio 8 (i.e. 2005) -// in the '\Microsoft Visual Studio 8\VC\crt\src' directory. It was moved into -// this file to support only the '_output' function used by _vscprintf() in vsprintf.c -// UNUSED / NON-RELEVANT PORTIONS OF THE CODE HAVE BEEN REMOVED - do not try and -// use it to generate any other safecrt 'output' functions -// -// Noteable modifications -// - changed FILE to miniFILE (defined in mbusafecrt_internal.h) -// - removed _soutput_s - it was unused in this case and conflicted with output.inl -// - changed #define SHORT_IS_INT to true varargs promotes shorts to ints in GCC -// - removed definition of __lookuptable_s when using FORMAT_VALIDATIONS, we don't use them - -// 7/03/07 - Created by Stephen Shaw (steshaw) -//------------------------------------------------------------------------------ - - -/* temporary work-around for compiler without 64-bit support */ -#ifndef _INTEGRAL_MAX_BITS -#define _INTEGRAL_MAX_BITS 64 -#endif /* _INTEGRAL_MAX_BITS */ - -#include -#include -#include -#include -#include -#include -#include - -#define _MBTOWC(x,y,z) _minimal_chartowchar( x, y ) - -#undef _malloc_crt -#define _malloc_crt malloc - -#undef _free_crt -#define _free_crt free - -// SNIP -srs 7/3/07 - -#ifndef _CFLTCVT -#define _CFLTCVT _cfltcvt -#endif /* _CFLTCVT */ - -#ifndef _CLDCVT -#define _CLDCVT _cldcvt -#endif /* _CLDCVT */ - -/* this macro defines a function which is private and as fast as possible: */ -/* for example, in C 6.0, it might be static _fastcall near. */ -#define LOCAL(x) static x __cdecl - -/* int/long/short/pointer sizes */ - -/* the following should be set depending on the sizes of various types */ -#if __LP64__ - #define LONG_IS_INT 0 - CASSERT(sizeof(long) > sizeof(int)); -#else - #define LONG_IS_INT 1 /* 1 means long is same size as int */ - CASSERT(sizeof(long) == sizeof(int)); -#endif - -// GCC: short is not int, but GCC promotes va_arg to int -#define SHORT_IS_INT 1 - -#define LONGLONG_IS_INT64 1 /* 1 means long long is same as int64 */ - CASSERT(sizeof(long long) == sizeof(int64_t)); - -#if defined (HOST_64BIT) - #define PTR_IS_INT 0 /* 1 means ptr is same size as int */ - CASSERT(sizeof(void *) != sizeof(int)); - #if __LP64__ - #define PTR_IS_LONG 1 /* 1 means ptr is same size as long */ - CASSERT(sizeof(void *) == sizeof(long)); - #else - #define PTR_IS_LONG 0 /* 1 means ptr is same size as long */ - CASSERT(sizeof(void *) != sizeof(long)); - #endif - #define PTR_IS_INT64 1 /* 1 means ptr is same size as int64 */ - CASSERT(sizeof(void *) == sizeof(int64_t)); -#else /* defined (HOST_64BIT) */ - #define PTR_IS_INT 1 /* 1 means ptr is same size as int */ - CASSERT(sizeof(void *) == sizeof(int)); - #define PTR_IS_LONG 1 /* 1 means ptr is same size as long */ - CASSERT(sizeof(void *) == sizeof(long)); - #define PTR_IS_INT64 0 /* 1 means ptr is same size as int64 */ - CASSERT(sizeof(void *) != sizeof(int64_t)); -#endif /* defined (HOST_64BIT) */ - -/* CONSTANTS */ - -/* size of conversion buffer (ANSI-specified minimum is 509) */ - -#define BUFFERSIZE 512 -#define MAXPRECISION BUFFERSIZE - -#if BUFFERSIZE < _CVTBUFSIZE + 6 -/* - * Buffer needs to be big enough for default minimum precision - * when converting floating point needs bigger buffer, and malloc - * fails - */ -#error Conversion buffer too small for max double. -#endif /* BUFFERSIZE < _CVTBUFSIZE + 6 */ - -/* flag definitions */ -#define FL_SIGN 0x00001 /* put plus or minus in front */ -#define FL_SIGNSP 0x00002 /* put space or minus in front */ -#define FL_LEFT 0x00004 /* left justify */ -#define FL_LEADZERO 0x00008 /* pad with leading zeros */ -#define FL_LONG 0x00010 /* long value given */ -#define FL_SHORT 0x00020 /* short value given */ -#define FL_SIGNED 0x00040 /* signed data given */ -#define FL_ALTERNATE 0x00080 /* alternate form requested */ -#define FL_NEGATIVE 0x00100 /* value is negative */ -#define FL_FORCEOCTAL 0x00200 /* force leading '0' for octals */ -#define FL_LONGDOUBLE 0x00400 /* long double value given */ -#define FL_WIDECHAR 0x00800 /* wide characters */ -#define FL_LONGLONG 0x01000 /* long long value given */ -#define FL_I64 0x08000 /* __int64 value given */ - -/* state definitions */ -enum STATE { - ST_NORMAL, /* normal state; outputting literal chars */ - ST_PERCENT, /* just read '%' */ - ST_FLAG, /* just read flag character */ - ST_WIDTH, /* just read width specifier */ - ST_DOT, /* just read '.' */ - ST_PRECIS, /* just read precision specifier */ - ST_SIZE, /* just read size specifier */ - ST_TYPE /* just read type specifier */ -#ifdef FORMAT_VALIDATIONS - ,ST_INVALID /* Invalid format */ -#endif /* FORMAT_VALIDATIONS */ - -}; - -#ifdef FORMAT_VALIDATIONS -#define NUMSTATES (ST_INVALID + 1) -#else /* FORMAT_VALIDATIONS */ -#define NUMSTATES (ST_TYPE + 1) -#endif /* FORMAT_VALIDATIONS */ - -/* character type values */ -enum CHARTYPE { - CH_OTHER, /* character with no special meaning */ - CH_PERCENT, /* '%' */ - CH_DOT, /* '.' */ - CH_STAR, /* '*' */ - CH_ZERO, /* '0' */ - CH_DIGIT, /* '1'..'9' */ - CH_FLAG, /* ' ', '+', '-', '#' */ - CH_SIZE, /* 'h', 'l', 'L', 'N', 'F', 'w' */ - CH_TYPE /* type specifying character */ -}; - -/* static data (read only, since we are re-entrant) */ -#if defined (_UNICODE) || defined (CPRFLAG) || defined (FORMAT_VALIDATIONS) -extern const char __nullstring[]; /* string to print on null ptr */ -extern const char16_t __wnullstring[]; /* string to print on null ptr */ -#else /* defined (_UNICODE) || defined (CPRFLAG) || defined (FORMAT_VALIDATIONS) */ -static const char __nullstring[] = "(null)"; /* string to print on null ptr */ -static const char16_t __wnullstring[] = { '(', 'n', 'u', 'l', 'l', ')', '\0' };/* string to print on null ptr */ -#endif /* defined (_UNICODE) || defined (CPRFLAG) || defined (FORMAT_VALIDATIONS) */ - -/* The state table. This table is actually two tables combined into one. */ -/* The lower nybble of each byte gives the character class of any */ -/* character; while the uper nybble of the byte gives the next state */ -/* to enter. See the macros below the table for details. */ -/* */ -/* The table is generated by maketabc.c -- use this program to make */ -/* changes. */ - -#ifndef FORMAT_VALIDATIONS -#if defined (_UNICODE) || defined (CPRFLAG) -extern const char __lookuptable[]; -#else /* defined (_UNICODE) || defined (CPRFLAG) */ -//extern const char __lookuptable[] = { -const char __lookuptable[] = { - /* ' ' */ 0x06, - /* '!' */ 0x00, - /* '"' */ 0x00, - /* '#' */ 0x06, - /* '$' */ 0x00, - /* '%' */ 0x01, - /* '&' */ 0x00, - /* ''' */ 0x00, - /* '(' */ 0x10, - /* ')' */ 0x00, - /* '*' */ 0x03, - /* '+' */ 0x06, - /* ',' */ 0x00, - /* '-' */ 0x06, - /* '.' */ 0x02, - /* '/' */ 0x10, - /* '0' */ 0x04, - /* '1' */ 0x45, - /* '2' */ 0x45, - /* '3' */ 0x45, - /* '4' */ 0x05, - /* '5' */ 0x05, - /* '6' */ 0x05, - /* '7' */ 0x05, - /* '8' */ 0x05, - /* '9' */ 0x35, - /* ':' */ 0x30, - /* ';' */ 0x00, - /* '<' */ 0x50, - /* '=' */ 0x00, - /* '>' */ 0x00, - /* '?' */ 0x00, - /* '@' */ 0x00, - /* 'A' */ 0x20, // Disable %A format - /* 'B' */ 0x20, - /* 'C' */ 0x38, - /* 'D' */ 0x50, - /* 'E' */ 0x58, - /* 'F' */ 0x07, - /* 'G' */ 0x08, - /* 'H' */ 0x00, - /* 'I' */ 0x37, - /* 'J' */ 0x30, - /* 'K' */ 0x30, - /* 'L' */ 0x57, - /* 'M' */ 0x50, - /* 'N' */ 0x07, - /* 'O' */ 0x00, - /* 'P' */ 0x00, - /* 'Q' */ 0x20, - /* 'R' */ 0x20, - /* 'S' */ 0x08, - /* 'T' */ 0x00, - /* 'U' */ 0x00, - /* 'V' */ 0x00, - /* 'W' */ 0x00, - /* 'X' */ 0x08, - /* 'Y' */ 0x60, - /* 'Z' */ 0x68, - /* '[' */ 0x60, - /* '\' */ 0x60, - /* ']' */ 0x60, - /* '^' */ 0x60, - /* '_' */ 0x00, - /* '`' */ 0x00, - /* 'a' */ 0x70, // Disable %a format - /* 'b' */ 0x70, - /* 'c' */ 0x78, - /* 'd' */ 0x78, - /* 'e' */ 0x78, - /* 'f' */ 0x78, - /* 'g' */ 0x08, - /* 'h' */ 0x07, - /* 'i' */ 0x08, - /* 'j' */ 0x00, - /* 'k' */ 0x00, - /* 'l' */ 0x07, - /* 'm' */ 0x00, - /* 'n' */ 0x00, // Disable %n format - /* 'o' */ 0x08, - /* 'p' */ 0x08, - /* 'q' */ 0x00, - /* 'r' */ 0x00, - /* 's' */ 0x08, - /* 't' */ 0x00, - /* 'u' */ 0x08, - /* 'v' */ 0x00, - /* 'w' */ 0x07, - /* 'x' */ 0x08, - /* 'y' */ 0x00, - /* 'z' */ 0x37 -}; - -#endif /* defined (_UNICODE) || defined (CPRFLAG) */ - -#else /* FORMAT_VALIDATIONS */ -// SNIP -srs 7/3/07 -#error code has been removed -#endif /* FORMAT_VALIDATIONS */ - -#define FIND_CHAR_CLASS(lookuptbl, c) \ - ((c) < _T(' ') || (c) > _T('z') ? \ - CH_OTHER \ - : \ - (enum CHARTYPE)(lookuptbl[(c)-_T(' ')] & 0xF)) - -#define FIND_NEXT_STATE(lookuptbl, class, state) \ - (enum STATE)(lookuptbl[(class) * NUMSTATES + (state)] >> 4) - -/* - * Note: CPRFLAG and _UNICODE cases are currently mutually exclusive. - */ - -/* prototypes */ - -#ifdef CPRFLAG - -#define WRITE_CHAR(ch, pnw) write_char(ch, pnw) -#define WRITE_MULTI_CHAR(ch, num, pnw) write_multi_char(ch, num, pnw) -#define WRITE_STRING(s, len, pnw) write_string(s, len, pnw) -#define WRITE_WSTRING(s, len, pnw) write_wstring(s, len, pnw) - -LOCAL(void) write_char(_TCHAR ch, int *pnumwritten); -LOCAL(void) write_multi_char(_TCHAR ch, int num, int *pnumwritten); -LOCAL(void) write_string(const _TCHAR *string, int len, int *numwritten); -LOCAL(void) write_wstring(const char16_t *string, int len, int *numwritten); - -#else /* CPRFLAG */ - -#define WRITE_CHAR(ch, pnw) write_char(ch, stream, pnw) -#define WRITE_MULTI_CHAR(ch, num, pnw) write_multi_char(ch, num, stream, pnw) -#define WRITE_STRING(s, len, pnw) write_string(s, len, stream, pnw) -#define WRITE_WSTRING(s, len, pnw) write_wstring(s, len, stream, pnw) - -LOCAL(void) write_char(_TCHAR ch, miniFILE *f, int *pnumwritten); -LOCAL(void) write_multi_char(_TCHAR ch, int num, miniFILE *f, int *pnumwritten); -LOCAL(void) write_string(const _TCHAR *string, int len, miniFILE *f, int *numwritten); -//LOCAL(void) write_wstring(const char16_t *string, int len, miniFILE *f, int *numwritten); - -#endif /* CPRFLAG */ - -#define get_short_arg(list) va_arg(*list, int) // GCC promotes va_arg shorts into int values -#define get_int_arg(list) va_arg(*list, int) -#define get_long_arg(list) va_arg(*list, long) -#define get_long_long_arg(list) va_arg(*list, long long) -#define get_int64_arg(list) va_arg(*list, __int64) -#define get_crtdouble_arg(list) va_arg(*list, _CRT_DOUBLE) -#define get_ptr_arg(list) va_arg(*list, void *) - -#ifdef CPRFLAG -LOCAL(int) output(const _TCHAR *, _locale_t , va_list); -_CRTIMP int __cdecl _vtcprintf_l (const _TCHAR *, _locale_t, va_list); -_CRTIMP int __cdecl _vtcprintf_s_l (const _TCHAR *, _locale_t, va_list); -_CRTIMP int __cdecl _vtcprintf_p_l (const _TCHAR *, _locale_t, va_list); - - -/*** -*int _cprintf(format, arglist) - write formatted output directly to console -* -*Purpose: -* Writes formatted data like printf, but uses console I/O functions. -* -*Entry: -* char *format - format string to determine data formats -* arglist - list of POINTERS to where to put data -* -*Exit: -* returns number of characters written -* -*Exceptions: -* -*******************************************************************************/ -#ifndef FORMAT_VALIDATIONS -_CRTIMP int __cdecl _tcprintf_l ( - const _TCHAR * format, - _locale_t plocinfo, - ... - ) -#else /* FORMAT_VALIDATIONS */ -_CRTIMP int __cdecl _tcprintf_s_l ( - const _TCHAR * format, - _locale_t plocinfo, - ... - ) -#endif /* FORMAT_VALIDATIONS */ - -{ - int ret; - va_list arglist; - va_start(arglist, plocinfo); - -#ifndef FORMAT_VALIDATIONS - ret = _vtcprintf_l(format, plocinfo, arglist); -#else /* FORMAT_VALIDATIONS */ - ret = _vtcprintf_s_l(format, plocinfo, arglist); - -#endif /* FORMAT_VALIDATIONS */ - - va_end(arglist); - - return ret; -} - -#ifndef FORMAT_VALIDATIONS -_CRTIMP int __cdecl _tcprintf ( - const _TCHAR * format, - ... - ) -#else /* FORMAT_VALIDATIONS */ -_CRTIMP int __cdecl _tcprintf_s ( - const _TCHAR * format, - ... - ) -#endif /* FORMAT_VALIDATIONS */ - -{ - int ret; - va_list arglist; - - va_start(arglist, format); - -#ifndef FORMAT_VALIDATIONS - ret = _vtcprintf_l(format, NULL, arglist); -#else /* FORMAT_VALIDATIONS */ - ret = _vtcprintf_s_l(format, NULL, arglist); - -#endif /* FORMAT_VALIDATIONS */ - - va_end(arglist); - - return ret; -} - -#endif /* CPRFLAG */ - - -/*** -*int _output(stream, format, argptr), static int output(format, argptr) -* -*Purpose: -* Output performs printf style output onto a stream. It is called by -* printf/fprintf/sprintf/vprintf/vfprintf/vsprintf to so the dirty -* work. In multi-thread situations, _output assumes that the given -* stream is already locked. -* -* Algorithm: -* The format string is parsed by using a finite state automaton -* based on the current state and the current character read from -* the format string. Thus, looping is on a per-character basis, -* not a per conversion specifier basis. Once the format specififying -* character is read, output is performed. -* -*Entry: -* FILE *stream - stream for output -* char *format - printf style format string -* va_list argptr - pointer to list of subsidiary arguments -* -*Exit: -* Returns the number of characters written, or -1 if an output error -* occurs. -*ifdef _UNICODE -* The wide-character flavour returns the number of wide-characters written. -*endif -* -*Exceptions: -* -*******************************************************************************/ -#ifdef CPRFLAG -#ifndef FORMAT_VALIDATIONS -_CRTIMP int __cdecl _vtcprintf ( - const _TCHAR *format, - va_list argptr - ) -{ - return _vtcprintf_l(format, NULL, argptr); -} - -#else /* FORMAT_VALIDATIONS */ -_CRTIMP int __cdecl _vtcprintf_s ( - const _TCHAR *format, - va_list argptr - ) -{ - return _vtcprintf_s_l(format, NULL, argptr); -} - -#endif /* FORMAT_VALIDATIONS */ -#endif /* CPRFLAG */ - -#ifdef CPRFLAG -#ifndef FORMAT_VALIDATIONS -_CRTIMP int __cdecl _vtcprintf_l ( -#else /* FORMAT_VALIDATIONS */ -_CRTIMP int __cdecl _vtcprintf_s_l ( -#endif /* FORMAT_VALIDATIONS */ -#else /* CPRFLAG */ - -#ifdef _UNICODE -#ifndef FORMAT_VALIDATIONS -int __cdecl _woutput ( - miniFILE *stream, -#else /* FORMAT_VALIDATIONS */ -int __cdecl _woutput_s ( - miniFILE *stream, -#endif /* FORMAT_VALIDATIONS */ -#else /* _UNICODE */ -#ifndef FORMAT_VALIDATIONS -int __cdecl _output ( - miniFILE *stream, -#else /* FORMAT_VALIDATIONS */ - int __cdecl _output_s ( - miniFILE *stream, - -#endif /* FORMAT_VALIDATIONS */ -#endif /* _UNICODE */ - -#endif /* CPRFLAG */ - const _TCHAR *format, - va_list argptr - ) -{ - int hexadd=0; /* offset to add to number to get 'a'..'f' */ - TCHAR ch; /* character just read */ - int flags=0; /* flag word -- see #defines above for flag values */ - enum STATE state; /* current state */ - enum CHARTYPE chclass; /* class of current character */ - int radix; /* current conversion radix */ - int charsout; /* characters currently written so far, -1 = IO error */ - int fldwidth = 0; /* selected field width -- 0 means default */ - int precision = 0; /* selected precision -- -1 means default */ - TCHAR prefix[2]; /* numeric prefix -- up to two characters */ - int prefixlen=0; /* length of prefix -- 0 means no prefix */ - int capexp = 0; /* non-zero = 'E' exponent signifient, zero = 'e' */ - int no_output=0; /* non-zero = prodcue no output for this specifier */ - union { - const char *sz; /* pointer text to be printed, not zero terminated */ - const char16_t *wz; - } text; - - int textlen; /* length of the text in bytes/wchars to be printed. - textlen is in multibyte or wide chars if _UNICODE */ - union { - char sz[BUFFERSIZE]; -#ifdef _UNICODE - char16_t wz[BUFFERSIZE]; -#endif /* _UNICODE */ - } buffer; - char16_t wchar; /* temp char16_t */ - int buffersize; /* size of text.sz (used only for the call to _cfltcvt) */ - int bufferiswide=0; /* non-zero = buffer contains wide chars already */ - -#ifndef CPRFLAG - _VALIDATE_RETURN( (stream != NULL), EINVAL, -1); -#endif /* CPRFLAG */ - _VALIDATE_RETURN( (format != NULL), EINVAL, -1); - - charsout = 0; /* no characters written yet */ - textlen = 0; /* no text yet */ - state = ST_NORMAL; /* starting state */ - buffersize = 0; - - /* main loop -- loop while format character exist and no I/O errors */ - while ((ch = *format++) != _T('\0') && charsout >= 0) { -#ifndef FORMAT_VALIDATIONS - chclass = FIND_CHAR_CLASS(__lookuptable, ch); /* find character class */ - state = FIND_NEXT_STATE(__lookuptable, chclass, state); /* find next state */ -#else /* FORMAT_VALIDATIONS */ - chclass = FIND_CHAR_CLASS(__lookuptable_s, ch); /* find character class */ - state = FIND_NEXT_STATE(__lookuptable_s, chclass, state); /* find next state */ - - _VALIDATE_RETURN((state != ST_INVALID), EINVAL, -1); - -#endif /* FORMAT_VALIDATIONS */ - - /* execute code for each state */ - switch (state) { - - case ST_NORMAL: - - NORMAL_STATE: - - /* normal state -- just write character */ -#ifdef _UNICODE - bufferiswide = 1; -#else /* _UNICODE */ - bufferiswide = 0; -#endif /* _UNICODE */ - WRITE_CHAR(ch, &charsout); - break; - - case ST_PERCENT: - /* set default value of conversion parameters */ - prefixlen = fldwidth = no_output = capexp = 0; - flags = 0; - precision = -1; - bufferiswide = 0; /* default */ - break; - - case ST_FLAG: - /* set flag based on which flag character */ - switch (ch) { - case _T('-'): - flags |= FL_LEFT; /* '-' => left justify */ - break; - case _T('+'): - flags |= FL_SIGN; /* '+' => force sign indicator */ - break; - case _T(' '): - flags |= FL_SIGNSP; /* ' ' => force sign or space */ - break; - case _T('#'): - flags |= FL_ALTERNATE; /* '#' => alternate form */ - break; - case _T('0'): - flags |= FL_LEADZERO; /* '0' => pad with leading zeros */ - break; - } - break; - - case ST_WIDTH: - /* update width value */ - if (ch == _T('*')) { - /* get width from arg list */ - fldwidth = get_int_arg(&argptr); - if (fldwidth < 0) { - /* ANSI says neg fld width means '-' flag and pos width */ - flags |= FL_LEFT; - fldwidth = -fldwidth; - } - } - else { - /* add digit to current field width */ - fldwidth = fldwidth * 10 + (ch - _T('0')); - } - break; - - case ST_DOT: - /* zero the precision, since dot with no number means 0 - not default, according to ANSI */ - precision = 0; - break; - - case ST_PRECIS: - /* update precision value */ - if (ch == _T('*')) { - /* get precision from arg list */ - precision = get_int_arg(&argptr); - if (precision < 0) - precision = -1; /* neg precision means default */ - } - else { - /* add digit to current precision */ - precision = precision * 10 + (ch - _T('0')); - } - break; - - case ST_SIZE: - /* just read a size specifier, set the flags based on it */ - switch (ch) { - case _T('l'): - /* - * In order to handle the ll case, we depart from the - * simple deterministic state machine. - */ - if (*format == _T('l')) - { - ++format; - flags |= FL_LONGLONG; /* 'll' => long long */ - } - else - { - flags |= FL_LONG; /* 'l' => long int or char16_t */ - } - break; - - case _T('z'): - case _T('I'): - /* - * In order to handle the I, I32, and I64 size modifiers, we - * depart from the simple deterministic state machine. The - * code below scans for characters following the 'I', - * and defaults to 64 bit on WIN64 and 32 bit on WIN32 - */ -#if PTR_IS_INT64 - flags |= FL_I64; /* 'I' => __int64 on WIN64 systems */ -#endif /* PTR_IS_INT64 */ - if ( (*format == _T('6')) && (*(format + 1) == _T('4')) ) - { - format += 2; - flags |= FL_I64; /* I64 => __int64 */ - } - else if ( (*format == _T('3')) && (*(format + 1) == _T('2')) ) - { - format += 2; - flags &= ~FL_I64; /* I32 => __int32 */ - } - else if ( (*format == _T('d')) || - (*format == _T('i')) || - (*format == _T('o')) || - (*format == _T('u')) || - (*format == _T('x')) || - (*format == _T('X')) ) - { - /* - * Nothing further needed. %Id (et al) is - * handled just like %d, except that it defaults to 64 bits - * on WIN64. Fall through to the next iteration. - */ - } - else { - state = ST_NORMAL; - goto NORMAL_STATE; - } - break; - - case _T('h'): - flags |= FL_SHORT; /* 'h' => short int or char */ - break; - - case _T('w'): - flags |= FL_WIDECHAR; /* 'w' => wide character */ - break; - - } - break; - - case ST_TYPE: - /* we have finally read the actual type character, so we */ - /* now format and "print" the output. We use a big switch */ - /* statement that sets 'text' to point to the text that should */ - /* be printed, and 'textlen' to the length of this text. */ - /* Common code later on takes care of justifying it and */ - /* other miscellaneous chores. Note that cases share code, */ - /* in particular, all integer formatting is done in one place. */ - /* Look at those funky goto statements! */ - - switch (ch) { - - case _T('C'): /* ISO wide character */ - if (!(flags & (FL_SHORT|FL_LONG|FL_WIDECHAR))) -#ifdef _UNICODE - flags |= FL_SHORT; -#else /* _UNICODE */ - flags |= FL_WIDECHAR; /* ISO std. */ -#endif /* _UNICODE */ - /* fall into 'c' case */ - FALLTHROUGH; - case _T('c'): { - /* print a single character specified by int argument */ -#ifdef _UNICODE - bufferiswide = 1; - wchar = (char16_t) get_int_arg(&argptr); - if (flags & FL_SHORT) { - /* format multibyte character */ - /* this is an extension of ANSI */ - char tempchar[2]; - { - tempchar[0] = (char)(wchar & 0x00ff); - tempchar[1] = '\0'; - } - - if (_MBTOWC(buffer.wz,tempchar, MB_CUR_MAX) < 0) - { - /* ignore if conversion was unsuccessful */ - no_output = 1; - } - } else { - buffer.wz[0] = wchar; - } - text.wz = buffer.wz; - textlen = 1; /* print just a single character */ -#else /* _UNICODE */ - if (flags & (FL_LONG|FL_WIDECHAR)) { - wchar = (char16_t) get_short_arg(&argptr); - no_output = 1; - } else { - /* format multibyte character */ - /* this is an extension of ANSI */ - unsigned short temp; - wchar = (char16_t)get_int_arg(&argptr); - temp = (unsigned short)wchar; - { - buffer.sz[0] = (char) temp; - textlen = 1; - } - } - text.sz = buffer.sz; -#endif /* _UNICODE */ - } - break; - - case _T('Z'): { - /* print a Counted String */ - struct _count_string { - short Length; - short MaximumLength; - char *Buffer; - } *pstr; - - pstr = (struct _count_string *)get_ptr_arg(&argptr); - if (pstr == NULL || pstr->Buffer == NULL) { - /* null ptr passed, use special string */ - text.sz = __nullstring; - textlen = (int)strlen(text.sz); - } else { - if (flags & FL_WIDECHAR) { - text.wz = (char16_t *)pstr->Buffer; - textlen = pstr->Length / (int)sizeof(char16_t); - bufferiswide = 1; - } else { - bufferiswide = 0; - text.sz = pstr->Buffer; - textlen = pstr->Length; - } - } - } - break; - - case _T('S'): /* ISO wide character string */ -#ifndef _UNICODE - if (!(flags & (FL_SHORT|FL_LONG|FL_WIDECHAR))) - flags |= FL_WIDECHAR; -#else /* _UNICODE */ - if (!(flags & (FL_SHORT|FL_LONG|FL_WIDECHAR))) - flags |= FL_SHORT; -#endif /* _UNICODE */ - FALLTHROUGH; - - case _T('s'): { - /* print a string -- */ - /* ANSI rules on how much of string to print: */ - /* all if precision is default, */ - /* min(precision, length) if precision given. */ - /* prints '(null)' if a null string is passed */ - - int i; - const char *p; /* temps */ - const char16_t *pwch; - - /* At this point it is tempting to use strlen(), but */ - /* if a precision is specified, we're not allowed to */ - /* scan past there, because there might be no null */ - /* at all. Thus, we must do our own scan. */ - - i = (precision == -1) ? INT_MAX : precision; - text.sz = (char *)get_ptr_arg(&argptr); - - /* scan for null upto i characters */ -#ifdef _UNICODE - if (flags & FL_SHORT) { - if (text.sz == NULL) /* NULL passed, use special string */ - text.sz = __nullstring; - p = text.sz; - for (textlen=0; textlen MAXPRECISION) - precision = MAXPRECISION; - - if (precision > BUFFERSIZE - _CVTBUFSIZE) { - precision = BUFFERSIZE - _CVTBUFSIZE; - } - - /* for safecrt, we pass along the FL_ALTERNATE flag to _safecrt_cfltcvt */ - if (flags & FL_ALTERNATE) - { - capexp |= FL_ALTERNATE; - } - - _CRT_DOUBLE tmp; - tmp=va_arg(argptr, _CRT_DOUBLE); - /* Note: assumes ch is in ASCII range */ - /* In safecrt, we provide a special version of _cfltcvt which internally calls printf (see safecrt_output_s.c) */ - _CFLTCVT(&tmp, buffer.sz, buffersize, (char)ch, precision, capexp); - - /* check if result was negative, save '-' for later */ - /* and point to positive part (this is for '0' padding) */ - if (*text.sz == '-') { - flags |= FL_NEGATIVE; - ++text.sz; - } - - textlen = (int)strlen(text.sz); /* compute length of text */ - } - break; - - case _T('d'): - case _T('i'): - /* signed decimal output */ - flags |= FL_SIGNED; - radix = 10; - goto COMMON_INT; - - case _T('u'): - radix = 10; - goto COMMON_INT; - - case _T('p'): - /* write a pointer -- this is like an integer or long */ - /* except we force precision to pad with zeros and */ - /* output in big hex. */ - - precision = 2 * sizeof(void *); /* number of hex digits needed */ -#if PTR_IS_INT64 - 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 */ - /* DROP THROUGH to hex formatting */ - FALLTHROUGH; - - case _T('X'): - /* unsigned upper hex output */ - hexadd = _T('A') - _T('9') - 1; /* set hexadd for uppercase hex */ - goto COMMON_HEX; - - case _T('x'): - /* unsigned lower hex output */ - hexadd = _T('a') - _T('9') - 1; /* set hexadd for lowercase hex */ - /* DROP THROUGH TO COMMON_HEX */ - - COMMON_HEX: - radix = 16; - if (flags & FL_ALTERNATE) { - /* alternate form means '0x' prefix */ - prefix[0] = _T('0'); - prefix[1] = (TCHAR)(_T('x') - _T('a') + _T('9') + 1 + hexadd); /* 'x' or 'X' */ - prefixlen = 2; - } - goto COMMON_INT; - - case _T('o'): - /* unsigned octal output */ - radix = 8; - if (flags & FL_ALTERNATE) { - /* alternate form means force a leading 0 */ - flags |= FL_FORCEOCTAL; - } - /* DROP THROUGH to COMMON_INT */ - - COMMON_INT: { - /* This is the general integer formatting routine. */ - /* Basically, we get an argument, make it positive */ - /* if necessary, and convert it according to the */ - /* correct radix, setting text and textlen */ - /* appropriately. */ - -#if _INTEGRAL_MAX_BITS >= 64 -// unsigned __int64 number; /* number to convert */ - uint64_t number; /* number to convert */ - int digit; /* ascii value of digit */ - __int64 l; /* temp long value */ -#else /* _INTEGRAL_MAX_BITS >= 64 */ - unsigned long number; /* number to convert */ - int digit; /* ascii value of digit */ - long l; /* temp long value */ -#endif /* _INTEGRAL_MAX_BITS >= 64 */ - - /* 1. read argument into l, sign extend as needed */ -#if _INTEGRAL_MAX_BITS >= 64 - if (flags & FL_I64) - l = get_int64_arg(&argptr); - else -#endif /* _INTEGRAL_MAX_BITS >= 64 */ - - if (flags & FL_LONGLONG) - l = get_long_long_arg(&argptr); - else - -#if !LONG_IS_INT - if (flags & FL_LONG) - l = get_long_arg(&argptr); - else -#endif /* !LONG_IS_INT */ - -#if !SHORT_IS_INT - if (flags & FL_SHORT) { - if (flags & FL_SIGNED) - l = (short) get_int_arg(&argptr); /* sign extend */ - else - l = (unsigned short) get_int_arg(&argptr); /* zero-extend*/ - - } else -#endif /* !SHORT_IS_INT */ - { - if (flags & FL_SIGNED) - l = get_int_arg(&argptr); /* sign extend */ - else - l = (unsigned int) get_int_arg(&argptr); /* zero-extend*/ - - } - - /* 2. check for negative; copy into number */ - if ( (flags & FL_SIGNED) && l < 0) { - number = -l; - flags |= FL_NEGATIVE; /* remember negative sign */ - } else { - number = l; - } - -#if _INTEGRAL_MAX_BITS >= 64 - if ( (flags & FL_I64) == 0 && (flags & FL_LONGLONG) == 0 ) { - /* - * Unless printing a full 64-bit value, insure values - * here are not in cananical longword format to prevent - * the sign extended upper 32-bits from being printed. - */ - number &= 0xffffffff; - } -#endif /* _INTEGRAL_MAX_BITS >= 64 */ - - /* 3. check precision value for default; non-default */ - /* turns off 0 flag, according to ANSI. */ - if (precision < 0) - precision = 1; /* default precision */ - else { - flags &= ~FL_LEADZERO; - if (precision > MAXPRECISION) - precision = MAXPRECISION; - } - - /* 4. Check if data is 0; if so, turn off hex prefix */ - if (number == 0) - prefixlen = 0; - - /* 5. Convert data to ASCII -- note if precision is zero */ - /* and number is zero, we get no digits at all. */ - - char *sz; - sz = &buffer.sz[BUFFERSIZE-1]; /* last digit at end of buffer */ - - while (precision-- > 0 || number != 0) { - digit = (int)(number % radix) + '0'; - number /= radix; /* reduce number */ - if (digit > '9') { - /* a hex digit, make it a letter */ - digit += hexadd; - } - *sz-- = (char)digit; /* store the digit */ - } - - textlen = (int)((char *)&buffer.sz[BUFFERSIZE-1] - sz); /* compute length of number */ - ++sz; /* text points to first digit now */ - - - /* 6. Force a leading zero if FORCEOCTAL flag set */ - if ((flags & FL_FORCEOCTAL) && (textlen == 0 || sz[0] != '0')) { - *--sz = '0'; - ++textlen; /* add a zero */ - } - - text.sz = sz; - } - break; - } - - - /* At this point, we have done the specific conversion, and */ - /* 'text' points to text to print; 'textlen' is length. Now we */ - /* justify it, put on prefixes, leading zeros, and then */ - /* print it. */ - - if (!no_output) { - int padding; /* amount of padding, negative means zero */ - - if (flags & FL_SIGNED) { - if (flags & FL_NEGATIVE) { - /* prefix is a '-' */ - prefix[0] = _T('-'); - prefixlen = 1; - } - else if (flags & FL_SIGN) { - /* prefix is '+' */ - prefix[0] = _T('+'); - prefixlen = 1; - } - else if (flags & FL_SIGNSP) { - /* prefix is ' ' */ - prefix[0] = _T(' '); - prefixlen = 1; - } - } - - /* calculate amount of padding -- might be negative, */ - /* but this will just mean zero */ - padding = fldwidth - textlen - prefixlen; - - /* put out the padding, prefix, and text, in the correct order */ - - if (!(flags & (FL_LEFT | FL_LEADZERO))) { - /* pad on left with blanks */ - WRITE_MULTI_CHAR(_T(' '), padding, &charsout); - } - - /* write prefix */ - WRITE_STRING(prefix, prefixlen, &charsout); - - if ((flags & FL_LEADZERO) && !(flags & FL_LEFT)) { - /* write leading zeros */ - WRITE_MULTI_CHAR(_T('0'), padding, &charsout); - } - - /* write text */ -#ifndef _UNICODE - if (bufferiswide && (textlen > 0)) { - charsout = -1; - } else { - WRITE_STRING(text.sz, textlen, &charsout); - } -#else /* _UNICODE */ - if (!bufferiswide && textlen > 0) { - char *p; - int retval = 0 - int count; - - p = text.sz; - count = textlen; - while (count-- > 0) { - retval = _MBTOWC(&wchar, p, MB_CUR_MAX); - if (retval <= 0) { - charsout = -1; - break; - } - WRITE_CHAR(wchar, &charsout); - p += retval; - } - } else { - WRITE_STRING(text.wz, textlen, &charsout); - } -#endif /* _UNICODE */ - - if (charsout >= 0 && (flags & FL_LEFT)) { - /* pad on right with blanks */ - WRITE_MULTI_CHAR(_T(' '), padding, &charsout); - } - - /* we're done! */ - } - break; - } - } - -#ifdef FORMAT_VALIDATIONS - /* The format string shouldn't be incomplete - i.e. when we are finished - with the format string, the last thing we should have encountered - should have been a regular char to be output or a type specifier. Else - the format string was incomplete */ - _VALIDATE_RETURN(((state == ST_NORMAL) || (state == ST_TYPE)), EINVAL, -1); -#endif /* FORMAT_VALIDATIONS */ - - return charsout; /* return value = number of characters written */ -} - -/* - * Future Optimizations for swprintf: - * - Don't free the memory used for converting the buffer to wide chars. - * Use realloc if the memory is not sufficient. Free it at the end. - */ - -/*** -*void write_char(char ch, int *pnumwritten) -*ifdef _UNICODE -*void write_char(char16_t ch, FILE *f, int *pnumwritten) -*endif -*void write_char(char ch, FILE *f, int *pnumwritten) -* -*Purpose: -* Writes a single character to the given file/console. If no error occurs, -* then *pnumwritten is incremented; otherwise, *pnumwritten is set -* to -1. -* -*Entry: -* _TCHAR ch - character to write -* FILE *f - file to write to -* int *pnumwritten - pointer to integer to update with total chars written -* -*Exit: -* No return value. -* -*Exceptions: -* -*******************************************************************************/ - -#ifdef CPRFLAG - -LOCAL(void) write_char ( - _TCHAR ch, - int *pnumwritten - ) -{ -#ifdef _UNICODE - if (_putwch_nolock(ch) == WEOF) -#else /* _UNICODE */ - if (_putch_nolock(ch) == EOF) -#endif /* _UNICODE */ - *pnumwritten = -1; - else - ++(*pnumwritten); -} - -#else /* CPRFLAG */ - -LOCAL(void) write_char ( - _TCHAR ch, - miniFILE *f, - int *pnumwritten - ) -{ - if ( (f->_flag & _IOSTRG) && f->_base == NULL) - { - ++(*pnumwritten); - return; - } -#ifdef _UNICODE - if (_putwc_nolock(ch, f) == WEOF) -#else /* _UNICODE */ - if (_putc_nolock(ch, f) == EOF) -#endif /* _UNICODE */ - *pnumwritten = -1; - else - ++(*pnumwritten); -} - -#endif /* CPRFLAG */ - -/*** -*void write_multi_char(char ch, int num, int *pnumwritten) -*ifdef _UNICODE -*void write_multi_char(char16_t ch, int num, FILE *f, int *pnumwritten) -*endif -*void write_multi_char(char ch, int num, FILE *f, int *pnumwritten) -* -*Purpose: -* Writes num copies of a character to the given file/console. If no error occurs, -* then *pnumwritten is incremented by num; otherwise, *pnumwritten is set -* to -1. If num is negative, it is treated as zero. -* -*Entry: -* _TCHAR ch - character to write -* int num - number of times to write the characters -* FILE *f - file to write to -* int *pnumwritten - pointer to integer to update with total chars written -* -*Exit: -* No return value. -* -*Exceptions: -* -*******************************************************************************/ - -#ifdef CPRFLAG -LOCAL(void) write_multi_char ( - _TCHAR ch, - int num, - int *pnumwritten - ) -{ - while (num-- > 0) { - write_char(ch, pnumwritten); - if (*pnumwritten == -1) - break; - } -} - -#else /* CPRFLAG */ - -LOCAL(void) write_multi_char ( - _TCHAR ch, - int num, - miniFILE *f, - int *pnumwritten - ) -{ - while (num-- > 0) { - write_char(ch, f, pnumwritten); - if (*pnumwritten == -1) - break; - } -} - -#endif /* CPRFLAG */ - -/*** -*void write_string(const char *string, int len, int *pnumwritten) -*void write_string(const char *string, int len, FILE *f, int *pnumwritten) -*ifdef _UNICODE -*void write_string(const char16_t *string, int len, FILE *f, int *pnumwritten) -*endif -*void write_wstring(const char16_t *string, int len, int *pnumwritten) -*void write_wstring(const char16_t *string, int len, FILE *f, int *pnumwritten) -* -*Purpose: -* Writes a string of the given length to the given file. If no error occurs, -* then *pnumwritten is incremented by len; otherwise, *pnumwritten is set -* to -1. If len is negative, it is treated as zero. -* -*Entry: -* _TCHAR *string - string to write (NOT null-terminated) -* int len - length of string -* FILE *f - file to write to -* int *pnumwritten - pointer to integer to update with total chars written -* -*Exit: -* No return value. -* -*Exceptions: -* -*******************************************************************************/ - -#ifdef CPRFLAG - -LOCAL(void) write_string ( - const _TCHAR *string, - int len, - int *pnumwritten - ) -{ - while (len-- > 0) { - write_char(*string++, pnumwritten); - if (*pnumwritten == -1) - { - if (errno == EILSEQ) - write_char(_T('?'), pnumwritten); - else - break; - } - } -} - -#else /* CPRFLAG */ - -LOCAL(void) write_string ( - const _TCHAR *string, - int len, - miniFILE *f, - int *pnumwritten - ) -{ - if ( (f->_flag & _IOSTRG) && f->_base == NULL) - { - (*pnumwritten) += len; - return; - } - while (len-- > 0) { - write_char(*string++, f, pnumwritten); - if (*pnumwritten == -1) - { - if (errno == EILSEQ) - write_char(_T('?'), f, pnumwritten); - else - break; - } - } -} -#endif /* CPRFLAG */ diff --git a/src/coreclr/pal/src/safecrt/safecrt_output_s.cpp b/src/coreclr/pal/src/safecrt/safecrt_output_s.cpp deleted file mode 100644 index ed93e0b..0000000 --- a/src/coreclr/pal/src/safecrt/safecrt_output_s.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*** -*safecrt_output_s.c - implementation of the _output family for safercrt.lib -* - -* -*Purpose: -* This file contains the implementation of the _output family for safercrt.lib. -* -*Revision History: -* 07-08-04 SJ Stub module created. -* 07-13-04 AC Added support for floating-point types. -* 07-29-04 AC Added macros for a safecrt version of mctowc and wctomb, which target ntdll.dll or msvcrt.dll -* based on the _NTSUBSET_ #define -* 09-24-04 MSL Prefix disallow NULL deref -* -****/ - -#define _SAFECRT_IMPL - -#define __STDC_LIMIT_MACROS -#include "pal/palinternal.h" -#include -#include -#include -#include -#include -#include -#include "internal_securecrt.h" - -#include "mbusafecrt_internal.h" - -#define FORMAT_VALIDATIONS -#define _CFLTCVT _safecrt_cfltcvt - -#define _TCHAR CRT_TCHAR -#define TCHAR CRTTCHAR - -typedef char _TCHAR; -typedef char TCHAR; -#define _T(x) x - -#include "output.inl" diff --git a/src/coreclr/pal/src/safecrt/safecrt_woutput_s.cpp b/src/coreclr/pal/src/safecrt/safecrt_woutput_s.cpp deleted file mode 100644 index c091119..0000000 --- a/src/coreclr/pal/src/safecrt/safecrt_woutput_s.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*** -*safecrt_woutput_s.c - implementation of the _woutput family for safercrt.lib -* - -* -*Purpose: -* This file contains the implementation of the _woutput family for safercrt.lib. -* -*Revision History: -* 07-08-04 SJ Stub module created. -* 07-13-04 AC Added support for floating-point types. -* 07-29-04 AC Added macros for a safecrt version of mctowc and wctomb, which target ntdll.dll or msvcrt.dll -* based on the _NTSUBSET_ #define -* -****/ - -#define _SAFECRT_IMPL - -#define __STDC_LIMIT_MACROS - -#include "pal/palinternal.h" -#include -#include -#include -#include -#include -#include -#include "internal_securecrt.h" - -#include "mbusafecrt_internal.h" - -#ifndef _UNICODE /* CRT flag */ -#define _UNICODE 1 -#endif - -#ifndef UNICODE /* NT flag */ -#define UNICODE 1 -#endif - -#define FORMAT_VALIDATIONS -#if defined(_NTSUBSET_) -#define _MBTOWC _safecrt_mbtowc -#endif -#define _WCTOMB_S _safecrt_wctomb_s -#define _CFLTCVT _safecrt_cfltcvt -#define _CLDCVT _safecrt_cldcvt - -#define _TCHAR CRT_TCHAR -#define TCHAR CRTTCHAR - -typedef char16_t _TCHAR; -typedef char16_t TCHAR; -#define _T(x) L##x - -#include "output.inl" diff --git a/src/coreclr/pal/src/safecrt/vsprintf.cpp b/src/coreclr/pal/src/safecrt/vsprintf.cpp index e4e77bd..b8ff745 100644 --- a/src/coreclr/pal/src/safecrt/vsprintf.cpp +++ b/src/coreclr/pal/src/safecrt/vsprintf.cpp @@ -20,103 +20,8 @@ #include "mbusafecrt_internal.h" -typedef int (*OUTPUTFN)(miniFILE *, const char *, va_list); - -static int _vsnprintf_helper( OUTPUTFN outfn, char *string, size_t count, const char *format, va_list ap ); -static int _vscprintf_helper ( OUTPUTFN outfn, const char *format, va_list ap); - -/*** -*ifndef _COUNT_ -*int vsprintf(string, format, ap) - print formatted data to string from arg ptr -*else -*int _vsnprintf(string, cnt, format, ap) - print formatted data to string from arg ptr -*endif -* -*Purpose: -* Prints formatted data, but to a string and gets data from an argument -* pointer. -* Sets up a FILE so file i/o operations can be used, make string look -* like a huge buffer to it, but _flsbuf will refuse to flush it if it -* fills up. Appends '\0' to make it a true string. -* -* Allocate the 'fake' _iob[] entryit statically instead of on -* the stack so that other routines can assume that _iob[] entries are in -* are in DGROUP and, thus, are near. -* -*ifdef _COUNT_ -* The _vsnprintf() flavor takes a count argument that is -* the max number of bytes that should be written to the -* user's buffer. -*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) -* Also, since there is only one statically allocated 'fake' iob, we must -* lock/unlock to prevent collisions. -* -*Entry: -* char *string - place to put destination string -*ifdef _COUNT_ -* size_t count - max number of bytes to put in buffer -*endif -* char *format - format string, describes format of data -* va_list ap - varargs argument pointer -* -*Exit: -* returns number of characters in string -* returns -2 if the string has been truncated (only in _vsnprintf_helper) -* returns -1 in other error cases -* -*Exceptions: -* -*******************************************************************************/ - -int __cdecl _vsnprintf_helper ( - OUTPUTFN outfn, - char *string, - size_t count, - const char *format, - va_list ap - ) -{ - miniFILE str; - miniFILE *outfile = &str; - int retval; - - _VALIDATE_RETURN( (format != NULL), EINVAL, -1); - - _VALIDATE_RETURN( (count == 0) || (string != NULL), EINVAL, -1 ); - - if(count>INT_MAX) - { - /* old-style functions allow any large value to mean unbounded */ - outfile->_cnt = INT_MAX; - } - else - { - outfile->_cnt = (int)count; - } - - outfile->_flag = _IOWRT|_IOSTRG; - outfile->_ptr = outfile->_base = string; - - retval = outfn(outfile, format, ap ); - - if ( string==NULL) - return(retval); - - if((retval >= 0) && (_putc_nolock('\0',outfile) != EOF)) - return(retval); - - string[count - 1] = 0; - - if (outfile->_cnt < 0) - { - /* the buffer was too small; we return -2 to indicate truncation */ - return -2; - } - return -1; -} +#include +#include DLLEXPORT int __cdecl vsprintf_s ( char *string, @@ -131,13 +36,13 @@ DLLEXPORT int __cdecl vsprintf_s ( _VALIDATE_RETURN(format != NULL, EINVAL, -1); _VALIDATE_RETURN(string != NULL && sizeInBytes > 0, EINVAL, -1); - retvalue = _vsnprintf_helper(_output_s, string, sizeInBytes, format, ap); + retvalue = vsnprintf(string, sizeInBytes, format, ap); if (retvalue < 0) { - string[0] = 0; + string[0] = '\0'; _SECURECRT__FILL_STRING(string, sizeInBytes, 1); } - if (retvalue == -2) + if (retvalue > (int)sizeInBytes) { _VALIDATE_RETURN(("Buffer too small" && 0), ERANGE, -1); } @@ -172,8 +77,8 @@ DLLEXPORT int __cdecl _vsnprintf_s ( if (sizeInBytes > count) { save_errno = errno; - retvalue = _vsnprintf_helper(_output_s, string, count + 1, format, ap); - if (retvalue == -2) + retvalue = vsnprintf(string, count + 1, format, ap); + if (retvalue > (int)(count + 1)) { /* the string has been truncated, return -1 */ _SECURECRT__FILL_STRING(string, sizeInBytes, count + 1); @@ -187,10 +92,10 @@ DLLEXPORT int __cdecl _vsnprintf_s ( else /* sizeInBytes <= count */ { save_errno = errno; - retvalue = _vsnprintf_helper(_output_s, string, sizeInBytes, format, ap); - string[sizeInBytes - 1] = 0; + retvalue = vsnprintf(string, sizeInBytes, format, ap); + string[sizeInBytes - 1] = '\0'; /* we allow truncation if count == _TRUNCATE */ - if (retvalue == -2 && count == _TRUNCATE) + if (retvalue > (int)sizeInBytes && count == _TRUNCATE) { if (errno == ERANGE) { @@ -202,12 +107,8 @@ DLLEXPORT int __cdecl _vsnprintf_s ( if (retvalue < 0) { - string[0] = 0; + string[0] = '\0'; _SECURECRT__FILL_STRING(string, sizeInBytes, 1); - if (retvalue == -2) - { - _VALIDATE_RETURN(("Buffer too small" && 0), ERANGE, -1); - } return -1; } @@ -215,53 +116,3 @@ DLLEXPORT int __cdecl _vsnprintf_s ( return (retvalue < 0 ? -1 : retvalue); } - -/*** -* _vscprintf() - counts the number of character needed to print the formatted -* data -* -*Purpose: -* Counts the number of characters in the fotmatted data. -* -*Entry: -* char *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 _vscprintf_helper ( - OUTPUTFN outfn, - const char *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 = outfn(outfile, format, ap); - return(retval); -} - -int __cdecl _vscprintf ( - const char *format, - va_list ap - ) -{ - return _vscprintf_helper(_output, format, ap); -} - -#endif /* _COUNT_ */ diff --git a/src/coreclr/pal/tests/palsuite/CMakeLists.txt b/src/coreclr/pal/tests/palsuite/CMakeLists.txt index 5d84f47..aafa8b4 100644 --- a/src/coreclr/pal/tests/palsuite/CMakeLists.txt +++ b/src/coreclr/pal/tests/palsuite/CMakeLists.txt @@ -14,6 +14,9 @@ endif() list(APPEND COMMON_TEST_LIBRARIES coreclrpal) +# Skip validation of printf format flags. +add_compile_options(-Wno-format) + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wno-incompatible-pointer-types-discards-qualifiers) add_compile_options(-Wno-int-to-void-pointer-cast) @@ -117,25 +120,6 @@ add_executable_clr(paltests c_runtime/fopen/test5/test5.cpp c_runtime/fopen/test6/test6.cpp c_runtime/fopen/test7/test7.cpp - c_runtime/fprintf/test1/test1.cpp - c_runtime/fprintf/test10/test10.cpp - c_runtime/fprintf/test11/test11.cpp - c_runtime/fprintf/test12/test12.cpp - c_runtime/fprintf/test13/test13.cpp - c_runtime/fprintf/test14/test14.cpp - c_runtime/fprintf/test15/test15.cpp - c_runtime/fprintf/test16/test16.cpp - c_runtime/fprintf/test17/test17.cpp - c_runtime/fprintf/test18/test18.cpp - c_runtime/fprintf/test19/test19.cpp - c_runtime/fprintf/test2/test2.cpp - c_runtime/fprintf/test3/test3.cpp - c_runtime/fprintf/test4/test4.cpp - c_runtime/fprintf/test5/test5.cpp - c_runtime/fprintf/test6/test6.cpp - c_runtime/fprintf/test7/test7.cpp - c_runtime/fprintf/test8/test8.cpp - c_runtime/fprintf/test9/test9.cpp c_runtime/fputs/test1/test1.cpp c_runtime/fputs/test2/test2.cpp c_runtime/fread/test1/test1.cpp @@ -175,25 +159,6 @@ add_executable_clr(paltests c_runtime/modff/test1/test1.cpp c_runtime/pow/test1/test1.cpp c_runtime/powf/test1/test1.cpp - c_runtime/printf/test1/test1.cpp - c_runtime/printf/test10/test10.cpp - c_runtime/printf/test11/test11.cpp - c_runtime/printf/test12/test12.cpp - c_runtime/printf/test13/test13.cpp - c_runtime/printf/test14/test14.cpp - c_runtime/printf/test15/test15.cpp - c_runtime/printf/test16/test16.cpp - c_runtime/printf/test17/test17.cpp - c_runtime/printf/test18/test18.cpp - c_runtime/printf/test19/test19.cpp - c_runtime/printf/test2/test2.cpp - c_runtime/printf/test3/test3.cpp - c_runtime/printf/test4/test4.cpp - c_runtime/printf/test5/test5.cpp - c_runtime/printf/test6/test6.cpp - c_runtime/printf/test7/test7.cpp - c_runtime/printf/test8/test8.cpp - c_runtime/printf/test9/test9.cpp c_runtime/qsort/test1/test1.cpp c_runtime/qsort/test2/test2.cpp c_runtime/rand_srand/test1/test1.cpp @@ -204,24 +169,6 @@ add_executable_clr(paltests c_runtime/sinf/test1/test1.cpp c_runtime/sinh/test1/test1.cpp c_runtime/sinhf/test1/test1.cpp - c_runtime/sprintf_s/test1/test1.cpp - c_runtime/sprintf_s/test10/test10.cpp - c_runtime/sprintf_s/test11/test11.cpp - c_runtime/sprintf_s/test12/test12.cpp - c_runtime/sprintf_s/test13/test13.cpp - c_runtime/sprintf_s/test14/test14.cpp - c_runtime/sprintf_s/test15/test15.cpp - c_runtime/sprintf_s/test16/test16.cpp - c_runtime/sprintf_s/test17/test17.cpp - c_runtime/sprintf_s/test18/test18.cpp - c_runtime/sprintf_s/test19/test19.cpp - c_runtime/sprintf_s/test2/test2.cpp - c_runtime/sprintf_s/test3/test3.cpp - c_runtime/sprintf_s/test4/test4.cpp - c_runtime/sprintf_s/test6/test6.cpp - c_runtime/sprintf_s/test7/test7.cpp - c_runtime/sprintf_s/test8/test8.cpp - c_runtime/sprintf_s/test9/test9.cpp c_runtime/sqrt/test1/test1.cpp c_runtime/sqrtf/test1/test1.cpp c_runtime/sscanf_s/test1/test1.cpp @@ -265,62 +212,6 @@ add_executable_clr(paltests c_runtime/toupper/test1/test1.cpp c_runtime/towlower/test1/test1.cpp c_runtime/towupper/test1/test1.cpp - c_runtime/vfprintf/test1/test1.cpp - c_runtime/vfprintf/test10/test10.cpp - c_runtime/vfprintf/test11/test11.cpp - c_runtime/vfprintf/test12/test12.cpp - c_runtime/vfprintf/test13/test13.cpp - c_runtime/vfprintf/test14/test14.cpp - c_runtime/vfprintf/test15/test15.cpp - c_runtime/vfprintf/test16/test16.cpp - c_runtime/vfprintf/test17/test17.cpp - c_runtime/vfprintf/test18/test18.cpp - c_runtime/vfprintf/test19/test19.cpp - c_runtime/vfprintf/test2/test2.cpp - c_runtime/vfprintf/test3/test3.cpp - c_runtime/vfprintf/test4/test4.cpp - c_runtime/vfprintf/test5/test5.cpp - c_runtime/vfprintf/test6/test6.cpp - c_runtime/vfprintf/test7/test7.cpp - c_runtime/vfprintf/test8/test8.cpp - c_runtime/vfprintf/test9/test9.cpp - #c_runtime/vprintf/test1/test1.cpp - c_runtime/vprintf/test10/test10.cpp - c_runtime/vprintf/test11/test11.cpp - c_runtime/vprintf/test12/test12.cpp - c_runtime/vprintf/test13/test13.cpp - c_runtime/vprintf/test14/test14.cpp - c_runtime/vprintf/test15/test15.cpp - c_runtime/vprintf/test16/test16.cpp - c_runtime/vprintf/test17/test17.cpp - c_runtime/vprintf/test18/test18.cpp - c_runtime/vprintf/test19/test19.cpp - c_runtime/vprintf/test2/test2.cpp - c_runtime/vprintf/test3/test3.cpp - c_runtime/vprintf/test4/test4.cpp - c_runtime/vprintf/test5/test5.cpp - c_runtime/vprintf/test6/test6.cpp - c_runtime/vprintf/test7/test7.cpp - c_runtime/vprintf/test8/test8.cpp - c_runtime/vprintf/test9/test9.cpp - c_runtime/vsprintf/test1/test1.cpp - c_runtime/vsprintf/test10/test10.cpp - c_runtime/vsprintf/test11/test11.cpp - c_runtime/vsprintf/test12/test12.cpp - c_runtime/vsprintf/test13/test13.cpp - c_runtime/vsprintf/test14/test14.cpp - c_runtime/vsprintf/test15/test15.cpp - c_runtime/vsprintf/test16/test16.cpp - c_runtime/vsprintf/test17/test17.cpp - c_runtime/vsprintf/test18/test18.cpp - c_runtime/vsprintf/test19/test19.cpp - c_runtime/vsprintf/test2/test2.cpp - c_runtime/vsprintf/test3/test3.cpp - c_runtime/vsprintf/test4/test4.cpp - c_runtime/vsprintf/test6/test6.cpp - c_runtime/vsprintf/test7/test7.cpp - c_runtime/vsprintf/test8/test8.cpp - c_runtime/vsprintf/test9/test9.cpp c_runtime/wcscat/test1/test1.cpp c_runtime/wcschr/test1/test1.cpp c_runtime/wcscmp/test1/test1.cpp @@ -353,24 +244,6 @@ add_executable_clr(paltests c_runtime/_putenv/test4/test4.cpp c_runtime/_rotl/test1/test1.cpp c_runtime/_rotr/test1/test1.cpp - c_runtime/_snprintf_s/test1/test1.cpp - c_runtime/_snprintf_s/test10/test10.cpp - c_runtime/_snprintf_s/test11/test11.cpp - c_runtime/_snprintf_s/test12/test12.cpp - c_runtime/_snprintf_s/test13/test13.cpp - c_runtime/_snprintf_s/test14/test14.cpp - c_runtime/_snprintf_s/test15/test15.cpp - c_runtime/_snprintf_s/test16/test16.cpp - c_runtime/_snprintf_s/test17/test17.cpp - c_runtime/_snprintf_s/test18/test18.cpp - c_runtime/_snprintf_s/test19/test19.cpp - c_runtime/_snprintf_s/test2/test2.cpp - c_runtime/_snprintf_s/test3/test3.cpp - c_runtime/_snprintf_s/test4/test4.cpp - c_runtime/_snprintf_s/test6/test6.cpp - c_runtime/_snprintf_s/test7/test7.cpp - c_runtime/_snprintf_s/test8/test8.cpp - c_runtime/_snprintf_s/test9/test9.cpp c_runtime/_stricmp/test1/test1.cpp c_runtime/_strnicmp/test1/test1.cpp c_runtime/_vsnprintf_s/test1/test1.cpp @@ -385,10 +258,8 @@ add_executable_clr(paltests c_runtime/_vsnprintf_s/test18/test18.cpp c_runtime/_vsnprintf_s/test19/test19.cpp c_runtime/_vsnprintf_s/test2/test2.cpp - c_runtime/_vsnprintf_s/test3/test3.cpp c_runtime/_vsnprintf_s/test4/test4.cpp c_runtime/_vsnprintf_s/test6/test6.cpp - c_runtime/_vsnprintf_s/test7/test7.cpp c_runtime/_vsnprintf_s/test8/test8.cpp c_runtime/_vsnprintf_s/test9/test9.cpp c_runtime/_wcsicmp/test1/test1.cpp diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/_snprintf_s.h b/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/_snprintf_s.h deleted file mode 100644 index 6e3212d..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/_snprintf_s.h +++ /dev/null @@ -1,204 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: sprintf_s.h -** -** Purpose: Contains common testing functions for sprintf_s -** -** -**==========================================================================*/ - -#ifndef __STRINGTEST_H__ -#define __STRINGTEST_H__ - -inline void DoStrTest_snprintf_s(const char *formatstr, char* param, const char *checkstr) -{ - char buf[256] = { 0 }; - - _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" - "Expected \"%s\" got \"%s\".\n", - param, formatstr, checkstr, buf); - } -} -#define DoStrTest DoStrTest_snprintf_s - -inline void DoWStrTest_snprintf_s(const char *formatstr, WCHAR* param, const char *checkstr) -{ - char buf[256] = { 0 }; - - _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" - "Expected \"%s\" got \"%s\".\n", - convertC(param), formatstr, checkstr, buf); - } -} -#define DoWStrTest DoWStrTest_snprintf_s - -inline void DoPointerTest_snprintf_s(const char *formatstr, void* param, char* paramstr, char - *checkstr1) -{ - char buf[256] = { 0 }; - - _snprintf_s(buf, 256, _TRUNCATE, formatstr, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\", got \"%s\".\n", - paramstr, formatstr, checkstr1, buf); - } -} -#define DoPointerTest DoPointerTest_snprintf_s - -inline void DoCountTest_snprintf_s(const char *formatstr, int param, const char *checkstr) -{ - char buf[512] = { 0 }; - int n = -1; - - sprintf_s(buf, 512, formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } -} -#define DoCountTest DoCountTest_snprintf_s - -inline void DoShortCountTest_snprintf_s(const char *formatstr, int param, const char *checkstr) -{ - char buf[256] = { 0 }; - short int n = -1; - - _snprintf_s(buf, 256, _TRUNCATE, formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } -} -#define DoShortCountTest DoShortCountTest_snprintf_s - -inline void DoCharTest_snprintf_s(const char *formatstr, char param, const char *checkstr) -{ - char buf[256] = { 0 }; - - _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" - "Expected \"%s\" got \"%s\".\n", - param, param, formatstr, checkstr, buf); - } -} -#define DoCharTest DoCharTest_snprintf_s - -inline void DoWCharTest_snprintf_s(const char *formatstr, WCHAR param, const char *checkstr) -{ - char buf[256] = { 0 }; - - _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" - "Expected \"%s\" got \"%s\".\n", - (char)param, param, formatstr, checkstr, buf); - } -} -#define DoWCharTest DoWCharTest_snprintf_s - -inline void DoNumTest_snprintf_s(const char *formatstr, int value, const char *checkstr) -{ - char buf[256] = { 0 }; - - _snprintf_s(buf, 256, _TRUNCATE, formatstr, value); - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert %#x into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - value, formatstr, checkstr, buf); - } -} -#define DoNumTest DoNumTest_snprintf_s - -inline void DoI64Test_snprintf_s(const char *formatstr, INT64 value, char *valuestr, const char *checkstr1) -{ - char buf[256] = { 0 }; - - _snprintf_s(buf, 256, _TRUNCATE, formatstr, value); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\", got \"%s\".\n", - valuestr, formatstr, checkstr1, buf); - } -} -#define DoI64Test DoI64Test_snprintf_s - -inline void DoDoubleTest_snprintf_s(const char *formatstr, double value, const char *checkstr1, char -*checkstr2) -{ - char buf[256] = { 0 }; - - _snprintf_s(buf, 256, _TRUNCATE, formatstr, value); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 - && memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\"\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - value, formatstr, checkstr1, checkstr2, buf); - } -} -#define DoDoubleTest DoDoubleTest_snprintf_s - -inline void DoArgumentPrecTest_snprintf_s(const char *formatstr, int precision, void *param, char -*paramstr, const char *checkstr1, const char *checkstr2) -{ - char buf[256]; - - _snprintf_s(buf, 256, _TRUNCATE, formatstr, precision, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - paramstr, formatstr, precision, checkstr1, checkstr2, buf); - } - -} -#define DoArgumentPrecTest DoArgumentPrecTest_snprintf_s - -inline void DoArgumentPrecDoubleTest_snprintf_s(const char *formatstr, int precision, double param, -const char *checkstr1, const char *checkstr2) -{ - char buf[256]; - - _snprintf_s(buf, 256, _TRUNCATE, formatstr, precision, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - param, formatstr, precision, checkstr1, checkstr2, buf); - } - -} -#define DoArgumentPrecDoubleTest DoArgumentPrecDoubleTest_snprintf_s - -#endif - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test1/test1.cpp deleted file mode 100644 index e7fc958..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test1/test1.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: General test to see if sprintf_s works correctly -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -PALTEST(c_runtime__snprintf_s_test1_paltest_snprintf_test1, "c_runtime/_snprintf_s/test1/paltest_snprintf_test1") -{ - char checkstr[] = "hello world"; - char buf[256] = { 0 }; - int ret; - - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - _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_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, 7) != 0 || buf[7] != 0 || buf[8] != 'x') - { - Fail("ERROR: expected %s (up to %d chars), got %s\n", - checkstr, 8, buf); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test10/test10.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test10/test10.cpp deleted file mode 100644 index 1ed1831..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test10/test10.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test10.c -** -** Purpose: Tests sprintf_s with octal numbers -** -** -**==========================================================================*/ - - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -PALTEST(c_runtime__snprintf_s_test10_paltest_snprintf_test10, "c_runtime/_snprintf_s/test10/paltest_snprintf_test10") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %o", pos, "foo 52"); - DoNumTest("foo %lo", 0xFFFF, "foo 177777"); - DoNumTest("foo %ho", 0xFFFF, "foo 177777"); - DoNumTest("foo %Lo", pos, "foo 52"); - DoI64Test("foo %I64o", l, "42", "foo 52"); - DoNumTest("foo %3o", pos, "foo 52"); - DoNumTest("foo %-3o", pos, "foo 52 "); - DoNumTest("foo %.1o", pos, "foo 52"); - DoNumTest("foo %.3o", pos, "foo 052"); - DoNumTest("foo %03o", pos, "foo 052"); - DoNumTest("foo %#o", pos, "foo 052"); - DoNumTest("foo %+o", pos, "foo 52"); - DoNumTest("foo % o", pos, "foo 52"); - DoNumTest("foo %+o", neg, "foo 37777777726"); - DoNumTest("foo % o", neg, "foo 37777777726"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test11/test11.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test11/test11.cpp deleted file mode 100644 index 2576460..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test11/test11.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test11.c -** -** Purpose: Tests sprintf_s with unsigned numbers -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -PALTEST(c_runtime__snprintf_s_test11_paltest_snprintf_test11, "c_runtime/_snprintf_s/test11/paltest_snprintf_test11") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %u", pos, "foo 42"); - DoNumTest("foo %lu", 0xFFFF, "foo 65535"); - DoNumTest("foo %hu", 0xFFFF, "foo 65535"); - DoNumTest("foo %Lu", pos, "foo 42"); - DoI64Test("foo %I64u", l, "42", "foo 42"); - DoNumTest("foo %3u", pos, "foo 42"); - DoNumTest("foo %-3u", pos, "foo 42 "); - DoNumTest("foo %.1u", pos, "foo 42"); - DoNumTest("foo %.3u", pos, "foo 042"); - DoNumTest("foo %03u", pos, "foo 042"); - DoNumTest("foo %#u", pos, "foo 42"); - DoNumTest("foo %+u", pos, "foo 42"); - DoNumTest("foo % u", pos, "foo 42"); - DoNumTest("foo %+u", neg, "foo 4294967254"); - DoNumTest("foo % u", neg, "foo 4294967254"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test12/test12.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test12/test12.cpp deleted file mode 100644 index de62e6e..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test12/test12.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test12.c -** -** Purpose: Tests sprintf_s with hex numbers (lowercase) -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -PALTEST(c_runtime__snprintf_s_test12_paltest_snprintf_test12, "c_runtime/_snprintf_s/test12/paltest_snprintf_test12") -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %x", pos, "foo 1234ab"); - DoNumTest("foo %lx", pos, "foo 1234ab"); - DoNumTest("foo %hx", pos, "foo 34ab"); - DoNumTest("foo %Lx", pos, "foo 1234ab"); - DoI64Test("foo %I64x", l, "0x1234567887654321", "foo 1234567887654321"); - DoNumTest("foo %7x", pos, "foo 1234ab"); - DoNumTest("foo %-7x", pos, "foo 1234ab "); - DoNumTest("foo %.1x", pos, "foo 1234ab"); - DoNumTest("foo %.7x", pos, "foo 01234ab"); - DoNumTest("foo %07x", pos, "foo 01234ab"); - DoNumTest("foo %#x", pos, "foo 0x1234ab"); - DoNumTest("foo %+x", pos, "foo 1234ab"); - DoNumTest("foo % x", pos, "foo 1234ab"); - DoNumTest("foo %+x", neg, "foo ffffffd6"); - DoNumTest("foo % x", neg, "foo ffffffd6"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test13/test13.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test13/test13.cpp deleted file mode 100644 index 59c26ca..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test13/test13.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test13.c -** -** Purpose: Tests sprintf_s with hex numbers (uppercase) -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -PALTEST(c_runtime__snprintf_s_test13_paltest_snprintf_test13, "c_runtime/_snprintf_s/test13/paltest_snprintf_test13") -{ - int neg = -42; - int pos = 0x1234AB; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %X", pos, "foo 1234AB"); - DoNumTest("foo %lX", pos, "foo 1234AB"); - DoNumTest("foo %hX", pos, "foo 34AB"); - DoNumTest("foo %LX", pos, "foo 1234AB"); - DoI64Test("foo %I64X", l, "0x1234567887654321", "foo 1234567887654321"); - DoNumTest("foo %7X", pos, "foo 1234AB"); - DoNumTest("foo %-7X", pos, "foo 1234AB "); - DoNumTest("foo %.1X", pos, "foo 1234AB"); - DoNumTest("foo %.7X", pos, "foo 01234AB"); - DoNumTest("foo %07X", pos, "foo 01234AB"); - DoNumTest("foo %#X", pos, "foo 0X1234AB"); - DoNumTest("foo %+X", pos, "foo 1234AB"); - DoNumTest("foo % X", pos, "foo 1234AB"); - DoNumTest("foo %+X", neg, "foo FFFFFFD6"); - DoNumTest("foo % X", neg, "foo FFFFFFD6"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test14/test14.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test14/test14.cpp deleted file mode 100644 index b3b5044..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test14/test14.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test14.c -** -** Purpose: Tests sprintf_s with exponential format doubles (lowercase) -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -PALTEST(c_runtime__snprintf_s_test14_paltest_snprintf_test14, "c_runtime/_snprintf_s/test14/paltest_snprintf_test14") -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest("foo %e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %he", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %Le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %I64e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %14e", val, "foo 2.560000e+002", - "foo 2.560000e+02"); - DoDoubleTest("foo %-14e", val, "foo 2.560000e+002 ", - "foo 2.560000e+02 "); - DoDoubleTest("foo %.1e", val, "foo 2.6e+002", "foo 2.6e+02"); - DoDoubleTest("foo %.8e", val, "foo 2.56000000e+002", - "foo 2.56000000e+02"); - DoDoubleTest("foo %014e", val, "foo 02.560000e+002", - "foo 002.560000e+02"); - DoDoubleTest("foo %#e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", val, "foo +2.560000e+002", "foo +2.560000e+02"); - DoDoubleTest("foo % e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - DoDoubleTest("foo % e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test15/test15.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test15/test15.cpp deleted file mode 100644 index 407af8c..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test15/test15.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test15.c -** -** Purpose: Tests sprintf_s with exponential format doubles (uppercase) -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -PALTEST(c_runtime__snprintf_s_test15_paltest_snprintf_test15, "c_runtime/_snprintf_s/test15/paltest_snprintf_test15") -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest("foo %E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %lE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %hE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %LE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %I64E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %14E", val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest("foo %-14E", val, "foo 2.560000E+002 ", - "foo 2.560000E+02 "); - DoDoubleTest("foo %.1E", val, "foo 2.6E+002", "foo 2.6E+02"); - DoDoubleTest("foo %.8E", val, "foo 2.56000000E+002", - "foo 2.56000000E+02"); - DoDoubleTest("foo %014E", val, "foo 02.560000E+002", - "foo 002.560000E+02"); - DoDoubleTest("foo %#E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", val, "foo +2.560000E+002", "foo +2.560000E+02"); - DoDoubleTest("foo % E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - DoDoubleTest("foo % E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test16/test16.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test16/test16.cpp deleted file mode 100644 index 4ea8909..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test16/test16.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test16.c -** -** Purpose: Test #15 for the sprintf_s function -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -PALTEST(c_runtime__snprintf_s_test16_paltest_snprintf_test16, "c_runtime/_snprintf_s/test16/paltest_snprintf_test16") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest("foo %f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %hf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %Lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %I64f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %12f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %-12f", val, "foo 2560.001000 ", "foo 2560.001000 "); - DoDoubleTest("foo %.1f", val, "foo 2560.0", "foo 2560.0"); - DoDoubleTest("foo %.8f", val, "foo 2560.00100000", "foo 2560.00100000"); - DoDoubleTest("foo %012f", val, "foo 02560.001000", "foo 02560.001000"); - DoDoubleTest("foo %#f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", val, "foo +2560.001000", "foo +2560.001000"); - DoDoubleTest("foo % f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", neg, "foo -2560.001000", "foo -2560.001000"); - DoDoubleTest("foo % f", neg, "foo -2560.001000", "foo -2560.001000"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test17/test17.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test17/test17.cpp deleted file mode 100644 index 496744c..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test17/test17.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test17.c -** -** Purpose: Tests sprintf_s with compact format doubles (lowercase) -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -PALTEST(c_runtime__snprintf_s_test17_paltest_snprintf_test17, "c_runtime/_snprintf_s/test17/paltest_snprintf_test17") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest("foo %g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %Lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5g", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1g", val, "foo 3e+003", "foo 3e+03"); - DoDoubleTest("foo %.2g", val, "foo 2.6e+003", "foo 2.6e+03"); - DoDoubleTest("foo %.12g", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06g", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#g", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+g", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+g", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % g", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test18/test18.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test18/test18.cpp deleted file mode 100644 index 0a96a01..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test18/test18.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test18.c -** -** Purpose: Tests sprintf_s with compact format doubles (uppercase) -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -PALTEST(c_runtime__snprintf_s_test18_paltest_snprintf_test18, "c_runtime/_snprintf_s/test18/paltest_snprintf_test18") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest("foo %G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %LG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5G", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1G", val, "foo 3E+003", "foo 3E+03"); - DoDoubleTest("foo %.2G", val, "foo 2.6E+003", "foo 2.6E+03"); - DoDoubleTest("foo %.12G", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06G", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#G", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+G", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+G", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % G", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test19/test19.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test19/test19.cpp deleted file mode 100644 index f3335fa..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test19/test19.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test19.c -** -** Purpose:Tests sprintf_s with argument specified precision -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -PALTEST(c_runtime__snprintf_s_test19_paltest_snprintf_test19, "c_runtime/_snprintf_s/test19/paltest_snprintf_test19") -{ - int n = -1; - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - DoArgumentPrecTest("%.*s", 2, (void*)"bar", "bar", "ba", "ba"); - DoArgumentPrecTest("%.*S", 2, (void*)convert("bar"), "bar", "ba", "ba"); - - DoArgumentPrecTest("%.*c", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*c", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*d", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*d", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*i", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*i", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*o", 1, (void*)42, "42", "52", "52"); - DoArgumentPrecTest("%.*o", 3, (void*)42, "42", "052", "052"); - DoArgumentPrecTest("%.*u", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*u", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*x", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*x", 3, (void*)0x42, "0x42", "042", "042"); - DoArgumentPrecTest("%.*X", 1, (void*)0x42, "0x42", "42", "42") ; - DoArgumentPrecTest("%.*X", 3, (void*)0x42, "0x42", "042", "042"); - - - DoArgumentPrecDoubleTest("%.*e", 1, 2.01, "2.0e+000", "2.0e+00"); - DoArgumentPrecDoubleTest("%.*e", 3, 2.01, "2.010e+000", "2.010e+00"); - DoArgumentPrecDoubleTest("%.*E", 1, 2.01, "2.0E+000", "2.0E+00"); - DoArgumentPrecDoubleTest("%.*E", 3, 2.01, "2.010E+000", "2.010E+00"); - DoArgumentPrecDoubleTest("%.*f", 1, 2.01, "2.0", "2.0"); - DoArgumentPrecDoubleTest("%.*f", 3, 2.01, "2.010", "2.010"); - DoArgumentPrecDoubleTest("%.*g", 1, 256.01, "3e+002", "3e+02"); - DoArgumentPrecDoubleTest("%.*g", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 6, 256.01, "256.01", "256.01"); - DoArgumentPrecDoubleTest("%.*G", 1, 256.01, "3E+002", "3E+02"); - DoArgumentPrecDoubleTest("%.*G", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 6, 256.01, "256.01", "256.01"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test2/test2.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test2/test2.cpp deleted file mode 100644 index 4f8a95d..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test2/test2.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose:Tests sprintf_s with strings -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" -/* - * Notes: memcmp is used, as is strlen. - */ - -PALTEST(c_runtime__snprintf_s_test2_paltest_snprintf_test2, "c_runtime/_snprintf_s/test2/paltest_snprintf_test2") -{ - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - DoStrTest("foo %s", "bar", "foo bar"); - DoStrTest("foo %hs", "bar", "foo bar"); - DoWStrTest("foo %ls", convert("bar"), "foo bar"); - DoWStrTest("foo %ws", convert("bar"), "foo bar"); - DoStrTest("foo %Ls", "bar", "foo bar"); - DoStrTest("foo %I64s", "bar", "foo bar"); - DoStrTest("foo %5s", "bar", "foo bar"); - DoStrTest("foo %.2s", "bar", "foo ba"); - DoStrTest("foo %5.2s", "bar", "foo ba"); - DoStrTest("foo %-5s", "bar", "foo bar "); - DoStrTest("foo %05s", "bar", "foo 00bar"); - DoStrTest("foo %s", NULL, "foo (null)"); - DoStrTest("foo %hs", NULL, "foo (null)"); - DoWStrTest("foo %ls", NULL, "foo (null)"); - DoWStrTest("foo %ws", NULL, "foo (null)"); - DoStrTest("foo %Ls", NULL, "foo (null)"); - DoStrTest("foo %I64s", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test3/test3.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test3/test3.cpp deleted file mode 100644 index 485ddfa..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test3/test3.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test3.c -** -** Purpose: Tests sprintf_s with wide strings -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -PALTEST(c_runtime__snprintf_s_test3_paltest_snprintf_test3, "c_runtime/_snprintf_s/test3/paltest_snprintf_test3") -{ - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - DoWStrTest("foo %S", convert("bar"), "foo bar"); - DoStrTest("foo %hS", "bar", "foo bar"); - DoWStrTest("foo %lS", convert("bar"), "foo bar"); - DoWStrTest("foo %wS", convert("bar"), "foo bar"); - DoWStrTest("foo %LS", convert("bar"), "foo bar"); - DoWStrTest("foo %I64S", convert("bar"), "foo bar"); - DoWStrTest("foo %5S", convert("bar"), "foo bar"); - DoWStrTest("foo %.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %5.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %-5S", convert("bar"), "foo bar "); - DoWStrTest("foo %05S", convert("bar"), "foo 00bar"); - DoWStrTest("foo %S", NULL, "foo (null)"); - DoStrTest("foo %hS", NULL, "foo (null)"); - DoWStrTest("foo %lS", NULL, "foo (null)"); - DoWStrTest("foo %wS", NULL, "foo (null)"); - DoWStrTest("foo %LS", NULL, "foo (null)"); - DoWStrTest("foo %I64S", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test4/test4.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test4/test4.cpp deleted file mode 100644 index 3cc097d..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test4/test4.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test4.c -** -** Purpose: Tests sprintf_s with pointers -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -PALTEST(c_runtime__snprintf_s_test4_paltest_snprintf_test4, "c_runtime/_snprintf_s/test4/paltest_snprintf_test4") -{ - void *ptr = (void*) 0x123456; - INT64 lptr = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - /* - ** Run only on 64 bit platforms - */ - #if defined(HOST_64BIT) - Trace("Testing for 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "0000000000000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%-17p", ptr, "pointer to 0x123456", "0000000000123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X0000000000123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); - #else - Trace("Testing for Non 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "00000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%9p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%09p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%-9p", ptr, "pointer to 0x123456", "00123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X00123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); - #endif //defined(HOST_64BIT) - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test6/test6.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test6/test6.cpp deleted file mode 100644 index 69cd3a4..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test6/test6.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test6.c -** -** Purpose: Tests sprintf_s with characters -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -PALTEST(c_runtime__snprintf_s_test6_paltest_snprintf_test6, "c_runtime/_snprintf_s/test6/paltest_snprintf_test6") -{ - WCHAR wc = (WCHAR) 'c'; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoCharTest("foo %c", 'b', "foo b"); - DoCharTest("foo %hc", 'b', "foo b"); - DoWCharTest("foo %lc", wc, "foo c"); - DoCharTest("foo %Lc", 'b', "foo b"); - DoCharTest("foo %I64c", 'b', "foo b"); - DoCharTest("foo %5c", 'b', "foo b"); - DoCharTest("foo %.0c", 'b', "foo b"); - DoCharTest("foo %-5c", 'b', "foo b "); - DoCharTest("foo %05c", 'b', "foo 0000b"); - DoCharTest("foo % c", 'b', "foo b"); - DoCharTest("foo %#c", 'b', "foo b"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test7/test7.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test7/test7.cpp deleted file mode 100644 index 76fb298..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test7/test7.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test7.c -** -** Purpose: Tests sprintf_s with wide characters -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" -/* - * Notes: memcmp is used, as is strlen. - */ - - -PALTEST(c_runtime__snprintf_s_test7_paltest_snprintf_test7, "c_runtime/_snprintf_s/test7/paltest_snprintf_test7") -{ - WCHAR wb = (WCHAR) 'b'; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoWCharTest("foo %C", wb, "foo b"); - DoWCharTest("foo %hC", wb, "foo b"); - DoCharTest("foo %lC", 'c', "foo c"); - DoWCharTest("foo %LC", wb, "foo b"); - DoWCharTest("foo %I64C", wb, "foo b"); - DoWCharTest("foo %5C", wb, "foo b"); - DoWCharTest("foo %.0C", wb, "foo b"); - DoWCharTest("foo %-5C", wb, "foo b "); - DoWCharTest("foo %05C", wb, "foo 0000b"); - DoWCharTest("foo % C", wb, "foo b"); - DoWCharTest("foo %#C", wb, "foo b"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test8/test8.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test8/test8.cpp deleted file mode 100644 index d167949f..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test8/test8.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test8.c -** -** Purpose: Tests sprintf_s with decimal numbers -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -PALTEST(c_runtime__snprintf_s_test8_paltest_snprintf_test8, "c_runtime/_snprintf_s/test8/paltest_snprintf_test8") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %d", pos, "foo 42"); - DoNumTest("foo %ld", 0xFFFF, "foo 65535"); - DoNumTest("foo %hd", 0xFFFF, "foo -1"); - DoNumTest("foo %Ld", pos, "foo 42"); - DoI64Test("foo %I64d", l, "42", "foo 42"); - DoNumTest("foo %3d", pos, "foo 42"); - DoNumTest("foo %-3d", pos, "foo 42 "); - DoNumTest("foo %.1d", pos, "foo 42"); - DoNumTest("foo %.3d", pos, "foo 042"); - DoNumTest("foo %03d", pos, "foo 042"); - DoNumTest("foo %#d", pos, "foo 42"); - DoNumTest("foo %+d", pos, "foo +42"); - DoNumTest("foo % d", pos, "foo 42"); - DoNumTest("foo %+d", neg, "foo -42"); - DoNumTest("foo % d", neg, "foo -42"); - - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test9/test9.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test9/test9.cpp deleted file mode 100644 index 82a1a10..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_snprintf_s/test9/test9.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test9.c -** -** Purpose: Tests sprintf_s with integer numbers -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -PALTEST(c_runtime__snprintf_s_test9_paltest_snprintf_test9, "c_runtime/_snprintf_s/test9/paltest_snprintf_test9") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %i", pos, "foo 42"); - DoNumTest("foo %li", 0xFFFF, "foo 65535"); - DoNumTest("foo %hi", 0xFFFF, "foo -1"); - DoNumTest("foo %Li", pos, "foo 42"); - DoI64Test("foo %I64i", l, "42", "foo 42"); - DoNumTest("foo %3i", pos, "foo 42"); - DoNumTest("foo %-3i", pos, "foo 42 "); - DoNumTest("foo %.1i", pos, "foo 42"); - DoNumTest("foo %.3i", pos, "foo 042"); - DoNumTest("foo %03i", pos, "foo 042"); - DoNumTest("foo %#i", pos, "foo 42"); - DoNumTest("foo %+i", pos, "foo +42"); - DoNumTest("foo % i", pos, "foo 42"); - DoNumTest("foo %+i", neg, "foo -42"); - DoNumTest("foo % i", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/_vsnprintf_s.h b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/_vsnprintf_s.h index ebb1b66..04b7b83 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/_vsnprintf_s.h +++ b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/_vsnprintf_s.h @@ -41,21 +41,6 @@ inline void DoStrTest_vsnprintf_s(const char *formatstr, char* param, const char } #define DoStrTest DoStrTest_vsnprintf_s -inline void DoWStrTest_vsnprintf_s(const char *formatstr, WCHAR* param, const char *checkstr) -{ - char buf[256] = { 0 }; - - Testvsnprintf(buf, 256, formatstr, param); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert wide string \"%s\" into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - convertC(param), formatstr, checkstr, buf); - } -} -#define DoWStrTest DoWStrTest_vsnprintf_s - - inline void DoCharTest_vsnprintf_s(const char *formatstr, char param, const char *checkstr) { char buf[256] = { 0 }; @@ -98,20 +83,6 @@ inline void DoNumTest_vsnprintf_s(const char *formatstr, int value, const char * } #define DoNumTest DoNumTest_vsnprintf_s -inline void DoI64Test_vsnprintf_s(const char *formatstr, INT64 value, char *valuestr, const char *checkstr) -{ - char buf[256] = { 0 }; - - Testvsnprintf(buf, 256, formatstr, value); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - valuestr, formatstr, checkstr, buf); - } -} -#define DoI64Test DoI64Test_vsnprintf_s - inline void DoDoubleTest_vsnprintf_s(const char *formatstr, double value, const char *checkstr1, char *checkstr2) { diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/test1.cpp index a94a7aa..fb5ab3a 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/test1.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/test1.cpp @@ -22,13 +22,13 @@ PALTEST(c_runtime__vsnprintf_s_test1_paltest_vsnprintf_test1, "c_runtime/_vsnpri char checkstr[] = "hello world"; char buf[256] = { 0 }; int ret; - + if (PAL_Initialize(argc, argv) != 0) { return(FAIL); } - Testvsnprintf(buf, 256, "hello world"); + ret = Testvsnprintf(buf, 256, "hello world"); if (memcmp(checkstr, buf, strlen(checkstr)+1) != 0) { diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/test10.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/test10.cpp index 2fcf197..608fde5 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/test10.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/test10.cpp @@ -8,8 +8,8 @@ ** Purpose: Test #10 for the _vsnprintf function. ** ** -**===================================================================*/ - +**===================================================================*/ + #include #include "../_vsnprintf_s.h" @@ -21,8 +21,7 @@ PALTEST(c_runtime__vsnprintf_s_test10_paltest_vsnprintf_test10, "c_runtime/_vsnp { int neg = -42; int pos = 42; - INT64 l = 42; - + if (PAL_Initialize(argc, argv) != 0) { return(FAIL); @@ -31,8 +30,6 @@ PALTEST(c_runtime__vsnprintf_s_test10_paltest_vsnprintf_test10, "c_runtime/_vsnp DoNumTest("foo %o", pos, "foo 52"); DoNumTest("foo %lo", 0xFFFF, "foo 177777"); DoNumTest("foo %ho", 0xFFFF, "foo 177777"); - DoNumTest("foo %Lo", pos, "foo 52"); - DoI64Test("foo %I64o", l, "42", "foo 52"); DoNumTest("foo %3o", pos, "foo 52"); DoNumTest("foo %-3o", pos, "foo 52 "); DoNumTest("foo %.1o", pos, "foo 52"); @@ -43,7 +40,7 @@ PALTEST(c_runtime__vsnprintf_s_test10_paltest_vsnprintf_test10, "c_runtime/_vsnp DoNumTest("foo % o", pos, "foo 52"); DoNumTest("foo %+o", neg, "foo 37777777726"); DoNumTest("foo % o", neg, "foo 37777777726"); - + PAL_Terminate(); return PASS; } diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/test11.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/test11.cpp index 3f3ae03..1b8ee73 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/test11.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/test11.cpp @@ -8,7 +8,7 @@ ** Purpose: Test #11 for the _vsnprintf function. ** ** -**===================================================================*/ +**===================================================================*/ #include #include "../_vsnprintf_s.h" @@ -21,8 +21,7 @@ PALTEST(c_runtime__vsnprintf_s_test11_paltest_vsnprintf_test11, "c_runtime/_vsnp { int neg = -42; int pos = 42; - INT64 l = 42; - + if (PAL_Initialize(argc, argv) != 0) { return(FAIL); @@ -31,8 +30,6 @@ PALTEST(c_runtime__vsnprintf_s_test11_paltest_vsnprintf_test11, "c_runtime/_vsnp DoNumTest("foo %u", pos, "foo 42"); DoNumTest("foo %lu", 0xFFFF, "foo 65535"); DoNumTest("foo %hu", 0xFFFF, "foo 65535"); - DoNumTest("foo %Lu", pos, "foo 42"); - DoI64Test("foo %I64u", l, "42", "foo 42"); DoNumTest("foo %3u", pos, "foo 42"); DoNumTest("foo %-3u", pos, "foo 42 "); DoNumTest("foo %.1u", pos, "foo 42"); diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/test12.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/test12.cpp index 621963f..5509667 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/test12.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/test12.cpp @@ -8,7 +8,7 @@ ** Purpose: Test #12 for the _vsnprintf function. ** ** -**===================================================================*/ +**===================================================================*/ #include #include "../_vsnprintf_s.h" @@ -22,8 +22,7 @@ PALTEST(c_runtime__vsnprintf_s_test12_paltest_vsnprintf_test12, "c_runtime/_vsnp { int neg = -42; int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - + if (PAL_Initialize(argc, argv) != 0) { return (FAIL); @@ -32,9 +31,6 @@ PALTEST(c_runtime__vsnprintf_s_test12_paltest_vsnprintf_test12, "c_runtime/_vsnp DoNumTest("foo %x", pos, "foo 1234ab"); DoNumTest("foo %lx", pos, "foo 1234ab"); DoNumTest("foo %hx", pos, "foo 34ab"); - DoNumTest("foo %Lx", pos, "foo 1234ab"); - DoI64Test("foo %I64x", l, "0x1234567887654321", - "foo 1234567887654321"); DoNumTest("foo %7x", pos, "foo 1234ab"); DoNumTest("foo %-7x", pos, "foo 1234ab "); DoNumTest("foo %.1x", pos, "foo 1234ab"); diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/test13.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/test13.cpp index f053c51..f75b2b4 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/test13.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/test13.cpp @@ -8,7 +8,7 @@ ** Purpose: Test #13 for the _vsnprintf function. ** ** -**===================================================================*/ +**===================================================================*/ #include #include "../_vsnprintf_s.h" @@ -22,8 +22,7 @@ PALTEST(c_runtime__vsnprintf_s_test13_paltest_vsnprintf_test13, "c_runtime/_vsnp { int neg = -42; int pos = 0x1234AB; - INT64 l = I64(0x1234567887654321); - + if (PAL_Initialize(argc, argv) != 0) { return(FAIL); @@ -32,9 +31,6 @@ PALTEST(c_runtime__vsnprintf_s_test13_paltest_vsnprintf_test13, "c_runtime/_vsnp DoNumTest("foo %X", pos, "foo 1234AB"); DoNumTest("foo %lX", pos, "foo 1234AB"); DoNumTest("foo %hX", pos, "foo 34AB"); - DoNumTest("foo %LX", pos, "foo 1234AB"); - DoI64Test("foo %I64X", l, "0x1234567887654321", - "foo 1234567887654321"); DoNumTest("foo %7X", pos, "foo 1234AB"); DoNumTest("foo %-7X", pos, "foo 1234AB "); DoNumTest("foo %.1X", pos, "foo 1234AB"); diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/test14.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/test14.cpp index 0e08acd..b38bd6a 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/test14.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/test14.cpp @@ -8,7 +8,7 @@ ** Purpose: Test #14 for the _vsnprintf function. ** ** -**===================================================================*/ +**===================================================================*/ #include #include "../_vsnprintf_s.h" @@ -22,7 +22,7 @@ PALTEST(c_runtime__vsnprintf_s_test14_paltest_vsnprintf_test14, "c_runtime/_vsnp { double val = 256.0; double neg = -256.0; - + if (PAL_Initialize(argc, argv) != 0) { return(FAIL); @@ -31,8 +31,6 @@ PALTEST(c_runtime__vsnprintf_s_test14_paltest_vsnprintf_test14, "c_runtime/_vsnp DoDoubleTest("foo %e", val, "foo 2.560000e+002", "foo 2.560000e+02"); DoDoubleTest("foo %le", val, "foo 2.560000e+002", "foo 2.560000e+02"); DoDoubleTest("foo %he", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %Le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %I64e", val, "foo 2.560000e+002", "foo 2.560000e+02"); DoDoubleTest("foo %14e", val, "foo 2.560000e+002", "foo 2.560000e+02"); DoDoubleTest("foo %-14e", val, "foo 2.560000e+002 ", "foo 2.560000e+02 "); DoDoubleTest("foo %.1e", val, "foo 2.6e+002", "foo 2.6e+02"); diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/test15.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/test15.cpp index 7850806..641ccff 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/test15.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/test15.cpp @@ -8,7 +8,7 @@ ** Purpose: Test #15 for the _vsnprintf function. ** ** -**===================================================================*/ +**===================================================================*/ #include #include "../_vsnprintf_s.h" @@ -21,7 +21,7 @@ PALTEST(c_runtime__vsnprintf_s_test15_paltest_vsnprintf_test15, "c_runtime/_vsnp { double val = 256.0; double neg = -256.0; - + if (PAL_Initialize(argc, argv) != 0) { return(FAIL); @@ -30,8 +30,6 @@ PALTEST(c_runtime__vsnprintf_s_test15_paltest_vsnprintf_test15, "c_runtime/_vsnp DoDoubleTest("foo %E", val, "foo 2.560000E+002", "foo 2.560000E+02"); DoDoubleTest("foo %lE", val, "foo 2.560000E+002", "foo 2.560000E+02"); DoDoubleTest("foo %hE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %LE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %I64E", val, "foo 2.560000E+002", "foo 2.560000E+02"); DoDoubleTest("foo %14E", val, "foo 2.560000E+002", "foo 2.560000E+02"); DoDoubleTest("foo %-14E", val, "foo 2.560000E+002 ", "foo 2.560000E+02 "); DoDoubleTest("foo %.1E", val, "foo 2.6E+002", "foo 2.6E+02"); diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/test16.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/test16.cpp index 5892a0c..6117d28 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/test16.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/test16.cpp @@ -30,8 +30,6 @@ PALTEST(c_runtime__vsnprintf_s_test16_paltest_vsnprintf_test16, "c_runtime/_vsnp DoDoubleTest("foo %f", val, "foo 2560.001000", "foo 2560.001000"); DoDoubleTest("foo %lf", val, "foo 2560.001000", "foo 2560.001000"); DoDoubleTest("foo %hf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %Lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %I64f", val, "foo 2560.001000", "foo 2560.001000"); DoDoubleTest("foo %12f", val, "foo 2560.001000", "foo 2560.001000"); DoDoubleTest("foo %-12f", val, "foo 2560.001000 ", "foo 2560.001000 "); DoDoubleTest("foo %.1f", val, "foo 2560.0", "foo 2560.0"); diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/test17.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/test17.cpp index 0522158..6153a58 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/test17.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/test17.cpp @@ -8,7 +8,7 @@ ** Purpose: Test #17 for the _vsnprintf function. ** ** -**===================================================================*/ +**===================================================================*/ #include #include "../_vsnprintf_s.h" @@ -21,7 +21,7 @@ PALTEST(c_runtime__vsnprintf_s_test17_paltest_vsnprintf_test17, "c_runtime/_vsnp { double val = 2560.001; double neg = -2560.001; - + if (PAL_Initialize(argc, argv) != 0) { return(FAIL); @@ -30,8 +30,6 @@ PALTEST(c_runtime__vsnprintf_s_test17_paltest_vsnprintf_test17, "c_runtime/_vsnp DoDoubleTest("foo %g", val, "foo 2560", "foo 2560"); DoDoubleTest("foo %lg", val, "foo 2560", "foo 2560"); DoDoubleTest("foo %hg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %Lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64g", val, "foo 2560", "foo 2560"); DoDoubleTest("foo %5g", val, "foo 2560", "foo 2560"); DoDoubleTest("foo %-5g", val, "foo 2560 ", "foo 2560 "); DoDoubleTest("foo %.1g", val, "foo 3e+003", "foo 3e+03"); diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/test18.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/test18.cpp index 2756671..4ac3757 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/test18.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/test18.cpp @@ -30,8 +30,6 @@ PALTEST(c_runtime__vsnprintf_s_test18_paltest_vsnprintf_test18, "c_runtime/_vsnp DoDoubleTest("foo %G", val, "foo 2560", "foo 2560"); DoDoubleTest("foo %lG", val, "foo 2560", "foo 2560"); DoDoubleTest("foo %hG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %LG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64G", val, "foo 2560", "foo 2560"); DoDoubleTest("foo %5G", val, "foo 2560", "foo 2560"); DoDoubleTest("foo %-5G", val, "foo 2560 ", "foo 2560 "); DoDoubleTest("foo %.1G", val, "foo 3E+003", "foo 3E+03"); diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/test19.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/test19.cpp index 731dfe0..0f8260e 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/test19.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/test19.cpp @@ -63,7 +63,6 @@ PALTEST(c_runtime__vsnprintf_s_test19_paltest_vsnprintf_test19, "c_runtime/_vsnp DoArgumentPrecTest("%.*s", 2, (void*)"bar", "bar", "ba", "ba"); - DoArgumentPrecTest("%.*S", 2, (void*)convert("bar"), "bar", "ba", "ba"); DoArgumentPrecTest("%.*c", 0, (void*)'a', "a", "a", "a"); DoArgumentPrecTest("%.*c", 4, (void*)'a', "a", "a", "a"); DoArgumentPrecTest("%.*C", 0, (void*)'a', "a", "a", "a"); diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/test2.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/test2.cpp index b9fe80c..00d97df 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/test2.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/test2.cpp @@ -8,8 +8,8 @@ ** Purpose: Test #2 for the _vsnprintf function. ** ** -**===================================================================*/ - +**===================================================================*/ + #include #include "../_vsnprintf_s.h" /* @@ -18,30 +18,16 @@ PALTEST(c_runtime__vsnprintf_s_test2_paltest_vsnprintf_test2, "c_runtime/_vsnprintf_s/test2/paltest_vsnprintf_test2") { - WCHAR szwStr[] = {'b','a','r','\0'}; - if (PAL_Initialize(argc, argv) != 0) { return(FAIL); } - DoStrTest("foo %s", "bar", "foo bar"); - DoStrTest("foo %hs", "bar", "foo bar"); - DoWStrTest("foo %ls", szwStr, "foo bar"); - DoWStrTest("foo %ws", szwStr, "foo bar"); - DoStrTest("foo %Ls", "bar", "foo bar"); - DoStrTest("foo %I64s", "bar", "foo bar"); + DoStrTest("foo %s", "bar", "foo bar"); DoStrTest("foo %5s", "bar", "foo bar"); DoStrTest("foo %.2s", "bar", "foo ba"); DoStrTest("foo %5.2s", "bar", "foo ba"); DoStrTest("foo %-5s", "bar", "foo bar "); - DoStrTest("foo %05s", "bar", "foo 00bar"); - DoStrTest("foo %s", NULL, "foo (null)"); - DoStrTest("foo %hs", NULL, "foo (null)"); - DoWStrTest("foo %ls", NULL, "foo (null)"); - DoWStrTest("foo %ws", NULL, "foo (null)"); - DoStrTest("foo %Ls", NULL, "foo (null)"); - DoStrTest("foo %I64s", NULL, "foo (null)"); PAL_Terminate(); return PASS; diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/test3.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/test3.cpp deleted file mode 100644 index decb64a..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/test3.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test3.c -** -** Purpose: Test #3 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -PALTEST(c_runtime__vsnprintf_s_test3_paltest_vsnprintf_test3, "c_runtime/_vsnprintf_s/test3/paltest_vsnprintf_test3") -{ - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoWStrTest("foo %S", convert("bar"), "foo bar"); - DoStrTest("foo %hS", "bar", "foo bar"); - DoWStrTest("foo %lS", convert("bar"), "foo bar"); - DoWStrTest("foo %wS", convert("bar"), "foo bar"); - DoWStrTest("foo %LS", convert("bar"), "foo bar"); - DoWStrTest("foo %I64S", convert("bar"), "foo bar"); - DoWStrTest("foo %5S", convert("bar"), "foo bar"); - DoWStrTest("foo %.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %5.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %-5S", convert("bar"), "foo bar "); - DoWStrTest("foo %05S", convert("bar"), "foo 00bar"); - DoWStrTest("foo %S", NULL, "foo (null)"); - DoStrTest("foo %hS", NULL, "foo (null)"); - DoWStrTest("foo %lS", NULL, "foo (null)"); - DoWStrTest("foo %wS", NULL, "foo (null)"); - DoWStrTest("foo %LS", NULL, "foo (null)"); - DoWStrTest("foo %I64S", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/test4.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/test4.cpp index 37c4a63..ef00bdf 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/test4.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/test4.cpp @@ -31,66 +31,30 @@ static void DoPointerTest(char *formatstr, void* param, char* paramstr, } } -static void DoI64DoubleTest(char *formatstr, INT64 value, char *valuestr, char -*checkstr1) -{ - char buf[256] = { 0 }; - - Testvsnprintf(buf,256,formatstr, value); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\", got \"%s\".\n", - valuestr, formatstr, checkstr1, buf); - } -} - PALTEST(c_runtime__vsnprintf_s_test4_paltest_vsnprintf_test4, "c_runtime/_vsnprintf_s/test4/paltest_vsnprintf_test4") { void *ptr = (void*) 0x123456; - INT64 lptr = I64(0x1234567887654321); if (PAL_Initialize(argc, argv) != 0) return(FAIL); /* -** Run only on 64 bit platforms -*/ + ** Run only on 64 bit platforms + */ #if defined(HOST_64BIT) Trace("Testing for 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "0000000000000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%-17p", ptr, "pointer to 0x123456", "0000000000123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X0000000000123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64DoubleTest("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); + DoPointerTest("%p", ptr, "pointer to 0x123456", "0x123456"); + DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0x123456"); + DoPointerTest("%-17p", ptr, "pointer to 0x123456", "0x123456 "); #else Trace("Testing for Non 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "00000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%9p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%09p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%-9p", ptr, "pointer to 0x123456", "00123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X00123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64DoubleTest("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); + DoPointerTest("%p", ptr, "pointer to 0x123456", "0x123456"); + DoPointerTest("%9p", ptr, "pointer to 0x123456", " 0x123456"); + DoPointerTest("%-9p", ptr, "pointer to 0x123456", "0x123456 "); #endif - - - PAL_Terminate(); return PASS; } diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/test6.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/test6.cpp index 88a1fa1..9ebc6f1 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/test6.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/test6.cpp @@ -19,8 +19,6 @@ PALTEST(c_runtime__vsnprintf_s_test6_paltest_vsnprintf_test6, "c_runtime/_vsnprintf_s/test6/paltest_vsnprintf_test6") { - WCHAR wc = (WCHAR) 'c'; - if (PAL_Initialize(argc, argv) != 0) { return(FAIL); @@ -28,16 +26,13 @@ PALTEST(c_runtime__vsnprintf_s_test6_paltest_vsnprintf_test6, "c_runtime/_vsnpri DoCharTest("foo %c", 'b', "foo b"); DoCharTest("foo %hc", 'b', "foo b"); - DoWCharTest("foo %lc", wc, "foo c"); DoCharTest("foo %Lc", 'b', "foo b"); - DoCharTest("foo %I64c", 'b', "foo b"); DoCharTest("foo %5c", 'b', "foo b"); DoCharTest("foo %.0c", 'b', "foo b"); DoCharTest("foo %-5c", 'b', "foo b "); - DoCharTest("foo %05c", 'b', "foo 0000b"); DoCharTest("foo % c", 'b', "foo b"); DoCharTest("foo %#c", 'b', "foo b"); - + PAL_Terminate(); return PASS; } diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/test7.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/test7.cpp deleted file mode 100644 index 87ac8d4..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/test7.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test7.c -** -** Purpose: Test #7 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf_s.h" -/* - * Notes: memcmp is used, as is strlen. - */ - - -PALTEST(c_runtime__vsnprintf_s_test7_paltest_vsnprintf_test7, "c_runtime/_vsnprintf_s/test7/paltest_vsnprintf_test7") -{ - WCHAR wb = (WCHAR) 'b'; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoWCharTest("foo %c", wb, "foo b"); - DoWCharTest("foo %hc", wb, "foo b"); - DoCharTest("foo %lc", 'c', "foo c"); - DoWCharTest("foo %Lc", wb, "foo b"); - DoWCharTest("foo %I64c", wb, "foo b"); - DoWCharTest("foo %5c", wb, "foo b"); - DoWCharTest("foo %.0c", wb, "foo b"); - DoWCharTest("foo %-5c", wb, "foo b "); - DoWCharTest("foo %05c", wb, "foo 0000b"); - DoWCharTest("foo % c", wb, "foo b"); - DoWCharTest("foo %#c", wb, "foo b"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/test8.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/test8.cpp index beb5420..7854c70 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/test8.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/test8.cpp @@ -22,8 +22,7 @@ PALTEST(c_runtime__vsnprintf_s_test8_paltest_vsnprintf_test8, "c_runtime/_vsnpri { int neg = -42; int pos = 42; - INT64 l = 42; - + if (PAL_Initialize(argc, argv) != 0) { return(FAIL); @@ -32,8 +31,6 @@ PALTEST(c_runtime__vsnprintf_s_test8_paltest_vsnprintf_test8, "c_runtime/_vsnpri DoNumTest("foo %d", pos, "foo 42"); DoNumTest("foo %ld", 0xFFFF, "foo 65535"); DoNumTest("foo %hd", 0xFFFF, "foo -1"); - DoNumTest("foo %Ld", pos, "foo 42"); - DoI64Test("foo %I64d", l, "42", "foo 42"); DoNumTest("foo %3d", pos, "foo 42"); DoNumTest("foo %-3d", pos, "foo 42 "); DoNumTest("foo %.1d", pos, "foo 42"); @@ -45,7 +42,7 @@ PALTEST(c_runtime__vsnprintf_s_test8_paltest_vsnprintf_test8, "c_runtime/_vsnpri DoNumTest("foo %+d", neg, "foo -42"); DoNumTest("foo % d", neg, "foo -42"); - + PAL_Terminate(); return PASS; } diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/test9.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/test9.cpp index b84c24e..7932557 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/test9.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/test9.cpp @@ -22,8 +22,7 @@ PALTEST(c_runtime__vsnprintf_s_test9_paltest_vsnprintf_test9, "c_runtime/_vsnpri { int neg = -42; int pos = 42; - INT64 l = 42; - + if (PAL_Initialize(argc, argv) != 0) { return(FAIL); @@ -32,8 +31,6 @@ PALTEST(c_runtime__vsnprintf_s_test9_paltest_vsnprintf_test9, "c_runtime/_vsnpri DoNumTest("foo %i", pos, "foo 42"); DoNumTest("foo %li", 0xFFFF, "foo 65535"); DoNumTest("foo %hi", 0xFFFF, "foo -1"); - DoNumTest("foo %Li", pos, "foo 42"); - DoI64Test("foo %I64i", l, "42", "foo 42"); DoNumTest("foo %3i", pos, "foo 42"); DoNumTest("foo %-3i", pos, "foo 42 "); DoNumTest("foo %.1i", pos, "foo 42"); diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/fprintf.h b/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/fprintf.h deleted file mode 100644 index fe19a4d..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/fprintf.h +++ /dev/null @@ -1,182 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*NOTE: -The creation of the test file within each function is because the FILE -structure is not defined within pal.h. Therefore, unable to have -function with this as a return type. -*/ - -#ifndef __FPRINTF_H__ -#define __FPRINTF_H__ - -inline void DoStrTest_fprintf(const char *formatstr, char* param, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - Fail("ERROR: fopen failed to create testfile\n"); - if ((fprintf(fp, formatstr, param)) < 0) - Fail("ERROR: fprintf failed\n"); - if ((fseek(fp, 0, SEEK_SET)) != 0) - Fail("ERROR: fseek failed\n"); - if ((fgets(buf, 100, fp)) == NULL) - Fail("ERROR: fseek failed\n"); - - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert string \"%s\" into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, formatstr, checkstr, buf); - } - fclose(fp); -} -#define DoStrTest DoStrTest_fprintf - -inline void DoWStrTest_fprintf(const char *formatstr, WCHAR* param, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - Fail("ERROR: fopen failed to create testfile\n"); - if ((fprintf(fp, formatstr, param)) < 0) - Fail("ERROR: fprintf failed\n"); - if ((fseek(fp, 0, SEEK_SET)) != 0) - Fail("ERROR: fseek failed\n"); - if ((fgets(buf, 100, fp)) == NULL) - Fail("ERROR: fseek failed\n"); - - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert wide string \"%s\" into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - convertC(param), formatstr, checkstr, buf); - } - fclose(fp); -} -#define DoWStrTest DoWStrTest_fprintf - -inline void DoCharTest_fprintf(const char *formatstr, char param, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - Fail("ERROR: fopen failed to create testfile\n"); - if ((fprintf(fp, formatstr, param)) < 0) - Fail("ERROR: fprintf failed\n"); - if ((fseek(fp, 0, SEEK_SET)) != 0) - Fail("ERROR: fseek failed\n"); - if ((fgets(buf, 100, fp)) == NULL) - Fail("ERROR: fseek failed\n"); - - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, param, formatstr, checkstr, buf); - } - fclose(fp); -} -#define DoCharTest DoCharTest_fprintf - -inline void DoWCharTest_fprintf(const char *formatstr, WCHAR param, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - Fail("ERROR: fopen failed to create testfile\n"); - if ((fprintf(fp, formatstr, param)) < 0) - Fail("ERROR: fprintf failed\n"); - if ((fseek(fp, 0, SEEK_SET)) != 0) - Fail("ERROR: fseek failed\n"); - if ((fgets(buf, 100, fp)) == NULL) - Fail("ERROR: fseek failed\n"); - - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - (char)param, param, formatstr, checkstr, buf); - } - fclose(fp); -} -#define DoWCharTest DoWCharTest_fprintf - -inline void DoNumTest_fprintf(const char *formatstr, int value, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - Fail("ERROR: fopen failed to create testfile\n"); - if ((fprintf(fp, formatstr, value)) < 0) - Fail("ERROR: fprintf failed\n"); - if ((fseek(fp, 0, SEEK_SET)) != 0) - Fail("ERROR: fseek failed\n"); - if ((fgets(buf, 100, fp)) == NULL) - Fail("ERROR: fseek failed\n"); - - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert %#x into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - value, formatstr, checkstr, buf); - } - fclose(fp); -} -#define DoNumTest DoNumTest_fprintf - -inline void DoI64Test_fprintf(const char *formatstr, INT64 value, char *valuestr, const char *checkstr1, const char *checkstr2) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - Fail("ERROR: fopen failed to create testfile\n"); - if ((fprintf(fp, formatstr, value)) < 0) - Fail("ERROR: fprintf failed\n"); - if ((fseek(fp, 0, SEEK_SET)) != 0) - Fail("ERROR: fseek failed\n"); - if ((fgets(buf, 100, fp)) == NULL) - Fail("ERROR: fseek failed\n"); - - if (memcmp(buf, checkstr1, strlen(buf) + 1) != 0 && - memcmp(buf, checkstr2, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - valuestr, formatstr, checkstr1, checkstr2, buf); - } - fclose(fp); -} -#define DoI64Test DoI64Test_fprintf - -inline void DoDoubleTest_fprintf(const char *formatstr, double value, const char *checkstr1, const char *checkstr2) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - Fail("ERROR: fopen failed to create testfile\n"); - if ((fprintf(fp, formatstr, value)) < 0) - Fail("ERROR: fprintf failed\n"); - if ((fseek(fp, 0, SEEK_SET)) != 0) - Fail("ERROR: fseek failed\n"); - if ((fgets(buf, 100, fp)) == NULL) - Fail("ERROR: fseek failed\n"); - - if (memcmp(buf, checkstr1, strlen(buf) + 1) != 0 && - memcmp(buf, checkstr2, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\"\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - value, formatstr, checkstr1, checkstr2, buf); - } - fclose(fp); -} -#define DoDoubleTest DoDoubleTest_fprintf -#endif diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test1/test1.cpp deleted file mode 100644 index 8fa9ef7..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test1/test1.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test1.c (fprintf) -** -** Purpose: A single, basic, test case with no formatting. -** Test modeled after the sprintf series. -** - -** -**==========================================================================*/ - -#include - -/* - * Depends on memcmp, strlen, fopen, fgets, fseek and fclose. - */ - -PALTEST(c_runtime_fprintf_test1_paltest_fprintf_test1, "c_runtime/fprintf/test1/paltest_fprintf_test1") -{ - FILE *fp; - char testfile[] = "testfile.txt"; - char checkstr[] = "hello world"; - char buf[256]; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - if ((fp = fopen(testfile, "w+")) == NULL) - { - Fail("ERROR: fopen failed to create \"%s\"\n", testfile); - } - - if ((fprintf(fp, "hello world")) < 0) - { - Fail("ERROR: fprintf failed to print to \"%s\"\n", testfile); - } - - if ((fseek( fp, 0, SEEK_SET)) != 0) - - { - - Fail("ERROR: Fseek failed to set pointer to beginning of file\n" ); - - } - - - - if ((fgets( buf, 100, fp )) == NULL) - - { - - Fail("ERROR: fgets failed\n"); - - } - - - if (memcmp(checkstr, buf, strlen(checkstr)+1) != 0) - { - Fail("ERROR: expected %s, got %s\n", checkstr, buf); - } - - - - if ((fclose( fp )) != 0) - - { - - Fail("ERROR: fclose failed to close \"%s\"\n", testfile); - - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test10/test10.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test10/test10.cpp deleted file mode 100644 index b94ee2e..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test10/test10.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test10.c (fprintf) -** -** Purpose: Tests the octal specifier (%o). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fprintf_test10_paltest_fprintf_test10, "c_runtime/fprintf/test10/paltest_fprintf_test10") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoNumTest("foo %o", pos, "foo 52"); - DoNumTest("foo %lo", 0xFFFF, "foo 177777"); - DoNumTest("foo %ho", 0xFFFF, "foo 177777"); - DoNumTest("foo %Lo", pos, "foo 52"); - DoI64Test("foo %I64o", l, "42", "foo 52", "foo 52"); - DoNumTest("foo %3o", pos, "foo 52"); - DoNumTest("foo %-3o", pos, "foo 52 "); - DoNumTest("foo %.1o", pos, "foo 52"); - DoNumTest("foo %.3o", pos, "foo 052"); - DoNumTest("foo %03o", pos, "foo 052"); - DoNumTest("foo %#o", pos, "foo 052"); - DoNumTest("foo %+o", pos, "foo 52"); - DoNumTest("foo % o", pos, "foo 52"); - DoNumTest("foo %+o", neg, "foo 37777777726"); - DoNumTest("foo % o", neg, "foo 37777777726"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test11/test11.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test11/test11.cpp deleted file mode 100644 index 4b987fc..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test11/test11.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test11.c (fprintf) -** -** Purpose: Test the unsigned int specifier (%u). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fprintf_test11_paltest_fprintf_test11, "c_runtime/fprintf/test11/paltest_fprintf_test11") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoNumTest("foo %u", pos, "foo 42"); - DoNumTest("foo %lu", 0xFFFF, "foo 65535"); - DoNumTest("foo %hu", 0xFFFF, "foo 65535"); - DoNumTest("foo %Lu", pos, "foo 42"); - DoI64Test("foo %I64u", l, "42", "foo 42", "foo 42"); - DoNumTest("foo %3u", pos, "foo 42"); - DoNumTest("foo %-3u", pos, "foo 42 "); - DoNumTest("foo %.1u", pos, "foo 42"); - DoNumTest("foo %.3u", pos, "foo 042"); - DoNumTest("foo %03u", pos, "foo 042"); - DoNumTest("foo %#u", pos, "foo 42"); - DoNumTest("foo %+u", pos, "foo 42"); - DoNumTest("foo % u", pos, "foo 42"); - DoNumTest("foo %+u", neg, "foo 4294967254"); - DoNumTest("foo % u", neg, "foo 4294967254"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test12/test12.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test12/test12.cpp deleted file mode 100644 index 368de69..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test12/test12.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test12.c -** -** Purpose: Tests the (lowercase) hexadecimal specifier (%x). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fprintf_test12_paltest_fprintf_test12, "c_runtime/fprintf/test12/paltest_fprintf_test12") -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoNumTest("foo %x", pos, "foo 1234ab"); - DoNumTest("foo %lx", pos, "foo 1234ab"); - DoNumTest("foo %hx", pos, "foo 34ab"); - DoNumTest("foo %Lx", pos, "foo 1234ab"); - DoI64Test("foo %I64x", l, "0x1234567887654321", - "foo 1234567887654321", "foo 0x1234567887654321"); - DoNumTest("foo %7x", pos, "foo 1234ab"); - DoNumTest("foo %-7x", pos, "foo 1234ab "); - DoNumTest("foo %.1x", pos, "foo 1234ab"); - DoNumTest("foo %.7x", pos, "foo 01234ab"); - DoNumTest("foo %07x", pos, "foo 01234ab"); - DoNumTest("foo %#x", pos, "foo 0x1234ab"); - DoNumTest("foo %+x", pos, "foo 1234ab"); - DoNumTest("foo % x", pos, "foo 1234ab"); - DoNumTest("foo %+x", neg, "foo ffffffd6"); - DoNumTest("foo % x", neg, "foo ffffffd6"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test13/test13.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test13/test13.cpp deleted file mode 100644 index 52cca2d..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test13/test13.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test13.c (fprintf) -** -** Purpose: Tests the (uppercase) hexadecimal specifier (%X). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fprintf_test13_paltest_fprintf_test13, "c_runtime/fprintf/test13/paltest_fprintf_test13") -{ - int neg = -42; - int pos = 0x1234AB; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoNumTest("foo %X", pos, "foo 1234AB"); - DoNumTest("foo %lX", pos, "foo 1234AB"); - DoNumTest("foo %hX", pos, "foo 34AB"); - DoNumTest("foo %LX", pos, "foo 1234AB"); - DoI64Test("foo %I64X", l, "0x1234567887654321", - "foo 1234567887654321", "foo 0x1234567887654321"); - DoNumTest("foo %7X", pos, "foo 1234AB"); - DoNumTest("foo %-7X", pos, "foo 1234AB "); - DoNumTest("foo %.1X", pos, "foo 1234AB"); - DoNumTest("foo %.7X", pos, "foo 01234AB"); - DoNumTest("foo %07X", pos, "foo 01234AB"); - DoNumTest("foo %#X", pos, "foo 0X1234AB"); - DoNumTest("foo %+X", pos, "foo 1234AB"); - DoNumTest("foo % X", pos, "foo 1234AB"); - DoNumTest("foo %+X", neg, "foo FFFFFFD6"); - DoNumTest("foo % X", neg, "foo FFFFFFD6"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test14/test14.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test14/test14.cpp deleted file mode 100644 index 2d230ac..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test14/test14.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test14.c (fprintf) -** -** Purpose: Tests the lowercase exponential -** notation double specifier (%e). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fprintf_test14_paltest_fprintf_test14, "c_runtime/fprintf/test14/paltest_fprintf_test14") -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoDoubleTest("foo %e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %he", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %Le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %I64e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %14e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %-14e", val, "foo 2.560000e+002 ", "foo 2.560000e+02 "); - DoDoubleTest("foo %.1e", val, "foo 2.6e+002", "foo 2.6e+02"); - DoDoubleTest("foo %.8e", val, "foo 2.56000000e+002", "foo 2.56000000e+02"); - DoDoubleTest("foo %014e", val, "foo 02.560000e+002", "foo 002.560000e+02"); - DoDoubleTest("foo %#e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", val, "foo +2.560000e+002", "foo +2.560000e+02"); - DoDoubleTest("foo % e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - DoDoubleTest("foo % e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test15/test15.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test15/test15.cpp deleted file mode 100644 index c5b1572..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test15/test15.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test15.c (fprintf) -** -** Purpose: Tests the uppercase exponential -** notation double specifier (%E). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fprintf_test15_paltest_fprintf_test15, "c_runtime/fprintf/test15/paltest_fprintf_test15") -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoDoubleTest("foo %E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %lE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %hE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %LE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %I64E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %14E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %-14E", val, "foo 2.560000E+002 ", "foo 2.560000E+02 "); - DoDoubleTest("foo %.1E", val, "foo 2.6E+002", "foo 2.6E+02"); - DoDoubleTest("foo %.8E", val, "foo 2.56000000E+002", "foo 2.56000000E+02"); - DoDoubleTest("foo %014E", val, "foo 02.560000E+002", "foo 002.560000E+02"); - DoDoubleTest("foo %#E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", val, "foo +2.560000E+002", "foo +2.560000E+02"); - DoDoubleTest("foo % E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - DoDoubleTest("foo % E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test16/test16.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test16/test16.cpp deleted file mode 100644 index fd56b5b..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test16/test16.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test16.c (fprintf) -** -** Purpose: Tests the decimal notation double specifier (%f). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fprintf_test16_paltest_fprintf_test16, "c_runtime/fprintf/test16/paltest_fprintf_test16") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoDoubleTest("foo %f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %hf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %Lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %I64f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %12f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %-12f", val, "foo 2560.001000 ", "foo 2560.001000 "); - DoDoubleTest("foo %.1f", val, "foo 2560.0", "foo 2560.0"); - DoDoubleTest("foo %.8f", val, "foo 2560.00100000", "foo 2560.00100000"); - DoDoubleTest("foo %012f", val, "foo 02560.001000", "foo 02560.001000"); - DoDoubleTest("foo %#f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", val, "foo +2560.001000", "foo +2560.001000"); - DoDoubleTest("foo % f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", neg, "foo -2560.001000", "foo -2560.001000"); - DoDoubleTest("foo % f", neg, "foo -2560.001000", "foo -2560.001000"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test17/test17.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test17/test17.cpp deleted file mode 100644 index e12048d..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test17/test17.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test17.c (fprintf) -** -** Purpose: Tests the lowercase shorthand notation double specifier (%g). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fprintf_test17_paltest_fprintf_test17, "c_runtime/fprintf/test17/paltest_fprintf_test17") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoDoubleTest("foo %g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %Lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5g", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1g", val, "foo 3e+003", "foo 3e+03"); - DoDoubleTest("foo %.2g", val, "foo 2.6e+003", "foo 2.6e+03"); - DoDoubleTest("foo %.12g", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06g", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#g", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+g", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+g", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % g", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test18/test18.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test18/test18.cpp deleted file mode 100644 index 62e4b66..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test18/test18.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test18.c (fprintf) -** -** Purpose: Tests the uppercase shorthand notation double specifier (%G). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fprintf_test18_paltest_fprintf_test18, "c_runtime/fprintf/test18/paltest_fprintf_test18") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoDoubleTest("foo %G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %LG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5G", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1G", val, "foo 3E+003", "foo 3E+03"); - DoDoubleTest("foo %.2G", val, "foo 2.6E+003", "foo 2.6E+03"); - DoDoubleTest("foo %.12G", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06G", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#G", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+G", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+G", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % G", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test19/test19.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test19/test19.cpp deleted file mode 100644 index 26a92db..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test19/test19.cpp +++ /dev/null @@ -1,152 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test19.c (fprintf) -** -** Purpose: Tests the variable length precision argument. -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -#define DOTEST(a,b,c,d,e,f) DoTest(a,b,(void*)c,d,e,f) - -void DoTest(char *formatstr, int precision, void *param, - char *paramstr, char *checkstr1, char *checkstr2) -{ - FILE *fp; - char buf[256]; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((fprintf(fp, formatstr, precision, param)) < 0) - { - Fail("ERROR: fprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fseek failed\n"); - } - - if (memcmp(buf, checkstr1, strlen(buf) + 1) != 0 && - memcmp(buf, checkstr2, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", paramstr, formatstr, - precision, - checkstr1, checkstr2, buf); - } - - if ((fclose( fp )) != 0) - - { - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - } - -} - -void DoublePrecTest(char *formatstr, int precision, - double param, char *checkstr1, char *checkstr2) -{ - FILE *fp; - char buf[256]; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((fprintf(fp, formatstr, precision, param)) < 0) - { - Fail("ERROR: fprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fseek failed\n"); - } - - if (memcmp(buf, checkstr1, strlen(buf) + 1) != 0 && - memcmp(buf, checkstr2, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - param, formatstr, precision, checkstr1, checkstr2, buf); - } - - if ((fclose( fp )) != 0) - { - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - } - -} - -PALTEST(c_runtime_fprintf_test19_paltest_fprintf_test19, "c_runtime/fprintf/test19/paltest_fprintf_test19") -{ - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DOTEST("%.*s", 2, "bar", "bar", "ba", "ba"); - DOTEST("%.*S", 2, convert("bar"), "bar", "ba", "ba"); - - //DOTEST("%.*n", 4, 2, "2", "0002"); - DOTEST("%.*c", 0, 'a', "a", "a", "a"); - DOTEST("%.*c", 4, 'a', "a", "a", "a"); - DOTEST("%.*C", 0, (WCHAR)'a', "a", "a", "a"); - DOTEST("%.*C", 4, (WCHAR)'a', "a", "a", "a"); - DOTEST("%.*d", 1, 42, "42", "42", "42"); - DOTEST("%.*d", 3, 42, "42", "042", "042"); - DOTEST("%.*i", 1, 42, "42", "42", "42"); - DOTEST("%.*i", 3, 42, "42", "042", "042"); - DOTEST("%.*o", 1, 42, "42", "52", "52"); - DOTEST("%.*o", 3, 42, "42", "052", "052"); - DOTEST("%.*u", 1, 42, "42", "42", "42"); - DOTEST("%.*u", 3, 42, "42", "042", "042"); - DOTEST("%.*x", 1, 0x42, "0x42", "42", "42"); - DOTEST("%.*x", 3, 0x42, "0x42", "042", "042"); - DOTEST("%.*X", 1, 0x42, "0x42", "42", "42"); - DOTEST("%.*X", 3, 0x42, "0x42", "042", "042"); - - - DoublePrecTest("%.*e", 1, 2.01, "2.0e+000", "2.0e+00"); - DoublePrecTest("%.*e", 3, 2.01, "2.010e+000", "2.010e+00"); - DoublePrecTest("%.*E", 1, 2.01, "2.0E+000", "2.0E+00"); - DoublePrecTest("%.*E", 3, 2.01, "2.010E+000", "2.010E+00"); - DoublePrecTest("%.*f", 1, 2.01, "2.0", "2.0"); - DoublePrecTest("%.*f", 3, 2.01, "2.010", "2.010"); - DoublePrecTest("%.*g", 1, 256.01, "3e+002", "3e+02"); - DoublePrecTest("%.*g", 3, 256.01, "256", "256"); - DoublePrecTest("%.*g", 4, 256.01, "256", "256"); - DoublePrecTest("%.*g", 6, 256.01, "256.01", "256.01"); - DoublePrecTest("%.*G", 1, 256.01, "3E+002", "3E+02"); - DoublePrecTest("%.*G", 3, 256.01, "256", "256"); - DoublePrecTest("%.*G", 4, 256.01, "256", "256"); - DoublePrecTest("%.*G", 6, 256.01, "256.01", "256.01"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test2/test2.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test2/test2.cpp deleted file mode 100644 index 8d08177..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test2/test2.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test2.c (fprintf) -** -** Purpose: Tests the string specifier (%s). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fprintf_test2_paltest_fprintf_test2, "c_runtime/fprintf/test2/paltest_fprintf_test2") -{ - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoStrTest("foo %s", "bar", "foo bar"); - DoStrTest("foo %hs", "bar", "foo bar"); - DoWStrTest("foo %ls", convert("bar"), "foo bar"); - DoWStrTest("foo %ws", convert("bar"), "foo bar"); - DoStrTest("foo %Ls", "bar", "foo bar"); - DoStrTest("foo %I64s", "bar", "foo bar"); - DoStrTest("foo %5s", "bar", "foo bar"); - DoStrTest("foo %.2s", "bar", "foo ba"); - DoStrTest("foo %5.2s", "bar", "foo ba"); - DoStrTest("foo %-5s", "bar", "foo bar "); - DoStrTest("foo %05s", "bar", "foo 00bar"); - DoStrTest("foo %s", NULL, "foo (null)"); - DoStrTest("foo %hs", NULL, "foo (null)"); - DoWStrTest("foo %ls", NULL, "foo (null)"); - DoWStrTest("foo %ws", NULL, "foo (null)"); - DoStrTest("foo %Ls", NULL, "foo (null)"); - DoStrTest("foo %I64s", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test3/test3.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test3/test3.cpp deleted file mode 100644 index 6f15aff..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test3/test3.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test3.c (fprintf) -** -** Purpose: Tests the wide string specifier (%S). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fprintf_test3_paltest_fprintf_test3, "c_runtime/fprintf/test3/paltest_fprintf_test3") -{ - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoWStrTest("foo %S", convert("bar"), "foo bar"); - DoStrTest("foo %hS", "bar", "foo bar"); - DoWStrTest("foo %lS", convert("bar"), "foo bar"); - DoWStrTest("foo %wS", convert("bar"), "foo bar"); - DoWStrTest("foo %LS", convert("bar"), "foo bar"); - DoWStrTest("foo %I64S", convert("bar"), "foo bar"); - DoWStrTest("foo %5S", convert("bar"), "foo bar"); - DoWStrTest("foo %.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %5.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %-5S", convert("bar"), "foo bar "); - DoWStrTest("foo %05S", convert("bar"), "foo 00bar"); - DoWStrTest("foo %S", NULL, "foo (null)"); - DoStrTest("foo %hS", NULL, "foo (null)"); - DoWStrTest("foo %lS", NULL, "foo (null)"); - DoWStrTest("foo %wS", NULL, "foo (null)"); - DoWStrTest("foo %LS", NULL, "foo (null)"); - DoWStrTest("foo %I64S", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test4/test4.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test4/test4.cpp deleted file mode 100644 index 2717de0..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test4/test4.cpp +++ /dev/null @@ -1,109 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test4.c (fprintf) -** -** Purpose: Tests the pointer specifier (%p). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -static void DoTest(char *formatstr, void* param, char* paramstr, - char *checkstr1, char *checkstr2) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((fprintf(fp, formatstr, param)) < 0) - { - Fail("ERROR: fprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fseek failed\n"); - } - - if (memcmp(buf, checkstr1, strlen(buf) + 1) != 0 && - memcmp(buf, checkstr2, strlen(buf) + 1) != 0 ) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\" or \"%s\" got \"%s\".\n", - paramstr, formatstr, checkstr1, checkstr2, buf); - } - - if ((fclose( fp )) != 0) - - { - - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - - } -} - - -PALTEST(c_runtime_fprintf_test4_paltest_fprintf_test4, "c_runtime/fprintf/test4/paltest_fprintf_test4") -{ - void *ptr = (void*) 0x123456; - INT64 lptr = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - -/* -** Run only on 64 bit platforms -*/ -#if defined(HOST_64BIT) - Trace("Testing for 64 Bit Platforms \n"); - DoTest("%p", NULL, "NULL", "0000000000000000", "0x0"); - DoTest("%p", ptr, "pointer to 0x123456", "0000000000123456", "0x123456"); - DoTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456", " 0x123456"); - DoTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456", "0x0123456"); - DoTest("%-17p", ptr, "pointer to 0x123456", "0000000000123456 ", "0x123456 "); - DoTest("%+p", ptr, "pointer to 0x123456", "0000000000123456", "0x123456"); - DoTest("%#p", ptr, "pointer to 0x123456", "0X0000000000123456", "0x123456"); - DoTest("%lp", ptr, "pointer to 0x123456", "00123456", "0x123456"); - DoTest("%hp", ptr, "pointer to 0x123456", "00003456", "0x3456"); - DoTest("%Lp", ptr, "pointer to 0x123456", "00123456", "0x123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321", "0x1234567887654321"); -#else - Trace("Testing for Non 64 Bit Platforms \n"); - DoTest("%p", NULL, "NULL", "00000000", "0x0"); - DoTest("%p", ptr, "pointer to 0x123456", "00123456", "0x123456"); - DoTest("%9p", ptr, "pointer to 0x123456", " 00123456", " 0x123456"); - DoTest("%09p", ptr, "pointer to 0x123456", " 00123456", "0x0123456"); - DoTest("%-9p", ptr, "pointer to 0x123456", "00123456 ", "0x123456 "); - DoTest("%+p", ptr, "pointer to 0x123456", "00123456", "0x123456"); - DoTest("%#p", ptr, "pointer to 0x123456", "0X00123456", "0x123456"); - DoTest("%lp", ptr, "pointer to 0x123456", "00123456", "0x123456"); - DoTest("%hp", ptr, "pointer to 0x123456", "00003456", "0x3456"); - DoTest("%Lp", ptr, "pointer to 0x123456", "00123456", "0x123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321", "0x1234567887654321"); -#endif - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test5/test5.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test5/test5.cpp deleted file mode 100644 index 1834f24..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test5/test5.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test5.c (fprintf) -** -** Purpose: Tests the count specifier (%n). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -static void DoTest(char *formatstr, int param, char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - int n = -1; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((fprintf(fp, formatstr, &n)) < 0) - { - Fail("ERROR: fprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fseek failed\n"); - } - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } - - - if ((fclose( fp )) != 0) - - { - - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - - } -} - -static void DoShortTest(char *formatstr, int param, char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - short int n = -1; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((fprintf(fp, formatstr, &n)) < 0) - { - Fail("ERROR: fprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fseek failed\n"); - } - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } - - if ((fclose( fp )) != 0) - { - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - } -} - -PALTEST(c_runtime_fprintf_test5_paltest_fprintf_test5, "c_runtime/fprintf/test5/paltest_fprintf_test5") -{ - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoTest("foo %n bar", 4, "foo bar"); - DoTest("foo %#n bar", 4, "foo bar"); - DoTest("foo % n bar", 4, "foo bar"); - DoTest("foo %+n bar", 4, "foo bar"); - DoTest("foo %-n bar", 4, "foo bar"); - DoTest("foo %0n bar", 4, "foo bar"); - DoShortTest("foo %hn bar", 4, "foo bar"); - DoTest("foo %ln bar", 4, "foo bar"); - DoTest("foo %Ln bar", 4, "foo bar"); - DoTest("foo %I64n bar", 4, "foo bar"); - DoTest("foo %20.3n bar", 4, "foo bar"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test6/test6.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test6/test6.cpp deleted file mode 100644 index 5cf185c..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test6/test6.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test6.c (fprintf) -** -** Purpose: Tests the char specifier (%c). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fprintf_test6_paltest_fprintf_test6, "c_runtime/fprintf/test6/paltest_fprintf_test6") -{ - WCHAR wc = (WCHAR) 'c'; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoCharTest("foo %c", 'b', "foo b"); - DoCharTest("foo %hc", 'b', "foo b"); - DoWCharTest("foo %lc", wc, "foo c"); - DoCharTest("foo %Lc", 'b', "foo b"); - DoCharTest("foo %I64c", 'b', "foo b"); - DoCharTest("foo %5c", 'b', "foo b"); - DoCharTest("foo %.0c", 'b', "foo b"); - DoCharTest("foo %-5c", 'b', "foo b "); - DoCharTest("foo %05c", 'b', "foo 0000b"); - DoCharTest("foo % c", 'b', "foo b"); - DoCharTest("foo %#c", 'b', "foo b"); - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test7/test7.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test7/test7.cpp deleted file mode 100644 index d81916c..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test7/test7.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test7.c (fprintf) -** -** Purpose: Tests the wide char specifier (%C). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fprintf_test7_paltest_fprintf_test7, "c_runtime/fprintf/test7/paltest_fprintf_test7") -{ - WCHAR wb = (WCHAR) 'b'; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoWCharTest("foo %C", wb, "foo b"); - DoWCharTest("foo %hC", wb, "foo b"); - DoCharTest("foo %lC", 'c', "foo c"); - DoWCharTest("foo %LC", wb, "foo b"); - DoWCharTest("foo %I64C", wb, "foo b"); - DoWCharTest("foo %5C", wb, "foo b"); - DoWCharTest("foo %.0C", wb, "foo b"); - DoWCharTest("foo %-5C", wb, "foo b "); - DoWCharTest("foo %05C", wb, "foo 0000b"); - DoWCharTest("foo % C", wb, "foo b"); - DoWCharTest("foo %#C", wb, "foo b"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test8/test8.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test8/test8.cpp deleted file mode 100644 index 3392aff..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test8/test8.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test8.c (fprintf) -** -** Purpose: Tests the decimal specifier (%d). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fprintf_test8_paltest_fprintf_test8, "c_runtime/fprintf/test8/paltest_fprintf_test8") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoNumTest("foo %d", pos, "foo 42"); - DoNumTest("foo %ld", 0xFFFF, "foo 65535"); - DoNumTest("foo %hd", 0xFFFF, "foo -1"); - DoNumTest("foo %Ld", pos, "foo 42"); - DoI64Test("foo %I64d", l, "42", "foo 42", "foo 42"); - DoNumTest("foo %3d", pos, "foo 42"); - DoNumTest("foo %-3d", pos, "foo 42 "); - DoNumTest("foo %.1d", pos, "foo 42"); - DoNumTest("foo %.3d", pos, "foo 042"); - DoNumTest("foo %03d", pos, "foo 042"); - DoNumTest("foo %#d", pos, "foo 42"); - DoNumTest("foo %+d", pos, "foo +42"); - DoNumTest("foo % d", pos, "foo 42"); - DoNumTest("foo %+d", neg, "foo -42"); - DoNumTest("foo % d", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test9/test9.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test9/test9.cpp deleted file mode 100644 index 7e42d5d..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test9/test9.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test9.c (fprintf) -** -** Purpose: Tests the integer specifier (%i). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fprintf_test9_paltest_fprintf_test9, "c_runtime/fprintf/test9/paltest_fprintf_test9") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoNumTest("foo %i", pos, "foo 42"); - DoNumTest("foo %li", 0xFFFF, "foo 65535"); - DoNumTest("foo %hi", 0xFFFF, "foo -1"); - DoNumTest("foo %Li", pos, "foo 42"); - DoI64Test("foo %I64i", l, "42", "foo 42", "foo 42"); - DoNumTest("foo %3i", pos, "foo 42"); - DoNumTest("foo %-3i", pos, "foo 42 "); - DoNumTest("foo %.1i", pos, "foo 42"); - DoNumTest("foo %.3i", pos, "foo 042"); - DoNumTest("foo %03i", pos, "foo 042"); - DoNumTest("foo %#i", pos, "foo 42"); - DoNumTest("foo %+i", pos, "foo +42"); - DoNumTest("foo % i", pos, "foo 42"); - DoNumTest("foo %+i", neg, "foo -42"); - DoNumTest("foo % i", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/printf/printf.h b/src/coreclr/pal/tests/palsuite/c_runtime/printf/printf.h deleted file mode 100644 index effc27f..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/printf/printf.h +++ /dev/null @@ -1,192 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: printf.h -** -** Purpose: Contains common testing functions for printf -** -** -**==========================================================================*/ - -#ifndef __printf_H__ -#define __printf_H__ - -inline void DoStrTest_printf(const char *formatstr, char* param, const char *checkstr) -{ - int ret; - - ret = printf(formatstr, param); - if (ret != strlen(checkstr)) - { - Fail("Expected printf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} -#define DoStrTest DoStrTest_printf - -inline void DoWStrTest_printf(const char *formatstr, WCHAR* param, const char *checkstr) -{ - int ret; - - ret = printf(formatstr, param); - if (ret != strlen(checkstr)) - { - Fail("Expected printf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} -#define DoWStrTest DoWStrTest_printf - -inline void DoPointerTest_printf(const char *formatstr, void* param, char* paramstr, - const char *checkstr1) -{ - int ret; - - ret = printf(formatstr, param); - if (ret != strlen(checkstr1)) - { - Fail("Expected printf to return %d, got %d.\n", - strlen(checkstr1), ret); - } -} -#define DoPointerTest DoPointerTest_printf - -inline void DoCountTest_printf(const char *formatstr, int param, const char *checkstr) -{ - int ret; - int n = -1; - - ret = printf(formatstr, &n); - - if (n != param) - { - Fail("Expected count parameter to resolve to %d, got %d\n", param, n); - } - - if (ret != strlen(checkstr)) - { - Fail("Expected printf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} -#define DoCountTest DoCountTest_printf - -inline void DoShortCountTest_printf(const char *formatstr, int param, const char *checkstr) -{ - int ret; - short int n = -1; - - ret = printf(formatstr, &n); - - if (n != param) - { - Fail("Expected count parameter to resolve to %d, got %d\n", param, n); - } - - if (ret != strlen(checkstr)) - { - Fail("Expected printf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} -#define DoShortCountTest DoShortCountTest_printf - -inline void DoCharTest_printf(const char *formatstr, char param, const char *checkstr) -{ - int ret; - - ret = printf(formatstr, param); - if (ret != strlen(checkstr)) - { - Fail("Expected printf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} -#define DoCharTest DoCharTest_printf - -inline void DoWCharTest_printf(const char *formatstr, WCHAR param, const char *checkstr) -{ - int ret; - - ret = printf(formatstr, param); - if (ret != strlen(checkstr)) - { - Fail("Expected printf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} -#define DoWCharTest DoWCharTest_printf - -inline void DoNumTest_printf(const char *formatstr, int param, const char *checkstr) -{ - int ret; - - ret = printf(formatstr, param); - if (ret != strlen(checkstr)) - { - Fail("Expected printf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} -#define DoNumTest DoNumTest_printf - -inline void DoI64Test_printf(const char *formatstr, INT64 param, char *valuestr, - const char *checkstr1) -{ - int ret; - - ret = printf(formatstr, param); - if (ret != strlen(checkstr1)) - { - Fail("Expected printf to return %d, got %d.\n", - strlen(checkstr1), ret); - } -} -#define DoI64Test DoI64Test_printf - -inline void DoDoubleTest_printf(const char *formatstr, double param, - const char *checkstr1, const char *checkstr2) -{ - int ret; - - ret = printf(formatstr, param); - if (ret != strlen(checkstr1) && ret != strlen(checkstr2)) - { - Fail("Expected printf to return %d or %d, got %d.\n", - strlen(checkstr1), strlen(checkstr2), ret); - } -} -#define DoDoubleTest DoDoubleTest_printf - -inline void DoArgumentPrecTest_printf(const char *formatstr, int precision, void *param, - char *paramstr, const char *checkstr1, const char *checkstr2) -{ - int ret; - - ret = printf(formatstr, precision, param); - if (ret != strlen(checkstr1) && ret != strlen(checkstr2)) - { - Fail("Expected printf to return %d or %d, got %d.\n", - strlen(checkstr1), strlen(checkstr2), ret); - } -} -#define DoArgumentPrecTest DoArgumentPrecTest_printf - -inline void DoArgumentPrecDoubleTest_printf(const char *formatstr, int precision, double param, - const char *checkstr1, const char *checkstr2) -{ - int ret; - - ret = printf(formatstr, precision, param); - if (ret != strlen(checkstr1) && ret != strlen(checkstr2)) - { - Fail("Expected printf to return %d or %d, got %d.\n", - strlen(checkstr1), strlen(checkstr2), ret); - } -} -#define DoArgumentPrecDoubleTest DoArgumentPrecDoubleTest_printf - -#endif - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/printf/test1/test1.cpp deleted file mode 100644 index 6523995..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test1/test1.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Test #1 for the printf function. A single, basic, test -** case with no formatting. -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - -PALTEST(c_runtime_printf_test1_paltest_printf_test1, "c_runtime/printf/test1/paltest_printf_test1") -{ - char checkstr[] = "hello world"; - int ret; - - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - ret = printf("hello world"); - - if (ret != strlen(checkstr)) - { - Fail("Expected printf to return %d, got %d.\n", - strlen(checkstr), ret); - - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test10/test10.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/printf/test10/test10.cpp deleted file mode 100644 index acad705..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test10/test10.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test10.c -** -** Purpose: Test #10 for the printf function. Tests the octal specifier -** (%o). -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - -PALTEST(c_runtime_printf_test10_paltest_printf_test10, "c_runtime/printf/test10/paltest_printf_test10") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %o", pos, "foo 52"); - DoNumTest("foo %lo", 0xFFFF, "foo 177777"); - DoNumTest("foo %ho", 0xFFFF, "foo 177777"); - DoNumTest("foo %Lo", pos, "foo 52"); - DoI64Test("foo %I64o", l, "42", "foo 52"); - DoNumTest("foo %3o", pos, "foo 52"); - DoNumTest("foo %-3o", pos, "foo 52 "); - DoNumTest("foo %.1o", pos, "foo 52"); - DoNumTest("foo %.3o", pos, "foo 052"); - DoNumTest("foo %03o", pos, "foo 052"); - DoNumTest("foo %#o", pos, "foo 052"); - DoNumTest("foo %+o", pos, "foo 52"); - DoNumTest("foo % o", pos, "foo 52"); - DoNumTest("foo %+o", neg, "foo 37777777726"); - DoNumTest("foo % o", neg, "foo 37777777726"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test11/test11.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/printf/test11/test11.cpp deleted file mode 100644 index 36dbdf3..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test11/test11.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test11.c -** -** Purpose: Test #11 for the printf function. Test the unsigned int -** specifier (%u). -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - -PALTEST(c_runtime_printf_test11_paltest_printf_test11, "c_runtime/printf/test11/paltest_printf_test11") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %u", pos, "foo 42"); - DoNumTest("foo %lu", 0xFFFF, "foo 65535"); - DoNumTest("foo %hu", 0xFFFF, "foo 65535"); - DoNumTest("foo %Lu", pos, "foo 42"); - DoI64Test("foo %I64u", l, "42", "foo 42"); - DoNumTest("foo %3u", pos, "foo 42"); - DoNumTest("foo %-3u", pos, "foo 42 "); - DoNumTest("foo %.1u", pos, "foo 42"); - DoNumTest("foo %.3u", pos, "foo 042"); - DoNumTest("foo %03u", pos, "foo 042"); - DoNumTest("foo %#u", pos, "foo 42"); - DoNumTest("foo %+u", pos, "foo 42"); - DoNumTest("foo % u", pos, "foo 42"); - DoNumTest("foo %+u", neg, "foo 4294967254"); - DoNumTest("foo % u", neg, "foo 4294967254"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test12/test12.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/printf/test12/test12.cpp deleted file mode 100644 index 5d6ed79..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test12/test12.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test12.c -** -** Purpose: Test #12 for the printf function. Tests the (lowercase) -** hexadecimal specifier (%x) -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - -PALTEST(c_runtime_printf_test12_paltest_printf_test12, "c_runtime/printf/test12/paltest_printf_test12") -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %x", pos, "foo 1234ab"); - DoNumTest("foo %lx", pos, "foo 1234ab"); - DoNumTest("foo %hx", pos, "foo 34ab"); - DoNumTest("foo %Lx", pos, "foo 1234ab"); - DoI64Test("foo %I64x", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7x", pos, "foo 1234ab"); - DoNumTest("foo %-7x", pos, "foo 1234ab "); - DoNumTest("foo %.1x", pos, "foo 1234ab"); - DoNumTest("foo %.7x", pos, "foo 01234ab"); - DoNumTest("foo %07x", pos, "foo 01234ab"); - DoNumTest("foo %#x", pos, "foo 0x1234ab"); - DoNumTest("foo %+x", pos, "foo 1234ab"); - DoNumTest("foo % x", pos, "foo 1234ab"); - DoNumTest("foo %+x", neg, "foo ffffffd6"); - DoNumTest("foo % x", neg, "foo ffffffd6"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test13/test13.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/printf/test13/test13.cpp deleted file mode 100644 index dbda8dc..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test13/test13.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test13.c -** -** Purpose: Test #13 for the printf function. Tests the (uppercase) -** hexadecimal specifier (%X) -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - - -PALTEST(c_runtime_printf_test13_paltest_printf_test13, "c_runtime/printf/test13/paltest_printf_test13") -{ - int neg = -42; - int pos = 0x1234AB; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %X", pos, "foo 1234AB"); - DoNumTest("foo %lX", pos, "foo 1234AB"); - DoNumTest("foo %hX", pos, "foo 34AB"); - DoNumTest("foo %LX", pos, "foo 1234AB"); - DoI64Test("foo %I64X", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7X", pos, "foo 1234AB"); - DoNumTest("foo %-7X", pos, "foo 1234AB "); - DoNumTest("foo %.1X", pos, "foo 1234AB"); - DoNumTest("foo %.7X", pos, "foo 01234AB"); - DoNumTest("foo %07X", pos, "foo 01234AB"); - DoNumTest("foo %#X", pos, "foo 0X1234AB"); - DoNumTest("foo %+X", pos, "foo 1234AB"); - DoNumTest("foo % X", pos, "foo 1234AB"); - DoNumTest("foo %+X", neg, "foo FFFFFFD6"); - DoNumTest("foo % X", neg, "foo FFFFFFD6"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test14/test14.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/printf/test14/test14.cpp deleted file mode 100644 index dcfa4a5..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test14/test14.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test14.c -** -** Purpose: Test #14 for the printf function. Tests the lowercase -** exponential notation double specifier (%e) -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - - -PALTEST(c_runtime_printf_test14_paltest_printf_test14, "c_runtime/printf/test14/paltest_printf_test14") -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %he", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %Le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %I64e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %14e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %-14e", val, "foo 2.560000e+002 ", - "foo 2.560000e+02 "); - DoDoubleTest("foo %.1e", val, "foo 2.6e+002", "foo 2.6e+02"); - DoDoubleTest("foo %.8e", val, "foo 2.56000000e+002", - "foo 2.56000000e+02"); - DoDoubleTest("foo %014e", val, "foo 02.560000e+002", - "foo 002.560000e+02"); - DoDoubleTest("foo %#e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", val, "foo +2.560000e+002", "foo +2.560000e+02"); - DoDoubleTest("foo % e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - DoDoubleTest("foo % e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test15/test15.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/printf/test15/test15.cpp deleted file mode 100644 index a53c4a4..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test15/test15.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test15.c -** -** Purpose: Test #15 for the printf function. Tests the uppercase -** exponential notation double specifier (%E) -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - - -PALTEST(c_runtime_printf_test15_paltest_printf_test15, "c_runtime/printf/test15/paltest_printf_test15") -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %lE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %hE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %LE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %I64E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %14E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %-14E", val, "foo 2.560000E+002 ", - "foo 2.560000E+02 "); - DoDoubleTest("foo %.1E", val, "foo 2.6E+002", "foo 2.6E+02"); - DoDoubleTest("foo %.8E", val, "foo 2.56000000E+002", - "foo 2.56000000E+02"); - DoDoubleTest("foo %014E", val, "foo 02.560000E+002", - "foo 002.560000E+02"); - DoDoubleTest("foo %#E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", val, "foo +2.560000E+002", "foo +2.560000E+02"); - DoDoubleTest("foo % E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - DoDoubleTest("foo % E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test16/test16.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/printf/test16/test16.cpp deleted file mode 100644 index a2fbc42..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test16/test16.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test16.c -** -** Purpose: Test #16 for the printf function. Tests the decimal notation -** double specifier (%f) -** -** -**==========================================================================*/ - - -#include -#include "../printf.h" - - - -PALTEST(c_runtime_printf_test16_paltest_printf_test16, "c_runtime/printf/test16/paltest_printf_test16") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %hf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %Lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %I64f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %12f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %-12f", val, "foo 2560.001000 ", "foo 2560.001000 "); - DoDoubleTest("foo %.1f", val, "foo 2560.0", "foo 2560.0"); - DoDoubleTest("foo %.8f", val, "foo 2560.00100000", "foo 2560.00100000"); - DoDoubleTest("foo %012f", val, "foo 02560.001000", "foo 02560.001000"); - DoDoubleTest("foo %#f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", val, "foo +2560.001000", "foo +2560.001000"); - DoDoubleTest("foo % f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", neg, "foo -2560.001000", "foo -2560.001000"); - DoDoubleTest("foo % f", neg, "foo -2560.001000", "foo -2560.001000"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test17/test17.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/printf/test17/test17.cpp deleted file mode 100644 index 70a574a..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test17/test17.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test17.c -** -** Purpose: Test #17 for the printf function. Tests the lowercase -** shorthand notation double specifier (%g) -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - - -PALTEST(c_runtime_printf_test17_paltest_printf_test17, "c_runtime/printf/test17/paltest_printf_test17") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %Lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5g", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1g", val, "foo 3e+003", "foo 3e+03"); - DoDoubleTest("foo %.2g", val, "foo 2.6e+003", "foo 2.6e+03"); - DoDoubleTest("foo %.12g", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06g", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#g", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+g", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+g", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % g", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test18/test18.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/printf/test18/test18.cpp deleted file mode 100644 index 17e9aab..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test18/test18.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test18.c -** -** Purpose: Test #18 for the printf function. Tests the uppercase -** shorthand notation double specifier (%G) -** -** -**==========================================================================*/ - - -#include -#include "../printf.h" - - - -PALTEST(c_runtime_printf_test18_paltest_printf_test18, "c_runtime/printf/test18/paltest_printf_test18") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %LG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5G", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1G", val, "foo 3E+003", "foo 3E+03"); - DoDoubleTest("foo %.2G", val, "foo 2.6E+003", "foo 2.6E+03"); - DoDoubleTest("foo %.12G", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06G", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#G", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+G", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+G", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % G", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test19/test19.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/printf/test19/test19.cpp deleted file mode 100644 index d70aad2..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test19/test19.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test19.c -** -** Purpose: Test #19 for the printf function. Tests the variable length -** precision argument. -** -** -**==========================================================================*/ - - -#include -#include "../printf.h" - - - - -PALTEST(c_runtime_printf_test19_paltest_printf_test19, "c_runtime/printf/test19/paltest_printf_test19") -{ - int n = -1; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - 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"); - DoArgumentPrecTest("%.*C", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*d", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*d", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*i", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*i", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*o", 1, (void*)42, "42", "52", "52"); - DoArgumentPrecTest("%.*o", 3, (void*)42, "42", "052", "052"); - DoArgumentPrecTest("%.*u", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*u", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*x", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*x", 3, (void*)0x42, "0x42", "042", "042"); - DoArgumentPrecTest("%.*X", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*X", 3, (void*)0x42, "0x42", "042", "042"); - - - DoArgumentPrecDoubleTest("%.*e", 1, 2.01, "2.0e+000", "2.0e+00"); - DoArgumentPrecDoubleTest("%.*e", 3, 2.01, "2.010e+000", "2.010e+00"); - DoArgumentPrecDoubleTest("%.*E", 1, 2.01, "2.0E+000", "2.0E+00"); - DoArgumentPrecDoubleTest("%.*E", 3, 2.01, "2.010E+000", "2.010E+00"); - DoArgumentPrecDoubleTest("%.*f", 1, 2.01, "2.0", "2.0"); - DoArgumentPrecDoubleTest("%.*f", 3, 2.01, "2.010", "2.010"); - DoArgumentPrecDoubleTest("%.*g", 1, 256.01, "3e+002", "3e+02"); - DoArgumentPrecDoubleTest("%.*g", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 6, 256.01, "256.01", "256.01"); - DoArgumentPrecDoubleTest("%.*G", 1, 256.01, "3E+002", "3E+02"); - DoArgumentPrecDoubleTest("%.*G", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 6, 256.01, "256.01", "256.01"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test2/test2.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/printf/test2/test2.cpp deleted file mode 100644 index b32f36d..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test2/test2.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Test #2 for the printf function. Tests the string specifier -** (%s). -** -** -**==========================================================================*/ - - -#include -#include "../printf.h" - - - -PALTEST(c_runtime_printf_test2_paltest_printf_test2, "c_runtime/printf/test2/paltest_printf_test2") -{ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoStrTest("foo %s", "bar", "foo bar"); - DoStrTest("foo %hs", "bar", "foo bar"); - DoWStrTest("foo %ls", convert("bar"), "foo bar"); - DoWStrTest("foo %ws", convert("bar"), "foo bar"); - DoStrTest("foo %Ls", "bar", "foo bar"); - DoStrTest("foo %I64s", "bar", "foo bar"); - DoStrTest("foo %5s", "bar", "foo bar"); - DoStrTest("foo %.2s", "bar", "foo ba"); - DoStrTest("foo %5.2s", "bar", "foo ba"); - DoStrTest("foo %-5s", "bar", "foo bar "); - DoStrTest("foo %05s", "bar", "foo 00bar"); - DoStrTest("foo %s", NULL, "foo (null)"); - DoStrTest("foo %hs", NULL, "foo (null)"); - DoWStrTest("foo %ls", NULL, "foo (null)"); - DoWStrTest("foo %ws", NULL, "foo (null)"); - DoStrTest("foo %Ls", NULL, "foo (null)"); - DoStrTest("foo %I64s", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test3/test3.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/printf/test3/test3.cpp deleted file mode 100644 index b7ff6bf..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test3/test3.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test3.c -** -** Purpose: Test #3 for the printf function. Tests the wide string -** specifier (%S). -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - - -PALTEST(c_runtime_printf_test3_paltest_printf_test3, "c_runtime/printf/test3/paltest_printf_test3") -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoWStrTest("foo %S", convert("bar"), "foo bar"); - DoStrTest("foo %hS", "bar", "foo bar"); - DoWStrTest("foo %lS", convert("bar"), "foo bar"); - DoWStrTest("foo %wS", convert("bar"), "foo bar"); - DoWStrTest("foo %LS", convert("bar"), "foo bar"); - DoWStrTest("foo %I64S", convert("bar"), "foo bar"); - DoWStrTest("foo %5S", convert("bar"), "foo bar"); - DoWStrTest("foo %.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %5.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %-5S", convert("bar"), "foo bar "); - DoWStrTest("foo %05S", convert("bar"), "foo 00bar"); - DoWStrTest("foo %S", NULL, "foo (null)"); - DoStrTest("foo %hS", NULL, "foo (null)"); - DoWStrTest("foo %lS", NULL, "foo (null)"); - DoWStrTest("foo %wS", NULL, "foo (null)"); - DoWStrTest("foo %LS", NULL, "foo (null)"); - DoWStrTest("foo %I64S", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test4/test4.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/printf/test4/test4.cpp deleted file mode 100644 index 5073087..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test4/test4.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test4.c -** -** Purpose: Test #4 for the printf function. Tests the pointer -** specifier (%p). -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - -PALTEST(c_runtime_printf_test4_paltest_printf_test4, "c_runtime/printf/test4/paltest_printf_test4") -{ - void *ptr = (void*) 0x123456; - INT64 lptr = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } -/* -** Run only on 64 bit platforms -*/ -#if defined(HOST_64BIT) - Trace("Testing for 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "0000000000000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%-17p", ptr, "pointer to 0x123456", "0000000000123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X0000000000123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); -#else - Trace("Testing for Non 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "00000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%9p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%09p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%-9p", ptr, "pointer to 0x123456", "00123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X00123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); - -#endif - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test5/test5.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/printf/test5/test5.cpp deleted file mode 100644 index 15e806b..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test5/test5.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test5.c -** -** Purpose: Test #5 for the printf function. Tests the count specifier (%n). -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - - - -PALTEST(c_runtime_printf_test5_paltest_printf_test5, "c_runtime/printf/test5/paltest_printf_test5") -{ - 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)) - { - 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; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test6/test6.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/printf/test6/test6.cpp deleted file mode 100644 index 8ba3d68..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test6/test6.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test6.c -** -** Purpose: Test #6 for the printf function. Tests the char specifier (%c). -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - - -PALTEST(c_runtime_printf_test6_paltest_printf_test6, "c_runtime/printf/test6/paltest_printf_test6") -{ - WCHAR wc = (WCHAR) 'c'; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoCharTest("foo %c", 'b', "foo b"); - DoCharTest("foo %hc", 'b', "foo b"); - DoWCharTest("foo %lc", wc, "foo c"); - DoCharTest("foo %Lc", 'b', "foo b"); - DoCharTest("foo %I64c", 'b', "foo b"); - DoCharTest("foo %5c", 'b', "foo b"); - DoCharTest("foo %.0c", 'b', "foo b"); - DoCharTest("foo %-5c", 'b', "foo b "); - DoCharTest("foo %05c", 'b', "foo 0000b"); - DoCharTest("foo % c", 'b', "foo b"); - DoCharTest("foo %#c", 'b', "foo b"); - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test7/test7.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/printf/test7/test7.cpp deleted file mode 100644 index 1e34f0a..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test7/test7.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test7.c -** -** Purpose: Test #7 for the printf function. Tests the wide char -** specifier (%C). -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - - -PALTEST(c_runtime_printf_test7_paltest_printf_test7, "c_runtime/printf/test7/paltest_printf_test7") -{ - WCHAR wb = (WCHAR) 'b'; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoWCharTest("foo %C", wb, "foo b"); - DoWCharTest("foo %hC", wb, "foo b"); - DoCharTest("foo %lC", 'c', "foo c"); - DoWCharTest("foo %LC", wb, "foo b"); - DoWCharTest("foo %I64C", wb, "foo b"); - DoWCharTest("foo %5C", wb, "foo b"); - DoWCharTest("foo %.0C", wb, "foo b"); - DoWCharTest("foo %-5C", wb, "foo b "); - DoWCharTest("foo %05C", wb, "foo 0000b"); - DoWCharTest("foo % C", wb, "foo b"); - DoWCharTest("foo %#C", wb, "foo b"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test8/test8.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/printf/test8/test8.cpp deleted file mode 100644 index 7b93fda..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test8/test8.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test8.c -** -** Purpose: Test #8 for the printf function. Tests the decimal -** specifier (%d). -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - - -PALTEST(c_runtime_printf_test8_paltest_printf_test8, "c_runtime/printf/test8/paltest_printf_test8") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %d", pos, "foo 42"); - DoNumTest("foo %ld", 0xFFFF, "foo 65535"); - DoNumTest("foo %hd", 0xFFFF, "foo -1"); - DoNumTest("foo %Ld", pos, "foo 42"); - DoI64Test("foo %I64d", l, "42", "foo 42"); - DoNumTest("foo %3d", pos, "foo 42"); - DoNumTest("foo %-3d", pos, "foo 42 "); - DoNumTest("foo %.1d", pos, "foo 42"); - DoNumTest("foo %.3d", pos, "foo 042"); - DoNumTest("foo %03d", pos, "foo 042"); - DoNumTest("foo %#d", pos, "foo 42"); - DoNumTest("foo %+d", pos, "foo +42"); - DoNumTest("foo % d", pos, "foo 42"); - DoNumTest("foo %+d", neg, "foo -42"); - DoNumTest("foo % d", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test9/test9.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/printf/test9/test9.cpp deleted file mode 100644 index 00de8a2..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/printf/test9/test9.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test9.c -** -** Purpose: Test #9 for the printf function. Tests the integer -** specifier (%i). -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - - -PALTEST(c_runtime_printf_test9_paltest_printf_test9, "c_runtime/printf/test9/paltest_printf_test9") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %i", pos, "foo 42"); - DoNumTest("foo %li", 0xFFFF, "foo 65535"); - DoNumTest("foo %hi", 0xFFFF, "foo -1"); - DoNumTest("foo %Li", pos, "foo 42"); - DoI64Test("foo %I64i", l, "42", "foo 42"); - DoNumTest("foo %3i", pos, "foo 42"); - DoNumTest("foo %-3i", pos, "foo 42 "); - DoNumTest("foo %.1i", pos, "foo 42"); - DoNumTest("foo %.3i", pos, "foo 042"); - DoNumTest("foo %03i", pos, "foo 042"); - DoNumTest("foo %#i", pos, "foo 42"); - DoNumTest("foo %+i", pos, "foo +42"); - DoNumTest("foo % i", pos, "foo 42"); - DoNumTest("foo %+i", neg, "foo -42"); - DoNumTest("foo % i", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/sprintf_s.h b/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/sprintf_s.h deleted file mode 100644 index 701c67e..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/sprintf_s.h +++ /dev/null @@ -1,205 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: sprintf_s.h -** -** Purpose: Contains common testing functions for sprintf_s -** -** -**==========================================================================*/ - -#ifndef __SPRINTF_S_H__ -#define __SPRINTF_S_H__ - -inline void DoStrTest_sprintf_s(const char *formatstr, char* param, const char *checkstr) -{ - char buf[256] = { 0 }; - - sprintf_s(buf, ARRAY_SIZE(buf), formatstr, param); - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert string \"%s\" into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, formatstr, checkstr, buf); - } -} -#define DoStrTest DoStrTest_sprintf_s - -inline void DoWStrTest_sprintf_s(const char *formatstr, WCHAR* param, const char *checkstr) -{ - char buf[256] = { 0 }; - - sprintf_s(buf, ARRAY_SIZE(buf), formatstr, param); - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert wide string \"%s\" into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - convertC(param), formatstr, checkstr, buf); - } -} -#define DoWStrTest DoWStrTest_sprintf_s - -inline void DoPointerTest_sprintf_s(const char *formatstr, void* param, char* paramstr, - const char *checkstr1) -{ - char buf[256] = { 0 }; - - sprintf_s(buf, ARRAY_SIZE(buf), formatstr, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - paramstr, formatstr, checkstr1, buf); - } -} -#define DoPointerTest DoPointerTest_sprintf_s - -inline void DoCountTest_sprintf_s(const char *formatstr, int param, const char *checkstr) -{ - char buf[512] = { 0 }; - int n = -1; - - sprintf_s(buf, ARRAY_SIZE(buf), formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } -} -#define DoCountTest DoCountTest_sprintf_s - -inline void DoShortCountTest_sprintf_s(const char *formatstr, int param, const char *checkstr) -{ - char buf[256] = { 0 }; - short int n = -1; - - sprintf_s(buf, ARRAY_SIZE(buf), formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } -} -#define DoShortCountTest DoShortCountTest_sprintf_s - -inline void DoCharTest_sprintf_s(const char *formatstr, char param, const char *checkstr) -{ - char buf[256] = { 0 }; - - sprintf_s(buf, ARRAY_SIZE(buf), formatstr, param); - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, param, formatstr, checkstr, buf); - } -} -#define DoCharTest DoCharTest_sprintf_s - -inline void DoWCharTest_sprintf_s(const char *formatstr, WCHAR param, const char *checkstr) -{ - char buf[256] = { 0 }; - - sprintf_s(buf, ARRAY_SIZE(buf), formatstr, param); - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - (char)param, param, formatstr, checkstr, buf); - } -} -#define DoWCharTest DoWCharTest_sprintf_s - -inline void DoNumTest_sprintf_s(const char *formatstr, int value, const char *checkstr) -{ - char buf[256] = { 0 }; - - sprintf_s(buf, ARRAY_SIZE(buf), formatstr, value); - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert %#x into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - value, formatstr, checkstr, buf); - } -} -#define DoNumTest DoNumTest_sprintf_s - -inline void DoI64Test_sprintf_s(const char *formatstr, INT64 value, char *valuestr, const char *checkstr1) -{ - char buf[256] = { 0 }; - - sprintf_s(buf, ARRAY_SIZE(buf), formatstr, value); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\", got \"%s\".\n", - valuestr, formatstr, checkstr1, buf); - } -} -#define DoI64Test DoI64Test_sprintf_s - -inline void DoDoubleTest_sprintf_s(const char *formatstr, double value, const char *checkstr1, - const char *checkstr2) -{ - char buf[256] = { 0 }; - - sprintf_s(buf, ARRAY_SIZE(buf), formatstr, value); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\"\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - value, formatstr, checkstr1, checkstr2, buf); - } -} -#define DoDoubleTest DoDoubleTest_sprintf_s - -inline void DoArgumentPrecTest_sprintf_s(const char *formatstr, int precision, void *param, - char *paramstr, const char *checkstr1, const char *checkstr2) -{ - char buf[256]; - - sprintf_s(buf, ARRAY_SIZE(buf), formatstr, precision, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", paramstr, formatstr, - precision, checkstr1, checkstr2, buf); - } - -} -#define DoArgumentPrecTest DoArgumentPrecTest_sprintf_s - -inline void DoArgumentPrecDoubleTest_sprintf_s(const char *formatstr, int precision, double param, - const char *checkstr1, const char *checkstr2) -{ - char buf[256]; - - sprintf_s(buf, ARRAY_SIZE(buf), formatstr, precision, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", param, formatstr, - precision, checkstr1, checkstr2, buf); - } - -} -#define DoArgumentPrecDoubleTest DoArgumentPrecDoubleTest_sprintf_s - -#endif - - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test1/test1.cpp deleted file mode 100644 index 6cc7fe4..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test1/test1.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Test #1 for the sprintf_s function. A single, basic, test -** case with no formatting. -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -PALTEST(c_runtime_sprintf_s_test1_paltest_sprintf_test1, "c_runtime/sprintf_s/test1/paltest_sprintf_test1") -{ - char checkstr[] = "hello world"; - char buf[256]; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - sprintf_s(buf, ARRAY_SIZE(buf), "hello world"); - - if (memcmp(checkstr, buf, strlen(checkstr)+1) != 0) - { - Fail("ERROR: expected %s, got %s\n", checkstr, buf); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test10/test10.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test10/test10.cpp deleted file mode 100644 index 915fae9..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test10/test10.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test10.c -** -** Purpose: Test #10 for the sprintf_s function. Tests the octal specifier -** (%o). -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -PALTEST(c_runtime_sprintf_s_test10_paltest_sprintf_test10, "c_runtime/sprintf_s/test10/paltest_sprintf_test10") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %o", pos, "foo 52"); - DoNumTest("foo %lo", 0xFFFF, "foo 177777"); - DoNumTest("foo %ho", 0xFFFF, "foo 177777"); - DoNumTest("foo %Lo", pos, "foo 52"); - DoI64Test("foo %I64o", l, "42", "foo 52"); - DoNumTest("foo %3o", pos, "foo 52"); - DoNumTest("foo %-3o", pos, "foo 52 "); - DoNumTest("foo %.1o", pos, "foo 52"); - DoNumTest("foo %.3o", pos, "foo 052"); - DoNumTest("foo %03o", pos, "foo 052"); - DoNumTest("foo %#o", pos, "foo 052"); - DoNumTest("foo %+o", pos, "foo 52"); - DoNumTest("foo % o", pos, "foo 52"); - DoNumTest("foo %+o", neg, "foo 37777777726"); - DoNumTest("foo % o", neg, "foo 37777777726"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test11/test11.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test11/test11.cpp deleted file mode 100644 index 4ce47e7..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test11/test11.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test11.c -** -** Purpose: Test #11 for the sprintf_s function. Test the unsigned int -** specifier (%u). -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -PALTEST(c_runtime_sprintf_s_test11_paltest_sprintf_test11, "c_runtime/sprintf_s/test11/paltest_sprintf_test11") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %u", pos, "foo 42"); - DoNumTest("foo %lu", 0xFFFF, "foo 65535"); - DoNumTest("foo %hu", 0xFFFF, "foo 65535"); - DoNumTest("foo %Lu", pos, "foo 42"); - DoI64Test("foo %I64u", l, "42", "foo 42"); - DoNumTest("foo %3u", pos, "foo 42"); - DoNumTest("foo %-3u", pos, "foo 42 "); - DoNumTest("foo %.1u", pos, "foo 42"); - DoNumTest("foo %.3u", pos, "foo 042"); - DoNumTest("foo %03u", pos, "foo 042"); - DoNumTest("foo %#u", pos, "foo 42"); - DoNumTest("foo %+u", pos, "foo 42"); - DoNumTest("foo % u", pos, "foo 42"); - DoNumTest("foo %+u", neg, "foo 4294967254"); - DoNumTest("foo % u", neg, "foo 4294967254"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test12/test12.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test12/test12.cpp deleted file mode 100644 index b41cf9b..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test12/test12.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test12.c -** -** Purpose: Test #12 for the sprintf_s function. Tests the (lowercase) -** hexadecimal specifier (%x) -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -PALTEST(c_runtime_sprintf_s_test12_paltest_sprintf_test12, "c_runtime/sprintf_s/test12/paltest_sprintf_test12") -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %x", pos, "foo 1234ab"); - DoNumTest("foo %lx", pos, "foo 1234ab"); - DoNumTest("foo %hx", pos, "foo 34ab"); - DoNumTest("foo %Lx", pos, "foo 1234ab"); - DoI64Test("foo %I64x", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7x", pos, "foo 1234ab"); - DoNumTest("foo %-7x", pos, "foo 1234ab "); - DoNumTest("foo %.1x", pos, "foo 1234ab"); - DoNumTest("foo %.7x", pos, "foo 01234ab"); - DoNumTest("foo %07x", pos, "foo 01234ab"); - DoNumTest("foo %#x", pos, "foo 0x1234ab"); - DoNumTest("foo %+x", pos, "foo 1234ab"); - DoNumTest("foo % x", pos, "foo 1234ab"); - DoNumTest("foo %+x", neg, "foo ffffffd6"); - DoNumTest("foo % x", neg, "foo ffffffd6"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test13/test13.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test13/test13.cpp deleted file mode 100644 index be0ba07..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test13/test13.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test13.c -** -** Purpose: Test #13 for the sprintf_s function. Tests the (uppercase) -** hexadecimal specifier (%X) -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -PALTEST(c_runtime_sprintf_s_test13_paltest_sprintf_test13, "c_runtime/sprintf_s/test13/paltest_sprintf_test13") -{ - int neg = -42; - int pos = 0x1234AB; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %X", pos, "foo 1234AB"); - DoNumTest("foo %lX", pos, "foo 1234AB"); - DoNumTest("foo %hX", pos, "foo 34AB"); - DoNumTest("foo %LX", pos, "foo 1234AB"); - DoI64Test("foo %I64X", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7X", pos, "foo 1234AB"); - DoNumTest("foo %-7X", pos, "foo 1234AB "); - DoNumTest("foo %.1X", pos, "foo 1234AB"); - DoNumTest("foo %.7X", pos, "foo 01234AB"); - DoNumTest("foo %07X", pos, "foo 01234AB"); - DoNumTest("foo %#X", pos, "foo 0X1234AB"); - DoNumTest("foo %+X", pos, "foo 1234AB"); - DoNumTest("foo % X", pos, "foo 1234AB"); - DoNumTest("foo %+X", neg, "foo FFFFFFD6"); - DoNumTest("foo % X", neg, "foo FFFFFFD6"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test14/test14.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test14/test14.cpp deleted file mode 100644 index 74c7b19..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test14/test14.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test14.c -** -** Purpose: Test #14 for the sprintf_s function. Tests the lowercase -** exponential notation double specifier (%e) -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -PALTEST(c_runtime_sprintf_s_test14_paltest_sprintf_test14, "c_runtime/sprintf_s/test14/paltest_sprintf_test14") -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest("foo %e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %he", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %Le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %I64e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %14e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %-14e", val, "foo 2.560000e+002 ", "foo 2.560000e+02 "); - DoDoubleTest("foo %.1e", val, "foo 2.6e+002", "foo 2.6e+02"); - DoDoubleTest("foo %.8e", val, "foo 2.56000000e+002", "foo 2.56000000e+02"); - DoDoubleTest("foo %014e", val, "foo 02.560000e+002", "foo 002.560000e+02"); - DoDoubleTest("foo %#e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", val, "foo +2.560000e+002", "foo +2.560000e+02"); - DoDoubleTest("foo % e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - DoDoubleTest("foo % e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test15/test15.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test15/test15.cpp deleted file mode 100644 index 1854436..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test15/test15.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test15.c -** -** Purpose: Test #15 for the sprintf_s function. Tests the uppercase -** exponential notation double specifier (%E) -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -PALTEST(c_runtime_sprintf_s_test15_paltest_sprintf_test15, "c_runtime/sprintf_s/test15/paltest_sprintf_test15") -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest("foo %E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %lE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %hE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %LE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %I64E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %14E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %-14E", val, "foo 2.560000E+002 ", "foo 2.560000E+02 "); - DoDoubleTest("foo %.1E", val, "foo 2.6E+002", "foo 2.6E+02"); - DoDoubleTest("foo %.8E", val, "foo 2.56000000E+002", "foo 2.56000000E+02"); - DoDoubleTest("foo %014E", val, "foo 02.560000E+002", "foo 002.560000E+02"); - DoDoubleTest("foo %#E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", val, "foo +2.560000E+002", "foo +2.560000E+02"); - DoDoubleTest("foo % E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - DoDoubleTest("foo % E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test16/test16.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test16/test16.cpp deleted file mode 100644 index b3cea7e..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test16/test16.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test16.c -** -** Purpose: Test #16 for the sprintf_s function. Tests the decimal notation -** double specifier (%f) -** -** -**==========================================================================*/ - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -PALTEST(c_runtime_sprintf_s_test16_paltest_sprintf_test16, "c_runtime/sprintf_s/test16/paltest_sprintf_test16") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest("foo %f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %hf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %Lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %I64f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %12f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %-12f", val, "foo 2560.001000 ", "foo 2560.001000 "); - DoDoubleTest("foo %.1f", val, "foo 2560.0", "foo 2560.0"); - DoDoubleTest("foo %.8f", val, "foo 2560.00100000", "foo 2560.00100000"); - DoDoubleTest("foo %012f", val, "foo 02560.001000", "foo 02560.001000"); - DoDoubleTest("foo %#f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", val, "foo +2560.001000", "foo +2560.001000"); - DoDoubleTest("foo % f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", neg, "foo -2560.001000", "foo -2560.001000"); - DoDoubleTest("foo % f", neg, "foo -2560.001000", "foo -2560.001000"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test17/test17.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test17/test17.cpp deleted file mode 100644 index daa05ba..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test17/test17.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test17.c -** -** Purpose: Test #17 for the sprintf_s function. Tests the lowercase -** shorthand notation double specifier (%g) -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -PALTEST(c_runtime_sprintf_s_test17_paltest_sprintf_test17, "c_runtime/sprintf_s/test17/paltest_sprintf_test17") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest("foo %g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %Lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5g", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1g", val, "foo 3e+003", "foo 3e+03"); - DoDoubleTest("foo %.2g", val, "foo 2.6e+003", "foo 2.6e+03"); - DoDoubleTest("foo %.12g", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06g", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#g", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+g", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+g", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % g", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test18/test18.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test18/test18.cpp deleted file mode 100644 index abb9a0b..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test18/test18.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test18.c -** -** Purpose: Test #18 for the sprintf_s function. Tests the uppercase -** shorthand notation double specifier (%G) -** -** -**==========================================================================*/ - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -PALTEST(c_runtime_sprintf_s_test18_paltest_sprintf_test18, "c_runtime/sprintf_s/test18/paltest_sprintf_test18") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest("foo %G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %LG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5G", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1G", val, "foo 3E+003", "foo 3E+03"); - DoDoubleTest("foo %.2G", val, "foo 2.6E+003", "foo 2.6E+03"); - DoDoubleTest("foo %.12G", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06G", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#G", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+G", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+G", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % G", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test19/test19.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test19/test19.cpp deleted file mode 100644 index f5976c9..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test19/test19.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test19.c -** -** Purpose: Test #19 for the sprintf_s function. Tests the variable length -** precision argument. -** -** -**==========================================================================*/ - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - - -PALTEST(c_runtime_sprintf_s_test19_paltest_sprintf_test19, "c_runtime/sprintf_s/test19/paltest_sprintf_test19") -{ - int n = -1; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - DoArgumentPrecTest("%.*s", 2, (void*)"bar", "bar", "ba", "ba"); - DoArgumentPrecTest("%.*S", 2, (void*)convert("bar"), "bar", "ba", "ba"); - - DoArgumentPrecTest("%.*c", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*c", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*d", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*d", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*i", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*i", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*o", 1, (void*)42, "42", "52", "52"); - DoArgumentPrecTest("%.*o", 3, (void*)42, "42", "052", "052"); - DoArgumentPrecTest("%.*u", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*u", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*x", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*x", 3, (void*)0x42, "0x42", "042", "042"); - DoArgumentPrecTest("%.*X", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*X", 3, (void*)0x42, "0x42", "042", "042"); - - - DoArgumentPrecDoubleTest("%.*e", 1, 2.01, "2.0e+000", "2.0e+00"); - DoArgumentPrecDoubleTest("%.*e", 3, 2.01, "2.010e+000", "2.010e+00"); - DoArgumentPrecDoubleTest("%.*E", 1, 2.01, "2.0E+000", "2.0E+00"); - DoArgumentPrecDoubleTest("%.*E", 3, 2.01, "2.010E+000", "2.010E+00"); - DoArgumentPrecDoubleTest("%.*f", 1, 2.01, "2.0", "2.0"); - DoArgumentPrecDoubleTest("%.*f", 3, 2.01, "2.010", "2.010"); - DoArgumentPrecDoubleTest("%.*g", 1, 256.01, "3e+002", "3e+02"); - DoArgumentPrecDoubleTest("%.*g", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 6, 256.01, "256.01", "256.01"); - DoArgumentPrecDoubleTest("%.*G", 1, 256.01, "3E+002", "3E+02"); - DoArgumentPrecDoubleTest("%.*G", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 6, 256.01, "256.01", "256.01"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test2/test2.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test2/test2.cpp deleted file mode 100644 index 56371a9..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test2/test2.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Test #2 for the sprintf_s function. Tests the string specifier -** (%s). -** -** -**==========================================================================*/ - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -PALTEST(c_runtime_sprintf_s_test2_paltest_sprintf_test2, "c_runtime/sprintf_s/test2/paltest_sprintf_test2") -{ - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoStrTest("foo %s", "bar", "foo bar"); - DoStrTest("foo %hs", "bar", "foo bar"); - DoWStrTest("foo %ls", convert("bar"), "foo bar"); - DoWStrTest("foo %ws", convert("bar"), "foo bar"); - DoStrTest("foo %Ls", "bar", "foo bar"); - DoStrTest("foo %I64s", "bar", "foo bar"); - DoStrTest("foo %5s", "bar", "foo bar"); - DoStrTest("foo %.2s", "bar", "foo ba"); - DoStrTest("foo %5.2s", "bar", "foo ba"); - DoStrTest("foo %-5s", "bar", "foo bar "); - DoStrTest("foo %05s", "bar", "foo 00bar"); - DoStrTest("foo %s", NULL, "foo (null)"); - DoStrTest("foo %hs", NULL, "foo (null)"); - DoWStrTest("foo %ls", NULL, "foo (null)"); - DoWStrTest("foo %ws", NULL, "foo (null)"); - DoStrTest("foo %Ls", NULL, "foo (null)"); - DoStrTest("foo %I64s", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test3/test3.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test3/test3.cpp deleted file mode 100644 index 5f1ec06..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test3/test3.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test3.c -** -** Purpose: Test #3 for the sprintf_s function. Tests the wide string -** specifier (%S). -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -PALTEST(c_runtime_sprintf_s_test3_paltest_sprintf_test3, "c_runtime/sprintf_s/test3/paltest_sprintf_test3") -{ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - DoWStrTest("foo %S", convert("bar"), "foo bar"); - DoStrTest("foo %hS", "bar", "foo bar"); - DoWStrTest("foo %lS", convert("bar"), "foo bar"); - DoWStrTest("foo %wS", convert("bar"), "foo bar"); - DoWStrTest("foo %LS", convert("bar"), "foo bar"); - DoWStrTest("foo %I64S", convert("bar"), "foo bar"); - DoWStrTest("foo %5S", convert("bar"), "foo bar"); - DoWStrTest("foo %.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %5.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %-5S", convert("bar"), "foo bar "); - DoWStrTest("foo %05S", convert("bar"), "foo 00bar"); - DoWStrTest("foo %S", NULL, "foo (null)"); - DoStrTest("foo %hS", NULL, "foo (null)"); - DoWStrTest("foo %lS", NULL, "foo (null)"); - DoWStrTest("foo %wS", NULL, "foo (null)"); - DoWStrTest("foo %LS", NULL, "foo (null)"); - DoWStrTest("foo %I64S", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test4/test4.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test4/test4.cpp deleted file mode 100644 index 6d9f3eb..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test4/test4.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test4.c -** -** Purpose: Test #4 for the sprintf_s function. Tests the pointer -** specifier (%p). -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" -/* - * Depends on memcmp and strlen - */ - -PALTEST(c_runtime_sprintf_s_test4_paltest_sprintf_test4, "c_runtime/sprintf_s/test4/paltest_sprintf_test4") -{ - void *ptr = (void*) 0x123456; - INT64 lptr = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - -/* -** Run only on 64 bit platforms -*/ -#if defined(HOST_64BIT) - Trace("Testing for 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "0000000000000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%-17p", ptr, "pointer to 0x123456", "0000000000123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X0000000000123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); -#else - Trace("Testing for Non 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "00000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%9p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%09p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%-9p", ptr, "pointer to 0x123456", "00123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X00123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); -#endif - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test6/test6.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test6/test6.cpp deleted file mode 100644 index a535777..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test6/test6.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test6.c -** -** Purpose: Test #6 for the sprintf_s function. Tests the char specifier (%c). -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -PALTEST(c_runtime_sprintf_s_test6_paltest_sprintf_test6, "c_runtime/sprintf_s/test6/paltest_sprintf_test6") -{ - WCHAR wc = (WCHAR) 'c'; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoCharTest("foo %c", 'b', "foo b"); - DoCharTest("foo %hc", 'b', "foo b"); - DoWCharTest("foo %lc", wc, "foo c"); - DoCharTest("foo %Lc", 'b', "foo b"); - DoCharTest("foo %I64c", 'b', "foo b"); - DoCharTest("foo %5c", 'b', "foo b"); - DoCharTest("foo %.0c", 'b', "foo b"); - DoCharTest("foo %-5c", 'b', "foo b "); - DoCharTest("foo %05c", 'b', "foo 0000b"); - DoCharTest("foo % c", 'b', "foo b"); - DoCharTest("foo %#c", 'b', "foo b"); - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test7/test7.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test7/test7.cpp deleted file mode 100644 index 91d1883..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test7/test7.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test7.c -** -** Purpose: Test #7 for the sprintf_s function. Tests the wide char -** specifier (%C). -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -PALTEST(c_runtime_sprintf_s_test7_paltest_sprintf_test7, "c_runtime/sprintf_s/test7/paltest_sprintf_test7") -{ - WCHAR wb = (WCHAR) 'b'; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoWCharTest("foo %C", wb, "foo b"); - DoWCharTest("foo %hC", wb, "foo b"); - DoCharTest("foo %lC", 'c', "foo c"); - DoWCharTest("foo %LC", wb, "foo b"); - DoWCharTest("foo %I64C", wb, "foo b"); - DoWCharTest("foo %5C", wb, "foo b"); - DoWCharTest("foo %.0C", wb, "foo b"); - DoWCharTest("foo %-5C", wb, "foo b "); - DoWCharTest("foo %05C", wb, "foo 0000b"); - DoWCharTest("foo % C", wb, "foo b"); - DoWCharTest("foo %#C", wb, "foo b"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test8/test8.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test8/test8.cpp deleted file mode 100644 index 1a5153c..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test8/test8.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test8.c -** -** Purpose: Test #8 for the sprintf_s function. Tests the decimal -** specifier (%d). -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -PALTEST(c_runtime_sprintf_s_test8_paltest_sprintf_test8, "c_runtime/sprintf_s/test8/paltest_sprintf_test8") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %d", pos, "foo 42"); - DoNumTest("foo %ld", 0xFFFF, "foo 65535"); - DoNumTest("foo %hd", 0xFFFF, "foo -1"); - DoNumTest("foo %Ld", pos, "foo 42"); - DoI64Test("foo %I64d", l, "42", "foo 42"); - DoNumTest("foo %3d", pos, "foo 42"); - DoNumTest("foo %-3d", pos, "foo 42 "); - DoNumTest("foo %.1d", pos, "foo 42"); - DoNumTest("foo %.3d", pos, "foo 042"); - DoNumTest("foo %03d", pos, "foo 042"); - DoNumTest("foo %#d", pos, "foo 42"); - DoNumTest("foo %+d", pos, "foo +42"); - DoNumTest("foo % d", pos, "foo 42"); - DoNumTest("foo %+d", neg, "foo -42"); - DoNumTest("foo % d", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test9/test9.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test9/test9.cpp deleted file mode 100644 index 5804db8..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test9/test9.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test9.c -** -** Purpose: Test #9 for the sprintf_s function. Tests the integer -** specifier (%i). -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -PALTEST(c_runtime_sprintf_s_test9_paltest_sprintf_test9, "c_runtime/sprintf_s/test9/paltest_sprintf_test9") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %i", pos, "foo 42"); - DoNumTest("foo %li", 0xFFFF, "foo 65535"); - DoNumTest("foo %hi", 0xFFFF, "foo -1"); - DoNumTest("foo %Li", pos, "foo 42"); - DoI64Test("foo %I64i", l, "42", "foo 42"); - DoNumTest("foo %3i", pos, "foo 42"); - DoNumTest("foo %-3i", pos, "foo 42 "); - DoNumTest("foo %.1i", pos, "foo 42"); - DoNumTest("foo %.3i", pos, "foo 042"); - DoNumTest("foo %03i", pos, "foo 042"); - DoNumTest("foo %#i", pos, "foo 42"); - DoNumTest("foo %+i", pos, "foo +42"); - DoNumTest("foo % i", pos, "foo 42"); - DoNumTest("foo %+i", neg, "foo -42"); - DoNumTest("foo % i", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test1/test1.cpp deleted file mode 100644 index 8b088ba..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test1/test1.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Test #1 for the vfprintf function. A single, basic, test -** case with no formatting. -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - -PALTEST(c_runtime_vfprintf_test1_paltest_vfprintf_test1, "c_runtime/vfprintf/test1/paltest_vfprintf_test1") -{ - FILE *fp; - char testfile[] = "testfile.txt"; - char buf[256]; - char checkstr[] = "hello world"; - int ret; - - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - if ((fp = fopen(testfile, "w+")) == NULL) - { - Fail("ERROR: fopen failed to create \"%s\"\n", testfile); - } - - ret = DoVfprintf(fp, "hello world"); - - if (ret != strlen(checkstr)) - { - Fail("Expected vfprintf to return %d, got %d.\n", - strlen(checkstr), ret); - - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: Fseek failed to set pointer to beginning of file\n" ); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - if (memcmp(checkstr, buf, strlen(checkstr)+1) != 0) - { - Fail("ERROR: expected %s, got %s\n", checkstr, buf); - } - if ((fclose(fp)) != 0) - { - Fail("ERROR: fclose failed to close \"%s\"\n", testfile); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test10/test10.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test10/test10.cpp deleted file mode 100644 index 17d5a3f..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test10/test10.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test10.c -** -** Purpose: Test #10 for the vfprintf function. Tests the octal specifier -** (%o). -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - -PALTEST(c_runtime_vfprintf_test10_paltest_vfprintf_test10, "c_runtime/vfprintf/test10/paltest_vfprintf_test10") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %o", pos, "foo 52"); - DoNumTest("foo %lo", 0xFFFF, "foo 177777"); - DoNumTest("foo %ho", 0xFFFF, "foo 177777"); - DoNumTest("foo %Lo", pos, "foo 52"); - DoI64Test("foo %I64o", l, "42", "foo 52"); - DoNumTest("foo %3o", pos, "foo 52"); - DoNumTest("foo %-3o", pos, "foo 52 "); - DoNumTest("foo %.1o", pos, "foo 52"); - DoNumTest("foo %.3o", pos, "foo 052"); - DoNumTest("foo %03o", pos, "foo 052"); - DoNumTest("foo %#o", pos, "foo 052"); - DoNumTest("foo %+o", pos, "foo 52"); - DoNumTest("foo % o", pos, "foo 52"); - DoNumTest("foo %+o", neg, "foo 37777777726"); - DoNumTest("foo % o", neg, "foo 37777777726"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test11/test11.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test11/test11.cpp deleted file mode 100644 index e545dba..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test11/test11.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test11.c -** -** Purpose: Test #11 for the vfprintf function. Test the unsigned int -** specifier (%u). -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - -PALTEST(c_runtime_vfprintf_test11_paltest_vfprintf_test11, "c_runtime/vfprintf/test11/paltest_vfprintf_test11") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %u", pos, "foo 42"); - DoNumTest("foo %lu", 0xFFFF, "foo 65535"); - DoNumTest("foo %hu", 0xFFFF, "foo 65535"); - DoNumTest("foo %Lu", pos, "foo 42"); - DoI64Test("foo %I64u", l, "42", "foo 42"); - DoNumTest("foo %3u", pos, "foo 42"); - DoNumTest("foo %-3u", pos, "foo 42 "); - DoNumTest("foo %.1u", pos, "foo 42"); - DoNumTest("foo %.3u", pos, "foo 042"); - DoNumTest("foo %03u", pos, "foo 042"); - DoNumTest("foo %#u", pos, "foo 42"); - DoNumTest("foo %+u", pos, "foo 42"); - DoNumTest("foo % u", pos, "foo 42"); - DoNumTest("foo %+u", neg, "foo 4294967254"); - DoNumTest("foo % u", neg, "foo 4294967254"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test12/test12.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test12/test12.cpp deleted file mode 100644 index 167c4b2..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test12/test12.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test12.c -** -** Purpose: Test #12 for the vfprintf function. Tests the (lowercase) -** hexadecimal specifier (%x) -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - -PALTEST(c_runtime_vfprintf_test12_paltest_vfprintf_test12, "c_runtime/vfprintf/test12/paltest_vfprintf_test12") -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %x", pos, "foo 1234ab"); - DoNumTest("foo %lx", pos, "foo 1234ab"); - DoNumTest("foo %hx", pos, "foo 34ab"); - DoNumTest("foo %Lx", pos, "foo 1234ab"); - DoI64Test("foo %I64x", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7x", pos, "foo 1234ab"); - DoNumTest("foo %-7x", pos, "foo 1234ab "); - DoNumTest("foo %.1x", pos, "foo 1234ab"); - DoNumTest("foo %.7x", pos, "foo 01234ab"); - DoNumTest("foo %07x", pos, "foo 01234ab"); - DoNumTest("foo %#x", pos, "foo 0x1234ab"); - DoNumTest("foo %+x", pos, "foo 1234ab"); - DoNumTest("foo % x", pos, "foo 1234ab"); - DoNumTest("foo %+x", neg, "foo ffffffd6"); - DoNumTest("foo % x", neg, "foo ffffffd6"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test13/test13.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test13/test13.cpp deleted file mode 100644 index 6c5e4ac..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test13/test13.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test13.c -** -** Purpose: Test #13 for the vfprintf function. Tests the (uppercase) -** hexadecimal specifier (%X) -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - - -PALTEST(c_runtime_vfprintf_test13_paltest_vfprintf_test13, "c_runtime/vfprintf/test13/paltest_vfprintf_test13") -{ - int neg = -42; - int pos = 0x1234AB; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %X", pos, "foo 1234AB"); - DoNumTest("foo %lX", pos, "foo 1234AB"); - DoNumTest("foo %hX", pos, "foo 34AB"); - DoNumTest("foo %LX", pos, "foo 1234AB"); - DoI64Test("foo %I64X", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7X", pos, "foo 1234AB"); - DoNumTest("foo %-7X", pos, "foo 1234AB "); - DoNumTest("foo %.1X", pos, "foo 1234AB"); - DoNumTest("foo %.7X", pos, "foo 01234AB"); - DoNumTest("foo %07X", pos, "foo 01234AB"); - DoNumTest("foo %#X", pos, "foo 0X1234AB"); - DoNumTest("foo %+X", pos, "foo 1234AB"); - DoNumTest("foo % X", pos, "foo 1234AB"); - DoNumTest("foo %+X", neg, "foo FFFFFFD6"); - DoNumTest("foo % X", neg, "foo FFFFFFD6"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test14/test14.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test14/test14.cpp deleted file mode 100644 index 9602a0a..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test14/test14.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test14.c -** -** Purpose: Test #14 for the vfprintf function. Tests the lowercase -** exponential notation double specifier (%e) -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - - -PALTEST(c_runtime_vfprintf_test14_paltest_vfprintf_test14, "c_runtime/vfprintf/test14/paltest_vfprintf_test14") -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %he", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %Le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %I64e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %14e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %-14e", val, "foo 2.560000e+002 ", - "foo 2.560000e+02 "); - DoDoubleTest("foo %.1e", val, "foo 2.6e+002", "foo 2.6e+02"); - DoDoubleTest("foo %.8e", val, "foo 2.56000000e+002", - "foo 2.56000000e+02"); - DoDoubleTest("foo %014e", val, "foo 02.560000e+002", - "foo 002.560000e+02"); - DoDoubleTest("foo %#e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", val, "foo +2.560000e+002", "foo +2.560000e+02"); - DoDoubleTest("foo % e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - DoDoubleTest("foo % e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test15/test15.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test15/test15.cpp deleted file mode 100644 index 050324d..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test15/test15.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test15.c -** -** Purpose: Test #15 for the vfprintf function. Tests the uppercase -** exponential notation double specifier (%E) -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - - -PALTEST(c_runtime_vfprintf_test15_paltest_vfprintf_test15, "c_runtime/vfprintf/test15/paltest_vfprintf_test15") -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %lE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %hE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %LE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %I64E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %14E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %-14E", val, "foo 2.560000E+002 ", - "foo 2.560000E+02 "); - DoDoubleTest("foo %.1E", val, "foo 2.6E+002", "foo 2.6E+02"); - DoDoubleTest("foo %.8E", val, "foo 2.56000000E+002", - "foo 2.56000000E+02"); - DoDoubleTest("foo %014E", val, "foo 02.560000E+002", - "foo 002.560000E+02"); - DoDoubleTest("foo %#E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", val, "foo +2.560000E+002", "foo +2.560000E+02"); - DoDoubleTest("foo % E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - DoDoubleTest("foo % E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test16/test16.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test16/test16.cpp deleted file mode 100644 index cc7dab4..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test16/test16.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test16.c -** -** Purpose: Test #16 for the vfprintf function. Tests the decimal notation -** double specifier (%f) -** -** -**==========================================================================*/ - - -#include -#include "../vfprintf.h" - - - -PALTEST(c_runtime_vfprintf_test16_paltest_vfprintf_test16, "c_runtime/vfprintf/test16/paltest_vfprintf_test16") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %hf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %Lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %I64f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %12f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %-12f", val, "foo 2560.001000 ", "foo 2560.001000 "); - DoDoubleTest("foo %.1f", val, "foo 2560.0", "foo 2560.0"); - DoDoubleTest("foo %.8f", val, "foo 2560.00100000", "foo 2560.00100000"); - DoDoubleTest("foo %012f", val, "foo 02560.001000", "foo 02560.001000"); - DoDoubleTest("foo %#f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", val, "foo +2560.001000", "foo +2560.001000"); - DoDoubleTest("foo % f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", neg, "foo -2560.001000", "foo -2560.001000"); - DoDoubleTest("foo % f", neg, "foo -2560.001000", "foo -2560.001000"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test17/test17.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test17/test17.cpp deleted file mode 100644 index e606949..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test17/test17.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test17.c -** -** Purpose: Test #17 for the vfprintf function. Tests the lowercase -** shorthand notation double specifier (%g) -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - - -PALTEST(c_runtime_vfprintf_test17_paltest_vfprintf_test17, "c_runtime/vfprintf/test17/paltest_vfprintf_test17") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %Lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5g", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1g", val, "foo 3e+003", "foo 3e+03"); - DoDoubleTest("foo %.2g", val, "foo 2.6e+003", "foo 2.6e+03"); - DoDoubleTest("foo %.12g", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06g", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#g", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+g", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+g", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % g", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test18/test18.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test18/test18.cpp deleted file mode 100644 index e634c02..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test18/test18.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test18.c -** -** Purpose: Test #18 for the vfprintf function. Tests the uppercase -** shorthand notation double specifier (%G) -** -** -**==========================================================================*/ - - -#include -#include "../vfprintf.h" - - - -PALTEST(c_runtime_vfprintf_test18_paltest_vfprintf_test18, "c_runtime/vfprintf/test18/paltest_vfprintf_test18") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %LG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5G", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1G", val, "foo 3E+003", "foo 3E+03"); - DoDoubleTest("foo %.2G", val, "foo 2.6E+003", "foo 2.6E+03"); - DoDoubleTest("foo %.12G", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06G", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#G", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+G", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+G", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % G", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test19/test19.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test19/test19.cpp deleted file mode 100644 index 1e83dc6..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test19/test19.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test19.c -** -** Purpose: Test #19 for the vfprintf function. Tests the variable length -** precision argument. -** -** -**==========================================================================*/ - - -#include -#include "../vfprintf.h" - - - - -PALTEST(c_runtime_vfprintf_test19_paltest_vfprintf_test19, "c_runtime/vfprintf/test19/paltest_vfprintf_test19") -{ - int n = -1; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - 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"); - DoArgumentPrecTest("%.*C", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*d", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*d", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*i", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*i", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*o", 1, (void*)42, "42", "52", "52"); - DoArgumentPrecTest("%.*o", 3, (void*)42, "42", "052", "052"); - DoArgumentPrecTest("%.*u", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*u", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*x", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*x", 3, (void*)0x42, "0x42", "042", "042"); - DoArgumentPrecTest("%.*X", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*X", 3, (void*)0x42, "0x42", "042", "042"); - - - DoArgumentPrecDoubleTest("%.*e", 1, 2.01, "2.0e+000", "2.0e+00"); - DoArgumentPrecDoubleTest("%.*e", 3, 2.01, "2.010e+000", "2.010e+00"); - DoArgumentPrecDoubleTest("%.*E", 1, 2.01, "2.0E+000", "2.0E+00"); - DoArgumentPrecDoubleTest("%.*E", 3, 2.01, "2.010E+000", "2.010E+00"); - DoArgumentPrecDoubleTest("%.*f", 1, 2.01, "2.0", "2.0"); - DoArgumentPrecDoubleTest("%.*f", 3, 2.01, "2.010", "2.010"); - DoArgumentPrecDoubleTest("%.*g", 1, 256.01, "3e+002", "3e+02"); - DoArgumentPrecDoubleTest("%.*g", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 6, 256.01, "256.01", "256.01"); - DoArgumentPrecDoubleTest("%.*G", 1, 256.01, "3E+002", "3E+02"); - DoArgumentPrecDoubleTest("%.*G", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 6, 256.01, "256.01", "256.01"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test2/test2.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test2/test2.cpp deleted file mode 100644 index df7ba73..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test2/test2.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Test #2 for the vfprintf function. Tests the string specifier -** (%s). -** -** -**==========================================================================*/ - - -#include -#include "../vfprintf.h" - - - -PALTEST(c_runtime_vfprintf_test2_paltest_vfprintf_test2, "c_runtime/vfprintf/test2/paltest_vfprintf_test2") -{ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoStrTest("foo %s", "bar", "foo bar"); - DoStrTest("foo %hs", "bar", "foo bar"); - DoWStrTest("foo %ls", convert("bar"), "foo bar"); - DoWStrTest("foo %ws", convert("bar"), "foo bar"); - DoStrTest("foo %Ls", "bar", "foo bar"); - DoStrTest("foo %I64s", "bar", "foo bar"); - DoStrTest("foo %5s", "bar", "foo bar"); - DoStrTest("foo %.2s", "bar", "foo ba"); - DoStrTest("foo %5.2s", "bar", "foo ba"); - DoStrTest("foo %-5s", "bar", "foo bar "); - DoStrTest("foo %05s", "bar", "foo 00bar"); - DoStrTest("foo %s", NULL, "foo (null)"); - DoStrTest("foo %hs", NULL, "foo (null)"); - DoStrTest("foo %ls", NULL, "foo (null)"); - DoStrTest("foo %ws", NULL, "foo (null)"); - DoStrTest("foo %Ls", NULL, "foo (null)"); - DoStrTest("foo %I64s", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test3/test3.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test3/test3.cpp deleted file mode 100644 index 96a08df..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test3/test3.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test3.c -** -** Purpose: Test #3 for the vfprintf function. Tests the wide string -** specifier (%S). -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - - -PALTEST(c_runtime_vfprintf_test3_paltest_vfprintf_test3, "c_runtime/vfprintf/test3/paltest_vfprintf_test3") -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoWStrTest("foo %S", convert("bar"), "foo bar"); - DoStrTest("foo %hS", "bar", "foo bar"); - DoWStrTest("foo %lS", convert("bar"), "foo bar"); - DoWStrTest("foo %wS", convert("bar"), "foo bar"); - DoWStrTest("foo %LS", convert("bar"), "foo bar"); - DoWStrTest("foo %I64S", convert("bar"), "foo bar"); - DoWStrTest("foo %5S", convert("bar"), "foo bar"); - DoWStrTest("foo %.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %5.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %-5S", convert("bar"), "foo bar "); - DoWStrTest("foo %05S", convert("bar"), "foo 00bar"); - DoWStrTest("foo %S", NULL, "foo (null)"); - DoStrTest("foo %hS", NULL, "foo (null)"); - DoWStrTest("foo %lS", NULL, "foo (null)"); - DoWStrTest("foo %wS", NULL, "foo (null)"); - DoWStrTest("foo %LS", NULL, "foo (null)"); - DoWStrTest("foo %I64S", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test4/test4.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test4/test4.cpp deleted file mode 100644 index 410c6ec..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test4/test4.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test4.c -** -** Purpose: Test #4 for the vfprintf function. Tests the pointer -** specifier (%p). -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - - -PALTEST(c_runtime_vfprintf_test4_paltest_vfprintf_test4, "c_runtime/vfprintf/test4/paltest_vfprintf_test4") -{ - void *ptr = (void*) 0x123456; - INT64 lptr = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - -/* -** Run only on 64 bit platforms -*/ -#if defined(HOST_64BIT) - Trace("Testing for 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "0000000000000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%-17p", ptr, "pointer to 0x123456", "0000000000123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X0000000000123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); - -#else - Trace("Testing for Non 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "00000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%9p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%09p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%-9p", ptr, "pointer to 0x123456", "00123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X00123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); - -#endif - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test5/test5.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test5/test5.cpp deleted file mode 100644 index ccea60e..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test5/test5.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test5.c -** -** Purpose: Test #5 for the vfprintf function. Tests the count specifier (%n). -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - - - -PALTEST(c_runtime_vfprintf_test5_paltest_vfprintf_test5, "c_runtime/vfprintf/test5/paltest_vfprintf_test5") -{ - 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)) - { - 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; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test6/test6.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test6/test6.cpp deleted file mode 100644 index 6404e8f..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test6/test6.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test6.c -** -** Purpose: Test #6 for the vfprintf function. Tests the char specifier (%c). -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - - -PALTEST(c_runtime_vfprintf_test6_paltest_vfprintf_test6, "c_runtime/vfprintf/test6/paltest_vfprintf_test6") -{ - WCHAR wc = (WCHAR) 'c'; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoCharTest("foo %c", 'b', "foo b"); - DoCharTest("foo %hc", 'b', "foo b"); - DoWCharTest("foo %lc", wc, "foo c"); - DoCharTest("foo %Lc", 'b', "foo b"); - DoCharTest("foo %I64c", 'b', "foo b"); - DoCharTest("foo %5c", 'b', "foo b"); - DoCharTest("foo %.0c", 'b', "foo b"); - DoCharTest("foo %-5c", 'b', "foo b "); - DoCharTest("foo %05c", 'b', "foo 0000b"); - DoCharTest("foo % c", 'b', "foo b"); - DoCharTest("foo %#c", 'b', "foo b"); - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test7/test7.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test7/test7.cpp deleted file mode 100644 index 05e88dc..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test7/test7.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test7.c -** -** Purpose: Test #7 for the vfprintf function. Tests the wide char -** specifier (%C). -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - - -PALTEST(c_runtime_vfprintf_test7_paltest_vfprintf_test7, "c_runtime/vfprintf/test7/paltest_vfprintf_test7") -{ - WCHAR wb = (WCHAR) 'b'; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoWCharTest("foo %C", wb, "foo b"); - DoWCharTest("foo %hC", wb, "foo b"); - DoCharTest("foo %lC", 'c', "foo c"); - DoWCharTest("foo %LC", wb, "foo b"); - DoWCharTest("foo %I64C", wb, "foo b"); - DoWCharTest("foo %5C", wb, "foo b"); - DoWCharTest("foo %.0C", wb, "foo b"); - DoWCharTest("foo %-5C", wb, "foo b "); - DoWCharTest("foo %05C", wb, "foo 0000b"); - DoWCharTest("foo % C", wb, "foo b"); - DoWCharTest("foo %#C", wb, "foo b"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test8/test8.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test8/test8.cpp deleted file mode 100644 index ce046df..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test8/test8.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test8.c -** -** Purpose: Test #8 for the vfprintf function. Tests the decimal -** specifier (%d). -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - - -PALTEST(c_runtime_vfprintf_test8_paltest_vfprintf_test8, "c_runtime/vfprintf/test8/paltest_vfprintf_test8") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %d", pos, "foo 42"); - DoNumTest("foo %ld", 0xFFFF, "foo 65535"); - DoNumTest("foo %hd", 0xFFFF, "foo -1"); - DoNumTest("foo %Ld", pos, "foo 42"); - DoI64Test("foo %I64d", l, "42", "foo 42"); - DoNumTest("foo %3d", pos, "foo 42"); - DoNumTest("foo %-3d", pos, "foo 42 "); - DoNumTest("foo %.1d", pos, "foo 42"); - DoNumTest("foo %.3d", pos, "foo 042"); - DoNumTest("foo %03d", pos, "foo 042"); - DoNumTest("foo %#d", pos, "foo 42"); - DoNumTest("foo %+d", pos, "foo +42"); - DoNumTest("foo % d", pos, "foo 42"); - DoNumTest("foo %+d", neg, "foo -42"); - DoNumTest("foo % d", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test9/test9.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test9/test9.cpp deleted file mode 100644 index 6a4bc39..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/test9/test9.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test9.c -** -** Purpose: Test #9 for the vfprintf function. Tests the integer -** specifier (%i). -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - - -PALTEST(c_runtime_vfprintf_test9_paltest_vfprintf_test9, "c_runtime/vfprintf/test9/paltest_vfprintf_test9") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %i", pos, "foo 42"); - DoNumTest("foo %li", 0xFFFF, "foo 65535"); - DoNumTest("foo %hi", 0xFFFF, "foo -1"); - DoNumTest("foo %Li", pos, "foo 42"); - DoI64Test("foo %I64i", l, "42", "foo 42"); - DoNumTest("foo %3i", pos, "foo 42"); - DoNumTest("foo %-3i", pos, "foo 42 "); - DoNumTest("foo %.1i", pos, "foo 42"); - DoNumTest("foo %.3i", pos, "foo 042"); - DoNumTest("foo %03i", pos, "foo 042"); - DoNumTest("foo %#i", pos, "foo 42"); - DoNumTest("foo %+i", pos, "foo +42"); - DoNumTest("foo % i", pos, "foo 42"); - DoNumTest("foo %+i", neg, "foo -42"); - DoNumTest("foo % i", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/vfprintf.h b/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/vfprintf.h deleted file mode 100644 index f8aa9dc..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vfprintf/vfprintf.h +++ /dev/null @@ -1,469 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: vfprintf.h -** -** Purpose: Contains common testing functions for vfprintf -** -** -**==========================================================================*/ - -#ifndef __vfprintf_H__ -#define __vfprintf_H__ - -inline int DoVfprintf(FILE *fp, const char *format, ...) -{ - int retVal; - va_list arglist; - - va_start(arglist, format); - retVal = vfprintf(fp, format, arglist); - va_end(arglist); - - return (retVal); -} - -inline void DoStrTest_vfprintf(const char *formatstr, char* param, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - if ((DoVfprintf(fp, formatstr, param)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert string \"%s\" into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, formatstr, checkstr, buf); - } - fclose(fp); -} -#define DoStrTest DoStrTest_vfprintf - -inline void DoWStrTest_vfprintf(const char *formatstr, WCHAR* param, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - if ((DoVfprintf(fp, formatstr, param)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert wide string \"%S\" into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, formatstr, checkstr, buf); - } - fclose(fp); -} -#define DoWStrTest DoWStrTest_vfprintf - -inline void DoPointerTest_vfprintf(const char *formatstr, void* param, char* paramstr, - const char *checkstr1) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((DoVfprintf(fp, formatstr, param)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - paramstr, formatstr, checkstr1, buf); - } - - if ((fclose( fp )) != 0) - { - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - } -} -#define DoPointerTest DoPointerTest_vfprintf - -inline void DoCountTest_vfprintf(const char *formatstr, int param, const char *checkstr) -{ - FILE *fp; - char buf[512] = { 0 }; - int n = -1; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((DoVfprintf(fp, formatstr, &n)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, sizeof(buf), fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } - - if ((fclose( fp )) != 0) - { - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - } -} -#define DoCountTest DoCountTest_vfprintf - -inline void DoShortCountTest_vfprintf(const char *formatstr, int param, const char *checkstr) -{ - FILE *fp; - char buf[512] = { 0 }; - short int n = -1; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((DoVfprintf(fp, formatstr, &n)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } - - if ((fclose( fp )) != 0) - { - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - } -} -#define DoShortCountTest DoShortCountTest_vfprintf - -inline void DoCharTest_vfprintf(const char *formatstr, char param, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - if ((DoVfprintf(fp, formatstr, param)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, param, formatstr, checkstr, buf); - } - fclose(fp); -} -#define DoCharTest DoCharTest_vfprintf - -inline void DoWCharTest_vfprintf(const char *formatstr, WCHAR param, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - if ((DoVfprintf(fp, formatstr, param)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - (char)param, param, formatstr, checkstr, buf); - } - fclose(fp); -} -#define DoWCharTest DoWCharTest_vfprintf - -inline void DoNumTest_vfprintf(const char *formatstr, int value, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - if ((DoVfprintf(fp, formatstr, value)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert %#x into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - value, formatstr, checkstr, buf); - } - fclose(fp); -} -#define DoNumTest DoNumTest_vfprintf - -inline void DoI64Test_vfprintf(const char *formatstr, INT64 value, char *valuestr, const char *checkstr1) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - if ((DoVfprintf(fp, formatstr, value)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\", got \"%s\".\n", - valuestr, formatstr, checkstr1, buf); - } - fclose(fp); -} -#define DoI64Test DoI64Test_vfprintf - -inline void DoDoubleTest_vfprintf(const char *formatstr, double value, const char *checkstr1, - const char *checkstr2) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((DoVfprintf(fp, formatstr, value)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\"\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - value, formatstr, checkstr1, checkstr2, buf); - } - fclose(fp); -} -#define DoDoubleTest DoDoubleTest_vfprintf - -inline void DoArgumentPrecTest_vfprintf(const char *formatstr, int precision, void *param, - char *paramstr, const char *checkstr1, const char *checkstr2) -{ - FILE *fp; - char buf[256]; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((DoVfprintf(fp, formatstr, precision, param)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", paramstr, formatstr, - precision, checkstr1, checkstr2, buf); - } - - - if ((fclose( fp )) != 0) - { - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - } - -} -#define DoArgumentPrecTest DoArgumentPrecTest_vfprintf - -inline void DoArgumentPrecDoubleTest_vfprintf(const char *formatstr, int precision, double param, - const char *checkstr1, const char *checkstr2) -{ - FILE *fp; - char buf[256]; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((DoVfprintf(fp, formatstr, precision, param)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", param, formatstr, - precision, checkstr1, checkstr2, buf); - } - - if ((fclose( fp )) != 0) - { - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - } - -} -#define DoArgumentPrecDoubleTest DoArgumentPrecDoubleTest_vfprintf - -#endif - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test1/test1.cpp deleted file mode 100644 index 018055c..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test1/test1.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Test #1 for the vprintf function. A single, basic, test -** case with no formatting. -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - -PALTEST(c_runtime_vprintf_test1_paltest_vprintf_test1, "c_runtime/vprintf/test1/paltest_vprintf_test1") -{ - char checkstr[] = "hello world"; - int ret; - - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - ret = vprintf("hello world", NULL); - - if (ret != strlen(checkstr)) - { - Fail("Expected vprintf to return %d, got %d.\n", - strlen(checkstr), ret); - - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test10/test10.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test10/test10.cpp deleted file mode 100644 index e58ac18..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test10/test10.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test10.c -** -** Purpose: Test #10 for the vprintf function. Tests the octal specifier -** (%o). -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - -PALTEST(c_runtime_vprintf_test10_paltest_vprintf_test10, "c_runtime/vprintf/test10/paltest_vprintf_test10") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %o", pos, "foo 52"); - DoNumTest("foo %lo", 0xFFFF, "foo 177777"); - DoNumTest("foo %ho", 0xFFFF, "foo 177777"); - DoNumTest("foo %Lo", pos, "foo 52"); - DoI64Test("foo %I64o", l, "42", "foo 52"); - DoNumTest("foo %3o", pos, "foo 52"); - DoNumTest("foo %-3o", pos, "foo 52 "); - DoNumTest("foo %.1o", pos, "foo 52"); - DoNumTest("foo %.3o", pos, "foo 052"); - DoNumTest("foo %03o", pos, "foo 052"); - DoNumTest("foo %#o", pos, "foo 052"); - DoNumTest("foo %+o", pos, "foo 52"); - DoNumTest("foo % o", pos, "foo 52"); - DoNumTest("foo %+o", neg, "foo 37777777726"); - DoNumTest("foo % o", neg, "foo 37777777726"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test11/test11.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test11/test11.cpp deleted file mode 100644 index b2718c9..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test11/test11.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test11.c -** -** Purpose: Test #11 for the vprintf function. Test the unsigned int -** specifier (%u). -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - -PALTEST(c_runtime_vprintf_test11_paltest_vprintf_test11, "c_runtime/vprintf/test11/paltest_vprintf_test11") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %u", pos, "foo 42"); - DoNumTest("foo %lu", 0xFFFF, "foo 65535"); - DoNumTest("foo %hu", 0xFFFF, "foo 65535"); - DoNumTest("foo %Lu", pos, "foo 42"); - DoI64Test("foo %I64u", l, "42", "foo 42"); - DoNumTest("foo %3u", pos, "foo 42"); - DoNumTest("foo %-3u", pos, "foo 42 "); - DoNumTest("foo %.1u", pos, "foo 42"); - DoNumTest("foo %.3u", pos, "foo 042"); - DoNumTest("foo %03u", pos, "foo 042"); - DoNumTest("foo %#u", pos, "foo 42"); - DoNumTest("foo %+u", pos, "foo 42"); - DoNumTest("foo % u", pos, "foo 42"); - DoNumTest("foo %+u", neg, "foo 4294967254"); - DoNumTest("foo % u", neg, "foo 4294967254"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test12/test12.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test12/test12.cpp deleted file mode 100644 index 1cf22fe..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test12/test12.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test12.c -** -** Purpose: Test #12 for the vprintf function. Tests the (lowercase) -** hexadecimal specifier (%x) -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - -PALTEST(c_runtime_vprintf_test12_paltest_vprintf_test12, "c_runtime/vprintf/test12/paltest_vprintf_test12") -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %x", pos, "foo 1234ab"); - DoNumTest("foo %lx", pos, "foo 1234ab"); - DoNumTest("foo %hx", pos, "foo 34ab"); - DoNumTest("foo %Lx", pos, "foo 1234ab"); - DoI64Test("foo %I64x", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7x", pos, "foo 1234ab"); - DoNumTest("foo %-7x", pos, "foo 1234ab "); - DoNumTest("foo %.1x", pos, "foo 1234ab"); - DoNumTest("foo %.7x", pos, "foo 01234ab"); - DoNumTest("foo %07x", pos, "foo 01234ab"); - DoNumTest("foo %#x", pos, "foo 0x1234ab"); - DoNumTest("foo %+x", pos, "foo 1234ab"); - DoNumTest("foo % x", pos, "foo 1234ab"); - DoNumTest("foo %+x", neg, "foo ffffffd6"); - DoNumTest("foo % x", neg, "foo ffffffd6"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test13/test13.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test13/test13.cpp deleted file mode 100644 index 9919fab..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test13/test13.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test13.c -** -** Purpose: Test #13 for the vprintf function. Tests the (uppercase) -** hexadecimal specifier (%X) -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - - -PALTEST(c_runtime_vprintf_test13_paltest_vprintf_test13, "c_runtime/vprintf/test13/paltest_vprintf_test13") -{ - int neg = -42; - int pos = 0x1234AB; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %X", pos, "foo 1234AB"); - DoNumTest("foo %lX", pos, "foo 1234AB"); - DoNumTest("foo %hX", pos, "foo 34AB"); - DoNumTest("foo %LX", pos, "foo 1234AB"); - DoI64Test("foo %I64X", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7X", pos, "foo 1234AB"); - DoNumTest("foo %-7X", pos, "foo 1234AB "); - DoNumTest("foo %.1X", pos, "foo 1234AB"); - DoNumTest("foo %.7X", pos, "foo 01234AB"); - DoNumTest("foo %07X", pos, "foo 01234AB"); - DoNumTest("foo %#X", pos, "foo 0X1234AB"); - DoNumTest("foo %+X", pos, "foo 1234AB"); - DoNumTest("foo % X", pos, "foo 1234AB"); - DoNumTest("foo %+X", neg, "foo FFFFFFD6"); - DoNumTest("foo % X", neg, "foo FFFFFFD6"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test14/test14.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test14/test14.cpp deleted file mode 100644 index 874fc00..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test14/test14.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test14.c -** -** Purpose: Test #14 for the vprintf function. Tests the lowercase -** exponential notation double specifier (%e) -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - - -PALTEST(c_runtime_vprintf_test14_paltest_vprintf_test14, "c_runtime/vprintf/test14/paltest_vprintf_test14") -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %he", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %Le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %I64e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %14e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %-14e", val, "foo 2.560000e+002 ", - "foo 2.560000e+02 "); - DoDoubleTest("foo %.1e", val, "foo 2.6e+002", "foo 2.6e+02"); - DoDoubleTest("foo %.8e", val, "foo 2.56000000e+002", - "foo 2.56000000e+02"); - DoDoubleTest("foo %014e", val, "foo 02.560000e+002", - "foo 002.560000e+02"); - DoDoubleTest("foo %#e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", val, "foo +2.560000e+002", "foo +2.560000e+02"); - DoDoubleTest("foo % e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - DoDoubleTest("foo % e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test15/test15.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test15/test15.cpp deleted file mode 100644 index d5b0d14..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test15/test15.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test15.c -** -** Purpose: Test #15 for the vprintf function. Tests the uppercase -** exponential notation double specifier (%E) -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - - -PALTEST(c_runtime_vprintf_test15_paltest_vprintf_test15, "c_runtime/vprintf/test15/paltest_vprintf_test15") -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %lE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %hE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %LE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %I64E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %14E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %-14E", val, "foo 2.560000E+002 ", - "foo 2.560000E+02 "); - DoDoubleTest("foo %.1E", val, "foo 2.6E+002", "foo 2.6E+02"); - DoDoubleTest("foo %.8E", val, "foo 2.56000000E+002", - "foo 2.56000000E+02"); - DoDoubleTest("foo %014E", val, "foo 02.560000E+002", - "foo 002.560000E+02"); - DoDoubleTest("foo %#E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", val, "foo +2.560000E+002", "foo +2.560000E+02"); - DoDoubleTest("foo % E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - DoDoubleTest("foo % E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test16/test16.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test16/test16.cpp deleted file mode 100644 index 4834d80..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test16/test16.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test16.c -** -** Purpose: Test #16 for the vprintf function. Tests the decimal notation -** double specifier (%f) -** -** -**==========================================================================*/ - - -#include -#include "../vprintf.h" - - - -PALTEST(c_runtime_vprintf_test16_paltest_vprintf_test16, "c_runtime/vprintf/test16/paltest_vprintf_test16") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %hf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %Lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %I64f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %12f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %-12f", val, "foo 2560.001000 ", "foo 2560.001000 "); - DoDoubleTest("foo %.1f", val, "foo 2560.0", "foo 2560.0"); - DoDoubleTest("foo %.8f", val, "foo 2560.00100000", "foo 2560.00100000"); - DoDoubleTest("foo %012f", val, "foo 02560.001000", "foo 02560.001000"); - DoDoubleTest("foo %#f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", val, "foo +2560.001000", "foo +2560.001000"); - DoDoubleTest("foo % f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", neg, "foo -2560.001000", "foo -2560.001000"); - DoDoubleTest("foo % f", neg, "foo -2560.001000", "foo -2560.001000"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test17/test17.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test17/test17.cpp deleted file mode 100644 index 1711b0f..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test17/test17.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test17.c -** -** Purpose: Test #17 for the vprintf function. Tests the lowercase -** shorthand notation double specifier (%g) -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - - -PALTEST(c_runtime_vprintf_test17_paltest_vprintf_test17, "c_runtime/vprintf/test17/paltest_vprintf_test17") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %Lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5g", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1g", val, "foo 3e+003", "foo 3e+03"); - DoDoubleTest("foo %.2g", val, "foo 2.6e+003", "foo 2.6e+03"); - DoDoubleTest("foo %.12g", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06g", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#g", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+g", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+g", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % g", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test18/test18.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test18/test18.cpp deleted file mode 100644 index a5b7f54..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test18/test18.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test18.c -** -** Purpose: Test #18 for the vprintf function. Tests the uppercase -** shorthand notation double specifier (%G) -** -** -**==========================================================================*/ - - -#include -#include "../vprintf.h" - - - -PALTEST(c_runtime_vprintf_test18_paltest_vprintf_test18, "c_runtime/vprintf/test18/paltest_vprintf_test18") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %LG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5G", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1G", val, "foo 3E+003", "foo 3E+03"); - DoDoubleTest("foo %.2G", val, "foo 2.6E+003", "foo 2.6E+03"); - DoDoubleTest("foo %.12G", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06G", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#G", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+G", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+G", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % G", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test19/test19.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test19/test19.cpp deleted file mode 100644 index d99abe7..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test19/test19.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test19.c -** -** Purpose: Test #19 for the vprintf function. Tests the variable length -** precision argument. -** -** -**==========================================================================*/ - - -#include -#include "../vprintf.h" - - - - -PALTEST(c_runtime_vprintf_test19_paltest_vprintf_test19, "c_runtime/vprintf/test19/paltest_vprintf_test19") -{ - int n = -1; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - 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"); - DoArgumentPrecTest("%.*C", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*d", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*d", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*i", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*i", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*o", 1, (void*)42, "42", "52", "52"); - DoArgumentPrecTest("%.*o", 3, (void*)42, "42", "052", "052"); - DoArgumentPrecTest("%.*u", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*u", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*x", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*x", 3, (void*)0x42, "0x42", "042", "042"); - DoArgumentPrecTest("%.*X", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*X", 3, (void*)0x42, "0x42", "042", "042"); - - - DoArgumentPrecDoubleTest("%.*e", 1, 2.01, "2.0e+000", "2.0e+00"); - DoArgumentPrecDoubleTest("%.*e", 3, 2.01, "2.010e+000", "2.010e+00"); - DoArgumentPrecDoubleTest("%.*E", 1, 2.01, "2.0E+000", "2.0E+00"); - DoArgumentPrecDoubleTest("%.*E", 3, 2.01, "2.010E+000", "2.010E+00"); - DoArgumentPrecDoubleTest("%.*f", 1, 2.01, "2.0", "2.0"); - DoArgumentPrecDoubleTest("%.*f", 3, 2.01, "2.010", "2.010"); - DoArgumentPrecDoubleTest("%.*g", 1, 256.01, "3e+002", "3e+02"); - DoArgumentPrecDoubleTest("%.*g", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 6, 256.01, "256.01", "256.01"); - DoArgumentPrecDoubleTest("%.*G", 1, 256.01, "3E+002", "3E+02"); - DoArgumentPrecDoubleTest("%.*G", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 6, 256.01, "256.01", "256.01"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test2/test2.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test2/test2.cpp deleted file mode 100644 index ca43ae8..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test2/test2.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Test #2 for the vprintf function. Tests the string specifier -** (%s). -** -** -**==========================================================================*/ - - -#include -#include "../vprintf.h" - - - -PALTEST(c_runtime_vprintf_test2_paltest_vprintf_test2, "c_runtime/vprintf/test2/paltest_vprintf_test2") -{ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoStrTest("foo %s", "bar", "foo bar"); - DoStrTest("foo %hs", "bar", "foo bar"); - DoWStrTest("foo %ls", convert("bar"), "foo bar"); - DoWStrTest("foo %ws", convert("bar"), "foo bar"); - DoStrTest("foo %Ls", "bar", "foo bar"); - DoStrTest("foo %I64s", "bar", "foo bar"); - DoStrTest("foo %5s", "bar", "foo bar"); - DoStrTest("foo %.2s", "bar", "foo ba"); - DoStrTest("foo %5.2s", "bar", "foo ba"); - DoStrTest("foo %-5s", "bar", "foo bar "); - DoStrTest("foo %05s", "bar", "foo 00bar"); - DoStrTest("foo %s", NULL, "foo (null)"); - DoStrTest("foo %hs", NULL, "foo (null)"); - DoWStrTest("foo %ls", NULL, "foo (null)"); - DoWStrTest("foo %ws", NULL, "foo (null)"); - DoStrTest("foo %Ls", NULL, "foo (null)"); - DoStrTest("foo %I64s", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test3/test3.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test3/test3.cpp deleted file mode 100644 index 1348eb4..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test3/test3.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test3.c -** -** Purpose: Test #3 for the vprintf function. Tests the wide string -** specifier (%S). -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - - -PALTEST(c_runtime_vprintf_test3_paltest_vprintf_test3, "c_runtime/vprintf/test3/paltest_vprintf_test3") -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoWStrTest("foo %S", convert("bar"), "foo bar"); - DoStrTest("foo %hS", "bar", "foo bar"); - DoWStrTest("foo %lS", convert("bar"), "foo bar"); - DoWStrTest("foo %wS", convert("bar"), "foo bar"); - DoWStrTest("foo %LS", convert("bar"), "foo bar"); - DoWStrTest("foo %I64S", convert("bar"), "foo bar"); - DoWStrTest("foo %5S", convert("bar"), "foo bar"); - DoWStrTest("foo %.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %5.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %-5S", convert("bar"), "foo bar "); - DoWStrTest("foo %05S", convert("bar"), "foo 00bar"); - DoWStrTest("foo %S", NULL, "foo (null)"); - DoStrTest("foo %hS", NULL, "foo (null)"); - DoWStrTest("foo %lS", NULL, "foo (null)"); - DoWStrTest("foo %wS", NULL, "foo (null)"); - DoWStrTest("foo %LS", NULL, "foo (null)"); - DoWStrTest("foo %I64S", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test4/test4.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test4/test4.cpp deleted file mode 100644 index bf98ec2..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test4/test4.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test4.c -** -** Purpose: Test #4 for the vprintf function. Tests the pointer -** specifier (%p). -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - - - -PALTEST(c_runtime_vprintf_test4_paltest_vprintf_test4, "c_runtime/vprintf/test4/paltest_vprintf_test4") -{ - void *ptr = (void*) 0x123456; - INT64 lptr = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } -/* -** Run only on 64 bit platforms -*/ -#if defined(HOST_64BIT) - Trace("Testing for 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "0000000000000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%-17p", ptr, "pointer to 0x123456", "0000000000123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X0000000000123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); - -#else - Trace("Testing for Non 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "00000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%9p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%09p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%-9p", ptr, "pointer to 0x123456", "00123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X00123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); - -#endif - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test5/test5.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test5/test5.cpp deleted file mode 100644 index a2b3233..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test5/test5.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test5.c -** -** Purpose: Test #5 for the vprintf function. Tests the count specifier (%n). -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - - - -PALTEST(c_runtime_vprintf_test5_paltest_vprintf_test5, "c_runtime/vprintf/test5/paltest_vprintf_test5") -{ - 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)) - { - 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; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test6/test6.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test6/test6.cpp deleted file mode 100644 index 5c6bec8..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test6/test6.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test6.c -** -** Purpose: Test #6 for the vprintf function. Tests the char specifier (%c). -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - - -PALTEST(c_runtime_vprintf_test6_paltest_vprintf_test6, "c_runtime/vprintf/test6/paltest_vprintf_test6") -{ - WCHAR wc = (WCHAR) 'c'; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoCharTest("foo %c", 'b', "foo b"); - DoCharTest("foo %hc", 'b', "foo b"); - DoWCharTest("foo %lc", wc, "foo c"); - DoCharTest("foo %Lc", 'b', "foo b"); - DoCharTest("foo %I64c", 'b', "foo b"); - DoCharTest("foo %5c", 'b', "foo b"); - DoCharTest("foo %.0c", 'b', "foo b"); - DoCharTest("foo %-5c", 'b', "foo b "); - DoCharTest("foo %05c", 'b', "foo 0000b"); - DoCharTest("foo % c", 'b', "foo b"); - DoCharTest("foo %#c", 'b', "foo b"); - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test7/test7.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test7/test7.cpp deleted file mode 100644 index d735623..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test7/test7.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test7.c -** -** Purpose: Test #7 for the vprintf function. Tests the wide char -** specifier (%C). -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - - -PALTEST(c_runtime_vprintf_test7_paltest_vprintf_test7, "c_runtime/vprintf/test7/paltest_vprintf_test7") -{ - WCHAR wb = (WCHAR) 'b'; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoWCharTest("foo %C", wb, "foo b"); - DoWCharTest("foo %hC", wb, "foo b"); - DoCharTest("foo %lC", 'c', "foo c"); - DoWCharTest("foo %LC", wb, "foo b"); - DoWCharTest("foo %I64C", wb, "foo b"); - DoWCharTest("foo %5C", wb, "foo b"); - DoWCharTest("foo %.0C", wb, "foo b"); - DoWCharTest("foo %-5C", wb, "foo b "); - DoWCharTest("foo %05C", wb, "foo 0000b"); - DoWCharTest("foo % C", wb, "foo b"); - DoWCharTest("foo %#C", wb, "foo b"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test8/test8.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test8/test8.cpp deleted file mode 100644 index 7c1128d..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test8/test8.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test8.c -** -** Purpose: Test #8 for the vprintf function. Tests the decimal -** specifier (%d). -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - - -PALTEST(c_runtime_vprintf_test8_paltest_vprintf_test8, "c_runtime/vprintf/test8/paltest_vprintf_test8") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %d", pos, "foo 42"); - DoNumTest("foo %ld", 0xFFFF, "foo 65535"); - DoNumTest("foo %hd", 0xFFFF, "foo -1"); - DoNumTest("foo %Ld", pos, "foo 42"); - DoI64Test("foo %I64d", l, "42", "foo 42"); - DoNumTest("foo %3d", pos, "foo 42"); - DoNumTest("foo %-3d", pos, "foo 42 "); - DoNumTest("foo %.1d", pos, "foo 42"); - DoNumTest("foo %.3d", pos, "foo 042"); - DoNumTest("foo %03d", pos, "foo 042"); - DoNumTest("foo %#d", pos, "foo 42"); - DoNumTest("foo %+d", pos, "foo +42"); - DoNumTest("foo % d", pos, "foo 42"); - DoNumTest("foo %+d", neg, "foo -42"); - DoNumTest("foo % d", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test9/test9.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test9/test9.cpp deleted file mode 100644 index 44004d3..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/test9/test9.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test9.c -** -** Purpose: Test #9 for the vprintf function. Tests the integer -** specifier (%i). -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - - -PALTEST(c_runtime_vprintf_test9_paltest_vprintf_test9, "c_runtime/vprintf/test9/paltest_vprintf_test9") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %i", pos, "foo 42"); - DoNumTest("foo %li", 0xFFFF, "foo 65535"); - DoNumTest("foo %hi", 0xFFFF, "foo -1"); - DoNumTest("foo %Li", pos, "foo 42"); - DoI64Test("foo %I64i", l, "42", "foo 42"); - DoNumTest("foo %3i", pos, "foo 42"); - DoNumTest("foo %-3i", pos, "foo 42 "); - DoNumTest("foo %.1i", pos, "foo 42"); - DoNumTest("foo %.3i", pos, "foo 042"); - DoNumTest("foo %03i", pos, "foo 042"); - DoNumTest("foo %#i", pos, "foo 42"); - DoNumTest("foo %+i", pos, "foo +42"); - DoNumTest("foo % i", pos, "foo 42"); - DoNumTest("foo %+i", neg, "foo -42"); - DoNumTest("foo % i", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/vprintf.h b/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/vprintf.h deleted file mode 100644 index 5bc6848..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vprintf/vprintf.h +++ /dev/null @@ -1,203 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: vprintf.h -** -** Purpose: Contains common testing functions for vprintf -** -** -**==========================================================================*/ - -#ifndef __vprintf_H__ -#define __vprintf_H__ - -inline int DoVprintf(const char *format, ...) -{ - int retVal; - va_list arglist; - - va_start(arglist, format); - retVal = vprintf(format, arglist); - va_end(arglist); - - return (retVal); -} - -inline void DoStrTest_vprintf(const char *formatstr, char* param, const char *checkstr) -{ - int ret; - - ret = DoVprintf(formatstr, param); - if (ret != strlen(checkstr)) - { - Fail("Expected vprintf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} -#define DoStrTest DoStrTest_vprintf - -inline void DoWStrTest_vprintf(const char *formatstr, WCHAR* param, const char *checkstr) -{ - int ret; - - ret = DoVprintf(formatstr, param); - if (ret != strlen(checkstr)) - { - Fail("Expected vprintf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} -#define DoWStrTest DoWStrTest_vprintf - -inline void DoPointerTest_vprintf(const char *formatstr, void* param, char* paramstr, - const char *checkstr1) -{ - int ret; - - ret = DoVprintf(formatstr, param); - if (ret != strlen(checkstr1)) - { - Fail("Expected vprintf to return %d, got %d.\n", - strlen(checkstr1), ret); - } -} -#define DoPointerTest DoPointerTest_vprintf - -inline void DoCountTest_vprintf(const char *formatstr, int param, const char *checkstr) -{ - int ret; - int n = -1; - - ret = DoVprintf(formatstr, &n); - - if (n != param) - { - Fail("Expected count parameter to resolve to %d, got %d\n", param, n); - } - - if (ret != strlen(checkstr)) - { - Fail("Expected vprintf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} -#define DoCountTest DoCountTest_vprintf - -inline void DoShortCountTest_vprintf(const char *formatstr, int param, const char *checkstr) -{ - int ret; - short int n = -1; - - ret = DoVprintf(formatstr, &n); - - if (n != param) - { - Fail("Expected count parameter to resolve to %d, got %d\n", param, n); - } - - if (ret != strlen(checkstr)) - { - Fail("Expected vprintf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} -#define DoShortCountTest DoShortCountTest_vprintf - -inline void DoCharTest_vprintf(const char *formatstr, char param, const char *checkstr) -{ - int ret; - - ret = DoVprintf(formatstr, param); - if (ret != strlen(checkstr)) - { - Fail("Expected vprintf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} -#define DoCharTest DoCharTest_vprintf - -inline void DoWCharTest_vprintf(const char *formatstr, WCHAR param, const char *checkstr) -{ - int ret; - - ret = DoVprintf(formatstr, param); - if (ret != strlen(checkstr)) - { - Fail("Expected vprintf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} -#define DoWCharTest DoWCharTest_vprintf - -inline void DoNumTest_vprintf(const char *formatstr, int param, const char *checkstr) -{ - int ret; - - ret = DoVprintf(formatstr, param); - if (ret != strlen(checkstr)) - { - Fail("Expected vprintf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} -#define DoNumTest DoNumTest_vprintf - -inline void DoI64Test_vprintf(const char *formatstr, INT64 param, char *valuestr, const char *checkstr1) -{ - int ret; - - ret = DoVprintf(formatstr, param); - if (ret != strlen(checkstr1)) - { - Fail("Expected vprintf to return %d, got %d.\n", - strlen(checkstr1), ret); - } -} -#define DoI64Test DoI64Test_vprintf - -inline void DoDoubleTest_vprintf(const char *formatstr, double param, const char *checkstr1, - const char *checkstr2) -{ - int ret; - - ret = DoVprintf(formatstr, param); - if (ret != strlen(checkstr1) && ret != strlen(checkstr2)) - { - Fail("Expected vprintf to return %d or %d, got %d.\n", - strlen(checkstr1), strlen(checkstr2), ret); - } -} -#define DoDoubleTest DoDoubleTest_vprintf - -inline void DoArgumentPrecTest_vprintf(const char *formatstr, int precision, void *param, - char *paramstr, const char *checkstr1, const char *checkstr2) -{ - int ret; - - ret = DoVprintf(formatstr, precision, param); - if (ret != strlen(checkstr1) && ret != strlen(checkstr2)) - { - Fail("Expected vprintf to return %d or %d, got %d.\n", - strlen(checkstr1), strlen(checkstr2), ret); - } -} -#define DoArgumentPrecTest DoArgumentPrecTest_vprintf - -inline void DoArgumentPrecDoubleTest_vprintf(const char *formatstr, int precision, double param, - const char *checkstr1, const char *checkstr2) -{ - int ret; - - ret = DoVprintf(formatstr, precision, param); - if (ret != strlen(checkstr1) && ret != strlen(checkstr2)) - { - Fail("Expected vprintf to return %d or %d, got %d.\n", - strlen(checkstr1), strlen(checkstr2), ret); - } -} -#define DoArgumentPrecDoubleTest DoArgumentPrecDoubleTest_vprintf - -#endif - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test1/test1.cpp deleted file mode 100644 index 74e4b0c..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test1/test1.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Test #1 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -PALTEST(c_runtime_vsprintf_test1_paltest_vsprintf_test1, "c_runtime/vsprintf/test1/paltest_vsprintf_test1") -{ - char checkstr[] = "hello world"; - char buf[256] = { 0 }; - int ret; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - testvsp(buf, ARRAY_SIZE(buf), "hello world"); - - if (memcmp(checkstr, buf, strlen(checkstr)+1) != 0) - { - Fail("ERROR: expected \"%s\" (up to %d chars), got \"%s\"\n", - checkstr, 256, buf); - } - - testvsp(buf, ARRAY_SIZE(buf), "xxxxxxxxxxxxxxxxx"); - ret = testvsp(buf, ARRAY_SIZE(buf), "hello world"); - - if (ret != strlen(checkstr)) - { - Fail("ERROR: expected negative return value, got %d", ret); - } - - if (memcmp(checkstr, buf, ret) != 0) - { - Fail("ERROR: expected %s, got %s\n", checkstr, buf); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test10/test10.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test10/test10.cpp deleted file mode 100644 index 57523d7..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test10/test10.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test10.c -** -** Purpose: Test #10 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -PALTEST(c_runtime_vsprintf_test10_paltest_vsprintf_test10, "c_runtime/vsprintf/test10/paltest_vsprintf_test10") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest("foo %o", pos, "foo 52"); - DoNumTest("foo %lo", 0xFFFF, "foo 177777"); - DoNumTest("foo %ho", 0xFFFF, "foo 177777"); - DoNumTest("foo %Lo", pos, "foo 52"); - DoI64Test("foo %I64o", l, "42", "foo 52"); - DoNumTest("foo %3o", pos, "foo 52"); - DoNumTest("foo %-3o", pos, "foo 52 "); - DoNumTest("foo %.1o", pos, "foo 52"); - DoNumTest("foo %.3o", pos, "foo 052"); - DoNumTest("foo %03o", pos, "foo 052"); - DoNumTest("foo %#o", pos, "foo 052"); - DoNumTest("foo %+o", pos, "foo 52"); - DoNumTest("foo % o", pos, "foo 52"); - DoNumTest("foo %+o", neg, "foo 37777777726"); - DoNumTest("foo % o", neg, "foo 37777777726"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test11/test11.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test11/test11.cpp deleted file mode 100644 index 8524870..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test11/test11.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test11.c -** -** Purpose: Test #11 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -PALTEST(c_runtime_vsprintf_test11_paltest_vsprintf_test11, "c_runtime/vsprintf/test11/paltest_vsprintf_test11") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest("foo %u", pos, "foo 42"); - DoNumTest("foo %lu", 0xFFFF, "foo 65535"); - DoNumTest("foo %hu", 0xFFFF, "foo 65535"); - DoNumTest("foo %Lu", pos, "foo 42"); - DoI64Test("foo %I64u", l, "42", "foo 42"); - DoNumTest("foo %3u", pos, "foo 42"); - DoNumTest("foo %-3u", pos, "foo 42 "); - DoNumTest("foo %.1u", pos, "foo 42"); - DoNumTest("foo %.3u", pos, "foo 042"); - DoNumTest("foo %03u", pos, "foo 042"); - DoNumTest("foo %#u", pos, "foo 42"); - DoNumTest("foo %+u", pos, "foo 42"); - DoNumTest("foo % u", pos, "foo 42"); - DoNumTest("foo %+u", neg, "foo 4294967254"); - DoNumTest("foo % u", neg, "foo 4294967254"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test12/test12.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test12/test12.cpp deleted file mode 100644 index 5b82544..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test12/test12.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test12.c -** -** Purpose: Test #12 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -PALTEST(c_runtime_vsprintf_test12_paltest_vsprintf_test12, "c_runtime/vsprintf/test12/paltest_vsprintf_test12") -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return (FAIL); - } - - DoNumTest("foo %x", pos, "foo 1234ab"); - DoNumTest("foo %lx", pos, "foo 1234ab"); - DoNumTest("foo %hx", pos, "foo 34ab"); - DoNumTest("foo %Lx", pos, "foo 1234ab"); - DoI64Test("foo %I64x", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7x", pos, "foo 1234ab"); - DoNumTest("foo %-7x", pos, "foo 1234ab "); - DoNumTest("foo %.1x", pos, "foo 1234ab"); - DoNumTest("foo %.7x", pos, "foo 01234ab"); - DoNumTest("foo %07x", pos, "foo 01234ab"); - DoNumTest("foo %#x", pos, "foo 0x1234ab"); - DoNumTest("foo %+x", pos, "foo 1234ab"); - DoNumTest("foo % x", pos, "foo 1234ab"); - DoNumTest("foo %+x", neg, "foo ffffffd6"); - DoNumTest("foo % x", neg, "foo ffffffd6"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test13/test13.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test13/test13.cpp deleted file mode 100644 index b3b7001..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test13/test13.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test13.c -** -** Purpose: Test #13 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -PALTEST(c_runtime_vsprintf_test13_paltest_vsprintf_test13, "c_runtime/vsprintf/test13/paltest_vsprintf_test13") -{ - int neg = -42; - int pos = 0x1234AB; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest("foo %X", pos, "foo 1234AB"); - DoNumTest("foo %lX", pos, "foo 1234AB"); - DoNumTest("foo %hX", pos, "foo 34AB"); - DoNumTest("foo %LX", pos, "foo 1234AB"); - DoI64Test("foo %I64X", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7X", pos, "foo 1234AB"); - DoNumTest("foo %-7X", pos, "foo 1234AB "); - DoNumTest("foo %.1X", pos, "foo 1234AB"); - DoNumTest("foo %.7X", pos, "foo 01234AB"); - DoNumTest("foo %07X", pos, "foo 01234AB"); - DoNumTest("foo %#X", pos, "foo 0X1234AB"); - DoNumTest("foo %+X", pos, "foo 1234AB"); - DoNumTest("foo % X", pos, "foo 1234AB"); - DoNumTest("foo %+X", neg, "foo FFFFFFD6"); - DoNumTest("foo % X", neg, "foo FFFFFFD6"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test14/test14.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test14/test14.cpp deleted file mode 100644 index 7c8ed0e..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test14/test14.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test14.c -** -** Purpose: Test #14 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -PALTEST(c_runtime_vsprintf_test14_paltest_vsprintf_test14, "c_runtime/vsprintf/test14/paltest_vsprintf_test14") -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest("foo %e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %he", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %Le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %I64e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %14e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %-14e", val, "foo 2.560000e+002 ", "foo 2.560000e+02 "); - DoDoubleTest("foo %.1e", val, "foo 2.6e+002", "foo 2.6e+02"); - DoDoubleTest("foo %.8e", val, "foo 2.56000000e+002", "foo 2.56000000e+02"); - DoDoubleTest("foo %014e", val, "foo 02.560000e+002", "foo 002.560000e+02"); - DoDoubleTest("foo %#e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", val, "foo +2.560000e+002", "foo +2.560000e+02"); - DoDoubleTest("foo % e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - DoDoubleTest("foo % e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test15/test15.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test15/test15.cpp deleted file mode 100644 index ccf2a32..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test15/test15.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test15.c -** -** Purpose: Test #15 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -PALTEST(c_runtime_vsprintf_test15_paltest_vsprintf_test15, "c_runtime/vsprintf/test15/paltest_vsprintf_test15") -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest("foo %E", val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest("foo %lE", val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest("foo %hE", val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest("foo %LE", val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest("foo %I64E", val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest("foo %14E", val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest("foo %-14E", val, "foo 2.560000E+002 ", - "foo 2.560000E+02 "); - DoDoubleTest("foo %.1E", val, "foo 2.6E+002", - "foo 2.6E+02"); - DoDoubleTest("foo %.8E", val, "foo 2.56000000E+002", - "foo 2.56000000E+02"); - DoDoubleTest("foo %014E", val, "foo 02.560000E+002", - "foo 002.560000E+02"); - DoDoubleTest("foo %#E", val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest("foo %+E", val, "foo +2.560000E+002", - "foo +2.560000E+02"); - DoDoubleTest("foo % E", val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest("foo %+E", neg, "foo -2.560000E+002", - "foo -2.560000E+02"); - DoDoubleTest("foo % E", neg, "foo -2.560000E+002", - "foo -2.560000E+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test16/test16.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test16/test16.cpp deleted file mode 100644 index 8130771..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test16/test16.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test16.c -** -** Purpose: Test #16 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -PALTEST(c_runtime_vsprintf_test16_paltest_vsprintf_test16, "c_runtime/vsprintf/test16/paltest_vsprintf_test16") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest("foo %f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %hf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %Lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %I64f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %12f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %-12f", val, "foo 2560.001000 ", "foo 2560.001000 "); - DoDoubleTest("foo %.1f", val, "foo 2560.0", "foo 2560.0"); - DoDoubleTest("foo %.8f", val, "foo 2560.00100000", "foo 2560.00100000"); - DoDoubleTest("foo %012f", val, "foo 02560.001000", "foo 02560.001000"); - DoDoubleTest("foo %#f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", val, "foo +2560.001000", "foo +2560.001000"); - DoDoubleTest("foo % f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", neg, "foo -2560.001000", "foo -2560.001000"); - DoDoubleTest("foo % f", neg, "foo -2560.001000", "foo -2560.001000"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test17/test17.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test17/test17.cpp deleted file mode 100644 index efc3344..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test17/test17.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test17.c -** -** Purpose: Test #17 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -PALTEST(c_runtime_vsprintf_test17_paltest_vsprintf_test17, "c_runtime/vsprintf/test17/paltest_vsprintf_test17") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest("foo %g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %Lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5g", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1g", val, "foo 3e+003", "foo 3e+03"); - DoDoubleTest("foo %.2g", val, "foo 2.6e+003", "foo 2.6e+03"); - DoDoubleTest("foo %.12g", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06g", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#g", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+g", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+g", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % g", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test18/test18.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test18/test18.cpp deleted file mode 100644 index 318df06..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test18/test18.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test18.c -** -** Purpose: Test #18 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -PALTEST(c_runtime_vsprintf_test18_paltest_vsprintf_test18, "c_runtime/vsprintf/test18/paltest_vsprintf_test18") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest("foo %G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %LG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5G", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1G", val, "foo 3E+003", "foo 3E+03"); - DoDoubleTest("foo %.2G", val, "foo 2.6E+003", "foo 2.6E+03"); - DoDoubleTest("foo %.12G", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06G", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#G", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+G", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+G", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % G", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test19/test19.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test19/test19.cpp deleted file mode 100644 index 622e2f0..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test19/test19.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test19.c -** -** Purpose: Test #19 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -PALTEST(c_runtime_vsprintf_test19_paltest_vsprintf_test19, "c_runtime/vsprintf/test19/paltest_vsprintf_test19") -{ - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - - DoArgumentPrecTest("%.*s", 2, (void*)"bar", "bar", "ba", "ba"); - DoArgumentPrecTest("%.*S", 2, (void*)convert("bar"), "bar", "ba", "ba"); - DoArgumentPrecTest("%.*c", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*c", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*d", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*d", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*i", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*i", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*o", 1, (void*)42, "42", "52", "52"); - DoArgumentPrecTest("%.*o", 3, (void*)42, "42", "052", "052"); - DoArgumentPrecTest("%.*u", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*u", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*x", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*x", 3, (void*)0x42, "0x42", "042", "042"); - DoArgumentPrecTest("%.*X", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*X", 3, (void*)0x42, "0x42", "042", "042"); - - - DoArgumentPrecDoubleTest("%.*e", 1, 2.01, "2.0e+000", "2.0e+00"); - DoArgumentPrecDoubleTest("%.*e", 3, 2.01, "2.010e+000", "2.010e+00"); - DoArgumentPrecDoubleTest("%.*E", 1, 2.01, "2.0E+000", "2.0E+00"); - DoArgumentPrecDoubleTest("%.*E", 3, 2.01, "2.010E+000", "2.010E+00"); - DoArgumentPrecDoubleTest("%.*f", 1, 2.01, "2.0", "2.0"); - DoArgumentPrecDoubleTest("%.*f", 3, 2.01, "2.010", "2.010"); - DoArgumentPrecDoubleTest("%.*g", 1, 256.01, "3e+002", "3e+02"); - DoArgumentPrecDoubleTest("%.*g", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 6, 256.01, "256.01", "256.01"); - DoArgumentPrecDoubleTest("%.*G", 1, 256.01, "3E+002", "3E+02"); - DoArgumentPrecDoubleTest("%.*G", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 6, 256.01, "256.01", "256.01"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test2/test2.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test2/test2.cpp deleted file mode 100644 index 0c91e8f..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test2/test2.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test2.c -** -** Purpose: Test #2 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" -/* - * Notes: memcmp is used, as is strlen. - */ - -PALTEST(c_runtime_vsprintf_test2_paltest_vsprintf_test2, "c_runtime/vsprintf/test2/paltest_vsprintf_test2") -{ - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoStrTest("foo %s", "bar", "foo bar"); - DoStrTest("foo %hs", "bar", "foo bar"); - DoWStrTest("foo %ls", convert("bar"), "foo bar"); - DoWStrTest("foo %ws", convert("bar"), "foo bar"); - DoStrTest("foo %Ls", "bar", "foo bar"); - DoStrTest("foo %I64s", "bar", "foo bar"); - DoStrTest("foo %5s", "bar", "foo bar"); - DoStrTest("foo %.2s", "bar", "foo ba"); - DoStrTest("foo %5.2s", "bar", "foo ba"); - DoStrTest("foo %-5s", "bar", "foo bar "); - DoStrTest("foo %05s", "bar", "foo 00bar"); - DoStrTest("foo %s", NULL, "foo (null)"); - DoStrTest("foo %hs", NULL, "foo (null)"); - DoWStrTest("foo %ls", NULL, "foo (null)"); - DoWStrTest("foo %ws", NULL, "foo (null)"); - DoStrTest("foo %Ls", NULL, "foo (null)"); - DoStrTest("foo %I64s", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test3/test3.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test3/test3.cpp deleted file mode 100644 index adfe6fb..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test3/test3.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test3.c -** -** Purpose: Test #3 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -PALTEST(c_runtime_vsprintf_test3_paltest_vsprintf_test3, "c_runtime/vsprintf/test3/paltest_vsprintf_test3") -{ - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoWStrTest("foo %S", convert("bar"), "foo bar"); - DoStrTest("foo %hS", "bar", "foo bar"); - DoWStrTest("foo %lS", convert("bar"), "foo bar"); - DoWStrTest("foo %wS", convert("bar"), "foo bar"); - DoWStrTest("foo %LS", convert("bar"), "foo bar"); - DoWStrTest("foo %I64S", convert("bar"), "foo bar"); - DoWStrTest("foo %5S", convert("bar"), "foo bar"); - DoWStrTest("foo %.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %5.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %-5S", convert("bar"), "foo bar "); - DoWStrTest("foo %05S", convert("bar"), "foo 00bar"); - DoWStrTest("foo %S", NULL, "foo (null)"); - DoStrTest("foo %hS", NULL, "foo (null)"); - DoWStrTest("foo %lS", NULL, "foo (null)"); - DoWStrTest("foo %wS", NULL, "foo (null)"); - DoWStrTest("foo %LS", NULL, "foo (null)"); - DoWStrTest("foo %I64S", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test4/test4.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test4/test4.cpp deleted file mode 100644 index 9318f06..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test4/test4.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test4.c -** -** Purpose: Test #4 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -PALTEST(c_runtime_vsprintf_test4_paltest_vsprintf_test4, "c_runtime/vsprintf/test4/paltest_vsprintf_test4") -{ - void *ptr = (void*) 0x123456; - INT64 lptr = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } -/* -** Run only on 64 bit platforms -*/ -#if defined(HOST_64BIT) - Trace("Testing for 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "0000000000000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%-17p", ptr, "pointer to 0x123456", "0000000000123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X0000000000123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64DoubleTest("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); -#else - Trace("Testing for Non 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "00000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%9p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%09p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%-9p", ptr, "pointer to 0x123456", "00123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X00123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64DoubleTest("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); -#endif - - - - - - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test6/test6.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test6/test6.cpp deleted file mode 100644 index 4560fb2..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test6/test6.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test6.c -** -** Purpose: Test #6 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -PALTEST(c_runtime_vsprintf_test6_paltest_vsprintf_test6, "c_runtime/vsprintf/test6/paltest_vsprintf_test6") -{ - WCHAR wc = (WCHAR) 'c'; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoCharTest("foo %c", 'b', "foo b"); - DoCharTest("foo %hc", 'b', "foo b"); - DoWCharTest("foo %lc", wc, "foo c"); - DoCharTest("foo %Lc", 'b', "foo b"); - DoCharTest("foo %I64c", 'b', "foo b"); - DoCharTest("foo %5c", 'b', "foo b"); - DoCharTest("foo %.0c", 'b', "foo b"); - DoCharTest("foo %-5c", 'b', "foo b "); - DoCharTest("foo %05c", 'b', "foo 0000b"); - DoCharTest("foo % c", 'b', "foo b"); - DoCharTest("foo %#c", 'b', "foo b"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test7/test7.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test7/test7.cpp deleted file mode 100644 index 9bdd339..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test7/test7.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test7.c -** -** Purpose: Test #7 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" -/* - * Notes: memcmp is used, as is strlen. - */ - - -PALTEST(c_runtime_vsprintf_test7_paltest_vsprintf_test7, "c_runtime/vsprintf/test7/paltest_vsprintf_test7") -{ - WCHAR wb = (WCHAR) 'b'; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoWCharTest("foo %c", wb, "foo b"); - DoWCharTest("foo %hc", wb, "foo b"); - DoCharTest("foo %lc", 'c', "foo c"); - DoWCharTest("foo %Lc", wb, "foo b"); - DoWCharTest("foo %I64c", wb, "foo b"); - DoWCharTest("foo %5c", wb, "foo b"); - DoWCharTest("foo %.0c", wb, "foo b"); - DoWCharTest("foo %-5c", wb, "foo b "); - DoWCharTest("foo %05c", wb, "foo 0000b"); - DoWCharTest("foo % c", wb, "foo b"); - DoWCharTest("foo %#c", wb, "foo b"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test8/test8.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test8/test8.cpp deleted file mode 100644 index c805dc5..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test8/test8.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test8.c -** -** Purpose: Test #8 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -PALTEST(c_runtime_vsprintf_test8_paltest_vsprintf_test8, "c_runtime/vsprintf/test8/paltest_vsprintf_test8") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest("foo %d", pos, "foo 42"); - DoNumTest("foo %ld", 0xFFFF, "foo 65535"); - DoNumTest("foo %hd", 0xFFFF, "foo -1"); - DoNumTest("foo %Ld", pos, "foo 42"); - DoI64Test("foo %I64d", l, "42", "foo 42"); - DoNumTest("foo %3d", pos, "foo 42"); - DoNumTest("foo %-3d", pos, "foo 42 "); - DoNumTest("foo %.1d", pos, "foo 42"); - DoNumTest("foo %.3d", pos, "foo 042"); - DoNumTest("foo %03d", pos, "foo 042"); - DoNumTest("foo %#d", pos, "foo 42"); - DoNumTest("foo %+d", pos, "foo +42"); - DoNumTest("foo % d", pos, "foo 42"); - DoNumTest("foo %+d", neg, "foo -42"); - DoNumTest("foo % d", neg, "foo -42"); - - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test9/test9.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test9/test9.cpp deleted file mode 100644 index 5f27679..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test9/test9.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: test9.c -** -** Purpose: Test #9 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -PALTEST(c_runtime_vsprintf_test9_paltest_vsprintf_test9, "c_runtime/vsprintf/test9/paltest_vsprintf_test9") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest("foo %i", pos, "foo 42"); - DoNumTest("foo %li", 0xFFFF, "foo 65535"); - DoNumTest("foo %hi", 0xFFFF, "foo -1"); - DoNumTest("foo %Li", pos, "foo 42"); - DoI64Test("foo %I64i", l, "42", "foo 42"); - DoNumTest("foo %3i", pos, "foo 42"); - DoNumTest("foo %-3i", pos, "foo 42 "); - DoNumTest("foo %.1i", pos, "foo 42"); - DoNumTest("foo %.3i", pos, "foo 042"); - DoNumTest("foo %03i", pos, "foo 042"); - DoNumTest("foo %#i", pos, "foo 42"); - DoNumTest("foo %+i", pos, "foo +42"); - DoNumTest("foo % i", pos, "foo 42"); - DoNumTest("foo %+i", neg, "foo -42"); - DoNumTest("foo % i", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/vsprintf.h b/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/vsprintf.h deleted file mode 100644 index 638f904..0000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/vsprintf.h +++ /dev/null @@ -1,232 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: vsprintf.h -** -** Purpose: Helper functions for the vsprintf tests. -** -** -**===================================================================*/ -#ifndef __VSPRINTF_H__ -#define __VSPRINTF_H__ - -/* These functions leaks memory a lot. C'est la vie. */ -inline int testvsp(char* buf, size_t buffSize, const char* format, ...) -{ - int retVal; - va_list arglist; - - va_start(arglist, format); - retVal = _vsnprintf_s(buf, buffSize, _TRUNCATE, format, arglist); - va_end(arglist); - - return (retVal); -} - -inline void DoStrTest_vsprintf(const char *formatstr, char* param, const char *checkstr) -{ - char buf[256] = { 0 }; - - testvsp(buf, ARRAY_SIZE(buf), formatstr, param); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert string \"%s\" into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, formatstr, checkstr, buf); - } -} -#define DoStrTest DoStrTest_vsprintf - -inline void DoWStrTest_vsprintf(const char *formatstr, WCHAR* param, const char *checkstr) -{ - char buf[256] = { 0 }; - - testvsp(buf, ARRAY_SIZE(buf), formatstr, param); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert wide string \"%s\" into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - convertC(param), formatstr, checkstr, buf); - } -} -#define DoWStrTest DoWStrTest_vsprintf - -inline void DoCharTest_vsprintf(const char *formatstr, char param, const char *checkstr) -{ - char buf[256] = { 0 }; - - testvsp(buf, ARRAY_SIZE(buf), formatstr, param); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, param, formatstr, checkstr, buf); - } -} -#define DoCharTest DoCharTest_vsprintf - -inline void DoWCharTest_vsprintf(const char *formatstr, WCHAR param, const char *checkstr) -{ - char buf[256] = { 0 }; - - testvsp(buf, ARRAY_SIZE(buf), formatstr, param); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - (char)param, param, formatstr, checkstr, buf); - } -} -#define DoWCharTest DoWCharTest_vsprintf - -inline void DoNumTest_vsprintf(const char *formatstr, int value, const char *checkstr) -{ - char buf[256] = { 0 }; - - testvsp(buf, ARRAY_SIZE(buf), formatstr, value); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert %#x into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - value, formatstr, checkstr, buf); - } -} -#define DoNumTest DoNumTest_vsprintf - -inline void DoI64Test_vsprintf(const char *formatstr, INT64 value, char *valuestr, const char *checkstr) -{ - char buf[256] = { 0 }; - - testvsp(buf, ARRAY_SIZE(buf), formatstr, value); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - valuestr, formatstr, checkstr, buf); - } -} -#define DoI64Test DoI64Test_vsprintf - -inline void DoDoubleTest_vsprintf(const char *formatstr, double value, const char *checkstr1, char -*checkstr2) -{ - char buf[256] = { 0 }; - - testvsp(buf, ARRAY_SIZE(buf), formatstr, value); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\"\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - value, formatstr, checkstr1, checkstr2, buf); - } -} -#define DoDoubleTest DoDoubleTest_vsprintf - -/*FROM TEST 9*/ -inline void DoArgumentPrecTest_vsprintf(const char *formatstr, int precision, void *param, - char *paramstr, const char *checkstr1, const char *checkstr2) -{ - char buf[256]; - - testvsp(buf, ARRAY_SIZE(buf), formatstr, precision, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", paramstr, formatstr, - precision, checkstr1, checkstr2, buf); - } - -} -#define DoArgumentPrecTest DoArgumentPrecTest_vsprintf - -inline void DoArgumentPrecDoubleTest_vsprintf(const char *formatstr, int precision, double param, - const char *checkstr1, const char *checkstr2) -{ - char buf[256]; - - testvsp(buf, ARRAY_SIZE(buf), formatstr, precision, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", param, formatstr, - precision, checkstr1, checkstr2, buf); - } -} -#define DoArgumentPrecDoubleTest DoArgumentPrecDoubleTest_vsprintf - -/*FROM TEST4*/ -inline void DoPointerTest_vsprintf(const char *formatstr, void* param, char* paramstr, - const char *checkstr1) -{ - char buf[256] = { 0 }; - - testvsp(buf, ARRAY_SIZE(buf), formatstr, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1)) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - paramstr, formatstr, checkstr1, buf); - } -} -#define DoPointerTest DoPointerTest_vsprintf - -inline void DoI64DoubleTest_vsprintf(const char *formatstr, INT64 value, char *valuestr, - const char *checkstr1) -{ - char buf[256] = { 0 }; - - testvsp(buf, ARRAY_SIZE(buf), formatstr, value); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\", got \"%s\".\n", - valuestr, formatstr, checkstr1, buf); - } -} -#define DoI64DoubleTest DoI64DoubleTest_vsprintf - -inline void DoTest_vsprintf(const char *formatstr, int param, const char *checkstr) -{ - char buf[256] = { 0 }; - int n = -1; - - testvsp(buf, ARRAY_SIZE(buf), formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } -} -#define DoTest DoTest_vsprintf - -inline void DoShortTest_vsprintf(const char *formatstr, int param, const char *checkstr) -{ - char buf[256] = { 0 }; - short int n = -1; - - testvsp(buf, ARRAY_SIZE(buf), formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } -} -#define DoShortTest DoShortTest_vsprintf - -#endif - diff --git a/src/coreclr/pal/tests/palsuite/compilableTests.txt b/src/coreclr/pal/tests/palsuite/compilableTests.txt index 4fb7c50..851ccd5 100644 --- a/src/coreclr/pal/tests/palsuite/compilableTests.txt +++ b/src/coreclr/pal/tests/palsuite/compilableTests.txt @@ -52,25 +52,6 @@ c_runtime/fopen/test4/paltest_fopen_test4 c_runtime/fopen/test5/paltest_fopen_test5 c_runtime/fopen/test6/paltest_fopen_test6 c_runtime/fopen/test7/paltest_fopen_test7 -c_runtime/fprintf/test1/paltest_fprintf_test1 -c_runtime/fprintf/test10/paltest_fprintf_test10 -c_runtime/fprintf/test11/paltest_fprintf_test11 -c_runtime/fprintf/test12/paltest_fprintf_test12 -c_runtime/fprintf/test13/paltest_fprintf_test13 -c_runtime/fprintf/test14/paltest_fprintf_test14 -c_runtime/fprintf/test15/paltest_fprintf_test15 -c_runtime/fprintf/test16/paltest_fprintf_test16 -c_runtime/fprintf/test17/paltest_fprintf_test17 -c_runtime/fprintf/test18/paltest_fprintf_test18 -c_runtime/fprintf/test19/paltest_fprintf_test19 -c_runtime/fprintf/test2/paltest_fprintf_test2 -c_runtime/fprintf/test3/paltest_fprintf_test3 -c_runtime/fprintf/test4/paltest_fprintf_test4 -c_runtime/fprintf/test5/paltest_fprintf_test5 -c_runtime/fprintf/test6/paltest_fprintf_test6 -c_runtime/fprintf/test7/paltest_fprintf_test7 -c_runtime/fprintf/test8/paltest_fprintf_test8 -c_runtime/fprintf/test9/paltest_fprintf_test9 c_runtime/fputs/test1/paltest_fputs_test1 c_runtime/fputs/test2/paltest_fputs_test2 c_runtime/fread/test1/paltest_fread_test1 @@ -109,25 +90,6 @@ c_runtime/modf/test1/paltest_modf_test1 c_runtime/modff/test1/paltest_modff_test1 c_runtime/pow/test1/paltest_pow_test1 c_runtime/powf/test1/paltest_powf_test1 -c_runtime/printf/test1/paltest_printf_test1 -c_runtime/printf/test10/paltest_printf_test10 -c_runtime/printf/test11/paltest_printf_test11 -c_runtime/printf/test12/paltest_printf_test12 -c_runtime/printf/test13/paltest_printf_test13 -c_runtime/printf/test14/paltest_printf_test14 -c_runtime/printf/test15/paltest_printf_test15 -c_runtime/printf/test16/paltest_printf_test16 -c_runtime/printf/test17/paltest_printf_test17 -c_runtime/printf/test18/paltest_printf_test18 -c_runtime/printf/test19/paltest_printf_test19 -c_runtime/printf/test2/paltest_printf_test2 -c_runtime/printf/test3/paltest_printf_test3 -c_runtime/printf/test4/paltest_printf_test4 -c_runtime/printf/test5/paltest_printf_test5 -c_runtime/printf/test6/paltest_printf_test6 -c_runtime/printf/test7/paltest_printf_test7 -c_runtime/printf/test8/paltest_printf_test8 -c_runtime/printf/test9/paltest_printf_test9 c_runtime/qsort/test1/paltest_qsort_test1 c_runtime/qsort/test2/paltest_qsort_test2 c_runtime/rand_srand/test1/paltest_rand_srand_test1 @@ -138,24 +100,6 @@ c_runtime/sincosf/test1/paltest_sincosf_test1 c_runtime/sinf/test1/paltest_sinf_test1 c_runtime/sinh/test1/paltest_sinh_test1 c_runtime/sinhf/test1/paltest_sinhf_test1 -c_runtime/sprintf_s/test1/paltest_sprintf_test1 -c_runtime/sprintf_s/test10/paltest_sprintf_test10 -c_runtime/sprintf_s/test11/paltest_sprintf_test11 -c_runtime/sprintf_s/test12/paltest_sprintf_test12 -c_runtime/sprintf_s/test13/paltest_sprintf_test13 -c_runtime/sprintf_s/test14/paltest_sprintf_test14 -c_runtime/sprintf_s/test15/paltest_sprintf_test15 -c_runtime/sprintf_s/test16/paltest_sprintf_test16 -c_runtime/sprintf_s/test17/paltest_sprintf_test17 -c_runtime/sprintf_s/test18/paltest_sprintf_test18 -c_runtime/sprintf_s/test19/paltest_sprintf_test19 -c_runtime/sprintf_s/test2/paltest_sprintf_test2 -c_runtime/sprintf_s/test3/paltest_sprintf_test3 -c_runtime/sprintf_s/test4/paltest_sprintf_test4 -c_runtime/sprintf_s/test6/paltest_sprintf_test6 -c_runtime/sprintf_s/test7/paltest_sprintf_test7 -c_runtime/sprintf_s/test8/paltest_sprintf_test8 -c_runtime/sprintf_s/test9/paltest_sprintf_test9 c_runtime/sqrt/test1/paltest_sqrt_test1 c_runtime/sqrtf/test1/paltest_sqrtf_test1 c_runtime/sscanf_s/test1/paltest_sscanf_test1 @@ -199,61 +143,6 @@ c_runtime/tolower/test1/paltest_tolower_test1 c_runtime/toupper/test1/paltest_toupper_test1 c_runtime/towlower/test1/paltest_towlower_test1 c_runtime/towupper/test1/paltest_towupper_test1 -c_runtime/vfprintf/test1/paltest_vfprintf_test1 -c_runtime/vfprintf/test10/paltest_vfprintf_test10 -c_runtime/vfprintf/test11/paltest_vfprintf_test11 -c_runtime/vfprintf/test12/paltest_vfprintf_test12 -c_runtime/vfprintf/test13/paltest_vfprintf_test13 -c_runtime/vfprintf/test14/paltest_vfprintf_test14 -c_runtime/vfprintf/test15/paltest_vfprintf_test15 -c_runtime/vfprintf/test16/paltest_vfprintf_test16 -c_runtime/vfprintf/test17/paltest_vfprintf_test17 -c_runtime/vfprintf/test18/paltest_vfprintf_test18 -c_runtime/vfprintf/test19/paltest_vfprintf_test19 -c_runtime/vfprintf/test2/paltest_vfprintf_test2 -c_runtime/vfprintf/test3/paltest_vfprintf_test3 -c_runtime/vfprintf/test4/paltest_vfprintf_test4 -c_runtime/vfprintf/test5/paltest_vfprintf_test5 -c_runtime/vfprintf/test6/paltest_vfprintf_test6 -c_runtime/vfprintf/test7/paltest_vfprintf_test7 -c_runtime/vfprintf/test8/paltest_vfprintf_test8 -c_runtime/vfprintf/test9/paltest_vfprintf_test9 -c_runtime/vprintf/test10/paltest_vprintf_test10 -c_runtime/vprintf/test11/paltest_vprintf_test11 -c_runtime/vprintf/test12/paltest_vprintf_test12 -c_runtime/vprintf/test13/paltest_vprintf_test13 -c_runtime/vprintf/test14/paltest_vprintf_test14 -c_runtime/vprintf/test15/paltest_vprintf_test15 -c_runtime/vprintf/test16/paltest_vprintf_test16 -c_runtime/vprintf/test17/paltest_vprintf_test17 -c_runtime/vprintf/test18/paltest_vprintf_test18 -c_runtime/vprintf/test19/paltest_vprintf_test19 -c_runtime/vprintf/test2/paltest_vprintf_test2 -c_runtime/vprintf/test3/paltest_vprintf_test3 -c_runtime/vprintf/test4/paltest_vprintf_test4 -c_runtime/vprintf/test5/paltest_vprintf_test5 -c_runtime/vprintf/test6/paltest_vprintf_test6 -c_runtime/vprintf/test7/paltest_vprintf_test7 -c_runtime/vprintf/test8/paltest_vprintf_test8 -c_runtime/vprintf/test9/paltest_vprintf_test9 -c_runtime/vsprintf/test1/paltest_vsprintf_test1 -c_runtime/vsprintf/test10/paltest_vsprintf_test10 -c_runtime/vsprintf/test11/paltest_vsprintf_test11 -c_runtime/vsprintf/test12/paltest_vsprintf_test12 -c_runtime/vsprintf/test13/paltest_vsprintf_test13 -c_runtime/vsprintf/test14/paltest_vsprintf_test14 -c_runtime/vsprintf/test15/paltest_vsprintf_test15 -c_runtime/vsprintf/test16/paltest_vsprintf_test16 -c_runtime/vsprintf/test17/paltest_vsprintf_test17 -c_runtime/vsprintf/test18/paltest_vsprintf_test18 -c_runtime/vsprintf/test19/paltest_vsprintf_test19 -c_runtime/vsprintf/test2/paltest_vsprintf_test2 -c_runtime/vsprintf/test3/paltest_vsprintf_test3 -c_runtime/vsprintf/test4/paltest_vsprintf_test4 -c_runtime/vsprintf/test6/paltest_vsprintf_test6 -c_runtime/vsprintf/test7/paltest_vsprintf_test7 -c_runtime/vsprintf/test8/paltest_vsprintf_test8 -c_runtime/vsprintf/test9/paltest_vsprintf_test9 c_runtime/wcscat/test1/paltest_wcscat_test1 c_runtime/wcschr/test1/paltest_wcschr_test1 c_runtime/wcscmp/test1/paltest_wcscmp_test1 @@ -284,24 +173,6 @@ c_runtime/_putenv/test3/paltest_putenv_test3 c_runtime/_putenv/test4/paltest_putenv_test4 c_runtime/_rotl/test1/paltest_rotl_test1 c_runtime/_rotr/test1/paltest_rotr_test1 -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/_stricmp/test1/paltest_stricmp_test1 c_runtime/_strnicmp/test1/paltest_strnicmp_test1 c_runtime/_vsnprintf_s/test1/paltest_vsnprintf_test1 @@ -316,10 +187,8 @@ c_runtime/_vsnprintf_s/test17/paltest_vsnprintf_test17 c_runtime/_vsnprintf_s/test18/paltest_vsnprintf_test18 c_runtime/_vsnprintf_s/test19/paltest_vsnprintf_test19 c_runtime/_vsnprintf_s/test2/paltest_vsnprintf_test2 -c_runtime/_vsnprintf_s/test3/paltest_vsnprintf_test3 c_runtime/_vsnprintf_s/test4/paltest_vsnprintf_test4 c_runtime/_vsnprintf_s/test6/paltest_vsnprintf_test6 -c_runtime/_vsnprintf_s/test7/paltest_vsnprintf_test7 c_runtime/_vsnprintf_s/test8/paltest_vsnprintf_test8 c_runtime/_vsnprintf_s/test9/paltest_vsnprintf_test9 c_runtime/_wcsicmp/test1/paltest_wcsicmp_test1 diff --git a/src/coreclr/pal/tests/palsuite/paltestlist.txt b/src/coreclr/pal/tests/palsuite/paltestlist.txt index 5a410d7..6f064d9 100644 --- a/src/coreclr/pal/tests/palsuite/paltestlist.txt +++ b/src/coreclr/pal/tests/palsuite/paltestlist.txt @@ -49,25 +49,6 @@ c_runtime/fopen/test4/paltest_fopen_test4 c_runtime/fopen/test5/paltest_fopen_test5 c_runtime/fopen/test6/paltest_fopen_test6 c_runtime/fopen/test7/paltest_fopen_test7 -c_runtime/fprintf/test1/paltest_fprintf_test1 -c_runtime/fprintf/test10/paltest_fprintf_test10 -c_runtime/fprintf/test11/paltest_fprintf_test11 -c_runtime/fprintf/test12/paltest_fprintf_test12 -c_runtime/fprintf/test13/paltest_fprintf_test13 -c_runtime/fprintf/test14/paltest_fprintf_test14 -c_runtime/fprintf/test15/paltest_fprintf_test15 -c_runtime/fprintf/test16/paltest_fprintf_test16 -c_runtime/fprintf/test17/paltest_fprintf_test17 -c_runtime/fprintf/test18/paltest_fprintf_test18 -c_runtime/fprintf/test19/paltest_fprintf_test19 -c_runtime/fprintf/test2/paltest_fprintf_test2 -c_runtime/fprintf/test3/paltest_fprintf_test3 -c_runtime/fprintf/test4/paltest_fprintf_test4 -c_runtime/fprintf/test5/paltest_fprintf_test5 -c_runtime/fprintf/test6/paltest_fprintf_test6 -c_runtime/fprintf/test7/paltest_fprintf_test7 -c_runtime/fprintf/test8/paltest_fprintf_test8 -c_runtime/fprintf/test9/paltest_fprintf_test9 c_runtime/fputs/test1/paltest_fputs_test1 c_runtime/free/test1/paltest_free_test1 c_runtime/fseek/test1/paltest_fseek_test1 @@ -101,25 +82,6 @@ c_runtime/modf/test1/paltest_modf_test1 c_runtime/modff/test1/paltest_modff_test1 c_runtime/pow/test1/paltest_pow_test1 c_runtime/powf/test1/paltest_powf_test1 -c_runtime/printf/test1/paltest_printf_test1 -c_runtime/printf/test10/paltest_printf_test10 -c_runtime/printf/test11/paltest_printf_test11 -c_runtime/printf/test12/paltest_printf_test12 -c_runtime/printf/test13/paltest_printf_test13 -c_runtime/printf/test14/paltest_printf_test14 -c_runtime/printf/test15/paltest_printf_test15 -c_runtime/printf/test16/paltest_printf_test16 -c_runtime/printf/test17/paltest_printf_test17 -c_runtime/printf/test18/paltest_printf_test18 -c_runtime/printf/test19/paltest_printf_test19 -c_runtime/printf/test2/paltest_printf_test2 -c_runtime/printf/test3/paltest_printf_test3 -c_runtime/printf/test4/paltest_printf_test4 -c_runtime/printf/test5/paltest_printf_test5 -c_runtime/printf/test6/paltest_printf_test6 -c_runtime/printf/test7/paltest_printf_test7 -c_runtime/printf/test8/paltest_printf_test8 -c_runtime/printf/test9/paltest_printf_test9 c_runtime/qsort/test1/paltest_qsort_test1 c_runtime/qsort/test2/paltest_qsort_test2 c_runtime/rand_srand/test1/paltest_rand_srand_test1 @@ -130,24 +92,6 @@ c_runtime/sincosf/test1/paltest_sincosf_test1 c_runtime/sinf/test1/paltest_sinf_test1 c_runtime/sinh/test1/paltest_sinh_test1 c_runtime/sinhf/test1/paltest_sinhf_test1 -c_runtime/sprintf_s/test1/paltest_sprintf_test1 -c_runtime/sprintf_s/test10/paltest_sprintf_test10 -c_runtime/sprintf_s/test11/paltest_sprintf_test11 -c_runtime/sprintf_s/test12/paltest_sprintf_test12 -c_runtime/sprintf_s/test13/paltest_sprintf_test13 -c_runtime/sprintf_s/test14/paltest_sprintf_test14 -c_runtime/sprintf_s/test15/paltest_sprintf_test15 -c_runtime/sprintf_s/test16/paltest_sprintf_test16 -c_runtime/sprintf_s/test17/paltest_sprintf_test17 -c_runtime/sprintf_s/test18/paltest_sprintf_test18 -c_runtime/sprintf_s/test19/paltest_sprintf_test19 -c_runtime/sprintf_s/test2/paltest_sprintf_test2 -c_runtime/sprintf_s/test3/paltest_sprintf_test3 -c_runtime/sprintf_s/test4/paltest_sprintf_test4 -c_runtime/sprintf_s/test6/paltest_sprintf_test6 -c_runtime/sprintf_s/test7/paltest_sprintf_test7 -c_runtime/sprintf_s/test8/paltest_sprintf_test8 -c_runtime/sprintf_s/test9/paltest_sprintf_test9 c_runtime/sqrt/test1/paltest_sqrt_test1 c_runtime/sqrtf/test1/paltest_sqrtf_test1 c_runtime/sscanf_s/test1/paltest_sscanf_test1 @@ -191,61 +135,6 @@ c_runtime/tolower/test1/paltest_tolower_test1 c_runtime/toupper/test1/paltest_toupper_test1 c_runtime/towlower/test1/paltest_towlower_test1 c_runtime/towupper/test1/paltest_towupper_test1 -c_runtime/vfprintf/test1/paltest_vfprintf_test1 -c_runtime/vfprintf/test10/paltest_vfprintf_test10 -c_runtime/vfprintf/test11/paltest_vfprintf_test11 -c_runtime/vfprintf/test12/paltest_vfprintf_test12 -c_runtime/vfprintf/test13/paltest_vfprintf_test13 -c_runtime/vfprintf/test14/paltest_vfprintf_test14 -c_runtime/vfprintf/test15/paltest_vfprintf_test15 -c_runtime/vfprintf/test16/paltest_vfprintf_test16 -c_runtime/vfprintf/test17/paltest_vfprintf_test17 -c_runtime/vfprintf/test18/paltest_vfprintf_test18 -c_runtime/vfprintf/test19/paltest_vfprintf_test19 -c_runtime/vfprintf/test2/paltest_vfprintf_test2 -c_runtime/vfprintf/test3/paltest_vfprintf_test3 -c_runtime/vfprintf/test4/paltest_vfprintf_test4 -c_runtime/vfprintf/test5/paltest_vfprintf_test5 -c_runtime/vfprintf/test6/paltest_vfprintf_test6 -c_runtime/vfprintf/test7/paltest_vfprintf_test7 -c_runtime/vfprintf/test8/paltest_vfprintf_test8 -c_runtime/vfprintf/test9/paltest_vfprintf_test9 -c_runtime/vprintf/test10/paltest_vprintf_test10 -c_runtime/vprintf/test11/paltest_vprintf_test11 -c_runtime/vprintf/test12/paltest_vprintf_test12 -c_runtime/vprintf/test13/paltest_vprintf_test13 -c_runtime/vprintf/test14/paltest_vprintf_test14 -c_runtime/vprintf/test15/paltest_vprintf_test15 -c_runtime/vprintf/test16/paltest_vprintf_test16 -c_runtime/vprintf/test17/paltest_vprintf_test17 -c_runtime/vprintf/test18/paltest_vprintf_test18 -c_runtime/vprintf/test19/paltest_vprintf_test19 -c_runtime/vprintf/test2/paltest_vprintf_test2 -c_runtime/vprintf/test3/paltest_vprintf_test3 -c_runtime/vprintf/test4/paltest_vprintf_test4 -c_runtime/vprintf/test5/paltest_vprintf_test5 -c_runtime/vprintf/test6/paltest_vprintf_test6 -c_runtime/vprintf/test7/paltest_vprintf_test7 -c_runtime/vprintf/test8/paltest_vprintf_test8 -c_runtime/vprintf/test9/paltest_vprintf_test9 -c_runtime/vsprintf/test1/paltest_vsprintf_test1 -c_runtime/vsprintf/test10/paltest_vsprintf_test10 -c_runtime/vsprintf/test11/paltest_vsprintf_test11 -c_runtime/vsprintf/test12/paltest_vsprintf_test12 -c_runtime/vsprintf/test13/paltest_vsprintf_test13 -c_runtime/vsprintf/test14/paltest_vsprintf_test14 -c_runtime/vsprintf/test15/paltest_vsprintf_test15 -c_runtime/vsprintf/test16/paltest_vsprintf_test16 -c_runtime/vsprintf/test17/paltest_vsprintf_test17 -c_runtime/vsprintf/test18/paltest_vsprintf_test18 -c_runtime/vsprintf/test19/paltest_vsprintf_test19 -c_runtime/vsprintf/test2/paltest_vsprintf_test2 -c_runtime/vsprintf/test3/paltest_vsprintf_test3 -c_runtime/vsprintf/test4/paltest_vsprintf_test4 -c_runtime/vsprintf/test6/paltest_vsprintf_test6 -c_runtime/vsprintf/test7/paltest_vsprintf_test7 -c_runtime/vsprintf/test8/paltest_vsprintf_test8 -c_runtime/vsprintf/test9/paltest_vsprintf_test9 c_runtime/wcscat/test1/paltest_wcscat_test1 c_runtime/wcschr/test1/paltest_wcschr_test1 c_runtime/wcscmp/test1/paltest_wcscmp_test1 @@ -276,24 +165,6 @@ c_runtime/_putenv/test3/paltest_putenv_test3 c_runtime/_putenv/test4/paltest_putenv_test4 c_runtime/_rotl/test1/paltest_rotl_test1 c_runtime/_rotr/test1/paltest_rotr_test1 -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/_stricmp/test1/paltest_stricmp_test1 c_runtime/_strnicmp/test1/paltest_strnicmp_test1 c_runtime/_vsnprintf_s/test1/paltest_vsnprintf_test1 @@ -308,10 +179,8 @@ c_runtime/_vsnprintf_s/test17/paltest_vsnprintf_test17 c_runtime/_vsnprintf_s/test18/paltest_vsnprintf_test18 c_runtime/_vsnprintf_s/test19/paltest_vsnprintf_test19 c_runtime/_vsnprintf_s/test2/paltest_vsnprintf_test2 -c_runtime/_vsnprintf_s/test3/paltest_vsnprintf_test3 c_runtime/_vsnprintf_s/test4/paltest_vsnprintf_test4 c_runtime/_vsnprintf_s/test6/paltest_vsnprintf_test6 -c_runtime/_vsnprintf_s/test7/paltest_vsnprintf_test7 c_runtime/_vsnprintf_s/test8/paltest_vsnprintf_test8 c_runtime/_vsnprintf_s/test9/paltest_vsnprintf_test9 c_runtime/_wcsicmp/test1/paltest_wcsicmp_test1 diff --git a/src/coreclr/tools/StressLogAnalyzer/StressLogPlugin.cpp b/src/coreclr/tools/StressLogAnalyzer/StressLogPlugin.cpp index 56258ed..a45c941 100644 --- a/src/coreclr/tools/StressLogAnalyzer/StressLogPlugin.cpp +++ b/src/coreclr/tools/StressLogAnalyzer/StressLogPlugin.cpp @@ -1173,7 +1173,7 @@ static double FindLatestTime(StressLog::StressLogHeader* hdr) static void PrintFriendlyNumber(LONGLONG n) { if (n < 1000) - printf("%lld", n); + printf("%d", (int32_t)n); else if (n < 1000 * 1000) printf("%5.3f thousand", n / 1000.0); else if (n < 1000 * 1000 * 1000) @@ -1486,7 +1486,7 @@ int ProcessStressLog(void* baseAddress, int argc, char* argv[]) (double)usedSize / (1024 * 1024 * 1024), (double)availSize/ (1024 * 1024 * 1024), s_threadStressLogCount, (int)s_wrappedWriteThreadCount); if (hdr->threadsWithNoLog != 0) - printf("%lld threads did not get a log!\n", hdr->threadsWithNoLog); + printf("%u threads did not get a log!\n", hdr->threadsWithNoLog); printf("Number of messages examined: "); PrintFriendlyNumber(s_totalMsgCount); printf(", printed: "); PrintFriendlyNumber(s_msgCount); printf("\n"); delete[] s_threadMsgBuf; diff --git a/src/coreclr/tools/superpmi/CMakeLists.txt b/src/coreclr/tools/superpmi/CMakeLists.txt index d4308d2..68b6dc8 100644 --- a/src/coreclr/tools/superpmi/CMakeLists.txt +++ b/src/coreclr/tools/superpmi/CMakeLists.txt @@ -1,3 +1,7 @@ +if (CLR_CMAKE_HOST_UNIX) + add_compile_options(-Wno-format) +endif(CLR_CMAKE_HOST_UNIX) + add_subdirectory(superpmi) add_subdirectory(mcs) add_subdirectory(superpmi-shim-collector)