84768a96f209b1e5c7c0516d1d06fae4a1f59f7b
[platform/upstream/glib2.0.git] / debian / patches / 04_homedir_env.patch
1 Index: glib-2.18.3/docs/reference/glib/running.sgml
2 ===================================================================
3 --- glib-2.18.3.orig/docs/reference/glib/running.sgml   2008-11-26 12:01:53.559365436 +0100
4 +++ glib-2.18.3/docs/reference/glib/running.sgml        2008-11-26 12:25:58.155366255 +0100
5 @@ -194,6 +194,22 @@ variables like <envar>LANG</envar>, <env
6    </para>
7  </formalpara> 
8  
9 +<formalpara id="G_HOME">
10 +  <title><envar>G_HOME</envar></title>
11 +
12 +  <para>
13 +    For various reasons, GLib applications ignore the <envar>HOME</envar>
14 +    environment variable on Unix systems and will use the user directory
15 +    as specified by the <filename>passwd</filename> entry, which is more
16 +    reliable.
17 +  </para>
18 +  <para>
19 +    The <envar>G_HOME</envar> environment variable will override any
20 +    other setting for the home directory. It is not meant for daily usage,
21 +    but it is useful in testing or building environments.
22 +  </para>
23 +</formalpara>
24 +
25  </refsect2>
26  
27  <refsect2 id="setlocale">
28 Index: glib-2.18.3/glib/gutils.c
29 ===================================================================
30 --- glib-2.18.3.orig/glib/gutils.c      2008-11-26 11:50:38.607861683 +0100
31 +++ glib-2.18.3/glib/gutils.c   2008-11-26 12:00:29.035360081 +0100
32 @@ -1520,11 +1520,14 @@ g_get_any_init_do (void)
33      }
34  #endif /* !G_OS_WIN32 */
35    
36 +  g_home_dir = g_strdup (g_getenv ("G_HOME"));
37 +  
38  #ifdef G_OS_WIN32
39    /* We check $HOME first for Win32, though it is a last resort for Unix
40     * where we prefer the results of getpwuid().
41     */
42 -  g_home_dir = g_strdup (g_getenv ("HOME"));
43 +  if (!g_home_dir)
44 +    g_home_dir = g_strdup (g_getenv ("HOME"));
45  
46    /* Only believe HOME if it is an absolute path and exists */
47    if (g_home_dir)
48 @@ -1820,6 +1823,11 @@ g_get_real_name (void)
49   *      homedir = g_get_home_dir (<!-- -->);
50   * ]|
51   *
52 + * However, to allow changing this value for testing and development
53 + * purposes, the value of the <envar>G_HOME</envar> environment 
54 + * variable, if set, will override the <filename>passwd</filename>
55 + * entry.
56 + *
57   * Returns: the current user's home directory
58   */
59  G_CONST_RETURN gchar*