small adjust in files

This commit is contained in:
LuckyLaszlo
2021-12-16 05:05:25 +01:00
parent 20c71bccbb
commit 06f1987ae4
6 changed files with 60 additions and 72 deletions

View File

@@ -6,14 +6,13 @@
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/24 10:52:40 by lperrey #+# #+# */
/* Updated: 2021/12/12 21:18:52 by lperrey ### ########.fr */
/* Updated: 2021/12/16 04:58:12 by lperrey ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void save_redirections_words(t_token *t);
void print_pipeline(t_cmd **pipeline);
t_cmd **parsing(t_token *token_list)
{
@@ -24,32 +23,19 @@ t_cmd **parsing(t_token *token_list)
// 2.9.1 - 1) Save Words
save_redirections_words(token_list);
// Struct CMD alloc
pipeline = pipeline_alloc(1 + count_pipes(token_list));
if (!pipeline)
return (NULL);
// 2.9.1 - 2) Expansion
// TEST TOKENS PRINT
/* ft_putstr_fd("TOKENS LIST :\n-----------\n", STDERR_FILENO);
ft_lstprint((t_list *)token_list, STDERR_FILENO); */
//
if (!expansions(token_list, pipeline))
return (ft_retp_free(NULL, &pipeline, (t_free_f)free_pipeline));
//
/* ft_putstr_fd("TOKENS LIST EXPANDED :\n-----------\n", STDERR_FILENO);
ft_lstprint((t_list *)token_list, STDERR_FILENO); */
// 2.9.1 - 3) Redirection
if (!redirections(token_list, pipeline))
return (ft_retp_free(NULL, &pipeline, (t_free_f)free_pipeline));
// Struct CMD fill
if (!pipeline_fill_argv(token_list, pipeline))
return (ft_retp_free(NULL, &pipeline, (t_free_f)free_pipeline));
//print_pipeline(pipeline);
return (pipeline);
}
@@ -67,21 +53,20 @@ void save_redirections_words(t_token *t)
}
}
void print_pipeline(t_cmd **pipeline)
{
int i;
/*
2.9.1 Simple Commands
2.9.1 - 1) Save Words
2.9.1 - 2) Expansion
2.9.1 - 3) Redirection
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
#tag_18_09_01
*/
i = 0;
while (pipeline[i])
{
printf("CMD %i, fd_in=%i, fd_out=%i\n", i, pipeline[i]->fd_in, pipeline[i]->fd_out);
ft_putstr_fd(" |", 1);
print_matrix(pipeline[i]->argv, "|\n |");
i++;
if (pipeline[i])
ft_putstr_fd("----------------\n", 1);
}
}
/*
2.10 Shell Grammar
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
#tag_18_10
*/
/* -------------------------------------------------------
The grammar symbols