mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 18:14:25 +03:00
When cd to "..", remove encoding at the end of path.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
f7ee6f8cf2
commit
c0384e0b6b
@ -625,6 +625,12 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
|
||||
else
|
||||
{
|
||||
/* "token/../foo" -> "foo" */
|
||||
#if HAVE_CHARSET
|
||||
/* special case: remove encoding */
|
||||
if (strncmp (s, "#enc:", 5) == 0)
|
||||
str_move (s, p + 1);
|
||||
else
|
||||
#endif /* HAVE_CHARSET */
|
||||
str_move (s, p + 4);
|
||||
}
|
||||
p = (s > lpath) ? s - 1 : s;
|
||||
@ -646,6 +652,24 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
|
||||
/* "foo/token/.." -> "foo" */
|
||||
if (s == lpath + 1)
|
||||
s[0] = 0;
|
||||
#if HAVE_CHARSET
|
||||
else if (strncmp (s, "#enc:", 5) == 0)
|
||||
{
|
||||
/* special case: remove encoding */
|
||||
s[0] = '.';
|
||||
s[1] = '.';
|
||||
s[2] = '\0';
|
||||
|
||||
/* search for the previous token */
|
||||
/* s[-1] == PATH_SEP */
|
||||
p = s - 1;
|
||||
while (p >= lpath && *p != PATH_SEP)
|
||||
p--;
|
||||
|
||||
if (p != NULL)
|
||||
continue;
|
||||
}
|
||||
#endif /* HAVE_CHARSET */
|
||||
else
|
||||
s[-1] = 0;
|
||||
break;
|
||||
|
20
src/main.c
20
src/main.c
@ -99,6 +99,7 @@
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "charsets.h"
|
||||
#include "selcodepage.h"
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
||||
|
||||
@ -392,7 +393,24 @@ subshell_chdir (const char *directory)
|
||||
int
|
||||
do_cd (const char *new_dir, enum cd_enum exact)
|
||||
{
|
||||
return (do_panel_cd (current_panel, new_dir, exact));
|
||||
gboolean res;
|
||||
|
||||
res = do_panel_cd (current_panel, new_dir, exact);
|
||||
|
||||
#if HAVE_CHARSET
|
||||
if (res)
|
||||
{
|
||||
const char *enc_name;
|
||||
|
||||
enc_name = vfs_get_encoding (current_panel->cwd);
|
||||
if (enc_name != NULL)
|
||||
current_panel->codepage = get_codepage_index (enc_name);
|
||||
else
|
||||
current_panel->codepage = SELECT_CHARSET_NO_TRANSLATE;
|
||||
}
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
||||
return res ? 1 : 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
|
Loading…
Reference in New Issue
Block a user