From 4adae8eaba27dfa9f06e111c11d59b80e3c2e0a5 Mon Sep 17 00:00:00 2001 From: Martin Date: Fri, 27 Feb 2015 21:42:13 +0100 Subject: [PATCH 1/2] Don't use MS-specific _vsnprintf, use standard vsnprintf instead. There's an alias in druntime and in MS stdio.h anyway. --- etc/c/zlib/gzguts.h | 4 +++- std/outbuffer.d | 2 +- std/stream.d | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/etc/c/zlib/gzguts.h b/etc/c/zlib/gzguts.h index 0f8fb79f87d..d1ff09216c6 100644 --- a/etc/c/zlib/gzguts.h +++ b/etc/c/zlib/gzguts.h @@ -33,7 +33,9 @@ #ifdef _MSC_VER # include -# define vsnprintf _vsnprintf +# if _MSC_VER < 1500 +# define vsnprintf _vsnprintf +# endif #endif #ifndef local diff --git a/std/outbuffer.d b/std/outbuffer.d index fb221f5f3a4..13c04e62cf0 100644 --- a/std/outbuffer.d +++ b/std/outbuffer.d @@ -271,7 +271,7 @@ class OutBuffer { version(Windows) { - count = _vsnprintf(p,psize,f,args); + count = vsnprintf(p,psize,f,args); if (count != -1) break; psize *= 2; diff --git a/std/stream.d b/std/stream.d index 0df106bc43f..f16b207cc44 100644 --- a/std/stream.d +++ b/std/stream.d @@ -1183,7 +1183,7 @@ class Stream : InputStream, OutputStream { version (LDC_X86_64) throw new Exception("unsupported platform"); else version (Windows) { - count = _vsnprintf(p, psize, f, args); + count = vsnprintf(p, psize, f, args); if (count != -1) break; psize *= 2; From dee61aca374e1baed55df58aae788be91cd893c7 Mon Sep 17 00:00:00 2001 From: Martin Date: Sun, 1 Mar 2015 15:02:11 +0100 Subject: [PATCH 2/2] Adapt some unit tests for MSVCRT 14 (VS 2015). --- std/conv.d | 7 ++++++- std/format.d | 9 ++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/std/conv.d b/std/conv.d index 8ce8ad6eef2..eff2facef61 100644 --- a/std/conv.d +++ b/std/conv.d @@ -2884,7 +2884,12 @@ unittest assert(s2.empty); x = *cast(longdouble *)&ld; version (Win64) - ld1 = 0x1.FFFFFFFFFFFFFFFEp-16382L; // strtold currently mapped to strtod + { + static if (real.mant_dig == 64) + ld1 = 0x1.FFFFFFFFFFFFFFFEp-16382L; // strtold currently mapped to strtod + else + ld1 = strtold(s.ptr, null); + } else ld1 = strtold(s.ptr, null); x1 = *cast(longdouble *)&ld1; diff --git a/std/format.d b/std/format.d index b8c43d10a8e..953e4674ba7 100644 --- a/std/format.d +++ b/std/format.d @@ -3423,7 +3423,8 @@ unittest } else version (Win64) { - assert(stream.data == "1.67 -0X1.47AE14P+0 nan", + assert(stream.data == "1.67 -0X1.47AE147AE147BP+0 nan" // MSVCRT 14+ (VS 2015) + || stream.data == "1.67 -0X1.47AE14P+0 nan", stream.data); } else @@ -3453,7 +3454,8 @@ unittest //formattedWrite(stream, "%x %X", 1.32); version (MinGW) { /+ LDC_FIXME: GitHub #383 +/ } else version (Win64) - assert(stream.data == "0x1.51eb85p+0 0X1.B1EB86P+2"); + assert(stream.data == "0x1.51eb851eb851fp+0 0X1.B1EB860000000P+2" // MSVCRT 14+ (VS 2015) + || stream.data == "0x1.51eb85p+0 0X1.B1EB86P+2"); else assert(stream.data == "0x1.51eb851eb851fp+0 0X1.B1EB86P+2"); stream.clear(); @@ -5973,7 +5975,8 @@ unittest version (MinGW) assert(s == "1.67 -0XA.3D70A3D70A3D8P-3 nan", s); else version (Win64) - assert(s == "1.67 -0X1.47AE14P+0 nan", s); + assert(s == "1.67 -0X1.47AE147AE147BP+0 nan" // MSVCRT 14+ (VS 2015) + || s == "1.67 -0X1.47AE14P+0 nan", s); else assert(s == "1.67 -0X1.47AE147AE147BP+0 nan", s);