another console related fix

eric pouech eric.pouech at wanadoo.fr
Sat Nov 24 14:19:56 CST 2001


as Alexandre noticed, there way be issues in new console window startup
code when the program name starts with a digit
this should fix it
A+
-- 
---------------
Eric Pouech (http://perso.wanadoo.fr/eric.pouech/)
"The future will be better tomorrow", Vice President Dan Quayle
-------------- next part --------------
Name: constrt
ChangeLog: now passing event with --use-event to let programs starting with digits being run
GenDate: 2001/11/24 20:18:10 UTC
ModifiedFiles: win32/console.c programs/wineconsole/wineconsole.c
AddedFiles: 
===================================================================
RCS file: /usr/share/cvs/cvsroot/wine/wine/win32/console.c,v
retrieving revision 1.81
diff -u -u -r1.81 console.c
--- win32/console.c	2001/11/23 23:05:11	1.81
+++ win32/console.c	2001/11/24 20:16:30
@@ -85,14 +85,14 @@
     /* first try environment variable */
     if ((p = getenv("WINECONSOLE")) != NULL)
     {
-	if (snprintf(buffer, sizeof(buffer), "%s %d", p, hEvent) > 0 &&
+	if (snprintf(buffer, sizeof(buffer), "%s -- --use-event=%d", p, hEvent) > 0 &&
 	    CreateProcessA(NULL, buffer, NULL, NULL, TRUE, DETACHED_PROCESS, NULL, NULL, &si, &pi))
 	    goto succeed;
 	ERR("Couldn't launch Wine console from WINECONSOLE env var... trying default access\n");
     }
 
     /* then the regular installation dir */
-    if (snprintf(buffer, sizeof(buffer), "%s %d", BINDIR "/wineconsole", hEvent) > 0 &&
+    if (snprintf(buffer, sizeof(buffer), "%s -- --use-event=%d", BINDIR "/wineconsole", hEvent) > 0 &&
 	CreateProcessA(NULL, buffer, NULL, NULL, TRUE, DETACHED_PROCESS, NULL, NULL, &si, &pi))
 	goto succeed;
 
@@ -104,10 +104,10 @@
 	if ((p = strrchr(strcpy( path, full_argv0 ), '/')))
 	{
 	    p++;
-	    sprintf(p, "wineconsole %d", hEvent);
+	    sprintf(p, "wineconsole -- --use-event=%d", hEvent);
 	    if (CreateProcessA(NULL, path, NULL, NULL, TRUE, DETACHED_PROCESS, NULL, NULL, &si, &pi))
 		goto succeed;
-	    sprintf(p, "programs/wineconsole/wineconsole %d", hEvent);
+	    sprintf(p, "programs/wineconsole/wineconsole -- --use-event=%d", hEvent);
 	    if (CreateProcessA(NULL, path, NULL, NULL, TRUE, DETACHED_PROCESS, NULL, NULL, &si, &pi))
 		goto succeed;
 	}
@@ -127,10 +127,10 @@
 	    if ((p = strrchr(path, '/')))
 	    {
 		p++;
-		sprintf(p, "wineconsole %d", hEvent);
+		sprintf(p, "wineconsole -- --use-event=%d", hEvent);
 		if (CreateProcessA(NULL, path, NULL, NULL, TRUE, DETACHED_PROCESS, NULL, NULL, &si, &pi))
 		    goto succeed;
-		sprintf(p, "programs/wineconsole/wineconsole %d", hEvent);
+		sprintf(p, "programs/wineconsole/wineconsole -- --use-event=%d", hEvent);
 		if (CreateProcessA(NULL, path, NULL, NULL, TRUE, DETACHED_PROCESS, NULL, NULL, &si, &pi))
 		    goto succeed;
 	    }
@@ -140,7 +140,7 @@
     }
 	
     /* then try the regular PATH */
-    sprintf(buffer, "wineconsole %d\n", hEvent);
+    sprintf(buffer, "wineconsole -- --use-event=%d\n", hEvent);
     if (CreateProcessA(NULL, buffer, NULL, NULL, TRUE, DETACHED_PROCESS, NULL, NULL, &si, &pi))
 	goto succeed;
 
Index: programs/wineconsole/wineconsole.c
===================================================================
RCS file: /usr/share/cvs/cvsroot/wine/wine/programs/wineconsole/wineconsole.c,v
retrieving revision 1.1
diff -u -u -r1.1 wineconsole.c
--- programs/wineconsole/wineconsole.c	2001/11/23 23:05:03	1.1
+++ programs/wineconsole/wineconsole.c	2001/11/24 20:03:17
@@ -443,11 +443,18 @@
     return done;
 }
 
+static BOOL WINECON_HasEvent(LPCSTR ptr, unsigned *evt)
+{
+    while (*ptr == ' ' || *ptr == '\t') ptr++;
+    if (strncmp(ptr, "--use-event=", 12)) return FALSE;
+    return sscanf(ptr + 12, "%d", evt) == 1;
+}
+
 /******************************************************************
  *		WINECON_WinMain
  *
  * wineconsole can either be started as:
- *	wineconsole <int>		used when a new console is created (AllocConsole)
+ *	wineconsole --use-event=<int>	used when a new console is created (AllocConsole)
  *	wineconsole <pgm> <arguments>	used to start the program <pgm> from the command line in
  *					a freshly created console
  */
@@ -458,7 +465,7 @@
     unsigned		evt;
 
     /* case of wineconsole <evt>, signal process that created us that we're up and running */
-    if (sscanf(lpCmdLine, "%d", &evt) == 1)
+    if (WINECON_HasEvent(lpCmdLine, &evt))
     {
         if (!(data = WINECON_Init(hInst, 0))) return 0;
 	ret = SetEvent((HANDLE)evt);


More information about the wine-patches mailing list