norminette expander_parse_string.c

This commit is contained in:
whaffman 2025-03-17 13:39:17 +01:00
parent 3babb7ca3d
commit d883cc7517

View File

@ -6,7 +6,7 @@
/* By: qmennen <qmennen@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/02/18 19:00:35 by qmennen #+# #+# */
/* Updated: 2025/02/26 22:56:05 by whaffman ######## odam.nl */
/* Updated: 2025/03/17 13:24:23 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
@ -26,18 +26,11 @@ static void free_variables(t_minishell *msh, t_list *variables)
}
}
//TODO: Figure out why echo "> echo "\as"" breaks
char *expander_parse_string(char *s, t_minishell *msh)
static void expander_parse_loop(char *s, t_list *current, char *string)
{
t_list *variables;
t_list *current;
char *string;
int i;
int j;
int i;
int j;
variables = expander_parse_variables(s, msh);
string = expander_allocate_memory(msh, s, variables);
current = variables;
i = 0;
j = 0;
while (s[i])
@ -58,6 +51,19 @@ char *expander_parse_string(char *s, t_minishell *msh)
string[j++] = s[i++];
}
string[j] = 0;
}
//TODO: Figure out why echo "> echo "\as"" breaks
char *expander_parse_string(char *s, t_minishell *msh)
{
t_list *variables;
t_list *current;
char *string;
variables = expander_parse_variables(s, msh);
string = expander_allocate_memory(msh, s, variables);
current = variables;
expander_parse_loop(s, current, string);
free_variables(msh, variables);
return (string);
}