From d5ec5235844e7bd09fd1641b27f6190246d9e7ea Mon Sep 17 00:00:00 2001 From: Asher Baker Date: Fri, 5 Apr 2013 07:03:43 +0100 Subject: [PATCH] Support emscripten for compiling spcomp (r=dvander). --- sourcepawn/compiler/sc1.c | 6 ++++++ sourcepawn/compiler/sclinux.h | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/sourcepawn/compiler/sc1.c b/sourcepawn/compiler/sc1.c index 21eaa64a..1793a13f 100644 --- a/sourcepawn/compiler/sc1.c +++ b/sourcepawn/compiler/sc1.c @@ -613,8 +613,14 @@ static void inst_datetime_defines(void) time(&td); curtime = localtime(&td); + +#if defined EMSCRIPTEN + snprintf(date, sizeof(date), "\"%02d/%02d/%04d\"", curtime->tm_mon + 1, curtime->tm_mday, curtime->tm_year + 1900); + snprintf(ltime, sizeof(ltime), "\"%02d:%02d:%02d\"", curtime->tm_hour, curtime->tm_min, curtime->tm_sec); +#else strftime(date, 31, "\"%m/%d/%Y\"", curtime); strftime(ltime, 31, "\"%H:%M:%S\"", curtime); +#endif insert_subst("__DATE__", date, 8); insert_subst("__TIME__", ltime, 8); diff --git a/sourcepawn/compiler/sclinux.h b/sourcepawn/compiler/sclinux.h index a3b15b4b..1ec9405c 100644 --- a/sourcepawn/compiler/sclinux.h +++ b/sourcepawn/compiler/sclinux.h @@ -16,8 +16,6 @@ */ #include "getch.h" -#define strnicmp(a,b,c) strncasecmp(a,b,c) - /* * WinWorld wants '\'. Unices do not. */ @@ -30,7 +28,11 @@ * For Linux, we must overrule these settings with those defined in glibc. */ #if !defined __BYTE_ORDER -# include +# if defined EMSCRIPTEN +# include +# else +# include +# endif #endif #if defined __OpenBSD__ || defined __FreeBSD__ || defined __APPLE__