diff --git a/libft/ft_isspace.c b/libft/ft_isspace.c index 909a73f..4d99ecf 100644 --- a/libft/ft_isspace.c +++ b/libft/ft_isspace.c @@ -6,7 +6,7 @@ /* By: mcombeau +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/11/22 13:53:06 by mcombeau #+# #+# */ -/* Updated: 2022/09/25 14:52:20 by mcombeau ### ########.fr */ +/* Updated: 2022/11/10 00:57:38 by alexa ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,7 +20,8 @@ int ft_isspace(int c) { - if (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\v' || c == '\f') + if (c == ' ' || c == '\t' || c == '\n' || c == '\r' + || c == '\v' || c == '\f') return (c); return (0); } diff --git a/minitester b/minitester index b82f8ed..1fe9ac4 160000 --- a/minitester +++ b/minitester @@ -1 +1 @@ -Subproject commit b82f8edaea70c54acb007345df53eb24fc80a867 +Subproject commit 1fe9ac4f633382936dd844c60ddbdee977662235 diff --git a/sources/expansion/replace_var.c b/sources/expansion/replace_var.c index 0519256..24a7279 100644 --- a/sources/expansion/replace_var.c +++ b/sources/expansion/replace_var.c @@ -1,3 +1,14 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* replace_var.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: alexa +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/11/10 00:51:45 by alexa #+# #+# */ +/* Updated: 2022/11/10 00:51:47 by alexa ### ########.fr */ +/* */ +/* ************************************************************************** */ #include "minishell.h" diff --git a/sources/expansion/var_expander_utils.c b/sources/expansion/var_expander_utils.c index 805203b..fee0715 100644 --- a/sources/expansion/var_expander_utils.c +++ b/sources/expansion/var_expander_utils.c @@ -1,3 +1,14 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* var_expander_utils.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: alexa +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/11/10 00:52:09 by alexa #+# #+# */ +/* Updated: 2022/11/10 00:52:18 by alexa ### ########.fr */ +/* */ +/* ************************************************************************** */ #include "minishell.h" diff --git a/sources/lexer/parse_user_input.c b/sources/lexer/parse_user_input.c index b0523be..542b1ce 100644 --- a/sources/lexer/parse_user_input.c +++ b/sources/lexer/parse_user_input.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* parse_user_input.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: alexa +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/11/10 00:01:18 by alexa #+# #+# */ +/* Updated: 2022/11/10 00:01:22 by alexa ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "minishell.h" static bool input_is_space(char *input) diff --git a/sources/parser/.fill_args_echo_utils.c.swp b/sources/parser/.fill_args_echo_utils.c.swp new file mode 100644 index 0000000..4c7c2d7 Binary files /dev/null and b/sources/parser/.fill_args_echo_utils.c.swp differ diff --git a/sources/parser/cmd_lst_utils.c b/sources/parser/cmd_lst_utils.c index deabf44..a981e03 100644 --- a/sources/parser/cmd_lst_utils.c +++ b/sources/parser/cmd_lst_utils.c @@ -1,3 +1,14 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* cmd_lst_utils.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: alexa +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/11/10 00:22:15 by alexa #+# #+# */ +/* Updated: 2022/11/10 00:22:18 by alexa ### ########.fr */ +/* */ +/* ************************************************************************** */ #include "minishell.h" diff --git a/sources/parser/cmd_lst_utils_cleanup.c b/sources/parser/cmd_lst_utils_cleanup.c index d212ba4..52c3f57 100644 --- a/sources/parser/cmd_lst_utils_cleanup.c +++ b/sources/parser/cmd_lst_utils_cleanup.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* cmd_lst_utils_cleanup.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: alexa +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/11/10 00:21:24 by alexa #+# #+# */ +/* Updated: 2022/11/10 00:21:27 by alexa ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "minishell.h" void lst_delone_cmd(t_command *lst, void (*del)(void *)) diff --git a/sources/parser/create_commands.c b/sources/parser/create_commands.c index 20406da..baf3171 100644 --- a/sources/parser/create_commands.c +++ b/sources/parser/create_commands.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* create_commands.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: alexa +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/11/10 00:16:58 by alexa #+# #+# */ +/* Updated: 2022/11/10 00:17:32 by alexa ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "minishell.h" static void prep_no_arg_commands(t_data *data) diff --git a/sources/parser/fill_args_default.c b/sources/parser/fill_args_default.c index a460e70..0ad381a 100644 --- a/sources/parser/fill_args_default.c +++ b/sources/parser/fill_args_default.c @@ -1,5 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* fill_args_default.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: alexa +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/11/10 00:05:49 by alexa #+# #+# */ +/* Updated: 2022/11/10 00:45:21 by alexa ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "minishell.h" +int count_arguments(t_token *temp) +{ + int i; + + i = 0; + while (temp && (temp->type == WORD || temp->type == VAR)) + { + i++; + temp = temp->next; + } + return (i); +} + /* ** This function fills the array of arguments of the last_cmd by default mode: ** - It allocates the array of arguments thanks to the count_args function @@ -10,16 +35,13 @@ int create_args_default_mode(t_token **token_node, t_command *last_cmd) { int i; + int nb_args; t_token *temp; i = 0; temp = *token_node; - while (temp->type == WORD || temp->type == VAR) - { - i++; - temp = temp->next; - } - last_cmd->args = malloc(sizeof(char *) * (i + 2)); + nb_args = count_arguments(temp); + last_cmd->args = malloc(sizeof(char *) * (nb_args + 2)); if (!last_cmd->args) return (FAILURE); temp = *token_node; diff --git a/sources/parser/fill_args_echo.c b/sources/parser/fill_args_echo.c index b9407a0..380aca1 100644 --- a/sources/parser/fill_args_echo.c +++ b/sources/parser/fill_args_echo.c @@ -1,3 +1,14 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* fill_args_echo.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: alexa +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/11/10 00:02:55 by alexa #+# #+# */ +/* Updated: 2022/11/10 00:03:12 by alexa ### ########.fr */ +/* */ +/* ************************************************************************** */ #include "minishell.h" diff --git a/sources/parser/fill_args_echo_utils.c b/sources/parser/fill_args_echo_utils.c index 17cec60..ef0aebd 100644 --- a/sources/parser/fill_args_echo_utils.c +++ b/sources/parser/fill_args_echo_utils.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* fill_args_echo_utils.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: alexa +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/11/10 00:10:11 by alexa #+# #+# */ +/* Updated: 2022/11/10 00:11:41 by alexa ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "minishell.h" /* diff --git a/sources/parser/parse_append.c b/sources/parser/parse_append.c index f115479..7abb360 100644 --- a/sources/parser/parse_append.c +++ b/sources/parser/parse_append.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* parse_append.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: alexa +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/11/10 00:06:46 by alexa #+# #+# */ +/* Updated: 2022/11/10 00:08:37 by alexa ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "minishell.h" /* diff --git a/sources/parser/parse_heredoc.c b/sources/parser/parse_heredoc.c index 25b3b0b..a28fd33 100644 --- a/sources/parser/parse_heredoc.c +++ b/sources/parser/parse_heredoc.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* parse_heredoc.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: alexa +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/11/10 00:09:01 by alexa #+# #+# */ +/* Updated: 2022/11/10 00:09:19 by alexa ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "minishell.h" /* get_heredoc: diff --git a/sources/parser/parse_heredoc_utils.c b/sources/parser/parse_heredoc_utils.c index 439feb9..19c206b 100644 --- a/sources/parser/parse_heredoc_utils.c +++ b/sources/parser/parse_heredoc_utils.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* parse_heredoc_utils.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: alexa +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/11/10 00:09:37 by alexa #+# #+# */ +/* Updated: 2022/11/10 00:09:40 by alexa ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "minishell.h" /* make_str_from_tab: diff --git a/sources/parser/parse_input.c b/sources/parser/parse_input.c index 3194297..a728cab 100644 --- a/sources/parser/parse_input.c +++ b/sources/parser/parse_input.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* parse_input.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: alexa +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/11/10 00:20:39 by alexa #+# #+# */ +/* Updated: 2022/11/10 00:20:42 by alexa ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "minishell.h" /* INPUT -> REDIR_IN (<) @@ -7,13 +19,6 @@ The general format for redirecting input is: [n] on trie dans l'ordre alphabetique le contenu qui se - trouve dans "mylist.txt". - wc -l < test.txt => affiche le nb de lignes dans le fichier test - - Probleme car avec ECHO ça marche différemment : -https://unix.stackexchange.com/questions/63658/redirecting-the-content-of-a-file-to-the-command-echo) */ bool remove_old_file_ref(t_io_fds *io, bool infile) @@ -41,15 +46,6 @@ bool remove_old_file_ref(t_io_fds *io, bool infile) return (true); } -/* -static void display_error(t_command *cmd, char *infile) -{ - cmd->error = errno; - cmd->err_msg = ft_strdup(strerror(errno)); - printf("bash: %s: %s\n", infile, cmd->err_msg); -} -*/ - /* open_infile: * Opens an infile. If an infile was already set, frees it * and overwrites it. If a previous infile open failed (file does diff --git a/sources/parser/parse_pipe.c b/sources/parser/parse_pipe.c index db3b714..8d63668 100644 --- a/sources/parser/parse_pipe.c +++ b/sources/parser/parse_pipe.c @@ -1,11 +1,17 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* parse_pipe.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: alexa +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/11/10 00:22:49 by alexa #+# #+# */ +/* Updated: 2022/11/10 00:22:52 by alexa ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "minishell.h" -// ex : echo bonjour | wc -l - /* - une commande deja cree : pour echo bonjour - on arrive au pipe : on doit creer une nouvelle commande - puis creer une aure commande - */ void parse_pipe(t_command **cmd, t_token **token_lst) { t_command *last_cmd; diff --git a/sources/parser/parse_trunc.c b/sources/parser/parse_trunc.c index 2edb588..2646d24 100644 --- a/sources/parser/parse_trunc.c +++ b/sources/parser/parse_trunc.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* parse_trunc.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: alexa +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/11/10 00:16:18 by alexa #+# #+# */ +/* Updated: 2022/11/10 00:16:26 by alexa ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "minishell.h" /* @@ -87,4 +99,4 @@ exemple : grep test > test.txt test1.txt *si line commence par un TRUNC (>) il faut creer la liste chainee, et faire condition existence cmd + fonction pour corriger ca -*/ \ No newline at end of file +*/ diff --git a/sources/parser/parse_word.c b/sources/parser/parse_word.c index 81744cf..11826ee 100644 --- a/sources/parser/parse_word.c +++ b/sources/parser/parse_word.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* parse_word.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: alexa +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/11/10 00:21:47 by alexa #+# #+# */ +/* Updated: 2022/11/10 00:22:01 by alexa ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "minishell.h" static bool contains_space(char *str)