src/main/windows/SDL_windows_main.c
changeset 6672 b61791cd595a
parent 6430 48d519500f7e
child 6719 c250f633c040
     1.1 --- a/src/main/windows/SDL_windows_main.c	Fri Nov 09 08:48:23 2012 -0800
     1.2 +++ b/src/main/windows/SDL_windows_main.c	Sat Nov 10 10:37:38 2012 -0800
     1.3 @@ -146,22 +146,22 @@
     1.4  
     1.5  /* This is where execution begins [windowed apps] */
     1.6  int WINAPI
     1.7 -WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPTSTR szCmdLine, int sw)
     1.8 +WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
     1.9  {
    1.10      char **argv;
    1.11      int argc;
    1.12      char *cmdline;
    1.13 -    char *bufp;
    1.14 -    size_t nLen;
    1.15  
    1.16      /* Grab the command line */
    1.17 -    bufp = GetCommandLine();
    1.18 -    nLen = SDL_strlen(bufp) + 1;
    1.19 -    cmdline = SDL_stack_alloc(char, nLen);
    1.20 +    TCHAR *text = GetCommandLine();
    1.21 +#if UNICODE
    1.22 +    cmdline = SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char *)(text), (SDL_wcslen(text)+1)*sizeof(WCHAR));
    1.23 +#else
    1.24 +    cmdline = SDL_strdup(text);
    1.25 +#endif
    1.26      if (cmdline == NULL) {
    1.27          return OutOfMemory();
    1.28      }
    1.29 -    SDL_strlcpy(cmdline, bufp, nLen);
    1.30  
    1.31      /* Parse it into argv and argc */
    1.32      argc = ParseCommandLine(cmdline, NULL);
    1.33 @@ -174,6 +174,8 @@
    1.34      /* Run the main program */
    1.35      console_main(argc, argv);
    1.36  
    1.37 +    SDL_free(cmdline);
    1.38 +
    1.39      /* Hush little compiler, don't you cry... */
    1.40      return 0;
    1.41  }