mirror of https://github.com/MidnightCommander/mc
Fix assumptions of "dir.list->len == 0".
`dir.list->len` can't be zero because we're always checking it after a call to dir_list_init(), which populated the list with "..". Therefore any code that checks for zero is either superfluous or a bug. As for the modifications in find.c: - The bug caused us not to call panel_clean_dir(), and this caused: - Memory leaks resulting from calling dir_list_init() without dir_list_clean() first. - The "total size" of selected files (for example) wasn't getting cleared. - We remove the `if (list->len != 0)` around the `current_panel->is_panelized = TRUE; ...` for several reasons: - The code isn't called anyway if no files were found. - Conceptually, there's no point in distinguishing an empty listing from an empty panelized listing. - It's the de-facto current behavior (as `list->len != 0` always) Signed-off-by: Mooffie <mooffie@gmail.com>
This commit is contained in:
parent
c9f058e65b
commit
bb45f84071
|
@ -1754,6 +1754,7 @@ do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs,
|
||||||
dir_list *list = ¤t_panel->dir;
|
dir_list *list = ¤t_panel->dir;
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
|
|
||||||
|
panel_clean_dir (current_panel);
|
||||||
dir_list_init (list);
|
dir_list_init (list);
|
||||||
|
|
||||||
for (i = 0, entry = listbox_get_first_link (find_list); entry != NULL;
|
for (i = 0, entry = listbox_get_first_link (find_list); entry != NULL;
|
||||||
|
@ -1803,8 +1804,6 @@ do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list->len == 0) /* first turn i.e clean old list */
|
|
||||||
panel_clean_dir (current_panel);
|
|
||||||
list->list[list->len].fnamelen = strlen (p);
|
list->list[list->len].fnamelen = strlen (p);
|
||||||
list->list[list->len].fname = g_strndup (p, list->list[list->len].fnamelen);
|
list->list[list->len].fname = g_strndup (p, list->list[list->len].fnamelen);
|
||||||
list->list[list->len].f.marked = 0;
|
list->list[list->len].f.marked = 0;
|
||||||
|
@ -1820,21 +1819,18 @@ do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs,
|
||||||
rotate_dash (TRUE);
|
rotate_dash (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list->len != 0)
|
current_panel->is_panelized = TRUE;
|
||||||
{
|
|
||||||
current_panel->is_panelized = TRUE;
|
|
||||||
|
|
||||||
/* absolute path */
|
/* absolute path */
|
||||||
if (start_dir_len < 0)
|
if (start_dir_len < 0)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
vfs_path_free (current_panel->cwd_vpath);
|
vfs_path_free (current_panel->cwd_vpath);
|
||||||
current_panel->cwd_vpath = vfs_path_from_str (PATH_SEP_STR);
|
current_panel->cwd_vpath = vfs_path_from_str (PATH_SEP_STR);
|
||||||
ret = chdir (PATH_SEP_STR);
|
ret = chdir (PATH_SEP_STR);
|
||||||
(void) ret;
|
(void) ret;
|
||||||
}
|
|
||||||
panelize_save_panel (current_panel);
|
|
||||||
}
|
}
|
||||||
|
panelize_save_panel (current_panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (content_pattern);
|
g_free (content_pattern);
|
||||||
|
|
|
@ -356,9 +356,7 @@ do_external_panelize (char *command)
|
||||||
|
|
||||||
current_panel->is_panelized = TRUE;
|
current_panel->is_panelized = TRUE;
|
||||||
|
|
||||||
if (list->len == 0)
|
if (list->len > 1 && IS_PATH_SEP (list->list[1].fname[0]))
|
||||||
dir_list_init (list);
|
|
||||||
else if (list->len > 1 && IS_PATH_SEP (list->list[1].fname[0]))
|
|
||||||
{
|
{
|
||||||
vfs_path_t *vpath_root;
|
vfs_path_t *vpath_root;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
Loading…
Reference in New Issue