From f5cbe4c9cab2873b60cd3c991732a250d2e164a2 Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Fri, 23 Dec 2016 14:41:28 +0100 Subject: Remove all usage of vsnprintf (#8709) This change removes all usages of vsnprintf and modifies runtime to not to use vsnprintf or _vsnprintf I've also fixed two issues in PAL TRACE function string format parameters that caused crashes when I was trying to run all PAL tests with PAL tracing enabled. --- src/ToolBox/SOS/Strike/strike.h | 4 - src/ToolBox/SOS/Strike/xplat/dbgeng.h | 2 +- src/dlls/mscordac/mscordac_unixexports.src | 4 +- src/gc/env/gcenv.base.h | 2 +- src/gc/gc.cpp | 2 +- src/md/compiler/regmeta.cpp | 5 +- src/pal/inc/pal.h | 6 - src/pal/inc/rt/palrt.h | 30 +- src/pal/inc/rt/safecrt.h | 4 - src/pal/src/cruntime/printf.cpp | 82 --- src/pal/src/cruntime/printfcpp.cpp | 722 +-------------------- src/pal/src/cruntime/silent_printf.cpp | 280 -------- src/pal/src/cruntime/string.cpp | 2 +- src/pal/src/include/pal/palinternal.h | 5 - src/pal/src/include/pal/printfcpp.hpp | 55 -- src/pal/src/misc/dbgmsg.cpp | 10 +- src/pal/src/misc/fmtmessage.cpp | 3 +- src/pal/tests/palsuite/c_runtime/CMakeLists.txt | 2 +- .../palsuite/c_runtime/_vsnprintf/CMakeLists.txt | 22 - .../palsuite/c_runtime/_vsnprintf/_vsnprintf.h | 124 ---- .../c_runtime/_vsnprintf/test1/CMakeLists.txt | 19 - .../palsuite/c_runtime/_vsnprintf/test1/test1.cpp | 55 -- .../c_runtime/_vsnprintf/test1/testinfo.dat | 13 - .../c_runtime/_vsnprintf/test10/CMakeLists.txt | 19 - .../c_runtime/_vsnprintf/test10/test10.cpp | 50 -- .../c_runtime/_vsnprintf/test10/testinfo.dat | 14 - .../c_runtime/_vsnprintf/test11/CMakeLists.txt | 19 - .../c_runtime/_vsnprintf/test11/test11.cpp | 50 -- .../c_runtime/_vsnprintf/test11/testinfo.dat | 14 - .../c_runtime/_vsnprintf/test12/CMakeLists.txt | 19 - .../c_runtime/_vsnprintf/test12/test12.cpp | 52 -- .../c_runtime/_vsnprintf/test12/testinfo.dat | 14 - .../c_runtime/_vsnprintf/test13/CMakeLists.txt | 19 - .../c_runtime/_vsnprintf/test13/test13.cpp | 52 -- .../c_runtime/_vsnprintf/test13/testinfo.dat | 14 - .../c_runtime/_vsnprintf/test14/CMakeLists.txt | 19 - .../c_runtime/_vsnprintf/test14/test14.cpp | 50 -- .../c_runtime/_vsnprintf/test14/testinfo.dat | 14 - .../c_runtime/_vsnprintf/test15/CMakeLists.txt | 19 - .../c_runtime/_vsnprintf/test15/test15.cpp | 49 -- .../c_runtime/_vsnprintf/test15/testinfo.dat | 14 - .../c_runtime/_vsnprintf/test16/CMakeLists.txt | 19 - .../c_runtime/_vsnprintf/test16/test16.cpp | 49 -- .../c_runtime/_vsnprintf/test16/testinfo.dat | 14 - .../c_runtime/_vsnprintf/test17/CMakeLists.txt | 19 - .../c_runtime/_vsnprintf/test17/test17.cpp | 50 -- .../c_runtime/_vsnprintf/test17/testinfo.dat | 14 - .../c_runtime/_vsnprintf/test18/CMakeLists.txt | 19 - .../c_runtime/_vsnprintf/test18/test18.cpp | 50 -- .../c_runtime/_vsnprintf/test18/testinfo.dat | 14 - .../c_runtime/_vsnprintf/test19/CMakeLists.txt | 19 - .../c_runtime/_vsnprintf/test19/test19.cpp | 103 --- .../c_runtime/_vsnprintf/test19/testinfo.dat | 14 - .../c_runtime/_vsnprintf/test2/CMakeLists.txt | 19 - .../palsuite/c_runtime/_vsnprintf/test2/test2.cpp | 44 -- .../c_runtime/_vsnprintf/test2/testinfo.dat | 14 - .../c_runtime/_vsnprintf/test3/CMakeLists.txt | 19 - .../palsuite/c_runtime/_vsnprintf/test3/test3.cpp | 43 -- .../c_runtime/_vsnprintf/test3/testinfo.dat | 14 - .../c_runtime/_vsnprintf/test4/CMakeLists.txt | 19 - .../palsuite/c_runtime/_vsnprintf/test4/test4.cpp | 98 --- .../c_runtime/_vsnprintf/test4/testinfo.dat | 14 - .../c_runtime/_vsnprintf/test5/CMakeLists.txt | 19 - .../palsuite/c_runtime/_vsnprintf/test5/test5.cpp | 78 --- .../c_runtime/_vsnprintf/test5/testinfo.dat | 14 - .../c_runtime/_vsnprintf/test6/CMakeLists.txt | 19 - .../palsuite/c_runtime/_vsnprintf/test6/test6.cpp | 44 -- .../c_runtime/_vsnprintf/test6/testinfo.dat | 14 - .../c_runtime/_vsnprintf/test7/CMakeLists.txt | 19 - .../palsuite/c_runtime/_vsnprintf/test7/test7.cpp | 44 -- .../c_runtime/_vsnprintf/test7/testinfo.dat | 14 - .../c_runtime/_vsnprintf/test8/CMakeLists.txt | 19 - .../palsuite/c_runtime/_vsnprintf/test8/test8.cpp | 52 -- .../c_runtime/_vsnprintf/test8/testinfo.dat | 14 - .../c_runtime/_vsnprintf/test9/CMakeLists.txt | 19 - .../palsuite/c_runtime/_vsnprintf/test9/test9.cpp | 51 -- .../c_runtime/_vsnprintf/test9/testinfo.dat | 14 - .../palsuite/c_runtime/_vsnprintf_s/CMakeLists.txt | 21 + .../palsuite/c_runtime/_vsnprintf_s/_vsnprintf_s.h | 124 ++++ .../c_runtime/_vsnprintf_s/test1/CMakeLists.txt | 19 + .../c_runtime/_vsnprintf_s/test1/test1.cpp | 55 ++ .../c_runtime/_vsnprintf_s/test1/testinfo.dat | 13 + .../c_runtime/_vsnprintf_s/test10/CMakeLists.txt | 19 + .../c_runtime/_vsnprintf_s/test10/test10.cpp | 50 ++ .../c_runtime/_vsnprintf_s/test10/testinfo.dat | 14 + .../c_runtime/_vsnprintf_s/test11/CMakeLists.txt | 19 + .../c_runtime/_vsnprintf_s/test11/test11.cpp | 50 ++ .../c_runtime/_vsnprintf_s/test11/testinfo.dat | 14 + .../c_runtime/_vsnprintf_s/test12/CMakeLists.txt | 19 + .../c_runtime/_vsnprintf_s/test12/test12.cpp | 52 ++ .../c_runtime/_vsnprintf_s/test12/testinfo.dat | 14 + .../c_runtime/_vsnprintf_s/test13/CMakeLists.txt | 19 + .../c_runtime/_vsnprintf_s/test13/test13.cpp | 52 ++ .../c_runtime/_vsnprintf_s/test13/testinfo.dat | 14 + .../c_runtime/_vsnprintf_s/test14/CMakeLists.txt | 19 + .../c_runtime/_vsnprintf_s/test14/test14.cpp | 50 ++ .../c_runtime/_vsnprintf_s/test14/testinfo.dat | 14 + .../c_runtime/_vsnprintf_s/test15/CMakeLists.txt | 19 + .../c_runtime/_vsnprintf_s/test15/test15.cpp | 49 ++ .../c_runtime/_vsnprintf_s/test15/testinfo.dat | 14 + .../c_runtime/_vsnprintf_s/test16/CMakeLists.txt | 19 + .../c_runtime/_vsnprintf_s/test16/test16.cpp | 49 ++ .../c_runtime/_vsnprintf_s/test16/testinfo.dat | 14 + .../c_runtime/_vsnprintf_s/test17/CMakeLists.txt | 19 + .../c_runtime/_vsnprintf_s/test17/test17.cpp | 50 ++ .../c_runtime/_vsnprintf_s/test17/testinfo.dat | 14 + .../c_runtime/_vsnprintf_s/test18/CMakeLists.txt | 19 + .../c_runtime/_vsnprintf_s/test18/test18.cpp | 50 ++ .../c_runtime/_vsnprintf_s/test18/testinfo.dat | 14 + .../c_runtime/_vsnprintf_s/test19/CMakeLists.txt | 19 + .../c_runtime/_vsnprintf_s/test19/test19.cpp | 103 +++ .../c_runtime/_vsnprintf_s/test19/testinfo.dat | 14 + .../c_runtime/_vsnprintf_s/test2/CMakeLists.txt | 19 + .../c_runtime/_vsnprintf_s/test2/test2.cpp | 44 ++ .../c_runtime/_vsnprintf_s/test2/testinfo.dat | 14 + .../c_runtime/_vsnprintf_s/test3/CMakeLists.txt | 19 + .../c_runtime/_vsnprintf_s/test3/test3.cpp | 43 ++ .../c_runtime/_vsnprintf_s/test3/testinfo.dat | 14 + .../c_runtime/_vsnprintf_s/test4/CMakeLists.txt | 19 + .../c_runtime/_vsnprintf_s/test4/test4.cpp | 98 +++ .../c_runtime/_vsnprintf_s/test4/testinfo.dat | 14 + .../c_runtime/_vsnprintf_s/test6/CMakeLists.txt | 19 + .../c_runtime/_vsnprintf_s/test6/test6.cpp | 44 ++ .../c_runtime/_vsnprintf_s/test6/testinfo.dat | 14 + .../c_runtime/_vsnprintf_s/test7/CMakeLists.txt | 19 + .../c_runtime/_vsnprintf_s/test7/test7.cpp | 44 ++ .../c_runtime/_vsnprintf_s/test7/testinfo.dat | 14 + .../c_runtime/_vsnprintf_s/test8/CMakeLists.txt | 19 + .../c_runtime/_vsnprintf_s/test8/test8.cpp | 52 ++ .../c_runtime/_vsnprintf_s/test8/testinfo.dat | 14 + .../c_runtime/_vsnprintf_s/test9/CMakeLists.txt | 19 + .../c_runtime/_vsnprintf_s/test9/test9.cpp | 51 ++ .../c_runtime/_vsnprintf_s/test9/testinfo.dat | 14 + .../palsuite/c_runtime/swprintf/CMakeLists.txt | 1 - .../tests/palsuite/c_runtime/swprintf/swprintf.h | 60 +- .../palsuite/c_runtime/swprintf/test1/test1.cpp | 2 +- .../palsuite/c_runtime/swprintf/test19/test19.cpp | 8 - .../c_runtime/swprintf/test5/CMakeLists.txt | 19 - .../palsuite/c_runtime/swprintf/test5/test5.cpp | 67 -- .../palsuite/c_runtime/swprintf/test5/testinfo.dat | 12 - .../palsuite/c_runtime/vsprintf/CMakeLists.txt | 1 - .../palsuite/c_runtime/vsprintf/test1/test1.cpp | 6 +- .../c_runtime/vsprintf/test5/CMakeLists.txt | 19 - .../palsuite/c_runtime/vsprintf/test5/test5.cpp | 43 -- .../palsuite/c_runtime/vsprintf/test5/testinfo.dat | 14 - .../tests/palsuite/c_runtime/vsprintf/vsprintf.h | 30 +- .../palsuite/c_runtime/vswprintf/CMakeLists.txt | 1 - .../palsuite/c_runtime/vswprintf/test1/test1.cpp | 2 +- .../palsuite/c_runtime/vswprintf/test19/test19.cpp | 4 +- .../palsuite/c_runtime/vswprintf/test4/test4.cpp | 4 +- .../c_runtime/vswprintf/test5/CMakeLists.txt | 19 - .../palsuite/c_runtime/vswprintf/test5/test5.cpp | 79 --- .../c_runtime/vswprintf/test5/testinfo.dat | 14 - .../tests/palsuite/c_runtime/vswprintf/vswprintf.h | 18 +- .../GetTempFileNameW/test1/GetTempFileNameW.cpp | 2 +- src/pal/tests/palsuite/paltestlist.txt | 40 +- src/pal/tests/palsuite/palverify.dat | 37 +- src/palrt/coguid.cpp | 2 +- src/utilcode/log.cpp | 2 +- src/utilcode/sstring.cpp | 2 +- src/vm/multicorejit.cpp | 2 +- 161 files changed, 1831 insertions(+), 3459 deletions(-) delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/CMakeLists.txt delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/_vsnprintf.h delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test1/CMakeLists.txt delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test1/test1.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test1/testinfo.dat delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test10/CMakeLists.txt delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test10/test10.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test10/testinfo.dat delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test11/CMakeLists.txt delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test11/test11.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test11/testinfo.dat delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test12/CMakeLists.txt delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test12/test12.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test12/testinfo.dat delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test13/CMakeLists.txt delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test13/test13.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test13/testinfo.dat delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test14/CMakeLists.txt delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test14/test14.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test14/testinfo.dat delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test15/CMakeLists.txt delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test15/test15.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test15/testinfo.dat delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test16/CMakeLists.txt delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test16/test16.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test16/testinfo.dat delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test17/CMakeLists.txt delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test17/test17.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test17/testinfo.dat delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test18/CMakeLists.txt delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test18/test18.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test18/testinfo.dat delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test19/CMakeLists.txt delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test19/test19.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test19/testinfo.dat delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test2/CMakeLists.txt delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test2/test2.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test2/testinfo.dat delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test3/CMakeLists.txt delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test3/test3.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test3/testinfo.dat delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test4/CMakeLists.txt delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test4/test4.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test4/testinfo.dat delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/CMakeLists.txt delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/test5.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/testinfo.dat delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test6/CMakeLists.txt delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test6/test6.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test6/testinfo.dat delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test7/CMakeLists.txt delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test7/test7.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test7/testinfo.dat delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test8/CMakeLists.txt delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test8/test8.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test8/testinfo.dat delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test9/CMakeLists.txt delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test9/test9.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf/test9/testinfo.dat create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/CMakeLists.txt create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/_vsnprintf_s.h create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/CMakeLists.txt create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/test1.cpp create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/testinfo.dat create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/CMakeLists.txt create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/test10.cpp create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/testinfo.dat create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/CMakeLists.txt create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/test11.cpp create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/testinfo.dat create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/CMakeLists.txt create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/test12.cpp create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/testinfo.dat create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/CMakeLists.txt create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/test13.cpp create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/testinfo.dat create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/CMakeLists.txt create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/test14.cpp create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/testinfo.dat create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/CMakeLists.txt create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/test15.cpp create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/testinfo.dat create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/CMakeLists.txt create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/test16.cpp create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/testinfo.dat create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/CMakeLists.txt create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/test17.cpp create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/testinfo.dat create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/CMakeLists.txt create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/test18.cpp create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/testinfo.dat create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/CMakeLists.txt create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/test19.cpp create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/testinfo.dat create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/CMakeLists.txt create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/test2.cpp create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/testinfo.dat create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/CMakeLists.txt create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/test3.cpp create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/testinfo.dat create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/CMakeLists.txt create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/test4.cpp create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/testinfo.dat create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/CMakeLists.txt create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/test6.cpp create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/testinfo.dat create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/CMakeLists.txt create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/test7.cpp create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/testinfo.dat create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/CMakeLists.txt create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/test8.cpp create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/testinfo.dat create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/CMakeLists.txt create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/test9.cpp create mode 100644 src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/testinfo.dat delete mode 100644 src/pal/tests/palsuite/c_runtime/swprintf/test5/CMakeLists.txt delete mode 100644 src/pal/tests/palsuite/c_runtime/swprintf/test5/test5.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/swprintf/test5/testinfo.dat delete mode 100644 src/pal/tests/palsuite/c_runtime/vsprintf/test5/CMakeLists.txt delete mode 100644 src/pal/tests/palsuite/c_runtime/vsprintf/test5/test5.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/vsprintf/test5/testinfo.dat delete mode 100644 src/pal/tests/palsuite/c_runtime/vswprintf/test5/CMakeLists.txt delete mode 100644 src/pal/tests/palsuite/c_runtime/vswprintf/test5/test5.cpp delete mode 100644 src/pal/tests/palsuite/c_runtime/vswprintf/test5/testinfo.dat diff --git a/src/ToolBox/SOS/Strike/strike.h b/src/ToolBox/SOS/Strike/strike.h index e070898ff5..dfc0dcfea4 100644 --- a/src/ToolBox/SOS/Strike/strike.h +++ b/src/ToolBox/SOS/Strike/strike.h @@ -44,10 +44,6 @@ #define _wcsstr wcsstr #endif // !PAL_STDCPP_COMPAT -#ifdef PLATFORM_UNIX -#define _vsnprintf vsnprintf -#endif - #define ___in _SAL1_Source_(__in, (), _In_) #define ___out _SAL1_Source_(__out, (), _Out_) diff --git a/src/ToolBox/SOS/Strike/xplat/dbgeng.h b/src/ToolBox/SOS/Strike/xplat/dbgeng.h index b4562271a6..5dcf9572bb 100644 --- a/src/ToolBox/SOS/Strike/xplat/dbgeng.h +++ b/src/ToolBox/SOS/Strike/xplat/dbgeng.h @@ -84,7 +84,7 @@ public: va_list args) { char str[4096]; - int length = PAL__vsnprintf(str, sizeof(str), format, args); + int length = _vsnprintf_s(str, sizeof(str), _TRUNCATE, format, args); if (length > 0) { return Output(mask, "%s", str); diff --git a/src/dlls/mscordac/mscordac_unixexports.src b/src/dlls/mscordac/mscordac_unixexports.src index 7d60c1ed4b..ab73c4fcb8 100644 --- a/src/dlls/mscordac/mscordac_unixexports.src +++ b/src/dlls/mscordac/mscordac_unixexports.src @@ -17,7 +17,6 @@ PAL_fflush PAL__flushall PAL_free PAL_fwprintf -PAL_swprintf PAL_GetPALDirectoryW PAL_GetResourceString PAL_get_stdout @@ -35,7 +34,6 @@ PAL_printf PAL_qsort PAL_Reenter PAL_fprintf -PAL__vsnprintf PAL__wcstoui64 PAL_wcstoul PAL_iswprint @@ -52,6 +50,8 @@ _wcsicmp _stricmp sprintf_s swprintf_s +vsprintf_s +_snprintf_s _snwprintf_s _vsnprintf_s _vsnwprintf_s diff --git a/src/gc/env/gcenv.base.h b/src/gc/env/gcenv.base.h index 94f73762f8..0a0de73ee1 100644 --- a/src/gc/env/gcenv.base.h +++ b/src/gc/env/gcenv.base.h @@ -96,7 +96,7 @@ inline HRESULT HRESULT_FROM_WIN32(unsigned long x) #define UNREFERENCED_PARAMETER(P) (void)(P) #ifdef PLATFORM_UNIX -#define _vsnprintf vsnprintf +#define _vsnprintf_s(string, sizeInBytes, count, format, args) vsnprintf(string, sizeInBytes, format, args) #define sprintf_s snprintf #define swprintf_s swprintf #endif diff --git a/src/gc/gc.cpp b/src/gc/gc.cpp index 6187938ff8..586da23527 100644 --- a/src/gc/gc.cpp +++ b/src/gc/gc.cpp @@ -389,7 +389,7 @@ void log_va_msg(const char *fmt, va_list args) int pid_len = sprintf_s (&pBuffer[buffer_start], BUFFERSIZE - buffer_start, "[%5d]", (uint32_t)GCToOSInterface::GetCurrentThreadIdForLogging()); buffer_start += pid_len; memset(&pBuffer[buffer_start], '-', BUFFERSIZE - buffer_start); - int msg_len = _vsnprintf(&pBuffer[buffer_start], BUFFERSIZE - buffer_start, fmt, args ); + int msg_len = _vsnprintf_s(&pBuffer[buffer_start], BUFFERSIZE - buffer_start, _TRUNCATE, fmt, args ); if (msg_len == -1) { msg_len = BUFFERSIZE - buffer_start; diff --git a/src/md/compiler/regmeta.cpp b/src/md/compiler/regmeta.cpp index 230d1e4ff0..feb1cdd31b 100644 --- a/src/md/compiler/regmeta.cpp +++ b/src/md/compiler/regmeta.cpp @@ -829,7 +829,10 @@ int DumpMD_VWriteMarker(__in __in_z const char *str, va_list marker) { if (FAILED(hr = m_output.ReSizeNoThrow(STRING_BUFFER_LEN * i))) return 0; - count = _vsnprintf((char *)m_output.Ptr(), STRING_BUFFER_LEN * i, str, marker); + va_list markerCopy; + va_copy(markerCopy, marker); + count = _vsnprintf_s((char *)m_output.Ptr(), STRING_BUFFER_LEN * i, _TRUNCATE, str, markerCopy); + va_end(markerCopy); i *= 2; } OutputDebugStringA((LPCSTR)m_output.Ptr()); diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h index 05c777c7ca..51ac5b9a5d 100644 --- a/src/pal/inc/pal.h +++ b/src/pal/inc/pal.h @@ -5640,7 +5640,6 @@ CoCreateGuid(OUT GUID * pguid); #define printf PAL_printf #define vprintf PAL_vprintf #define wprintf PAL_wprintf -#define swprintf PAL_swprintf #define wcsspn PAL_wcsspn #define wcstod PAL_wcstod #define wcstol PAL_wcstol @@ -5667,8 +5666,6 @@ CoCreateGuid(OUT GUID * pguid); #define iswxdigit PAL_iswxdigit #define towlower PAL_towlower #define towupper PAL_towupper -#define vsprintf PAL_vsprintf -#define vswprintf PAL_vswprintf #define realloc PAL_realloc #define fopen PAL_fopen #define strtok PAL_strtok @@ -5731,7 +5728,6 @@ CoCreateGuid(OUT GUID * pguid); #define _close PAL__close #define _wcstoui64 PAL__wcstoui64 #define _flushall PAL__flushall -#define _vsnprintf PAL__vsnprintf #define strnlen PAL_strnlen #ifdef _AMD64_ @@ -5809,7 +5805,6 @@ PALIMPORT char * __cdecl strstr(const char *, const char *); PALIMPORT char * __cdecl strtok(char *, const char *); PALIMPORT size_t __cdecl strspn(const char *, const char *); PALIMPORT size_t __cdecl strcspn(const char *, const char *); -PALIMPORT int __cdecl vsprintf(char *, const char *, va_list); PALIMPORT int __cdecl atoi(const char *); PALIMPORT LONG __cdecl atol(const char *); PALIMPORT ULONG __cdecl strtoul(const char *, char **, int); @@ -5873,7 +5868,6 @@ PALIMPORT WCHAR * __cdecl PAL_wcstok(WCHAR *, const WCHAR *); PALIMPORT size_t __cdecl PAL_wcscspn(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__vsnprintf(LPSTR Buffer, size_t Count, LPCSTR Format, va_list ap); PALIMPORT int __cdecl PAL_swscanf(const WCHAR *, const WCHAR *, ...); PALIMPORT LONG __cdecl PAL_wcstol(const WCHAR *, WCHAR **, int); PALIMPORT ULONG __cdecl PAL_wcstoul(const WCHAR *, WCHAR **, int); diff --git a/src/pal/inc/rt/palrt.h b/src/pal/inc/rt/palrt.h index c181f38c2b..ce637bad0e 100644 --- a/src/pal/inc/rt/palrt.h +++ b/src/pal/inc/rt/palrt.h @@ -893,7 +893,6 @@ Remember to fix the errcode defintion in safecrt.h. */ #define _wcslwr_s _wcslwr_unsafe -#define _snprintf_s _snprintf_unsafe #define swscanf_s swscanf #define _wfopen_s _wfopen_unsafe @@ -903,8 +902,6 @@ Remember to fix the errcode defintion in safecrt.h. #define _vscprintf _vscprintf_unsafe -#define vsprintf_s _vsnprintf - extern "C++" { #include @@ -959,8 +956,11 @@ inline int __cdecl _vscprintf_unsafe(const char *_Format, va_list _ArgList) if(buf == nullptr) return 0; - int ret = _vsnprintf(buf, guess, _Format, _ArgList); + va_list argListCopy; + va_copy(argListCopy, _ArgList); + int ret = _vsnprintf_s(buf, guess, _TRUNCATE, _Format, argListCopy); free(buf); + va_end(argListCopy); if ((ret != -1) && (ret < guess)) return ret; @@ -969,28 +969,6 @@ inline int __cdecl _vscprintf_unsafe(const char *_Format, va_list _ArgList) } } -inline int __cdecl _vsnprintf_unsafe(char *_Dst, size_t _SizeInWords, size_t _Count, const char *_Format, va_list _ArgList) -{ - if (_Count == _TRUNCATE) _Count = _SizeInWords - 1; - int ret = _vsnprintf(_Dst, _Count, _Format, _ArgList); - _Dst[_SizeInWords - 1] = L'\0'; - if (ret < 0 && errno == 0) - { - errno = ERANGE; - } - return ret; -} - -inline int __cdecl _snprintf_unsafe(char *_Dst, size_t _SizeInWords, size_t _Count, const char *_Format, ...) -{ - int ret; - va_list _ArgList; - va_start(_ArgList, _Format); - ret = _vsnprintf_unsafe(_Dst, _SizeInWords, _Count, _Format, _ArgList); - va_end(_ArgList); - return ret; -} - inline errno_t __cdecl _wfopen_unsafe(PAL_FILE * *ff, const WCHAR *fileName, const WCHAR *mode) { PAL_FILE *result = _wfopen(fileName, mode); diff --git a/src/pal/inc/rt/safecrt.h b/src/pal/inc/rt/safecrt.h index 3cc10cef33..ab3e37ec48 100644 --- a/src/pal/inc/rt/safecrt.h +++ b/src/pal/inc/rt/safecrt.h @@ -3253,10 +3253,6 @@ int __cdecl vswprintf_s(WCHAR (&_Dst)[_SizeInWords], const WCHAR *_Format, va_li * return -1 if the formatted string does not entirely fit into _Dst (we will not call _SAFECRT_INVALID_PARAMETER); * if _Count == 0, then (_Dst == nullptr && _SizeInBytes == 0) is allowed */ -_SAFECRT__EXTERN_C -int __cdecl _snprintf_s(char *_Dst, size_t _SizeInBytes, size_t _Count, const char *_Format, ...); -_SAFECRT__EXTERN_C -int __cdecl _vsnprintf_s(char *_Dst, size_t _SizeInBytes, size_t _Count, const char *_Format, va_list _ArgList); #if defined(__cplusplus) && _SAFECRT_USE_CPP_OVERLOADS template diff --git a/src/pal/src/cruntime/printf.cpp b/src/pal/src/cruntime/printf.cpp index c437b8e39f..72c7e11bea 100644 --- a/src/pal/src/cruntime/printf.cpp +++ b/src/pal/src/cruntime/printf.cpp @@ -1363,34 +1363,6 @@ int PAL_wvsscanf(LPCWSTR Buffer, LPCWSTR Format, va_list ap) return Length; } -/*++ -Function: - PAL_swprintf - -See MSDN doc. ---*/ -int -__cdecl -PAL_swprintf( - wchar_16 *buffer, - const wchar_16 *format, - ...) -{ - LONG Length; - va_list ap; - - PERF_ENTRY(swprintf); - ENTRY("PAL_swprintf (buffer=%p, format=%p (%S))\n", buffer, format, format); - - va_start(ap, format); - Length = PAL__wvsnprintf(buffer, 0x7fffffff, format, ap); - va_end(ap); - - LOGEXIT("PAL_swprintf returns int %d\n", Length); - PERF_EXIT(swprintf); - return Length; -} - /*++ Function: PAL_swscanf @@ -1420,60 +1392,6 @@ PAL_swscanf( } -/*++ -Function: - PAL_vsprintf - -See MSDN doc. ---*/ -int -__cdecl -PAL_vsprintf(char *buffer, - const char *format, - va_list argptr) -{ - LONG Length; - - PERF_ENTRY(vsprintf); - ENTRY("PAL_vsprintf (buffer=%p, format=%p (%s), argptr=%p)\n", - buffer, format, format, argptr); - - Length = InternalVsnprintf(CorUnix::InternalGetCurrentThread(), buffer, 0x7fffffff, format, argptr); - - LOGEXIT("PAL_vsprintf returns int %d\n", Length); - PERF_EXIT(vsprintf); - - return Length; -} - - -/*++ -Function: - PAL_vswprintf - -See MSDN doc. ---*/ -int -__cdecl -PAL_vswprintf(wchar_16 *buffer, - const wchar_16 *format, - va_list argptr) -{ - LONG Length; - - PERF_ENTRY(vswprintf); - ENTRY("PAL_vswprintf (buffer=%p, format=%p (%S), argptr=%p)\n", - buffer, format, format, argptr); - - Length = PAL__wvsnprintf(buffer, 0x7fffffff, format, argptr); - - LOGEXIT("PAL_vswprintf returns int %d\n", Length); - PERF_EXIT(vswprintf); - - return Length; -} - - #if SSCANF_CANNOT_HANDLE_MISSING_EXPONENT /*++ Function: diff --git a/src/pal/src/cruntime/printfcpp.cpp b/src/pal/src/cruntime/printfcpp.cpp index ea074a604b..85ec698991 100644 --- a/src/pal/src/cruntime/printfcpp.cpp +++ b/src/pal/src/cruntime/printfcpp.cpp @@ -35,8 +35,6 @@ SET_DEFAULT_DEBUG_CHANNEL(CRT); using namespace CorUnix; -int CoreWvsnprintf(CPalThread *pthrCurrent, LPWSTR Buffer, size_t Count, LPCWSTR Format, va_list ap); -int CoreVsnprintf(CPalThread *pthrCurrent, LPSTR Buffer, size_t Count, LPCSTR Format, va_list ap); 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); @@ -1051,49 +1049,6 @@ static INT Internal_AddPaddingVfwprintf(CPalThread *pthrCurrent, PAL_FILE *strea return Written; } -/******************************************************************************* -Function: - PAL_vsnprintf - -Parameters: - Buffer - - out buffer - Count - - buffer size - Format - - format string - ap - - stdarg parameter list -*******************************************************************************/ - -int __cdecl PAL__vsnprintf(LPSTR Buffer, size_t Count, LPCSTR Format, va_list ap) -{ - LONG Length; - - PERF_ENTRY(PAL__vsnprintf); - ENTRY("PAL__vsnprintf (buffer=%p, count=%d, format=%p (%s), argptr=%p)\n", - Buffer, Count, Format, Format, ap); - - Length = CoreVsnprintf(InternalGetCurrentThread(), Buffer, Count, Format, ap); - - LOGEXIT("PAL__vsnprintf returns int %d\n", Length); - PERF_EXIT(PAL__vsnprintf); - - return Length; -} - -/******************************************************************************* -Function: - PAL_wvsnprintf - - -- see PAL_vsnprintf above -*******************************************************************************/ - -int __cdecl PAL__wvsnprintf(LPWSTR Buffer, size_t Count, LPCWSTR Format, va_list ap) -{ - return CoreWvsnprintf(InternalGetCurrentThread(), Buffer, Count, Format, ap); -} - /******************************************************************************* Function: PAL_vfprintf @@ -1132,26 +1087,11 @@ int __cdecl PAL_vfwprintf(PAL_FILE *stream, const wchar_16 *format, va_list ap) } // end extern "C" -int CorUnix::InternalWvsnprintf(CPalThread *pthrCurrent, LPWSTR Buffer, size_t Count, LPCWSTR Format, va_list ap) -{ - return CoreWvsnprintf(pthrCurrent, Buffer, Count, Format, ap); -} - -int CorUnix::InternalVsnprintf(CPalThread *pthrCurrent, LPSTR Buffer, size_t Count, LPCSTR Format, va_list ap) -{ - return CoreVsnprintf(pthrCurrent, Buffer, Count, Format, ap); -} - int CorUnix::InternalVfprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const char *format, va_list ap) { return CoreVfprintf(pthrCurrent, stream, format, ap); } -int CorUnix::InternalVfwprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const wchar_16 *format, va_list ap) -{ - return CoreVfwprintf(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 */ @@ -1466,7 +1406,7 @@ int CoreVfwprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const wchar_16 *for va_list apcopy; va_copy(apcopy, ap); - TempInt = vsnprintf(TempSprintfStr, TEMP_COUNT, TempBuff, apcopy); + TempInt = _vsnprintf_s(TempSprintfStr, TEMP_COUNT, _TRUNCATE, TempBuff, apcopy); va_end(apcopy); PAL_printf_arg_remover(&ap, Width, Precision, Type, Prefix); @@ -1484,7 +1424,7 @@ int CoreVfwprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const wchar_16 *for TempSprintfStr = TempSprintfStrPtr; va_copy(apcopy, ap); - vsnprintf(TempSprintfStr, TempInt, TempBuff, apcopy); + _vsnprintf_s(TempSprintfStr, TempInt, _TRUNCATE, TempBuff, apcopy); va_end(apcopy); PAL_printf_arg_remover(&ap, Width, Precision, Type, Prefix); } @@ -1581,664 +1521,6 @@ int CoreVfwprintf(CPalThread *pthrCurrent, PAL_FILE *stream, const wchar_16 *for return (written); } -int CoreVsnprintf(CPalThread *pthrCurrent, LPSTR Buffer, size_t Count, LPCSTR Format, va_list aparg) -{ - BOOL BufferRanOut = FALSE; - CHAR TempBuff[1024]; /* used to hold a single % format string */ - LPSTR BufferPtr = Buffer; - LPCSTR Fmt = Format; - LPWSTR TempWStr; - LPSTR TempStr; - WCHAR TempWChar; - INT Flags; - INT Width; - INT Precision; - INT Prefix; - INT Type; - INT Length; - INT TempInt; - int wctombResult; - va_list ap; - - va_copy(ap, aparg); - - while (*Fmt) - { - if (BufferRanOut || (BufferPtr - Buffer) >= static_cast(Count)) //Count is assumed to be in the range of int - { - BufferRanOut = TRUE; - break; - } - else if(*Fmt == '%' && - TRUE == Internal_ExtractFormatA(pthrCurrent, &Fmt, TempBuff, &Flags, - &Width, &Precision, - &Prefix, &Type)) - { - if (Prefix == PFF_PREFIX_LONG && Type == PFF_TYPE_STRING) - { - if (WIDTH_STAR == Width) - { - Width = va_arg(ap, INT); - } - else if (WIDTH_INVALID == Width) - { - /* both a '*' and a number, ignore, but remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - - if (PRECISION_STAR == Precision) - { - Precision = va_arg(ap, INT); - } - else if (PRECISION_INVALID == Precision) - { - /* both a '*' and a number, ignore, but remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - - TempWStr = va_arg(ap, LPWSTR); - Length = WideCharToMultiByte(CP_ACP, 0, TempWStr, -1, 0, - 0, 0, 0); - if (!Length) - { - ASSERT("WideCharToMultiByte failed. Error is %d\n", - GetLastError()); - va_end(ap); - return -1; - } - TempStr = (LPSTR) InternalMalloc(Length); - if (!TempStr) - { - ERROR("InternalMalloc failed\n"); - pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY); - va_end(ap); - return -1; - } - if (PRECISION_DOT == Precision) - { - /* copy nothing */ - *TempStr = 0; - Length = 0; - } - else if (Precision > 0 && Precision < Length - 1) - { - Length = WideCharToMultiByte(CP_ACP, 0, TempWStr, - Precision, TempStr, Length, - 0, 0); - if (!Length) - { - ASSERT("WideCharToMultiByte failed. Error is %d\n", - GetLastError()); - free(TempStr); - va_end(ap); - return -1; - } - TempStr[Length] = 0; - Length = Precision; - } - /* copy everything */ - else - { - wctombResult = WideCharToMultiByte(CP_ACP, 0, TempWStr, -1, - TempStr, Length, 0, 0); - if (!wctombResult) - { - ASSERT("WideCharToMultiByte failed. Error is %d\n", - GetLastError()); - free(TempStr); - va_end(ap); - return -1; - } - --Length; /* exclude null char */ - } - - /* do the padding (if needed)*/ - BufferRanOut = !Internal_AddPaddingA(&BufferPtr, - Count - (BufferPtr - Buffer), - TempStr, - Width - Length, - Flags); - - free(TempStr); - } - else if (Prefix == PFF_PREFIX_LONG && Type == PFF_TYPE_CHAR) - { - CHAR TempBuffer[5]; - - if (WIDTH_STAR == Width || - WIDTH_INVALID == Width) - { - /* ignore (because it's a char), and remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - if (PRECISION_STAR == Precision || - PRECISION_INVALID == Precision) - { - /* ignore (because it's a char), and remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - - TempWChar = va_arg(ap, int); - Length = WideCharToMultiByte(CP_ACP, 0, &TempWChar, 1, - TempBuffer, sizeof(TempBuffer), - 0, 0); - if (!Length) - { - ASSERT("WideCharToMultiByte failed. Error is %d\n", - GetLastError()); - va_end(ap); - return -1; - } - TempBuffer[Length] = 0; - - /* do the padding (if needed)*/ - BufferRanOut = !Internal_AddPaddingA(&BufferPtr, - Count - (BufferPtr - Buffer), - TempBuffer, - Width - Length, - Flags); - - } - /* 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 *)) = BufferPtr - Buffer; - } - else - { - *(va_arg(ap, LPLONG)) = BufferPtr - Buffer; - } - } - else if (Type == PFF_TYPE_CHAR && (Flags & PFF_ZERO) != 0) - { - // Some versions of sprintf don't support 0-padded chars, - // so we handle them here. - char ch[2]; - - ch[0] = (char) va_arg(ap, int); - ch[1] = '\0'; - Length = 1; - BufferRanOut = !Internal_AddPaddingA(&BufferPtr, - Count - (BufferPtr - Buffer), - ch, - Width - Length, - Flags); - } - else if (Type == PFF_TYPE_STRING && (Flags & PFF_ZERO) != 0) - { - // Some versions of sprintf don't support 0-padded strings, - // so we handle them here. - char *tempStr; - - tempStr = va_arg(ap, char *); - Length = strlen(tempStr); - BufferRanOut = !Internal_AddPaddingA(&BufferPtr, - Count - (BufferPtr - Buffer), - tempStr, - Width - Length, - Flags); - } - else - { - // Types that sprintf can handle - size_t TempCount = Count - (BufferPtr - Buffer); - -#if !HAVE_LARGE_SNPRINTF_SUPPORT - // Limit TempCount to 0x40000000, which is sufficient - // for platforms on which snprintf fails for very large - // sizes. - if (TempCount > 0x40000000) - { - TempCount = 0x40000000; - } -#endif // HAVE_LARGE_SNPRINTF_SUPPORT - - 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(BufferPtr, TempCount, TempBuff, trunc1); - } - else if (Type == PFF_TYPE_INT && Prefix == PFF_PREFIX_SHORT) - { - // Convert explicitly from int to short to get - // correct sign extension for shorts on all systems. - int n; - short s; - - n = va_arg(ap, int); - s = (short) n; - - TempInt = snprintf(BufferPtr, TempCount, TempBuff, s); - } - else - { - va_list apcopy; - va_copy(apcopy, ap); - TempInt = vsnprintf(BufferPtr, TempCount, TempBuff, apcopy); - va_end(apcopy); - PAL_printf_arg_remover(&ap, Width, Precision, Type, Prefix); - } - - if (TempInt < 0 || static_cast(TempInt) >= TempCount) /* buffer not long enough */ - { - BufferPtr += TempCount; - BufferRanOut = TRUE; - } - else - { - BufferPtr += TempInt; - } - } - } - else - { - *BufferPtr++ = *Fmt++; /* copy regular chars into buffer */ - } - } - - if (static_cast(Count) > (BufferPtr - Buffer)) //Count is assumed to be in the range of int - { - *BufferPtr = 0; /* end the string */ - } - - va_end(ap); - - if (BufferRanOut) - { - errno = ERANGE; - return -1; - } - else - { - return BufferPtr - Buffer; - } -} - -int CoreWvsnprintf(CPalThread *pthrCurrent, LPWSTR Buffer, size_t Count, LPCWSTR Format, va_list aparg) -{ - BOOL BufferRanOut = FALSE; - CHAR TempBuff[1024]; /* used to hold a single % format string */ - LPWSTR BufferPtr = Buffer; - LPCWSTR Fmt = Format; - LPWSTR TempWStr = NULL; - LPWSTR WorkingWStr = NULL; - WCHAR TempWChar[2]; - INT Flags; - INT Width; - INT Precision; - INT Prefix; - INT Type; - INT TempInt; - LPSTR TempNumberBuffer; - int mbtowcResult; - va_list(ap); - - PERF_ENTRY(wvsnprintf); - ENTRY("wvsnprintf (buffer=%p, count=%u, format=%p (%S))\n", - Buffer, Count, Format, Format); - - va_copy(ap, aparg); - - while (*Fmt) - { - if (BufferRanOut || (BufferPtr - Buffer) >= static_cast(Count)) //Count is assumed to be in the range of int - { - BufferRanOut = TRUE; - break; - } - else 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)) || - (Prefix == PFF_PREFIX_SHORT && Type == PFF_TYPE_STRING) || - (Type == PFF_TYPE_WSTRING && (Flags & PFF_ZERO) != 0)) - { - BOOL needToFree = FALSE; - - 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) || - Prefix == PFF_PREFIX_LONG_W) - { - TempWStr = va_arg(ap, LPWSTR); - } - else - { - // %lS and %hs assume an LPSTR argument. - LPSTR s = va_arg(ap, LPSTR ); - UINT Length = 0; - Length = MultiByteToWideChar( CP_ACP, 0, s, -1, NULL, 0 ); - if ( Length != 0 ) - { - TempWStr = - (LPWSTR)InternalMalloc((Length + 1 ) * sizeof( WCHAR ) ); - if ( TempWStr ) - { - needToFree = TRUE; - MultiByteToWideChar( CP_ACP, 0, s, -1, - TempWStr, Length ); - } - else - { - ERROR( "InternalMalloc failed.\n" ); - va_end(ap); - return -1; - } - } - else - { - ASSERT( "Unable to convert from multibyte " - " to wide char.\n" ); - va_end(ap); - return -1; - } - - } - - INT Length = PAL_wcslen(TempWStr); - WorkingWStr = (LPWSTR) InternalMalloc(sizeof(WCHAR) * (Length + 1)); - if (!WorkingWStr) - { - ERROR("InternalMalloc failed\n"); - pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY); - if (needToFree) - { - free(TempWStr); - } - 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("CoreWvsnprintf failed\n"); - if (needToFree) - { - free(TempWStr); - } - free(WorkingWStr); - LOGEXIT("wcsncpy_s failed!\n"); - PERF_EXIT(wvsnprintf); - va_end(ap); - return (-1); - } - - Length = Precision; - } - else - { - // Copy everything - PAL_wcscpy(WorkingWStr, TempWStr); - } - - // Add padding if needed. - BufferRanOut = !Internal_AddPaddingW(&BufferPtr, - Count - (BufferPtr - Buffer), - WorkingWStr, - Width - Length, - Flags); - - if (needToFree) - { - free(TempWStr); - } - free(WorkingWStr); - } - 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] = va_arg(ap, int); - TempWChar[1] = 0; - - /* do the padding (if needed)*/ - BufferRanOut = !Internal_AddPaddingW(&BufferPtr, - Count - (BufferPtr - Buffer), - TempWChar, - Width - 1, - Flags); - - } - /* 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 *)) = BufferPtr - Buffer; - } - else - { - *(va_arg(ap, LPLONG)) = BufferPtr - Buffer; - } - } - 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) */ - size_t TempCount = Count - (BufferPtr - Buffer); - TempInt = 0; - -#if !HAVE_LARGE_SNPRINTF_SUPPORT - // Limit TempCount to 0x40000000, which is sufficient - // for platforms on which snprintf fails for very large - // sizes. - if (TempCount > 0x40000000) - { - TempCount = 0x40000000; - } -#endif // HAVE_LARGE_SNPRINTF_SUPPORT - - // %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((LPSTR)BufferPtr, TempCount, TempBuff, trunc1); - } - else if (Type == PFF_TYPE_INT && Prefix == PFF_PREFIX_SHORT) - { - // Convert explicitly from int to short to get - // correct sign extension for shorts on all systems. - int n; - short s; - - n = va_arg(ap, int); - s = (short) n; - - TempInt = snprintf((LPSTR)BufferPtr, TempCount, TempBuff, s); - } - else - { - va_list apcopy; - va_copy(apcopy, ap); - TempInt = vsnprintf((LPSTR) BufferPtr, TempCount, TempBuff, apcopy); - va_end(apcopy); - PAL_printf_arg_remover(&ap, Width, Precision, Type, Prefix); - } - - if (TempInt == 0) - { - // The argument is "". - continue; - } - if (TempInt < 0 || static_cast(TempInt) >= TempCount) /* buffer not long enough */ - { - TempNumberBuffer = (LPSTR) InternalMalloc(TempCount+1); - if (!TempNumberBuffer) - { - ERROR("InternalMalloc failed\n"); - pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY); - errno = ENOMEM; - va_end(ap); - return -1; - } - - if (strncpy_s(TempNumberBuffer, TempCount+1, (LPSTR) BufferPtr, TempCount) != SAFECRT_SUCCESS) - { - ASSERT("strncpy_s failed!\n"); - free(TempNumberBuffer); - va_end(ap); - return -1; - } - - mbtowcResult = MultiByteToWideChar(CP_ACP, 0, - TempNumberBuffer, - TempCount, - BufferPtr, TempCount); - if (!mbtowcResult) - { - ASSERT("MultiByteToWideChar failed. Error is %d\n", - GetLastError()); - free(TempNumberBuffer); - va_end(ap); - return -1; - } - BufferPtr += TempCount; - BufferRanOut = TRUE; - } - else - { - TempNumberBuffer = (LPSTR) InternalMalloc(TempInt+1); - if (!TempNumberBuffer) - { - ERROR("InternalMalloc failed\n"); - pthrCurrent->SetLastError(ERROR_NOT_ENOUGH_MEMORY); - va_end(ap); - return -1; - } - - if (strncpy_s(TempNumberBuffer, TempInt+1, (LPSTR) BufferPtr, TempInt) != SAFECRT_SUCCESS) - { - ASSERT("strncpy_s failed!\n"); - free(TempNumberBuffer); - va_end(ap); - return -1; - } - - mbtowcResult = MultiByteToWideChar(CP_ACP, 0, - TempNumberBuffer, - TempInt, - BufferPtr, TempInt); - if (!mbtowcResult) - { - ASSERT("MultiByteToWideChar failed. Error is %d\n", - GetLastError()); - free(TempNumberBuffer); - va_end(ap); - return -1; - } - BufferPtr += TempInt; - } - free(TempNumberBuffer); - } - } - else - { - *BufferPtr++ = *Fmt++; /* copy regular chars into buffer */ - } - } - - if (static_cast(Count) > (BufferPtr - Buffer)) //Count is assumed to be in the range of int - { - *BufferPtr = 0; /* end the string */ - } - - va_end(ap); - - if (BufferRanOut) - { - errno = ERANGE; - return -1; - } - else - { - return BufferPtr - Buffer; - } -} - 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/pal/src/cruntime/silent_printf.cpp b/src/pal/src/cruntime/silent_printf.cpp index 1d10963973..4047c7e199 100644 --- a/src/pal/src/cruntime/silent_printf.cpp +++ b/src/pal/src/cruntime/silent_printf.cpp @@ -40,286 +40,6 @@ static INT Silent_AddPaddingVfprintf(PAL_FILE *stream, LPSTR In, INT Padding, static size_t Silent_PAL_wcslen(const wchar_16 *string); -/******************************************************************************* -Function: - PAL_vsnprintf (silent version) - for more details, see PAL_vsnprintf in printf.c -*******************************************************************************/ -INT Silent_PAL_vsnprintf(LPSTR Buffer, INT Count, LPCSTR Format, va_list aparg) -{ - BOOL BufferRanOut = FALSE; - CHAR TempBuff[1024]; /* used to hold a single % format string */ - LPSTR BufferPtr = Buffer; - LPCSTR Fmt = Format; - LPWSTR TempWStr; - CHAR TempStr[MAX_STR_LEN+1]; - WCHAR TempWChar; - INT Flags; - INT Width; - INT Precision; - INT Prefix; - INT Type; - INT Length; - INT TempInt; - int wctombResult; - va_list ap; - - va_copy(ap, aparg); - - while (*Fmt) - { - if ((BufferPtr - Buffer) >= Count) - { - BufferRanOut = TRUE; - break; - } - else if(*Fmt == '%' && - TRUE == Silent_ExtractFormatA(&Fmt, TempBuff, &Flags, - &Width, &Precision, - &Prefix, &Type)) - { - if (Prefix == PFF_PREFIX_LONG && Type == PFF_TYPE_STRING) - { - if (WIDTH_STAR == Width) - { - Width = va_arg(ap, INT); - } - else if (WIDTH_INVALID == Width) - { - /* both a '*' and a number, ignore, but remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - - if (PRECISION_STAR == Precision) - { - Precision = va_arg(ap, INT); - } - else if (PRECISION_INVALID == Precision) - { - /* both a '*' and a number, ignore, but remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - - TempWStr = va_arg(ap, LPWSTR); - Length = Silent_WideCharToMultiByte(TempWStr, -1, 0, 0); - if (!Length) - { - va_end(ap); - return -1; - } - - /* clip string output to MAX_STR_LEN characters */ - if (PRECISION_DOT == Precision) - { - Precision = MAX_STR_LEN; - } - - if (PRECISION_DOT == Precision) - { - /* copy nothing */ - *TempStr = 0; - Length = 0; - } - else if (Precision > 0 && Precision < Length - 1) - { - Length = Silent_WideCharToMultiByte(TempWStr, Precision, - TempStr, Length); - if (!Length) - { - va_end(ap); - return -1; - } - TempStr[Length] = 0; - Length = Precision; - } - /* copy everything */ - else - { - wctombResult = Silent_WideCharToMultiByte(TempWStr, -1, - TempStr, Length); - if (!wctombResult) - { - PAL_free(TempStr); - va_end(ap); - return -1; - } - --Length; /* exclude null char */ - } - - /* do the padding (if needed)*/ - BufferRanOut = !Internal_AddPaddingA(&BufferPtr, - Count - (BufferPtr - Buffer), - TempStr, - Width - Length, - Flags); - } - else if (Prefix == PFF_PREFIX_LONG && Type == PFF_TYPE_CHAR) - { - CHAR TempBuffer[4]; - - if (WIDTH_STAR == Width || - WIDTH_INVALID == Width) - { - /* ignore (because it's a char), and remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - if (PRECISION_STAR == Precision || - PRECISION_INVALID == Precision) - { - /* ignore (because it's a char), and remove arg */ - TempInt = va_arg(ap, INT); /* value not used */ - } - - TempWChar = va_arg(ap, int); - Length = Silent_WideCharToMultiByte(&TempWChar, 1, TempBuffer, 4); - if (!Length) - { - va_end(ap); - return -1; - } - TempBuffer[Length] = 0; - - /* do the padding (if needed)*/ - BufferRanOut = !Internal_AddPaddingA(&BufferPtr, - Count - (BufferPtr - Buffer), - TempBuffer, - Width - Length, - Flags); - - } - /* 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 *)) = BufferPtr - Buffer; - } - else - { - *(va_arg(ap, LPLONG)) = BufferPtr - Buffer; - } - } - else if (Type == PFF_TYPE_CHAR && (Flags & PFF_ZERO) != 0) - { - // Some versions of sprintf don't support 0-padded chars, - // so we handle them here. - char ch[2]; - - ch[0] = (char) va_arg(ap, int); - ch[1] = '\0'; - Length = 1; - BufferRanOut = !Internal_AddPaddingA(&BufferPtr, - Count - (BufferPtr - Buffer), - ch, - Width - Length, - Flags); - } - else if (Type == PFF_TYPE_STRING && (Flags & PFF_ZERO) != 0) - { - // Some versions of sprintf don't support 0-padded strings, - // so we handle them here. - char *tempStr; - - tempStr = va_arg(ap, char *); - Length = strlen(tempStr); - BufferRanOut = !Internal_AddPaddingA(&BufferPtr, - Count - (BufferPtr - Buffer), - tempStr, - Width - Length, - Flags); - } - /* types that sprintf can handle */ - else - { - size_t TempCount = Count - (BufferPtr - Buffer); - - TempInt = 0; - /* %h (short) doesn't seem to be handled properly by local sprintf, - so lets do the truncation ourselves. (ptr -> int -> short to avoid - warnings */ - if (Type == PFF_TYPE_P && Prefix == PFF_PREFIX_SHORT) - { - long trunc1; - short trunc2; - - trunc1 = va_arg(ap, LONG); - trunc2 = (short)trunc1; - - TempInt = snprintf(BufferPtr, TempCount, 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(BufferPtr, TempCount, TempBuff, s); - } - else - { - /* limit string output (%s) to 300 characters */ - if(TempBuff[0] == '%' && TempBuff[1] == 's') - { - if (strcpy_s(TempBuff, sizeof(TempBuff), "%.300s") != SAFECRT_SUCCESS) - { - va_end(ap); - return -1; - } - } - va_list apcopy; - va_copy(apcopy, ap); - TempInt = InternalVsnprintf(CorUnix::InternalGetCurrentThread(), BufferPtr, TempCount, TempBuff, apcopy); - va_end(apcopy); - PAL_printf_arg_remover(&ap, Width, Precision, Type, Prefix); - } - - if (TempInt < 0 || static_cast(TempInt) >= TempCount) /* buffer not long enough */ - { - BufferPtr += TempCount; - BufferRanOut = TRUE; - } - else - { - BufferPtr += TempInt; - } - } - } - else - { - *BufferPtr++ = *Fmt++; /* copy regular chars into buffer */ - } - } - - if (Count > (BufferPtr - Buffer)) - { - *BufferPtr = 0; /* end the string */ - } - - va_end(ap); - - if (BufferRanOut) - { - return -1; - } - else - { - return BufferPtr - Buffer; - } -} - /*++ Function: PAL_vfprintf (silent version) diff --git a/src/pal/src/cruntime/string.cpp b/src/pal/src/cruntime/string.cpp index abe6d136f0..2abce6fd8f 100644 --- a/src/pal/src/cruntime/string.cpp +++ b/src/pal/src/cruntime/string.cpp @@ -278,7 +278,7 @@ PAL_atol(const char *szNumber) PERF_ENTRY(atol); ENTRY("atol (szNumber=%p (%s))\n", - szNumber?szNumber:"NULL" + szNumber, szNumber?szNumber:"NULL" ); lResult = atol(szNumber); diff --git a/src/pal/src/include/pal/palinternal.h b/src/pal/src/include/pal/palinternal.h index f7856be902..8e1a5f158b 100644 --- a/src/pal/src/include/pal/palinternal.h +++ b/src/pal/src/include/pal/palinternal.h @@ -502,7 +502,6 @@ function_name() to call the system's implementation #undef vfwprintf #undef vprintf #undef wprintf -#undef swprintf #undef wcstod #undef wcstol #undef wcstoul @@ -525,10 +524,6 @@ function_name() to call the system's implementation #undef iswspace #undef towlower #undef towupper -#undef vsprintf -#undef vswprintf -#undef _vsnprintf -#undef vsnprintf #undef wvsnprintf #ifdef _AMD64_ diff --git a/src/pal/src/include/pal/printfcpp.hpp b/src/pal/src/include/pal/printfcpp.hpp index 0a728c9fd7..12e923a506 100644 --- a/src/pal/src/include/pal/printfcpp.hpp +++ b/src/pal/src/include/pal/printfcpp.hpp @@ -31,22 +31,6 @@ typedef char16_t wchar_16; // __wchar_16_cpp (which is defined in palinternal.h) extern "C" { - int - __cdecl - PAL__vsnprintf( - LPSTR Buffer, - size_t Count, - LPCSTR Format, - va_list ap); - - int - __cdecl - PAL__wvsnprintf( - LPWSTR Buffer, - size_t Count, - LPCWSTR Format, - va_list ap); - int __cdecl PAL_vfprintf( @@ -71,48 +55,9 @@ namespace CorUnix const char *format, va_list ap); - int - InternalWvsnprintf( - CPalThread *pthrCurrent, - LPWSTR Buffer, - size_t Count, - LPCWSTR Format, - va_list ap); - - int - InternalVsnprintf( - CPalThread *pthrCurrent, - LPSTR Buffer, - size_t Count, - LPCSTR Format, - va_list ap); - - int - InternalVfwprintf( - CPalThread *pthrCurrent, - PAL_FILE *stream, - const wchar_16 *format, - va_list ap); - } #else // __cplusplus - int - __cdecl - PAL__vsnprintf( - LPSTR Buffer, - size_t Count, - LPCSTR Format, - va_list ap); - - int - __cdecl - PAL__wvsnprintf( - LPWSTR Buffer, - size_t Count, - LPCWSTR Format, - va_list ap); - int __cdecl PAL_vfprintf( diff --git a/src/pal/src/misc/dbgmsg.cpp b/src/pal/src/misc/dbgmsg.cpp index 488e61494e..d6f173f160 100644 --- a/src/pal/src/misc/dbgmsg.cpp +++ b/src/pal/src/misc/dbgmsg.cpp @@ -528,8 +528,8 @@ int DBG_printf_gcc(DBG_CHANNEL_ID channel, DBG_LEVEL_ID level, BOOL bHeader, va_start(args, format); - output_size+=Silent_PAL_vsnprintf(buffer_ptr, DBG_BUFFER_SIZE-output_size, - format, args); + output_size+=_vsnprintf_s(buffer_ptr, DBG_BUFFER_SIZE-output_size, _TRUNCATE, + format, args); va_end(args); if( output_size > DBG_BUFFER_SIZE ) @@ -633,8 +633,8 @@ int DBG_printf_c99(DBG_CHANNEL_ID channel, DBG_LEVEL_ID level, BOOL bHeader, } va_start(args, format); - output_size+=Silent_PAL_vsnprintf(buffer_ptr, DBG_BUFFER_SIZE-output_size, - format, args); + output_size+=_vsnprintf_s(buffer_ptr, DBG_BUFFER_SIZE-output_size, _TRUNCATE, + format, args); va_end(args); if(output_size>DBG_BUFFER_SIZE) @@ -960,7 +960,7 @@ void PAL_DisplayDialogFormatted(const char *szTitle, const char *szTextFormat, . const int cchBuffer = 4096; char *szBuffer = (char*)alloca(cchBuffer); - PAL__vsnprintf(szBuffer, cchBuffer, szTextFormat, args); + _vsnprintf_s(szBuffer, cchBuffer, _TRUNCATE, szTextFormat, args); PAL_DisplayDialog(szTitle, szBuffer); va_end(args); diff --git a/src/pal/src/misc/fmtmessage.cpp b/src/pal/src/misc/fmtmessage.cpp index 46e0af6e0d..70b854aa9c 100644 --- a/src/pal/src/misc/fmtmessage.cpp +++ b/src/pal/src/misc/fmtmessage.cpp @@ -205,7 +205,7 @@ static LPWSTR FMTMSG_ProcessPrintf( wchar_t c , UINT nFormatLength = 0; int nBufferLength = 0; - TRACE( "FMTMSG_ProcessPrintf( %C, %S, %S )\n", c, + TRACE( "FMTMSG_ProcessPrintf( %C, %S, %p )\n", c, lpPrintfString, lpInsertString ); switch ( c ) @@ -299,7 +299,6 @@ FormatMessageW( LPWSTR lpReturnString = NULL; LPWSTR lpWorkingString = NULL; - PERF_ENTRY(FormatMessageW); ENTRY( "FormatMessageW(dwFlags=%#x, lpSource=%p, dwMessageId=%#x, " "dwLanguageId=%#x, lpBuffer=%p, nSize=%u, va_list=%p)\n", diff --git a/src/pal/tests/palsuite/c_runtime/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/CMakeLists.txt index cf062530eb..8225ed2dd4 100644 --- a/src/pal/tests/palsuite/c_runtime/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/CMakeLists.txt @@ -165,7 +165,7 @@ add_subdirectory(_snwprintf_s) add_subdirectory(_stricmp) add_subdirectory(_strlwr) add_subdirectory(_strnicmp) -add_subdirectory(_vsnprintf) +add_subdirectory(_vsnprintf_s) add_subdirectory(_vsnwprintf_s) add_subdirectory(_wcsicmp) add_subdirectory(_wcslwr) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf/CMakeLists.txt deleted file mode 100644 index cafb9536b0..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test10) -add_subdirectory(test11) -add_subdirectory(test12) -add_subdirectory(test13) -add_subdirectory(test14) -add_subdirectory(test15) -add_subdirectory(test16) -add_subdirectory(test17) -add_subdirectory(test18) -add_subdirectory(test19) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) -add_subdirectory(test7) -add_subdirectory(test8) -add_subdirectory(test9) - diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/_vsnprintf.h b/src/pal/tests/palsuite/c_runtime/_vsnprintf/_vsnprintf.h deleted file mode 100644 index 30e70648c3..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/_vsnprintf.h +++ /dev/null @@ -1,124 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: _vsnprintf.h -** -** Purpose: Contains common testing functions for _vsnprintf -** -** -**==========================================================================*/ - -#ifndef __STRINGTEST_H__ -#define __STRINGTEST_H__ - -/* These functions leaks memory like crazy. C'est la vie. */ -int Testvsnprintf(char* buf, size_t count, const char* format, ...) -{ - int retVal; - va_list arglist; - - va_start(arglist, format); - retVal = _vsnprintf(buf, count, format, arglist); - va_end(arglist); - - return (retVal); -} - - -void DoStrTest(const char *formatstr, char* param, const char *checkstr) -{ - char buf[256] = { 0 }; - - Testvsnprintf(buf, 256, formatstr, param); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert string \"%s\" into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, formatstr, checkstr, buf); - } -} - -void DoWStrTest(const char *formatstr, WCHAR* param, const char *checkstr) -{ - char buf[256] = { 0 }; - - Testvsnprintf(buf, 256, formatstr, param); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert wide string \"%s\" into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - convertC(param), formatstr, checkstr, buf); - } -} - - -void DoCharTest(const char *formatstr, char param, const char *checkstr) -{ - char buf[256] = { 0 }; - - Testvsnprintf(buf, 256, formatstr, param); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, param, formatstr, checkstr, buf); - } -} - -void DoWCharTest(const char *formatstr, WCHAR param, const char *checkstr) -{ - char buf[256] = { 0 }; - - Testvsnprintf(buf, 256, formatstr, param); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - (char)param, param, formatstr, checkstr, buf); - } -} - -void DoNumTest(const char *formatstr, int value, const char *checkstr) -{ - char buf[256] = { 0 }; - - Testvsnprintf(buf, 256, formatstr, value); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert %#x into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - value, formatstr, checkstr, buf); - } -} - -void DoI64Test(const char *formatstr, INT64 value, char *valuestr, const char *checkstr) -{ - char buf[256] = { 0 }; - - Testvsnprintf(buf, 256, formatstr, value); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - valuestr, formatstr, checkstr, buf); - } -} -void DoDoubleTest(const char *formatstr, double value, const char *checkstr1, char - *checkstr2) -{ - char buf[256] = { 0 }; - - Testvsnprintf(buf,256, formatstr, value); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\"\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - value, formatstr, checkstr1, checkstr2, buf); - } -} - -#endif diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test1/CMakeLists.txt deleted file mode 100644 index 489b7bf566..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test1/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_vsnprintf_test1 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test1 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test1 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test1/test1.cpp deleted file mode 100644 index 88aeec27a5..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test1/test1.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Test #1 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - char checkstr[] = "hello world"; - char buf[256] = { 0 }; - int ret; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - Testvsnprintf(buf, 256, "hello world"); - - if (memcmp(checkstr, buf, strlen(checkstr)+1) != 0) - { - Fail("ERROR: expected \"%s\" (up to %d chars), got \"%s\"\n", - checkstr, 256, buf); - } - - Testvsnprintf(buf, 256, "xxxxxxxxxxxxxxxxx"); - - ret = Testvsnprintf(buf, 8, "hello world"); - - if (ret >= 0) - { - Fail("ERROR: expected negative return value, got %d", ret); - } - if (memcmp(checkstr, buf, 8) != 0 || buf[8] != 'x') - { - Fail("ERROR: expected %s (up to %d chars), got %s\n", checkstr, 8, buf); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test1/testinfo.dat deleted file mode 100644 index f96bf084f2..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the _vsnprintf function. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test10/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test10/CMakeLists.txt deleted file mode 100644 index bc35dbd0c2..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test10/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test10.cpp -) - -add_executable(paltest_vsnprintf_test10 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test10 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test10 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test10/test10.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test10/test10.cpp deleted file mode 100644 index 3099957ab7..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/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. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test10.c -** -** Purpose: Test #10 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest("foo %o", pos, "foo 52"); - DoNumTest("foo %lo", 0xFFFF, "foo 177777"); - DoNumTest("foo %ho", 0xFFFF, "foo 177777"); - DoNumTest("foo %Lo", pos, "foo 52"); - DoI64Test("foo %I64o", l, "42", "foo 52"); - DoNumTest("foo %3o", pos, "foo 52"); - DoNumTest("foo %-3o", pos, "foo 52 "); - DoNumTest("foo %.1o", pos, "foo 52"); - DoNumTest("foo %.3o", pos, "foo 052"); - DoNumTest("foo %03o", pos, "foo 052"); - DoNumTest("foo %#o", pos, "foo 052"); - DoNumTest("foo %+o", pos, "foo 52"); - DoNumTest("foo % o", pos, "foo 52"); - DoNumTest("foo %+o", neg, "foo 37777777726"); - DoNumTest("foo % o", neg, "foo 37777777726"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test10/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test10/testinfo.dat deleted file mode 100644 index a3d8eca54e..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test10/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test10 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with octal numbers. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test11/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test11/CMakeLists.txt deleted file mode 100644 index bf3dd9a534..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test11/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test11.cpp -) - -add_executable(paltest_vsnprintf_test11 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test11 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test11 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test11/test11.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test11/test11.cpp deleted file mode 100644 index 74b0435c6d..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/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. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test11.c -** -** Purpose: Test #11 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest("foo %u", pos, "foo 42"); - DoNumTest("foo %lu", 0xFFFF, "foo 65535"); - DoNumTest("foo %hu", 0xFFFF, "foo 65535"); - DoNumTest("foo %Lu", pos, "foo 42"); - DoI64Test("foo %I64u", l, "42", "foo 42"); - DoNumTest("foo %3u", pos, "foo 42"); - DoNumTest("foo %-3u", pos, "foo 42 "); - DoNumTest("foo %.1u", pos, "foo 42"); - DoNumTest("foo %.3u", pos, "foo 042"); - DoNumTest("foo %03u", pos, "foo 042"); - DoNumTest("foo %#u", pos, "foo 42"); - DoNumTest("foo %+u", pos, "foo 42"); - DoNumTest("foo % u", pos, "foo 42"); - DoNumTest("foo %+u", neg, "foo 4294967254"); - DoNumTest("foo % u", neg, "foo 4294967254"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test11/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test11/testinfo.dat deleted file mode 100644 index 17e9f04946..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test11/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test11 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with unsigned numbers. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test12/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test12/CMakeLists.txt deleted file mode 100644 index 9fceeaf7a5..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test12/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test12.cpp -) - -add_executable(paltest_vsnprintf_test12 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test12 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test12 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test12/test12.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test12/test12.cpp deleted file mode 100644 index 3718620971..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test12/test12.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test12.c -** -** Purpose: Test #12 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return (FAIL); - } - - DoNumTest("foo %x", pos, "foo 1234ab"); - DoNumTest("foo %lx", pos, "foo 1234ab"); - DoNumTest("foo %hx", pos, "foo 34ab"); - DoNumTest("foo %Lx", pos, "foo 1234ab"); - DoI64Test("foo %I64x", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7x", pos, "foo 1234ab"); - DoNumTest("foo %-7x", pos, "foo 1234ab "); - DoNumTest("foo %.1x", pos, "foo 1234ab"); - DoNumTest("foo %.7x", pos, "foo 01234ab"); - DoNumTest("foo %07x", pos, "foo 01234ab"); - DoNumTest("foo %#x", pos, "foo 0x1234ab"); - DoNumTest("foo %+x", pos, "foo 1234ab"); - DoNumTest("foo % x", pos, "foo 1234ab"); - DoNumTest("foo %+x", neg, "foo ffffffd6"); - DoNumTest("foo % x", neg, "foo ffffffd6"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test12/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test12/testinfo.dat deleted file mode 100644 index 82f58e4371..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test12/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test12 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with hex numbers (lowercase). -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test13/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test13/CMakeLists.txt deleted file mode 100644 index 7e805f6ad4..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test13/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test13.cpp -) - -add_executable(paltest_vsnprintf_test13 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test13 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test13 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test13/test13.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test13/test13.cpp deleted file mode 100644 index 1abada4033..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test13/test13.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. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test13.c -** -** Purpose: Test #13 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234AB; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest("foo %X", pos, "foo 1234AB"); - DoNumTest("foo %lX", pos, "foo 1234AB"); - DoNumTest("foo %hX", pos, "foo 34AB"); - DoNumTest("foo %LX", pos, "foo 1234AB"); - DoI64Test("foo %I64X", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7X", pos, "foo 1234AB"); - DoNumTest("foo %-7X", pos, "foo 1234AB "); - DoNumTest("foo %.1X", pos, "foo 1234AB"); - DoNumTest("foo %.7X", pos, "foo 01234AB"); - DoNumTest("foo %07X", pos, "foo 01234AB"); - DoNumTest("foo %#X", pos, "foo 0X1234AB"); - DoNumTest("foo %+X", pos, "foo 1234AB"); - DoNumTest("foo % X", pos, "foo 1234AB"); - DoNumTest("foo %+X", neg, "foo FFFFFFD6"); - DoNumTest("foo % X", neg, "foo FFFFFFD6"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test13/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test13/testinfo.dat deleted file mode 100644 index d308edf871..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test13/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test13 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with hex numbers (uppercase). -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test14/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test14/CMakeLists.txt deleted file mode 100644 index 6e4566b577..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test14/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test14.cpp -) - -add_executable(paltest_vsnprintf_test14 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test14 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test14 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test14/test14.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test14/test14.cpp deleted file mode 100644 index 2e98f6ad4e..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test14/test14.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. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test14.c -** -** Purpose: Test #14 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest("foo %e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %he", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %Le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %I64e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %14e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %-14e", val, "foo 2.560000e+002 ", "foo 2.560000e+02 "); - DoDoubleTest("foo %.1e", val, "foo 2.6e+002", "foo 2.6e+02"); - DoDoubleTest("foo %.8e", val, "foo 2.56000000e+002", "foo 2.56000000e+02"); - DoDoubleTest("foo %014e", val, "foo 02.560000e+002", "foo 002.560000e+02"); - DoDoubleTest("foo %#e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", val, "foo +2.560000e+002", "foo +2.560000e+02"); - DoDoubleTest("foo % e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - DoDoubleTest("foo % e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test14/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test14/testinfo.dat deleted file mode 100644 index 8d11b1d6ff..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test14/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test14 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with exponential format doubles (lowercase). -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test15/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test15/CMakeLists.txt deleted file mode 100644 index d9039b39b7..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test15/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test15.cpp -) - -add_executable(paltest_vsnprintf_test15 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test15 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test15 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test15/test15.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test15/test15.cpp deleted file mode 100644 index 4d32e9c638..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test15/test15.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test15.c -** -** Purpose: Test #15 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest("foo %E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %lE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %hE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %LE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %I64E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %14E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %-14E", val, "foo 2.560000E+002 ", "foo 2.560000E+02 "); - DoDoubleTest("foo %.1E", val, "foo 2.6E+002", "foo 2.6E+02"); - DoDoubleTest("foo %.8E", val, "foo 2.56000000E+002", "foo 2.56000000E+02"); - DoDoubleTest("foo %014E", val, "foo 02.560000E+002", "foo 002.560000E+02"); - DoDoubleTest("foo %#E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", val, "foo +2.560000E+002", "foo +2.560000E+02"); - DoDoubleTest("foo % E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - DoDoubleTest("foo % E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test15/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test15/testinfo.dat deleted file mode 100644 index 913912508e..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test15/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test15 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with exponential format doubles (uppercase). -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test16/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test16/CMakeLists.txt deleted file mode 100644 index b298df318b..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test16/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test16.cpp -) - -add_executable(paltest_vsnprintf_test16 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test16 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test16 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test16/test16.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test16/test16.cpp deleted file mode 100644 index 118ba1453c..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test16/test16.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test16.c -** -** Purpose: Test #16 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest("foo %f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %hf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %Lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %I64f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %12f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %-12f", val, "foo 2560.001000 ", "foo 2560.001000 "); - DoDoubleTest("foo %.1f", val, "foo 2560.0", "foo 2560.0"); - DoDoubleTest("foo %.8f", val, "foo 2560.00100000", "foo 2560.00100000"); - DoDoubleTest("foo %012f", val, "foo 02560.001000", "foo 02560.001000"); - DoDoubleTest("foo %#f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", val, "foo +2560.001000", "foo +2560.001000"); - DoDoubleTest("foo % f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", neg, "foo -2560.001000", "foo -2560.001000"); - DoDoubleTest("foo % f", neg, "foo -2560.001000", "foo -2560.001000"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test16/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test16/testinfo.dat deleted file mode 100644 index fc2f13071b..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test16/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test16 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with decimal point format doubles. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test17/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test17/CMakeLists.txt deleted file mode 100644 index b195f334d3..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test17/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test17.cpp -) - -add_executable(paltest_vsnprintf_test17 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test17 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test17 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test17/test17.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test17/test17.cpp deleted file mode 100644 index 9b5063ddf0..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/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. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test17.c -** -** Purpose: Test #17 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest("foo %g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %Lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5g", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1g", val, "foo 3e+003", "foo 3e+03"); - DoDoubleTest("foo %.2g", val, "foo 2.6e+003", "foo 2.6e+03"); - DoDoubleTest("foo %.12g", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06g", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#g", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+g", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+g", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % g", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test17/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test17/testinfo.dat deleted file mode 100644 index aeb924495c..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test17/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test17 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with compact format doubles (lowercase). -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test18/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test18/CMakeLists.txt deleted file mode 100644 index f0f6d1124e..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test18/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test18.cpp -) - -add_executable(paltest_vsnprintf_test18 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test18 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test18 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test18/test18.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test18/test18.cpp deleted file mode 100644 index 5232befc7f..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/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. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test18.c -** -** Purpose: Test #18 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest("foo %G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %LG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5G", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1G", val, "foo 3E+003", "foo 3E+03"); - DoDoubleTest("foo %.2G", val, "foo 2.6E+003", "foo 2.6E+03"); - DoDoubleTest("foo %.12G", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06G", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#G", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+G", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+G", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % G", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test18/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test18/testinfo.dat deleted file mode 100644 index 57aaed5953..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test18/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test18 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with compact format doubles (uppercase). -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test19/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test19/CMakeLists.txt deleted file mode 100644 index 44b38902ef..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test19/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test19.cpp -) - -add_executable(paltest_vsnprintf_test19 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test19 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test19 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test19/test19.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test19/test19.cpp deleted file mode 100644 index 211354bc3a..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test19/test19.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test19.c -** -** Purpose: Test #19 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -#define DOTEST(a,b,c,d,e) DoTest(a,b,(void*)c,d,e) - -void DoArgumentPrecTest(char *formatstr, int precision, void *param, - char *paramstr, char *checkstr1, char *checkstr2) -{ - char buf[256]; - - Testvsnprintf(buf,256,formatstr, precision, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - paramstr, formatstr, precision, checkstr1, checkstr2, buf); - } - -} - -void DoArgumentPrecDoubleTest(char *formatstr, int precision, double param, - char *checkstr1, char *checkstr2) -{ - char buf[256]; - - Testvsnprintf(buf,256,formatstr, precision, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - param, formatstr, precision, checkstr1, checkstr2, buf); - } - -} - - - -int __cdecl main(int argc, char *argv[]) -{ - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - - DoArgumentPrecTest("%.*s", 2, (void*)"bar", "bar", "ba", "ba"); - DoArgumentPrecTest("%.*S", 2, (void*)convert("bar"), "bar", "ba", "ba"); - DoArgumentPrecTest("%.*c", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*c", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*d", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*d", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*i", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*i", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*o", 1, (void*)42, "42", "52", "52"); - DoArgumentPrecTest("%.*o", 3, (void*)42, "42", "052", "052"); - DoArgumentPrecTest("%.*u", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*u", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*x", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*x", 3, (void*)0x42, "0x42", "042", "042"); - DoArgumentPrecTest("%.*X", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*X", 3, (void*)0x42, "0x42", "042", "042"); - - - DoArgumentPrecDoubleTest("%.*e", 1, 2.01, "2.0e+000", "2.0e+00"); - DoArgumentPrecDoubleTest("%.*e", 3, 2.01, "2.010e+000", "2.010e+00"); - DoArgumentPrecDoubleTest("%.*E", 1, 2.01, "2.0E+000", "2.0E+00"); - DoArgumentPrecDoubleTest("%.*E", 3, 2.01, "2.010E+000", "2.010E+00"); - DoArgumentPrecDoubleTest("%.*f", 1, 2.01, "2.0", "2.0"); - DoArgumentPrecDoubleTest("%.*f", 3, 2.01, "2.010", "2.010"); - DoArgumentPrecDoubleTest("%.*g", 1, 256.01, "3e+002", "3e+02"); - DoArgumentPrecDoubleTest("%.*g", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 6, 256.01, "256.01", "256.01"); - DoArgumentPrecDoubleTest("%.*G", 1, 256.01, "3E+002", "3E+02"); - DoArgumentPrecDoubleTest("%.*G", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 6, 256.01, "256.01", "256.01"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test19/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test19/testinfo.dat deleted file mode 100644 index cda8966865..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test19/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test19 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with argument specified precision. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test2/CMakeLists.txt deleted file mode 100644 index 1d3910e70c..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test2/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_vsnprintf_test2 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test2 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test2 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test2/test2.cpp deleted file mode 100644 index 4bac4d2c83..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test2/test2.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c -** -** Purpose: Test #2 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf.h" -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR szwStr[] = {'b','a','r','\0'}; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoStrTest("foo %s", "bar", "foo bar"); - DoStrTest("foo %hs", "bar", "foo bar"); - DoWStrTest("foo %ls", szwStr, "foo bar"); - DoWStrTest("foo %ws", szwStr, "foo bar"); - DoStrTest("foo %Ls", "bar", "foo bar"); - DoStrTest("foo %I64s", "bar", "foo bar"); - DoStrTest("foo %5s", "bar", "foo bar"); - DoStrTest("foo %.2s", "bar", "foo ba"); - DoStrTest("foo %5.2s", "bar", "foo ba"); - DoStrTest("foo %-5s", "bar", "foo bar "); - DoStrTest("foo %05s", "bar", "foo 00bar"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test2/testinfo.dat deleted file mode 100644 index 6e8f03e639..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test2/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test2 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with strings. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test3/CMakeLists.txt deleted file mode 100644 index 62d765ec5f..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test3/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_vsnprintf_test3 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test3 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test3 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test3/test3.cpp deleted file mode 100644 index 2b30c9ad99..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test3/test3.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. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test3.c -** -** Purpose: Test #3 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoWStrTest("foo %S", convert("bar"), "foo bar"); - DoStrTest("foo %hS", "bar", "foo bar"); - DoWStrTest("foo %lS", convert("bar"), "foo bar"); - DoWStrTest("foo %wS", convert("bar"), "foo bar"); - DoWStrTest("foo %LS", convert("bar"), "foo bar"); - DoWStrTest("foo %I64S", convert("bar"), "foo bar"); - DoWStrTest("foo %5S", convert("bar"), "foo bar"); - DoWStrTest("foo %.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %5.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %-5S", convert("bar"), "foo bar "); - DoWStrTest("foo %05S", convert("bar"), "foo 00bar"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test3/testinfo.dat deleted file mode 100644 index 638cef69ef..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test3/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test3 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with wide strings. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test4/CMakeLists.txt deleted file mode 100644 index 5662bd57ad..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test4/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_vsnprintf_test4 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test4 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test4 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test4/test4.cpp deleted file mode 100644 index 33fc49deba..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test4/test4.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test4.c -** -** Purpose: Test #4 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -static void DoPointerTest(char *formatstr, void* param, char* paramstr, - char *checkstr1) -{ - char buf[256] = { 0 }; - - Testvsnprintf(buf,256, formatstr, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - paramstr, formatstr, checkstr1, buf); - } -} - -static void DoI64DoubleTest(char *formatstr, INT64 value, char *valuestr, char -*checkstr1) -{ - char buf[256] = { 0 }; - - Testvsnprintf(buf,256,formatstr, value); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\", got \"%s\".\n", - valuestr, formatstr, checkstr1, buf); - } -} - -int __cdecl main(int argc, char *argv[]) -{ - void *ptr = (void*) 0x123456; - INT64 lptr = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - - /* -** Run only on 64 bit platforms -*/ -#if defined(BIT64) && defined(PLATFORM_UNIX) - Trace("Testing for 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "0000000000000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%-17p", ptr, "pointer to 0x123456", "0000000000123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X0000000000123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64DoubleTest("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); - -#else - Trace("Testing for Non 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "00000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%9p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%09p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%-9p", ptr, "pointer to 0x123456", "00123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X00123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64DoubleTest("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); -#endif - - - - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test4/testinfo.dat deleted file mode 100644 index 03ff2931bc..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test4/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test4 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with pointers. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/CMakeLists.txt deleted file mode 100644 index 92540541f3..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_vsnprintf_test5 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test5 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test5 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/test5.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/test5.cpp deleted file mode 100644 index 534e42e293..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/test5.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test5.c -** -** Purpose: Test #5 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -static void DoTest(char *formatstr, int param, char *checkstr) -{ - char buf[256] = { 0 }; - int n = -1; - - Testvsnprintf(buf, 256, formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } -} - -static void DoShortTest(char *formatstr, int param, char *checkstr) -{ - char buf[256] = { 0 }; - short int n = -1; - - Testvsnprintf(buf, 256, formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } -} - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoTest("foo %n bar", 4, "foo bar"); - DoTest("foo %#n bar", 4, "foo bar"); - DoTest("foo % n bar", 4, "foo bar"); - DoTest("foo %+n bar", 4, "foo bar"); - DoTest("foo %-n bar", 4, "foo bar"); - DoTest("foo %0n bar", 4, "foo bar"); - DoShortTest("foo %hn bar", 4, "foo bar"); - DoTest("foo %ln bar", 4, "foo bar"); - DoTest("foo %Ln bar", 4, "foo bar"); - DoTest("foo %I64n bar", 4, "foo bar"); - DoTest("foo %20.3n bar", 4, "foo bar"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/testinfo.dat deleted file mode 100644 index c3848824f1..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test5/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test5 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with the count specifier. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test6/CMakeLists.txt deleted file mode 100644 index d80d433c22..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test6/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_vsnprintf_test6 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test6 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test6 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test6/test6.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test6/test6.cpp deleted file mode 100644 index 103d1181c2..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test6/test6.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test6.c -** -** Purpose: Test #6 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wc = (WCHAR) 'c'; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoCharTest("foo %c", 'b', "foo b"); - DoCharTest("foo %hc", 'b', "foo b"); - DoWCharTest("foo %lc", wc, "foo c"); - DoCharTest("foo %Lc", 'b', "foo b"); - DoCharTest("foo %I64c", 'b', "foo b"); - DoCharTest("foo %5c", 'b', "foo b"); - DoCharTest("foo %.0c", 'b', "foo b"); - DoCharTest("foo %-5c", 'b', "foo b "); - DoCharTest("foo %05c", 'b', "foo 0000b"); - DoCharTest("foo % c", 'b', "foo b"); - DoCharTest("foo %#c", 'b', "foo b"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test6/testinfo.dat deleted file mode 100644 index e375f9238d..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test6/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test6 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with characters. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test7/CMakeLists.txt deleted file mode 100644 index a1dc0a7c2c..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test7/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test7.cpp -) - -add_executable(paltest_vsnprintf_test7 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test7 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test7 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test7/test7.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test7/test7.cpp deleted file mode 100644 index c7e45d67fa..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test7/test7.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test7.c -** -** Purpose: Test #7 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf.h" -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wb = (WCHAR) 'b'; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoWCharTest("foo %c", wb, "foo b"); - DoWCharTest("foo %hc", wb, "foo b"); - DoCharTest("foo %lc", 'c', "foo c"); - DoWCharTest("foo %Lc", wb, "foo b"); - DoWCharTest("foo %I64c", wb, "foo b"); - DoWCharTest("foo %5c", wb, "foo b"); - DoWCharTest("foo %.0c", wb, "foo b"); - DoWCharTest("foo %-5c", wb, "foo b "); - DoWCharTest("foo %05c", wb, "foo 0000b"); - DoWCharTest("foo % c", wb, "foo b"); - DoWCharTest("foo %#c", wb, "foo b"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test7/testinfo.dat deleted file mode 100644 index 09eb481b59..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test7/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test7 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with wide characters. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test8/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test8/CMakeLists.txt deleted file mode 100644 index 1ca4732492..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test8/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test8.cpp -) - -add_executable(paltest_vsnprintf_test8 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test8 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test8 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test8/test8.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test8/test8.cpp deleted file mode 100644 index 2cefbeac25..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test8/test8.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test8.c -** -** Purpose: Test #8 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest("foo %d", pos, "foo 42"); - DoNumTest("foo %ld", 0xFFFF, "foo 65535"); - DoNumTest("foo %hd", 0xFFFF, "foo -1"); - DoNumTest("foo %Ld", pos, "foo 42"); - DoI64Test("foo %I64d", l, "42", "foo 42"); - DoNumTest("foo %3d", pos, "foo 42"); - DoNumTest("foo %-3d", pos, "foo 42 "); - DoNumTest("foo %.1d", pos, "foo 42"); - DoNumTest("foo %.3d", pos, "foo 042"); - DoNumTest("foo %03d", pos, "foo 042"); - DoNumTest("foo %#d", pos, "foo 42"); - DoNumTest("foo %+d", pos, "foo +42"); - DoNumTest("foo % d", pos, "foo 42"); - DoNumTest("foo %+d", neg, "foo -42"); - DoNumTest("foo % d", neg, "foo -42"); - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test8/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test8/testinfo.dat deleted file mode 100644 index 1bdf411983..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test8/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test8 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with decimal numbers. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test9/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test9/CMakeLists.txt deleted file mode 100644 index 583971fe5a..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test9/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test9.cpp -) - -add_executable(paltest_vsnprintf_test9 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test9 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test9 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test9/test9.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test9/test9.cpp deleted file mode 100644 index d2cd8165c0..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test9/test9.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. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test9.c -** -** Purpose: Test #9 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest("foo %i", pos, "foo 42"); - DoNumTest("foo %li", 0xFFFF, "foo 65535"); - DoNumTest("foo %hi", 0xFFFF, "foo -1"); - DoNumTest("foo %Li", pos, "foo 42"); - DoI64Test("foo %I64i", l, "42", "foo 42"); - DoNumTest("foo %3i", pos, "foo 42"); - DoNumTest("foo %-3i", pos, "foo 42 "); - DoNumTest("foo %.1i", pos, "foo 42"); - DoNumTest("foo %.3i", pos, "foo 042"); - DoNumTest("foo %03i", pos, "foo 042"); - DoNumTest("foo %#i", pos, "foo 42"); - DoNumTest("foo %+i", pos, "foo +42"); - DoNumTest("foo % i", pos, "foo 42"); - DoNumTest("foo %+i", neg, "foo -42"); - DoNumTest("foo % i", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test9/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf/test9/testinfo.dat deleted file mode 100644 index bdaae87ce8..0000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf/test9/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test9 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with integer numbers. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/CMakeLists.txt new file mode 100644 index 0000000000..8fe1cb60ac --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +add_subdirectory(test1) +add_subdirectory(test10) +add_subdirectory(test11) +add_subdirectory(test12) +add_subdirectory(test13) +add_subdirectory(test14) +add_subdirectory(test15) +add_subdirectory(test16) +add_subdirectory(test17) +add_subdirectory(test18) +add_subdirectory(test19) +add_subdirectory(test2) +add_subdirectory(test3) +add_subdirectory(test4) +add_subdirectory(test6) +add_subdirectory(test7) +add_subdirectory(test8) +add_subdirectory(test9) + diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/_vsnprintf_s.h b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/_vsnprintf_s.h new file mode 100644 index 0000000000..7c81136f71 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/_vsnprintf_s.h @@ -0,0 +1,124 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*============================================================================ +** +** Source: _vsnprintf_s.h +** +** Purpose: Contains common testing functions for _vsnprintf +** +** +**==========================================================================*/ + +#ifndef __STRINGTEST_H__ +#define __STRINGTEST_H__ + +/* These functions leaks memory like crazy. C'est la vie. */ +int Testvsnprintf(char* buf, size_t count, const char* format, ...) +{ + int retVal; + va_list arglist; + + va_start(arglist, format); + retVal = _vsnprintf_s(buf, count, _TRUNCATE, format, arglist); + va_end(arglist); + + return (retVal); +} + + +void DoStrTest(const char *formatstr, char* param, const char *checkstr) +{ + char buf[256] = { 0 }; + + Testvsnprintf(buf, 256, formatstr, param); + if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) + { + Fail("ERROR: failed to insert string \"%s\" into \"%s\"\n" + "Expected \"%s\" got \"%s\".\n", + param, formatstr, checkstr, buf); + } +} + +void DoWStrTest(const char *formatstr, WCHAR* param, const char *checkstr) +{ + char buf[256] = { 0 }; + + Testvsnprintf(buf, 256, formatstr, param); + if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) + { + Fail("ERROR: failed to insert wide string \"%s\" into \"%s\"\n" + "Expected \"%s\" got \"%s\".\n", + convertC(param), formatstr, checkstr, buf); + } +} + + +void DoCharTest(const char *formatstr, char param, const char *checkstr) +{ + char buf[256] = { 0 }; + + Testvsnprintf(buf, 256, formatstr, param); + if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) + { + Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" + "Expected \"%s\" got \"%s\".\n", + param, param, formatstr, checkstr, buf); + } +} + +void DoWCharTest(const char *formatstr, WCHAR param, const char *checkstr) +{ + char buf[256] = { 0 }; + + Testvsnprintf(buf, 256, formatstr, param); + if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) + { + Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" + "Expected \"%s\" got \"%s\".\n", + (char)param, param, formatstr, checkstr, buf); + } +} + +void DoNumTest(const char *formatstr, int value, const char *checkstr) +{ + char buf[256] = { 0 }; + + Testvsnprintf(buf, 256, formatstr, value); + if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) + { + Fail("ERROR: failed to insert %#x into \"%s\"\n" + "Expected \"%s\" got \"%s\".\n", + value, formatstr, checkstr, buf); + } +} + +void DoI64Test(const char *formatstr, INT64 value, char *valuestr, const char *checkstr) +{ + char buf[256] = { 0 }; + + Testvsnprintf(buf, 256, formatstr, value); + if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) + { + Fail("ERROR: failed to insert %s into \"%s\"\n" + "Expected \"%s\" got \"%s\".\n", + valuestr, formatstr, checkstr, buf); + } +} +void DoDoubleTest(const char *formatstr, double value, const char *checkstr1, char + *checkstr2) +{ + char buf[256] = { 0 }; + + Testvsnprintf(buf,256, formatstr, value); + if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && + memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) + { + Fail("ERROR: failed to insert %f into \"%s\"\n" + "Expected \"%s\" or \"%s\", got \"%s\".\n", + value, formatstr, checkstr1, checkstr2, buf); + } +} + +#endif diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/CMakeLists.txt new file mode 100644 index 0000000000..489b7bf566 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test1.cpp +) + +add_executable(paltest_vsnprintf_test1 + ${SOURCES} +) + +add_dependencies(paltest_vsnprintf_test1 coreclrpal) + +target_link_libraries(paltest_vsnprintf_test1 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/test1.cpp new file mode 100644 index 0000000000..db70f5612b --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/test1.cpp @@ -0,0 +1,55 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: test1.c +** +** Purpose: Test #1 for the _vsnprintf function. +** +** +**===================================================================*/ + +#include +#include "../_vsnprintf_s.h" + +/* + * Notes: memcmp is used, as is strlen. + */ + +int __cdecl main(int argc, char *argv[]) +{ + char checkstr[] = "hello world"; + char buf[256] = { 0 }; + int ret; + + if (PAL_Initialize(argc, argv) != 0) + { + return(FAIL); + } + + Testvsnprintf(buf, 256, "hello world"); + + if (memcmp(checkstr, buf, strlen(checkstr)+1) != 0) + { + Fail("ERROR: expected \"%s\" (up to %d chars), got \"%s\"\n", + checkstr, 256, buf); + } + + Testvsnprintf(buf, 256, "xxxxxxxxxxxxxxxxx"); + + ret = Testvsnprintf(buf, 8, "hello world"); + + if (ret >= 0) + { + Fail("ERROR: expected negative return value, got %d", ret); + } + if (memcmp(checkstr, buf, 7) != 0 || buf[7] != 0) + { + Fail("ERROR: expected %s (up to %d chars), got %s\n", checkstr, 8, buf); + } + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/testinfo.dat new file mode 100644 index 0000000000..f96bf084f2 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/testinfo.dat @@ -0,0 +1,13 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = C Runtime +Function = _vsnprintf +Name = Positive Test for _vsnprintf +TYPE = DEFAULT +EXE1 = test1 +Description += Tests the PAL implementation of the _vsnprintf function. += This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/CMakeLists.txt new file mode 100644 index 0000000000..bc35dbd0c2 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test10.cpp +) + +add_executable(paltest_vsnprintf_test10 + ${SOURCES} +) + +add_dependencies(paltest_vsnprintf_test10 coreclrpal) + +target_link_libraries(paltest_vsnprintf_test10 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/test10.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/test10.cpp new file mode 100644 index 0000000000..707a91c048 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/test10.cpp @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: test10.c +** +** Purpose: Test #10 for the _vsnprintf function. +** +** +**===================================================================*/ + +#include +#include "../_vsnprintf_s.h" + +/* + * Notes: memcmp is used, as is strlen. + */ + +int __cdecl main(int argc, char *argv[]) +{ + int neg = -42; + int pos = 42; + INT64 l = 42; + + if (PAL_Initialize(argc, argv) != 0) + { + return(FAIL); + } + + DoNumTest("foo %o", pos, "foo 52"); + DoNumTest("foo %lo", 0xFFFF, "foo 177777"); + DoNumTest("foo %ho", 0xFFFF, "foo 177777"); + DoNumTest("foo %Lo", pos, "foo 52"); + DoI64Test("foo %I64o", l, "42", "foo 52"); + DoNumTest("foo %3o", pos, "foo 52"); + DoNumTest("foo %-3o", pos, "foo 52 "); + DoNumTest("foo %.1o", pos, "foo 52"); + DoNumTest("foo %.3o", pos, "foo 052"); + DoNumTest("foo %03o", pos, "foo 052"); + DoNumTest("foo %#o", pos, "foo 052"); + DoNumTest("foo %+o", pos, "foo 52"); + DoNumTest("foo % o", pos, "foo 52"); + DoNumTest("foo %+o", neg, "foo 37777777726"); + DoNumTest("foo % o", neg, "foo 37777777726"); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/testinfo.dat new file mode 100644 index 0000000000..a3d8eca54e --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/testinfo.dat @@ -0,0 +1,14 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = C Runtime +Function = _vsnprintf +Name = Positive Test for _vsnprintf +TYPE = DEFAULT +EXE1 = test10 +Description += Tests the PAL implementation of the _vsnprintf function. += Tests _vsnprintf with octal numbers. += This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/CMakeLists.txt new file mode 100644 index 0000000000..bf3dd9a534 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test11.cpp +) + +add_executable(paltest_vsnprintf_test11 + ${SOURCES} +) + +add_dependencies(paltest_vsnprintf_test11 coreclrpal) + +target_link_libraries(paltest_vsnprintf_test11 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/test11.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/test11.cpp new file mode 100644 index 0000000000..4c710e56b0 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/test11.cpp @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: test11.c +** +** Purpose: Test #11 for the _vsnprintf function. +** +** +**===================================================================*/ + +#include +#include "../_vsnprintf_s.h" + +/* + * Notes: memcmp is used, as is strlen. + */ + +int __cdecl main(int argc, char *argv[]) +{ + int neg = -42; + int pos = 42; + INT64 l = 42; + + if (PAL_Initialize(argc, argv) != 0) + { + return(FAIL); + } + + DoNumTest("foo %u", pos, "foo 42"); + DoNumTest("foo %lu", 0xFFFF, "foo 65535"); + DoNumTest("foo %hu", 0xFFFF, "foo 65535"); + DoNumTest("foo %Lu", pos, "foo 42"); + DoI64Test("foo %I64u", l, "42", "foo 42"); + DoNumTest("foo %3u", pos, "foo 42"); + DoNumTest("foo %-3u", pos, "foo 42 "); + DoNumTest("foo %.1u", pos, "foo 42"); + DoNumTest("foo %.3u", pos, "foo 042"); + DoNumTest("foo %03u", pos, "foo 042"); + DoNumTest("foo %#u", pos, "foo 42"); + DoNumTest("foo %+u", pos, "foo 42"); + DoNumTest("foo % u", pos, "foo 42"); + DoNumTest("foo %+u", neg, "foo 4294967254"); + DoNumTest("foo % u", neg, "foo 4294967254"); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/testinfo.dat new file mode 100644 index 0000000000..17e9f04946 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/testinfo.dat @@ -0,0 +1,14 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = C Runtime +Function = _vsnprintf +Name = Positive Test for _vsnprintf +TYPE = DEFAULT +EXE1 = test11 +Description += Tests the PAL implementation of the _vsnprintf function. += Tests _vsnprintf with unsigned numbers. += This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/CMakeLists.txt new file mode 100644 index 0000000000..9fceeaf7a5 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test12.cpp +) + +add_executable(paltest_vsnprintf_test12 + ${SOURCES} +) + +add_dependencies(paltest_vsnprintf_test12 coreclrpal) + +target_link_libraries(paltest_vsnprintf_test12 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/test12.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/test12.cpp new file mode 100644 index 0000000000..528e6582a8 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/test12.cpp @@ -0,0 +1,52 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: test12.c +** +** Purpose: Test #12 for the _vsnprintf function. +** +** +**===================================================================*/ + +#include +#include "../_vsnprintf_s.h" + +/* + * Notes: memcmp is used, as is strlen. + */ + + +int __cdecl main(int argc, char *argv[]) +{ + int neg = -42; + int pos = 0x1234ab; + INT64 l = I64(0x1234567887654321); + + if (PAL_Initialize(argc, argv) != 0) + { + return (FAIL); + } + + DoNumTest("foo %x", pos, "foo 1234ab"); + DoNumTest("foo %lx", pos, "foo 1234ab"); + DoNumTest("foo %hx", pos, "foo 34ab"); + DoNumTest("foo %Lx", pos, "foo 1234ab"); + DoI64Test("foo %I64x", l, "0x1234567887654321", + "foo 1234567887654321"); + DoNumTest("foo %7x", pos, "foo 1234ab"); + DoNumTest("foo %-7x", pos, "foo 1234ab "); + DoNumTest("foo %.1x", pos, "foo 1234ab"); + DoNumTest("foo %.7x", pos, "foo 01234ab"); + DoNumTest("foo %07x", pos, "foo 01234ab"); + DoNumTest("foo %#x", pos, "foo 0x1234ab"); + DoNumTest("foo %+x", pos, "foo 1234ab"); + DoNumTest("foo % x", pos, "foo 1234ab"); + DoNumTest("foo %+x", neg, "foo ffffffd6"); + DoNumTest("foo % x", neg, "foo ffffffd6"); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/testinfo.dat new file mode 100644 index 0000000000..82f58e4371 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/testinfo.dat @@ -0,0 +1,14 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = C Runtime +Function = _vsnprintf +Name = Positive Test for _vsnprintf +TYPE = DEFAULT +EXE1 = test12 +Description += Tests the PAL implementation of the _vsnprintf function. += Tests _vsnprintf with hex numbers (lowercase). += This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/CMakeLists.txt new file mode 100644 index 0000000000..7e805f6ad4 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test13.cpp +) + +add_executable(paltest_vsnprintf_test13 + ${SOURCES} +) + +add_dependencies(paltest_vsnprintf_test13 coreclrpal) + +target_link_libraries(paltest_vsnprintf_test13 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/test13.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/test13.cpp new file mode 100644 index 0000000000..645a118682 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/test13.cpp @@ -0,0 +1,52 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: test13.c +** +** Purpose: Test #13 for the _vsnprintf function. +** +** +**===================================================================*/ + +#include +#include "../_vsnprintf_s.h" + +/* + * Notes: memcmp is used, as is strlen. + */ + + +int __cdecl main(int argc, char *argv[]) +{ + int neg = -42; + int pos = 0x1234AB; + INT64 l = I64(0x1234567887654321); + + if (PAL_Initialize(argc, argv) != 0) + { + return(FAIL); + } + + DoNumTest("foo %X", pos, "foo 1234AB"); + DoNumTest("foo %lX", pos, "foo 1234AB"); + DoNumTest("foo %hX", pos, "foo 34AB"); + DoNumTest("foo %LX", pos, "foo 1234AB"); + DoI64Test("foo %I64X", l, "0x1234567887654321", + "foo 1234567887654321"); + DoNumTest("foo %7X", pos, "foo 1234AB"); + DoNumTest("foo %-7X", pos, "foo 1234AB "); + DoNumTest("foo %.1X", pos, "foo 1234AB"); + DoNumTest("foo %.7X", pos, "foo 01234AB"); + DoNumTest("foo %07X", pos, "foo 01234AB"); + DoNumTest("foo %#X", pos, "foo 0X1234AB"); + DoNumTest("foo %+X", pos, "foo 1234AB"); + DoNumTest("foo % X", pos, "foo 1234AB"); + DoNumTest("foo %+X", neg, "foo FFFFFFD6"); + DoNumTest("foo % X", neg, "foo FFFFFFD6"); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/testinfo.dat new file mode 100644 index 0000000000..d308edf871 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/testinfo.dat @@ -0,0 +1,14 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = C Runtime +Function = _vsnprintf +Name = Positive Test for _vsnprintf +TYPE = DEFAULT +EXE1 = test13 +Description += Tests the PAL implementation of the _vsnprintf function. += Tests _vsnprintf with hex numbers (uppercase). += This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/CMakeLists.txt new file mode 100644 index 0000000000..6e4566b577 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test14.cpp +) + +add_executable(paltest_vsnprintf_test14 + ${SOURCES} +) + +add_dependencies(paltest_vsnprintf_test14 coreclrpal) + +target_link_libraries(paltest_vsnprintf_test14 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/test14.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/test14.cpp new file mode 100644 index 0000000000..05965f0ed7 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/test14.cpp @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: test14.c +** +** Purpose: Test #14 for the _vsnprintf function. +** +** +**===================================================================*/ + +#include +#include "../_vsnprintf_s.h" + +/* + * Notes: memcmp is used, as is strlen. + */ + + +int __cdecl main(int argc, char *argv[]) +{ + double val = 256.0; + double neg = -256.0; + + if (PAL_Initialize(argc, argv) != 0) + { + return(FAIL); + } + + DoDoubleTest("foo %e", val, "foo 2.560000e+002", "foo 2.560000e+02"); + DoDoubleTest("foo %le", val, "foo 2.560000e+002", "foo 2.560000e+02"); + DoDoubleTest("foo %he", val, "foo 2.560000e+002", "foo 2.560000e+02"); + DoDoubleTest("foo %Le", val, "foo 2.560000e+002", "foo 2.560000e+02"); + DoDoubleTest("foo %I64e", val, "foo 2.560000e+002", "foo 2.560000e+02"); + DoDoubleTest("foo %14e", val, "foo 2.560000e+002", "foo 2.560000e+02"); + DoDoubleTest("foo %-14e", val, "foo 2.560000e+002 ", "foo 2.560000e+02 "); + DoDoubleTest("foo %.1e", val, "foo 2.6e+002", "foo 2.6e+02"); + DoDoubleTest("foo %.8e", val, "foo 2.56000000e+002", "foo 2.56000000e+02"); + DoDoubleTest("foo %014e", val, "foo 02.560000e+002", "foo 002.560000e+02"); + DoDoubleTest("foo %#e", val, "foo 2.560000e+002", "foo 2.560000e+02"); + DoDoubleTest("foo %+e", val, "foo +2.560000e+002", "foo +2.560000e+02"); + DoDoubleTest("foo % e", val, "foo 2.560000e+002", "foo 2.560000e+02"); + DoDoubleTest("foo %+e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); + DoDoubleTest("foo % e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/testinfo.dat new file mode 100644 index 0000000000..8d11b1d6ff --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/testinfo.dat @@ -0,0 +1,14 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = C Runtime +Function = _vsnprintf +Name = Positive Test for _vsnprintf +TYPE = DEFAULT +EXE1 = test14 +Description += Tests the PAL implementation of the _vsnprintf function. += Tests _vsnprintf with exponential format doubles (lowercase). += This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/CMakeLists.txt new file mode 100644 index 0000000000..d9039b39b7 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test15.cpp +) + +add_executable(paltest_vsnprintf_test15 + ${SOURCES} +) + +add_dependencies(paltest_vsnprintf_test15 coreclrpal) + +target_link_libraries(paltest_vsnprintf_test15 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/test15.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/test15.cpp new file mode 100644 index 0000000000..cd34f74e6c --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/test15.cpp @@ -0,0 +1,49 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: test15.c +** +** Purpose: Test #15 for the _vsnprintf function. +** +** +**===================================================================*/ + +#include +#include "../_vsnprintf_s.h" + +/* + * Notes: memcmp is used, as is strlen. + */ + +int __cdecl main(int argc, char *argv[]) +{ + double val = 256.0; + double neg = -256.0; + + if (PAL_Initialize(argc, argv) != 0) + { + return(FAIL); + } + + DoDoubleTest("foo %E", val, "foo 2.560000E+002", "foo 2.560000E+02"); + DoDoubleTest("foo %lE", val, "foo 2.560000E+002", "foo 2.560000E+02"); + DoDoubleTest("foo %hE", val, "foo 2.560000E+002", "foo 2.560000E+02"); + DoDoubleTest("foo %LE", val, "foo 2.560000E+002", "foo 2.560000E+02"); + DoDoubleTest("foo %I64E", val, "foo 2.560000E+002", "foo 2.560000E+02"); + DoDoubleTest("foo %14E", val, "foo 2.560000E+002", "foo 2.560000E+02"); + DoDoubleTest("foo %-14E", val, "foo 2.560000E+002 ", "foo 2.560000E+02 "); + DoDoubleTest("foo %.1E", val, "foo 2.6E+002", "foo 2.6E+02"); + DoDoubleTest("foo %.8E", val, "foo 2.56000000E+002", "foo 2.56000000E+02"); + DoDoubleTest("foo %014E", val, "foo 02.560000E+002", "foo 002.560000E+02"); + DoDoubleTest("foo %#E", val, "foo 2.560000E+002", "foo 2.560000E+02"); + DoDoubleTest("foo %+E", val, "foo +2.560000E+002", "foo +2.560000E+02"); + DoDoubleTest("foo % E", val, "foo 2.560000E+002", "foo 2.560000E+02"); + DoDoubleTest("foo %+E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); + DoDoubleTest("foo % E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/testinfo.dat new file mode 100644 index 0000000000..913912508e --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/testinfo.dat @@ -0,0 +1,14 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = C Runtime +Function = _vsnprintf +Name = Positive Test for _vsnprintf +TYPE = DEFAULT +EXE1 = test15 +Description += Tests the PAL implementation of the _vsnprintf function. += Tests _vsnprintf with exponential format doubles (uppercase). += This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/CMakeLists.txt new file mode 100644 index 0000000000..b298df318b --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test16.cpp +) + +add_executable(paltest_vsnprintf_test16 + ${SOURCES} +) + +add_dependencies(paltest_vsnprintf_test16 coreclrpal) + +target_link_libraries(paltest_vsnprintf_test16 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/test16.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/test16.cpp new file mode 100644 index 0000000000..de9b74f9b3 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/test16.cpp @@ -0,0 +1,49 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: test16.c +** +** Purpose: Test #16 for the _vsnprintf function. +** +** +**===================================================================*/ + +#include +#include "../_vsnprintf_s.h" + +/* + * Notes: memcmp is used, as is strlen. + */ + +int __cdecl main(int argc, char *argv[]) +{ + double val = 2560.001; + double neg = -2560.001; + + if (PAL_Initialize(argc, argv) != 0) + { + return(FAIL); + } + + DoDoubleTest("foo %f", val, "foo 2560.001000", "foo 2560.001000"); + DoDoubleTest("foo %lf", val, "foo 2560.001000", "foo 2560.001000"); + DoDoubleTest("foo %hf", val, "foo 2560.001000", "foo 2560.001000"); + DoDoubleTest("foo %Lf", val, "foo 2560.001000", "foo 2560.001000"); + DoDoubleTest("foo %I64f", val, "foo 2560.001000", "foo 2560.001000"); + DoDoubleTest("foo %12f", val, "foo 2560.001000", "foo 2560.001000"); + DoDoubleTest("foo %-12f", val, "foo 2560.001000 ", "foo 2560.001000 "); + DoDoubleTest("foo %.1f", val, "foo 2560.0", "foo 2560.0"); + DoDoubleTest("foo %.8f", val, "foo 2560.00100000", "foo 2560.00100000"); + DoDoubleTest("foo %012f", val, "foo 02560.001000", "foo 02560.001000"); + DoDoubleTest("foo %#f", val, "foo 2560.001000", "foo 2560.001000"); + DoDoubleTest("foo %+f", val, "foo +2560.001000", "foo +2560.001000"); + DoDoubleTest("foo % f", val, "foo 2560.001000", "foo 2560.001000"); + DoDoubleTest("foo %+f", neg, "foo -2560.001000", "foo -2560.001000"); + DoDoubleTest("foo % f", neg, "foo -2560.001000", "foo -2560.001000"); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/testinfo.dat new file mode 100644 index 0000000000..fc2f13071b --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/testinfo.dat @@ -0,0 +1,14 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = C Runtime +Function = _vsnprintf +Name = Positive Test for _vsnprintf +TYPE = DEFAULT +EXE1 = test16 +Description += Tests the PAL implementation of the _vsnprintf function. += Tests _vsnprintf with decimal point format doubles. += This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/CMakeLists.txt new file mode 100644 index 0000000000..b195f334d3 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test17.cpp +) + +add_executable(paltest_vsnprintf_test17 + ${SOURCES} +) + +add_dependencies(paltest_vsnprintf_test17 coreclrpal) + +target_link_libraries(paltest_vsnprintf_test17 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/test17.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/test17.cpp new file mode 100644 index 0000000000..3304eda7f9 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/test17.cpp @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: test17.c +** +** Purpose: Test #17 for the _vsnprintf function. +** +** +**===================================================================*/ + +#include +#include "../_vsnprintf_s.h" + +/* + * Notes: memcmp is used, as is strlen. + */ + +int __cdecl main(int argc, char *argv[]) +{ + double val = 2560.001; + double neg = -2560.001; + + if (PAL_Initialize(argc, argv) != 0) + { + return(FAIL); + } + + DoDoubleTest("foo %g", val, "foo 2560", "foo 2560"); + DoDoubleTest("foo %lg", val, "foo 2560", "foo 2560"); + DoDoubleTest("foo %hg", val, "foo 2560", "foo 2560"); + DoDoubleTest("foo %Lg", val, "foo 2560", "foo 2560"); + DoDoubleTest("foo %I64g", val, "foo 2560", "foo 2560"); + DoDoubleTest("foo %5g", val, "foo 2560", "foo 2560"); + DoDoubleTest("foo %-5g", val, "foo 2560 ", "foo 2560 "); + DoDoubleTest("foo %.1g", val, "foo 3e+003", "foo 3e+03"); + DoDoubleTest("foo %.2g", val, "foo 2.6e+003", "foo 2.6e+03"); + DoDoubleTest("foo %.12g", val, "foo 2560.001", "foo 2560.001"); + DoDoubleTest("foo %06g", val, "foo 002560", "foo 002560"); + DoDoubleTest("foo %#g", val, "foo 2560.00", "foo 2560.00"); + DoDoubleTest("foo %+g", val, "foo +2560", "foo +2560"); + DoDoubleTest("foo % g", val, "foo 2560", "foo 2560"); + DoDoubleTest("foo %+g", neg, "foo -2560", "foo -2560"); + DoDoubleTest("foo % g", neg, "foo -2560", "foo -2560"); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/testinfo.dat new file mode 100644 index 0000000000..aeb924495c --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/testinfo.dat @@ -0,0 +1,14 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = C Runtime +Function = _vsnprintf +Name = Positive Test for _vsnprintf +TYPE = DEFAULT +EXE1 = test17 +Description += Tests the PAL implementation of the _vsnprintf function. += Tests _vsnprintf with compact format doubles (lowercase). += This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/CMakeLists.txt new file mode 100644 index 0000000000..f0f6d1124e --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test18.cpp +) + +add_executable(paltest_vsnprintf_test18 + ${SOURCES} +) + +add_dependencies(paltest_vsnprintf_test18 coreclrpal) + +target_link_libraries(paltest_vsnprintf_test18 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/test18.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/test18.cpp new file mode 100644 index 0000000000..14ad8f583a --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/test18.cpp @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: test18.c +** +** Purpose: Test #18 for the _vsnprintf function. +** +** +**===================================================================*/ + +#include +#include "../_vsnprintf_s.h" + +/* + * Notes: memcmp is used, as is strlen. + */ + +int __cdecl main(int argc, char *argv[]) +{ + double val = 2560.001; + double neg = -2560.001; + + if (PAL_Initialize(argc, argv) != 0) + { + return(FAIL); + } + + DoDoubleTest("foo %G", val, "foo 2560", "foo 2560"); + DoDoubleTest("foo %lG", val, "foo 2560", "foo 2560"); + DoDoubleTest("foo %hG", val, "foo 2560", "foo 2560"); + DoDoubleTest("foo %LG", val, "foo 2560", "foo 2560"); + DoDoubleTest("foo %I64G", val, "foo 2560", "foo 2560"); + DoDoubleTest("foo %5G", val, "foo 2560", "foo 2560"); + DoDoubleTest("foo %-5G", val, "foo 2560 ", "foo 2560 "); + DoDoubleTest("foo %.1G", val, "foo 3E+003", "foo 3E+03"); + DoDoubleTest("foo %.2G", val, "foo 2.6E+003", "foo 2.6E+03"); + DoDoubleTest("foo %.12G", val, "foo 2560.001", "foo 2560.001"); + DoDoubleTest("foo %06G", val, "foo 002560", "foo 002560"); + DoDoubleTest("foo %#G", val, "foo 2560.00", "foo 2560.00"); + DoDoubleTest("foo %+G", val, "foo +2560", "foo +2560"); + DoDoubleTest("foo % G", val, "foo 2560", "foo 2560"); + DoDoubleTest("foo %+G", neg, "foo -2560", "foo -2560"); + DoDoubleTest("foo % G", neg, "foo -2560", "foo -2560"); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/testinfo.dat new file mode 100644 index 0000000000..57aaed5953 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/testinfo.dat @@ -0,0 +1,14 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = C Runtime +Function = _vsnprintf +Name = Positive Test for _vsnprintf +TYPE = DEFAULT +EXE1 = test18 +Description += Tests the PAL implementation of the _vsnprintf function. += Tests _vsnprintf with compact format doubles (uppercase). += This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/CMakeLists.txt new file mode 100644 index 0000000000..44b38902ef --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test19.cpp +) + +add_executable(paltest_vsnprintf_test19 + ${SOURCES} +) + +add_dependencies(paltest_vsnprintf_test19 coreclrpal) + +target_link_libraries(paltest_vsnprintf_test19 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/test19.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/test19.cpp new file mode 100644 index 0000000000..6f2aefa94c --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/test19.cpp @@ -0,0 +1,103 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: test19.c +** +** Purpose: Test #19 for the _vsnprintf function. +** +** +**===================================================================*/ + +#include +#include "../_vsnprintf_s.h" + +/* + * Notes: memcmp is used, as is strlen. + */ + +#define DOTEST(a,b,c,d,e) DoTest(a,b,(void*)c,d,e) + +void DoArgumentPrecTest(char *formatstr, int precision, void *param, + char *paramstr, char *checkstr1, char *checkstr2) +{ + char buf[256]; + + Testvsnprintf(buf,256,formatstr, precision, param); + if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && + memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) + { + Fail("ERROR: failed to insert %s into \"%s\" with precision %d\n" + "Expected \"%s\" or \"%s\", got \"%s\".\n", + paramstr, formatstr, precision, checkstr1, checkstr2, buf); + } + +} + +void DoArgumentPrecDoubleTest(char *formatstr, int precision, double param, + char *checkstr1, char *checkstr2) +{ + char buf[256]; + + Testvsnprintf(buf,256,formatstr, precision, param); + if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && + memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) + { + Fail("ERROR: failed to insert %f into \"%s\" with precision %d\n" + "Expected \"%s\" or \"%s\", got \"%s\".\n", + param, formatstr, precision, checkstr1, checkstr2, buf); + } + +} + + + +int __cdecl main(int argc, char *argv[]) +{ + + if (PAL_Initialize(argc, argv) != 0) + { + return(FAIL); + } + + + DoArgumentPrecTest("%.*s", 2, (void*)"bar", "bar", "ba", "ba"); + DoArgumentPrecTest("%.*S", 2, (void*)convert("bar"), "bar", "ba", "ba"); + DoArgumentPrecTest("%.*c", 0, (void*)'a', "a", "a", "a"); + DoArgumentPrecTest("%.*c", 4, (void*)'a', "a", "a", "a"); + DoArgumentPrecTest("%.*C", 0, (void*)'a', "a", "a", "a"); + DoArgumentPrecTest("%.*C", 4, (void*)'a', "a", "a", "a"); + DoArgumentPrecTest("%.*d", 1, (void*)42, "42", "42", "42"); + DoArgumentPrecTest("%.*d", 3, (void*)42, "42", "042", "042"); + DoArgumentPrecTest("%.*i", 1, (void*)42, "42", "42", "42"); + DoArgumentPrecTest("%.*i", 3, (void*)42, "42", "042", "042"); + DoArgumentPrecTest("%.*o", 1, (void*)42, "42", "52", "52"); + DoArgumentPrecTest("%.*o", 3, (void*)42, "42", "052", "052"); + DoArgumentPrecTest("%.*u", 1, (void*)42, "42", "42", "42"); + DoArgumentPrecTest("%.*u", 3, (void*)42, "42", "042", "042"); + DoArgumentPrecTest("%.*x", 1, (void*)0x42, "0x42", "42", "42"); + DoArgumentPrecTest("%.*x", 3, (void*)0x42, "0x42", "042", "042"); + DoArgumentPrecTest("%.*X", 1, (void*)0x42, "0x42", "42", "42"); + DoArgumentPrecTest("%.*X", 3, (void*)0x42, "0x42", "042", "042"); + + + DoArgumentPrecDoubleTest("%.*e", 1, 2.01, "2.0e+000", "2.0e+00"); + DoArgumentPrecDoubleTest("%.*e", 3, 2.01, "2.010e+000", "2.010e+00"); + DoArgumentPrecDoubleTest("%.*E", 1, 2.01, "2.0E+000", "2.0E+00"); + DoArgumentPrecDoubleTest("%.*E", 3, 2.01, "2.010E+000", "2.010E+00"); + DoArgumentPrecDoubleTest("%.*f", 1, 2.01, "2.0", "2.0"); + DoArgumentPrecDoubleTest("%.*f", 3, 2.01, "2.010", "2.010"); + DoArgumentPrecDoubleTest("%.*g", 1, 256.01, "3e+002", "3e+02"); + DoArgumentPrecDoubleTest("%.*g", 3, 256.01, "256", "256"); + DoArgumentPrecDoubleTest("%.*g", 4, 256.01, "256", "256"); + DoArgumentPrecDoubleTest("%.*g", 6, 256.01, "256.01", "256.01"); + DoArgumentPrecDoubleTest("%.*G", 1, 256.01, "3E+002", "3E+02"); + DoArgumentPrecDoubleTest("%.*G", 3, 256.01, "256", "256"); + DoArgumentPrecDoubleTest("%.*G", 4, 256.01, "256", "256"); + DoArgumentPrecDoubleTest("%.*G", 6, 256.01, "256.01", "256.01"); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/testinfo.dat new file mode 100644 index 0000000000..cda8966865 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/testinfo.dat @@ -0,0 +1,14 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = C Runtime +Function = _vsnprintf +Name = Positive Test for _vsnprintf +TYPE = DEFAULT +EXE1 = test19 +Description += Tests the PAL implementation of the _vsnprintf function. += Tests _vsnprintf with argument specified precision. += This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/CMakeLists.txt new file mode 100644 index 0000000000..1d3910e70c --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test2.cpp +) + +add_executable(paltest_vsnprintf_test2 + ${SOURCES} +) + +add_dependencies(paltest_vsnprintf_test2 coreclrpal) + +target_link_libraries(paltest_vsnprintf_test2 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/test2.cpp new file mode 100644 index 0000000000..69c8c2723b --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/test2.cpp @@ -0,0 +1,44 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: test2.c +** +** Purpose: Test #2 for the _vsnprintf function. +** +** +**===================================================================*/ + +#include +#include "../_vsnprintf_s.h" +/* + * Notes: memcmp is used, as is strlen. + */ + +int __cdecl main(int argc, char *argv[]) +{ + WCHAR szwStr[] = {'b','a','r','\0'}; + + if (PAL_Initialize(argc, argv) != 0) + { + return(FAIL); + } + + DoStrTest("foo %s", "bar", "foo bar"); + DoStrTest("foo %hs", "bar", "foo bar"); + DoWStrTest("foo %ls", szwStr, "foo bar"); + DoWStrTest("foo %ws", szwStr, "foo bar"); + DoStrTest("foo %Ls", "bar", "foo bar"); + DoStrTest("foo %I64s", "bar", "foo bar"); + DoStrTest("foo %5s", "bar", "foo bar"); + DoStrTest("foo %.2s", "bar", "foo ba"); + DoStrTest("foo %5.2s", "bar", "foo ba"); + DoStrTest("foo %-5s", "bar", "foo bar "); + DoStrTest("foo %05s", "bar", "foo 00bar"); + + PAL_Terminate(); + return PASS; +} + diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/testinfo.dat new file mode 100644 index 0000000000..6e8f03e639 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/testinfo.dat @@ -0,0 +1,14 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = C Runtime +Function = _vsnprintf +Name = Positive Test for _vsnprintf +TYPE = DEFAULT +EXE1 = test2 +Description += Tests the PAL implementation of the _vsnprintf function. += Tests _vsnprintf with strings. += This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/CMakeLists.txt new file mode 100644 index 0000000000..62d765ec5f --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test3.cpp +) + +add_executable(paltest_vsnprintf_test3 + ${SOURCES} +) + +add_dependencies(paltest_vsnprintf_test3 coreclrpal) + +target_link_libraries(paltest_vsnprintf_test3 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/test3.cpp new file mode 100644 index 0000000000..a244aa44b6 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/test3.cpp @@ -0,0 +1,43 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: test3.c +** +** Purpose: Test #3 for the _vsnprintf function. +** +** +**===================================================================*/ + +#include +#include "../_vsnprintf_s.h" + +/* + * Notes: memcmp is used, as is strlen. + */ + +int __cdecl main(int argc, char *argv[]) +{ + + if (PAL_Initialize(argc, argv) != 0) + { + return(FAIL); + } + + DoWStrTest("foo %S", convert("bar"), "foo bar"); + DoStrTest("foo %hS", "bar", "foo bar"); + DoWStrTest("foo %lS", convert("bar"), "foo bar"); + DoWStrTest("foo %wS", convert("bar"), "foo bar"); + DoWStrTest("foo %LS", convert("bar"), "foo bar"); + DoWStrTest("foo %I64S", convert("bar"), "foo bar"); + DoWStrTest("foo %5S", convert("bar"), "foo bar"); + DoWStrTest("foo %.2S", convert("bar"), "foo ba"); + DoWStrTest("foo %5.2S", convert("bar"), "foo ba"); + DoWStrTest("foo %-5S", convert("bar"), "foo bar "); + DoWStrTest("foo %05S", convert("bar"), "foo 00bar"); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/testinfo.dat new file mode 100644 index 0000000000..638cef69ef --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/testinfo.dat @@ -0,0 +1,14 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = C Runtime +Function = _vsnprintf +Name = Positive Test for _vsnprintf +TYPE = DEFAULT +EXE1 = test3 +Description += Tests the PAL implementation of the _vsnprintf function. += Tests _vsnprintf with wide strings. += This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/CMakeLists.txt new file mode 100644 index 0000000000..5662bd57ad --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test4.cpp +) + +add_executable(paltest_vsnprintf_test4 + ${SOURCES} +) + +add_dependencies(paltest_vsnprintf_test4 coreclrpal) + +target_link_libraries(paltest_vsnprintf_test4 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/test4.cpp new file mode 100644 index 0000000000..0cf25cb88d --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/test4.cpp @@ -0,0 +1,98 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: test4.c +** +** Purpose: Test #4 for the _vsnprintf function. +** +** +**===================================================================*/ + +#include +#include "../_vsnprintf_s.h" + +/* + * Notes: memcmp is used, as is strlen. + */ + +static void DoPointerTest(char *formatstr, void* param, char* paramstr, + char *checkstr1) +{ + char buf[256] = { 0 }; + + Testvsnprintf(buf,256, formatstr, param); + if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) + { + Fail("ERROR: failed to insert %s into \"%s\"\n" + "Expected \"%s\" got \"%s\".\n", + paramstr, formatstr, checkstr1, buf); + } +} + +static void DoI64DoubleTest(char *formatstr, INT64 value, char *valuestr, char +*checkstr1) +{ + char buf[256] = { 0 }; + + Testvsnprintf(buf,256,formatstr, value); + if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) + { + Fail("ERROR: failed to insert %s into \"%s\"\n" + "Expected \"%s\", got \"%s\".\n", + valuestr, formatstr, checkstr1, buf); + } +} + +int __cdecl main(int argc, char *argv[]) +{ + void *ptr = (void*) 0x123456; + INT64 lptr = I64(0x1234567887654321); + + if (PAL_Initialize(argc, argv) != 0) + return(FAIL); + + + /* +** Run only on 64 bit platforms +*/ +#if defined(BIT64) && defined(PLATFORM_UNIX) + Trace("Testing for 64 Bit Platforms \n"); + DoPointerTest("%p", NULL, "NULL", "0000000000000000"); + DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456"); + DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); + DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); + DoPointerTest("%-17p", ptr, "pointer to 0x123456", "0000000000123456 "); + DoPointerTest("%+p", ptr, "pointer to 0x123456", "0000000000123456"); + DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X0000000000123456"); + DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); + DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); + DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); + DoI64DoubleTest("%I64p", lptr, "pointer to 0x1234567887654321", + "1234567887654321"); + +#else + Trace("Testing for Non 64 Bit Platforms \n"); + DoPointerTest("%p", NULL, "NULL", "00000000"); + DoPointerTest("%p", ptr, "pointer to 0x123456", "00123456"); + DoPointerTest("%9p", ptr, "pointer to 0x123456", " 00123456"); + DoPointerTest("%09p", ptr, "pointer to 0x123456", " 00123456"); + DoPointerTest("%-9p", ptr, "pointer to 0x123456", "00123456 "); + DoPointerTest("%+p", ptr, "pointer to 0x123456", "00123456"); + DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X00123456"); + DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); + DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); + DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); + DoI64DoubleTest("%I64p", lptr, "pointer to 0x1234567887654321", + "1234567887654321"); +#endif + + + + + PAL_Terminate(); + return PASS; +} + diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/testinfo.dat new file mode 100644 index 0000000000..03ff2931bc --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/testinfo.dat @@ -0,0 +1,14 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = C Runtime +Function = _vsnprintf +Name = Positive Test for _vsnprintf +TYPE = DEFAULT +EXE1 = test4 +Description += Tests the PAL implementation of the _vsnprintf function. += Tests _vsnprintf with pointers. += This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/CMakeLists.txt new file mode 100644 index 0000000000..d80d433c22 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test6.cpp +) + +add_executable(paltest_vsnprintf_test6 + ${SOURCES} +) + +add_dependencies(paltest_vsnprintf_test6 coreclrpal) + +target_link_libraries(paltest_vsnprintf_test6 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/test6.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/test6.cpp new file mode 100644 index 0000000000..cbcead88b5 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/test6.cpp @@ -0,0 +1,44 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: test6.c +** +** Purpose: Test #6 for the _vsnprintf function. +** +** +**===================================================================*/ + +#include +#include "../_vsnprintf_s.h" + +/* + * Notes: memcmp is used, as is strlen. + */ + +int __cdecl main(int argc, char *argv[]) +{ + WCHAR wc = (WCHAR) 'c'; + + if (PAL_Initialize(argc, argv) != 0) + { + return(FAIL); + } + + DoCharTest("foo %c", 'b', "foo b"); + DoCharTest("foo %hc", 'b', "foo b"); + DoWCharTest("foo %lc", wc, "foo c"); + DoCharTest("foo %Lc", 'b', "foo b"); + DoCharTest("foo %I64c", 'b', "foo b"); + DoCharTest("foo %5c", 'b', "foo b"); + DoCharTest("foo %.0c", 'b', "foo b"); + DoCharTest("foo %-5c", 'b', "foo b "); + DoCharTest("foo %05c", 'b', "foo 0000b"); + DoCharTest("foo % c", 'b', "foo b"); + DoCharTest("foo %#c", 'b', "foo b"); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/testinfo.dat new file mode 100644 index 0000000000..e375f9238d --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/testinfo.dat @@ -0,0 +1,14 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = C Runtime +Function = _vsnprintf +Name = Positive Test for _vsnprintf +TYPE = DEFAULT +EXE1 = test6 +Description += Tests the PAL implementation of the _vsnprintf function. += Tests _vsnprintf with characters. += This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/CMakeLists.txt new file mode 100644 index 0000000000..a1dc0a7c2c --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test7.cpp +) + +add_executable(paltest_vsnprintf_test7 + ${SOURCES} +) + +add_dependencies(paltest_vsnprintf_test7 coreclrpal) + +target_link_libraries(paltest_vsnprintf_test7 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/test7.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/test7.cpp new file mode 100644 index 0000000000..4843d27598 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/test7.cpp @@ -0,0 +1,44 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: test7.c +** +** Purpose: Test #7 for the _vsnprintf function. +** +** +**===================================================================*/ + +#include +#include "../_vsnprintf_s.h" +/* + * Notes: memcmp is used, as is strlen. + */ + + +int __cdecl main(int argc, char *argv[]) +{ + WCHAR wb = (WCHAR) 'b'; + + if (PAL_Initialize(argc, argv) != 0) + { + return(FAIL); + } + + DoWCharTest("foo %c", wb, "foo b"); + DoWCharTest("foo %hc", wb, "foo b"); + DoCharTest("foo %lc", 'c', "foo c"); + DoWCharTest("foo %Lc", wb, "foo b"); + DoWCharTest("foo %I64c", wb, "foo b"); + DoWCharTest("foo %5c", wb, "foo b"); + DoWCharTest("foo %.0c", wb, "foo b"); + DoWCharTest("foo %-5c", wb, "foo b "); + DoWCharTest("foo %05c", wb, "foo 0000b"); + DoWCharTest("foo % c", wb, "foo b"); + DoWCharTest("foo %#c", wb, "foo b"); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/testinfo.dat new file mode 100644 index 0000000000..09eb481b59 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/testinfo.dat @@ -0,0 +1,14 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = C Runtime +Function = _vsnprintf +Name = Positive Test for _vsnprintf +TYPE = DEFAULT +EXE1 = test7 +Description += Tests the PAL implementation of the _vsnprintf function. += Tests _vsnprintf with wide characters. += This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/CMakeLists.txt new file mode 100644 index 0000000000..1ca4732492 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test8.cpp +) + +add_executable(paltest_vsnprintf_test8 + ${SOURCES} +) + +add_dependencies(paltest_vsnprintf_test8 coreclrpal) + +target_link_libraries(paltest_vsnprintf_test8 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/test8.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/test8.cpp new file mode 100644 index 0000000000..8021a797c8 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/test8.cpp @@ -0,0 +1,52 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: test8.c +** +** Purpose: Test #8 for the _vsnprintf function. +** +** +**===================================================================*/ + +#include +#include "../_vsnprintf_s.h" + +/* + * Notes: memcmp is used, as is strlen. + */ + + +int __cdecl main(int argc, char *argv[]) +{ + int neg = -42; + int pos = 42; + INT64 l = 42; + + if (PAL_Initialize(argc, argv) != 0) + { + return(FAIL); + } + + DoNumTest("foo %d", pos, "foo 42"); + DoNumTest("foo %ld", 0xFFFF, "foo 65535"); + DoNumTest("foo %hd", 0xFFFF, "foo -1"); + DoNumTest("foo %Ld", pos, "foo 42"); + DoI64Test("foo %I64d", l, "42", "foo 42"); + DoNumTest("foo %3d", pos, "foo 42"); + DoNumTest("foo %-3d", pos, "foo 42 "); + DoNumTest("foo %.1d", pos, "foo 42"); + DoNumTest("foo %.3d", pos, "foo 042"); + DoNumTest("foo %03d", pos, "foo 042"); + DoNumTest("foo %#d", pos, "foo 42"); + DoNumTest("foo %+d", pos, "foo +42"); + DoNumTest("foo % d", pos, "foo 42"); + DoNumTest("foo %+d", neg, "foo -42"); + DoNumTest("foo % d", neg, "foo -42"); + + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/testinfo.dat new file mode 100644 index 0000000000..1bdf411983 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/testinfo.dat @@ -0,0 +1,14 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = C Runtime +Function = _vsnprintf +Name = Positive Test for _vsnprintf +TYPE = DEFAULT +EXE1 = test8 +Description += Tests the PAL implementation of the _vsnprintf function. += Tests _vsnprintf with decimal numbers. += This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/CMakeLists.txt new file mode 100644 index 0000000000..583971fe5a --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test9.cpp +) + +add_executable(paltest_vsnprintf_test9 + ${SOURCES} +) + +add_dependencies(paltest_vsnprintf_test9 coreclrpal) + +target_link_libraries(paltest_vsnprintf_test9 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/test9.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/test9.cpp new file mode 100644 index 0000000000..d36846e401 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/test9.cpp @@ -0,0 +1,51 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: test9.c +** +** Purpose: Test #9 for the _vsnprintf function. +** +** +**===================================================================*/ + +#include +#include "../_vsnprintf_s.h" + +/* + * Notes: memcmp is used, as is strlen. + */ + + +int __cdecl main(int argc, char *argv[]) +{ + int neg = -42; + int pos = 42; + INT64 l = 42; + + if (PAL_Initialize(argc, argv) != 0) + { + return(FAIL); + } + + DoNumTest("foo %i", pos, "foo 42"); + DoNumTest("foo %li", 0xFFFF, "foo 65535"); + DoNumTest("foo %hi", 0xFFFF, "foo -1"); + DoNumTest("foo %Li", pos, "foo 42"); + DoI64Test("foo %I64i", l, "42", "foo 42"); + DoNumTest("foo %3i", pos, "foo 42"); + DoNumTest("foo %-3i", pos, "foo 42 "); + DoNumTest("foo %.1i", pos, "foo 42"); + DoNumTest("foo %.3i", pos, "foo 042"); + DoNumTest("foo %03i", pos, "foo 042"); + DoNumTest("foo %#i", pos, "foo 42"); + DoNumTest("foo %+i", pos, "foo +42"); + DoNumTest("foo % i", pos, "foo 42"); + DoNumTest("foo %+i", neg, "foo -42"); + DoNumTest("foo % i", neg, "foo -42"); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/testinfo.dat new file mode 100644 index 0000000000..bdaae87ce8 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/testinfo.dat @@ -0,0 +1,14 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = C Runtime +Function = _vsnprintf +Name = Positive Test for _vsnprintf +TYPE = DEFAULT +EXE1 = test9 +Description += Tests the PAL implementation of the _vsnprintf function. += Tests _vsnprintf with integer numbers. += This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/CMakeLists.txt index cafb9536b0..8fe1cb60ac 100644 --- a/src/pal/tests/palsuite/c_runtime/swprintf/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/swprintf/CMakeLists.txt @@ -14,7 +14,6 @@ add_subdirectory(test19) add_subdirectory(test2) add_subdirectory(test3) add_subdirectory(test4) -add_subdirectory(test5) add_subdirectory(test6) add_subdirectory(test7) add_subdirectory(test8) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/swprintf.h b/src/pal/tests/palsuite/c_runtime/swprintf/swprintf.h index 6f4c914a82..210b12ec7a 100644 --- a/src/pal/tests/palsuite/c_runtime/swprintf/swprintf.h +++ b/src/pal/tests/palsuite/c_runtime/swprintf/swprintf.h @@ -18,7 +18,7 @@ void DoWStrTest(const WCHAR *formatstr, WCHAR *param, const WCHAR *checkstr) { WCHAR buf[256] = { 0 }; - swprintf(buf, formatstr, param); + swprintf_s(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(checkstr) * 2 + 2) != 0) { @@ -33,7 +33,7 @@ void DoStrTest(const WCHAR *formatstr, char *param, const WCHAR *checkstr) { WCHAR buf[256] = { 0 }; - swprintf(buf, formatstr, param); + swprintf_s(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(checkstr) * 2 + 2) != 0) { @@ -48,7 +48,7 @@ void DoPointerTest(const WCHAR *formatstr, void* param, const WCHAR *checkstr1) { WCHAR buf[256] = { 0 }; - swprintf(buf, formatstr, param); + swprintf_s(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr1, wcslen(checkstr1)*2 + 2) != 0) { Fail("ERROR: failed to insert pointer to %#p into \"%s\"\n" @@ -57,51 +57,11 @@ void DoPointerTest(const WCHAR *formatstr, void* param, const WCHAR *checkstr1) } } -void DoCountTest(const WCHAR *formatstr, int param, const WCHAR *checkstr) -{ - WCHAR buf[512] = { 0 }; - int n = -1; - - swprintf(buf, formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %d\n", - param, n); - } - - if (memcmp(buf, checkstr, wcslen(checkstr)*2 + 2) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", - convertC(checkstr), convertC(buf)); - } -} - -void DoShortCountTest(const WCHAR *formatstr, int param, const WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - short int n = -1; - - swprintf(buf, formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %d\n", - param, n); - } - - if (memcmp(buf, checkstr, wcslen(checkstr)*2 + 2) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", - convertC(checkstr), convertC(buf)); - } -} - void DoCharTest(const WCHAR *formatstr, char param, const WCHAR *checkstr) { WCHAR buf[256] = { 0 }; - swprintf(buf, formatstr, param); + swprintf_s(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(checkstr)*2 + 2) != 0) { Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" @@ -114,7 +74,7 @@ void DoWCharTest(const WCHAR *formatstr, WCHAR param, const WCHAR *checkstr) { WCHAR buf[256] = { 0 }; - swprintf(buf, formatstr, param); + swprintf_s(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(checkstr)*2 + 2) != 0) { Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" @@ -127,7 +87,7 @@ void DoNumTest(const WCHAR *formatstr, int value, const WCHAR *checkstr) { WCHAR buf[256] = { 0 }; - swprintf(buf, formatstr, value); + swprintf_s(buf, _countof(buf), formatstr, value); if (memcmp(buf, checkstr, wcslen(checkstr)* 2 + 2) != 0) { Fail("ERROR: failed to insert %#x into \"%s\"\n" @@ -141,7 +101,7 @@ void DoI64Test(const WCHAR *formatstr, INT64 param, char *paramdesc, { WCHAR buf[256] = { 0 }; - swprintf(buf, formatstr, param); + swprintf_s(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr1, wcslen(checkstr1)*2 + 2) != 0) { Fail("ERROR: failed to insert %s into \"%s\"\n" @@ -155,7 +115,7 @@ void DoDoubleTest(const WCHAR *formatstr, double value, const WCHAR *checkstr1, { WCHAR buf[256] = { 0 }; - swprintf(buf, formatstr, value); + swprintf_s(buf, _countof(buf), formatstr, value); if (memcmp(buf, checkstr1, wcslen(checkstr1)*2 + 2) != 0 && memcmp(buf, checkstr2, wcslen(checkstr2)*2 + 2) != 0) { @@ -171,7 +131,7 @@ void DoArgumentPrecTest(const WCHAR *formatstr, int precision, void *param, { WCHAR buf[256]; - swprintf(buf, formatstr, precision, param); + swprintf_s(buf, _countof(buf), formatstr, precision, param); if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) { @@ -187,7 +147,7 @@ void DoArgumentPrecDoubleTest(const WCHAR *formatstr, int precision, double para { WCHAR buf[256]; - swprintf(buf, formatstr, precision, param); + swprintf_s(buf, _countof(buf), formatstr, precision, param); if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) { diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/swprintf/test1/test1.cpp index 626040d9f7..c47d7d5202 100644 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test1/test1.cpp +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test1/test1.cpp @@ -31,7 +31,7 @@ int __cdecl main(int argc, char *argv[]) } checkstr = convert("hello world"); - swprintf(buf, convert("hello world")); + swprintf_s(buf, _countof(buf), convert("hello world")); if (memcmp(checkstr, buf, wcslen(checkstr)*2+2) != 0) { diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test19/test19.cpp b/src/pal/tests/palsuite/c_runtime/swprintf/test19/test19.cpp index c0346036cd..0967bc8f4b 100644 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test19/test19.cpp +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test19/test19.cpp @@ -33,14 +33,6 @@ int __cdecl main(int argc, char *argv[]) convert("ba"), convert("ba")); DoArgumentPrecTest(convert("%.*S"), 2, (void*)"bar", "bar", convert("ba"), convert("ba")); - DoArgumentPrecTest(convert("%.*n"), 3, (void*)&n, "pointer to int", convert(""), - convert("")); - if (n != 0) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - 0, n); - } - DoArgumentPrecTest(convert("%.*c"), 0, (void*)'a', "a", convert("a"), convert("a")); DoArgumentPrecTest(convert("%.*c"), 4, (void*)'a', "a", convert("a"), diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test5/CMakeLists.txt deleted file mode 100644 index 967ccbb992..0000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test5/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_swprintf_test5 - ${SOURCES} -) - -add_dependencies(paltest_swprintf_test5 coreclrpal) - -target_link_libraries(paltest_swprintf_test5 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test5/test5.cpp b/src/pal/tests/palsuite/c_runtime/swprintf/test5/test5.cpp deleted file mode 100644 index e85adc120e..0000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test5/test5.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test5.c -** -** Purpose:Tests swprintf with the count specifier -** -** -**==========================================================================*/ - - - -#include -#include "../swprintf.h" - -/* - * Uses memcmp & wcslen - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR *longStr; - WCHAR *longResult; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - longStr = - convert("really-long-string-that-just-keeps-going-on-and-on-and-on.." - "..................useless-filler.................................." - "..................useless-filler.................................." - "..................useless-filler.................................." - "%n bar"); - longResult = - convert("really-long-string-that-just-keeps-going-on-and-on-and-on.." - "..................useless-filler.................................." - "..................useless-filler.................................." - "..................useless-filler.................................." - " bar"); - - DoCountTest(convert("foo %n bar"), 4, convert("foo bar")); - DoCountTest(longStr, 257, longResult); - DoCountTest(convert("fo%n bar"), 2, convert("fo bar")); - DoCountTest(convert("%n"), 0, convert("")); - DoCountTest(convert("foo %#n bar"), 4, convert("foo bar")); - DoCountTest(convert("foo % n bar"), 4, convert("foo bar")); - DoCountTest(convert("foo %+n bar"), 4, convert("foo bar")); - DoCountTest(convert("foo %-n bar"), 4, convert("foo bar")); - DoCountTest(convert("foo %0n bar"), 4, convert("foo bar")); - DoShortCountTest(convert("foo %hn bar"), 4, convert("foo bar")); - DoCountTest(convert("foo %ln bar"), 4, convert("foo bar")); - DoCountTest(convert("foo %Ln bar"), 4, convert("foo bar")); - DoCountTest(convert("foo %I64n bar"), 4, convert("foo bar")); - DoCountTest(convert("foo %20.3n bar"), 4, convert("foo bar")); - - PAL_Terminate(); - - free(longStr); - free(longResult); - - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test5/testinfo.dat deleted file mode 100644 index ef1f1ffc5a..0000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test5/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf -Name = Positive Test for swprintf -TYPE = DEFAULT -EXE1 = test5 -Description -= Tests swprintf with the count specifier diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vsprintf/CMakeLists.txt index cafb9536b0..8fe1cb60ac 100644 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/vsprintf/CMakeLists.txt @@ -14,7 +14,6 @@ add_subdirectory(test19) add_subdirectory(test2) add_subdirectory(test3) add_subdirectory(test4) -add_subdirectory(test5) add_subdirectory(test6) add_subdirectory(test7) add_subdirectory(test8) diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/vsprintf/test1/test1.cpp index 2007fefc5b..18c8c0ea1a 100644 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test1/test1.cpp +++ b/src/pal/tests/palsuite/c_runtime/vsprintf/test1/test1.cpp @@ -29,7 +29,7 @@ int __cdecl main(int argc, char *argv[]) return(FAIL); } - testvsp(buf, "hello world"); + testvsp(buf, _countof(buf), "hello world"); if (memcmp(checkstr, buf, strlen(checkstr)+1) != 0) { @@ -37,8 +37,8 @@ int __cdecl main(int argc, char *argv[]) checkstr, 256, buf); } - testvsp(buf, "xxxxxxxxxxxxxxxxx"); - ret = testvsp(buf, "hello world"); + testvsp(buf, _countof(buf), "xxxxxxxxxxxxxxxxx"); + ret = testvsp(buf, _countof(buf), "hello world"); if (ret != strlen(checkstr)) { diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vsprintf/test5/CMakeLists.txt deleted file mode 100644 index 6d14bf76bf..0000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test5/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_vsprintf_test5 - ${SOURCES} -) - -add_dependencies(paltest_vsprintf_test5 coreclrpal) - -target_link_libraries(paltest_vsprintf_test5 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test5/test5.cpp b/src/pal/tests/palsuite/c_runtime/vsprintf/test5/test5.cpp deleted file mode 100644 index e630d8863b..0000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/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. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test5.c -** -** Purpose: Test #5 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoTest("foo %n bar", 4, "foo bar"); - DoTest("foo %#n bar", 4, "foo bar"); - DoTest("foo % n bar", 4, "foo bar"); - DoTest("foo %+n bar", 4, "foo bar"); - DoTest("foo %-n bar", 4, "foo bar"); - DoTest("foo %0n bar", 4, "foo bar"); - DoShortTest("foo %hn bar", 4, "foo bar"); - DoTest("foo %ln bar", 4, "foo bar"); - DoTest("foo %Ln bar", 4, "foo bar"); - DoTest("foo %I64n bar", 4, "foo bar"); - DoTest("foo %20.3n bar", 4, "foo bar"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vsprintf/test5/testinfo.dat deleted file mode 100644 index 81748f88b9..0000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test5/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vsprintf -Name = Positive Test for vsprintf -TYPE = DEFAULT -EXE1 = test5 -Description -= Tests the PAL implementation of the vsprintf function. -= Tests vsprintf with the count specifier. -= This test is modeled after _snprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/vsprintf.h b/src/pal/tests/palsuite/c_runtime/vsprintf/vsprintf.h index 7b04a777ca..22bf53e53b 100644 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/vsprintf.h +++ b/src/pal/tests/palsuite/c_runtime/vsprintf/vsprintf.h @@ -14,13 +14,13 @@ #define __VSPRINTF_H__ /* These functions leaks memory like crazy. C'est la vie. */ -int testvsp(char* buf, const char* format, ...) +int testvsp(char* buf, size_t buffSize, const char* format, ...) { int retVal; va_list arglist; va_start(arglist, format); - retVal = vsprintf(buf, format, arglist); + retVal = _vsnprintf_s(buf, buffSize, _TRUNCATE, format, arglist); va_end(arglist); return (retVal); @@ -30,7 +30,7 @@ void DoStrTest(const char *formatstr, char* param, const char *checkstr) { char buf[256] = { 0 }; - testvsp(buf, formatstr, param); + testvsp(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) { Fail("ERROR: failed to insert string \"%s\" into \"%s\"\n" @@ -43,7 +43,7 @@ void DoWStrTest(const char *formatstr, WCHAR* param, const char *checkstr) { char buf[256] = { 0 }; - testvsp(buf, formatstr, param); + testvsp(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) { Fail("ERROR: failed to insert wide string \"%s\" into \"%s\"\n" @@ -57,7 +57,7 @@ void DoCharTest(const char *formatstr, char param, const char *checkstr) { char buf[256] = { 0 }; - testvsp(buf, formatstr, param); + testvsp(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) { Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" @@ -70,7 +70,7 @@ void DoWCharTest(const char *formatstr, WCHAR param, const char *checkstr) { char buf[256] = { 0 }; - testvsp(buf, formatstr, param); + testvsp(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) { Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" @@ -83,7 +83,7 @@ void DoNumTest(const char *formatstr, int value, const char *checkstr) { char buf[256] = { 0 }; - testvsp(buf, formatstr, value); + testvsp(buf, _countof(buf), formatstr, value); if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) { Fail("ERROR: failed to insert %#x into \"%s\"\n" @@ -96,7 +96,7 @@ void DoI64Test(const char *formatstr, INT64 value, char *valuestr, const char *c { char buf[256] = { 0 }; - testvsp(buf, formatstr, value); + testvsp(buf, _countof(buf), formatstr, value); if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) { Fail("ERROR: failed to insert %s into \"%s\"\n" @@ -109,7 +109,7 @@ void DoDoubleTest(const char *formatstr, double value, const char *checkstr1, ch { char buf[256] = { 0 }; - testvsp(buf, formatstr, value); + testvsp(buf, _countof(buf), formatstr, value); if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) { @@ -124,7 +124,7 @@ void DoArgumentPrecTest(const char *formatstr, int precision, void *param, { char buf[256]; - testvsp(buf, formatstr, precision, param); + testvsp(buf, _countof(buf), formatstr, precision, param); if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) { @@ -140,7 +140,7 @@ void DoArgumentPrecDoubleTest(const char *formatstr, int precision, double param { char buf[256]; - testvsp(buf, formatstr, precision, param); + testvsp(buf, _countof(buf), formatstr, precision, param); if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) { @@ -155,7 +155,7 @@ void DoPointerTest(const char *formatstr, void* param, char* paramstr, { char buf[256] = { 0 }; - testvsp(buf, formatstr, param); + testvsp(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr1, strlen(checkstr1) + 1)) { Fail("ERROR: failed to insert %s into \"%s\"\n" @@ -169,7 +169,7 @@ void DoI64DoubleTest(const char *formatstr, INT64 value, char *valuestr, { char buf[256] = { 0 }; - testvsp(buf, formatstr, value); + testvsp(buf, _countof(buf), formatstr, value); if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) { Fail("ERROR: failed to insert %s into \"%s\"\n" @@ -183,7 +183,7 @@ void DoTest(const char *formatstr, int param, const char *checkstr) char buf[256] = { 0 }; int n = -1; - testvsp(buf, formatstr, &n); + testvsp(buf, _countof(buf), formatstr, &n); if (n != param) { @@ -201,7 +201,7 @@ void DoShortTest(const char *formatstr, int param, const char *checkstr) char buf[256] = { 0 }; short int n = -1; - testvsp(buf, formatstr, &n); + testvsp(buf, _countof(buf), formatstr, &n); if (n != param) { diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vswprintf/CMakeLists.txt index cafb9536b0..8fe1cb60ac 100644 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/CMakeLists.txt +++ b/src/pal/tests/palsuite/c_runtime/vswprintf/CMakeLists.txt @@ -14,7 +14,6 @@ add_subdirectory(test19) add_subdirectory(test2) add_subdirectory(test3) add_subdirectory(test4) -add_subdirectory(test5) add_subdirectory(test6) add_subdirectory(test7) add_subdirectory(test8) diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test1/test1.cpp index d386ce104f..968f8a5c69 100644 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test1/test1.cpp +++ b/src/pal/tests/palsuite/c_runtime/vswprintf/test1/test1.cpp @@ -27,7 +27,7 @@ int __cdecl main(int argc, char *argv[]) return(FAIL); checkstr = convert("hello world"); - testvswp(buf, checkstr); + testvswp(buf, _countof(buf), checkstr); if (memcmp(checkstr, buf, wcslen(checkstr)*2+2) != 0) { diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test19/test19.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test19/test19.cpp index 1d1c5656b2..12f2b7ba99 100644 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test19/test19.cpp +++ b/src/pal/tests/palsuite/c_runtime/vswprintf/test19/test19.cpp @@ -24,7 +24,7 @@ void DoArgumentPrecTest(WCHAR *formatstr, int precision, void *param, { WCHAR buf[256]; - testvswp(buf, formatstr, precision, param); + testvswp(buf, _countof(buf), formatstr, precision, param); if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) { @@ -43,7 +43,7 @@ void DoArgumentPrecDoubleTest(WCHAR *formatstr, int precision, double param, { WCHAR buf[256]; - testvswp(buf, formatstr, precision, param); + testvswp(buf, _countof(buf), formatstr, precision, param); if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) { diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test4/test4.cpp index 5c9047b5a7..583cf0c849 100644 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test4/test4.cpp +++ b/src/pal/tests/palsuite/c_runtime/vswprintf/test4/test4.cpp @@ -21,7 +21,7 @@ static void DoPointerTest(WCHAR *formatstr, void* param, WCHAR* paramstr, { WCHAR buf[256] = { 0 }; - testvswp(buf, formatstr, param); + testvswp(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0) { @@ -39,7 +39,7 @@ static void DoI64DoubleTest(WCHAR *formatstr, INT64 value, WCHAR *valuestr, { WCHAR buf[256] = { 0 }; - testvswp(buf, formatstr, value); + testvswp(buf, _countof(buf), formatstr, value); if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0) { Fail("ERROR: failed to insert %s into \"%s\"\n" diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vswprintf/test5/CMakeLists.txt deleted file mode 100644 index 888ce27d22..0000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test5/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_vswprintf_test5 - ${SOURCES} -) - -add_dependencies(paltest_vswprintf_test5 coreclrpal) - -target_link_libraries(paltest_vswprintf_test5 - pthread - m - coreclrpal -) diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test5/test5.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test5/test5.cpp deleted file mode 100644 index 42146c8be7..0000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test5/test5.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test5.c -** -** Purpose: Test #5 for the vswprintf function. -** -** -**===================================================================*/ - -#include -#include "../vswprintf.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -static void DoTest(WCHAR *formatstr, int param, WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - int n = -1; - - testvswp(buf, formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %d\n", - param, n); - } - - if (memcmp(buf, checkstr, wcslen(buf)*2 + 2) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", - convertC(checkstr), convertC(buf)); - } -} - -static void DoShortTest(WCHAR *formatstr, int param, WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - short int n = -1; - - testvswp(buf, formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %d\n", - param, n); - } - - if (memcmp(buf, checkstr, wcslen(buf)*2 + 2) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", - convertC(checkstr), convertC(buf)); - } -} - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoTest(convert("foo %n bar"), 4, convert("foo bar")); - DoTest(convert("foo %#n bar"), 4, convert("foo bar")); - DoTest(convert("foo % n bar"), 4, convert("foo bar")); - DoTest(convert("foo %+n bar"), 4, convert("foo bar")); - DoTest(convert("foo %-n bar"), 4, convert("foo bar")); - DoTest(convert("foo %0n bar"), 4, convert("foo bar")); - DoShortTest(convert("foo %hn bar"), 4, convert("foo bar")); - DoTest(convert("foo %ln bar"), 4, convert("foo bar")); - DoTest(convert("foo %Ln bar"), 4, convert("foo bar")); - DoTest(convert("foo %I64n bar"), 4, convert("foo bar")); - DoTest(convert("foo %20.3n bar"), 4, convert("foo bar")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vswprintf/test5/testinfo.dat deleted file mode 100644 index 17ca0fd33b..0000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test5/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vswprintf -Name = Positive Test for vswprintf -TYPE = DEFAULT -EXE1 = test5 -Description -= Tests the PAL implementation of the vswprintf function. -= Tests vswprintf with the count specifier. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/vswprintf.h b/src/pal/tests/palsuite/c_runtime/vswprintf/vswprintf.h index 37a379212e..36895d207f 100644 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/vswprintf.h +++ b/src/pal/tests/palsuite/c_runtime/vswprintf/vswprintf.h @@ -15,13 +15,13 @@ #define __vswprintf_H__ /* These functions leaks memory like crazy. C'est la vie. */ -int testvswp(wchar_t* buf, const wchar_t* format, ...) +int testvswp(wchar_t* buf, size_t buffSize, const wchar_t* format, ...) { int retVal = 0; va_list arglist; va_start(arglist, format); - retVal = vswprintf(buf, format, arglist); + retVal = _vsnwprintf_s(buf, buffSize, _TRUNCATE, format, arglist); va_end(arglist); return( retVal); @@ -31,7 +31,7 @@ void DoWStrTest(const WCHAR *formatstr, WCHAR *param, const WCHAR *checkstr) { WCHAR buf[256] = { 0 }; - testvswp(buf, formatstr, param); + testvswp(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(buf) * 2 + 2) != 0) { @@ -46,7 +46,7 @@ void DoStrTest(const WCHAR *formatstr, char *param, const WCHAR *checkstr) { WCHAR buf[256] = { 0 }; - testvswp(buf, formatstr, param); + testvswp(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(buf) * 2 + 2) != 0) { @@ -61,7 +61,7 @@ void DoCharTest(const WCHAR *formatstr, char param, const WCHAR *checkstr) { WCHAR buf[256] = { 0 }; - testvswp(buf, formatstr, param); + testvswp(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(buf)*2 + 2) != 0) { Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" @@ -75,7 +75,7 @@ void DoWCharTest(const WCHAR *formatstr, WCHAR param, const WCHAR *checkstr) { WCHAR buf[256] = { 0 }; - testvswp(buf, formatstr, param); + testvswp(buf, _countof(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(buf)*2 + 2) != 0) { Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" @@ -89,7 +89,7 @@ void DoNumTest(const WCHAR *formatstr, int value, const WCHAR *checkstr) { WCHAR buf[256] = { 0 }; - testvswp(buf, formatstr, value); + testvswp(buf, _countof(buf), formatstr, value); if (memcmp(buf, checkstr, wcslen(buf)* 2 + 2) != 0) { Fail("ERROR: failed to insert %#x into \"%s\"\n" @@ -102,7 +102,7 @@ void DoI64NumTest(const WCHAR *formatstr, INT64 value, char *valuestr, const WCH { WCHAR buf[256] = { 0 }; - testvswp(buf, formatstr, value); + testvswp(buf, _countof(buf), formatstr, value); if (memcmp(buf, checkstr, wcslen(buf)* 2 + 2) != 0) { Fail("ERROR: failed to insert %s into \"%s\"\n" @@ -115,7 +115,7 @@ void DoDoubleTest(const WCHAR *formatstr, double value, const WCHAR *checkstr1, { WCHAR buf[256] = { 0 }; - testvswp(buf, formatstr, value); + testvswp(buf, _countof(buf), formatstr, value); if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) { diff --git a/src/pal/tests/palsuite/file_io/GetTempFileNameW/test1/GetTempFileNameW.cpp b/src/pal/tests/palsuite/file_io/GetTempFileNameW/test1/GetTempFileNameW.cpp index 43cda8f447..ebc4d25bcb 100644 --- a/src/pal/tests/palsuite/file_io/GetTempFileNameW/test1/GetTempFileNameW.cpp +++ b/src/pal/tests/palsuite/file_io/GetTempFileNameW/test1/GetTempFileNameW.cpp @@ -104,7 +104,7 @@ int __cdecl main(int argc, char *argv[]) } // now verify that it only used the first 3 characters of the prefix - swprintf(wTempString, convert("%s\\%s"), wPath, wPrefix); + swprintf_s(wTempString, _countof(wTempString), convert("%s\\%s"), wPath, wPrefix); if (memcmp(wTempString, wReturnedName, wcslen(wTempString)*sizeof(WCHAR)) == 0) { free (wPath); diff --git a/src/pal/tests/palsuite/paltestlist.txt b/src/pal/tests/palsuite/paltestlist.txt index 2cedca2b97..98b17fa6f9 100644 --- a/src/pal/tests/palsuite/paltestlist.txt +++ b/src/pal/tests/palsuite/paltestlist.txt @@ -210,7 +210,6 @@ c_runtime/swprintf/test18/paltest_swprintf_test18 c_runtime/swprintf/test19/paltest_swprintf_test19 c_runtime/swprintf/test3/paltest_swprintf_test3 c_runtime/swprintf/test4/paltest_swprintf_test4 -c_runtime/swprintf/test5/paltest_swprintf_test5 c_runtime/swprintf/test6/paltest_swprintf_test6 c_runtime/swprintf/test8/paltest_swprintf_test8 c_runtime/swprintf/test9/paltest_swprintf_test9 @@ -292,7 +291,6 @@ c_runtime/vsprintf/test19/paltest_vsprintf_test19 c_runtime/vsprintf/test2/paltest_vsprintf_test2 c_runtime/vsprintf/test3/paltest_vsprintf_test3 c_runtime/vsprintf/test4/paltest_vsprintf_test4 -c_runtime/vsprintf/test5/paltest_vsprintf_test5 c_runtime/vsprintf/test6/paltest_vsprintf_test6 c_runtime/vsprintf/test7/paltest_vsprintf_test7 c_runtime/vsprintf/test8/paltest_vsprintf_test8 @@ -310,7 +308,6 @@ c_runtime/vswprintf/test18/paltest_vswprintf_test18 c_runtime/vswprintf/test19/paltest_vswprintf_test19 c_runtime/vswprintf/test3/paltest_vswprintf_test3 c_runtime/vswprintf/test4/paltest_vswprintf_test4 -c_runtime/vswprintf/test5/paltest_vswprintf_test5 c_runtime/vswprintf/test6/paltest_vswprintf_test6 c_runtime/vswprintf/test8/paltest_vswprintf_test8 c_runtime/vswprintf/test9/paltest_vswprintf_test9 @@ -398,25 +395,24 @@ c_runtime/_snwprintf_s/test9/paltest_snwprintf_test9 c_runtime/_stricmp/test1/paltest_stricmp_test1 c_runtime/_strlwr/test1/paltest_strlwr_test1 c_runtime/_strnicmp/test1/paltest_strnicmp_test1 -c_runtime/_vsnprintf/test1/paltest_vsnprintf_test1 -c_runtime/_vsnprintf/test10/paltest_vsnprintf_test10 -c_runtime/_vsnprintf/test11/paltest_vsnprintf_test11 -c_runtime/_vsnprintf/test12/paltest_vsnprintf_test12 -c_runtime/_vsnprintf/test13/paltest_vsnprintf_test13 -c_runtime/_vsnprintf/test14/paltest_vsnprintf_test14 -c_runtime/_vsnprintf/test15/paltest_vsnprintf_test15 -c_runtime/_vsnprintf/test16/paltest_vsnprintf_test16 -c_runtime/_vsnprintf/test17/paltest_vsnprintf_test17 -c_runtime/_vsnprintf/test18/paltest_vsnprintf_test18 -c_runtime/_vsnprintf/test19/paltest_vsnprintf_test19 -c_runtime/_vsnprintf/test2/paltest_vsnprintf_test2 -c_runtime/_vsnprintf/test3/paltest_vsnprintf_test3 -c_runtime/_vsnprintf/test4/paltest_vsnprintf_test4 -c_runtime/_vsnprintf/test5/paltest_vsnprintf_test5 -c_runtime/_vsnprintf/test6/paltest_vsnprintf_test6 -c_runtime/_vsnprintf/test7/paltest_vsnprintf_test7 -c_runtime/_vsnprintf/test8/paltest_vsnprintf_test8 -c_runtime/_vsnprintf/test9/paltest_vsnprintf_test9 +c_runtime/_vsnprintf_s/test1/paltest_vsnprintf_test1 +c_runtime/_vsnprintf_s/test10/paltest_vsnprintf_test10 +c_runtime/_vsnprintf_s/test11/paltest_vsnprintf_test11 +c_runtime/_vsnprintf_s/test12/paltest_vsnprintf_test12 +c_runtime/_vsnprintf_s/test13/paltest_vsnprintf_test13 +c_runtime/_vsnprintf_s/test14/paltest_vsnprintf_test14 +c_runtime/_vsnprintf_s/test15/paltest_vsnprintf_test15 +c_runtime/_vsnprintf_s/test16/paltest_vsnprintf_test16 +c_runtime/_vsnprintf_s/test17/paltest_vsnprintf_test17 +c_runtime/_vsnprintf_s/test18/paltest_vsnprintf_test18 +c_runtime/_vsnprintf_s/test19/paltest_vsnprintf_test19 +c_runtime/_vsnprintf_s/test2/paltest_vsnprintf_test2 +c_runtime/_vsnprintf_s/test3/paltest_vsnprintf_test3 +c_runtime/_vsnprintf_s/test4/paltest_vsnprintf_test4 +c_runtime/_vsnprintf_s/test6/paltest_vsnprintf_test6 +c_runtime/_vsnprintf_s/test7/paltest_vsnprintf_test7 +c_runtime/_vsnprintf_s/test8/paltest_vsnprintf_test8 +c_runtime/_vsnprintf_s/test9/paltest_vsnprintf_test9 c_runtime/_vsnwprintf_s/test1/paltest_vsnwprintf_test1 c_runtime/_vsnwprintf_s/test10/paltest_vsnwprintf_test10 c_runtime/_vsnwprintf_s/test11/paltest_vsnwprintf_test11 diff --git a/src/pal/tests/palsuite/palverify.dat b/src/pal/tests/palsuite/palverify.dat index d6e113b670..1872313a94 100644 --- a/src/pal/tests/palsuite/palverify.dat +++ b/src/pal/tests/palsuite/palverify.dat @@ -66,25 +66,24 @@ c_runtime/_snwprintf_s/test19,1 c_runtime/_stricmp/test1,1 c_runtime/_strlwr/test1,1 c_runtime/_strnicmp/test1,1 -c_runtime/_vsnprintf/test1,1 -c_runtime/_vsnprintf/test2,1 -c_runtime/_vsnprintf/test3,1 -c_runtime/_vsnprintf/test4,1 -c_runtime/_vsnprintf/test5,1 -c_runtime/_vsnprintf/test6,1 -c_runtime/_vsnprintf/test7,1 -c_runtime/_vsnprintf/test8,1 -c_runtime/_vsnprintf/test9,1 -c_runtime/_vsnprintf/test10,1 -c_runtime/_vsnprintf/test11,1 -c_runtime/_vsnprintf/test12,1 -c_runtime/_vsnprintf/test13,1 -c_runtime/_vsnprintf/test14,1 -c_runtime/_vsnprintf/test15,1 -c_runtime/_vsnprintf/test16,1 -c_runtime/_vsnprintf/test17,1 -c_runtime/_vsnprintf/test18,1 -c_runtime/_vsnprintf/test19,1 +c_runtime/_vsnprintf_s/test1,1 +c_runtime/_vsnprintf_s/test2,1 +c_runtime/_vsnprintf_s/test3,1 +c_runtime/_vsnprintf_s/test4,1 +c_runtime/_vsnprintf_s/test6,1 +c_runtime/_vsnprintf_s/test7,1 +c_runtime/_vsnprintf_s/test8,1 +c_runtime/_vsnprintf_s/test9,1 +c_runtime/_vsnprintf_s/test10,1 +c_runtime/_vsnprintf_s/test11,1 +c_runtime/_vsnprintf_s/test12,1 +c_runtime/_vsnprintf_s/test13,1 +c_runtime/_vsnprintf_s/test14,1 +c_runtime/_vsnprintf_s/test15,1 +c_runtime/_vsnprintf_s/test16,1 +c_runtime/_vsnprintf_s/test17,1 +c_runtime/_vsnprintf_s/test18,1 +c_runtime/_vsnprintf_s/test19,1 c_runtime/_vsnwprintf_s/test1,1 c_runtime/_vsnwprintf_s/test2,1 c_runtime/_vsnwprintf_s/test3,1 diff --git a/src/palrt/coguid.cpp b/src/palrt/coguid.cpp index cd03dce591..6c1efd460a 100644 --- a/src/palrt/coguid.cpp +++ b/src/palrt/coguid.cpp @@ -17,7 +17,7 @@ STDAPI_(int) StringFromGUID2(REFGUID rguid, LPOLESTR lptsz, int cchMax) if (cchMax < 39) return 0; - return swprintf(lptsz, W("{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}"), + return swprintf_s(lptsz, cchMax, W("{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}"), rguid.Data1, rguid.Data2, rguid.Data3, rguid.Data4[0], rguid.Data4[1], rguid.Data4[2], rguid.Data4[3], diff --git a/src/utilcode/log.cpp b/src/utilcode/log.cpp index 0dc85527c0..c07ac8baff 100644 --- a/src/utilcode/log.cpp +++ b/src/utilcode/log.cpp @@ -325,7 +325,7 @@ VOID LogSpewAlwaysValist(const char *fmt, va_list args) needsPrefix = (fmt[strlen(fmt)-1] == '\n'); - int cCountWritten = _vsnprintf(&pBuffer[buflen], BUFFERSIZE-buflen, fmt, args ); + int cCountWritten = _vsnprintf_s(&pBuffer[buflen], BUFFERSIZE-buflen, _TRUNCATE, fmt, args ); pBuffer[BUFFERSIZE-1] = 0; if (cCountWritten < 0) { buflen = BUFFERSIZE - 1; diff --git a/src/utilcode/sstring.cpp b/src/utilcode/sstring.cpp index ce532d70f6..7c332e08c3 100644 --- a/src/utilcode/sstring.cpp +++ b/src/utilcode/sstring.cpp @@ -2107,7 +2107,7 @@ void SString::VPrintf(const CHAR *format, va_list args) else if (errno!=0 && errno!=EBADF && errno!=ERANGE) { - CONSISTENCY_CHECK_MSG(FALSE, "_vsnprintf failed. Potential globalization bug."); + CONSISTENCY_CHECK_MSG(FALSE, "_vsnprintf_s failed. Potential globalization bug."); ThrowHR(HRESULT_FROM_WIN32(ERROR_NO_UNICODE_TRANSLATION)); } } diff --git a/src/vm/multicorejit.cpp b/src/vm/multicorejit.cpp index 24154a81c7..7660fd1895 100644 --- a/src/vm/multicorejit.cpp +++ b/src/vm/multicorejit.cpp @@ -168,7 +168,7 @@ void _MulticoreJitTrace(const char * format, ...) int len; len = sprintf_s(buffer, _countof(buffer), "Mcj TID %04x: ", GetCurrentThreadId()); - len += _vsnprintf(buffer + len, _countof(buffer) - len, format, args); + len += _vsnprintf_s(buffer + len, _countof(buffer) - len, format, args); len += sprintf_s(buffer + len, _countof(buffer) - len, ", (time=%d ms)\r\n", GetTickCount() - s_startTick); OutputDebugStringA(buffer); -- cgit v1.2.3