Fixed command line parsing for applications defining UNICODE
This commit is contained in:
parent
1f8c1bd271
commit
414515401f
1 changed files with 9 additions and 7 deletions
|
@ -146,22 +146,22 @@ console_main(int argc, char *argv[])
|
||||||
|
|
||||||
/* This is where execution begins [windowed apps] */
|
/* This is where execution begins [windowed apps] */
|
||||||
int WINAPI
|
int WINAPI
|
||||||
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPTSTR szCmdLine, int sw)
|
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
|
||||||
{
|
{
|
||||||
char **argv;
|
char **argv;
|
||||||
int argc;
|
int argc;
|
||||||
char *cmdline;
|
char *cmdline;
|
||||||
char *bufp;
|
|
||||||
size_t nLen;
|
|
||||||
|
|
||||||
/* Grab the command line */
|
/* Grab the command line */
|
||||||
bufp = GetCommandLine();
|
TCHAR *text = GetCommandLine();
|
||||||
nLen = SDL_strlen(bufp) + 1;
|
#if UNICODE
|
||||||
cmdline = SDL_stack_alloc(char, nLen);
|
cmdline = SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char *)(text), (SDL_wcslen(text)+1)*sizeof(WCHAR));
|
||||||
|
#else
|
||||||
|
cmdline = SDL_strdup(text);
|
||||||
|
#endif
|
||||||
if (cmdline == NULL) {
|
if (cmdline == NULL) {
|
||||||
return OutOfMemory();
|
return OutOfMemory();
|
||||||
}
|
}
|
||||||
SDL_strlcpy(cmdline, bufp, nLen);
|
|
||||||
|
|
||||||
/* Parse it into argv and argc */
|
/* Parse it into argv and argc */
|
||||||
argc = ParseCommandLine(cmdline, NULL);
|
argc = ParseCommandLine(cmdline, NULL);
|
||||||
|
@ -174,6 +174,8 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPTSTR szCmdLine, int sw)
|
||||||
/* Run the main program */
|
/* Run the main program */
|
||||||
console_main(argc, argv);
|
console_main(argc, argv);
|
||||||
|
|
||||||
|
SDL_free(cmdline);
|
||||||
|
|
||||||
/* Hush little compiler, don't you cry... */
|
/* Hush little compiler, don't you cry... */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue