From 894b343f9061ce7f3e30806994b2ab777ede9e61 Mon Sep 17 00:00:00 2001 From: Leonard den Ottolander Date: Wed, 2 Nov 2005 11:50:51 +0000 Subject: [PATCH] * main.c (directory_history_add): Fix invalid directory preselection on cd. --- src/ChangeLog | 5 +++++ src/main.c | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 755ceccb1..55e205dd3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2005-11-02 Egmont Koblinger + + * main.c (directory_history_add): Fix invalid directory preselection on + cd. + 2005-10-08 Pavel Roskin * man2hlp.c (main): Fix using 0 instead of NULL. diff --git a/src/main.c b/src/main.c index c301258fe..5a9bd0759 100644 --- a/src/main.c +++ b/src/main.c @@ -534,7 +534,6 @@ directory_history_add (struct WPanel *panel, const char *dir) /* * If we moved to the parent directory move the selection pointer to * the old directory name; If we leave VFS dir, remove FS specificator. - * Warn: This code spoils lwd string. * * You do _NOT_ want to add any vfs aware code here. */ @@ -543,7 +542,9 @@ get_parent_dir_name (const char *cwd, const char *lwd) { const char *p; if (strlen (lwd) > strlen (cwd)) - if ((p = strrchr (lwd, PATH_SEP)) && !strncmp (cwd, lwd, p - lwd)) { + if ((p = strrchr (lwd, PATH_SEP)) && !strncmp (cwd, lwd, p - lwd) && + (strlen (cwd) == p - lwd || (p == lwd && cwd[0] == PATH_SEP && + cwd[1] == '\0'))) { return (p + 1); } return NULL;