ajout du bool dans l'appel a glob pour demander un matching complet ou juste une expnsion de var +bquote (cas de l'assignation de variables)
This commit is contained in:
parent
7a72910a97
commit
df7ed59b03
4 changed files with 27 additions and 25 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/04 16:31:18 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/03 12:10:17 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/03 16:15:47 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ typedef struct s_bquote
|
|||
** interface of glob.
|
||||
*/
|
||||
char **glob(char *str, unsigned char *esc,
|
||||
unsigned char *dbl_esc);
|
||||
unsigned char *dbl_esc, int do_match);
|
||||
void esc_print(char *str, unsigned char *esc);
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit bfc8ca207ab4d39f0140322c0f1d368137304a3c
|
||||
Subproject commit 8f6e64fa9b4ac1dd3e3d5200fb93471ddfeedd40
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/14 17:28:14 by jhalford #+# #+# */
|
||||
/* Updated: 2017/02/07 18:06:13 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/03 16:19:31 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ static char **token_to_argv(t_astnode *node)
|
|||
while (ld)
|
||||
{
|
||||
content = ld->content;
|
||||
if ((expand = glob(content[0], (unsigned char *)content[1], (unsigned char *)content[2])))
|
||||
if ((expand = glob(content[0], (unsigned char *)content[1], (unsigned char *)content[2], 1)))
|
||||
{
|
||||
index = -1;
|
||||
while (expand[++index])
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/04 16:29:54 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/03 12:11:17 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/03 16:18:11 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -34,19 +34,20 @@ static char **treat_glob(t_glob *gl)
|
|||
return (ret);
|
||||
}
|
||||
|
||||
static void normal_expand_before_match(t_glob *gl)
|
||||
static void normal_expand_before_match(t_glob *gl, int do_match)
|
||||
{
|
||||
char *home;
|
||||
|
||||
expand_var(gl);
|
||||
expand_bquote(gl);
|
||||
expand_brace(gl);
|
||||
if (do_match)
|
||||
expand_brace(gl);
|
||||
if ((home = ft_getenv(data_singleton()->env, "HOME")))
|
||||
expand_home(gl, home);
|
||||
}
|
||||
|
||||
char **glob(char *pat, unsigned char *esc,
|
||||
unsigned char *esc2)
|
||||
unsigned char *esc2, int do_match)
|
||||
{
|
||||
t_glob gl;
|
||||
int len;
|
||||
|
|
@ -54,21 +55,22 @@ char **glob(char *pat, unsigned char *esc,
|
|||
len = ft_strlen(pat);
|
||||
gl = (t_glob){0, 0, ft_strdup(pat), dup_char_esc(esc, (len >> 3) + 1),
|
||||
dup_char_esc(esc2, (len >> 3) + 1), NULL, NULL};
|
||||
normal_expand_before_match(&gl);
|
||||
while (gl.m_pat && !(gl.found = 0))
|
||||
{
|
||||
gl.cur_dir = 1;
|
||||
gl.pat = CH(gl.m_pat)[0];
|
||||
if ((gl.esc = UCH(gl.m_pat)[1]) && gl.pat[0] != '/')
|
||||
dir_research(&gl, ".", gl.pat, 0);
|
||||
else
|
||||
dir_research(&gl, "/", gl.pat + 1, 0);
|
||||
if (!gl.found)
|
||||
ft_ld_pushfront(&gl.match,
|
||||
ft_strjoin(gl.cur_dir ? "" : "./", CH(gl.m_pat)[0]));
|
||||
if (!gl.m_pat->next)
|
||||
break ;
|
||||
gl.m_pat = gl.m_pat->next;
|
||||
}
|
||||
normal_expand_before_match(&gl, do_match);
|
||||
if (do_match)
|
||||
while (gl.m_pat && !(gl.found = 0))
|
||||
{
|
||||
gl.cur_dir = 1;
|
||||
gl.pat = CH(gl.m_pat)[0];
|
||||
if ((gl.esc = UCH(gl.m_pat)[1]) && gl.pat[0] != '/')
|
||||
dir_research(&gl, ".", gl.pat, 0);
|
||||
else
|
||||
dir_research(&gl, "/", gl.pat + 1, 0);
|
||||
if (!gl.found)
|
||||
ft_ld_pushfront(&gl.match,
|
||||
ft_strjoin(gl.cur_dir ? "" : "./", CH(gl.m_pat)[0]));
|
||||
if (!gl.m_pat->next)
|
||||
break ;
|
||||
gl.m_pat = gl.m_pat->next;
|
||||
}
|
||||
return (treat_glob(&gl));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue