From b15e89e4fcb76dcadaace5a63cbd252917c4e22f Mon Sep 17 00:00:00 2001 From: M600 Date: Thu, 16 Feb 2017 15:19:02 +0100 Subject: [PATCH] Fix rematching and one leak --- 42sh/src/completion/c_binary.c | 2 +- 42sh/src/completion/c_matching.c | 5 ++++- 42sh/src/completion/c_output.c | 3 ++- 42sh/src/completion/c_rematch.c | 15 +++++++-------- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/42sh/src/completion/c_binary.c b/42sh/src/completion/c_binary.c index 4d9b05b3..4bbc824d 100644 --- a/42sh/src/completion/c_binary.c +++ b/42sh/src/completion/c_binary.c @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/09 13:30:57 by alao #+# #+# */ -/* Updated: 2017/02/16 12:02:41 by alao ### ########.fr */ +/* Updated: 2017/02/16 15:18:14 by alao ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/completion/c_matching.c b/42sh/src/completion/c_matching.c index d805e45c..7b267ac7 100644 --- a/42sh/src/completion/c_matching.c +++ b/42sh/src/completion/c_matching.c @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/10/15 13:27:14 by alao #+# #+# */ -/* Updated: 2017/02/15 19:06:32 by alao ### ########.fr */ +/* Updated: 2017/02/16 15:16:05 by alao ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,6 +32,9 @@ int c_matching(t_data *s, t_comp *c) else c_seek_files(s, c); if (c->lst) + { c_sizing(c); + return (1); + } return (0); } diff --git a/42sh/src/completion/c_output.c b/42sh/src/completion/c_output.c index b4df647a..72f36ec0 100644 --- a/42sh/src/completion/c_output.c +++ b/42sh/src/completion/c_output.c @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/03 13:10:38 by alao #+# #+# */ -/* Updated: 2017/02/16 12:10:24 by alao ### ########.fr */ +/* Updated: 2017/02/16 15:16:10 by alao ### ########.fr */ /* */ /* ************************************************************************** */ @@ -34,6 +34,7 @@ int c_updater(t_comp *c, char *select) tmp = ft_strdup(c->rcmd); rt = ft_strjoin(tmp, select); tmp ? ft_memdel((void *)&tmp) : (0); + data_singleton()->line.input ? ft_memdel((void *)&data_singleton()->line.input) : (0); if (c->trail) data_singleton()->line.input = ft_strjoin(rt, c->trail); else diff --git a/42sh/src/completion/c_rematch.c b/42sh/src/completion/c_rematch.c index 1b27819f..fcb4c121 100644 --- a/42sh/src/completion/c_rematch.c +++ b/42sh/src/completion/c_rematch.c @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/15 12:03:30 by alao #+# #+# */ -/* Updated: 2017/02/16 12:15:28 by alao ### ########.fr */ +/* Updated: 2017/02/16 15:17:52 by alao ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,13 +21,16 @@ static int c_refresh_match(t_comp *c, long int keypress) char *tmp; char kpconv[2]; - kpconv[0] = keypress; + kpconv[0] = (char)keypress; kpconv[1] = '\0'; tmp = c->match ? ft_strjoin(c->match, kpconv) : ft_strdup(kpconv); c->match ? ft_memdel((void *)&c->match) : (0); c->match = ft_strdup(tmp); tmp ? ft_memdel((void *)&tmp) : (0); - (void)c; + tmp = ft_strjoin(c->rcmd, kpconv); + c->rcmd ? ft_memdel((void *)&c->rcmd) : (0); + c->rcmd = ft_strdup(tmp); + tmp ? ft_memdel((void *)&tmp) : (0); return (0); } @@ -50,12 +53,8 @@ int c_rematch(t_comp *c, long int keypress) c_refresh_match(c, keypress); c_clear_lst(c); c->lst = NULL; - c_seek_files(data_singleton(), c); - if (c->lst) - { - c_sizing(c); + if (c_matching(data_singleton(), c)) return (1); - } } return (0); }