Commit c3c2c313 authored by Nirbheek Chauhan's avatar Nirbheek Chauhan 👏

glib: Use g_getenv everywhere instead of getenv

`getenv()` doesn't work well on Windows, f.ex., it can't fetch env
vars set with `SetEnvironmentVariable()`. This also means that it
doesn't work at all when targeting UWP since that's the only way to
set env vars in that case.
parent f5b4a6b9
......@@ -49,6 +49,7 @@
#include "gthreadprivate.h"
#include "gunicode.h"
#include "gfileutils.h"
#include "genviron.h"
#include "glibintl.h"
......@@ -1131,14 +1132,14 @@ g_get_filename_charsets (const gchar ***filename_charsets)
if (!(cache->charset && strcmp (cache->charset, charset) == 0))
{
const gchar *new_charset;
gchar *p;
const gchar *p;
gint i;
g_free (cache->charset);
g_strfreev (cache->filename_charsets);
cache->charset = g_strdup (charset);
p = getenv ("G_FILENAME_ENCODING");
p = g_getenv ("G_FILENAME_ENCODING");
if (p != NULL && p[0] != '\0')
{
cache->filename_charsets = g_strsplit (p, ",", 0);
......@@ -1154,7 +1155,7 @@ g_get_filename_charsets (const gchar ***filename_charsets)
}
}
}
else if (getenv ("G_BROKEN_FILENAMES") != NULL)
else if (g_getenv ("G_BROKEN_FILENAMES") != NULL)
{
cache->filename_charsets = g_new0 (gchar *, 2);
cache->is_utf8 = g_get_charset (&new_charset);
......
......@@ -263,7 +263,7 @@ condition_to_string (GIOCondition condition)
static gboolean
g_io_win32_get_debug_flag (void)
{
return (getenv ("G_IO_WIN32_DEBUG") != NULL);
return (g_getenv ("G_IO_WIN32_DEBUG") != NULL);
}
static void
......
......@@ -663,7 +663,7 @@ g_main_context_new (void)
if (g_once_init_enter (&initialised))
{
#ifdef G_MAIN_POLL_DEBUG
if (getenv ("G_MAIN_POLL_DEBUG") != NULL)
if (g_getenv ("G_MAIN_POLL_DEBUG") != NULL)
_g_main_poll_debug = TRUE;
#endif
......
......@@ -364,7 +364,7 @@ slice_config_init (SliceConfig *config)
*config = slice_config;
val = getenv ("G_SLICE");
val = g_getenv ("G_SLICE");
if (val != NULL)
{
gint flags;
......
......@@ -72,7 +72,7 @@
{ \
if (debug == -1) \
{ \
if (getenv ("G_SPAWN_WIN32_DEBUG") != NULL) \
if (g_getenv ("G_SPAWN_WIN32_DEBUG") != NULL) \
debug = 1; \
else \
debug = 0; \
......
......@@ -447,7 +447,7 @@ zone_info_unix (const gchar *identifier,
gchar *resolved_identifier = NULL;
const gchar *tzdir;
tzdir = getenv ("TZDIR");
tzdir = g_getenv ("TZDIR");
if (tzdir == NULL)
tzdir = "/usr/share/zoneinfo";
......
......@@ -109,7 +109,7 @@ g_win32_getlocale (void)
{
LCID lcid;
LANGID langid;
gchar *ev;
const gchar *ev;
gint primary, sub;
char iso639[10];
char iso3166[10];
......@@ -120,9 +120,9 @@ g_win32_getlocale (void)
* since GTK+ 2.10.7 setting either LC_ALL or LANG also sets the
* Win32 locale and C library locale through code in gtkmain.c.
*/
if (((ev = getenv ("LC_ALL")) != NULL && ev[0] != '\0')
|| ((ev = getenv ("LC_MESSAGES")) != NULL && ev[0] != '\0')
|| ((ev = getenv ("LANG")) != NULL && ev[0] != '\0'))
if (((ev = g_getenv ("LC_ALL")) != NULL && ev[0] != '\0')
|| ((ev = g_getenv ("LC_MESSAGES")) != NULL && ev[0] != '\0')
|| ((ev = g_getenv ("LANG")) != NULL && ev[0] != '\0'))
return g_strdup (ev);
lcid = GetThreadLocale ();
......@@ -1084,7 +1084,7 @@ g_win32_veh_handler (PEXCEPTION_POINTERS ExceptionInfo)
case EXCEPTION_ILLEGAL_INSTRUCTION:
break;
default:
catch_list = getenv ("G_VEH_CATCH");
catch_list = g_getenv ("G_VEH_CATCH");
while (!catch &&
catch_list != NULL &&
......@@ -1143,7 +1143,7 @@ g_win32_veh_handler (PEXCEPTION_POINTERS ExceptionInfo)
fflush (stderr);
debugger_env = getenv ("G_DEBUGGER");
debugger_env = g_getenv ("G_DEBUGGER");
if (debugger_env == NULL)
return EXCEPTION_CONTINUE_SEARCH;
......@@ -1173,7 +1173,7 @@ g_win32_veh_handler (PEXCEPTION_POINTERS ExceptionInfo)
NULL,
NULL,
TRUE,
getenv ("G_DEBUGGER_OLD_CONSOLE") != NULL ? 0 : CREATE_NEW_CONSOLE,
g_getenv ("G_DEBUGGER_OLD_CONSOLE") != NULL ? 0 : CREATE_NEW_CONSOLE,
NULL,
NULL,
&si,
......@@ -1213,7 +1213,7 @@ g_crash_handler_win32_init (void)
* break advanced exception handling such as in CLRs like C# or other managed
* code. See: https://blogs.msdn.microsoft.com/jmstall/2006/05/24/beware-of-the-vectored-exception-handler-and-managed-code/
*/
if (getenv ("G_DEBUGGER") == NULL && getenv("G_VEH_CATCH") == NULL)
if (g_getenv ("G_DEBUGGER") == NULL && g_getenv("G_VEH_CATCH") == NULL)
return;
WinVEH_handle = AddVectoredExceptionHandler (0, &g_win32_veh_handler);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment