src/main/win32/SDL_win32_main.c
branchSDL-1.3
changeset 1662 782fd950bd46
parent 1659 14717b52abc0
child 1668 4da1ee79c9af
     1.1 --- a/src/main/win32/SDL_win32_main.c	Sun May 21 17:27:13 2006 +0000
     1.2 +++ b/src/main/win32/SDL_win32_main.c	Sun May 28 13:04:16 2006 +0000
     1.3 @@ -40,11 +40,11 @@
     1.4  
     1.5  #ifndef NO_STDIO_REDIRECT
     1.6  # ifdef _WIN32_WCE
     1.7 -  static wchar_t stdoutPath[MAX_PATH];
     1.8 -  static wchar_t stderrPath[MAX_PATH];
     1.9 +static wchar_t stdoutPath[MAX_PATH];
    1.10 +static wchar_t stderrPath[MAX_PATH];
    1.11  # else
    1.12 -  static char stdoutPath[MAX_PATH];
    1.13 -  static char stderrPath[MAX_PATH];
    1.14 +static char stdoutPath[MAX_PATH];
    1.15 +static char stderrPath[MAX_PATH];
    1.16  # endif
    1.17  #endif
    1.18  
    1.19 @@ -54,114 +54,119 @@
    1.20  #endif /* _WIN32_WCE < 300 */
    1.21  
    1.22  /* Parse a command line buffer into arguments */
    1.23 -static int ParseCommandLine(char *cmdline, char **argv)
    1.24 +static int
    1.25 +ParseCommandLine (char *cmdline, char **argv)
    1.26  {
    1.27 -	char *bufp;
    1.28 -	int argc;
    1.29 +    char *bufp;
    1.30 +    int argc;
    1.31  
    1.32 -	argc = 0;
    1.33 -	for ( bufp = cmdline; *bufp; ) {
    1.34 -		/* Skip leading whitespace */
    1.35 -		while ( isspace(*bufp) ) {
    1.36 -			++bufp;
    1.37 -		}
    1.38 -		/* Skip over argument */
    1.39 -		if ( *bufp == '"' ) {
    1.40 -			++bufp;
    1.41 -			if ( *bufp ) {
    1.42 -				if ( argv ) {
    1.43 -					argv[argc] = bufp;
    1.44 -				}
    1.45 -				++argc;
    1.46 -			}
    1.47 -			/* Skip over word */
    1.48 -			while ( *bufp && (*bufp != '"') ) {
    1.49 -				++bufp;
    1.50 -			}
    1.51 -		} else {
    1.52 -			if ( *bufp ) {
    1.53 -				if ( argv ) {
    1.54 -					argv[argc] = bufp;
    1.55 -				}
    1.56 -				++argc;
    1.57 -			}
    1.58 -			/* Skip over word */
    1.59 -			while ( *bufp && ! isspace(*bufp) ) {
    1.60 -				++bufp;
    1.61 -			}
    1.62 -		}
    1.63 -		if ( *bufp ) {
    1.64 -			if ( argv ) {
    1.65 -				*bufp = '\0';
    1.66 -			}
    1.67 -			++bufp;
    1.68 -		}
    1.69 -	}
    1.70 -	if ( argv ) {
    1.71 -		argv[argc] = NULL;
    1.72 -	}
    1.73 -	return(argc);
    1.74 +    argc = 0;
    1.75 +    for (bufp = cmdline; *bufp;) {
    1.76 +        /* Skip leading whitespace */
    1.77 +        while (isspace (*bufp)) {
    1.78 +            ++bufp;
    1.79 +        }
    1.80 +        /* Skip over argument */
    1.81 +        if (*bufp == '"') {
    1.82 +            ++bufp;
    1.83 +            if (*bufp) {
    1.84 +                if (argv) {
    1.85 +                    argv[argc] = bufp;
    1.86 +                }
    1.87 +                ++argc;
    1.88 +            }
    1.89 +            /* Skip over word */
    1.90 +            while (*bufp && (*bufp != '"')) {
    1.91 +                ++bufp;
    1.92 +            }
    1.93 +        } else {
    1.94 +            if (*bufp) {
    1.95 +                if (argv) {
    1.96 +                    argv[argc] = bufp;
    1.97 +                }
    1.98 +                ++argc;
    1.99 +            }
   1.100 +            /* Skip over word */
   1.101 +            while (*bufp && !isspace (*bufp)) {
   1.102 +                ++bufp;
   1.103 +            }
   1.104 +        }
   1.105 +        if (*bufp) {
   1.106 +            if (argv) {
   1.107 +                *bufp = '\0';
   1.108 +            }
   1.109 +            ++bufp;
   1.110 +        }
   1.111 +    }
   1.112 +    if (argv) {
   1.113 +        argv[argc] = NULL;
   1.114 +    }
   1.115 +    return (argc);
   1.116  }
   1.117  
   1.118  /* Show an error message */
   1.119 -static void ShowError(const char *title, const char *message)
   1.120 +static void
   1.121 +ShowError (const char *title, const char *message)
   1.122  {
   1.123  /* If USE_MESSAGEBOX is defined, you need to link with user32.lib */
   1.124  #ifdef USE_MESSAGEBOX
   1.125 -	MessageBox(NULL, message, title, MB_ICONEXCLAMATION|MB_OK);
   1.126 +    MessageBox (NULL, message, title, MB_ICONEXCLAMATION | MB_OK);
   1.127  #else
   1.128 -	fprintf(stderr, "%s: %s\n", title, message);
   1.129 +    fprintf (stderr, "%s: %s\n", title, message);
   1.130  #endif
   1.131  }
   1.132  
   1.133  /* Pop up an out of memory message, returns to Windows */
   1.134 -static BOOL OutOfMemory(void)
   1.135 +static BOOL
   1.136 +OutOfMemory (void)
   1.137  {
   1.138 -	ShowError("Fatal Error", "Out of memory - aborting");
   1.139 -	return FALSE;
   1.140 +    ShowError ("Fatal Error", "Out of memory - aborting");
   1.141 +    return FALSE;
   1.142  }
   1.143  
   1.144  /* SDL_Quit() shouldn't be used with atexit() directly because
   1.145     calling conventions may differ... */
   1.146 -static void cleanup(void)
   1.147 +static void
   1.148 +cleanup (void)
   1.149  {
   1.150 -	SDL_Quit();
   1.151 +    SDL_Quit ();
   1.152  }
   1.153  
   1.154  /* Remove the output files if there was no output written */
   1.155 -static void cleanup_output(void)
   1.156 +static void
   1.157 +cleanup_output (void)
   1.158  {
   1.159  #ifndef NO_STDIO_REDIRECT
   1.160 -	FILE *file;
   1.161 -	int empty;
   1.162 +    FILE *file;
   1.163 +    int empty;
   1.164  #endif
   1.165  
   1.166 -	/* Flush the output in case anything is queued */
   1.167 -	fclose(stdout);
   1.168 -	fclose(stderr);
   1.169 +    /* Flush the output in case anything is queued */
   1.170 +    fclose (stdout);
   1.171 +    fclose (stderr);
   1.172  
   1.173  #ifndef NO_STDIO_REDIRECT
   1.174 -	/* See if the files have any output in them */
   1.175 -	if ( stdoutPath[0] ) {
   1.176 -		file = fopen(stdoutPath, TEXT("rb"));
   1.177 -		if ( file ) {
   1.178 -			empty = (fgetc(file) == EOF) ? 1 : 0;
   1.179 -			fclose(file);
   1.180 -			if ( empty ) {
   1.181 -				remove(stdoutPath);
   1.182 -			}
   1.183 -		}
   1.184 -	}
   1.185 -	if ( stderrPath[0] ) {
   1.186 -		file = fopen(stderrPath, TEXT("rb"));
   1.187 -		if ( file ) {
   1.188 -			empty = (fgetc(file) == EOF) ? 1 : 0;
   1.189 -			fclose(file);
   1.190 -			if ( empty ) {
   1.191 -				remove(stderrPath);
   1.192 -			}
   1.193 -		}
   1.194 -	}
   1.195 +    /* See if the files have any output in them */
   1.196 +    if (stdoutPath[0]) {
   1.197 +        file = fopen (stdoutPath, TEXT ("rb"));
   1.198 +        if (file) {
   1.199 +            empty = (fgetc (file) == EOF) ? 1 : 0;
   1.200 +            fclose (file);
   1.201 +            if (empty) {
   1.202 +                remove (stdoutPath);
   1.203 +            }
   1.204 +        }
   1.205 +    }
   1.206 +    if (stderrPath[0]) {
   1.207 +        file = fopen (stderrPath, TEXT ("rb"));
   1.208 +        if (file) {
   1.209 +            empty = (fgetc (file) == EOF) ? 1 : 0;
   1.210 +            fclose (file);
   1.211 +            if (empty) {
   1.212 +                remove (stderrPath);
   1.213 +            }
   1.214 +        }
   1.215 +    }
   1.216  #endif
   1.217  }
   1.218  
   1.219 @@ -171,187 +176,194 @@
   1.220  #endif
   1.221  
   1.222  /* This is where execution begins [console apps] */
   1.223 -int console_main(int argc, char *argv[])
   1.224 +int
   1.225 +console_main (int argc, char *argv[])
   1.226  {
   1.227 -	size_t n;
   1.228 -	char *bufp, *appname;
   1.229 -	int status;
   1.230 +    size_t n;
   1.231 +    char *bufp, *appname;
   1.232 +    int status;
   1.233  
   1.234 -	/* Get the class name from argv[0] */
   1.235 -	appname = argv[0];
   1.236 -	if ( (bufp=SDL_strrchr(argv[0], '\\')) != NULL ) {
   1.237 -		appname = bufp+1;
   1.238 -	} else
   1.239 -	if ( (bufp=SDL_strrchr(argv[0], '/')) != NULL ) {
   1.240 -		appname = bufp+1;
   1.241 -	}
   1.242 +    /* Get the class name from argv[0] */
   1.243 +    appname = argv[0];
   1.244 +    if ((bufp = SDL_strrchr (argv[0], '\\')) != NULL) {
   1.245 +        appname = bufp + 1;
   1.246 +    } else if ((bufp = SDL_strrchr (argv[0], '/')) != NULL) {
   1.247 +        appname = bufp + 1;
   1.248 +    }
   1.249  
   1.250 -	if ( (bufp=SDL_strrchr(appname, '.')) == NULL )
   1.251 -		n = SDL_strlen(appname);
   1.252 -	else
   1.253 -		n = (bufp-appname);
   1.254 +    if ((bufp = SDL_strrchr (appname, '.')) == NULL)
   1.255 +        n = SDL_strlen (appname);
   1.256 +    else
   1.257 +        n = (bufp - appname);
   1.258  
   1.259 -	bufp = SDL_stack_alloc(char, n+1);
   1.260 -	if ( bufp == NULL ) {
   1.261 -		return OutOfMemory();
   1.262 -	}
   1.263 -	SDL_strlcpy(bufp, appname, n+1);
   1.264 -	appname = bufp;
   1.265 +    bufp = SDL_stack_alloc (char, n + 1);
   1.266 +    if (bufp == NULL) {
   1.267 +        return OutOfMemory ();
   1.268 +    }
   1.269 +    SDL_strlcpy (bufp, appname, n + 1);
   1.270 +    appname = bufp;
   1.271  
   1.272 -	/* Load SDL dynamic link library */
   1.273 -	if ( SDL_Init(SDL_INIT_NOPARACHUTE) < 0 ) {
   1.274 -		ShowError("WinMain() error", SDL_GetError());
   1.275 -		return(FALSE);
   1.276 -	}
   1.277 -	atexit(cleanup_output);
   1.278 -	atexit(cleanup);
   1.279 +    /* Load SDL dynamic link library */
   1.280 +    if (SDL_Init (SDL_INIT_NOPARACHUTE) < 0) {
   1.281 +        ShowError ("WinMain() error", SDL_GetError ());
   1.282 +        return (FALSE);
   1.283 +    }
   1.284 +    atexit (cleanup_output);
   1.285 +    atexit (cleanup);
   1.286  
   1.287 -	/* Sam:
   1.288 -	   We still need to pass in the application handle so that
   1.289 -	   DirectInput will initialize properly when SDL_RegisterApp()
   1.290 -	   is called later in the video initialization.
   1.291 -	 */
   1.292 -	SDL_SetModuleHandle(GetModuleHandle(NULL));
   1.293 +    /* Sam:
   1.294 +       We still need to pass in the application handle so that
   1.295 +       DirectInput will initialize properly when SDL_RegisterApp()
   1.296 +       is called later in the video initialization.
   1.297 +     */
   1.298 +    SDL_SetModuleHandle (GetModuleHandle (NULL));
   1.299  
   1.300 -	/* Run the application main() code */
   1.301 -	status = SDL_main(argc, argv);
   1.302 +    /* Run the application main() code */
   1.303 +    status = SDL_main (argc, argv);
   1.304  
   1.305 -	/* Exit cleanly, calling atexit() functions */
   1.306 -	exit(status);
   1.307 +    /* Exit cleanly, calling atexit() functions */
   1.308 +    exit (status);
   1.309  
   1.310 -	/* Hush little compiler, don't you cry... */
   1.311 -	return 0;
   1.312 +    /* Hush little compiler, don't you cry... */
   1.313 +    return 0;
   1.314  }
   1.315  
   1.316  /* This is where execution begins [windowed apps] */
   1.317  #ifdef _WIN32_WCE
   1.318 -int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPWSTR szCmdLine, int sw)
   1.319 +int WINAPI
   1.320 +WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPWSTR szCmdLine, int sw)
   1.321  #else
   1.322 -int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
   1.323 +int WINAPI
   1.324 +WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
   1.325  #endif
   1.326  {
   1.327 -	HINSTANCE handle;
   1.328 -	char **argv;
   1.329 -	int argc;
   1.330 -	char *cmdline;
   1.331 -	DWORD pathlen;
   1.332 +    HINSTANCE handle;
   1.333 +    char **argv;
   1.334 +    int argc;
   1.335 +    char *cmdline;
   1.336 +    DWORD pathlen;
   1.337  #ifdef _WIN32_WCE
   1.338 -	wchar_t path[MAX_PATH];
   1.339 +    wchar_t path[MAX_PATH];
   1.340  #else
   1.341 -	char path[MAX_PATH];
   1.342 +    char path[MAX_PATH];
   1.343  #endif
   1.344  #ifdef _WIN32_WCE
   1.345 -	wchar_t *bufp;
   1.346 -	int nLen;
   1.347 +    wchar_t *bufp;
   1.348 +    int nLen;
   1.349  #else
   1.350 -	char *bufp;
   1.351 -	size_t nLen;
   1.352 +    char *bufp;
   1.353 +    size_t nLen;
   1.354  #endif
   1.355  #ifndef NO_STDIO_REDIRECT
   1.356 -	FILE *newfp;
   1.357 +    FILE *newfp;
   1.358  #endif
   1.359  
   1.360 -	/* Start up DDHELP.EXE before opening any files, so DDHELP doesn't
   1.361 -	   keep them open.  This is a hack.. hopefully it will be fixed 
   1.362 -	   someday.  DDHELP.EXE starts up the first time DDRAW.DLL is loaded.
   1.363 -	 */
   1.364 -	handle = LoadLibrary(TEXT("DDRAW.DLL"));
   1.365 -	if ( handle != NULL ) {
   1.366 -		FreeLibrary(handle);
   1.367 -	}
   1.368 -
   1.369 +    /* Start up DDHELP.EXE before opening any files, so DDHELP doesn't
   1.370 +       keep them open.  This is a hack.. hopefully it will be fixed 
   1.371 +       someday.  DDHELP.EXE starts up the first time DDRAW.DLL is loaded.
   1.372 +     */
   1.373 +    handle = LoadLibrary (TEXT ("DDRAW.DLL"));
   1.374 +    if (handle != NULL) {
   1.375 +        FreeLibrary (handle);
   1.376 +    }
   1.377  #ifndef NO_STDIO_REDIRECT
   1.378 -	pathlen = GetModuleFileName(NULL, path, SDL_arraysize(path));
   1.379 -	while ( pathlen > 0 && path[pathlen] != '\\' ) {
   1.380 -		--pathlen;
   1.381 -	}
   1.382 -	path[pathlen] = '\0';
   1.383 +    pathlen = GetModuleFileName (NULL, path, SDL_arraysize (path));
   1.384 +    while (pathlen > 0 && path[pathlen] != '\\') {
   1.385 +        --pathlen;
   1.386 +    }
   1.387 +    path[pathlen] = '\0';
   1.388  
   1.389  #ifdef _WIN32_WCE
   1.390 -	wcsncpy( stdoutPath, path, SDL_arraysize(stdoutPath) );
   1.391 -	wcsncat( stdoutPath, DIR_SEPERATOR STDOUT_FILE, SDL_arraysize(stdoutPath) );
   1.392 +    wcsncpy (stdoutPath, path, SDL_arraysize (stdoutPath));
   1.393 +    wcsncat (stdoutPath, DIR_SEPERATOR STDOUT_FILE,
   1.394 +             SDL_arraysize (stdoutPath));
   1.395  #else
   1.396 -	SDL_strlcpy( stdoutPath, path, SDL_arraysize(stdoutPath) );
   1.397 -	SDL_strlcat( stdoutPath, DIR_SEPERATOR STDOUT_FILE, SDL_arraysize(stdoutPath) );
   1.398 +    SDL_strlcpy (stdoutPath, path, SDL_arraysize (stdoutPath));
   1.399 +    SDL_strlcat (stdoutPath, DIR_SEPERATOR STDOUT_FILE,
   1.400 +                 SDL_arraysize (stdoutPath));
   1.401  #endif
   1.402 -    
   1.403 -	/* Redirect standard input and standard output */
   1.404 -	newfp = freopen(stdoutPath, TEXT("w"), stdout);
   1.405 +
   1.406 +    /* Redirect standard input and standard output */
   1.407 +    newfp = freopen (stdoutPath, TEXT ("w"), stdout);
   1.408  
   1.409  #ifndef _WIN32_WCE
   1.410 -	if ( newfp == NULL ) {	/* This happens on NT */
   1.411 +    if (newfp == NULL) {        /* This happens on NT */
   1.412  #if !defined(stdout)
   1.413 -		stdout = fopen(stdoutPath, TEXT("w"));
   1.414 +        stdout = fopen (stdoutPath, TEXT ("w"));
   1.415  #else
   1.416 -		newfp = fopen(stdoutPath, TEXT("w"));
   1.417 -		if ( newfp ) {
   1.418 -			*stdout = *newfp;
   1.419 -		}
   1.420 +        newfp = fopen (stdoutPath, TEXT ("w"));
   1.421 +        if (newfp) {
   1.422 +            *stdout = *newfp;
   1.423 +        }
   1.424  #endif
   1.425 -	}
   1.426 +    }
   1.427  #endif /* _WIN32_WCE */
   1.428  
   1.429  #ifdef _WIN32_WCE
   1.430 -	wcsncpy( stderrPath, path, SDL_arraysize(stdoutPath) );
   1.431 -	wcsncat( stderrPath, DIR_SEPERATOR STDOUT_FILE, SDL_arraysize(stdoutPath) );
   1.432 +    wcsncpy (stderrPath, path, SDL_arraysize (stdoutPath));
   1.433 +    wcsncat (stderrPath, DIR_SEPERATOR STDOUT_FILE,
   1.434 +             SDL_arraysize (stdoutPath));
   1.435  #else
   1.436 -	SDL_strlcpy( stderrPath, path, SDL_arraysize(stderrPath) );
   1.437 -	SDL_strlcat( stderrPath, DIR_SEPERATOR STDERR_FILE, SDL_arraysize(stderrPath) );
   1.438 +    SDL_strlcpy (stderrPath, path, SDL_arraysize (stderrPath));
   1.439 +    SDL_strlcat (stderrPath, DIR_SEPERATOR STDERR_FILE,
   1.440 +                 SDL_arraysize (stderrPath));
   1.441  #endif
   1.442  
   1.443 -	newfp = freopen(stderrPath, TEXT("w"), stderr);
   1.444 +    newfp = freopen (stderrPath, TEXT ("w"), stderr);
   1.445  #ifndef _WIN32_WCE
   1.446 -	if ( newfp == NULL ) {	/* This happens on NT */
   1.447 +    if (newfp == NULL) {        /* This happens on NT */
   1.448  #if !defined(stderr)
   1.449 -		stderr = fopen(stderrPath, TEXT("w"));
   1.450 +        stderr = fopen (stderrPath, TEXT ("w"));
   1.451  #else
   1.452 -		newfp = fopen(stderrPath, TEXT("w"));
   1.453 -		if ( newfp ) {
   1.454 -			*stderr = *newfp;
   1.455 -		}
   1.456 +        newfp = fopen (stderrPath, TEXT ("w"));
   1.457 +        if (newfp) {
   1.458 +            *stderr = *newfp;
   1.459 +        }
   1.460  #endif
   1.461 -	}
   1.462 +    }
   1.463  #endif /* _WIN32_WCE */
   1.464  
   1.465 -	setvbuf(stdout, NULL, _IOLBF, BUFSIZ);	/* Line buffered */
   1.466 -	setbuf(stderr, NULL);			/* No buffering */
   1.467 +    setvbuf (stdout, NULL, _IOLBF, BUFSIZ);     /* Line buffered */
   1.468 +    setbuf (stderr, NULL);      /* No buffering */
   1.469  #endif /* !NO_STDIO_REDIRECT */
   1.470  
   1.471  #ifdef _WIN32_WCE
   1.472 -	nLen = wcslen(szCmdLine)+128+1;
   1.473 -	bufp = SDL_stack_alloc(wchar_t, nLen*2);
   1.474 -	wcscpy (bufp, TEXT("\""));
   1.475 -	GetModuleFileName(NULL, bufp+1, 128-3);
   1.476 -	wcscpy (bufp+wcslen(bufp), TEXT("\" "));
   1.477 -	wcsncpy(bufp+wcslen(bufp), szCmdLine,nLen-wcslen(bufp));
   1.478 -	nLen = wcslen(bufp)+1;
   1.479 -	cmdline = SDL_stack_alloc(char, nLen);
   1.480 -	if ( cmdline == NULL ) {
   1.481 -		return OutOfMemory();
   1.482 -	}
   1.483 -	WideCharToMultiByte(CP_ACP, 0, bufp, -1, cmdline, nLen, NULL, NULL);
   1.484 +    nLen = wcslen (szCmdLine) + 128 + 1;
   1.485 +    bufp = SDL_stack_alloc (wchar_t, nLen * 2);
   1.486 +    wcscpy (bufp, TEXT ("\""));
   1.487 +    GetModuleFileName (NULL, bufp + 1, 128 - 3);
   1.488 +    wcscpy (bufp + wcslen (bufp), TEXT ("\" "));
   1.489 +    wcsncpy (bufp + wcslen (bufp), szCmdLine, nLen - wcslen (bufp));
   1.490 +    nLen = wcslen (bufp) + 1;
   1.491 +    cmdline = SDL_stack_alloc (char, nLen);
   1.492 +    if (cmdline == NULL) {
   1.493 +        return OutOfMemory ();
   1.494 +    }
   1.495 +    WideCharToMultiByte (CP_ACP, 0, bufp, -1, cmdline, nLen, NULL, NULL);
   1.496  #else
   1.497 -	/* Grab the command line */
   1.498 -	bufp = GetCommandLine();
   1.499 -	nLen = SDL_strlen(bufp)+1;
   1.500 -	cmdline = SDL_stack_alloc(char, nLen);
   1.501 -	if ( cmdline == NULL ) {
   1.502 -		return OutOfMemory();
   1.503 -	}
   1.504 -	SDL_strlcpy(cmdline, bufp, nLen);
   1.505 +    /* Grab the command line */
   1.506 +    bufp = GetCommandLine ();
   1.507 +    nLen = SDL_strlen (bufp) + 1;
   1.508 +    cmdline = SDL_stack_alloc (char, nLen);
   1.509 +    if (cmdline == NULL) {
   1.510 +        return OutOfMemory ();
   1.511 +    }
   1.512 +    SDL_strlcpy (cmdline, bufp, nLen);
   1.513  #endif
   1.514  
   1.515 -	/* Parse it into argv and argc */
   1.516 -	argc = ParseCommandLine(cmdline, NULL);
   1.517 -	argv = SDL_stack_alloc(char*, argc+1);
   1.518 -	if ( argv == NULL ) {
   1.519 -		return OutOfMemory();
   1.520 -	}
   1.521 -	ParseCommandLine(cmdline, argv);
   1.522 +    /* Parse it into argv and argc */
   1.523 +    argc = ParseCommandLine (cmdline, NULL);
   1.524 +    argv = SDL_stack_alloc (char *, argc + 1);
   1.525 +    if (argv == NULL) {
   1.526 +        return OutOfMemory ();
   1.527 +    }
   1.528 +    ParseCommandLine (cmdline, argv);
   1.529  
   1.530 -	/* Run the main program (after a little SDL initialization) */
   1.531 -	console_main(argc, argv);
   1.532 +    /* Run the main program (after a little SDL initialization) */
   1.533 +    console_main (argc, argv);
   1.534  
   1.535 -	/* Hush little compiler, don't you cry... */
   1.536 -	return 0;
   1.537 +    /* Hush little compiler, don't you cry... */
   1.538 +    return 0;
   1.539  }
   1.540 +
   1.541 +/* vi: set ts=4 sw=4 expandtab: */