changeset 24478:daefbf001774

Fix the initial parsing of args in the win32 launcher to be more robust. This should prevent stuff like "--login=blah@something-d.tld" from making the debug console appear. Fixes #7627
author Daniel Atallah <daniel.atallah@gmail.com>
date Tue, 25 Nov 2008 03:40:28 +0000
parents d70eb6304eae
children 64c5a37dcaea eb1bf40d6fd0 db23767c5b3f
files pidgin/win32/winpidgin.c
diffstat 1 files changed, 16 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/win32/winpidgin.c	Tue Nov 25 02:43:56 2008 +0000
+++ b/pidgin/win32/winpidgin.c	Tue Nov 25 03:40:28 2008 +0000
@@ -621,9 +621,22 @@
 	char *tmp;
 	int pidgin_argc = __argc;
 	char **pidgin_argv = __argv;
+	int i;
+	BOOL debug = FALSE, help = FALSE, version = FALSE, multiple = FALSE;
 
 	/* If debug or help or version flag used, create console for output */
-	if (strstr(lpszCmdLine, "-d") || strstr(lpszCmdLine, "-h") || strstr(lpszCmdLine, "-v")) {
+	for (i = 1; i < __argc; i++) {
+		if (strstr(__argv[i], "-d") || strstr(__argv[i], "--debug"))
+			debug = TRUE;
+		else if (strstr(__argv[i], "-h") || strstr(__argv[i], "--help"))
+			help = TRUE;
+		else if (strstr(__argv[i], "-v") || strstr(__argv[i], "--version"))
+			version = TRUE;
+		else if (strstr(__argv[i], "-m") || strstr(__argv[i], "--multiple"))
+			multiple = TRUE;
+	}
+
+	if (debug || help || version) {
 		/* If stdout hasn't been redirected to a file, alloc a console
 		 *  (_istty() doesn't work for stuff using the GUI subsystem) */
 		if (_fileno(stdout) == -1 || _fileno(stdout) == -2) {
@@ -710,8 +723,8 @@
 	winpidgin_add_stuff_to_path();
 
 	/* If help, version or multiple flag used, do not check Mutex */
-	if (!strstr(lpszCmdLine, "-h") && !strstr(lpszCmdLine, "-v"))
-		if (!winpidgin_set_running(getenv("PIDGIN_MULTI_INST") == NULL && strstr(lpszCmdLine, "-m") == NULL))
+	if (!help && !version)
+		if (!winpidgin_set_running(getenv("PIDGIN_MULTI_INST") == NULL && !multiple))
 			return 0;
 
 	/* Now we are ready for Pidgin .. */