diff options
| author | Dominik Kaiser | 2025-01-20 18:46:39 +0100 |
|---|---|---|
| committer | GitHub | 2025-01-20 18:46:39 +0100 |
| commit | 9fa887da20e409c2f25fac44b57f999e508a30ea (patch) | |
| tree | 7e3fee3edea18d0d81abddb89104858cfc0ec5e3 /src/env_to_strlst.c | |
| parent | af9d1a9b39daaf1b86cf94ee629e06503d8ab6d4 (diff) | |
| parent | 62845ce01f222fad126372c574c7ab084478adf0 (diff) | |
| download | minishell-9fa887da20e409c2f25fac44b57f999e508a30ea.tar.gz minishell-9fa887da20e409c2f25fac44b57f999e508a30ea.zip | |
Merge pull request #30 from dpu-kaiser/merge_format_redir
Merge format redir
Diffstat (limited to 'src/env_to_strlst.c')
| -rw-r--r-- | src/env_to_strlst.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/env_to_strlst.c b/src/env_to_strlst.c index a1ab7cc..5806d96 100644 --- a/src/env_to_strlst.c +++ b/src/env_to_strlst.c @@ -6,7 +6,7 @@ /* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/12/17 19:22:28 by chuhlig #+# #+# */ -/* Updated: 2025/01/14 19:34:10 by chuhlig ### ########.fr */ +/* Updated: 2025/01/18 18:50:49 by chuhlig ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,25 +15,32 @@ static char *get_var_assign(t_env *cur); -char **env_to_strlst(t_env *env) +static int getsize(t_env *env) { int size; t_env *cur; - char **result; - int i; size = 0; cur = env; - while (cur != NULL) + while (cur) { - if (ft_strchr(cur->name, '?')) - { - cur = cur->next; - continue ; - } - size++; + if (!ft_strchr(cur->name, '?')) + size++; cur = cur->next; } + return (size); +} + +char **env_to_strlst(t_env *env) +{ + int size; + t_env *cur; + char **result; + int i; + + size = 0; + cur = env; + size = getsize(env); result = malloc(sizeof(char *) * (size + 1)); if (result == NULL) return (NULL); |
