From 29ddb9f4d9570c14326dbed0378343d5cbe55ed1 Mon Sep 17 00:00:00 2001 From: Asher Baker Date: Mon, 2 Dec 2013 13:08:27 +0000 Subject: [PATCH] Fix spcomp compilation on OS X 10.9 Summary: 10.9's SDK changed strlcat and strlcmp to macros, which has broken lots of code. As they will always be available from the system (being BSD functions), just use the system ones there. tempnam has also been deprecated, refactoring spcomp to use it safely is quite a bit of work, and it's not critical, so just hacking around it with mkstemp. Test Plan: Compiled spcomp. Reviewers: dvander Differential Revision: https://phabricator.alliedmods.net/D3 --HG-- extra : rebase_source : 535b88f815727b186fa6a141036599651a60e334 --- sourcepawn/compiler/AMBuilder | 2 +- sourcepawn/compiler/sc1.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sourcepawn/compiler/AMBuilder b/sourcepawn/compiler/AMBuilder index 31ab6fd6..dac2bab9 100644 --- a/sourcepawn/compiler/AMBuilder +++ b/sourcepawn/compiler/AMBuilder @@ -18,7 +18,7 @@ elif compiler.cc.name == 'msvc': if AMBuild.target['platform'] == 'linux': compiler['CDEFINES'].extend(['LINUX', 'HAVE_STDINT_H', 'AMX_ANSIONLY', 'ENABLE_BINRELOC', '_GNU_SOURCE']) elif AMBuild.target['platform'] == 'darwin': - compiler['CDEFINES'].extend(['DARWIN', 'HAVE_STDINT_H', 'AMX_ANSIONLY', 'ENABLE_BINRELOC']) + compiler['CDEFINES'].extend(['DARWIN', 'HAVE_STDINT_H', 'AMX_ANSIONLY', 'ENABLE_BINRELOC', 'HAVE_SAFESTR']) extension = AMBuild.AddJob('spcomp') binary = Cpp.ExecutableBuilder('spcomp', AMBuild, extension, compiler) diff --git a/sourcepawn/compiler/sc1.c b/sourcepawn/compiler/sc1.c index 5d8dc850..cc7d1706 100644 --- a/sourcepawn/compiler/sc1.c +++ b/sourcepawn/compiler/sc1.c @@ -267,7 +267,9 @@ int pc_compile(int argc, char *argv[]) tname=NULL; sname=NULL; #else - tname=tempnam(NULL,"pawn"); + char buffer[] = P_tmpdir "/pawn.XXXXXX"; + close(mkstemp(buffer)); + tname=buffer; #endif ftmp=(FILE*)pc_createsrc(tname); for (fidx=0; (sname=get_sourcefile(fidx))!=NULL; fidx++) {