norminette expander_parse_string.c
This commit is contained in:
parent
3babb7ca3d
commit
d883cc7517
@ -6,7 +6,7 @@
|
|||||||
/* By: qmennen <qmennen@student.codam.nl> +#+ */
|
/* By: qmennen <qmennen@student.codam.nl> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2025/02/18 19:00:35 by qmennen #+# #+# */
|
/* 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
|
static void expander_parse_loop(char *s, t_list *current, char *string)
|
||||||
char *expander_parse_string(char *s, t_minishell *msh)
|
|
||||||
{
|
{
|
||||||
t_list *variables;
|
|
||||||
t_list *current;
|
|
||||||
char *string;
|
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
variables = expander_parse_variables(s, msh);
|
|
||||||
string = expander_allocate_memory(msh, s, variables);
|
|
||||||
current = variables;
|
|
||||||
i = 0;
|
i = 0;
|
||||||
j = 0;
|
j = 0;
|
||||||
while (s[i])
|
while (s[i])
|
||||||
@ -58,6 +51,19 @@ char *expander_parse_string(char *s, t_minishell *msh)
|
|||||||
string[j++] = s[i++];
|
string[j++] = s[i++];
|
||||||
}
|
}
|
||||||
string[j] = 0;
|
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);
|
free_variables(msh, variables);
|
||||||
return (string);
|
return (string);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user