Use $HOME before anything else to determine the home directory. Patch by Benjamin...
authorRafaël Carré <funman@videolan.org>
Mon, 15 Oct 2007 13:09:47 +0000 (13:09 +0000)
committerRafaël Carré <funman@videolan.org>
Mon, 15 Oct 2007 13:09:47 +0000 (13:09 +0000)
src/modules/configuration.c

index 72745bc..e47539c 100644 (file)
@@ -1843,25 +1843,23 @@ static char *GetDir( vlc_bool_t b_appdata )
         return FromWide( whomedir );
 #endif
 
         return FromWide( whomedir );
 #endif
 
+    psz_localhome = getenv( "HOME" );
+    if( psz_localhome == NULL )
+    {
 #if defined(HAVE_GETPWUID)
 #if defined(HAVE_GETPWUID)
-    struct passwd *p_pw;
-    (void)b_appdata;
+        struct passwd *p_pw;
+        (void)b_appdata;
 
 
-    if( ( p_pw = getpwuid( getuid() ) ) == NULL )
+        if( ( p_pw = getpwuid( getuid() ) ) != NULL )
+            psz_localhome = p_pw->pw_dir;
+        else
 #endif
 #endif
-    {
-        psz_localhome = getenv( "HOME" );
-        if( psz_localhome == NULL )
         {
             psz_localhome = getenv( "TMP" );
             if( psz_localhome == NULL )
                 psz_localhome = "/tmp";
         }
     }
         {
             psz_localhome = getenv( "TMP" );
             if( psz_localhome == NULL )
                 psz_localhome = "/tmp";
         }
     }
-#if defined(HAVE_GETPWUID)
-    else
-        psz_localhome = p_pw->pw_dir;
-#endif
 
     return FromLocaleDup( psz_localhome );
 }
 
     return FromLocaleDup( psz_localhome );
 }