aboutsummaryrefslogtreecommitdiff
path: root/src/collect_redirs.c
diff options
context:
space:
mode:
authorChristopher Uhlig2025-01-23 18:41:18 +0100
committerChristopher Uhlig2025-01-23 18:41:18 +0100
commit18fb7cb8ae69fc3439266a154aa6b0f947d6805d (patch)
tree2cbdd7ab727d82cb69ea7acc431e2ffcc317e4ff /src/collect_redirs.c
parent202a5a26d1c0411c441cf12be2b22318abc4f3f9 (diff)
downloadminishell-18fb7cb8ae69fc3439266a154aa6b0f947d6805d.tar.gz
minishell-18fb7cb8ae69fc3439266a154aa6b0f947d6805d.zip
a
Diffstat (limited to 'src/collect_redirs.c')
-rw-r--r--src/collect_redirs.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/collect_redirs.c b/src/collect_redirs.c
index d40cee4..8f5dadc 100644
--- a/src/collect_redirs.c
+++ b/src/collect_redirs.c
@@ -6,7 +6,7 @@
/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/02 13:49:31 by dkaiser #+# #+# */
-/* Updated: 2025/01/22 16:08:25 by chuhlig ### ########.fr */
+/* Updated: 2025/01/23 18:22:04 by chuhlig ### ########.fr */
/* */
/* ************************************************************************** */
@@ -21,7 +21,7 @@ static int set_heredoc_data(t_token *cur, t_redirection *result,
t_env *env);
t_redirection *collect_redirs(t_token **tokens, t_env *env,
- t_list **create_files)
+ t_list **create_files)// tokes is possition after pipe or first token
{
t_redirection *result;
t_token *cur;
@@ -31,14 +31,15 @@ t_redirection *collect_redirs(t_token **tokens, t_env *env,
result = malloc(sizeof(t_redirection) * 2);
if (result == NULL)
return (free_tokens(*tokens), NULL);
- free(set_redir(&result[0], 0, NULL, env));
- free(set_redir(&result[1], 0, NULL, env));
+ free(set_redir(&result[0], 0, NULL, env));// no token use
+ free(set_redir(&result[1], 0, NULL, env));// no token use
data.create_files = create_files;
data.env = env;
while (cur != NULL)
{
- if (cur->type == REDIR_TOKEN && cur->next->type == STRING_TOKEN)
- collect_and_check_redir(result, &cur, &data, tokens);
+ if (cur->type == REDIR_TOKEN && cur->next->type == STRING_TOKEN)//could this be a problem with recursion?
+ collect_and_check_redir(result, &cur, &data, tokens);// cur=token is just in there to free and connect dont know if its ok
+ //return or better said does
else if (cur->type == REDIR_TOKEN)
return (free(result), NULL);
else
@@ -56,20 +57,21 @@ static void collect_and_check_redir(t_redirection *result, t_token **cur,
str = ft_strdup((*cur)->next->content.string);
if ((*cur)->content.redir_type == INPUT_LIMITER)
{
- if (!set_heredoc_data(*cur, result, data->env))
+ if (!set_heredoc_data(*cur, result, data->env))// set here doc data with token head or first token after pipe
return ;
}
else if ((*cur)->content.redir_type == INPUT_FILE)
q4fc(data->create_files, set_redir(&result[0], INPUT_FILE,
- format_string(str, data->env, 0), data->env));
+ format_string(str, data->env, 0), data->env));//here toke list should be not messed up
else if ((*cur)->content.redir_type == OUTPUT_OVERRIDE)
q4fc(data->create_files, set_redir(&result[1], OUTPUT_OVERRIDE,
format_string(str, data->env, 0), data->env));
else if ((*cur)->content.redir_type == OUTPUT_APPEND)
q4fc(data->create_files, set_redir(&result[1], OUTPUT_APPEND,
format_string(str, data->env, 0), data->env));
- i_love_the_norme(cur, tokens);
-}
+ i_love_the_norme(cur, tokens);// takes adress of token head or pos after pipe and the token specifer
+}// i love the norm simple does free token and connect
+//later more detailes
static t_redirection *set_redir(t_redirection *redir, int type, char *spec,
t_env *env)