🔨」 fix: working parsing

This commit is contained in:
2024-07-06 13:36:03 +02:00
parent 4793df800d
commit 22f7565d47
3 changed files with 48 additions and 52 deletions

View File

@ -34,4 +34,9 @@ char set_env(char **env, const char *name, char *content);
bool is_str(char *src, char *dst); bool is_str(char *src, char *dst);
void print_cmd(t_cmd *cmd); void print_cmd(t_cmd *cmd);
void free_redir(void *redir_v);
void free_token(void *token_v);
void free_cmd(void *content);
#endif #endif

42
src/free_list.c Normal file
View File

@ -0,0 +1,42 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* free_list.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/04 20:10:35 by adjoly #+# #+# */
/* Updated: 2024/07/04 20:12:06 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include "parsing.h"
void free_redir(void *redir_v)
{
t_redirection *redir;
redir = redir_v;
free(redir->file_name);
}
void free_token(void *token_v)
{
t_token *token;
token = token_v;
free(token->argv);
ft_lstclear(&(token->redirection), free_redir);
free(token);
}
void free_cmd(void *content)
{
t_cmd *cmd;
cmd = (t_cmd *)content;
free(cmd->cmd);
ft_free("a", &(cmd->argv));
free(cmd);
}

View File

@ -6,7 +6,7 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */ /* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/24 11:18:04 by adjoly #+# #+# */ /* Created: 2024/04/24 11:18:04 by adjoly #+# #+# */
/* Updated: 2024/07/04 17:02:14 by adjoly ### ########.fr */ /* Updated: 2024/07/04 20:17:22 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -24,47 +24,6 @@
#include "parsing.h" #include "parsing.h"
#include "prompt.h" #include "prompt.h"
void free_redir(void *redir_v)
{
t_redirection *redir;
redir = redir_v;
free(redir->file_name);
}
void free_token(void *token_v)
{
t_token *token;
token = token_v;
print_token(token);
free(token->argv);
ft_lstclear(&(token->redirection), free_redir);
free(token);
}
/*void print_cmd(t_cmd cmd)
{
ft_putendl_fd(cmd.cmd, 1);
while (*(cmd.argv))
{
ft_putendl_fd(*(cmd.argv), 1);
(cmd.argv)++;
}
}*/
void print_pipe(t_list *pipe)
{
t_list *tmp;
tmp = pipe;
while (tmp)
{
ft_putendl_fd(tmp->content, STDOUT_FILENO);
tmp = tmp->next;
}
}
void sig_c(int code) void sig_c(int code)
{ {
(void)code; (void)code;
@ -74,16 +33,6 @@ void sig_c(int code)
rl_redisplay(); rl_redisplay();
} }
void free_cmd(void *content)
{
t_cmd *cmd;
cmd = (t_cmd *)content;
free(cmd->cmd);
ft_free("a", &(cmd->argv));
free(cmd);
}
int main(int ac, char **av, char **env) int main(int ac, char **av, char **env)
{ {
char *rl; char *rl;