From 147743058dd7bf98d0c36cfd82452ec62de92a19 Mon Sep 17 00:00:00 2001 From: mcolonna Date: Mon, 1 Jul 2024 11:23:31 +0200 Subject: [PATCH] norm --- include/main.h | 12 ++++++------ include/parse_command.h | 21 ++++++++++----------- src/parse_command_utils.h | 16 ++++++++-------- src/variables.c | 8 +++++--- 4 files changed, 29 insertions(+), 28 deletions(-) diff --git a/include/main.h b/include/main.h index 80a8769..23d6552 100644 --- a/include/main.h +++ b/include/main.h @@ -6,7 +6,7 @@ /* By: jschaft +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/23 14:15:12 by mcolonna #+# #+# */ -/* Updated: 2024/06/28 14:01:25 by mcolonna ### ########.fr */ +/* Updated: 2024/07/01 11:12:51 by mcolonna ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,11 +17,11 @@ typedef struct s_env { - t_memclass mc_global; // open during all the runtime - t_memclass mc_command; // open during the execution of a command - int errorstatus; // Error status of the last executed command - t_list *variables; // Shell variables - bool exit; // Set to true to exit minishell + t_memclass mc_global; + t_memclass mc_command; + int errorstatus; + t_list *variables; + bool exit; } t_env; #endif diff --git a/include/parse_command.h b/include/parse_command.h index ded1531..e81c21f 100644 --- a/include/parse_command.h +++ b/include/parse_command.h @@ -6,7 +6,7 @@ /* By: jschaft +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/23 14:15:12 by mcolonna #+# #+# */ -/* Updated: 2024/06/27 13:47:56 by mcolonna ### ########.fr */ +/* Updated: 2024/07/01 11:16:02 by mcolonna ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,26 +18,25 @@ // Represents a call to a program (the program name and its arguments) typedef struct s_call { - const char *program; // path of the program to call. - int argc; // number of arguments given - char *const *argv; // arguments given (ended by NULL) - // (argc and argv must include the program name) + const char *program; + int argc; + char *const *argv; } t_call; // Represents a command given by the user. typedef struct s_command { - int error; // 0 if parse_command() succeded, error status if not - bool empty; // true if there isn't anything to do - const t_call *calls; // all calls to programs (ended by .program == NULL) - int input_fd; // fd to use with '<' redirection (0 by default) - int output_fd; // fd to use with '>' redirection (1 by default) + int error; + bool empty; + const t_call *calls; + int input_fd; + int output_fd; } t_command; // An element of a list of pipes typedef struct s_pipes { - int pipe[2]; // Simple pipe, we write on pipe[1] and we read on pipe[0] + int pipe[2]; } t_pipes; // Return the t_command representing the command given by the user. diff --git a/src/parse_command_utils.h b/src/parse_command_utils.h index e622f0b..368d0f9 100644 --- a/src/parse_command_utils.h +++ b/src/parse_command_utils.h @@ -6,7 +6,7 @@ /* By: mcolonna +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/24 13:47:40 by mcolonna #+# #+# */ -/* Updated: 2024/06/27 14:47:14 by mcolonna ### ########.fr */ +/* Updated: 2024/07/01 11:15:33 by mcolonna ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,13 +20,13 @@ // Global variables for all the parsing functions typedef struct s_parsing_args { - t_memclass mc; // mc freed given to parse_command - t_command r; // t_command that parse_command will return - t_stream stream; // stream reading the command string - t_list calls; // list of calls - bool got_first_call; // already got at least the first program call? - const char *heredoc; // EOF line for heredoc. NULL if no heredoc - t_list *variables; // list of current variables + t_memclass mc; + t_command r; + t_stream stream; + t_list calls; + bool got_first_call; + const char *heredoc; + t_list *variables; t_env *env; } t_parsing_args; diff --git a/src/variables.c b/src/variables.c index 53142f9..f2d4adb 100644 --- a/src/variables.c +++ b/src/variables.c @@ -6,7 +6,7 @@ /* By: mcolonna +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/24 13:47:40 by mcolonna #+# #+# */ -/* Updated: 2024/06/28 14:33:14 by mcolonna ### ########.fr */ +/* Updated: 2024/07/01 13:38:03 by mcolonna ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,8 +15,10 @@ void variables_set(t_list *variables, const char *name, const char *value) { - variables_find(variables, name)->value = ( - str_dup(fatal_error, variables->mc, value)); + t_variable *var; + + var = variables_find(variables, name); + var->value = str_dup(fatal_error, variables->mc, value); } const char *variables_get(t_list *variables, const char *name)