integration du retour de glob dans les tokens

This commit is contained in:
wescande 2017-01-30 17:19:09 +01:00
parent 77b94ee8ce
commit 3c46e10736
7 changed files with 71 additions and 51 deletions

View file

@ -30,10 +30,14 @@ INC_DIR = includes/
OBJ_DIR = objs/
SRC_BASE = \
builtin/bt_read_get.c\
builtin/bt_read_parse.c\
builtin/bt_read_term.c\
builtin/builtin_cd.c\
builtin/builtin_echo.c\
builtin/builtin_env.c\
builtin/builtin_exit.c\
builtin/builtin_read.c\
builtin/builtin_setenv.c\
builtin/builtin_unsetenv.c\
builtin/is_builtin.c\
@ -58,7 +62,7 @@ exec/set_exitstatus.c\
glob/dir_glob.c\
glob/expand_brace.c\
glob/glob.c\
glob/glob_print.c\
glob/glob_expand_token.c\
glob/is_char_esc.c\
glob/lib_perso/ft_ld_back.c\
glob/lib_perso/ft_ld_clear.c\
@ -92,6 +96,7 @@ job-control/job_kill_all.c\
job-control/job_notify_change.c\
job-control/job_notify_new.c\
job-control/job_remove.c\
job-control/job_run.c\
job-control/job_update_id.c\
job-control/job_update_status.c\
job-control/job_wait.c\
@ -133,35 +138,31 @@ lexer/token_expand_var.c\
lexer/token_free.c\
lexer/token_init.c\
lexer/token_print.c\
line-editing/curs_ask.c\
line-editing/curs_clear.c\
line-editing/curs_goto.c\
line-editing/curs_move.c\
line-editing/curs_setup.c\
line-editing/curs_single.c\
line-editing/curs_term_setup.c\
line-editing/curs_write.c\
line-editing/ft_readline.c\
line-editing/rl_bitset.c\
line-editing/rl_clear_function.c\
line-editing/rl_clipboard_function.c\
line-editing/rl_clipboard_utility.c\
line-editing/rl_comp_function.c\
line-editing/rl_default_function.c\
line-editing/rl_display.c\
line-editing/rl_dynamic_buffer.c\
line-editing/rl_long_move_function.c\
line-editing/rl_merge_line.c\
line-editing/rl_page_move_function.c\
line-editing/rl_prompt.c\
line-editing/rl_quoting_function.c\
line-editing/rl_remove_function.c\
line-editing/rl_setup.c\
line-editing/rl_short_move_function.c\
line-editing/rl_stack_line.c\
line-editing/rl_state_function.c\
line-editing/rl_word_move_function.c\
line-editing/rl_word_utility.c\
line-editing/builtin_history.c\
line-editing/check_backslash.c\
line-editing/copy_cut_paste.c\
line-editing/ft_split_whitespaces.c\
line-editing/get_touch.c\
line-editing/get_touch_toolz.c\
line-editing/get_touch_toolz_2.c\
line-editing/heredoc.c\
line-editing/history_parsing.c\
line-editing/history_parsing_toolz.c\
line-editing/history_parsing_toolz_2.c\
line-editing/list_toolz.c\
line-editing/move_to_line.c\
line-editing/print_and_del.c\
line-editing/prompt.c\
line-editing/quotes_gest.c\
line-editing/reader.c\
line-editing/readline.c\
line-editing/surch_in_history.c\
line-editing/tool_line.c\
line-editing/tool_line_2.c\
line-editing/toolz.c\
line-editing/toolz2.c\
line-editing/toolz_parseur.c\
line-editing/toolz_termcaps.c\
main/data_exit.c\
main/data_init.c\
main/data_singleton.c\

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/04 16:31:18 by wescande #+# #+# */
/* Updated: 2017/01/30 12:12:23 by wescande ### ########.fr */
/* Updated: 2017/01/30 17:14:48 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -42,15 +42,16 @@ typedef struct s_expand
char *s1;
} t_expand;
char **glob(const char *str, const unsigned char *esc, char **env);
void expand_brace(t_glob *tglob);
void glob_print(t_list *token, t_data *data);
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_recursive(t_glob *tglob, char *p, const char *pat);
/*
** interface of glob.
** It fill all token->expand_data with correspind expansion
*/
void glob_expand_token(t_list *token, t_data *data);
/*
** return TRUE if path file is a directory.
*/
int is_directory(const char *path);
/*
** return TRUE if char at str_pos in ini_str is escape.
@ -58,6 +59,21 @@ int is_directory(const char *path);
int is_char_esc(const unsigned char *esc,
const char *ini_str, const char *str_pos);
/*
** Internal function.
**
**
**
**
**
**
**
*/
char **glob(const char *str, const unsigned char *esc, char **env);
void expand_brace(t_glob *tglob);
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_recursive(t_glob *tglob, char *p, const char *pat);
/*
** LIST D:
*/

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/01 12:15:50 by jhalford #+# #+# */
/* Updated: 2017/01/30 13:07:23 by wescande ### ########.fr */
/* Updated: 2017/01/30 17:05:20 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -63,6 +63,7 @@ struct s_token
{
t_type type;
char *data;
char **expand_data;
unsigned char *esc;
int size;
};

View file

@ -1,18 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* glob_print.c :+: :+: :+: */
/* glob_expand_token.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/05 16:09:40 by wescande #+# #+# */
/* Updated: 2017/01/27 21:57:24 by wescande ### ########.fr */
/* Created: 2017/01/30 17:10:34 by wescande #+# #+# */
/* Updated: 2017/01/30 17:12:02 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "glob.h"
void ft_tabprint_fd(char **mytab, int fd)
static void ft_tabprint_fd(char **mytab, int fd)
{
int i;
@ -26,12 +26,11 @@ void ft_tabprint_fd(char **mytab, int fd)
}
}
void glob_print(t_list *lst, t_data *data)
void glob_expand_token(t_list *lst, t_data *data)
{
t_token *token;
int i;
t_type type;
char **glob_ret;
while (lst)
{
@ -40,9 +39,10 @@ void glob_print(t_list *lst, t_data *data)
type = token->type;
while (type >> (i++ + 2))
;
glob_ret = glob(token->data, token->esc, data->env);
DG("%02i '%s'", i, token->data);
ft_tabprint_fd(glob_ret, 3);
token->expand_data = glob(token->data, token->esc, data->env);
DG("EXPANSION DU TOKEN : %02i '%s'", i, token->data);
ft_tabprint_fd(token->expand_data, 4);
DG("FIN DE L'EXPANSION DU TOKEN");
lst = lst->next;
}
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/03 12:07:30 by jhalford #+# #+# */
/* Updated: 2017/01/27 21:54:05 by wescande ### ########.fr */
/* Updated: 2017/01/30 17:06:23 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -21,6 +21,7 @@ void token_free(void *data, size_t size)
if (!(token->type & TK_NON_FREEABLE))
{
ft_strdel(&token->data);
ft_tabdel(&token->expand_data);
ft_memdel((void **)&token->esc);
}
free(token);

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/10 15:30:25 by jhalford #+# #+# */
/* Updated: 2017/01/27 21:54:53 by wescande ### ########.fr */
/* Updated: 2017/01/30 17:05:55 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -21,5 +21,6 @@ t_token *token_init(void)
token->size = 8;
token->data = ft_strnew(token->size + 1);
token->esc = (unsigned char *)ft_strnew(token->size / 8 + 1);
token->expand_data = NULL;
return (token);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
/* Updated: 2017/01/30 13:09:12 by wescande ### ########.fr */
/* Updated: 2017/01/30 17:15:28 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -30,7 +30,7 @@ int shell_single_command(char *command)
return (1);
DG("after post_tokenize");
token_print(token);
glob_print(token, data_singleton());
glob_expand_token(token, data_singleton());
if (ft_parse(&ast, &token))
return (1);
btree_print(STDBUG, ast, &ft_putast);