diff options
Diffstat (limited to 'src/env_to_strlst.c')
| -rw-r--r-- | src/env_to_strlst.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/env_to_strlst.c b/src/env_to_strlst.c index c4c98c3..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: 2024/12/17 19:22:36 by chuhlig ### ########.fr */ +/* Updated: 2025/01/18 18:50:49 by chuhlig ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,20 +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) { - 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); @@ -36,6 +48,8 @@ char **env_to_strlst(t_env *env) cur = env; while (i < size) { + if (ft_strchr(cur->name, '?')) + cur = cur->next; result[i] = get_var_assign(cur); cur = cur->next; i++; @@ -55,4 +69,4 @@ static char *get_var_assign(t_env *cur) result = ft_strjoin(left_side, cur->value); free(left_side); return (result); -}
\ No newline at end of file +} |
