From a178d9563d829ef4627210ff00e4ebb9133763bd Mon Sep 17 00:00:00 2001 From: Kelly Wilson Date: Sat, 23 May 2009 14:59:04 -0600 Subject: [PATCH] Fix for mingw32 segfault --- bin/ldmd | 2 +- dmd/root/root.c | 2 +- dmd/statement.c | 4 ++++ dmd2/root.c | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/ldmd b/bin/ldmd index 5d95a34b..329f1847 100755 --- a/bin/ldmd +++ b/bin/ldmd @@ -1,4 +1,4 @@ -#! /usr/bin/env bash +#! /usr/bin/env sh # Default to 'ldc' next to this file LDC=`basename "$0"`/ldc diff --git a/dmd/root/root.c b/dmd/root/root.c index e607e95a..db2a88fd 100644 --- a/dmd/root/root.c +++ b/dmd/root/root.c @@ -1668,7 +1668,7 @@ void OutBuffer::align(unsigned size) // The compiler shipped with Visual Studio 2005 (and possible // other versions) does not support C99 printf format specfiers // such as %z and %j -#if _MSC_VER +#if _MSC_VER || __MINGW32__ using std::string; using std::wstring; diff --git a/dmd/statement.c b/dmd/statement.c index 78b3d078..f4e47ec7 100644 --- a/dmd/statement.c +++ b/dmd/statement.c @@ -1739,7 +1739,11 @@ Statement *ForeachStatement::semantic(Scope *sc) default: assert(0); } const char *r = (op == TOKforeach_reverse) ? "R" : ""; +#ifdef __MINGW32__ + int j = sprintf(fdname, "_aApply%s%.*s%lu", r, 2, fntab[flag], dim); +#else int j = sprintf(fdname, "_aApply%s%.*s%zu", r, 2, fntab[flag], dim); +#endif assert(j < sizeof(fdname)); //LDC: Build arguments. Arguments* args = new Arguments; diff --git a/dmd2/root.c b/dmd2/root.c index 43a87889..60b66402 100644 --- a/dmd2/root.c +++ b/dmd2/root.c @@ -1613,7 +1613,7 @@ void OutBuffer::align(unsigned size) // The compiler shipped with Visual Studio 2005 (and possible // other versions) does not support C99 printf format specfiers // such as %z and %j -#if _MSC_VER +#if _MSC_VER || __MINGW32__ using std::string; using std::wstring;