mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 07:21:58 +00:00
SDL2: rebuilt for Windows from SDL2-hg-r12978 to test upcoming v2.0.11.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1616 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
9c34c2dec9
commit
eca65d118a
14 changed files with 36 additions and 132 deletions
|
@ -130,6 +130,8 @@
|
|||
#define HAVE_SYSCONF 1
|
||||
#define HAVE_SYSCTLBYNAME 1
|
||||
|
||||
#define HAVE_GCC_ATOMICS 1
|
||||
|
||||
/* Enable various audio drivers */
|
||||
#define SDL_AUDIO_DRIVER_COREAUDIO 1
|
||||
#define SDL_AUDIO_DRIVER_DISK 1
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#define SDL_REVISION "hg-12927:abb47c384db3"
|
||||
#define SDL_REVISION_NUMBER 12927
|
||||
#define SDL_REVISION "hg-12978:d2e027c5a389"
|
||||
#define SDL_REVISION_NUMBER 12978
|
||||
|
|
|
@ -415,6 +415,7 @@ extern DECLSPEC void *SDLCALL SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c,
|
|||
|
||||
#define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x)))
|
||||
#define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x)))
|
||||
#define SDL_zeroa(x) SDL_memset((x), 0, sizeof((x)))
|
||||
|
||||
/* Note that memset() is a byte assignment and this is a 32-bit assignment, so they're not directly equivalent. */
|
||||
SDL_FORCE_INLINE void SDL_memset4(void *dst, Uint32 val, size_t dwords)
|
||||
|
|
Binary file not shown.
|
@ -130,6 +130,8 @@
|
|||
#define HAVE_SYSCONF 1
|
||||
#define HAVE_SYSCTLBYNAME 1
|
||||
|
||||
#define HAVE_GCC_ATOMICS 1
|
||||
|
||||
/* Enable various audio drivers */
|
||||
#define SDL_AUDIO_DRIVER_COREAUDIO 1
|
||||
#define SDL_AUDIO_DRIVER_DISK 1
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#define SDL_REVISION "hg-12919:d3a97780aa05"
|
||||
#define SDL_REVISION_NUMBER 12919
|
||||
#define SDL_REVISION "hg-12978:d2e027c5a389"
|
||||
#define SDL_REVISION_NUMBER 12978
|
||||
|
|
|
@ -415,6 +415,7 @@ extern DECLSPEC void *SDLCALL SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c,
|
|||
|
||||
#define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x)))
|
||||
#define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x)))
|
||||
#define SDL_zeroa(x) SDL_memset((x), 0, sizeof((x)))
|
||||
|
||||
/* Note that memset() is a byte assignment and this is a 32-bit assignment, so they're not directly equivalent. */
|
||||
SDL_FORCE_INLINE void SDL_memset4(void *dst, Uint32 val, size_t dwords)
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -8,8 +8,8 @@
|
|||
#ifdef __WIN32__
|
||||
|
||||
/* Include this so we define UNICODE properly */
|
||||
/*#include "../../core/windows/SDL_windows.h"*/
|
||||
#include "SDL_windows.h" /* copied here from the SDL2 source tree */
|
||||
#include <shellapi.h> /* CommandLineToArgvW() */
|
||||
|
||||
/* Include the SDL main definition header */
|
||||
#include "SDL.h"
|
||||
|
@ -19,87 +19,7 @@
|
|||
# undef main
|
||||
#endif /* main */
|
||||
|
||||
static void
|
||||
UnEscapeQuotes(char *arg)
|
||||
{
|
||||
char *last = NULL;
|
||||
|
||||
while (*arg) {
|
||||
if (*arg == '"' && (last != NULL && *last == '\\')) {
|
||||
char *c_curr = arg;
|
||||
char *c_last = last;
|
||||
|
||||
while (*c_curr) {
|
||||
*c_last = *c_curr;
|
||||
c_last = c_curr;
|
||||
c_curr++;
|
||||
}
|
||||
*c_last = '\0';
|
||||
}
|
||||
last = arg;
|
||||
arg++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Parse a command line buffer into arguments */
|
||||
static int
|
||||
ParseCommandLine(char *cmdline, char **argv)
|
||||
{
|
||||
char *bufp;
|
||||
char *lastp = NULL;
|
||||
int argc, last_argc;
|
||||
|
||||
argc = last_argc = 0;
|
||||
for (bufp = cmdline; *bufp;) {
|
||||
/* Skip leading whitespace */
|
||||
while (*bufp == ' ' || *bufp == '\t') {
|
||||
++bufp;
|
||||
}
|
||||
/* Skip over argument */
|
||||
if (*bufp == '"') {
|
||||
++bufp;
|
||||
if (*bufp) {
|
||||
if (argv) {
|
||||
argv[argc] = bufp;
|
||||
}
|
||||
++argc;
|
||||
}
|
||||
/* Skip over word */
|
||||
lastp = bufp;
|
||||
while (*bufp && (*bufp != '"' || *lastp == '\\')) {
|
||||
lastp = bufp;
|
||||
++bufp;
|
||||
}
|
||||
} else {
|
||||
if (*bufp) {
|
||||
if (argv) {
|
||||
argv[argc] = bufp;
|
||||
}
|
||||
++argc;
|
||||
}
|
||||
/* Skip over word */
|
||||
while (*bufp && (*bufp != ' ' && *bufp != '\t')) {
|
||||
++bufp;
|
||||
}
|
||||
}
|
||||
if (*bufp) {
|
||||
if (argv) {
|
||||
*bufp = '\0';
|
||||
}
|
||||
++bufp;
|
||||
}
|
||||
|
||||
/* Strip out \ from \" sequences */
|
||||
if (argv && last_argc != argc) {
|
||||
UnEscapeQuotes(argv[last_argc]);
|
||||
}
|
||||
last_argc = argc;
|
||||
}
|
||||
if (argv) {
|
||||
argv[argc] = NULL;
|
||||
}
|
||||
return (argc);
|
||||
}
|
||||
#define WIN_WStringToUTF8(S) SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR))
|
||||
|
||||
/* Pop up an out of memory message, returns to Windows */
|
||||
static BOOL
|
||||
|
@ -120,65 +40,43 @@ OutOfMemory(void)
|
|||
/* Gets the arguments with GetCommandLine, converts them to argc and argv
|
||||
and calls SDL_main */
|
||||
static int
|
||||
main_getcmdline()
|
||||
main_getcmdline(void)
|
||||
{
|
||||
LPWSTR *argvw;
|
||||
char **argv;
|
||||
int argc;
|
||||
char *cmdline = NULL;
|
||||
int retval = 0;
|
||||
int cmdalloc = 0;
|
||||
const TCHAR *text = GetCommandLine();
|
||||
const TCHAR *ptr;
|
||||
int argc_guess = 2; /* space for NULL and initial argument. */
|
||||
int rc;
|
||||
int i, argc, result;
|
||||
|
||||
/* make a rough guess of command line arguments. Overestimates if there
|
||||
are quoted things. */
|
||||
for (ptr = text; *ptr; ptr++) {
|
||||
if ((*ptr == ' ') || (*ptr == '\t')) {
|
||||
argc_guess++;
|
||||
}
|
||||
}
|
||||
|
||||
#if UNICODE
|
||||
rc = WideCharToMultiByte(CP_UTF8, 0, text, -1, NULL, 0, NULL, NULL);
|
||||
if (rc > 0) {
|
||||
cmdalloc = rc + (sizeof (char *) * argc_guess);
|
||||
argv = (char **) VirtualAlloc(NULL, cmdalloc, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
|
||||
if (argv) {
|
||||
int rc2;
|
||||
cmdline = (char *) (argv + argc_guess);
|
||||
rc2 = WideCharToMultiByte(CP_UTF8, 0, text, -1, cmdline, rc, NULL, NULL);
|
||||
SDL_assert(rc2 == rc);
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* !!! FIXME: are these in the system codepage? We need to convert to UTF-8. */
|
||||
rc = ((int) SDL_strlen(text)) + 1;
|
||||
cmdalloc = rc + (sizeof (char *) * argc_guess);
|
||||
argv = (char **) VirtualAlloc(NULL, cmdalloc, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
|
||||
if (argv) {
|
||||
cmdline = (char *) (argv + argc_guess);
|
||||
SDL_strcpy(cmdline, text);
|
||||
}
|
||||
#endif
|
||||
if (cmdline == NULL) {
|
||||
argvw = CommandLineToArgvW(GetCommandLineW(), &argc);
|
||||
if (argvw == NULL) {
|
||||
return OutOfMemory();
|
||||
}
|
||||
|
||||
/* Parse it into argv and argc */
|
||||
SDL_assert(ParseCommandLine(cmdline, NULL) <= argc_guess);
|
||||
argc = ParseCommandLine(cmdline, argv);
|
||||
argv = (char **)SDL_calloc(argc + 1, sizeof(*argv));
|
||||
if (!argv) {
|
||||
return OutOfMemory();
|
||||
}
|
||||
for (i = 0; i < argc; ++i) {
|
||||
argv[i] = WIN_WStringToUTF8(argvw[i]);
|
||||
if (!argv[i]) {
|
||||
return OutOfMemory();
|
||||
}
|
||||
}
|
||||
argv[i] = NULL;
|
||||
LocalFree(argvw);
|
||||
|
||||
SDL_SetMainReady();
|
||||
|
||||
/* Run the application main() code */
|
||||
retval = SDL_main(argc, argv);
|
||||
result = SDL_main(argc, argv);
|
||||
|
||||
VirtualFree(argv, cmdalloc, MEM_DECOMMIT);
|
||||
VirtualFree(argv, 0, MEM_RELEASE);
|
||||
/* Free argv, to avoid memory leak */
|
||||
for (i = 0; i < argc; ++i) {
|
||||
SDL_free(argv[i]);
|
||||
}
|
||||
SDL_free(argv);
|
||||
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
/* This is where execution begins [console apps, ansi] */
|
||||
|
|
Loading…
Reference in a new issue