rectif du glob sur l'affichage du pattern quand pas de match, et ajout du / quand match avec un dossier
This commit is contained in:
parent
4ee0f24632
commit
e2a254863c
3 changed files with 12 additions and 8 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/30 12:07:16 by wescande #+# #+# */
|
/* Created: 2017/01/30 12:07:16 by wescande #+# #+# */
|
||||||
/* Updated: 2017/02/24 22:04:49 by ariard ### ########.fr */
|
/* Updated: 2017/03/08 14:50:58 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -49,9 +49,13 @@ int dir_research(t_glob *gl, char *p,
|
||||||
{
|
{
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *in;
|
struct dirent *in;
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = 0;
|
if (!pat)
|
||||||
|
{
|
||||||
|
gl->found = 1;
|
||||||
|
ft_ld_pushfront(&gl->match, ft_strjoin(p, "/"));
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
if ((ft_strlen(p) <= 1 || p[ft_strlen(p) - 1] != '.') && is_directory(p))
|
if ((ft_strlen(p) <= 1 || p[ft_strlen(p) - 1] != '.') && is_directory(p))
|
||||||
{
|
{
|
||||||
dir = opendir(p);
|
dir = opendir(p);
|
||||||
|
|
@ -60,5 +64,5 @@ int dir_research(t_glob *gl, char *p,
|
||||||
(char *[2]){p, in->d_name}, pat, recursive);
|
(char *[2]){p, in->d_name}, pat, recursive);
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
}
|
}
|
||||||
return (ret);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/04 16:29:54 by wescande #+# #+# */
|
/* Created: 2017/01/04 16:29:54 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/03 20:38:53 by wescande ### ########.fr */
|
/* Updated: 2017/03/08 14:50:56 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -66,8 +66,7 @@ char **glob(char *pat, unsigned char *esc,
|
||||||
else
|
else
|
||||||
dir_research(&gl, "/", gl.pat + 1, 0);
|
dir_research(&gl, "/", gl.pat + 1, 0);
|
||||||
if (!gl.found)
|
if (!gl.found)
|
||||||
ft_ld_pushfront(&gl.match,
|
ft_ld_pushfront(&gl.match, ft_strdup(CH(gl.m_pat)[0]));
|
||||||
ft_strjoin(gl.cur_dir ? "" : "./", CH(gl.m_pat)[0]));
|
|
||||||
if (!gl.m_pat->next)
|
if (!gl.m_pat->next)
|
||||||
break ;
|
break ;
|
||||||
gl.m_pat = gl.m_pat->next;
|
gl.m_pat = gl.m_pat->next;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/24 17:30:23 by wescande #+# #+# */
|
/* Created: 2017/01/24 17:30:23 by wescande #+# #+# */
|
||||||
/* Updated: 2017/02/24 22:06:01 by ariard ### ########.fr */
|
/* Updated: 2017/03/08 14:35:43 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -90,6 +90,7 @@ static char *manage_pat(t_glob *gl, char *pat, char *str)
|
||||||
if (pat[0] == '.' && pat[1] == '/'
|
if (pat[0] == '.' && pat[1] == '/'
|
||||||
&& ((str[0] == '.' && str[1] != '/') || str[0] != '.'))
|
&& ((str[0] == '.' && str[1] != '/') || str[0] != '.'))
|
||||||
{
|
{
|
||||||
|
DG("%s vs %s", pat, str);
|
||||||
gl->cur_dir = 0;
|
gl->cur_dir = 0;
|
||||||
return (pat + 2);
|
return (pat + 2);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue