diff options
| author | Dominik Kaiser | 2024-08-11 12:27:02 +0200 |
|---|---|---|
| committer | Dominik Kaiser | 2024-08-11 12:27:02 +0200 |
| commit | 99e8655aaf9827c7d5248c7f3d0913fcb1377cfb (patch) | |
| tree | fcfc4288ea38348d707ad549cd4fa04c49a446b7 /src/collect_assigns.c | |
| parent | f53acc629b1b3e7f4097eef1e26841ef0b9b24c6 (diff) | |
| download | minishell-99e8655aaf9827c7d5248c7f3d0913fcb1377cfb.tar.gz minishell-99e8655aaf9827c7d5248c7f3d0913fcb1377cfb.zip | |
Remove assigns
I found out that there's a difference between shell variables and env
variables.
We don't have to implement shell variables, so I removed all code that
handles them.
Diffstat (limited to 'src/collect_assigns.c')
| -rw-r--r-- | src/collect_assigns.c | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/src/collect_assigns.c b/src/collect_assigns.c deleted file mode 100644 index da43503..0000000 --- a/src/collect_assigns.c +++ /dev/null @@ -1,84 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* collect_assigns.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/08/02 13:54:36 by dkaiser #+# #+# */ -/* Updated: 2024/08/02 14:37:41 by dkaiser ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "minishell.h" -#include "token.h" - -static t_assign *to_assign(char *str); -static int count_tokens(t_token *tokens); -static int is_quote(char c); - -t_assign **collect_assigns(t_token **tokens) -{ - t_token *cur; - t_assign **result; - int i; - - result = malloc(sizeof(t_assign *) * (count_tokens(*tokens) + 1)); - if (result == NULL) - return (free_tokens(*tokens), NULL); - cur = *tokens; - i = 0; - while (cur != NULL && cur->type == STRING_TOKEN - && !is_quote(cur->content.string[0]) && ft_strchr(cur->content.string, - '=') != NULL) - { - result[i++] = to_assign(cur->content.string); - if (cur->next != NULL) - { - cur = cur->next; - free_token(cur->previous); - } - else - free_token(cur); - } - *tokens = cur; - result[i] = NULL; - return (result); -} - -static t_assign *to_assign(char *str) -{ - t_assign *result; - char *split_pos; - - split_pos = ft_strchr(str, '='); - *split_pos = '\0'; - result = malloc(sizeof(t_assign)); - if (result == NULL) - { - return (NULL); - } - result->var = str; - result->value = split_pos + 1; - return (result); -} - -static int count_tokens(t_token *tokens) -{ - int len; - - len = 0; - while (tokens != NULL && tokens->type == STRING_TOKEN - && !is_quote(tokens->content.string[0]) - && ft_strchr(tokens->content.string, '=') != NULL) - { - len++; - tokens = tokens->next; - } - return (len); -} - -static int is_quote(char c) -{ - return (c == '"' || c == '\''); -} |
