[glib] win32: g_getenv() should return "" if variable exists and empty



commit bfbfbec91e10ea7f34e43a5d263031abb914dec6
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date:   Mon Jul 9 04:12:02 2012 +0200

    win32: g_getenv() should return "" if variable exists and empty
    
    On Windows, GetEnvironmentVariable() returns 0 for empty variables.
    Checking GetLastError() == ERROR_ENVVAR_NOT_FOUND helps make a
    difference between a variable that does not exist or an empty one
    which should return "".
    
    https://bugzilla.gnome.org/show_bug.cgi?id=679617

 glib/genviron.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/glib/genviron.c b/glib/genviron.c
index 4abf776..aed4b63 100644
--- a/glib/genviron.c
+++ b/glib/genviron.c
@@ -466,7 +466,11 @@ g_getenv (const gchar *variable)
   if (len == 0)
     {
       g_free (wname);
-      return NULL;
+      if (GetLastError () == ERROR_ENVVAR_NOT_FOUND)
+        return NULL;
+
+      quark = g_quark_from_static_string ("");
+      return g_quark_to_string (quark);
     }
   else if (len == 1)
     len = 2;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]