From 9de9190859e8cfa398c2b614c459503a5cf9fe52 Mon Sep 17 00:00:00 2001 From: smartsgy Date: Sun, 1 Sep 2013 22:54:57 +0800 Subject: [PATCH] Fix minGW sprintf_s build error On windows, We should replace snprintf on msvc only. --- lib/ultrajsonenc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/ultrajsonenc.c b/lib/ultrajsonenc.c index 0bef1a4..8fb361c 100644 --- a/lib/ultrajsonenc.c +++ b/lib/ultrajsonenc.c @@ -51,6 +51,10 @@ http://www.opensource.apple.com/source/tcl/tcl-14/tcl/license.terms #define FALSE 0 #endif +#if ( (defined(_WIN32) || defined(WIN32) ) && ( defined(_MSC_VER) ) ) +#define snprintf sprintf_s +#endif + /* Worst cases being: @@ -573,11 +577,7 @@ int Buffer_AppendDoubleUnchecked(JSOBJ obj, JSONObjectEncoder *enc, double value */ if (value > thres_max) { -#ifdef _WIN32 - enc->offset += sprintf_s(str, enc->end - enc->offset, "%.15e", neg ? -value : value); -#else - enc->offset += snprintf(str, enc->end - enc->offset, "%.15e", neg ? -value : value); -#endif + enc->offset += snprintf(str, enc->end - enc->offset, "%.15e", neg ? -value : value); return TRUE; }