Fixed the return value in GetEnvironmentVariable().
authorHartmut Birr <osexpert@googlemail.com>
Sun, 17 Mar 2002 17:56:57 +0000 (17:56 +0000)
committerHartmut Birr <osexpert@googlemail.com>
Sun, 17 Mar 2002 17:56:57 +0000 (17:56 +0000)
svn path=/trunk/; revision=2728

reactos/lib/kernel32/misc/env.c

index 3d5831b..bce4233 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: env.c,v 1.11 2000/07/01 17:07:00 ea Exp $
+/* $Id: env.c,v 1.12 2002/03/17 17:56:57 hbirr Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -70,7 +70,14 @@ GetEnvironmentVariableA (
                RtlFreeUnicodeString (&VarNameU);
 
                SetLastErrorByStatus (Status);
-               return 0;
+               if (Status == STATUS_BUFFER_TOO_SMALL)
+               {
+                       return VarNameU.Length / sizeof(WCHAR) + 1;
+               }
+               else
+               {
+                       return 0;
+               }
        }
 
        /* convert unicode value string to ansi */
@@ -115,7 +122,14 @@ GetEnvironmentVariableW (
        if (!NT_SUCCESS(Status))
        {
                SetLastErrorByStatus (Status);
-               return 0;
+               if (Status == STATUS_BUFFER_TOO_SMALL)
+               {
+                       return (VarValue.Length / sizeof(WCHAR)) + 1;
+               }
+               else
+               {
+                       return 0;
+               }
        }
 
        return (VarValue.Length / sizeof(WCHAR));
@@ -135,6 +149,8 @@ SetEnvironmentVariableA (
        UNICODE_STRING VarValueU;
        NTSTATUS Status;
 
+       DPRINT("SetEnvironmentVariableA(Name '%s', Value '%s')\n", lpName, lpValue);
+
        RtlInitAnsiString (&VarName,
                           (LPSTR)lpName);
        RtlAnsiStringToUnicodeString (&VarNameU,
@@ -175,6 +191,8 @@ SetEnvironmentVariableW (
        UNICODE_STRING VarValue;
        NTSTATUS Status;
 
+       DPRINT("SetEnvironmentVariableW(Name '%S', Value '%S')\n", lpName, lpValue);
+
        RtlInitUnicodeString (&VarName,
                              lpName);