From 28408d2bb946a2e7fcb2ff85c2882181240fca25 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Thu, 22 Mar 2012 15:26:52 +0300 Subject: [PATCH] Fixed creating string from relative non-local VFS. Signed-off-by: Slava Zanko --- lib/vfs/path.c | 3 +++ tests/lib/vfs/current_dir.c | 2 +- tests/lib/vfs/relative_cd.c | 33 +++++++++++++++++++++++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/lib/vfs/path.c b/lib/vfs/path.c index 347af0890..ee1ec6364 100644 --- a/lib/vfs/path.c +++ b/lib/vfs/path.c @@ -639,7 +639,10 @@ vfs_path_to_str_flags (const vfs_path_t * vpath, int elements_count, vfs_path_fl url_str = vfs_path_build_url_params_str (element, !(flags & VPF_STRIP_PASSWORD)); if (*url_str != '\0') + { g_string_append (buffer, url_str); + g_string_append_c (buffer, PATH_SEP); + } g_free (url_str); } diff --git a/tests/lib/vfs/current_dir.c b/tests/lib/vfs/current_dir.c index b56061cbf..f96147715 100644 --- a/tests/lib/vfs/current_dir.c +++ b/tests/lib/vfs/current_dir.c @@ -108,7 +108,7 @@ START_TEST (set_up_current_dir_url) test_subclass.flags = VFS_S_REMOTE; cd_and_check ("/test://user:pass@host.net/path", "/test://user:pass@host.net/path"); - cd_and_check ("..", "/test://user:pass@host.net"); + cd_and_check ("..", "/test://user:pass@host.net/"); cd_and_check ("..", "/"); diff --git a/tests/lib/vfs/relative_cd.c b/tests/lib/vfs/relative_cd.c index e8acec43c..930bb9f58 100644 --- a/tests/lib/vfs/relative_cd.c +++ b/tests/lib/vfs/relative_cd.c @@ -90,7 +90,7 @@ test_chdir (const vfs_path_t * vpath) /* --------------------------------------------------------------------------------------------- */ -START_TEST (relative_cd) +START_TEST (test_relative_cd) { vfs_path_t *vpath; @@ -102,11 +102,39 @@ START_TEST (relative_cd) fail_if (mc_chdir(vpath) == -1); vfs_path_free (vpath); } +END_TEST /* --------------------------------------------------------------------------------------------- */ +/* Relative to panel_correct_path_to_show() */ + +START_TEST (test_vpath_to_str_filter) +{ + vfs_path_t *vpath, *last_vpath; + char *filtered_path; + const vfs_path_element_t *path_element; + + vpath = vfs_path_from_str ("/test1://some.host/dir"); + path_element = vfs_path_element_clone (vfs_path_get_by_index (vpath, -1)); + vfs_path_free (vpath); + + last_vpath = vfs_path_new (); + last_vpath->relative = TRUE; + + vfs_path_add_element (last_vpath, path_element); + + filtered_path = vfs_path_to_str_flags (last_vpath, 0, + VPF_STRIP_HOME | VPF_STRIP_PASSWORD | VPF_HIDE_CHARSET); + vfs_path_free (last_vpath); + + fail_unless (strcmp("test1://some.host/dir", filtered_path) == 0, "actual: %s", filtered_path); + g_free (filtered_path); + +} END_TEST +/* --------------------------------------------------------------------------------------------- */ + int main (void) { @@ -119,7 +147,8 @@ main (void) tcase_add_checked_fixture (tc_core, setup, teardown); /* Add new tests here: *************** */ - tcase_add_test (tc_core, relative_cd); + tcase_add_test (tc_core, test_relative_cd); + tcase_add_test (tc_core, test_vpath_to_str_filter); /* *********************************** */ suite_add_tcase (s, tc_core); -- 2.11.4.GIT