Fix rematching and one leak

This commit is contained in:
M600 2017-02-16 15:19:02 +01:00
parent 2abdf8c925
commit b15e89e4fc
4 changed files with 14 additions and 11 deletions

View file

@ -6,7 +6,7 @@
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */ /* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/09 13:30:57 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */ /* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/10/15 13:27:14 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 else
c_seek_files(s, c); c_seek_files(s, c);
if (c->lst) if (c->lst)
{
c_sizing(c); c_sizing(c);
return (1);
}
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */ /* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/03 13:10:38 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); tmp = ft_strdup(c->rcmd);
rt = ft_strjoin(tmp, select); rt = ft_strjoin(tmp, select);
tmp ? ft_memdel((void *)&tmp) : (0); tmp ? ft_memdel((void *)&tmp) : (0);
data_singleton()->line.input ? ft_memdel((void *)&data_singleton()->line.input) : (0);
if (c->trail) if (c->trail)
data_singleton()->line.input = ft_strjoin(rt, c->trail); data_singleton()->line.input = ft_strjoin(rt, c->trail);
else else

View file

@ -6,7 +6,7 @@
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */ /* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/15 12:03:30 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 *tmp;
char kpconv[2]; char kpconv[2];
kpconv[0] = keypress; kpconv[0] = (char)keypress;
kpconv[1] = '\0'; kpconv[1] = '\0';
tmp = c->match ? ft_strjoin(c->match, kpconv) : ft_strdup(kpconv); tmp = c->match ? ft_strjoin(c->match, kpconv) : ft_strdup(kpconv);
c->match ? ft_memdel((void *)&c->match) : (0); c->match ? ft_memdel((void *)&c->match) : (0);
c->match = ft_strdup(tmp); c->match = ft_strdup(tmp);
tmp ? ft_memdel((void *)&tmp) : (0); 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); return (0);
} }
@ -50,12 +53,8 @@ int c_rematch(t_comp *c, long int keypress)
c_refresh_match(c, keypress); c_refresh_match(c, keypress);
c_clear_lst(c); c_clear_lst(c);
c->lst = NULL; c->lst = NULL;
c_seek_files(data_singleton(), c); if (c_matching(data_singleton(), c))
if (c->lst)
{
c_sizing(c);
return (1); return (1);
} }
}
return (0); return (0);
} }