aboutsummaryrefslogtreecommitdiff
path: root/src/collect_redirs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/collect_redirs.c')
-rw-r--r--src/collect_redirs.c53
1 files changed, 28 insertions, 25 deletions
diff --git a/src/collect_redirs.c b/src/collect_redirs.c
index 350cf6b..aeaf177 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/20 13:03:47 by dkaiser ### ########.fr */
+/* Updated: 2025/01/20 13:17:59 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
@@ -20,7 +20,8 @@ static t_redirection *set_redir(t_redirection *redir, int type, char *spec,
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_redirection *collect_redirs(t_token **tokens, t_env *env,
+ t_list **create_files)
{
t_redirection *result;
t_token *cur;
@@ -45,28 +46,6 @@ t_redirection *collect_redirs(t_token **tokens, t_env *env, t_list **create_file
return (result);
}
-static t_redirection *set_redir(t_redirection *redir, int type, char *spec,
- t_env *env)
-{
- t_redirection *result;
-
- redir->type = type;
- if (spec != NULL)
- redir->specifier = format_string(spec, env);
- else
- redir->specifier = spec;
- if (redir->type == OUTPUT_APPEND || redir->type == OUTPUT_OVERRIDE)
- {
- result = malloc(sizeof(t_redirection));
- if (!result)
- return (NULL);
- result->type = type;
- result->specifier = spec;
- return (result);
- }
- return (NULL);
-}
-
static void collect_and_check_redir(t_redirection *result, t_token **cur,
t_env *env, t_list **create_files)
{
@@ -89,7 +68,7 @@ static void collect_and_check_redir(t_redirection *result, t_token **cur,
ft_lstadd_back(create_files, ft_lstnew(set_redir(&result[1],
OUTPUT_APPEND, format_string(str, env), env)));
next_token = (*cur)->next;
- free_token_and_connect(*cur);
+ // free_token_and_connect(*cur);
if (next_token)
{
*cur = next_token->next;
@@ -99,6 +78,30 @@ static void collect_and_check_redir(t_redirection *result, t_token **cur,
*cur = NULL;
}
+static t_redirection *set_redir(t_redirection *redir, int type, char *spec,
+ t_env *env)
+{
+ t_redirection *result;
+
+ redir->type = type;
+ if (spec != NULL)
+ redir->specifier = format_string(spec, env, ft_atoi("0"));
+ else
+ redir->specifier = spec;
+ if (redir->type == OUTPUT_APPEND || redir->type == OUTPUT_OVERRIDE)
+ {
+ result = malloc(sizeof(t_redirection));
+ if (!result)
+ return (NULL);
+ result->type = type;
+ result->specifier = spec;
+ return (result);
+ }
+ return (NULL);
+}
+
+
+
static int set_heredoc_data(t_token *cur, t_redirection *result, t_env *env)
{
char *heredoc_data;