Use snprintf instead of sprintf if possible.

This commit is contained in:
Tsuda Kageyu
2013-05-01 14:54:17 +09:00
parent ffc7bcfef0
commit fbe329bb70
3 changed files with 56 additions and 21 deletions

View File

@ -84,13 +84,25 @@ if(NOT HAVE_STD_SHARED_PTR AND NOT HAVE_TR1_SHARED_PTR AND NOT HAVE_BOOST_SHARED
endif()
endif()
# Determine whether your compiler supports codecvt header.
check_cxx_source_compiles("
#include <codecvt>
int main() { std::codecvt_utf8_utf16<wchar_t> x; return 0; }
" HAVE_CODECVT)
# Determine whether your compiler supports some safer version of sprintf.
check_cxx_source_compiles("
#include <cstdio>
int main() { char buf[20]; snprintf(buf, 20, \"%d\", 1); return 0; }
" HAVE_SNPRINTF)
if(NOT HAVE_SNPRINTF)
check_cxx_source_compiles("
#include <cstdio>
int main() { char buf[20]; sprintf_s(buf, \"%d\", 1); return 0; }
" HAVE_SPRINTF_S)
endif()
# check for libz using the cmake supplied FindZLIB.cmake
find_package(ZLIB)
if(ZLIB_FOUND)