Make argv[0] an absolute path so 'wine d:setup' works (2nd try)

Dan Kegel dank at kegel.com
Fri Jan 3 22:33:43 CST 2003


My last version broke the existing regression tests.
This one doesn't, and I've added a regression test to
make sure argv[0] is an absolute path.

This patch should be reviewed carefully, as I don't really
understand Wine's internals yet.

Changelog:
      * scheduler/process.c: make argv[0] absolute so 'wine d:setup' works
      * dlls/kernel/tests/process.c: verify that argv[0] is absolute and contains drive letter

Copyright 2003, Dan Kegel.  LGPL.

-- 
Dan Kegel
Linux User #78045
http://www.kegel.com
-------------- next part --------------
Index: scheduler/process.c
===================================================================
RCS file: /home/wine/wine/scheduler/process.c,v
retrieving revision 1.205
diff -d -u -r1.205 process.c
--- scheduler/process.c	5 Dec 2002 19:56:15 -0000	1.205
+++ scheduler/process.c	4 Jan 2003 04:13:31 -0000
@@ -577,6 +577,7 @@
 {
     char error[100], *p;
     DWORD stack_size = 0;
+    char main_exe_name_copy[MAX_PATH];
 
     /* Initialize everything */
     if (!process_init( argv )) exit(1);
@@ -610,6 +611,10 @@
         MESSAGE( "%s: cannot open builtin library for '%s': %s\n", argv0, main_exe_name, error );
         ExitProcess(1);
     }
+
+    /* absolutify argv[0] so 'wine d:setup' works */
+    strcpy(main_exe_name_copy, main_exe_name);
+    argv[0] = main_exe_name_copy;
 
     switch( MODULE_GetBinaryType( main_exe_file ))
     {
Index: dlls/kernel/tests/process.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/tests/process.c,v
retrieving revision 1.7
diff -d -u -r1.7 process.c
--- dlls/kernel/tests/process.c	18 Dec 2002 20:51:33 -0000	1.7
+++ dlls/kernel/tests/process.c	4 Jan 2003 04:13:32 -0000
@@ -624,6 +624,7 @@
     char                buffer[MAX_PATH];
     PROCESS_INFORMATION	info;
     STARTUPINFOA	startup;
+    const char          *pstr;
 
     memset(&startup, 0, sizeof(startup));
     startup.cb = sizeof(startup);
@@ -640,6 +641,12 @@
     WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
 
     okChildInt("Arguments", "argcA", 4);
+    pstr = getChildString("Arguments", "argvA0");
+    ok(pstr != NULL, "expected non-null argv[0]");
+    if (pstr) {
+        ok(pstr[1] == ':', "expected drive letter in argv[0], got %s", pstr);
+        ok(pstr[2] == '\\', "expected absolute path in argv[0], got %s", pstr);
+    }
     okChildString("Arguments", "argvA3", "C:\\Program Files\\my nice app.exe");
     okChildString("Arguments", "argvA4", NULL);
     okChildString("Arguments", "CommandLineA", buffer);


More information about the wine-devel mailing list