From 1aaccbe58691356e226be7966d4e6be8eb154c80 Mon Sep 17 00:00:00 2001 From: wescande Date: Thu, 9 Mar 2017 03:47:39 +0100 Subject: [PATCH] retif matching du glob sur du star --- 42sh/src/glob/dir_glob.c | 3 ++- 42sh/src/glob/glob.c | 2 +- 42sh/src/glob/match_pattern.c | 6 ++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/42sh/src/glob/dir_glob.c b/42sh/src/glob/dir_glob.c index e83d55b9..75e7e0a5 100644 --- a/42sh/src/glob/dir_glob.c +++ b/42sh/src/glob/dir_glob.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/30 12:07:16 by wescande #+# #+# */ -/* Updated: 2017/03/08 14:50:58 by wescande ### ########.fr */ +/* Updated: 2017/03/09 03:24:59 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -40,6 +40,7 @@ static void dir_list_content(t_glob *gl, char **str, char *pat, ft_ld_pushfront(&gl->match, ft_strdup(path_tmp + gl->cur_dir * 2 * (path_tmp[0] == '.' && path_tmp[1] == '/'))); } + gl->pat = pat; ft_strdel(&path_tmp); } } diff --git a/42sh/src/glob/glob.c b/42sh/src/glob/glob.c index 30161c24..fa92d44b 100644 --- a/42sh/src/glob/glob.c +++ b/42sh/src/glob/glob.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/04 16:29:54 by wescande #+# #+# */ -/* Updated: 2017/03/08 23:31:22 by ariard ### ########.fr */ +/* Updated: 2017/03/09 03:24:24 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/glob/match_pattern.c b/42sh/src/glob/match_pattern.c index 57323c48..59dbe552 100644 --- a/42sh/src/glob/match_pattern.c +++ b/42sh/src/glob/match_pattern.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/24 17:30:23 by wescande #+# #+# */ -/* Updated: 2017/03/08 14:35:43 by wescande ### ########.fr */ +/* Updated: 2017/03/09 03:24:48 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -69,15 +69,18 @@ static int match_bracket(t_glob *gl, char c) static int match_star(t_glob *gl, char *str, char *full_word) { char *fix; + char *pat; if (gl->pat[1] == '*' && !is_char_esc(gl->esc, ((char **)gl->m_pat->content)[0], gl->pat + 1)) dir_research(gl, full_word, gl->pat + 1, 1); if (!*gl->pat || (*gl->pat == '*' && !*++gl->pat)) return (1); + pat = gl->pat; fix = str + ft_strlen(str); while (fix > str) { + gl->pat = pat; if (match_pattern(gl, fix, full_word)) return (1); --fix; @@ -90,7 +93,6 @@ static char *manage_pat(t_glob *gl, char *pat, char *str) if (pat[0] == '.' && pat[1] == '/' && ((str[0] == '.' && str[1] != '/') || str[0] != '.')) { - DG("%s vs %s", pat, str); gl->cur_dir = 0; return (pat + 2); }