summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKWIML Upstream <kwrobot@kitware.com>2022-06-14 13:33:12 (GMT)
committerBrad King <brad.king@kitware.com>2022-06-14 14:43:13 (GMT)
commit2a233bb7540bac9f8ec648f8aafcaed45668f908 (patch)
treeccfd01b71bd75c528d6ecde44582e7224beff138
parentf171b651b46c99a9744c1fd3e1a8956dd0a667f0 (diff)
downloadCMake-2a233bb7540bac9f8ec648f8aafcaed45668f908.zip
CMake-2a233bb7540bac9f8ec648f8aafcaed45668f908.tar.gz
CMake-2a233bb7540bac9f8ec648f8aafcaed45668f908.tar.bz2
KWIML 2022-06-14 (7b9bd7fe)
Code extracted from: https://gitlab.kitware.com/utils/kwiml.git at commit 7b9bd7fe925396d06d3d9540b4863d6d2382661d (master). Upstream Shortlog ----------------- Brad King (2): 33c2acf1 test: Replace sprintf with snprintf 7b9bd7fe test: Avoid snprintf on MSVC before VS 2015
-rw-r--r--test/test_int_format.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/test/test_int_format.h b/test/test_int_format.h
index 2e0310c..e139bdb 100644
--- a/test/test_int_format.h
+++ b/test/test_int_format.h
@@ -24,6 +24,12 @@
# define STATIC_CAST(t,v) (t)(v)
#endif
+#if defined(_MSC_VER) && _MSC_VER < 1900
+# define SNPRINTF(buf, sz, fmt, x) sprintf(buf, fmt, x)
+#else
+# define SNPRINTF(buf, sz, fmt, x) snprintf(buf, sz, fmt, x)
+#endif
+
#define VALUE(T, U) STATIC_CAST(T, STATIC_CAST(U, 0xab) << ((sizeof(T)-1)<<3))
#define TEST_C_(C, V, PRI, T, U) \
@@ -48,7 +54,7 @@
{ \
T const x = VALUE(T, U); \
char const* str = STR; \
- sprintf(buf, "%" KWIML_INT_PRI##PRI, x); \
+ SNPRINTF(buf, sizeof(buf), "%" KWIML_INT_PRI##PRI, x); \
printf(LANG "KWIML_INT_PRI" #PRI ":" \
" expected [%s], got [%s]", str, buf); \
if(strcmp(str, buf) == 0) \