Introduction
Introduction Statistics Contact Development Disclaimer Help
tFix for incorrect getopt() usage under Win32 (argv[0] was the first argument, …
git clone git://src.adamsgaard.dk/vaccinewars
Log
Files
Refs
README
LICENSE
---
commit f9dd12e8900997767e53ab87f837c4162cfb78ea
parent b2248529c46658addd46efdc6f6a22f9449fcac0
Author: Ben Webb <[email protected]>
Date: Sat, 7 Jun 2003 17:48:28 +0000
Fix for incorrect getopt() usage under Win32 (argv[0] was the first argument,
rather than the executable name.)
Diffstat:
M src/winmain.c | 30 +++++++++++++++++++++++-------
1 file changed, 23 insertions(+), 7 deletions(-)
---
diff --git a/src/winmain.c b/src/winmain.c
t@@ -218,10 +218,29 @@ static gchar *GetWindowsLocale(void)
}
#endif /* ENABLE_NLS */
+/*
+ * Converts the passed lpszCmdParam WinMain-style command line into
+ * Unix-style (argc, argv) parameters (returned).
+ */
+void get_cmdline(const LPSTR lpszCmdParam, int *argc, gchar ***argv)
+{
+ gchar **split;
+ gchar *tmp_cmdline;
+
+ tmp_cmdline = g_strdup_printf("%s %s", PACKAGE, lpszCmdParam);
+ split = g_strsplit(tmp_cmdline, " ", 0);
+ *argc = 0;
+ while (split[*argc] && split[*argc][0]) {
+ (*argc)++;
+ }
+ *argv = split;
+ g_free(tmp_cmdline);
+}
+
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdParam, int nCmdShow)
{
- gchar **split;
+ gchar **argv;
int argc;
gboolean is_service;
gchar *modpath;
t@@ -267,12 +286,9 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrev…
"# informative messages resulting from configuration\n"
"# file processing and the like.\n\n"));
- split = g_strsplit(lpszCmdParam, " ", 0);
- argc = 0;
- while (split[argc] && split[argc][0])
- argc++;
+ get_cmdline(lpszCmdParam, &argc, &argv);
- cmdline = GeneralStartup(argc, split);
+ cmdline = GeneralStartup(argc, argv);
OpenLog();
SoundInit();
if (cmdline->version || cmdline->help) {
t@@ -358,7 +374,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevI…
FreeCmdLine(cmdline);
CloseLog();
LogFileEnd();
- g_strfreev(split);
+ g_strfreev(argv);
CloseHighScoreFile();
g_free(PidFile);
g_free(Log.File);
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.