/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* collect_assigns.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: dkaiser 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 == '\''); }