From 7de89b43b17b1e193427a7c74c5f2888730219a0 Mon Sep 17 00:00:00 2001 From: Hugo LAMY Date: Mon, 20 Dec 2021 17:02:57 +0100 Subject: [PATCH] srcs a la norme --- srcs/generic/ft_split_quotes.c | 8 ++++---- srcs/generic/ft_strdup_quotes.c | 6 +++--- srcs/misc/last_exit_status.c | 14 ++------------ srcs/parsing/parsing.c | 10 ++-------- 4 files changed, 11 insertions(+), 27 deletions(-) diff --git a/srcs/generic/ft_split_quotes.c b/srcs/generic/ft_split_quotes.c index 8caf895..5b01dcd 100644 --- a/srcs/generic/ft_split_quotes.c +++ b/srcs/generic/ft_split_quotes.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/11/13 07:08:40 by lperrey #+# #+# */ -/* Updated: 2021/11/26 21:27:10 by lperrey ### ########.fr */ +/* Updated: 2021/12/20 16:45:10 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -148,7 +148,7 @@ static void fill_arr(char const *s, char c, char **str_arr) if (s[i] && (s[i] != c || quote_state)) str_arr[arr_i][char_i++] = s[i++]; } - str_arr[arr_i][char_i] = '\0'; //superflu si ft_calloc + str_arr[arr_i][char_i] = '\0'; arr_i++; } } @@ -159,7 +159,7 @@ static int quote_state_change(int *quote_state, const char *s) { if (*quote_state == IN_QUOTES) *quote_state = 0; - else if (ft_strchr(&s[1], '\'')) // if closed quotes + else if (ft_strchr(&s[1], '\'')) *quote_state = IN_QUOTES; else return (0); @@ -169,7 +169,7 @@ static int quote_state_change(int *quote_state, const char *s) { if (*quote_state == IN_DQUOTES) *quote_state = 0; - else if (ft_strchr(&s[1], '\"')) // if closed quotes + else if (ft_strchr(&s[1], '\"')) *quote_state = IN_DQUOTES; else return (0); diff --git a/srcs/generic/ft_strdup_quotes.c b/srcs/generic/ft_strdup_quotes.c index 65d04fb..d0df9aa 100644 --- a/srcs/generic/ft_strdup_quotes.c +++ b/srcs/generic/ft_strdup_quotes.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/11/13 04:35:06 by lperrey #+# #+# */ -/* Updated: 2021/11/26 21:27:05 by lperrey ### ########.fr */ +/* Updated: 2021/12/20 16:29:27 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -44,7 +44,7 @@ static int quote_state_change(int *quote_state, const char *s) { if (*quote_state == IN_QUOTES) *quote_state = 0; - else if (ft_strchr(&s[1], '\'')) // if closed quotes + else if (ft_strchr(&s[1], '\'')) *quote_state = IN_QUOTES; else return (0); @@ -54,7 +54,7 @@ static int quote_state_change(int *quote_state, const char *s) { if (*quote_state == IN_DQUOTES) *quote_state = 0; - else if (ft_strchr(&s[1], '\"')) // if closed quotes + else if (ft_strchr(&s[1], '\"')) *quote_state = IN_DQUOTES; else return (0); diff --git a/srcs/misc/last_exit_status.c b/srcs/misc/last_exit_status.c index 13da226..e61c2d3 100644 --- a/srcs/misc/last_exit_status.c +++ b/srcs/misc/last_exit_status.c @@ -6,13 +6,13 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/11/26 19:02:27 by lperrey #+# #+# */ -/* Updated: 2021/11/26 20:48:11 by lperrey ### ########.fr */ +/* Updated: 2021/12/20 16:48:02 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" -int set_last_exit_status(int new_value) +int set_last_exit_status(int new_value) { static int last_exit_status = 0; @@ -25,13 +25,3 @@ int get_last_exit_status(void) { return (set_last_exit_status(-1)); } - -/* void ALT_set_last_exit_status(int new_value, int *set_last_exit_status_ptr) -{ - static int *last_exit_status_ptr = NULL; - - if (set_last_exit_status_ptr) - last_exit_status_ptr = set_last_exit_status_ptr; - else if (new_value >= 0) - *last_exit_status_ptr = new_value; -} */ diff --git a/srcs/parsing/parsing.c b/srcs/parsing/parsing.c index eb9df80..4df6caa 100644 --- a/srcs/parsing/parsing.c +++ b/srcs/parsing/parsing.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/10/24 10:52:40 by lperrey #+# #+# */ -/* Updated: 2021/12/16 16:23:09 by lperrey ### ########.fr */ +/* Updated: 2021/12/20 16:22:13 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,20 +20,14 @@ t_cmd **parsing(t_token *token_list) if (!valid_syntax(token_list)) return (NULL); - - // 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 if (!expansions(token_list, pipeline)) return (ft_retp_free(NULL, &pipeline, (t_free_f)free_pipeline)); - // 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)); return (pipeline); @@ -44,7 +38,7 @@ void save_redirections_words(t_token *t) while (t) { if (t->id == '>' || t->id == T_DGREAT - || t->id == '<' || t->id == T_DLESS) + || t->id == '<' || t->id == T_DLESS) { t = t->next; t->id = T_REDIRECTION_WORD;