warning fixes

eric pouech eric.pouech at wanadoo.fr
Tue May 22 01:31:06 CDT 2001


Francois Gouget wrote:
> 
> On Mon, 21 May 2001, eric pouech wrote:
> > ChangeLog: fixed a couple of warnings
> 
>    This does not fix the warnings, it just hides the bug. As the
> comments say, the assignments are plain wrong in the first place.
well, to be completely exact it did fix the warning but didn't fix 
the bug nor the FIXME ;-)

but, since you didn't request it, here's a patch that should indeed fix
the FIXME, remove the bug, and incidentally remove the warning

A+

-- 
---------------
Eric Pouech (http://perso.wanadoo.fr/eric.pouech/)
"The future will be better tomorrow", Vice President Dan Quayle
-------------- next part --------------
Name: msvcrt
ChangeLog: correctly generates the environment global variables
GenDate: 2001/05/22 06:25:57 UTC
ModifiedFiles: dlls/msvcrt/data.c
AddedFiles: 
===================================================================
RCS file: /usr/share/cvs/cvsroot/wine/wine/dlls/msvcrt/data.c,v
retrieving revision 1.8
diff -u -u -r1.8 data.c
--- dlls/msvcrt/data.c	2001/05/11 20:03:40	1.8
+++ dlls/msvcrt/data.c	2001/05/22 06:22:47
@@ -142,9 +142,9 @@
  */
 void msvcrt_init_args(void)
 {
-  char *cmdline, **xargv = NULL;
-  WCHAR *wcmdline, **wxargv = NULL;
-  int xargc,end,last_arg,afterlastspace;
+  char *cmdline, **xargv = NULL, *ptr, *env;
+  WCHAR *wcmdline, **wxargv = NULL, *wptr, *wenv;
+  int xargc,end,last_arg,afterlastspace,count;
   DWORD version;
 
   MSVCRT__acmdln = _strdup( GetCommandLineA() );
@@ -221,15 +221,42 @@
   MSVCRT_free( cmdline );
 
   TRACE("found %d arguments\n",MSVCRT___argc);
-  /* FIXME: This is plain wrong, we must convert from a '\0' separated 
-   * memory block to an array of pointers to string format.
-   */
-  MSVCRT__environ = GetEnvironmentStringsA();
+
+  env = GetEnvironmentStringsA();
+  count = 1; /* for NULL sentinel */
+  for (ptr = env; *ptr; ptr += strlen(ptr) + 1)
+  {
+    count++;
+  }
+  MSVCRT__environ = HeapAlloc(GetProcessHeap(), 0, count * sizeof(char*));
+  if (MSVCRT__environ)
+  {
+    count = 0;
+    for (ptr = env; *ptr; ptr += strlen(ptr) + 1)
+    {
+      MSVCRT__environ[count++] = ptr;
+    }
+    MSVCRT__environ[count] = NULL;
+  }
+
   MSVCRT___initenv = MSVCRT__environ;
-  /* FIXME: This is plain wrong, we must convert from a '\0' separated 
-   * memory block to an array of pointers to string format.
-   */
-  MSVCRT__wenviron = GetEnvironmentStringsW();
+
+  wenv = GetEnvironmentStringsW();
+  count = 1; /* for NULL sentinel */
+  for (wptr = wenv; *wptr; wptr += lstrlenW(wptr) + 1)
+  {
+    count++;
+  }
+  MSVCRT__wenviron = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR*));
+  if (MSVCRT__wenviron)
+  {
+    count = 0;
+    for (wptr = wenv; *wptr; wptr += lstrlenW(wptr) + 1)
+    {
+      MSVCRT__wenviron[count++] = wptr;
+    }
+    MSVCRT__wenviron[count] = NULL;
+  }
   MSVCRT___winitenv = MSVCRT__wenviron;
 }
 


More information about the wine-patches mailing list