pidgin: c2e5c6cc: Fix the initial parsing of args in the w...

datallah at pidgin.im datallah at pidgin.im
Mon Nov 24 22:45:32 EST 2008


-----------------------------------------------------------------
Revision: c2e5c6cc5feb732b79c07ae4dd8fa6bf02e05dd1
Ancestor: 2c953d945e8ab39ad778ed7ce41748dea0109113
Author: datallah at pidgin.im
Date: 2008-11-25T03:40:28
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/c2e5c6cc5feb732b79c07ae4dd8fa6bf02e05dd1

Modified files:
        pidgin/win32/winpidgin.c

ChangeLog: 

Fix the initial parsing of args in the win32 launcher to be more robust.
This should prevent stuff like "--login=blah at something-d.tld" from making the
debug console appear.
Fixes #7627

-------------- next part --------------
============================================================
--- pidgin/win32/winpidgin.c	2bb5593249622530331e64b00f604870888dda56
+++ pidgin/win32/winpidgin.c	d855fbe1ccacd0ca7448cb5570e2b565a1783e3b
@@ -621,9 +621,22 @@ WinMain (struct HINSTANCE__ *hInstance, 
 	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 @@ WinMain (struct HINSTANCE__ *hInstance, 
 	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 .. */


More information about the Commits mailing list