Support emscripten for compiling spcomp (r=dvander).
Support emscripten for compiling spcomp (r=dvander).
1.1 --- a/sourcepawn/compiler/sc1.c Wed Apr 03 12:26:08 2013 -0400
1.2 +++ b/sourcepawn/compiler/sc1.c Fri Apr 05 07:03:43 2013 +0100
1.3 @@ -613,8 +613,14 @@
1.4
1.5 time(&td);
1.6 curtime = localtime(&td);
1.7 +
1.8 +#if defined EMSCRIPTEN
1.9 + snprintf(date, sizeof(date), "\"%02d/%02d/%04d\"", curtime->tm_mon + 1, curtime->tm_mday, curtime->tm_year + 1900);
1.10 + snprintf(ltime, sizeof(ltime), "\"%02d:%02d:%02d\"", curtime->tm_hour, curtime->tm_min, curtime->tm_sec);
1.11 +#else
1.12 strftime(date, 31, "\"%m/%d/%Y\"", curtime);
1.13 strftime(ltime, 31, "\"%H:%M:%S\"", curtime);
1.14 +#endif
1.15
1.16 insert_subst("__DATE__", date, 8);
1.17 insert_subst("__TIME__", ltime, 8);
2.1 --- a/sourcepawn/compiler/sclinux.h Wed Apr 03 12:26:08 2013 -0400
2.2 +++ b/sourcepawn/compiler/sclinux.h Fri Apr 05 07:03:43 2013 +0100
2.3 @@ -16,8 +16,6 @@
2.4 */
2.5 #include "getch.h"
2.6
2.7 -#define strnicmp(a,b,c) strncasecmp(a,b,c)
2.8 -
2.9 /*
2.10 * WinWorld wants '\'. Unices do not.
2.11 */
2.12 @@ -30,7 +28,11 @@
2.13 * For Linux, we must overrule these settings with those defined in glibc.
2.14 */
2.15 #if !defined __BYTE_ORDER
2.16 -# include <stdlib.h>
2.17 +# if defined EMSCRIPTEN
2.18 +# include <endian.h>
2.19 +# else
2.20 +# include <stdlib.h>
2.21 +# endif
2.22 #endif
2.23
2.24 #if defined __OpenBSD__ || defined __FreeBSD__ || defined __APPLE__