--- src/editfns.c.orig	Sat Jul  1 07:19:57 2006
+++ src/editfns.c	Sun Jan  2 23:29:57 2011
@@ -876,6 +876,7 @@ get_home_directory (void)
      between XEmacs and the outside world, the very moment we first get
      the data.  --ben */
   int output_home_warning = 0;
+  struct passwd *pw = NULL;
 
   if (cached_home_directory == NULL)
     {
@@ -922,6 +923,13 @@ get_home_directory (void)
 # endif
 	    }
 #else	/* !WIN32_NATIVE */
+	if ((pw = getpwuid(getuid())) != NULL)
+	  {
+	   cached_home_directory = pw->pw_dir;
+	   output_home_warning = 0;
+	  }
+	else
+	  {
 	  /*
 	   * Unix, typically.
 	   * Using "/" isn't quite right, but what should we do?
@@ -930,6 +938,7 @@ get_home_directory (void)
 	   */
 	  cached_home_directory = (Extbyte *) "/";
 	  output_home_warning = 1;
+	}
 #endif	/* !WIN32_NATIVE */
 	}
       if (initialized && output_home_warning)
