From 301ec53259d77677183f1d7fd0603e14a033d37f Mon Sep 17 00:00:00 2001 From: gwojda Date: Wed, 8 Mar 2017 13:48:37 +0100 Subject: [PATCH] j'avais fait des betises --- 42sh/includes/completion.h | 8 +------- 42sh/src/completion/c_files.c | 4 ++-- 42sh/src/completion/c_matching.c | 26 +++++++++++++++++++++++++- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/42sh/includes/completion.h b/42sh/includes/completion.h index 630f5b7b..dc826172 100644 --- a/42sh/includes/completion.h +++ b/42sh/includes/completion.h @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/02/18 11:13:04 by alao #+# #+# */ -/* Updated: 2017/03/08 13:34:05 by gwojda ### ########.fr */ +/* Updated: 2017/03/08 13:46:51 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -162,10 +162,4 @@ int c_spacing_clear(t_comp *c); int ft_sstrlen(char **s); char *ft_sstrtostr(char **s, char *sep); -/* -** yolo je mets ca au pif - gwojda -*/ - -int c_exclusion_folder(t_comp *c); - #endif diff --git a/42sh/src/completion/c_files.c b/42sh/src/completion/c_files.c index 4586095f..3196a90d 100644 --- a/42sh/src/completion/c_files.c +++ b/42sh/src/completion/c_files.c @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/09 13:31:21 by alao #+# #+# */ -/* Updated: 2017/03/08 13:33:13 by gwojda ### ########.fr */ +/* Updated: 2017/03/08 13:46:46 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,7 +20,7 @@ ** Returning 1 if success (trigger an update) or 0. */ -int c_exclusion_folder(t_comp *c) +static int c_exclusion_folder(t_comp *c) { DIR *rep; char *tmp; diff --git a/42sh/src/completion/c_matching.c b/42sh/src/completion/c_matching.c index bc639b2d..bbbd8fa3 100644 --- a/42sh/src/completion/c_matching.c +++ b/42sh/src/completion/c_matching.c @@ -6,12 +6,36 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/10/15 13:27:14 by alao #+# #+# */ -/* Updated: 2017/03/08 13:33:10 by gwojda ### ########.fr */ +/* Updated: 2017/03/08 13:47:34 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ #include "completion.h" +static int c_exclusion_folder(t_comp *c) +{ + DIR *rep; + char *tmp; + char *tmp2; + + tmp = ft_strjoin(c->cpath, c->match); + tmp2 = NULL; + if (tmp[ft_strlen(tmp) - 1] == '/') + return (0); + if ((rep = opendir(tmp)) && (!closedir(rep))) + { + tmp ? ft_memdel((void *)&tmp) : (0); + tmp2 = ft_strjoin(c->match, "/"); + c_updater(c, tmp2); + tmp2 ? ft_memdel((void *)&tmp2) : (0); + ft_strdel(&c->match); + c->match = ft_strdup("/"); + return (1); + } + tmp ? ft_memdel((void *)&tmp) : (0); + tmp ? ft_memdel((void *)&tmp) : (0); + return (0); +} /* ** Start the parsing for the autocompletion. ** Check the first char of the c->rcmd for a . or /. to see if it's a local