diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-06-23 09:09:17 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-06-23 10:31:27 +0200 |
| commit | 11b258841f4a15c514c49af7d378b51cd6a8ab79 (patch) | |
| tree | 0df3f625f49fc1a8ca0e74f81272120f07a35feb /src/lexer/lexer.c | |
| parent | 58fc321ec43be4c3f7976769733116232361857a (diff) | |
| download | minishell-11b258841f4a15c514c49af7d378b51cd6a8ab79.tar.gz minishell-11b258841f4a15c514c49af7d378b51cd6a8ab79.tar.bz2 minishell-11b258841f4a15c514c49af7d378b51cd6a8ab79.zip | |
Fixing builtin which needed to not be run in a child process, Added exit builtin
Diffstat (limited to 'src/lexer/lexer.c')
| -rw-r--r-- | src/lexer/lexer.c | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/src/lexer/lexer.c b/src/lexer/lexer.c index 9b43616..dd34654 100644 --- a/src/lexer/lexer.c +++ b/src/lexer/lexer.c @@ -69,24 +69,24 @@ int check_input_out(char *input) return(0); } -t_token *lexer_lst_token_str(char *input, int i, int j) -{ - t_token *lst_token; - - if (!(lst_token = malloc(sizeof(t_token) * 1))) - return (NULL); - lst_token->tag = 0; - lst_token->content = NULL; - if (!(lst_token->content = malloc(sizeof(char) * j + 1))) - return(0); - if (!(ft_strlcpy(lst_token->content, &input[i], j + 1))) - { - free(lst_token); - return(0); - } - - return (lst_token); -} +/* t_token *lexer_lst_token_str(char *input, int i, int j) */ +/* { */ +/* t_token *lst_token; */ +/* */ +/* if (!(lst_token = malloc(sizeof(t_token) * 1))) */ +/* return (NULL); */ +/* lst_token->tag = 0; */ +/* lst_token->content = NULL; */ +/* if (!(lst_token->content = malloc(sizeof(char) * j + 1))) */ +/* return(0); */ +/* if (!(ft_strlcpy(lst_token->content, &input[i], j + 1))) */ +/* { */ +/* free(lst_token); */ +/* return(0); */ +/* } */ +/* */ +/* return (lst_token); */ +/* } */ enum e_token_tag token_verif_stick(t_token *lst_token) { @@ -151,9 +151,10 @@ static t_ftlst *create_token_list(char *input, t_ftlst **lst) { j = 0; j += check_input(&input[i]); - lst_token = lexer_lst_token_str(input,i,j); + /* lst_token = lexer_lst_token_str(input,i,j); */ + lst_token = token_new_until(0, input + i, j); lst_token = push_token_enum(lst_token); - new = ft_lstnew((void *) lst_token); + new = ft_lstnew(lst_token); ft_lstpush_back(lst, new); i += j; } @@ -165,10 +166,7 @@ t_ftlst *lexer(char *input) t_ftlst *lst; if (!input) - return (0); - lst = malloc(sizeof(t_ftlst ) * 1); - if (!lst) - return(0); + return (NULL); lst = NULL; lst = create_token_list(input, &lst); lst = lexe_trim_out(lst); |
