finalisation norme
This commit is contained in:
parent
4f5c65b9a2
commit
7cfa1a4837
3 changed files with 17 additions and 38 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/04 16:31:18 by wescande #+# #+# */
|
/* Created: 2017/01/04 16:31:18 by wescande #+# #+# */
|
||||||
/* Updated: 2017/01/28 00:14:11 by wescande ### ########.fr */
|
/* Updated: 2017/01/30 12:12:23 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -48,9 +48,15 @@ void glob_print(t_list *token, t_data *data);
|
||||||
int match_pattern(t_glob *tglob, char *str, char *full_word);
|
int match_pattern(t_glob *tglob, char *str, char *full_word);
|
||||||
void dir_research(t_glob *tglob, char *p, const char *pat);
|
void dir_research(t_glob *tglob, char *p, const char *pat);
|
||||||
void dir_research_recursive(t_glob *tglob, char *p, const char *pat);
|
void dir_research_recursive(t_glob *tglob, char *p, const char *pat);
|
||||||
|
/*
|
||||||
|
** return TRUE if path file is a directory.
|
||||||
|
*/
|
||||||
int is_directory(const char *path);
|
int is_directory(const char *path);
|
||||||
|
/*
|
||||||
int is_char_esc(const unsigned char *esc, const char *ini_str, const char *str_pos);
|
** return TRUE if char at str_pos in ini_str is escape.
|
||||||
|
*/
|
||||||
|
int is_char_esc(const unsigned char *esc,
|
||||||
|
const char *ini_str, const char *str_pos);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** LIST D:
|
** LIST D:
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* glob.c :+: :+: :+: */
|
/* dir_glob.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/04 16:29:54 by wescande #+# #+# */
|
/* Created: 2017/01/30 12:07:16 by wescande #+# #+# */
|
||||||
/* Updated: 2017/01/27 23:48:18 by wescande ### ########.fr */
|
/* Updated: 2017/01/30 12:07:19 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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/01/28 01:17:04 by wescande ### ########.fr */
|
/* Updated: 2017/01/30 12:08:49 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -14,11 +14,12 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** glob return expansion of a string.
|
** glob return expansion of a string.
|
||||||
** pattern searched are ~, *, ?, [a-z], [!a-z], [^a-z], {ab, ac}, **
|
** pattern searched are *, ?, [a-z], [!a-z], [^a-z], {ab, ac}, **
|
||||||
** input parameters are :
|
** input parameters are :
|
||||||
** -char *pat -> pattern string to be looking for match
|
** -char *pat -> pattern string to be looking for match
|
||||||
|
** -char *esc -> escape binary sequence of *pat
|
||||||
** -char **env -> env var. could be NULL
|
** -char **env -> env var. could be NULL
|
||||||
** to just expanse in local directory and not in path
|
** to just expanse in local directory and not in path dir
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void path_research(t_glob *gl, char **path)
|
static void path_research(t_glob *gl, char **path)
|
||||||
|
|
@ -65,33 +66,6 @@ static void add_simple_pat(t_glob *gl)
|
||||||
ft_ld_pushfront(&gl->match, ft_strdup(gl->pat));
|
ft_ld_pushfront(&gl->match, ft_strdup(gl->pat));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printme_me(const char *pat, const unsigned char *esc)
|
|
||||||
{
|
|
||||||
char *str;
|
|
||||||
int index;
|
|
||||||
int len;
|
|
||||||
|
|
||||||
str = (char *)pat;
|
|
||||||
while (*str)
|
|
||||||
{
|
|
||||||
ft_dprintf(3, is_char_esc(esc, pat, str) ? "\\%c" : "%c", *str);
|
|
||||||
++str;
|
|
||||||
}
|
|
||||||
ft_dprintf(3, "\n");
|
|
||||||
len = ft_strlen(pat);
|
|
||||||
index = -1;
|
|
||||||
while (++index < len)
|
|
||||||
ft_dprintf(3, ((esc[index / 8] >> (7 - index % 8)) & 1) ? " 1" : "0");
|
|
||||||
ft_dprintf(3, "\n");
|
|
||||||
index = 0;
|
|
||||||
while (index < len)
|
|
||||||
{
|
|
||||||
ft_dprintf(3, "%08b", esc[index / 8]);
|
|
||||||
index += 8;
|
|
||||||
}
|
|
||||||
ft_dprintf(3, "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
char **glob(const char *pat, const unsigned char *esc, char **env)
|
char **glob(const char *pat, const unsigned char *esc, char **env)
|
||||||
{
|
{
|
||||||
t_glob gl;
|
t_glob gl;
|
||||||
|
|
@ -103,7 +77,6 @@ char **glob(const char *pat, const unsigned char *esc, char **env)
|
||||||
{
|
{
|
||||||
gl.pat = ((char **)gl.m_pat->content)[0];
|
gl.pat = ((char **)gl.m_pat->content)[0];
|
||||||
gl.esc = ((unsigned char **)gl.m_pat->content)[1];
|
gl.esc = ((unsigned char **)gl.m_pat->content)[1];
|
||||||
printme_me(gl.pat, gl.esc);
|
|
||||||
add_simple_pat(&gl);
|
add_simple_pat(&gl);
|
||||||
if (!(gl.pat[0] == '/' || (gl.pat[0] == '.' && gl.pat[1] == '/'))
|
if (!(gl.pat[0] == '/' || (gl.pat[0] == '.' && gl.pat[1] == '/'))
|
||||||
&& env && (path = ft_strsplit(ft_getenv(env, "PATH"), ':')))
|
&& env && (path = ft_strsplit(ft_getenv(env, "PATH"), ':')))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue