2008-04-02  Federico Mena Quintero  <federico@novell.com>

	Merged from trunk:

	Fix http://bugzilla.gnome.org/show_bug.cgi?id=492134 - The file
	chooser incorrectly substitutes and expands a ~ when you type it
	in the filename entry.

	* gtk/gtkfilesystemunix.c (expand_tilde): Ensure that empty
	basenames result in a slash-terminated pathname.
	gtk_file_system_unix_parse() is correct, but it was splitting
	"/home/username" into path="/home" and file_part="username", which
	is not what the caller wants when the entry has just "~" or
	"~username".

diff --git a/gtk/gtkfilesystemunix.c b/gtk/gtkfilesystemunix.c
index ad225af..31387cb 100644
--- a/gtk/gtkfilesystemunix.c
+++ b/gtk/gtkfilesystemunix.c
@@ -1470,10 +1470,11 @@ expand_tilde (const char *filename)
       home = passwd->pw_dir;
     }
 
+  /* We put G_DIR_SEPARATOR_S so that empty basenames will make the resulting path end in a slash */
   if (slash)
     return g_build_filename (home, G_DIR_SEPARATOR_S, slash + 1, NULL);
   else
-    return g_strdup (home);
+    return g_build_filename (home, G_DIR_SEPARATOR_S, NULL);
 }
 
 static gboolean