Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

Commit

Permalink
win32: g_getenv() should return "" if variable exists and empty
Browse files Browse the repository at this point in the history
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
  • Loading branch information
elmarco committed Jul 16, 2012
1 parent 6007a4b commit bfbfbec
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion glib/genviron.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit bfbfbec

Please sign in to comment.