diff --git a/src/ChangeLog b/src/ChangeLog index 03a056ea6..8e8dee466 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2003-11-28 Pavel Roskin + + * utilunix.c (tilde_expand): Correct last fix, simplify code. + Reported by David Sterba + 2003-11-27 Pavel Roskin * execute.c (toggle_panels): Refresh panels after returning from diff --git a/src/utilunix.c b/src/utilunix.c index 5ee32d69d..d841ef433 100644 --- a/src/utilunix.c +++ b/src/utilunix.c @@ -262,27 +262,27 @@ char * tilde_expand (const char *directory) { struct passwd *passwd; - const char *p; + const char *p, *q; char *name; if (*directory != '~') return g_strdup (directory); - directory++; + p = directory + 1; - p = strchr (directory, PATH_SEP); + q = strchr (p, PATH_SEP); /* d = "~" or d = "~/" */ - if (!(*directory) || (*directory == PATH_SEP)) { + if (!(*p) || (*p == PATH_SEP)) { passwd = getpwuid (geteuid ()); - p = (*directory == PATH_SEP) ? directory + 1 : ""; + q = (*p == PATH_SEP) ? p + 1 : ""; } else { - if (!p) { - passwd = getpwnam (directory); + if (!q) { + passwd = getpwnam (p); } else { - name = g_malloc (p - directory + 1); - strncpy (name, directory, p - directory); - name[p - directory] = 0; + name = g_malloc (q - p + 1); + strncpy (name, p, q - p); + name[q - p] = 0; passwd = getpwnam (name); g_free (name); } @@ -292,7 +292,7 @@ tilde_expand (const char *directory) if (!passwd) return g_strdup (directory); - return g_strconcat (passwd->pw_dir, PATH_SEP_STR, p, NULL); + return g_strconcat (passwd->pw_dir, PATH_SEP_STR, q, NULL); }