diff options
| author | Christopher Uhlig | 2024-08-11 15:15:06 +0200 |
|---|---|---|
| committer | Dominik Kaiser | 2024-08-11 15:42:30 +0200 |
| commit | 0d4f9e94f6d28a154ae4be3b918bfb014b4fa1e0 (patch) | |
| tree | ff66a099b7f364dc2e50d91b8b397df0ba1e4e0c /src/tokenizer.c | |
| parent | 8abf7abdc9d49f52c4fcad0afc92730c4c195b7f (diff) | |
| download | minishell-0d4f9e94f6d28a154ae4be3b918bfb014b4fa1e0.tar.gz minishell-0d4f9e94f6d28a154ae4be3b918bfb014b4fa1e0.zip | |
fixed |> fixed norm added new function
Diffstat (limited to 'src/tokenizer.c')
| -rw-r--r-- | src/tokenizer.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/tokenizer.c b/src/tokenizer.c index 34685ac..a9a86ca 100644 --- a/src/tokenizer.c +++ b/src/tokenizer.c @@ -6,7 +6,7 @@ /* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/28 20:55:50 by chuhlig #+# #+# */ -/* Updated: 2024/08/09 15:40:00 by chuhlig ### ########.fr */ +/* Updated: 2024/08/11 14:52:54 by chuhlig ### ########.fr */ /* */ /* ************************************************************************** */ @@ -36,7 +36,7 @@ void print_token(t_token *token) } } -void conditional_print(char *string, int start_of_string, int i, +void snap_string_token(char *string, int start_of_string, int i, t_token **token_list) { char *line; @@ -64,7 +64,7 @@ void conditional_print(char *string, int start_of_string, int i, void handle_special_chars(char *s, int *i, int *start, t_token **token_list) { - conditional_print(s, *start, *i - 1, token_list); + snap_string_token(s, *start, *i - 1, token_list); if (s[*i] == '<' && s[*i + 1] == '<') *token_list = new_redir_token(INPUT_LIMITER, *token_list, NULL); else if (s[*i] == '>' && s[*i + 1] == '>') @@ -78,14 +78,15 @@ void handle_special_chars(char *s, int *i, int *start, t_token **token_list) else if (s[*i] == '\n') *token_list = new_token(NEWLINE_TOKEN, *token_list, NULL); print_token(*token_list); - if (s[*i + 1] == '<' || s[*i + 1] == '>') + if (s[*i] == '<' && s[*i + 1] == '<') + (*i)++; + if (s[*i] == '>' && s[*i + 1] == '>') (*i)++; *start = *i + 1; } -void tokenizer(char *s, t_token **token_list) +void tokenizer(char *s, t_token **token_list, char quote_check) { - char quote_check; int pos; int i; int f; @@ -104,9 +105,9 @@ void tokenizer(char *s, t_token **token_list) f = 1; quote_check = s[i]; } - if ((!f && (s[i] == ' ' || s[i] == '\t')) || i == ft_strlen(s) - 1) + if ((!f && (ft_isspace(s[i + 1]))) || i == ft_strlen(s) - 1) { - conditional_print(s, pos, i, token_list); + snap_string_token(s, pos, i, token_list); pos = i + 1; } } |
