From 366e7c7e4b09096874d712696e79a913c17dd2c3 Mon Sep 17 00:00:00 2001 From: Philip Date: Fri, 21 Oct 2016 18:22:24 +0300 Subject: [PATCH] =?UTF-8?q?MS=20VS2015=20compilation=20fix.=20It=E2=80=99s?= =?UTF-8?q?=20better=20to=20use=20native=20Win32=20(strncpy=5Fs,=20sprintf?= =?UTF-8?q?=5Fs)=20to=20avoid=20compilation=20errors=20when=20building=20b?= =?UTF-8?q?y=20MS=20C++.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/crow/json.h | 5 +++++ include/crow/query_string.h | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/crow/json.h b/include/crow/json.h index 891fedfcb..35f9068da 100644 --- a/include/crow/json.h +++ b/include/crow/json.h @@ -1377,7 +1377,12 @@ namespace crow case type::Number: { char outbuf[128]; +#ifdef _MSC_VER + sprintf_s(outbuf, 128, "%g", v.d); +#else sprintf(outbuf, "%g", v.d); +#endif + out += outbuf; } break; diff --git a/include/crow/query_string.h b/include/crow/query_string.h index 3f8bffecd..edde0f62c 100644 --- a/include/crow/query_string.h +++ b/include/crow/query_string.h @@ -222,8 +222,12 @@ inline char * qs_scanvalue(const char * key, const char * qs, char * val, size_t { qs++; i = strcspn(qs, "&=#"); - strncpy(val, qs, (val_len-1)<(i+1) ? (val_len-1) : (i+1)); - qs_decode(val); +#ifdef _MSC_VER + strncpy_s(val, val_len, qs, (val_len - 1)<(i + 1) ? (val_len - 1) : (i + 1)); +#else + strncpy(val, qs, (val_len - 1)<(i + 1) ? (val_len - 1) : (i + 1)); +#endif + qs_decode(val); } else {