/* ************************************************************************** */ /* */ /* :::::::: */ /* expander_parse_string.c :+: :+: */ /* +:+ */ /* By: qmennen +#+ */ /* +#+ */ /* Created: 2025/02/18 19:00:35 by qmennen #+# #+# */ /* Updated: 2025/02/25 14:32:59 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ #include "minishell.h" static void free_variables(t_list *variables) { t_list *current; t_list *last; current = variables; while (current) { last = current; current = current->next; free(last); } } char *expander_parse_string(char *s, t_minishell *minishell) { t_list *variables; t_list *current; char *string; int i; int j; variables = expander_parse_variables(s, minishell); string = expander_allocate_memory(minishell, s, variables); i = 0; j = 0; current = variables; while (s[i]) { if (s[i] == '$' && s[i + 1]) { i++; i += expander_expand_dollar(s + i, string, &j, current); if (current) current = current->next; } else string[j++] = s[i++]; } //TODO: Figure out why echo "> echo "\as"" breaks string[j] = 0; free_variables(variables); return (string); }