mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
parsing: fix some easy leaks
This commit is contained in:
parent
d40b6c3586
commit
0c489f25bb
2 changed files with 22 additions and 19 deletions
|
|
@ -5,14 +5,15 @@
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/04/14 16:09/29 by khais #+# #+# */
|
/* Created: 2025/04/14 17:18/55 by khais #+# #+# */
|
||||||
/* Updated: 2025/04/14 16:09:29 by khais ### ########.fr */
|
/* Updated: 2025/04/14 17:18:55 by khais ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
#include "env/env.h"
|
#include "env/env.h"
|
||||||
#include "get_command.h"
|
#include "get_command.h"
|
||||||
|
#include "parser/cmd/cmd_destroy.h"
|
||||||
#include "parser/simple_cmd/simple_cmd.h"
|
#include "parser/simple_cmd/simple_cmd.h"
|
||||||
#include "parser/wordlist/wordlist.h"
|
#include "parser/wordlist/wordlist.h"
|
||||||
#include "parser/wordsplit/wordsplit.h"
|
#include "parser/wordsplit/wordsplit.h"
|
||||||
|
|
@ -78,26 +79,28 @@ static void app_init(t_minishell *app, char **envp)
|
||||||
|
|
||||||
int main(int argc, char *argv[], char **envp)
|
int main(int argc, char *argv[], char **envp)
|
||||||
{
|
{
|
||||||
char *line;
|
char *line;
|
||||||
t_simple_cmd *cmd;
|
t_cmd *cmd;
|
||||||
t_minishell app;
|
t_minishell app;
|
||||||
|
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
app_init(&app, envp);
|
app_init(&app, envp);
|
||||||
|
|
||||||
/* line = "echo coucou"; */
|
line = "echo coucou";
|
||||||
/* minishell_parse(&app, line); */
|
cmd = minishell_parse(&app, line);
|
||||||
/* return (0); */
|
cmd_destroy(cmd);
|
||||||
|
|
||||||
line = get_command();
|
|
||||||
while (line != NULL)
|
|
||||||
{
|
|
||||||
cmd = parse_command(line);
|
|
||||||
cmd = post_process_command(cmd, &app);
|
|
||||||
execute_command(cmd, &app);
|
|
||||||
line = get_command();
|
|
||||||
}
|
|
||||||
env_destroy(app.env);
|
env_destroy(app.env);
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
|
/* line = get_command(); */
|
||||||
|
/* while (line != NULL) */
|
||||||
|
/* { */
|
||||||
|
/* cmd = parse_command(line); */
|
||||||
|
/* cmd = post_process_command(cmd, &app); */
|
||||||
|
/* execute_command(cmd, &app); */
|
||||||
|
/* line = get_command(); */
|
||||||
|
/* } */
|
||||||
|
/* env_destroy(app.env); */
|
||||||
|
/* return (0); */
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/03/31 10:28:28 by jguelen #+# #+# */
|
/* Created: 2025/03/31 10:28:28 by jguelen #+# #+# */
|
||||||
/* Updated: 2025/04/14 15:10:28 by khais ### ########.fr */
|
/* Updated: 2025/04/14 17:18:21 by khais ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -173,7 +173,7 @@ t_cmd *minishell_simple_parse(t_minishell *app, t_wordlist *tokens)
|
||||||
t_redirect_add_back(&simple->value.simple->redirections, redir);
|
t_redirect_add_back(&simple->value.simple->redirections, redir);
|
||||||
}
|
}
|
||||||
if (!simple->value.simple->words)
|
if (!simple->value.simple->words)
|
||||||
return (parse_error(app, tokens->word), NULL);
|
return (cmd_destroy(simple), parse_error(app, tokens->word), NULL);
|
||||||
return (simple);
|
return (simple);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue