From a04f75c50789b953d238f4e141368ddb70eb3c95 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Mon, 10 Oct 2022 11:51:21 -0700 Subject: [PATCH] Remove more PAL exports for `wprintf` `wscanf` funcs (#76771) * Remove more PAL exports for wprintf funcs * Remove tests for fwprintf * Remove swscanf tests * Remove wprintf tests --- .../dlls/mscordac/mscordac_unixexports.src | 1 - src/coreclr/ilasm/main.cpp | 100 +- src/coreclr/pal/inc/pal.h | 10 - src/coreclr/pal/inc/rt/palrt.h | 2 - src/coreclr/pal/src/cruntime/printf.cpp | 643 ---------- src/coreclr/pal/src/cruntime/printfcpp.cpp | 1077 +---------------- src/coreclr/pal/src/include/pal/palinternal.h | 5 - src/coreclr/pal/src/include/pal/printfcpp.hpp | 37 +- src/coreclr/pal/tests/palsuite/CMakeLists.txt | 38 - .../palsuite/c_runtime/fwprintf/fwprintf.h | 459 ------- .../c_runtime/fwprintf/test1/test1.cpp | 70 -- .../c_runtime/fwprintf/test10/test10.cpp | 50 - .../c_runtime/fwprintf/test11/test11.cpp | 50 - .../c_runtime/fwprintf/test12/test12.cpp | 51 - .../c_runtime/fwprintf/test13/test13.cpp | 51 - .../c_runtime/fwprintf/test14/test14.cpp | 65 - .../c_runtime/fwprintf/test15/test15.cpp | 65 - .../c_runtime/fwprintf/test16/test16.cpp | 64 - .../c_runtime/fwprintf/test17/test17.cpp | 50 - .../c_runtime/fwprintf/test18/test18.cpp | 50 - .../c_runtime/fwprintf/test19/test19.cpp | 80 -- .../c_runtime/fwprintf/test2/test2.cpp | 50 - .../c_runtime/fwprintf/test3/test3.cpp | 50 - .../c_runtime/fwprintf/test4/test4.cpp | 84 -- .../c_runtime/fwprintf/test5/test5.cpp | 62 - .../c_runtime/fwprintf/test6/test6.cpp | 47 - .../c_runtime/fwprintf/test7/test7.cpp | 46 - .../c_runtime/fwprintf/test8/test8.cpp | 50 - .../c_runtime/fwprintf/test9/test9.cpp | 50 - .../palsuite/c_runtime/swscanf/swscanf.h | 268 ---- .../c_runtime/swscanf/test1/test1.cpp | 52 - .../c_runtime/swscanf/test10/test10.cpp | 35 - .../c_runtime/swscanf/test11/test11.cpp | 34 - .../c_runtime/swscanf/test12/test12.cpp | 34 - .../c_runtime/swscanf/test13/test13.cpp | 36 - .../c_runtime/swscanf/test14/test14.cpp | 37 - .../c_runtime/swscanf/test15/test15.cpp | 36 - .../c_runtime/swscanf/test16/test16.cpp | 36 - .../c_runtime/swscanf/test17/test17.cpp | 36 - .../c_runtime/swscanf/test2/test2.cpp | 42 - .../c_runtime/swscanf/test3/test3.cpp | 35 - .../c_runtime/swscanf/test4/test4.cpp | 43 - .../c_runtime/swscanf/test5/test5.cpp | 43 - .../c_runtime/swscanf/test6/test6.cpp | 43 - .../c_runtime/swscanf/test7/test7.cpp | 43 - .../c_runtime/swscanf/test8/test8.cpp | 43 - .../c_runtime/swscanf/test9/test9.cpp | 36 - .../c_runtime/wprintf/test1/test1.cpp | 46 - .../c_runtime/wprintf/test2/test2.cpp | 50 - .../palsuite/c_runtime/wprintf/wprintf.h | 179 --- .../pal/tests/palsuite/compilableTests.txt | 38 - .../pal/tests/palsuite/paltestlist.txt | 34 - .../palsuite/paltestlist_to_be_reviewed.txt | 4 - src/coreclr/vm/hosting.cpp | 20 +- 54 files changed, 144 insertions(+), 4616 deletions(-) delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/fwprintf.h delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test10/test10.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test11/test11.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test12/test12.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test13/test13.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test14/test14.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test15/test15.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test16/test16.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test17/test17.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test18/test18.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test19/test19.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test2/test2.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test3/test3.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test4/test4.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test5/test5.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test6/test6.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test7/test7.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test8/test8.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test9/test9.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/swscanf/swscanf.h delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test10/test10.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test11/test11.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test12/test12.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test13/test13.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test14/test14.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test15/test15.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test16/test16.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test17/test17.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test2/test2.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test3/test3.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test4/test4.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test5/test5.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test6/test6.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test7/test7.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test8/test8.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test9/test9.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/wprintf/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/wprintf/test2/test2.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/wprintf/wprintf.h diff --git a/src/coreclr/dlls/mscordac/mscordac_unixexports.src b/src/coreclr/dlls/mscordac/mscordac_unixexports.src index cbdce1b792472c..f9f082ebf3a906 100644 --- a/src/coreclr/dlls/mscordac/mscordac_unixexports.src +++ b/src/coreclr/dlls/mscordac/mscordac_unixexports.src @@ -28,7 +28,6 @@ nativeStringResourceTable_mscorrc #PAL_fflush #PAL__flushall #PAL_free -#PAL_fwprintf #PAL_GetLogicalCpuCountFromOS #PAL_GetTotalCpuCount #PAL_GetNumaProcessorNode diff --git a/src/coreclr/ilasm/main.cpp b/src/coreclr/ilasm/main.cpp index 767154b5b8a68d..c2feb91e474b95 100644 --- a/src/coreclr/ilasm/main.cpp +++ b/src/coreclr/ilasm/main.cpp @@ -16,8 +16,8 @@ WCHAR* EqualOrColon(_In_ __nullterminated WCHAR* szArg) { - WCHAR* pchE = wcschr(szArg,L'='); - WCHAR* pchC = wcschr(szArg,L':'); + WCHAR* pchE = wcschr(szArg,W('=')); + WCHAR* pchC = wcschr(szArg,W(':')); WCHAR* ret; if(pchE == NULL) ret = pchC; else if(pchC == NULL) ret = pchE; @@ -25,6 +25,31 @@ WCHAR* EqualOrColon(_In_ __nullterminated WCHAR* szArg) return ret; } +// When converting a string for number parsing it is +// possible to simply cast a WCHAR to a char with no +// loss of data. +class NarrowForNumberParsing final +{ + char* _buffer; +public: + NarrowForNumberParsing(const WCHAR* str) + { + size_t len = wcslen(str); + _buffer = (char*)malloc(len + 1); + for (size_t i = 0; i < len; ++i) + _buffer[i] = (char)str[i]; + _buffer[len] = '\0'; + } + ~NarrowForNumberParsing() + { + free(_buffer); + } + operator const char*() const + { + return _buffer; + } +}; + static DWORD g_dwSubsystem=(DWORD)-1,g_dwComImageFlags=(DWORD)-1,g_dwFileAlignment=0,g_dwTestRepeat=0; static ULONGLONG g_stBaseAddress=0; static size_t g_stSizeOfStackReserve=0; @@ -214,9 +239,9 @@ extern "C" int _cdecl wmain(int argc, _In_ WCHAR **argv) for (i = 1; i < argc; i++) { #ifdef TARGET_UNIX - if(argv[i][0] == L'-') + if(argv[i][0] == W('-')) #else - if((argv[i][0] == L'/') || (argv[i][0] == L'-')) + if((argv[i][0] == W('/')) || (argv[i][0] == W('-'))) #endif { char szOpt[3 + 1] = { 0 }; @@ -247,7 +272,7 @@ extern "C" int _cdecl wmain(int argc, _In_ WCHAR **argv) WCHAR *pStr = EqualOrColon(argv[i]); if(pStr != NULL) { - for(pStr++; *pStr == L' '; pStr++); //skip the blanks + for(pStr++; *pStr == W(' '); pStr++); //skip the blanks if(wcslen(pStr)==0) goto InvalidOption; //if no suboption else { @@ -260,9 +285,10 @@ extern "C" int _cdecl wmain(int argc, _In_ WCHAR **argv) pAsm->m_dwIncludeDebugInfo = 0x103; else { - const WCHAR *pFmt =((*pStr == '0')&&(*(pStr+1) == 'x'))? W("%lx") : W("%ld"); - if(swscanf_s(pStr,pFmt,&(pAsm->m_dwIncludeDebugInfo))!=1) - goto InvalidOption; // bad subooption + const CHAR *pFmt =((*pStr == '0')&&(*(pStr+1) == 'x'))? "%x" : "%d"; + NarrowForNumberParsing str{pStr}; + if(sscanf_s(str,pFmt,&(pAsm->m_dwIncludeDebugInfo))!=1) + goto InvalidOption; // bad subooption } } } @@ -360,7 +386,7 @@ extern "C" int _cdecl wmain(int argc, _In_ WCHAR **argv) { WCHAR *pStr = EqualOrColon(argv[i]); if(pStr == NULL) goto ErrorExit; - for(pStr++; *pStr == L' '; pStr++); //skip the blanks + for(pStr++; *pStr == W(' '); pStr++); //skip the blanks if(wcslen(pStr)==0) goto InvalidOption; //if no file name pAsm->m_wzResourceFile = pStr; } @@ -371,7 +397,7 @@ extern "C" int _cdecl wmain(int argc, _In_ WCHAR **argv) { WCHAR *pStr = EqualOrColon(argv[i]); if(pStr == NULL) goto InvalidOption; - for(pStr++; *pStr == L' '; pStr++); //skip the blanks + for(pStr++; *pStr == W(' '); pStr++); //skip the blanks if(wcslen(pStr)==0) goto InvalidOption; //if no file name pAsm->m_wzKeySourceName = pStr; } @@ -379,7 +405,7 @@ extern "C" int _cdecl wmain(int argc, _In_ WCHAR **argv) { WCHAR *pStr = EqualOrColon(argv[i]); if(pStr == NULL) goto InvalidOption; - for(pStr++; *pStr == L' '; pStr++); //skip the blanks + for(pStr++; *pStr == W(' '); pStr++); //skip the blanks if(wcslen(pStr)==0) goto InvalidOption; //if no file name wzIncludePath = pStr; } @@ -387,7 +413,7 @@ extern "C" int _cdecl wmain(int argc, _In_ WCHAR **argv) { WCHAR *pStr = EqualOrColon(argv[i]); if(pStr == NULL) goto InvalidOption; - for(pStr++; *pStr == L' '; pStr++); //skip the blanks + for(pStr++; *pStr == W(' '); pStr++); //skip the blanks if(wcslen(pStr)==0) goto InvalidOption; //if no file name if(wcslen(pStr) >= MAX_FILENAME_LENGTH) { @@ -400,7 +426,7 @@ extern "C" int _cdecl wmain(int argc, _In_ WCHAR **argv) { WCHAR *pStr = EqualOrColon(argv[i]); if(pStr == NULL) goto InvalidOption; - for(pStr++; *pStr == L' '; pStr++); //skip the blanks + for(pStr++; *pStr == W(' '); pStr++); //skip the blanks if(wcslen(pStr)==0) goto InvalidOption; //if no version string pAsm->m_wzMetadataVersion = pStr; } @@ -408,11 +434,12 @@ extern "C" int _cdecl wmain(int argc, _In_ WCHAR **argv) { WCHAR *pStr = EqualOrColon(argv[i]); if(pStr == NULL) goto InvalidOption; - for(pStr++; *pStr == L' '; pStr++); //skip the blanks + for(pStr++; *pStr == W(' '); pStr++); //skip the blanks if(wcslen(pStr)==0) goto InvalidOption; //if no version { int major=-1,minor=-1; - if(swscanf_s(pStr,W("%d.%d"),&major, &minor)==2) + NarrowForNumberParsing str{pStr}; + if(sscanf_s(str,"%d.%d",&major, &minor)==2) { if((major >= 0)&&(major < 0xFF)) pAsm->m_wMSVmajor = (WORD)major; @@ -426,18 +453,20 @@ extern "C" int _cdecl wmain(int argc, _In_ WCHAR **argv) WCHAR *pStr = EqualOrColon(argv[i]); if(pStr == NULL) goto InvalidOption; pStr++; - const WCHAR *pFmt = ((*pStr=='0')&&(*(pStr+1) == 'x'))? W("%lx") : W("%ld"); - if(swscanf_s(pStr,pFmt,&g_dwSubsystem)!=1) goto InvalidOption; + const CHAR *pFmt = ((*pStr=='0')&&(*(pStr+1) == 'x'))? "%x" : "%d"; + NarrowForNumberParsing str{pStr}; + if(sscanf_s(str,pFmt,&g_dwSubsystem)!=1) goto InvalidOption; } else if (!_stricmp(szOpt, "SSV")) { WCHAR *pStr = EqualOrColon(argv[i]); if(pStr == NULL) goto InvalidOption; - for(pStr++; *pStr == L' '; pStr++); //skip the blanks + for(pStr++; *pStr == W(' '); pStr++); //skip the blanks if(wcslen(pStr)==0) goto InvalidOption; //if no version { int major=-1,minor=-1; - if(swscanf_s(pStr,W("%d.%d"),&major, &minor)==2) + NarrowForNumberParsing str{pStr}; + if(sscanf_s(str,"%d.%d",&major, &minor)==2) { if((major >= 0)&&(major < 0xFFFF)) pAsm->m_wSSVersionMajor = (WORD)major; @@ -452,8 +481,9 @@ extern "C" int _cdecl wmain(int argc, _In_ WCHAR **argv) WCHAR *pStr = EqualOrColon(argv[i]); if(pStr == NULL) goto InvalidOption; pStr++; - const WCHAR *pFmt = ((*pStr=='0')&&(*(pStr+1) == 'x'))? W("%lx") : W("%ld"); - if(swscanf_s(pStr,pFmt,&g_dwFileAlignment)!=1) goto InvalidOption; + const CHAR *pFmt = ((*pStr=='0')&&(*(pStr+1) == 'x'))? "%x" : "%d"; + NarrowForNumberParsing str{pStr}; + if(sscanf_s(str,pFmt,&g_dwFileAlignment)!=1) goto InvalidOption; if((g_dwFileAlignment & (g_dwFileAlignment-1)) || (g_dwFileAlignment < 0x200) || (g_dwFileAlignment > 0x10000)) { @@ -466,16 +496,18 @@ extern "C" int _cdecl wmain(int argc, _In_ WCHAR **argv) WCHAR *pStr = EqualOrColon(argv[i]); if(pStr == NULL) goto InvalidOption; pStr++; - const WCHAR *pFmt = ((*pStr=='0')&&(*(pStr+1) == 'x'))? W("%lx") : W("%ld"); - if(swscanf_s(pStr,pFmt,&g_dwComImageFlags)!=1) goto InvalidOption; + const CHAR *pFmt = ((*pStr=='0')&&(*(pStr+1) == 'x'))? "%x" : "%d"; + NarrowForNumberParsing str{pStr}; + if(sscanf_s(str,pFmt,&g_dwComImageFlags)!=1) goto InvalidOption; } else if (!_stricmp(szOpt, "BAS")) { WCHAR *pStr = EqualOrColon(argv[i]); if(pStr == NULL) goto InvalidOption; pStr++; - const WCHAR *pFmt = ((*pStr=='0')&&(*(pStr+1) == 'x'))? W("%I64x") : W("%I64d"); - if(swscanf_s(pStr,pFmt,&g_stBaseAddress)!=1) goto InvalidOption; + const CHAR *pFmt = ((*pStr=='0')&&(*(pStr+1) == 'x'))? "%llx" : "%lld"; + NarrowForNumberParsing str{pStr}; + if(sscanf_s(str,pFmt,&g_stBaseAddress)!=1) goto InvalidOption; if(g_stBaseAddress & 0xFFFF) { fprintf(stderr,"\nBase address must be 0x10000-aligned\n"); @@ -487,8 +519,9 @@ extern "C" int _cdecl wmain(int argc, _In_ WCHAR **argv) WCHAR *pStr = EqualOrColon(argv[i]); if(pStr == NULL) goto InvalidOption; pStr++; - const WCHAR *pFmt = ((*pStr=='0')&&(*(pStr+1) == 'x'))? W("%lx") : W("%ld"); - if(swscanf_s(pStr,pFmt,&g_stSizeOfStackReserve)!=1) goto InvalidOption; + const CHAR *pFmt = ((*pStr=='0')&&(*(pStr+1) == 'x'))? "%x" : "%d"; + NarrowForNumberParsing str{pStr}; + if(sscanf_s(str,pFmt,&g_stSizeOfStackReserve)!=1) goto InvalidOption; } #ifdef _SPECIAL_INTERNAL_USE_ONLY else if (!_stricmp(szOpt, "TES")) @@ -496,8 +529,9 @@ extern "C" int _cdecl wmain(int argc, _In_ WCHAR **argv) WCHAR *pStr = EqualOrColon(argv[i]); if(pStr == NULL) goto InvalidOption; pStr++; - WCHAR *pFmt = ((*pStr=='0')&&(*(pStr+1) == 'x'))? L"%lx" : L"%ld"; - if(swscanf_s(pStr,pFmt,&g_dwTestRepeat)!=1) goto InvalidOption; + const CHAR *pFmt = ((*pStr=='0')&&(*(pStr+1) == 'x'))? "%x" : "%d"; + NarrowForNumberParsing str{pStr}; + if(sscanf_s(str,pFmt,&g_dwTestRepeat)!=1) goto InvalidOption; } #endif else @@ -592,7 +626,7 @@ extern "C" int _cdecl wmain(int argc, _In_ WCHAR **argv) do { j--; - if(wzOutputFilename[j] == L'.') + if(wzOutputFilename[j] == W('.')) { wzOutputFilename[j] = 0; break; @@ -604,7 +638,7 @@ extern "C" int _cdecl wmain(int argc, _In_ WCHAR **argv) if (pAsm->m_fGeneratePDB) { wcscpy_s(wzPdbFilename, MAX_FILENAME_LENGTH, wzOutputFilename); - WCHAR* extPos = wcsrchr(wzPdbFilename, L'.'); + WCHAR* extPos = wcsrchr(wzPdbFilename, W('.')); if (extPos != NULL) *extPos = 0; wcscat_s(wzPdbFilename, MAX_FILENAME_LENGTH, W(".pdb")); @@ -805,11 +839,11 @@ extern "C" int _cdecl wmain(int argc, _In_ WCHAR **argv) if (exitval || !bGeneratePdb) { // PE file was not created, or no debug info required. Kill PDB if any - WCHAR* pc = wcsrchr(wzOutputFilename,L'.'); + WCHAR* pc = wcsrchr(wzOutputFilename,W('.')); if(pc==NULL) { pc = &wzOutputFilename[wcslen(wzOutputFilename)]; - *pc = L'.'; + *pc = W('.'); } wcscpy_s(pc+1,4,W("PDB")); #undef DeleteFileW diff --git a/src/coreclr/pal/inc/pal.h b/src/coreclr/pal/inc/pal.h index 925ab18d4f088b..d5a60d766d3d30 100644 --- a/src/coreclr/pal/inc/pal.h +++ b/src/coreclr/pal/inc/pal.h @@ -4059,7 +4059,6 @@ PAL_GetCurrentThreadAffinitySet(SIZE_T size, UINT_PTR* data); #define exit PAL_exit #define printf PAL_printf #define vprintf PAL_vprintf -#define wprintf PAL_wprintf #define wcstod PAL_wcstod #define wcstoul PAL_wcstoul #define wcscat PAL_wcscat @@ -4069,7 +4068,6 @@ PAL_GetCurrentThreadAffinitySet(SIZE_T size, UINT_PTR* data); #define wcschr PAL_wcschr #define wcsrchr PAL_wcsrchr #define wcsstr PAL_wcsstr -#define swscanf PAL_swscanf #define wcspbrk PAL_wcspbrk #define wcscmp PAL_wcscmp #define wcsncpy PAL_wcsncpy @@ -4079,9 +4077,7 @@ PAL_GetCurrentThreadAffinitySet(SIZE_T size, UINT_PTR* data); #define strtoul PAL_strtoul #define strtoull PAL_strtoull #define fprintf PAL_fprintf -#define fwprintf PAL_fwprintf #define vfprintf PAL_vfprintf -#define vfwprintf PAL_vfwprintf #define rand PAL_rand #define time PAL_time #define getenv PAL_getenv @@ -4258,9 +4254,6 @@ PALIMPORT DLLEXPORT const WCHAR * __cdecl PAL_wcschr(const WCHAR *, WCHAR); PALIMPORT DLLEXPORT const WCHAR * __cdecl PAL_wcsrchr(const WCHAR *, WCHAR); PALIMPORT WCHAR _WConst_return * __cdecl PAL_wcspbrk(const WCHAR *, const WCHAR *); PALIMPORT DLLEXPORT WCHAR _WConst_return * __cdecl PAL_wcsstr(const WCHAR *, const WCHAR *); -PALIMPORT int __cdecl PAL_swprintf(WCHAR *, const WCHAR *, ...); -PALIMPORT int __cdecl PAL_vswprintf(WCHAR *, const WCHAR *, va_list); -PALIMPORT int __cdecl PAL_swscanf(const WCHAR *, const WCHAR *, ...); PALIMPORT DLLEXPORT ULONG __cdecl PAL_wcstoul(const WCHAR *, WCHAR **, int); PALIMPORT double __cdecl PAL_wcstod(const WCHAR *, WCHAR **); @@ -4494,9 +4487,6 @@ PALIMPORT LONG __cdecl PAL_ftell(PAL_FILE *); PALIMPORT int __cdecl PAL_ferror(PAL_FILE *); PALIMPORT PAL_FILE * __cdecl PAL_fopen(const char *, const char *); PALIMPORT int __cdecl PAL_setvbuf(PAL_FILE *stream, char *, int, size_t); -PALIMPORT DLLEXPORT int __cdecl PAL_fwprintf(PAL_FILE *, const WCHAR *, ...); -PALIMPORT int __cdecl PAL_vfwprintf(PAL_FILE *, const WCHAR *, va_list); -PALIMPORT int __cdecl PAL_wprintf(const WCHAR*, ...); PALIMPORT int __cdecl _getw(PAL_FILE *); PALIMPORT int __cdecl _putw(int, PAL_FILE *); diff --git a/src/coreclr/pal/inc/rt/palrt.h b/src/coreclr/pal/inc/rt/palrt.h index c87411ca932713..9a9fe4d4798739 100644 --- a/src/coreclr/pal/inc/rt/palrt.h +++ b/src/coreclr/pal/inc/rt/palrt.h @@ -672,8 +672,6 @@ The wrappers below are simple implementations that may not be as robust as compl Remember to fix the errcode definition in safecrt.h. */ -#define swscanf_s swscanf - #define _wfopen_s _wfopen_unsafe #define fopen_s _fopen_unsafe diff --git a/src/coreclr/pal/src/cruntime/printf.cpp b/src/coreclr/pal/src/cruntime/printf.cpp index c312a935656f95..0ae63e57e3ad1b 100644 --- a/src/coreclr/pal/src/cruntime/printf.cpp +++ b/src/coreclr/pal/src/cruntime/printf.cpp @@ -143,35 +143,6 @@ PAL_fprintf(PAL_FILE *stream,const char *format,...) return Length; } -/*++ -Function: - PAL_wprintf - -See MSDN doc. ---*/ -int -__cdecl -PAL_wprintf( - const wchar_16 *format, - ...) -{ - LONG Length; - va_list ap; - - PERF_ENTRY(wprintf); - ENTRY("PAL_wprintf (format=%p (%S))\n", format, format); - - va_start(ap, format); - Length = PAL_vfwprintf( PAL_get_stdout(PAL_get_caller), format, ap); - va_end(ap); - - LOGEXIT("PAL_wprintf returns int %d\n", Length); - PERF_EXIT(wprintf); - return Length; -} - - - /*++ Function: PAL_vprintf @@ -196,620 +167,6 @@ PAL_vprintf( return Length; } - -/*++ -Function: - fwprintf - -See MSDN doc. ---*/ -int -__cdecl -PAL_fwprintf( - PAL_FILE *stream, - const wchar_16 *format, - ...) -{ - LONG Length; - va_list ap; - - PERF_ENTRY(fwprintf); - ENTRY("PAL_fwprintf (stream=%p, format=%p (%S))\n", stream, format, format); - - va_start(ap, format); - Length = PAL_vfwprintf( stream, format, ap); - va_end(ap); - - LOGEXIT("PAL_fwprintf returns int %d\n", Length); - PERF_EXIT(fwprintf); - return Length; -} - -/******************************************************************************* -Function: - Internal_ScanfExtractFormatW - -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 - Store - - boolean value representing whether to store the type to be parsed - - '*' flag - Width - - will contain the width specified by the format string - - -1 if none given - Prefix - - an enumeration of the type prefix - Type - - an enumeration of the value type to be parsed - -Notes: - - I'm also handling the undocumented %ws, %wc, %w... -*******************************************************************************/ -static BOOL Internal_ScanfExtractFormatW(LPCWSTR *Fmt, LPSTR Out, int iOutSize, LPBOOL Store, - LPINT Width, LPINT Prefix, LPINT Type) -{ - BOOL Result = FALSE; - LPSTR TempStr; - LPSTR TempStrPtr; - - *Width = -1; - *Store = TRUE; - *Prefix = -1; - *Type = -1; - - if (*Fmt && **Fmt == '%') - { - *Out++ = (CHAR)*(*Fmt)++; - } - else - { - return Result; - } - - /* we'll never need a temp string longer than the original */ - TempStrPtr = TempStr = (LPSTR) PAL_malloc(PAL_wcslen(*Fmt)+1); - if (!TempStr) - { - ERROR("PAL_malloc failed\n"); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return Result; - } - - /* parse '*' flag which means don't store */ - if (**Fmt == '*') - { - *Store = FALSE; - *Out++ = (CHAR)*(*Fmt)++; - } - - /* grab width specifier */ - if (isdigit(**Fmt)) - { - TempStrPtr = TempStr; - while (isdigit(**Fmt)) - { - *TempStrPtr++ = (CHAR)**Fmt; - *Out++ = (CHAR)*(*Fmt)++; - } - *TempStrPtr = 0; /* end string */ - *Width = atoi(TempStr); - if (*Width < 0) - { - ERROR("atoi returned a negative value indicative of an overflow.\n"); - SetLastError(ERROR_INTERNAL_ERROR); - goto EXIT; - } - } - -#ifdef HOST_64BIT - if (**Fmt == 'p') - { - *Prefix = SCANF_PREFIX_LONGLONG; - } -#endif - /* grab prefix of 'I64' for __int64 */ - if ((*Fmt)[0] == 'I' && (*Fmt)[1] == '6' && (*Fmt)[2] == '4') - { - /* convert to 'q'/'ll' so that Unix sscanf can handle it */ - *Fmt += 3; - *Prefix = SCANF_PREFIX_LONGLONG; - } - /* grab a prefix of 'h' */ - else if (**Fmt == 'h') - { - *Prefix = SCANF_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 inputing characters. - if (**Fmt == 'C' || **Fmt == 'S') -#endif - { - *Prefix = SCANF_PREFIX_LONG; /* give it a wide prefix */ - } - if (**Fmt == 'l') - { - *Prefix = SCANF_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 = SCANF_TYPE_CHAR; - if (*Prefix != SCANF_PREFIX_SHORT && **Fmt == 'c') - { - *Prefix = SCANF_PREFIX_LONG; /* give it a wide prefix */ - } - if (*Prefix == SCANF_PREFIX_LONG) - { - *Out++ = 'l'; - } - *Out++ = 'c'; - ++(*Fmt); - Result = TRUE; - } - /* grab type 's' */ - else if (**Fmt == 's' || **Fmt == 'S') - { - *Type = SCANF_TYPE_STRING; - if (*Prefix != SCANF_PREFIX_SHORT && **Fmt == 's') - { - *Prefix = SCANF_PREFIX_LONG; /* give it a wide prefix */ - } - if (*Prefix == SCANF_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' || - **Fmt == 'p') - { - *Type = SCANF_TYPE_INT; - if (*Prefix == SCANF_PREFIX_SHORT) - { - *Out++ = 'h'; - } - else if (*Prefix == SCANF_PREFIX_LONG) - { - *Out++ = 'l'; - } - else if (*Prefix == SCANF_PREFIX_LONGLONG) - { - if (strcpy_s(Out, iOutSize, scanf_longlongfmt) != SAFECRT_SUCCESS) - { - ERROR("strcpy_s failed\n"); - SetLastError(ERROR_INSUFFICIENT_BUFFER); - goto EXIT; - } - - Out += strlen(scanf_longlongfmt); - } - *Out++ = (CHAR)*(*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 = SCANF_TYPE_FLOAT; - /* this gets rid of %E/%G since they're they're the - same when scanning */ - *Out++ = (CHAR)tolower( *(*Fmt)++ ); - Result = TRUE; - } - else if (**Fmt == 'n') - { - if (*Prefix == SCANF_PREFIX_SHORT) - { - *Out++ = 'h'; - } - *Out++ = (CHAR)*(*Fmt)++; - *Type = SCANF_TYPE_N; - Result = TRUE; - } - else if (**Fmt == '[') - { - /* There is a small compatibility problem in the handling of the [] - option in FreeBSD vs. Windows. In Windows, you can have [z-a] - as well as [a-z]. In FreeBSD, [z-a] fails. So, we need to - reverse the instances of z-a to a-z (and [m-e] to [e-m], etc). */ - - /* step 1 : copy the leading [ */ - *Out++ = '['; - (*Fmt)++; - - /* step 2 : copy a leading ^, if present */ - if( '^' == **Fmt ) - { - *Out++ = '^'; - (*Fmt)++; - } - - /* step 3 : copy a leading ], if present; a ] immediately after the - leading [ (or [^) does *not* end the sequence, it is part of the - characters to match */ - if( ']' == **Fmt ) - { - *Out++ = ']'; - (*Fmt)++; - } - - /* step 4 : if the next character is already a '-', it's not part of an - interval specifier, so just copy it */ - if('-' == **Fmt ) - { - *Out++ = '-'; - (*Fmt)++; - } - - /* ok then, process the rest of it */ - while( '\0' != **Fmt ) - { - if(']' == **Fmt) - { - /* ']' marks end of the format specifier; we're done */ - *Out++ = ']'; - (*Fmt)++; - break; - } - if('-' == **Fmt) - { - if( ']' == (*Fmt)[1] ) - { - /* got a '-', next character is the terminating ']'; - copy '-' literally */ - *Out++ = '-'; - (*Fmt)++; - } - else - { - /* got a '-' indicating an interval specifier */ - unsigned char prev, next; - - /* get the interval boundaries */ - prev = (unsigned char)(*Fmt)[-1]; - next = (unsigned char)(*Fmt)[1]; - - /* if boundaries were inverted, replace the already-copied - low boundary by the 'real' low boundary */ - if( prev > next ) - { - Out[-1] = next; - - /* ...and save the 'real' upper boundary, which will be - copied to 'Out' below */ - next = prev; - } - - *Out++ = '-'; - *Out++ = next; - - /* skip over the '-' and the next character, which we - already copied */ - (*Fmt)+=2; - } - } - else - { - /* plain character; just copy it */ - *Out++ = (CHAR)**Fmt; - (*Fmt)++; - } - } - - *Type = SCANF_TYPE_BRACKETS; - Result = TRUE; - } - else if (**Fmt == ' ') - { - *Type = SCANF_TYPE_SPACE; - } - - /* add %n so we know how far to increment the pointer */ - *Out++ = '%'; - *Out++ = 'n'; - - *Out = 0; /* end the string */ - -EXIT: - PAL_free(TempStr); - return Result; -} - -/******************************************************************************* -Function: - PAL_wvsscanf - - Buffer - - buffer to parse values from - Format - - format string - ap - - stdarg parameter list -*******************************************************************************/ -int PAL_wvsscanf(LPCWSTR Buffer, LPCWSTR Format, va_list ap) -{ - INT Length = 0; - LPCWSTR Buff = Buffer; - LPCWSTR Fmt = Format; - CHAR TempBuff[1024]; /* used to hold a single % format string */ - BOOL Store; - INT Width; - INT Prefix; - INT Type = -1; - - while (*Fmt) - { - if (!*Buff && Length == 0) - { - Length = EOF; - break; - } - /* remove any number of blanks */ - else if (isspace(*Fmt)) - { - while (isspace(*Buff)) - { - ++Buff; - } - ++Fmt; - } - else if (*Fmt == '%' && - Internal_ScanfExtractFormatW(&Fmt, TempBuff, sizeof(TempBuff), &Store, - &Width, &Prefix, &Type)) - { - if (Prefix == SCANF_PREFIX_LONG && - (Type == SCANF_TYPE_STRING || Type == SCANF_TYPE_CHAR)) - { - int len = 0; - WCHAR *charPtr = 0; - - /* a single character */ - if (Type == SCANF_TYPE_CHAR && Width == -1) - { - len = Width = 1; - } - - /* calculate length of string to copy */ - while (Buff[len] && !isspace(Buff[len])) - { - if (Width != -1 && len >= Width) - { - break; - } - ++len; - } - - if (Store) - { - int i; - charPtr = va_arg(ap, WCHAR *); - - for (i = 0; i < len; i++) - { - charPtr[i] = Buff[i]; - } - if (Type == SCANF_TYPE_STRING) - { - /* end string */ - charPtr[len] = 0; - } - ++Length; - } - Buff += len; - } - /* this places the number of bytes stored into the next arg */ - else if (Type == SCANF_TYPE_N) - { - if (Prefix == SCANF_PREFIX_SHORT) - { - *(va_arg(ap, short *)) = (short)(Buff - Buffer); - } - else - { - *(va_arg(ap, LPLONG)) = Buff - Buffer; - } - } - /* types that sscanf can handle */ - else - { - int ret; - int n; - int size; - LPSTR newBuff = 0; - LPVOID voidPtr = NULL; - - size = WideCharToMultiByte(CP_ACP, 0, Buff, -1, 0, 0, 0, 0); - if (!size) - { - ASSERT("WideCharToMultiByte failed. Error is %d\n", - GetLastError()); - return -1; - } - newBuff = (LPSTR) PAL_malloc(size); - if (!newBuff) - { - ERROR("PAL_malloc failed\n"); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return -1; - } - size = WideCharToMultiByte(CP_ACP, 0, Buff, size, - newBuff, size, 0, 0); - if (!size) - { - ASSERT("WideCharToMultiByte failed. Error is %d\n", - GetLastError()); - PAL_free(newBuff); - return -1; - } - - if (Store) - { - if (Type == SCANF_TYPE_BRACKETS) - { - WCHAR *strPtr; - int i; - - /* add a '*' to %[] --> %*[] */ - i = strlen(TempBuff) + 1; - while (i) - { - /* shift everything right one */ - TempBuff[i] = TempBuff[i - 1]; - --i; - } - TempBuff[0] = '%'; - TempBuff[1] = '*'; - - /* %n doesn't count as a conversion. Since we're - suppressing conversion of the %[], sscanf will - always return 0, so we can't use the return value - to determine success. Set n to 0 before the call; if - it's still 0 afterwards, we know the call failed */ - n = 0; - sscanf_s(newBuff, TempBuff, &n); - if(0 == n) - { - /* sscanf failed, nothing matched. set ret to 0, - so we know we have to break */ - ret = 0; - } - else - { - strPtr = va_arg(ap, WCHAR *); - for (i = 0; i < n; i++) - { - strPtr[i] = Buff[i]; - } - strPtr[n] = 0; /* end string */ - ret = 1; - } - } - else - { - voidPtr = va_arg(ap, LPVOID); - // sscanf_s requires that if we are trying to read "%s" or "%c", then - // the size of the buffer must follow the buffer we are trying to read into. - unsigned typeLen = 0; - if (Type == SCANF_TYPE_STRING) - { - // We don’t really know the size of the destination buffer provided by the - // caller. So we have to assume that the caller has allocated enough space - // to hold either the width specified in the format or the entire input - // string plus ‘\0’. - typeLen = ((Width > 0) ? Width : PAL_wcslen(Buffer)) + 1; - } - else if (Type == SCANF_TYPE_CHAR) - { - // Check whether the format string contains number of characters - // that should be read from the input string. - // Note: ‘\0’ does not get appended in the “%c” case. - typeLen = (Width > 0) ? Width : 1; - } - - if (typeLen > 0) - { - ret = sscanf_s(newBuff, TempBuff, voidPtr, typeLen, &n); - } - else - ret = sscanf_s(newBuff, TempBuff, voidPtr, &n); - } - } - else - { - ret = sscanf_s(newBuff, TempBuff, &n); - } - -#if SSCANF_CANNOT_HANDLE_MISSING_EXPONENT - if ((ret == 0) && (Type == SCANF_TYPE_FLOAT)) - { - ret = SscanfFloatCheckExponent(newBuff, TempBuff, voidPtr, &n); - } -#endif // SSCANF_CANNOT_HANDLE_MISSING_EXPONENT - - PAL_free(newBuff); - if (ret > 0) - { - Length += ret; - } - else - { - /* no match; break scan */ - break; - } - Buff += n; - } - } - else - { - /* grab, but not store */ - if (*Fmt == *Buff && Type != SCANF_TYPE_SPACE) - { - ++Fmt; - ++Buff; - } - /* doesn't match, break scan */ - else - { - break; - } - } - } - - return Length; -} - -/*++ -Function: - PAL_swscanf - -See MSDN doc. ---*/ -int -__cdecl -PAL_swscanf( - const wchar_16 *buffer, - const wchar_16 *format, - ...) -{ - int Length; - va_list ap; - - PERF_ENTRY(swscanf); - ENTRY("PAL_swscanf (buffer=%p (%S), format=%p (%S))\n", buffer, buffer, format, format); - - va_start(ap, format); - Length = PAL_wvsscanf(buffer, format, ap); - va_end(ap); - - LOGEXIT("PAL_swscanf returns int %d\n", Length); - PERF_EXIT(swscanf); - return Length; -} - - #if SSCANF_CANNOT_HANDLE_MISSING_EXPONENT /*++ Function: diff --git a/src/coreclr/pal/src/cruntime/printfcpp.cpp b/src/coreclr/pal/src/cruntime/printfcpp.cpp index a2fb5bd2b9ae2c..a2b9c8f004dee7 100644 --- a/src/coreclr/pal/src/cruntime/printfcpp.cpp +++ b/src/coreclr/pal/src/cruntime/printfcpp.cpp @@ -38,76 +38,10 @@ 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); -int CoreVfwprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const wchar_16 *format, va_list ap); extern "C" { -/******************************************************************************* -Function: - Internal_Convertfwrite - This function is a wrapper around fwrite for cases where the buffer has - to be converted from WideChar to MultiByte -*******************************************************************************/ - -static int Internal_Convertfwrite(CPalThread *pthrCurrent, const void *buffer, size_t size, size_t count, FILE *stream, BOOL convert) -{ - int ret; - int iError = 0; - -#if FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL - clearerr (stream); -#endif - - - if(convert) - { - int nsize; - LPSTR newBuff = 0; - nsize = WideCharToMultiByte(CP_ACP, 0,(LPCWSTR)buffer, count, 0, 0, 0, 0); - if (!nsize) - { - if (count == 0) - return 0; - ASSERT("WideCharToMultiByte failed. Error is %d\n", GetLastError()); - return -1; - } - newBuff = (LPSTR) InternalMalloc(nsize); - if (!newBuff) - { - ERROR("InternalMalloc failed\n"); - pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return -1; - } - nsize = WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)buffer, count, newBuff, nsize, 0, 0); - if (!nsize) - { - ASSERT("WideCharToMultiByte failed. Error is %d\n", GetLastError()); - free(newBuff); - return -1; - } - ret = InternalFwrite(newBuff, 1, nsize, stream, &iError); - if (iError != 0) - { - ERROR("InternalFwrite did not write the whole buffer. Error is %d\n", iError); - free(newBuff); - return -1; - } - free(newBuff); - } - else - { - ret = InternalFwrite(buffer, size, count, stream, &iError); - if (iError != 0) - { - ERROR("InternalFwrite did not write the whole buffer. Error is %d\n", iError); - return -1; - } - } - return ret; - -} - /******************************************************************************* Function: Internal_ExtractFormatA @@ -452,537 +386,105 @@ BOOL Internal_ExtractFormatA(CPalThread *pthrCurrent, LPCSTR *Fmt, LPSTR Out, LP /******************************************************************************* Function: - Internal_ExtractFormatW + Internal_AddPaddingVfprintf - -- see Internal_ExtractFormatA above +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) *******************************************************************************/ -BOOL Internal_ExtractFormatW(CPalThread *pthrCurrent, LPCWSTR *Fmt, LPSTR Out, LPINT Flags, - LPINT Width, LPINT Precision, LPINT Prefix, LPINT Type) + +INT Internal_AddPaddingVfprintf(CPalThread *pthrCurrent, PAL_FILE *stream, LPCSTR In, + INT Padding, INT Flags) { - BOOL Result = FALSE; - LPSTR TempStr; - LPSTR TempStrPtr; + LPSTR Out; + INT LengthInStr; + INT Length; + LPSTR OutOriginal; + INT Written; - *Width = WIDTH_DEFAULT; - *Precision = PRECISION_DEFAULT; - *Flags = PFF_NONE; - *Prefix = PFF_PREFIX_DEFAULT; - *Type = PFF_TYPE_DEFAULT; + LengthInStr = strlen(In); + Length = LengthInStr; - if (*Fmt && **Fmt == '%') - { - *Out++ = (CHAR) *(*Fmt)++; - } - else + if (Padding > 0) { - return Result; + Length += Padding; } - - /* we'll never need a temp string longer than the original */ - TempStrPtr = TempStr = (LPSTR) InternalMalloc(PAL_wcslen(*Fmt)+1); - if (!TempStr) + Out = (LPSTR) InternalMalloc(Length+1); + int iLength = Length+1; + if (!Out) { ERROR("InternalMalloc failed\n"); pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return Result; + return -1; } + OutOriginal = Out; - /* parse flags */ - while (**Fmt && (**Fmt == '-' || **Fmt == '+' || - **Fmt == '0' || **Fmt == ' ' || **Fmt == '#')) + if (Flags & PFF_MINUS) /* pad on right */ { - switch (**Fmt) + if (strcpy_s(Out, iLength, In) != SAFECRT_SUCCESS) { - 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; + ERROR("strcpy_s failed\n"); + pthrCurrent->SetLastError(ERROR_INSUFFICIENT_BUFFER); + Written = -1; + goto Done; } - *Out++ = (CHAR) *(*Fmt)++; - } - /* '-' flag negates '0' flag */ - if ((*Flags & PFF_MINUS) && (*Flags & PFF_ZERO)) - { - *Flags -= PFF_ZERO; - } - /* grab width specifier */ - if (isdigit(**Fmt)) - { - TempStrPtr = TempStr; - while (isdigit(**Fmt)) - { - *TempStrPtr++ = (CHAR) **Fmt; - *Out++ = (CHAR) *(*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++ = (CHAR) *(*Fmt)++; - if (isdigit(**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(**Fmt)) - { - *Out++ = (CHAR) *(*Fmt)++; - } - } + Out += LengthInStr; + iLength -= LengthInStr; } - - /* grab precision specifier */ - if (**Fmt == '.') + if (Padding > 0) { - *Out++ = (CHAR) *(*Fmt)++; - if (isdigit(**Fmt)) + iLength -= Padding; + if (Flags & PFF_ZERO) /* '0', pad with zeros */ { - TempStrPtr = TempStr; - while (isdigit(**Fmt)) - { - *TempStrPtr++ = (CHAR) **Fmt; - *Out++ = (CHAR) *(*Fmt)++; - } - *TempStrPtr = 0; /* end string */ - *Precision = atoi(TempStr); - if (*Precision < 0) + while (Padding--) { - ERROR("atoi returned a negative value indicative of an overflow.\n"); - pthrCurrent->SetLastError(ERROR_INTERNAL_ERROR); - goto EXIT; + *Out++ = '0'; } } - else if (**Fmt == '*') + else /* pad with spaces */ { - *Precision = PRECISION_STAR; - *Out++ = (CHAR) *(*Fmt)++; - if (isdigit(**Fmt)) + while (Padding--) { - /* 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(**Fmt)) - { - *Out++ = (CHAR) *(*Fmt)++; - } + *Out++ = ' '; } } - else - { - *Precision = PRECISION_DOT; - } - } - -#ifdef HOST_64BIT - if (**Fmt == 'p') - { - *Prefix = PFF_PREFIX_LONGLONG; } -#endif - if ((*Fmt)[0] == 'I') + if (!(Flags & PFF_MINUS)) /* put 'In' after padding */ { - /* 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 + if (strcpy_s(Out, iLength, In) != SAFECRT_SUCCESS) { - ++(*Fmt); - #ifdef HOST_64BIT - /* convert to 'll' so that Unix snprintf can handle it */ - *Prefix = PFF_PREFIX_LONGLONG; - #endif + ERROR("strcpy_s failed\n"); + pthrCurrent->SetLastError(ERROR_INSUFFICIENT_BUFFER); + Written = -1; + goto Done; } + + Out += LengthInStr; + iLength -= LengthInStr; } - /* grab a prefix of 'h' */ - else if (**Fmt == 'h') - { - *Prefix = PFF_PREFIX_SHORT; - ++(*Fmt); - } - 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') + +#if FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL + clearerr (stream->bsdFilePtr); #endif - { - *Prefix = PFF_PREFIX_LONG_W; - } - if (**Fmt == 'l') - { - *Prefix = PFF_PREFIX_LONGLONG; - ++(*Fmt); - } - } - else if (**Fmt == 'L') + + Written = InternalFwrite(OutOriginal, 1, Length, stream->bsdFilePtr, &stream->PALferrorCode); + if (stream->PALferrorCode == PAL_FILE_ERROR) { - /* a prefix of 'L' seems to be ignored */ - ++(*Fmt); + ERROR("fwrite() failed with errno == %d\n", errno); } +Done: + free(OutOriginal); - /* 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 || *Prefix == PFF_PREFIX_LONG_W) - { - *Out++ = 'l'; - *Prefix = PFF_PREFIX_LONG; - } - *Out++ = 'c'; - ++(*Fmt); - Result = TRUE; - } - /* grab type 's' */ - else if (**Fmt == 's' || **Fmt == 'S' ) - { - if ( **Fmt == 'S' ) - { - *Type = PFF_TYPE_WSTRING; - } - else - { - *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 || *Prefix == PFF_PREFIX_LONG_W) - { - *Out++ = 'l'; - *Prefix = PFF_PREFIX_LONG; - } - else if (*Prefix == PFF_PREFIX_LONGLONG) - { - *Out++ = 'l'; - *Out++ = 'l'; - } - *Out++ = (CHAR)*(*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*/ - if (*Prefix == PFF_PREFIX_LONG_W) - { - *Prefix = PFF_PREFIX_LONG; - } - - *Type = PFF_TYPE_FLOAT; - *Out++ = (CHAR)*(*Fmt)++; - Result = TRUE; - } - else if (**Fmt == 'n') - { - if (*Prefix == PFF_PREFIX_LONG_W) - { - *Prefix = PFF_PREFIX_LONG; - } - - if (*Prefix == PFF_PREFIX_SHORT) - { - *Out++ = 'h'; - } - *Out++ = (CHAR)*(*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'; - } - /* native *printf does not support %I64p - (actually %llp), so we need to cheat a little bit */ - *Out++ = 'l'; - *Out++ = 'l'; - } - else - { - if (*Precision == PRECISION_DEFAULT) - { - *Precision = 8; - *Out++ = '.'; - *Out++ = '8'; - } - if (*Prefix == PFF_PREFIX_LONG_W) - { - *Prefix = PFF_PREFIX_LONG; - } - } - *Out++ = 'X'; - Result = TRUE; - } - - *Out = 0; /* end the string */ - -EXIT: - free(TempStr); - return Result; -} - -/******************************************************************************* -Function: - Internal_AddPaddingVfprintf - -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) -{ - 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 - - Written = InternalFwrite(OutOriginal, 1, Length, stream->bsdFilePtr, &stream->PALferrorCode); - if (stream->PALferrorCode == PAL_FILE_ERROR) - { - ERROR("fwrite() failed with errno == %d\n", errno); - } - -Done: - free(OutOriginal); - - return Written; -} - -/******************************************************************************* -Function: - Internal_AddPaddingVfwprintf - -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) -*******************************************************************************/ -static INT Internal_AddPaddingVfwprintf(CPalThread *pthrCurrent, PAL_FILE *stream, LPWSTR In, - INT Padding, INT Flags,BOOL convert) -{ - LPWSTR Out; - LPWSTR OutOriginal; - INT LengthInStr; - INT Length; - INT Written = -1; - - LengthInStr = PAL_wcslen(In); - Length = LengthInStr; - - if (Padding > 0) - { - Length += Padding; - } - - int iLen = (Length+1); - Out = (LPWSTR) InternalMalloc(iLen * sizeof(WCHAR)); - if (!Out) - { - ERROR("InternalMalloc failed\n"); - pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return -1; - } - OutOriginal = Out; - - if (Flags & PFF_MINUS) /* pad on right */ - { - if (wcscpy_s(Out, iLen, In) != SAFECRT_SUCCESS) - { - ERROR("wcscpy_s failed!\n"); - pthrCurrent->SetLastError(ERROR_INSUFFICIENT_BUFFER); - goto EXIT; - } - 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 (wcscpy_s(Out, iLen, In) != SAFECRT_SUCCESS) - { - ERROR("wcscpy_s failed!\n"); - pthrCurrent->SetLastError(ERROR_INSUFFICIENT_BUFFER); - goto EXIT; - } - - Out += LengthInStr; - iLen -= LengthInStr; - } - - if (Length > 0) { - Written = Internal_Convertfwrite(pthrCurrent, OutOriginal, sizeof(wchar_16), Length, - (FILE*)(stream->bsdFilePtr), convert); - - if (-1 == Written) - { - ERROR("fwrite() failed with errno == %d\n", errno); - } - } - else - { - Written = 0; - } - -EXIT: - free(OutOriginal); - return Written; -} + return Written; +} /******************************************************************************* Function: @@ -1002,461 +504,8 @@ int __cdecl PAL_vfprintf(PAL_FILE *stream, const char *format, va_list ap) return CoreVfprintf(InternalGetCurrentThread(), stream, format, ap); } -/******************************************************************************* -Function: - PAL_vfwprintf - -Parameters: - stream - - out stream - Format - - format string - ap - - stdarg parameter list -*******************************************************************************/ - -int __cdecl PAL_vfwprintf(PAL_FILE *stream, const wchar_16 *format, va_list ap) -{ - return CoreVfwprintf(InternalGetCurrentThread(), stream, format, ap); -} - } // end extern "C" -int CorUnix::InternalVfprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const char *format, va_list ap) -{ - return CoreVfprintf(pthrCurrent, stream, format, ap); -} - -int CoreVfwprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const wchar_16 *format, va_list aparg) -{ - CHAR TempBuff[1024]; /* used to hold a single % format string */ - LPCWSTR Fmt = format; - LPCWSTR TempWStr = NULL; - LPWSTR AllocedTempWStr = NULL; - LPWSTR WorkingWStr = NULL; - WCHAR TempWChar[2]; - INT Flags; - INT Width; - INT Precision; - INT Prefix; - INT Type; - INT TempInt; - int mbtowcResult; - int written=0; - int paddingReturnValue; - int ret; - va_list ap; - - /* fwprintf for now in the PAL is always used on file opened - in text mode. In those case the output should be ANSI not Unicode */ - BOOL textMode = TRUE; - - PERF_ENTRY(vfwprintf); - ENTRY("vfwprintf (stream=%p, format=%p (%S))\n", - stream, format, format); - - va_copy(ap, aparg); - - while (*Fmt) - { - if(*Fmt == '%' && - TRUE == Internal_ExtractFormatW(pthrCurrent, &Fmt, TempBuff, &Flags, - &Width, &Precision, - &Prefix, &Type)) - { - if (((Prefix == PFF_PREFIX_LONG || Prefix == PFF_PREFIX_LONG_W) && - (Type == PFF_TYPE_STRING || Type == PFF_TYPE_WSTRING)) || - (Type == PFF_TYPE_WSTRING && (Flags & PFF_ZERO) != 0)) - { - AllocedTempWStr = NULL; - - 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 */ - } - - if (Type == PFF_TYPE_STRING || Prefix == PFF_PREFIX_LONG_W) - { - TempWStr = va_arg(ap, LPWSTR); - } - else - { - /* %lS assumes a LPSTR argument. */ - LPCSTR s = va_arg(ap, LPSTR ); - if (s == NULL) - { - TempWStr = NULL; - } - else - { - UINT Length = 0; - Length = MultiByteToWideChar( CP_ACP, 0, s, -1, NULL, 0 ); - if ( Length != 0 ) - { - AllocedTempWStr = - (LPWSTR)InternalMalloc( (Length) * sizeof( WCHAR ) ); - - if ( AllocedTempWStr ) - { - MultiByteToWideChar( CP_ACP, 0, s, -1, - AllocedTempWStr, Length ); - TempWStr = AllocedTempWStr; - } - else - { - ERROR( "InternalMalloc failed.\n" ); - LOGEXIT("vfwprintf returns int -1\n"); - PERF_EXIT(vfwprintf); - va_end(ap); - return -1; - } - } - else - { - ASSERT( "Unable to convert from multibyte " - " to wide char.\n" ); - LOGEXIT("vfwprintf returns int -1\n"); - PERF_EXIT(vfwprintf); - va_end(ap); - return -1; - } - } - } - - if (TempWStr == NULL) - { - TempWStr = __wnullstring; - } - - INT Length = PAL_wcslen(TempWStr); - WorkingWStr = (LPWSTR) InternalMalloc((sizeof(WCHAR) * (Length + 1))); - if (!WorkingWStr) - { - ERROR("InternalMalloc failed\n"); - LOGEXIT("vfwprintf returns int -1\n"); - PERF_EXIT(vfwprintf); - pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY); - free(AllocedTempWStr); - va_end(ap); - return -1; - } - if (PRECISION_DOT == Precision) - { - /* copy nothing */ - *WorkingWStr = 0; - Length = 0; - } - else if (Precision > 0 && Precision < Length) - { - if (wcsncpy_s(WorkingWStr, (Length + 1), TempWStr, Precision+1) != SAFECRT_SUCCESS) - { - ERROR("Internal_AddPaddingVfwprintf failed\n"); - free(AllocedTempWStr); - free(WorkingWStr); - LOGEXIT("wcsncpy_s failed!\n"); - PERF_EXIT(vfwprintf); - va_end(ap); - return (-1); - } - - Length = Precision; - } - /* copy everything */ - else - { - PAL_wcscpy(WorkingWStr, TempWStr); - } - - - /* do the padding (if needed)*/ - paddingReturnValue = - Internal_AddPaddingVfwprintf( pthrCurrent, stream, WorkingWStr, - Width - Length, - Flags,textMode); - - if (paddingReturnValue == -1) - { - ERROR("Internal_AddPaddingVfwprintf failed\n"); - free(AllocedTempWStr); - free(WorkingWStr); - LOGEXIT("vfwprintf returns int -1\n"); - PERF_EXIT(vfwprintf); - va_end(ap); - return (-1); - } - written += paddingReturnValue; - - free(WorkingWStr); - free(AllocedTempWStr); - } - else if (Prefix == PFF_PREFIX_LONG && Type == PFF_TYPE_CHAR) - { - 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[0] = (WCHAR)va_arg(ap, int); - TempWChar[1] = W('\0'); - - /* do the padding (if needed)*/ - paddingReturnValue = - Internal_AddPaddingVfwprintf(pthrCurrent, stream, TempWChar, - Width - 1, - Flags,textMode); - if (paddingReturnValue == -1) - { - ERROR("Internal_AddPaddingVfwprintf failed\n"); - LOGEXIT("vfwprintf returns int -1\n"); - PERF_EXIT(vfwprintf); - 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 - { - // Types that sprintf can handle. - - /* note: I'm using the wide buffer as a (char *) buffer when I - pass it to sprintf(). After I get the buffer back I make a - backup of the chars copied and then convert them to wide - and place them in the buffer (BufferPtr) */ - - // This argument will be limited to 1024 characters. - // It should be enough. - size_t TEMP_COUNT = 1024; - char TempSprintfStrBuffer[1024]; - char *TempSprintfStrPtr = NULL; - char *TempSprintfStr = TempSprintfStrBuffer; - LPWSTR TempWideBuffer; - - 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 = snprintf(TempSprintfStr, TEMP_COUNT, TempBuff, trunc1); - - if (TempInt < 0 || static_cast(TempInt) >= TEMP_COUNT) - { - if (NULL == (TempSprintfStrPtr = (char*)InternalMalloc(++TempInt))) - { - ERROR("InternalMalloc failed\n"); - LOGEXIT("vfwprintf returns int -1\n"); - PERF_EXIT(vfwprintf); - pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY); - va_end(ap); - return -1; - } - - TempSprintfStr = TempSprintfStrPtr; - snprintf(TempSprintfStr, TempInt, 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 = snprintf(TempSprintfStr, TEMP_COUNT, TempBuff, s); - - if (TempInt < 0 || static_cast(TempInt) >= TEMP_COUNT) - { - if (NULL == (TempSprintfStrPtr = (char*)InternalMalloc(++TempInt))) - { - ERROR("InternalMalloc failed\n"); - LOGEXIT("vfwprintf returns int -1\n"); - PERF_EXIT(vfwprintf); - pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY); - va_end(ap); - return -1; - } - - TempSprintfStr = TempSprintfStrPtr; - snprintf(TempSprintfStr, TempInt, TempBuff, s); - } - } - else - { - va_list apcopy; - - va_copy(apcopy, ap); - TempInt = _vsnprintf_s(TempSprintfStr, TEMP_COUNT, _TRUNCATE, TempBuff, apcopy); - va_end(apcopy); - PAL_printf_arg_remover(&ap, Width, Precision, Type, Prefix); - - if (TempInt < 0 || static_cast(TempInt) >= TEMP_COUNT) - { - if (NULL == (TempSprintfStrPtr = (char*)InternalMalloc(++TempInt))) - { - ERROR("InternalMalloc failed\n"); - LOGEXIT("vfwprintf returns int -1\n"); - PERF_EXIT(vfwprintf); - pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY); - va_end(ap); - return -1; - } - - TempSprintfStr = TempSprintfStrPtr; - va_copy(apcopy, ap); - _vsnprintf_s(TempSprintfStr, TempInt, _TRUNCATE, TempBuff, apcopy); - va_end(apcopy); - PAL_printf_arg_remover(&ap, Width, Precision, Type, Prefix); - } - } - - mbtowcResult = MultiByteToWideChar(CP_ACP, 0, - TempSprintfStr, -1, - NULL, 0); - - if (mbtowcResult == 0) - { - ERROR("MultiByteToWideChar failed\n"); - if(TempSprintfStrPtr) - { - free(TempSprintfStrPtr); - } - LOGEXIT("vfwprintf returns int -1\n"); - PERF_EXIT(vfwprintf); - va_end(ap); - return -1; - } - - TempWideBuffer = (LPWSTR) InternalMalloc(mbtowcResult*sizeof(WCHAR)); - if (!TempWideBuffer) - { - ERROR("InternalMalloc failed\n"); - LOGEXIT("vfwprintf returns int -1\n"); - PERF_EXIT(vfwprintf); - pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY); - if(TempSprintfStrPtr) - { - free(TempSprintfStrPtr); - } - va_end(ap); - return -1; - } - - MultiByteToWideChar(CP_ACP, 0, TempSprintfStr, -1, - TempWideBuffer, mbtowcResult); - - ret = Internal_Convertfwrite( - pthrCurrent, - TempWideBuffer, - sizeof(wchar_16), - mbtowcResult-1, - (FILE*)stream->bsdFilePtr, - textMode); - - if (-1 == ret) - { - ERROR("fwrite() failed with errno == %d (%s)\n", errno, strerror(errno)); - LOGEXIT("vfwprintf returns int -1\n"); - PERF_EXIT(vfwprintf); - free(TempWideBuffer); - if(TempSprintfStrPtr) - { - free(TempSprintfStrPtr); - } - va_end(ap); - return -1; - } - if(TempSprintfStrPtr) - { - free(TempSprintfStrPtr); - } - free(TempWideBuffer); - } - } - else - { - ret = Internal_Convertfwrite( - pthrCurrent, - Fmt++, - sizeof(wchar_16), - 1, - (FILE*)stream->bsdFilePtr, - textMode); /* copy regular chars into buffer */ - - if (-1 == ret) - { - ERROR("fwrite() failed with errno == %d\n", errno); - LOGEXIT("vfwprintf returns int -1\n"); - PERF_EXIT(vfwprintf); - va_end(ap); - return -1; - } - ++written; - } - } - - LOGEXIT("vfwprintf returns int %d\n", written); - PERF_EXIT(vfwprintf); - va_end(ap); - return (written); -} - int CoreVfprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const char *format, va_list aparg) { CHAR TempBuff[1024]; /* used to hold a single % format string */ diff --git a/src/coreclr/pal/src/include/pal/palinternal.h b/src/coreclr/pal/src/include/pal/palinternal.h index dc39af8f4d41aa..b5d81aedbfd172 100644 --- a/src/coreclr/pal/src/include/pal/palinternal.h +++ b/src/coreclr/pal/src/include/pal/palinternal.h @@ -503,11 +503,8 @@ function_name() to call the system's implementation #undef printf #undef fprintf -#undef fwprintf #undef vfprintf -#undef vfwprintf #undef vprintf -#undef wprintf #undef wcstod #undef wcstoul #undef _wcstoui64 @@ -517,7 +514,6 @@ function_name() to call the system's implementation #undef wcsncmp #undef wcschr #undef wcsrchr -#undef swscanf #undef wcspbrk #undef wcsstr #undef wcscmp @@ -526,7 +522,6 @@ function_name() to call the system's implementation #undef iswspace #undef towlower #undef towupper -#undef wvsnprintf #ifdef HOST_AMD64 #undef _mm_getcsr diff --git a/src/coreclr/pal/src/include/pal/printfcpp.hpp b/src/coreclr/pal/src/include/pal/printfcpp.hpp index fd04285c949c19..44526cb8a4eaae 100644 --- a/src/coreclr/pal/src/include/pal/printfcpp.hpp +++ b/src/coreclr/pal/src/include/pal/printfcpp.hpp @@ -27,35 +27,9 @@ Module Name: #ifdef __cplusplus typedef char16_t wchar_16; // __wchar_16_cpp (which is defined in palinternal.h) needs to be redefined to wchar_16. - extern "C" { - int - __cdecl - PAL_vfprintf( - PAL_FILE *stream, - const char *format, - va_list ap); - - int - __cdecl - PAL_vfwprintf( - PAL_FILE *stream, - const wchar_16 *format, - va_list ap); -} - -namespace CorUnix -{ - int - InternalVfprintf( - CPalThread *pthrCurrent, - PAL_FILE *stream, - const char *format, - va_list ap); - -} -#else // __cplusplus +#endif // __cplusplus int __cdecl @@ -64,13 +38,8 @@ namespace CorUnix const char *format, va_list ap); - int - __cdecl - PAL_vfwprintf( - PAL_FILE *stream, - const wchar_16 *format, - va_list ap); - +#ifdef __cplusplus +} #endif // __cplusplus #endif // _PRINTFCPP_HPP diff --git a/src/coreclr/pal/tests/palsuite/CMakeLists.txt b/src/coreclr/pal/tests/palsuite/CMakeLists.txt index c88f4effb42ee4..2e3142d4107c45 100644 --- a/src/coreclr/pal/tests/palsuite/CMakeLists.txt +++ b/src/coreclr/pal/tests/palsuite/CMakeLists.txt @@ -146,25 +146,6 @@ add_executable_clr(paltests c_runtime/free/test1/test1.cpp c_runtime/fseek/test1/test1.cpp c_runtime/ftell/test1/ftell.cpp - c_runtime/fwprintf/test1/test1.cpp - c_runtime/fwprintf/test10/test10.cpp - c_runtime/fwprintf/test11/test11.cpp - c_runtime/fwprintf/test12/test12.cpp - c_runtime/fwprintf/test13/test13.cpp - c_runtime/fwprintf/test14/test14.cpp - c_runtime/fwprintf/test15/test15.cpp - c_runtime/fwprintf/test16/test16.cpp - c_runtime/fwprintf/test17/test17.cpp - c_runtime/fwprintf/test18/test18.cpp - c_runtime/fwprintf/test19/test19.cpp - c_runtime/fwprintf/test2/test2.cpp - c_runtime/fwprintf/test3/test3.cpp - c_runtime/fwprintf/test4/test4.cpp - c_runtime/fwprintf/test5/test5.cpp - c_runtime/fwprintf/test6/test6.cpp - c_runtime/fwprintf/test7/test7.cpp - c_runtime/fwprintf/test8/test8.cpp - c_runtime/fwprintf/test9/test9.cpp c_runtime/fwrite/test1/test1.cpp c_runtime/getenv/test1/test1.cpp c_runtime/getenv/test2/test2.cpp @@ -299,23 +280,6 @@ add_executable_clr(paltests c_runtime/swprintf/test7/test7.cpp c_runtime/swprintf/test8/test8.cpp c_runtime/swprintf/test9/test9.cpp - c_runtime/swscanf/test1/test1.cpp - c_runtime/swscanf/test10/test10.cpp - c_runtime/swscanf/test11/test11.cpp - c_runtime/swscanf/test12/test12.cpp - c_runtime/swscanf/test13/test13.cpp - c_runtime/swscanf/test14/test14.cpp - c_runtime/swscanf/test15/test15.cpp - c_runtime/swscanf/test16/test16.cpp - c_runtime/swscanf/test17/test17.cpp - c_runtime/swscanf/test2/test2.cpp - c_runtime/swscanf/test3/test3.cpp - c_runtime/swscanf/test4/test4.cpp - c_runtime/swscanf/test5/test5.cpp - c_runtime/swscanf/test6/test6.cpp - c_runtime/swscanf/test7/test7.cpp - c_runtime/swscanf/test8/test8.cpp - c_runtime/swscanf/test9/test9.cpp c_runtime/tan/test1/test1.cpp c_runtime/tanf/test1/test1.cpp c_runtime/tanh/test1/test1.cpp @@ -417,8 +381,6 @@ add_executable_clr(paltests c_runtime/wcstoul/test4/test4.cpp c_runtime/wcstoul/test5/test5.cpp c_runtime/wcstoul/test6/test6.cpp - c_runtime/wprintf/test1/test1.cpp - c_runtime/wprintf/test2/test2.cpp c_runtime/_alloca/test1/test1.cpp c_runtime/_fdopen/test1/test1.cpp c_runtime/_finite/test1/test1.cpp diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/fwprintf.h b/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/fwprintf.h deleted file mode 100644 index ec9519c1e9e39d..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/fwprintf.h +++ /dev/null @@ -1,459 +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: fwprintf.h -** -** Purpose: Contains common testing functions for fwprintf -** -** -**==========================================================================*/ - -#ifndef __fwprintf_H__ -#define __fwprintf_H__ - -inline void DoStrTest_fwprintf(const WCHAR *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 ((fwprintf(fp, formatstr, param)) < 0) - { - Fail("ERROR: fwprintf 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(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert string \"%\" into \"%S\"\n" - "Expected \"%s\" got \"%s\".\n", - param, formatstr, checkstr, buf); - } - fclose(fp); -} -#define DoStrTest DoStrTest_fwprintf - -inline void DoWStrTest_fwprintf(const WCHAR *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 ((fwprintf(fp, formatstr, param)) < 0) - { - Fail("ERROR: fwprintf 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(checkstr) + 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_fwprintf - -inline void DoPointerTest_fwprintf(const WCHAR *formatstr, void* param, char* paramstr, - 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 ((fwprintf(fp, formatstr, param)) < 0) - { - Fail("ERROR: fwprintf 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(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 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"); - } -} -#define DoPointerTest DoPointerTest_fwprintf - - -inline void DoCountTest_fwprintf(const WCHAR *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 ((fwprintf(fp, formatstr, &n)) < 0) - { - Fail("ERROR: fwprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, sizeof(buf), 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(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_fwprintf - -inline void DoShortCountTest_fwprintf(const WCHAR *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 ((fwprintf(fp, formatstr, &n)) < 0) - { - Fail("ERROR: fwprintf 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(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_fwprintf - -inline void DoCharTest_fwprintf(const WCHAR *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 ((fwprintf(fp, formatstr, param)) < 0) - { - Fail("ERROR: fwprintf 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(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_fwprintf - -inline void DoWCharTest_fwprintf(const WCHAR *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 ((fwprintf(fp, formatstr, param)) < 0) - { - Fail("ERROR: fwprintf 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(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_fwprintf - -inline void DoNumTest_fwprintf(const WCHAR *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 ((fwprintf(fp, formatstr, value)) < 0) - { - Fail("ERROR: fwprintf 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(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_fwprintf - -inline void DoI64Test_fwprintf(const WCHAR *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 ((fwprintf(fp, formatstr, value)) < 0) - { - Fail("ERROR: fwprintf 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(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 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_fwprintf - -inline void DoDoubleTest_fwprintf(const WCHAR *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 ((fwprintf(fp, formatstr, value)) < 0) - { - Fail("ERROR: fwprintf 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(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_fwprintf - -inline void DoArgumentPrecTest_fwprintf(const WCHAR *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 ((fwprintf(fp, formatstr, precision, param)) < 0) - { - Fail("ERROR: fwprintf 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(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_fwprintf - -inline void DoArgumentPrecDoubleTest_fwprintf(const WCHAR *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 ((fwprintf(fp, formatstr, precision, param)) < 0) - { - Fail("ERROR: fwprintf 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(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_fwprintf -#endif diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test1/test1.cpp deleted file mode 100644 index 907c009b1177ee..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test1/test1.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: test1.c -** -** 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_fwprintf_test1_paltest_fwprintf_test1, "c_runtime/fwprintf/test1/paltest_fwprintf_test1") -{ - FILE *fp; - char testfile[] = "testfile.txt"; - - WCHAR *outstr; - char checkstr[] = "hello world"; - char buf[256]; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - outstr = convert(checkstr); - if ((fp = fopen(testfile, "w+")) == NULL) - { - Fail("ERROR: fopen failed to create \"%s\"\n", testfile); - } - - if ((fwprintf(fp, outstr)) < 0) - { - Fail("ERROR: fwprintf 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/fwprintf/test10/test10.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test10/test10.cpp deleted file mode 100644 index eb3c3021702885..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test10/test10.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: test10.c -** -** Purpose: Tests the octal specifier (%o). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fwprintf_test10_paltest_fwprintf_test10, "c_runtime/fwprintf/test10/paltest_fwprintf_test10") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest(convert("foo %o"), pos, "foo 52"); - DoNumTest(convert("foo %lo"), 0xFFFF, "foo 177777"); - DoNumTest(convert("foo %ho"), 0xFFFF, "foo 177777"); - DoNumTest(convert("foo %Lo"), pos, "foo 52"); - DoI64Test(convert("foo %I64o"), l, "42", "foo 52", "foo 52"); - DoNumTest(convert("foo %3o"), pos, "foo 52"); - DoNumTest(convert("foo %-3o"), pos, "foo 52 "); - DoNumTest(convert("foo %.1o"), pos, "foo 52"); - DoNumTest(convert("foo %.3o"), pos, "foo 052"); - DoNumTest(convert("foo %03o"), pos, "foo 052"); - DoNumTest(convert("foo %#o"), pos, "foo 052"); - DoNumTest(convert("foo %+o"), pos, "foo 52"); - DoNumTest(convert("foo % o"), pos, "foo 52"); - DoNumTest(convert("foo %+o"), neg, "foo 37777777726"); - DoNumTest(convert("foo % o"), neg, "foo 37777777726"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test11/test11.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test11/test11.cpp deleted file mode 100644 index 43d3c8931766b1..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/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 the unsigned int specifier (%u). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fwprintf_test11_paltest_fwprintf_test11, "c_runtime/fwprintf/test11/paltest_fwprintf_test11") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest(convert("foo %u"), pos, "foo 42"); - DoNumTest(convert("foo %lu"), 0xFFFF, "foo 65535"); - DoNumTest(convert("foo %hu"), 0xFFFF, "foo 65535"); - DoNumTest(convert("foo %Lu"), pos, "foo 42"); - DoI64Test(convert("foo %I64u"), l, "42", "foo 42", "foo 42"); - DoNumTest(convert("foo %3u"), pos, "foo 42"); - DoNumTest(convert("foo %-3u"), pos, "foo 42 "); - DoNumTest(convert("foo %.1u"), pos, "foo 42"); - DoNumTest(convert("foo %.3u"), pos, "foo 042"); - DoNumTest(convert("foo %03u"), pos, "foo 042"); - DoNumTest(convert("foo %#u"), pos, "foo 42"); - DoNumTest(convert("foo %+u"), pos, "foo 42"); - DoNumTest(convert("foo % u"), pos, "foo 42"); - DoNumTest(convert("foo %+u"), neg, "foo 4294967254"); - DoNumTest(convert("foo % u"), neg, "foo 4294967254"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test12/test12.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test12/test12.cpp deleted file mode 100644 index eda46590a18044..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/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: Tests the (lowercase) hexadecimal specifier (%x). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fwprintf_test12_paltest_fwprintf_test12, "c_runtime/fwprintf/test12/paltest_fwprintf_test12") -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest(convert("foo %x"), pos, "foo 1234ab"); - DoNumTest(convert("foo %lx"), pos, "foo 1234ab"); - DoNumTest(convert("foo %hx"), pos, "foo 34ab"); - DoNumTest(convert("foo %Lx"), pos, "foo 1234ab"); - DoI64Test(convert("foo %I64x"), l, "0x1234567887654321", - "foo 1234567887654321", "foo 0x1234567887654321"); - DoNumTest(convert("foo %7x"), pos, "foo 1234ab"); - DoNumTest(convert("foo %-7x"), pos, "foo 1234ab "); - DoNumTest(convert("foo %.1x"), pos, "foo 1234ab"); - DoNumTest(convert("foo %.7x"), pos, "foo 01234ab"); - DoNumTest(convert("foo %07x"), pos, "foo 01234ab"); - DoNumTest(convert("foo %#x"), pos, "foo 0x1234ab"); - DoNumTest(convert("foo %+x"), pos, "foo 1234ab"); - DoNumTest(convert("foo % x"), pos, "foo 1234ab"); - DoNumTest(convert("foo %+x"), neg, "foo ffffffd6"); - DoNumTest(convert("foo % x"), neg, "foo ffffffd6"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test13/test13.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test13/test13.cpp deleted file mode 100644 index 0a9d214181bc7a..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/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: Tests the (uppercase) hexadecimal specifier (%X). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fwprintf_test13_paltest_fwprintf_test13, "c_runtime/fwprintf/test13/paltest_fwprintf_test13") -{ - int neg = -42; - int pos = 0x1234AB; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest(convert("foo %X"), pos, "foo 1234AB"); - DoNumTest(convert("foo %lX"), pos, "foo 1234AB"); - DoNumTest(convert("foo %hX"), pos, "foo 34AB"); - DoNumTest(convert("foo %LX"), pos, "foo 1234AB"); - DoI64Test(convert("foo %I64X"), l, "0x1234567887654321", - "foo 1234567887654321", "foo 0x1234567887654321"); - DoNumTest(convert("foo %7X"), pos, "foo 1234AB"); - DoNumTest(convert("foo %-7X"), pos, "foo 1234AB "); - DoNumTest(convert("foo %.1X"), pos, "foo 1234AB"); - DoNumTest(convert("foo %.7X"), pos, "foo 01234AB"); - DoNumTest(convert("foo %07X"), pos, "foo 01234AB"); - DoNumTest(convert("foo %#X"), pos, "foo 0X1234AB"); - DoNumTest(convert("foo %+X"), pos, "foo 1234AB"); - DoNumTest(convert("foo % X"), pos, "foo 1234AB"); - DoNumTest(convert("foo %+X"), neg, "foo FFFFFFD6"); - DoNumTest(convert("foo % X"), neg, "foo FFFFFFD6"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test14/test14.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test14/test14.cpp deleted file mode 100644 index ea1436239d7a85..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test14/test14.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: test14.c -** -** Purpose: Tests the lowercase exponential -** notation double specifier (%e). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fwprintf_test14_paltest_fwprintf_test14, "c_runtime/fwprintf/test14/paltest_fwprintf_test14") -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest(convert("foo %e"), val, "foo 2.560000e+002", - "foo 2.560000e+02"); - DoDoubleTest(convert("foo %le"), val, "foo 2.560000e+002", - "foo 2.560000e+02"); - DoDoubleTest(convert("foo %he"), val, "foo 2.560000e+002", - "foo 2.560000e+02"); - DoDoubleTest(convert("foo %Le"), val, "foo 2.560000e+002", - "foo 2.560000e+02"); - DoDoubleTest(convert("foo %I64e"), val, "foo 2.560000e+002", - "foo 2.560000e+02"); - DoDoubleTest(convert("foo %14e"), val, "foo 2.560000e+002", - "foo 2.560000e+02"); - DoDoubleTest(convert("foo %-14e"), val, "foo 2.560000e+002 ", - "foo 2.560000e+02 "); - DoDoubleTest(convert("foo %.1e"), val, "foo 2.6e+002", - "foo 2.6e+02"); - DoDoubleTest(convert("foo %.8e"), val, "foo 2.56000000e+002", - "foo 2.56000000e+02"); - DoDoubleTest(convert("foo %014e"), val, "foo 02.560000e+002", - "foo 002.560000e+02"); - DoDoubleTest(convert("foo %#e"), val, "foo 2.560000e+002", - "foo 2.560000e+02"); - DoDoubleTest(convert("foo %+e"), val, "foo +2.560000e+002", - "foo +2.560000e+02"); - DoDoubleTest(convert("foo % e"), val, "foo 2.560000e+002", - "foo 2.560000e+02"); - DoDoubleTest(convert("foo %+e"), neg, "foo -2.560000e+002", - "foo -2.560000e+02"); - DoDoubleTest(convert("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/fwprintf/test15/test15.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test15/test15.cpp deleted file mode 100644 index 34f78cc3dbaca4..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test15/test15.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: test15.c -** -** Purpose: Tests the uppercase exponential -** notation double specifier (%E). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fwprintf_test15_paltest_fwprintf_test15, "c_runtime/fwprintf/test15/paltest_fwprintf_test15") -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest(convert("foo %E"), val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest(convert("foo %lE"), val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest(convert("foo %hE"), val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest(convert("foo %LE"), val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest(convert("foo %I64E"), val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest(convert("foo %14E"), val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest(convert("foo %-14E"), val, "foo 2.560000E+002 ", - "foo 2.560000E+02 "); - DoDoubleTest(convert("foo %.1E"), val, "foo 2.6E+002", - "foo 2.6E+02"); - DoDoubleTest(convert("foo %.8E"), val, "foo 2.56000000E+002", - "foo 2.56000000E+02"); - DoDoubleTest(convert("foo %014E"), val, "foo 02.560000E+002", - "foo 002.560000E+02"); - DoDoubleTest(convert("foo %#E"), val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest(convert("foo %+E"), val, "foo +2.560000E+002", - "foo +2.560000E+02"); - DoDoubleTest(convert("foo % E"), val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest(convert("foo %+E"), neg, "foo -2.560000E+002", - "foo -2.560000E+02"); - DoDoubleTest(convert("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/fwprintf/test16/test16.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test16/test16.cpp deleted file mode 100644 index 8f90e162874cd4..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test16/test16.cpp +++ /dev/null @@ -1,64 +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: Tests the decimal notation double specifier (%f). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fwprintf_test16_paltest_fwprintf_test16, "c_runtime/fwprintf/test16/paltest_fwprintf_test16") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest(convert("foo %f"), val, "foo 2560.001000", - "foo 2560.001000"); - DoDoubleTest(convert("foo %lf"), val, "foo 2560.001000", - "foo 2560.001000"); - DoDoubleTest(convert("foo %hf"), val, "foo 2560.001000", - "foo 2560.001000"); - DoDoubleTest(convert("foo %Lf"), val, "foo 2560.001000", - "foo 2560.001000"); - DoDoubleTest(convert("foo %I64f"), val, "foo 2560.001000", - "foo 2560.001000"); - DoDoubleTest(convert("foo %12f"), val, "foo 2560.001000", - "foo 2560.001000"); - DoDoubleTest(convert("foo %-12f"), val, "foo 2560.001000 ", - "foo 2560.001000 "); - DoDoubleTest(convert("foo %.1f"), val, "foo 2560.0", - "foo 2560.0"); - DoDoubleTest(convert("foo %.8f"), val, "foo 2560.00100000", - "foo 2560.00100000"); - DoDoubleTest(convert("foo %012f"), val, "foo 02560.001000", - "foo 02560.001000"); - DoDoubleTest(convert("foo %#f"), val, "foo 2560.001000", - "foo 2560.001000"); - DoDoubleTest(convert("foo %+f"), val, "foo +2560.001000", - "foo +2560.001000"); - DoDoubleTest(convert("foo % f"), val, "foo 2560.001000", - "foo 2560.001000"); - DoDoubleTest(convert("foo %+f"), neg, "foo -2560.001000", - "foo -2560.001000"); - DoDoubleTest(convert("foo % f"), neg, "foo -2560.001000", - "foo -2560.001000"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test17/test17.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test17/test17.cpp deleted file mode 100644 index 002bbcd034ab2e..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test17/test17.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: test17.c -** -** Purpose: Tests the lowercase shorthand notation double specifier (%g). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fwprintf_test17_paltest_fwprintf_test17, "c_runtime/fwprintf/test17/paltest_fwprintf_test17") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest(convert("foo %g"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %lg"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %hg"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %Lg"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %I64g"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %5g"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %-5g"), val, "foo 2560 ", "foo 2560 "); - DoDoubleTest(convert("foo %.1g"), val, "foo 3e+003", "foo 3e+03"); - DoDoubleTest(convert("foo %.2g"), val, "foo 2.6e+003", "foo 2.6e+03"); - DoDoubleTest(convert("foo %.12g"), val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest(convert("foo %06g"), val, "foo 002560", "foo 002560"); - DoDoubleTest(convert("foo %#g"), val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest(convert("foo %+g"), val, "foo +2560", "foo +2560"); - DoDoubleTest(convert("foo % g"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %+g"), neg, "foo -2560", "foo -2560"); - DoDoubleTest(convert("foo % g"), neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test18/test18.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test18/test18.cpp deleted file mode 100644 index fd9955b218d726..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/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: Tests the uppercase shorthand notation double specifier (%G). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fwprintf_test18_paltest_fwprintf_test18, "c_runtime/fwprintf/test18/paltest_fwprintf_test18") -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest(convert("foo %G"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %lG"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %hG"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %LG"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %I64G"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %5G"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %-5G"), val, "foo 2560 ", "foo 2560 "); - DoDoubleTest(convert("foo %.1G"), val, "foo 3E+003", "foo 3E+03"); - DoDoubleTest(convert("foo %.2G"), val, "foo 2.6E+003", "foo 2.6E+03"); - DoDoubleTest(convert("foo %.12G"), val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest(convert("foo %06G"), val, "foo 002560", "foo 002560"); - DoDoubleTest(convert("foo %#G"), val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest(convert("foo %+G"), val, "foo +2560", "foo +2560"); - DoDoubleTest(convert("foo % G"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %+G"), neg, "foo -2560", "foo -2560"); - DoDoubleTest(convert("foo % G"), neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test19/test19.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test19/test19.cpp deleted file mode 100644 index c53509d22754fa..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test19/test19.cpp +++ /dev/null @@ -1,80 +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 the variable length precision argument. -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - - - -PALTEST(c_runtime_fwprintf_test19_paltest_fwprintf_test19, "c_runtime/fwprintf/test19/paltest_fwprintf_test19") -{ - int n = -1; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoArgumentPrecTest(convert("%.*s"), 2, (void*)convert("bar"), "bar", "ba", "ba"); - DoArgumentPrecTest(convert("%.*S"), 2, (void*)"bar", "bar", "ba", "ba"); - DoArgumentPrecTest(convert("foo %.*n"), 3, (void*)&n, "pointer to int", "foo ", - "foo "); - if (n != 4) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - 4, n); - } - - DoArgumentPrecTest(convert("%.*c"), 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest(convert("%.*c"), 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest(convert("%.*C"), 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest(convert("%.*C"), 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest(convert("%.*d"), 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest(convert("%.*d"), 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest(convert("%.*i"), 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest(convert("%.*i"), 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest(convert("%.*o"), 1, (void*)42, "42", "52", "52"); - DoArgumentPrecTest(convert("%.*o"), 3, (void*)42, "42", "052", "052"); - DoArgumentPrecTest(convert("%.*u"), 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest(convert("%.*u"), 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest(convert("%.*x"), 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest(convert("%.*x"), 3, (void*)0x42, "0x42", "042", "042"); - DoArgumentPrecTest(convert("%.*X"), 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest(convert("%.*X"), 3, (void*)0x42, "0x42", "042", "042"); - - - DoArgumentPrecDoubleTest(convert("%.*e"), 1, 2.01, "2.0e+000", "2.0e+00"); - DoArgumentPrecDoubleTest(convert("%.*e"), 3, 2.01, "2.010e+000", - "2.010e+00"); - DoArgumentPrecDoubleTest(convert("%.*E"), 1, 2.01, "2.0E+000", "2.0E+00"); - DoArgumentPrecDoubleTest(convert("%.*E"), 3, 2.01, "2.010E+000", - "2.010E+00"); - DoArgumentPrecDoubleTest(convert("%.*f"), 1, 2.01, "2.0", "2.0"); - DoArgumentPrecDoubleTest(convert("%.*f"), 3, 2.01, "2.010", "2.010"); - DoArgumentPrecDoubleTest(convert("%.*g"), 1, 256.01, "3e+002", "3e+02"); - DoArgumentPrecDoubleTest(convert("%.*g"), 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest(convert("%.*g"), 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest(convert("%.*g"), 6, 256.01, "256.01", "256.01"); - DoArgumentPrecDoubleTest(convert("%.*G"), 1, 256.01, "3E+002", "3E+02"); - DoArgumentPrecDoubleTest(convert("%.*G"), 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest(convert("%.*G"), 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest(convert("%.*G"), 6, 256.01, "256.01", "256.01"); - - PAL_Terminate(); - - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test2/test2.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test2/test2.cpp deleted file mode 100644 index e591a71ab58746..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/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: Tests the string specifier (%s). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fwprintf_test2_paltest_fwprintf_test2, "c_runtime/fwprintf/test2/paltest_fwprintf_test2") -{ - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoWStrTest(convert("foo %s"), convert("bar"), "foo bar"); - DoStrTest(convert("foo %hs"), "bar", "foo bar"); - DoWStrTest(convert("foo %ls"), convert("bar"), "foo bar"); - DoWStrTest(convert("foo %ws"), convert("bar"), "foo bar"); - DoWStrTest(convert("foo %Ls"), convert("bar"), "foo bar"); - DoWStrTest(convert("foo %I64s"), convert("bar"), "foo bar"); - DoWStrTest(convert("foo %5s"), convert("bar"), "foo bar"); - DoWStrTest(convert("foo %.2s"), convert("bar"), "foo ba"); - DoWStrTest(convert("foo %5.2s"), convert("bar"), "foo ba"); - DoWStrTest(convert("foo %-5s"), convert("bar"), "foo bar "); - DoWStrTest(convert("foo %05s"), convert("bar"), "foo 00bar"); - DoWStrTest(convert("foo %s"), NULL, "foo (null)"); - DoStrTest(convert("foo %hs"), NULL, "foo (null)"); - DoWStrTest(convert("foo %ls"), NULL, "foo (null)"); - DoWStrTest(convert("foo %ws"), NULL, "foo (null)"); - DoWStrTest(convert("foo %Ls"), NULL, "foo (null)"); - DoWStrTest(convert("foo %I64s"), NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test3/test3.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test3/test3.cpp deleted file mode 100644 index 21876d28b1ac7d..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/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 the wide string specifier (%S). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fwprintf_test3_paltest_fwprintf_test3, "c_runtime/fwprintf/test3/paltest_fwprintf_test3") -{ - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoStrTest(convert("foo %S"), "bar", "foo bar"); - DoStrTest(convert("foo %hS"), "bar", "foo bar"); - DoWStrTest(convert("foo %lS"), convert("bar"), "foo bar"); - DoWStrTest(convert("foo %wS"), convert("bar"), "foo bar"); - DoStrTest(convert("foo %LS"), "bar", "foo bar"); - DoStrTest(convert("foo %I64S"), "bar", "foo bar"); - DoStrTest(convert("foo %5S"), "bar", "foo bar"); - DoStrTest(convert("foo %.2S"), "bar", "foo ba"); - DoStrTest(convert("foo %5.2S"),"bar", "foo ba"); - DoStrTest(convert("foo %-5S"), "bar", "foo bar "); - DoStrTest(convert("foo %05S"), "bar", "foo 00bar"); - DoStrTest(convert("foo %S"), NULL, "foo (null)"); - DoStrTest(convert("foo %hS"), NULL, "foo (null)"); - DoWStrTest(convert("foo %lS"), NULL, "foo (null)"); - DoWStrTest(convert("foo %wS"), NULL, "foo (null)"); - DoStrTest(convert("foo %LS"), NULL, "foo (null)"); - DoStrTest(convert("foo %I64S"), NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test4/test4.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test4/test4.cpp deleted file mode 100644 index 35053ad0df3855..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test4/test4.cpp +++ /dev/null @@ -1,84 +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 the pointer specifier (%p). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fwprintf_test4_paltest_fwprintf_test4, "c_runtime/fwprintf/test4/paltest_fwprintf_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(convert("%p"), NULL, "NULL", "0000000000000000", "0x0"); - DoPointerTest(convert("%p"), ptr, "pointer to 0x123456", "0000000000123456", - "0x123456"); - DoPointerTest(convert("%17p"), ptr, "pointer to 0x123456", " 0000000000123456", - " 0x123456"); - DoPointerTest(convert("%17p"), ptr, "pointer to 0x123456", " 0000000000123456", - "0x0123456"); - DoPointerTest(convert("%-17p"), ptr, "pointer to 0x123456", "0000000000123456 ", - "0x123456 "); - DoPointerTest(convert("%+p"), ptr, "pointer to 0x123456", "0000000000123456", - "0x123456"); - DoPointerTest(convert("%#p"), ptr, "pointer to 0x123456", "0X0000000000123456", - "0x123456"); - DoPointerTest(convert("%lp"), ptr, "pointer to 0x123456", "00123456", - "0x123456"); - DoPointerTest(convert("%hp"), ptr, "pointer to 0x123456", "00003456", - "0x3456"); - DoPointerTest(convert("%Lp"), ptr, "pointer to 0x123456", "00123456", - "0x123456"); - DoI64Test(convert("%I64p"), lptr, "pointer to 0x1234567887654321", - "1234567887654321", "0x1234567887654321"); -#else - Trace("Testing for Non 64 Bit Platforms \n"); - DoPointerTest(convert("%p"), NULL, "NULL", "00000000", "0x0"); - DoPointerTest(convert("%p"), ptr, "pointer to 0x123456", "00123456", - "0x123456"); - DoPointerTest(convert("%9p"), ptr, "pointer to 0x123456", " 00123456", - " 0x123456"); - DoPointerTest(convert("%09p"), ptr, "pointer to 0x123456", " 00123456", - "0x0123456"); - DoPointerTest(convert("%-9p"), ptr, "pointer to 0x123456", "00123456 ", - "0x123456 "); - DoPointerTest(convert("%+p"), ptr, "pointer to 0x123456", "00123456", - "0x123456"); - DoPointerTest(convert("%#p"), ptr, "pointer to 0x123456", "0X00123456", - "0x123456"); - DoPointerTest(convert("%lp"), ptr, "pointer to 0x123456", "00123456", - "0x123456"); - DoPointerTest(convert("%hp"), ptr, "pointer to 0x123456", "00003456", - "0x3456"); - DoPointerTest(convert("%Lp"), ptr, "pointer to 0x123456", "00123456", - "0x123456"); - DoI64Test(convert("%I64p"), lptr, "pointer to 0x1234567887654321", - "1234567887654321", "0x1234567887654321"); -#endif - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test5/test5.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test5/test5.cpp deleted file mode 100644 index d7ee738f8a1867..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test5/test5.cpp +++ /dev/null @@ -1,62 +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: Tests the count specifier (%n). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fwprintf_test5_paltest_fwprintf_test5, "c_runtime/fwprintf/test5/paltest_fwprintf_test5") -{ - WCHAR *longStr; - 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; - } - - longStr = - convert("really-long-string-that-just-keeps-going-on-and-on-and-on.." - "..................useless-filler.................................." - "..................useless-filler.................................." - "..................useless-filler.................................." - "%n bar"); - DoCountTest(convert("foo %n bar"), 4, "foo bar"); - DoCountTest(longStr, 257, longResult); - DoCountTest(convert("fo%n bar"), 2, "fo bar"); - DoCountTest(convert("%n foo"), 0, " foo"); - DoCountTest(convert("foo %#n bar"), 4, "foo bar"); - DoCountTest(convert("foo % n bar"), 4, "foo bar"); - DoCountTest(convert("foo %+n bar"), 4, "foo bar"); - DoCountTest(convert("foo %-n bar"), 4, "foo bar"); - DoCountTest(convert("foo %0n bar"), 4, "foo bar"); - DoShortCountTest(convert("foo %hn bar"), 4, "foo bar"); - DoCountTest(convert("foo %ln bar"), 4, "foo bar"); - DoCountTest(convert("foo %Ln bar"), 4, "foo bar"); - DoCountTest(convert("foo %I64n bar"), 4, "foo bar"); - DoCountTest(convert("foo %20.3n bar"), 4, "foo bar"); - - PAL_Terminate(); - - free(longStr); - - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test6/test6.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test6/test6.cpp deleted file mode 100644 index 5baa96b229f53f..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/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: Tests the char specifier (%c). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fwprintf_test6_paltest_fwprintf_test6, "c_runtime/fwprintf/test6/paltest_fwprintf_test6") -{ - WCHAR wb = (WCHAR) 'b'; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoWCharTest(convert("foo %c"), wb, "foo b"); - DoCharTest(convert("foo %hc"), 'c', "foo c"); - DoWCharTest(convert("foo %lc"), wb, "foo b"); - DoWCharTest(convert("foo %Lc"), wb, "foo b"); - DoWCharTest(convert("foo %I64c"), wb, "foo b"); - DoWCharTest(convert("foo %5c"), wb, "foo b"); - DoWCharTest(convert("foo %.0c"), wb, "foo b"); - DoWCharTest(convert("foo %-5c"), wb, "foo b "); - DoWCharTest(convert("foo %05c"), wb, "foo 0000b"); - DoWCharTest(convert("foo % c"), wb, "foo b"); - DoWCharTest(convert("foo %#c"), wb, "foo b"); - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test7/test7.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test7/test7.cpp deleted file mode 100644 index aff34340f63ae8..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/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 the wide char specifier (%C). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fwprintf_test7_paltest_fwprintf_test7, "c_runtime/fwprintf/test7/paltest_fwprintf_test7") -{ - WCHAR wb = (WCHAR) 'b'; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoCharTest(convert("foo %C"), 'c', "foo c"); - DoWCharTest(convert("foo %hc"), wb, "foo b"); - DoCharTest(convert("foo %lC"), 'c', "foo c"); - DoCharTest(convert("foo %LC"), 'c', "foo c"); - DoCharTest(convert("foo %I64C"), 'c', "foo c"); - DoCharTest(convert("foo %5C"), 'c', "foo c"); - DoCharTest(convert("foo %.0C"), 'c', "foo c"); - DoCharTest(convert("foo %-5C"), 'c', "foo c "); - DoCharTest(convert("foo %05C"), 'c', "foo 0000c"); - DoCharTest(convert("foo % C"), 'c', "foo c"); - DoCharTest(convert("foo %#C"), 'c', "foo c"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test8/test8.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test8/test8.cpp deleted file mode 100644 index a7d253166e4821..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test8/test8.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: test8.c -** -** Purpose: Tests the decimal specifier (%d). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fwprintf_test8_paltest_fwprintf_test8, "c_runtime/fwprintf/test8/paltest_fwprintf_test8") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest(convert("foo %d"), pos, "foo 42"); - DoNumTest(convert("foo %ld"), 0xFFFF, "foo 65535"); - DoNumTest(convert("foo %hd"), 0xFFFF, "foo -1"); - DoNumTest(convert("foo %Ld"), pos, "foo 42"); - DoI64Test(convert("foo %I64d"), l, "42", "foo 42", "foo 42"); - DoNumTest(convert("foo %3d"), pos, "foo 42"); - DoNumTest(convert("foo %-3d"), pos, "foo 42 "); - DoNumTest(convert("foo %.1d"), pos, "foo 42"); - DoNumTest(convert("foo %.3d"), pos, "foo 042"); - DoNumTest(convert("foo %03d"), pos, "foo 042"); - DoNumTest(convert("foo %#d"), pos, "foo 42"); - DoNumTest(convert("foo %+d"), pos, "foo +42"); - DoNumTest(convert("foo % d"), pos, "foo 42"); - DoNumTest(convert("foo %+d"), neg, "foo -42"); - DoNumTest(convert("foo % d"), neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test9/test9.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/test9/test9.cpp deleted file mode 100644 index 74fbdfc57e89ba..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/fwprintf/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: Tests the integer specifier (%i). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -PALTEST(c_runtime_fwprintf_test9_paltest_fwprintf_test9, "c_runtime/fwprintf/test9/paltest_fwprintf_test9") -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest(convert("foo %i"), pos, "foo 42"); - DoNumTest(convert("foo %li"), 0xFFFF, "foo 65535"); - DoNumTest(convert("foo %hi"), 0xFFFF, "foo -1"); - DoNumTest(convert("foo %Li"), pos, "foo 42"); - DoI64Test(convert("foo %I64i"), l, "42", "foo 42", "foo 42"); - DoNumTest(convert("foo %3i"), pos, "foo 42"); - DoNumTest(convert("foo %-3i"), pos, "foo 42 "); - DoNumTest(convert("foo %.1i"), pos, "foo 42"); - DoNumTest(convert("foo %.3i"), pos, "foo 042"); - DoNumTest(convert("foo %03i"), pos, "foo 042"); - DoNumTest(convert("foo %#i"), pos, "foo 42"); - DoNumTest(convert("foo %+i"), pos, "foo +42"); - DoNumTest(convert("foo % i"), pos, "foo 42"); - DoNumTest(convert("foo %+i"), neg, "foo -42"); - DoNumTest(convert("foo % i"), neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/swscanf.h b/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/swscanf.h deleted file mode 100644 index 0950263bfae63d..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/swscanf.h +++ /dev/null @@ -1,268 +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: swscanf.h -** -** Purpose: Contains common testing functions for swscanf.h -** -** -**==========================================================================*/ - -#ifndef __SWSCANF_H__ -#define __SWSCANF_H__ - -inline void DoVoidTest_swscanf(WCHAR *inputstr, const WCHAR *formatstr) -{ - char buf[256] = { 0 }; - int i; - int ret; - - ret = swscanf(inputstr, formatstr, buf); - if (ret != 0) - { - Fail("ERROR: Expected sscanf to return 0, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), - convertC(formatstr)); - } - - for (i=0; i<256; i++) - { - if (buf[i] != 0) - { - Fail("ERROR: Parameter unexpectedly modified scanning \"%s\" " - "using \"%s\".\n", convertC(inputstr), - convertC(formatstr)); - } - } - -} -#define DoVoidTest DoVoidTest_swscanf - -inline void DoStrTest_swscanf(WCHAR *inputstr, const WCHAR *formatstr, const char *checkstr) -{ - char buf[256] = { 0 }; - int ret; - - ret = swscanf(inputstr, formatstr, buf); - if (ret != 1) - { - Fail("ERROR: Expected swscanf to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), - convertC(formatstr)); - } - - if (memcmp(checkstr, buf, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: scanned string incorrectly from \"%s\" using \"%s\".\n" - "Expected \"%s\", got \"%s\".\n", convertC(inputstr), - convertC(formatstr), checkstr, - buf); - } - -} -#define DoStrTest DoStrTest_swscanf - -inline void DoWStrTest_swscanf(WCHAR *inputstr, const WCHAR *formatstr, const WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - int ret; - - ret = swscanf(inputstr, formatstr, buf); - if (ret != 1) - { - Fail("ERROR: Expected swscanf to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), - convertC(formatstr)); - } - - if (memcmp(checkstr, buf, wcslen(checkstr)*2 + 2) != 0) - { - Fail("ERROR: scanned wide string incorrectly from \"%s\" using \"%s\".\n" - "Expected \"%s\", got \"%s\".\n", convertC(inputstr), - convertC(formatstr), convertC(checkstr), - convertC(buf)); - } - -} -#define DoWStrTest DoWStrTest_swscanf - -inline void DoNumTest_swscanf(WCHAR *inputstr, const WCHAR *formatstr, int checknum) -{ - int num = 0; - int ret; - - ret = swscanf(inputstr, formatstr, &num); - if (ret != 1) - { - Fail("ERROR: Expected swscanf to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), - convertC(formatstr)); - } - - if (checknum != num) - { - Fail("ERROR: scanned number incorrectly from \"%s\" using \"%s\".\n" - "Expected %d, got %d.\n", convertC(inputstr), - convertC(formatstr), checknum, num); - } -} -#define DoNumTest DoNumTest_swscanf - -inline void DoShortNumTest_swscanf(WCHAR *inputstr, const WCHAR *formatstr, short checknum) -{ - short num = 0; - int ret; - - ret = swscanf(inputstr, formatstr, &num); - if (ret != 1) - { - Fail("ERROR: Expected swscanf to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), - convertC(formatstr)); - } - - if (checknum != num) - { - Fail("ERROR: scanned number incorrectly from \"%s\" using \"%s\".\n" - "Expected %hd, got %hd.\n", convertC(inputstr), - convertC(formatstr), checknum, num); - } -} -#define DoShortNumTest DoShortNumTest_swscanf - -inline void DoI64NumTest_swscanf(WCHAR *inputstr, const WCHAR *formatstr, INT64 checknum) -{ - char buf[256]; - char check[256]; - INT64 num; - int ret; - - ret = swscanf(inputstr, formatstr, &num); - if (ret != 1) - { - Fail("ERROR: Expected swscanf to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), - convertC(formatstr)); - } - - if (checknum != num) - { - sprintf_s(buf, ARRAY_SIZE(buf), "%I64d", num); - sprintf_s(check, ARRAY_SIZE(check), "%I64d", checknum); - Fail("ERROR: scanned I64 number incorrectly from \"%s\" using \"%s\".\n" - "Expected %s, got %s.\n", convertC(inputstr), - convertC(formatstr), check, buf); - } -} -#define DoI64NumTest DoI64NumTest_swscanf - -inline void DoCharTest_swscanf(WCHAR *inputstr, const WCHAR *formatstr, char* checkchars, int numchars) -{ - char buf[256]; - int ret; - int i; - - for (i=0; i<256; i++) - buf[i] = (char)-1; - - ret = swscanf(inputstr, formatstr, buf); - if (ret != 1) - { - Fail("ERROR: Expected swscanf to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), - convertC(formatstr)); - } - - if (memcmp(buf, checkchars, numchars) != 0) - { - buf[numchars] = 0; - - Fail("ERROR: scanned character(s) incorrectly from \"%s\" using \"%s\".\n" - "Expected %s, got %s.\n", convertC(inputstr), - convertC(formatstr), checkchars, buf); - } - - if (buf[numchars] != (char)-1) - { - Fail("ERROR: overflow occurred in scanning character(s) from \"%s\" " - "using \"%s\".\nExpected %d character(s)\n", - convertC(inputstr), convertC(formatstr), numchars); - } -} -#define DoCharTest DoCharTest_swscanf - -inline void DoWCharTest_swscanf(WCHAR *inputstr, const WCHAR *formatstr, const WCHAR *checkchars, int numchars) -{ - WCHAR buf[256]; - int ret; - int i; - - for (i=0; i<256; i++) - buf[i] = (WCHAR)-1; - - ret = swscanf(inputstr, formatstr, buf); - if (ret != 1) - { - Fail("ERROR: Expected swscanf to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), - convertC(formatstr)); - } - - if (memcmp(buf, checkchars, numchars*2) != 0) - { - buf[numchars] = 0; - - Fail("ERROR: scanned wide character(s) incorrectly from \"%s\" using \"%s\".\n" - "Expected %s, got %s.\n", convertC(inputstr), - convertC(formatstr), convertC(checkchars), - convertC(buf)); - } - - if (buf[numchars] != (WCHAR)-1) - { - Fail("ERROR: overflow occurred in scanning wide character(s) from \"%s\" " - "using \"%s\".\nExpected %d character(s)\n", - convertC(inputstr), convertC(formatstr), numchars); - } -} -#define DoWCharTest DoWCharTest_swscanf - -inline void DoFloatTest_swscanf(WCHAR *inputstr, const WCHAR *formatstr, float checkval) -{ - char buf[256] = { 0 }; - float val; - int ret; - int i; - - for (i=0; i<256; i++) - buf[i] = (char)-1; - - ret = swscanf(inputstr, formatstr, buf); - val = *(float*)buf; - - if (ret != 1) - { - Fail("ERROR: Expected swscanf to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), - convertC(formatstr)); - } - - if (val != checkval) - { - Fail("ERROR: scanned float incorrectly from \"%s\" using \"%s\".\n" - "Expected \"%f\", got \"%f\".\n", convertC(inputstr), - convertC(formatstr), checkval, val); - } - - if (buf[4] != (char)-1) - { - Fail("ERROR: overflow occurred in scanning float from \"%s\" " - "using \"%s\".\n", convertC(inputstr), convertC(formatstr)); - - } -} -#define DoFloatTest DoFloatTest_swscanf - -#endif diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test1/test1.cpp deleted file mode 100644 index 257706ae4cd3da..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test1/test1.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: test1.c -** -** Purpose: General test of swscanf -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - - -PALTEST(c_runtime_swscanf_test1_paltest_swscanf_test1, "c_runtime/swscanf/test1/paltest_swscanf_test1") -{ - int num; - int ret; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoVoidTest(convert("foo bar"), convert("foo")); - DoVoidTest(convert("foo bar"), convert("baz")); - DoVoidTest(convert("foo bar"), convert("foo %*s")); - - DoStrTest(convert("foo % bar"), convert("foo %% %S"), "bar"); - DoStrTest(convert("foo bar baz"), convert("foo %bar %S"), "baz"); - - DoVoidTest(convert("foo bar baz"), convert("foo % bar %S")); - DoVoidTest(convert("foo bar baz"), convert("foo% bar %S")); - - - ret = swscanf(convert("foo bar baz"), convert("foo bar %n"), &num); - if (ret != 0 || num != 8) - { - Fail("ERROR: Got incorrect values in scanning \"%s\" using \"%s\".\n" - "Expected to get a value of %d with return value of %d, " - "got %d with return %d\n", "foo bar baz", "foo bar %n", 8, 0, - num, ret); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test10/test10.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test10/test10.cpp deleted file mode 100644 index 0e9422950bd7b8..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test10/test10.cpp +++ /dev/null @@ -1,35 +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 swscanf with wide characters -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - -PALTEST(c_runtime_swscanf_test10_paltest_swscanf_test10, "c_runtime/swscanf/test10/paltest_swscanf_test10") -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoCharTest(convert("1234"), convert("%C"), "1", 1); - DoCharTest(convert("abc"), convert("%2C"), "ab", 2); - DoCharTest(convert(" ab"), convert("%C"), " ", 1); - DoCharTest(convert("ab"), convert("%hC"), "a", 1); - DoWCharTest(convert("ab"), convert("%lC"), convert("a"), 1); - DoCharTest(convert("ab"), convert("%LC"), "a", 1); - DoCharTest(convert("ab"), convert("%I64C"), "a", 1); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test11/test11.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test11/test11.cpp deleted file mode 100644 index e24ca297f49362..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test11/test11.cpp +++ /dev/null @@ -1,34 +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 swscanf with strings -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - -PALTEST(c_runtime_swscanf_test11_paltest_swscanf_test11, "c_runtime/swscanf/test11/paltest_swscanf_test11") -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoWStrTest(convert("foo bar"), convert("foo %s"), convert("bar")); - DoWStrTest(convert("foo bar"), convert("foo %2s"), convert("ba")); - DoStrTest(convert("foo bar"), convert("foo %hs"), "bar"); - DoWStrTest(convert("foo bar"), convert("foo %ls"), convert("bar")); - DoWStrTest(convert("foo bar"), convert("foo %Ls"), convert("bar")); - DoWStrTest(convert("foo bar"), convert("foo %I64s"), convert("bar")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test12/test12.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test12/test12.cpp deleted file mode 100644 index 857c1386f9ff76..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test12/test12.cpp +++ /dev/null @@ -1,34 +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 swscanf with wide strings -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - -PALTEST(c_runtime_swscanf_test12_paltest_swscanf_test12, "c_runtime/swscanf/test12/paltest_swscanf_test12") -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoStrTest(convert("foo bar"), convert("foo %S"), "bar"); - DoStrTest(convert("foo bar"), convert("foo %2S"), "ba"); - DoStrTest(convert("foo bar"), convert("foo %hS"), "bar"); - DoWStrTest(convert("foo bar"), convert("foo %lS"), convert("bar")); - DoStrTest(convert("foo bar"), convert("foo %LS"), "bar"); - DoStrTest(convert("foo bar"), convert("foo %I64S"), "bar"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test13/test13.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test13/test13.cpp deleted file mode 100644 index 1e4d6021eb77f9..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test13/test13.cpp +++ /dev/null @@ -1,36 +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 swscanf with floats (decimal notation) -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - -PALTEST(c_runtime_swscanf_test13_paltest_swscanf_test13, "c_runtime/swscanf/test13/paltest_swscanf_test13") -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoFloatTest(convert("123.0"), convert("%f"), 123.0f); - DoFloatTest(convert("123.0"), convert("%2f"), 12.0f); - DoFloatTest(convert("10E1"), convert("%f"), 100.0f); - DoFloatTest(convert("-12.01e-2"), convert("%f"), -0.1201f); - DoFloatTest(convert("+12.01e-2"), convert("%f"), 0.1201f); - DoFloatTest(convert("-12.01e+2"), convert("%f"), -1201.0f); - DoFloatTest(convert("+12.01e+2"), convert("%f"), 1201.0f); - DoFloatTest(convert("1234567890.0123456789f"), convert("%f"), 1234567936); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test14/test14.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test14/test14.cpp deleted file mode 100644 index a8cfc9040177a3..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test14/test14.cpp +++ /dev/null @@ -1,37 +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 swscanf with floats (exponential notation, lowercase) -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - - -PALTEST(c_runtime_swscanf_test14_paltest_swscanf_test14, "c_runtime/swscanf/test14/paltest_swscanf_test14") -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoFloatTest(convert("123.0"), convert("%e"), 123.0f); - DoFloatTest(convert("123.0"), convert("%2e"), 12.0f); - DoFloatTest(convert("10E1"), convert("%e"), 100.0f); - DoFloatTest(convert("-12.01e-2"), convert("%e"), -0.1201f); - DoFloatTest(convert("+12.01e-2"), convert("%e"), 0.1201f); - DoFloatTest(convert("-12.01e+2"), convert("%e"), -1201.0f); - DoFloatTest(convert("+12.01e+2"), convert("%e"), 1201.0f); - DoFloatTest(convert("1234567890.0123456789f"), convert("%e"), 1234567936); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test15/test15.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test15/test15.cpp deleted file mode 100644 index 73a4e536ca4119..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test15/test15.cpp +++ /dev/null @@ -1,36 +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 swscanf with floats (exponential notation, uppercase) -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - -PALTEST(c_runtime_swscanf_test15_paltest_swscanf_test15, "c_runtime/swscanf/test15/paltest_swscanf_test15") -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoFloatTest(convert("123.0"), convert("%E"), 123.0f); - DoFloatTest(convert("123.0"), convert("%2E"), 12.0f); - DoFloatTest(convert("10E1"), convert("%E"), 100.0f); - DoFloatTest(convert("-12.01e-2"), convert("%E"), -0.1201f); - DoFloatTest(convert("+12.01e-2"), convert("%E"), 0.1201f); - DoFloatTest(convert("-12.01e+2"), convert("%E"), -1201.0f); - DoFloatTest(convert("+12.01e+2"), convert("%E"), 1201.0f); - DoFloatTest(convert("1234567890.0123456789f"), convert("%E"), 1234567936); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test16/test16.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test16/test16.cpp deleted file mode 100644 index aff2ce3e0e5016..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test16/test16.cpp +++ /dev/null @@ -1,36 +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: Tests swscanf with floats (compact notation, lowercase) -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - -PALTEST(c_runtime_swscanf_test16_paltest_swscanf_test16, "c_runtime/swscanf/test16/paltest_swscanf_test16") -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoFloatTest(convert("123.0"), convert("%g"), 123.0f); - DoFloatTest(convert("123.0"), convert("%2g"), 12.0f); - DoFloatTest(convert("10E1"), convert("%g"), 100.0f); - DoFloatTest(convert("-12.01e-2"), convert("%g"), -0.1201f); - DoFloatTest(convert("+12.01e-2"), convert("%g"), 0.1201f); - DoFloatTest(convert("-12.01e+2"), convert("%g"), -1201.0f); - DoFloatTest(convert("+12.01e+2"), convert("%g"), 1201.0f); - DoFloatTest(convert("1234567890.0123456789f"), convert("%g"), 1234567936); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test17/test17.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test17/test17.cpp deleted file mode 100644 index e50bf8a924f52a..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test17/test17.cpp +++ /dev/null @@ -1,36 +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 swscanf with floats (compact notation, uppercase) -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - -PALTEST(c_runtime_swscanf_test17_paltest_swscanf_test17, "c_runtime/swscanf/test17/paltest_swscanf_test17") -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoFloatTest(convert("123.0"), convert("%G"), 123.0f); - DoFloatTest(convert("123.0"), convert("%2G"), 12.0f); - DoFloatTest(convert("10E1"), convert("%G"), 100.0f); - DoFloatTest(convert("-12.01e-2"), convert("%G"), -0.1201f); - DoFloatTest(convert("+12.01e-2"), convert("%G"), 0.1201f); - DoFloatTest(convert("-12.01e+2"), convert("%G"), -1201.0f); - DoFloatTest(convert("+12.01e+2"), convert("%G"), 1201.0f); - DoFloatTest(convert("1234567890.0123456789f"), convert("%G"), 1234567936); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test2/test2.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test2/test2.cpp deleted file mode 100644 index 2661d0205da095..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test2/test2.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: test2.c -** -** Purpose: Test to see if swscanf handles whitespace correctly -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - -/* - * Tests out how it handles whitespace. Seems to accept anything that qualifies - * as isspace (space, tab, vertical tab, line feed, carriage return and form - * feed), even if it says it only wants spaces tabs and newlines. - */ - -PALTEST(c_runtime_swscanf_test2_paltest_swscanf_test2, "c_runtime/swscanf/test2/paltest_swscanf_test2") -{ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoStrTest(convert("foo bar"), convert("foo %S"), "bar"); - DoStrTest(convert("foo\tbar"), convert("foo %S"), "bar"); - DoStrTest(convert("foo\nbar"), convert("foo %S"), "bar"); - DoStrTest(convert("foo\rbar"), convert("foo %S"), "bar"); - DoStrTest(convert("foo\vbar"), convert("foo %S"), "bar"); - DoStrTest(convert("foo\fbar"), convert("foo %S"), "bar"); - DoStrTest(convert("foo \t\n\r\v\fbar"), convert("foo %S"), "bar"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test3/test3.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test3/test3.cpp deleted file mode 100644 index f1fc330fc2ecfb..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test3/test3.cpp +++ /dev/null @@ -1,35 +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 swscanf with bracketed set strings -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - - -PALTEST(c_runtime_swscanf_test3_paltest_swscanf_test3, "c_runtime/swscanf/test3/paltest_swscanf_test3") -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoWStrTest(convert("bar1"), convert("%[a-z]"), convert("bar")); - DoWStrTest(convert("bar1"), convert("%[z-a]"), convert("bar")); - DoWStrTest(convert("bar1"), convert("%[ab]"), convert("ba")); - DoWStrTest(convert("bar1"), convert("%[ar1b]"), convert("bar1")); - DoWStrTest(convert("bar1"), convert("%[^4]"), convert("bar1")); - DoWStrTest(convert("bar1"), convert("%[^4a]"), convert("b")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test4/test4.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test4/test4.cpp deleted file mode 100644 index be65035d4b7ee1..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test4/test4.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: test4.c -** -** Purpose:Tests swscanf with decimal numbers -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - - -PALTEST(c_runtime_swscanf_test4_paltest_swscanf_test4, "c_runtime/swscanf/test4/paltest_swscanf_test4") -{ - int n65535 = 65535; /* Walkaround compiler strictness */ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoNumTest(convert("1234d"), convert("%d"), 1234); - DoNumTest(convert("1234d"), convert("%2d"), 12); - DoNumTest(convert("-1"), convert("%d"), -1); - DoNumTest(convert("0x1234"), convert("%d"), 0); - DoNumTest(convert("012"), convert("%d"), 12); - DoShortNumTest(convert("-1"), convert("%hd"), n65535); - DoShortNumTest(convert("65536"), convert("%hd"), 0); - DoNumTest(convert("-1"), convert("%ld"), -1); - DoNumTest(convert("65536"), convert("%ld"), 65536); - DoNumTest(convert("-1"), convert("%Ld"), -1); - DoNumTest(convert("65536"), convert("%Ld"), 65536); - DoI64NumTest(convert("4294967296"), convert("%I64d"), I64(4294967296)); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test5/test5.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test5/test5.cpp deleted file mode 100644 index 396c862fef12e3..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test5/test5.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: test5.c -** -** Purpose: Tests swscanf with integer numbers -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - - -PALTEST(c_runtime_swscanf_test5_paltest_swscanf_test5, "c_runtime/swscanf/test5/paltest_swscanf_test5") -{ - int n65535 = 65535; /* Walkaround compiler strictness */ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoNumTest(convert("1234d"), convert("%i"), 1234); - DoNumTest(convert("1234d"), convert("%2i"), 12); - DoNumTest(convert("-1"), convert("%i"), -1); - DoNumTest(convert("0x1234"), convert("%i"), 0x1234); - DoNumTest(convert("012"), convert("%i"), 10); - DoShortNumTest(convert("-1"), convert("%hi"), n65535); - DoShortNumTest(convert("65536"), convert("%hi"), 0); - DoNumTest(convert("-1"), convert("%li"), -1); - DoNumTest(convert("65536"), convert("%li"), 65536); - DoNumTest(convert("-1"), convert("%Li"), -1); - DoNumTest(convert("65536"), convert("%Li"), 65536); - DoI64NumTest(convert("4294967296"), convert("%I64i"), I64(4294967296)); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test6/test6.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test6/test6.cpp deleted file mode 100644 index 8cf2063f01786b..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/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:Tests swscanf with octal numbers -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - - -PALTEST(c_runtime_swscanf_test6_paltest_swscanf_test6, "c_runtime/swscanf/test6/paltest_swscanf_test6") -{ - int n65535 = 65535; /* Walkaround compiler strictness */ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoNumTest(convert("1234d"), convert("%o"), 668); - DoNumTest(convert("1234d"), convert("%2o"), 10); - DoNumTest(convert("-1"), convert("%o"), -1); - DoNumTest(convert("0x1234"), convert("%o"), 0); - DoNumTest(convert("012"), convert("%o"), 10); - DoShortNumTest(convert("-1"), convert("%ho"), n65535); - DoShortNumTest(convert("200000"), convert("%ho"), 0); - DoNumTest(convert("-1"), convert("%lo"), -1); - DoNumTest(convert("200000"), convert("%lo"), 65536); - DoNumTest(convert("-1"), convert("%Lo"), -1); - DoNumTest(convert("200000"), convert("%Lo"), 65536); - DoI64NumTest(convert("40000000000"), convert("%I64o"), I64(4294967296)); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test7/test7.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test7/test7.cpp deleted file mode 100644 index 404eeecf13ca52..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/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 #6 for the swscanf function -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - - -PALTEST(c_runtime_swscanf_test7_paltest_swscanf_test7, "c_runtime/swscanf/test7/paltest_swscanf_test7") -{ - int n65535 = 65535; /* Walkaround compiler strictness */ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoNumTest(convert("1234d"), convert("%x"), 0x1234d); - DoNumTest(convert("1234d"), convert("%2x"), 0x12); - DoNumTest(convert("-1"), convert("%x"), -1); - DoNumTest(convert("0x1234"), convert("%x"), 0x1234); - DoNumTest(convert("012"), convert("%x"), 0x12); - DoShortNumTest(convert("-1"), convert("%hx"), n65535); - DoShortNumTest(convert("10000"), convert("%hx"), 0); - DoNumTest(convert("-1"), convert("%lx"), -1); - DoNumTest(convert("10000"), convert("%lx"), 65536); - DoNumTest(convert("-1"), convert("%Lx"), -1); - DoNumTest(convert("10000"), convert("%Lx"), 65536); - DoI64NumTest(convert("100000000"), convert("%I64x"), I64(4294967296)); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test8/test8.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test8/test8.cpp deleted file mode 100644 index 9c54283c09f9d1..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test8/test8.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: test8.c -** -** Purpose: Tests swscanf with unsigned numbers -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - - -PALTEST(c_runtime_swscanf_test8_paltest_swscanf_test8, "c_runtime/swscanf/test8/paltest_swscanf_test8") -{ - int n65535 = 65535; /* Walkaround compiler strictness */ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoNumTest(convert("1234d"), convert("%u"), 1234); - DoNumTest(convert("1234d"), convert("%2u"), 12); - DoNumTest(convert("-1"), convert("%u"), -1); - DoNumTest(convert("0x1234"), convert("%u"), 0); - DoNumTest(convert("012"), convert("%u"), 12); - DoShortNumTest(convert("-1"), convert("%hu"), n65535); - DoShortNumTest(convert("65536"), convert("%hu"), 0); - DoNumTest(convert("-1"), convert("%lu"), -1); - DoNumTest(convert("65536"), convert("%lu"), 65536); - DoNumTest(convert("-1"), convert("%Lu"), -1); - DoNumTest(convert("65536"), convert("%Lu"), 65536); - DoI64NumTest(convert("4294967296"), convert("%I64u"), I64(4294967296)); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test9/test9.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test9/test9.cpp deleted file mode 100644 index c6cab41fe2673c..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/test9/test9.cpp +++ /dev/null @@ -1,36 +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 swscanf with characters -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - -PALTEST(c_runtime_swscanf_test9_paltest_swscanf_test9, "c_runtime/swscanf/test9/paltest_swscanf_test9") -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoWCharTest(convert("1234"), convert("%c"), convert("1"), 1); - DoWCharTest(convert("1234"), convert("%c"), convert("1"), 1); - DoWCharTest(convert("abc"), convert("%2c"), convert("ab"), 2); - DoWCharTest(convert(" ab"), convert("%c"), convert(" "), 1); - DoCharTest(convert("ab"), convert("%hc"), "a", 1); - DoWCharTest(convert("ab"), convert("%lc"), convert("a"), 1); - DoWCharTest(convert("ab"), convert("%Lc"), convert("a"), 1); - DoWCharTest(convert("ab"), convert("%I64c"), convert("a"), 1); - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/wprintf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/wprintf/test1/test1.cpp deleted file mode 100644 index 75717a5e623605..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/wprintf/test1/test1.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: test1.c -** -** Purpose: Test #1 for the wprintf function. A single, basic, test -** case with no formatting. -** -** -**==========================================================================*/ - - - -#include -#include "../wprintf.h" - -PALTEST(c_runtime_wprintf_test1_paltest_wprintf_test1, "c_runtime/wprintf/test1/paltest_wprintf_test1") -{ - char checkstr[] = "hello world"; - WCHAR *wcheckstr; - int ret; - - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - wcheckstr = convert(checkstr); - - ret = wprintf(wcheckstr); - - if (ret != wcslen(wcheckstr)) - { - Fail("Expected wprintf to return %d, got %d.\n", - wcslen(wcheckstr), ret); - - } - - free(wcheckstr); - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/wprintf/test2/test2.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/wprintf/test2/test2.cpp deleted file mode 100644 index 9f9dd0e6dc4bde..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/wprintf/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 wprintf function. Tests the string specifier -** (%s). -** -** -**==========================================================================*/ - - -#include -#include "../wprintf.h" - - - -PALTEST(c_runtime_wprintf_test2_paltest_wprintf_test2, "c_runtime/wprintf/test2/paltest_wprintf_test2") -{ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoStrTest(u"foo %s", u"bar", u"foo bar"); - DoStrTest(u"foo %ws", u"bar", u"foo bar"); - DoStrTest(u"foo %ls", u"bar", u"foo bar"); - DoStrTest(u"foo %ws", u"bar", u"foo bar"); - DoStrTest(u"foo %Ls", u"bar", u"foo bar"); - DoStrTest(u"foo %I64s", u"bar", u"foo bar"); - DoStrTest(u"foo %5s", u"bar", u"foo bar"); - DoStrTest(u"foo %.2s", u"bar", u"foo ba"); - DoStrTest(u"foo %5.2s", u"bar", u"foo ba"); - DoStrTest(u"foo %-5s", u"bar", u"foo bar "); - DoStrTest(u"foo %05s", u"bar", u"foo 00bar"); - DoStrTest(u"foo %s", NULL, u"foo (null)"); - DoStrTest(u"foo %hs", NULL, u"foo (null)"); - DoStrTest(u"foo %ls", NULL, u"foo (null)"); - DoStrTest(u"foo %ws", NULL, u"foo (null)"); - DoStrTest(u"foo %Ls", NULL, u"foo (null)"); - DoStrTest(u"foo %I64s", NULL, u"foo (null)"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/wprintf/wprintf.h b/src/coreclr/pal/tests/palsuite/c_runtime/wprintf/wprintf.h deleted file mode 100644 index 46b040485cde31..00000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/wprintf/wprintf.h +++ /dev/null @@ -1,179 +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: wprintf.h -** -** Purpose: Contains common testing functions for wprintf -** -** -**==========================================================================*/ - -#ifndef __wprintf_H__ -#define __wprintf_H__ - -inline void DoStrTest_wprintf(const WCHAR *formatstr, const WCHAR *param, const WCHAR *checkstr) -{ - int ret; - - ret = wprintf(formatstr, param); - if (ret != wcslen(checkstr)) - { - Fail("DoStrTest:Expected wprintf to return %d, got %d.\n", - wcslen(checkstr), ret); - } -} -#define DoStrTest DoStrTest_wprintf - -inline void DoPointerTest_wprintf(const WCHAR *formatstr, void* param, WCHAR* paramstr, - const WCHAR *checkstr1) -{ - int ret; - - ret = wprintf(formatstr, param); - if (ret != wcslen(checkstr1)) - { - Fail("DoPointerTest:Expected wprintf to return %d, got %d.\n", - wcslen(checkstr1), ret); - } -} -#define DoPointerTest DoPointerTest_wprintf - -inline void DoCountTest_wprintf(const WCHAR *formatstr, int param, const WCHAR *checkstr) -{ - int ret; - int n = -1; - - ret = wprintf(formatstr, &n); - - if (n != param) - { - Fail("DoCountTest:Expected count parameter to resolve to %d, got %d\n", param, n); - } - - if (ret != wcslen(checkstr)) - { - Fail("DoCountTest:Expected wprintf to return %d, got %d.\n", - wcslen(checkstr), ret); - } -} -#define DoCountTest DoCountTest_wprintf - -inline void DoShortCountTest_wprintf(const WCHAR *formatstr, int param, const WCHAR *checkstr) -{ - int ret; - short int n = -1; - - ret = wprintf(formatstr, &n); - - if (n != param) - { - Fail("DoShortCountTest:Expected count parameter to resolve to %d, got %d\n", param, n); - } - - if (ret != wcslen(checkstr)) - { - Fail("DoShortCountTest:Expected wprintf to return %d, got %d.\n", - wcslen(checkstr), ret); - } -} -#define DoShortCountTest DoShortCountTest_wprintf - -inline void DoCharTest_wprintf(const WCHAR *formatstr, WCHAR param, const WCHAR *checkstr) -{ - int ret; - - ret = wprintf(formatstr, param); - if (ret != wcslen(checkstr)) - { - Fail("DoCharTest:Expected wprintf to return %d, got %d.\n", - wcslen(checkstr), ret); - } -} -#define DoCharTest DoCharTest_wprintf - -inline void DoWCharTest_wprintf(const WCHAR *formatstr, WCHAR param, const WCHAR *checkstr) -{ - int ret; - - ret = wprintf(formatstr, param); - if (ret != wcslen(checkstr)) - { - Fail("DoWCharTest:Expected wprintf to return %d, got %d.\n", - wcslen(checkstr), ret); - } -} -#define DoWCharTest DoWCharTest_wprintf - -inline void DoNumTest_wprintf(const WCHAR *formatstr, int param, const WCHAR *checkstr) -{ - int ret; - - ret = wprintf(formatstr, param); - if (ret != wcslen(checkstr)) - { - Fail("DoNumTest:Expected wprintf to return %d, got %d.\n", - wcslen(checkstr), ret); - } -} -#define DoNumTest DoNumTest_wprintf - -inline void DoI64Test_wprintf(const WCHAR *formatstr, INT64 param, const WCHAR *valuestr, - const WCHAR *checkstr1) -{ - int ret; - - ret = wprintf(formatstr, param); - if (ret != wcslen(checkstr1)) - { - Fail("DoI64Test:Expected wprintf to return %d, got %d.\n", - wcslen(checkstr1), ret); - } -} -#define DoI64Test DoI64Test_wprintf - -inline void DoDoubleTest_wprintf(const WCHAR *formatstr, double param, - const WCHAR *checkstr1, const WCHAR *checkstr2) -{ - int ret; - - ret = wprintf(formatstr, param); - if (ret != wcslen(checkstr1) && ret != wcslen(checkstr2)) - { - Fail("DoDoubleTest:Expected wprintf to return %d or %d, got %d.\n", - wcslen(checkstr1), wcslen(checkstr2), ret); - } -} -#define DoDoubleTest DoDoubleTest_wprintf - -inline void DoArgumentPrecTest_wprintf(const WCHAR *formatstr, int precision, void *param, - WCHAR *paramstr, const WCHAR *checkstr1, const WCHAR *checkstr2) -{ - int ret; - - ret = wprintf(formatstr, precision, param); - if (ret != wcslen(checkstr1) && ret != wcslen(checkstr2)) - { - Fail("DoArgumentPrecTest:Expected wprintf to return %d or %d, got %d.\n", - wcslen(checkstr1), wcslen(checkstr2), ret); - } -} -#define DoArgumentPrecTest DoArgumentPrecTest_wprintf - -inline void DoArgumentPrecDoubleTest_wprintf(const WCHAR *formatstr, int precision, double param, - const WCHAR *checkstr1, const WCHAR *checkstr2) -{ - int ret; - - ret = wprintf(formatstr, precision, param); - if (ret != wcslen(checkstr1) && ret != wcslen(checkstr2)) - { - Fail("DoArgumentPrecDoubleTest:Expected wprintf to return %d or %d, got %d.\n", - wcslen(checkstr1), wcslen(checkstr2), ret); - } -} -#define DoArgumentPrecDoubleTest DoArgumentPrecDoubleTest_wprintf - -#endif - diff --git a/src/coreclr/pal/tests/palsuite/compilableTests.txt b/src/coreclr/pal/tests/palsuite/compilableTests.txt index 1cd7c5b964395b..63ce8565292879 100644 --- a/src/coreclr/pal/tests/palsuite/compilableTests.txt +++ b/src/coreclr/pal/tests/palsuite/compilableTests.txt @@ -81,25 +81,6 @@ c_runtime/fread/test3/paltest_fread_test3 c_runtime/free/test1/paltest_free_test1 c_runtime/fseek/test1/paltest_fseek_test1 c_runtime/ftell/test1/paltest_ftell_test1 -c_runtime/fwprintf/test1/paltest_fwprintf_test1 -c_runtime/fwprintf/test10/paltest_fwprintf_test10 -c_runtime/fwprintf/test11/paltest_fwprintf_test11 -c_runtime/fwprintf/test12/paltest_fwprintf_test12 -c_runtime/fwprintf/test13/paltest_fwprintf_test13 -c_runtime/fwprintf/test14/paltest_fwprintf_test14 -c_runtime/fwprintf/test15/paltest_fwprintf_test15 -c_runtime/fwprintf/test16/paltest_fwprintf_test16 -c_runtime/fwprintf/test17/paltest_fwprintf_test17 -c_runtime/fwprintf/test18/paltest_fwprintf_test18 -c_runtime/fwprintf/test19/paltest_fwprintf_test19 -c_runtime/fwprintf/test2/paltest_fwprintf_test2 -c_runtime/fwprintf/test3/paltest_fwprintf_test3 -c_runtime/fwprintf/test4/paltest_fwprintf_test4 -c_runtime/fwprintf/test5/paltest_fwprintf_test5 -c_runtime/fwprintf/test6/paltest_fwprintf_test6 -c_runtime/fwprintf/test7/paltest_fwprintf_test7 -c_runtime/fwprintf/test8/paltest_fwprintf_test8 -c_runtime/fwprintf/test9/paltest_fwprintf_test9 c_runtime/fwrite/test1/paltest_fwrite_test1 c_runtime/getenv/test1/paltest_getenv_test1 c_runtime/getenv/test2/paltest_getenv_test2 @@ -233,23 +214,6 @@ c_runtime/swprintf/test6/paltest_swprintf_test6 c_runtime/swprintf/test7/paltest_swprintf_test7 c_runtime/swprintf/test8/paltest_swprintf_test8 c_runtime/swprintf/test9/paltest_swprintf_test9 -c_runtime/swscanf/test1/paltest_swscanf_test1 -c_runtime/swscanf/test10/paltest_swscanf_test10 -c_runtime/swscanf/test11/paltest_swscanf_test11 -c_runtime/swscanf/test12/paltest_swscanf_test12 -c_runtime/swscanf/test13/paltest_swscanf_test13 -c_runtime/swscanf/test14/paltest_swscanf_test14 -c_runtime/swscanf/test15/paltest_swscanf_test15 -c_runtime/swscanf/test16/paltest_swscanf_test16 -c_runtime/swscanf/test17/paltest_swscanf_test17 -c_runtime/swscanf/test2/paltest_swscanf_test2 -c_runtime/swscanf/test3/paltest_swscanf_test3 -c_runtime/swscanf/test4/paltest_swscanf_test4 -c_runtime/swscanf/test5/paltest_swscanf_test5 -c_runtime/swscanf/test6/paltest_swscanf_test6 -c_runtime/swscanf/test7/paltest_swscanf_test7 -c_runtime/swscanf/test8/paltest_swscanf_test8 -c_runtime/swscanf/test9/paltest_swscanf_test9 c_runtime/tan/test1/paltest_tan_test1 c_runtime/tanf/test1/paltest_tanf_test1 c_runtime/tanh/test1/paltest_tanh_test1 @@ -350,8 +314,6 @@ c_runtime/wcstoul/test3/paltest_wcstoul_test3 c_runtime/wcstoul/test4/paltest_wcstoul_test4 c_runtime/wcstoul/test5/paltest_wcstoul_test5 c_runtime/wcstoul/test6/paltest_wcstoul_test6 -c_runtime/wprintf/test1/paltest_wprintf_test1 -c_runtime/wprintf/test2/paltest_wprintf_test2 c_runtime/_alloca/test1/paltest_alloca_test1 c_runtime/_fdopen/test1/paltest_fdopen_test1 c_runtime/_finite/test1/paltest_finite_test1 diff --git a/src/coreclr/pal/tests/palsuite/paltestlist.txt b/src/coreclr/pal/tests/palsuite/paltestlist.txt index 607f8c7d686417..3a653a8c129b92 100644 --- a/src/coreclr/pal/tests/palsuite/paltestlist.txt +++ b/src/coreclr/pal/tests/palsuite/paltestlist.txt @@ -73,22 +73,6 @@ 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 -c_runtime/fwprintf/test1/paltest_fwprintf_test1 -c_runtime/fwprintf/test10/paltest_fwprintf_test10 -c_runtime/fwprintf/test11/paltest_fwprintf_test11 -c_runtime/fwprintf/test12/paltest_fwprintf_test12 -c_runtime/fwprintf/test13/paltest_fwprintf_test13 -c_runtime/fwprintf/test14/paltest_fwprintf_test14 -c_runtime/fwprintf/test15/paltest_fwprintf_test15 -c_runtime/fwprintf/test16/paltest_fwprintf_test16 -c_runtime/fwprintf/test17/paltest_fwprintf_test17 -c_runtime/fwprintf/test18/paltest_fwprintf_test18 -c_runtime/fwprintf/test3/paltest_fwprintf_test3 -c_runtime/fwprintf/test4/paltest_fwprintf_test4 -c_runtime/fwprintf/test5/paltest_fwprintf_test5 -c_runtime/fwprintf/test6/paltest_fwprintf_test6 -c_runtime/fwprintf/test8/paltest_fwprintf_test8 -c_runtime/fwprintf/test9/paltest_fwprintf_test9 c_runtime/fwrite/test1/paltest_fwrite_test1 c_runtime/getenv/test1/paltest_getenv_test1 c_runtime/getenv/test2/paltest_getenv_test2 @@ -220,23 +204,6 @@ c_runtime/swprintf/test4/paltest_swprintf_test4 c_runtime/swprintf/test6/paltest_swprintf_test6 c_runtime/swprintf/test8/paltest_swprintf_test8 c_runtime/swprintf/test9/paltest_swprintf_test9 -c_runtime/swscanf/test1/paltest_swscanf_test1 -c_runtime/swscanf/test10/paltest_swscanf_test10 -c_runtime/swscanf/test11/paltest_swscanf_test11 -c_runtime/swscanf/test12/paltest_swscanf_test12 -c_runtime/swscanf/test13/paltest_swscanf_test13 -c_runtime/swscanf/test14/paltest_swscanf_test14 -c_runtime/swscanf/test15/paltest_swscanf_test15 -c_runtime/swscanf/test16/paltest_swscanf_test16 -c_runtime/swscanf/test17/paltest_swscanf_test17 -c_runtime/swscanf/test2/paltest_swscanf_test2 -c_runtime/swscanf/test3/paltest_swscanf_test3 -c_runtime/swscanf/test4/paltest_swscanf_test4 -c_runtime/swscanf/test5/paltest_swscanf_test5 -c_runtime/swscanf/test6/paltest_swscanf_test6 -c_runtime/swscanf/test7/paltest_swscanf_test7 -c_runtime/swscanf/test8/paltest_swscanf_test8 -c_runtime/swscanf/test9/paltest_swscanf_test9 c_runtime/tan/test1/paltest_tan_test1 c_runtime/tanf/test1/paltest_tanf_test1 c_runtime/tanh/test1/paltest_tanh_test1 @@ -335,7 +302,6 @@ c_runtime/wcstoul/test3/paltest_wcstoul_test3 c_runtime/wcstoul/test4/paltest_wcstoul_test4 c_runtime/wcstoul/test5/paltest_wcstoul_test5 c_runtime/wcstoul/test6/paltest_wcstoul_test6 -c_runtime/wprintf/test1/paltest_wprintf_test1 c_runtime/_alloca/test1/paltest_alloca_test1 c_runtime/_fdopen/test1/paltest_fdopen_test1 c_runtime/_finite/test1/paltest_finite_test1 diff --git a/src/coreclr/pal/tests/palsuite/paltestlist_to_be_reviewed.txt b/src/coreclr/pal/tests/palsuite/paltestlist_to_be_reviewed.txt index cd828cf71a226e..b488ac96134f90 100644 --- a/src/coreclr/pal/tests/palsuite/paltestlist_to_be_reviewed.txt +++ b/src/coreclr/pal/tests/palsuite/paltestlist_to_be_reviewed.txt @@ -9,16 +9,12 @@ c_runtime/fread/test1/paltest_fread_test1 c_runtime/fread/test2/paltest_fread_test2 c_runtime/fread/test3/paltest_fread_test3 c_runtime/ftell/test1/paltest_ftell_test1 -c_runtime/fwprintf/test19/paltest_fwprintf_test19 -c_runtime/fwprintf/test2/paltest_fwprintf_test2 -c_runtime/fwprintf/test7/paltest_fwprintf_test7 c_runtime/iswprint/test1/paltest_iswprint_test1 c_runtime/swprintf/test2/paltest_swprintf_test2 c_runtime/swprintf/test7/paltest_swprintf_test7 c_runtime/vprintf/test1/paltest_vprintf_test1 c_runtime/vswprintf/test2/paltest_vswprintf_test2 c_runtime/vswprintf/test7/paltest_vswprintf_test7 -c_runtime/wprintf/test2/paltest_wprintf_test2 c_runtime/_gcvt/test1/paltest_gcvt_test1 c_runtime/_gcvt/test2/paltest_gcvt_test2 c_runtime/_getw/test1/paltest_getw_test1 diff --git a/src/coreclr/vm/hosting.cpp b/src/coreclr/vm/hosting.cpp index 7eefe12c4674d9..3482781620be80 100644 --- a/src/coreclr/vm/hosting.cpp +++ b/src/coreclr/vm/hosting.cpp @@ -383,19 +383,21 @@ DEBUG_NOINLINE void ClrLeaveCriticalSection(CRITSEC_COOKIE cookie) #ifndef DACCESS_COMPILE -NOINLINE static void FailFastOnApiErrorWithHandle(const WCHAR *apiName, HANDLE handle) +NOINLINE static void FailFastOnApiErrorWithHandle(const CHAR *apiName, HANDLE handle) { WRAPPER_NO_CONTRACT; DWORD errorCode = GetLastError(); - WCHAR message[128] = W("\0"); - swprintf_s( - message, - sizeof(message) / sizeof(message[0]), - W("%s failed with error %u. Handle: 0x%Ix"), + CHAR messageUtf8[128] = "\0"; + sprintf_s( + messageUtf8, + ARRAY_SIZE(messageUtf8), + "%s failed with error %u. Handle: 0x%p", apiName, errorCode, - (SIZE_T)handle); + (void*)handle); + + MAKE_WIDEPTR_FROMUTF8_NOTHROW(message, messageUtf8); EEPOLICY_HANDLE_FATAL_ERROR_WITH_MESSAGE(COR_E_EXECUTIONENGINE, message); } @@ -407,7 +409,7 @@ DWORD ClrSuspendThread(HANDLE hThread) DWORD result = SuspendThread(hThread); if (result == (DWORD)-1) { - FailFastOnApiErrorWithHandle(W("SuspendThread"), hThread); + FailFastOnApiErrorWithHandle("SuspendThread", hThread); } return result; @@ -421,7 +423,7 @@ DWORD ClrResumeThread(HANDLE hThread) DWORD result = ResumeThread(hThread); if (result == (DWORD)-1) { - FailFastOnApiErrorWithHandle(W("ResumeThread"), hThread); + FailFastOnApiErrorWithHandle("ResumeThread", hThread); } return result;