From 486a207834755db63493be7be2b41e3cff7b4a1a Mon Sep 17 00:00:00 2001 From: whaffman Date: Tue, 11 Feb 2025 17:22:11 +0100 Subject: [PATCH] norm errors --- inc/executor.h | 10 ++--- inc/parser.h | 16 ++++---- src/environment/environment_add.c | 10 +++-- src/environment/environment_del.c | 4 +- src/environment/environment_free_list.c | 4 +- src/environment/environment_get.c | 5 ++- src/environment/environment_get_arr.c | 52 ++++++++++++------------- src/environment/environment_parse.c | 4 +- src/environment/environment_print.c | 8 ++-- src/executor/executor_absolute_path.c | 12 +++--- src/utils/simple_builtins.c | 13 +++---- 11 files changed, 69 insertions(+), 69 deletions(-) diff --git a/inc/executor.h b/inc/executor.h index 1415487..1c256de 100644 --- a/inc/executor.h +++ b/inc/executor.h @@ -6,15 +6,15 @@ /* By: willem +#+ */ /* +#+ */ /* Created: 2025/02/08 17:06:07 by willem #+# #+# */ -/* Updated: 2025/02/08 17:15:24 by willem ######## odam.nl */ +/* Updated: 2025/02/11 17:06:54 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ -#ifndef EXECUTER_H -# define EXECUTER_H +#ifndef EXECUTOR_H +# define EXECUTOR_H # include "minishell.h" -char *executor_absolute_path(t_list *env, char *cmd); +char *executor_absolute_path(t_list *env, char *cmd); -#endif // EXECUTER_H \ No newline at end of file +#endif // EXECUTOR_H diff --git a/inc/parser.h b/inc/parser.h index 5c581fa..8caaa0a 100644 --- a/inc/parser.h +++ b/inc/parser.h @@ -1,19 +1,19 @@ /* ************************************************************************** */ /* */ -/* ::: :::::::: */ -/* parser.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: qmennen +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2025/02/11 14:03:03 by qmennen #+# #+# */ -/* Updated: 2025/02/11 16:25:16 by qmennen ### ########.fr */ +/* :::::::: */ +/* parser.h :+: :+: */ +/* +:+ */ +/* By: qmennen +#+ */ +/* +#+ */ +/* Created: 2025/02/11 14:03:03 by qmennen #+# #+# */ +/* Updated: 2025/02/11 17:19:01 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ #ifndef PARSER_H # define PARSER_H -#include "minishell.h" +# include "minishell.h" t_command *parser_command_new(char *cmd); char **parser_get_arguments(t_list *list); diff --git a/src/environment/environment_add.c b/src/environment/environment_add.c index 4ab1252..03c9cc9 100644 --- a/src/environment/environment_add.c +++ b/src/environment/environment_add.c @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* :::::::: */ -/* environment_add.c :+: :+: */ +/* environment_add.c :+: :+: */ /* +:+ */ /* By: whaffman +#+ */ /* +#+ */ /* Created: 2025/02/04 16:13:33 by whaffman #+# #+# */ -/* Updated: 2025/02/04 16:15:35 by whaffman ######## odam.nl */ +/* Updated: 2025/02/11 17:15:45 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -25,7 +25,9 @@ void environment_add(t_list **environment, char *name, char *value) new_environment->name = ft_strdup(name); new_environment->value = ft_strdup(value); new_node = ft_lstnew(new_environment); - if (new_node == NULL || new_environment->name == NULL || new_environment->value == NULL) + if (new_node == NULL + || new_environment->name == NULL + || new_environment->value == NULL) { free(new_environment->name); free(new_environment->value); @@ -34,4 +36,4 @@ void environment_add(t_list **environment, char *name, char *value) } ft_lstadd_back(environment, new_node); } -} \ No newline at end of file +} diff --git a/src/environment/environment_del.c b/src/environment/environment_del.c index e8c74e0..6a7fd35 100644 --- a/src/environment/environment_del.c +++ b/src/environment/environment_del.c @@ -6,13 +6,13 @@ /* By: whaffman +#+ */ /* +#+ */ /* Created: 2025/02/11 14:17:53 by whaffman #+# #+# */ -/* Updated: 2025/02/11 15:40:09 by whaffman ######## odam.nl */ +/* Updated: 2025/02/11 17:20:26 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ #include "minishell.h" -void environment_del(t_list **environment, char *name) +void environment_del(t_list **environment, char *name) { t_list *prev; t_list *current; diff --git a/src/environment/environment_free_list.c b/src/environment/environment_free_list.c index 711d851..2e1905c 100644 --- a/src/environment/environment_free_list.c +++ b/src/environment/environment_free_list.c @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* :::::::: */ -/* environment_free_list.c :+: :+: */ +/* environment_free_list.c :+: :+: */ /* +:+ */ /* By: whaffman +#+ */ /* +#+ */ /* Created: 2025/02/04 16:13:59 by whaffman #+# #+# */ -/* Updated: 2025/02/04 16:14:04 by whaffman ######## odam.nl */ +/* Updated: 2025/02/11 17:18:27 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ diff --git a/src/environment/environment_get.c b/src/environment/environment_get.c index be1f1de..280698e 100644 --- a/src/environment/environment_get.c +++ b/src/environment/environment_get.c @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* :::::::: */ -/* environment_get.c :+: :+: */ +/* environment_get.c :+: :+: */ /* +:+ */ /* By: whaffman +#+ */ /* +#+ */ /* Created: 2025/02/04 16:15:05 by whaffman #+# #+# */ -/* Updated: 2025/02/04 16:15:10 by whaffman ######## odam.nl */ +/* Updated: 2025/02/11 17:04:28 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -15,6 +15,7 @@ t_environment *environment_get(t_list *environment, char *name) { t_environment *env; + while (environment != NULL) { env = (t_environment *)environment->content; diff --git a/src/environment/environment_get_arr.c b/src/environment/environment_get_arr.c index 824a9c3..8052e04 100644 --- a/src/environment/environment_get_arr.c +++ b/src/environment/environment_get_arr.c @@ -6,37 +6,35 @@ /* By: willem +#+ */ /* +#+ */ /* Created: 2025/02/08 13:59:48 by willem #+# #+# */ -/* Updated: 2025/02/08 13:59:49 by willem ######## odam.nl */ +/* Updated: 2025/02/11 17:18:15 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ -# include "minishell.h" +#include "minishell.h" -char **environment_get_arr(t_list *environment) +char **environment_get_arr(t_list *environment) { - char **arr; - t_environment *env; - int i; + char **arr; + t_environment *env; + int i; - arr = malloc(sizeof(char *) * (ft_lstsize(environment) + 1)); - if (arr == NULL) - return (NULL); - i = 0; - while (environment != NULL) - { - env = (t_environment *)environment->content; - arr[i] = malloc(ft_strlen(env->name) + ft_strlen(env->value) + 2); - if (arr[i] == NULL) - { - ft_free_arr(arr); - return (NULL); - } - ft_strlcpy(arr[i], env->name, ft_strlen(env->name) + 1); - ft_strlcat(arr[i], "=", ft_strlen(env->name) + 2); - ft_strlcat(arr[i], env->value, ft_strlen(env->name) + ft_strlen(env->value) + 2); - environment = environment->next; - i++; - } - arr[i] = NULL; - return (arr); + arr = malloc(sizeof(char *) * (ft_lstsize(environment) + 1)); + if (arr == NULL) + return (NULL); + i = 0; + while (environment != NULL) + { + env = (t_environment *)environment->content; + arr[i] = malloc(ft_strlen(env->name) + ft_strlen(env->value) + 2); + if (arr[i] == NULL) + return (ft_free_arr(arr), NULL); + ft_strlcpy(arr[i], env->name, ft_strlen(env->name) + 1); + ft_strlcat(arr[i], "=", ft_strlen(env->name) + 2); + ft_strlcat(arr[i], env->value, + ft_strlen(env->name) + ft_strlen(env->value) + 2); + environment = environment->next; + i++; + } + arr[i] = NULL; + return (arr); } diff --git a/src/environment/environment_parse.c b/src/environment/environment_parse.c index ffbfd9d..3abd042 100644 --- a/src/environment/environment_parse.c +++ b/src/environment/environment_parse.c @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* :::::::: */ -/* environment_parse.c :+: :+: */ +/* environment_parse.c :+: :+: */ /* +:+ */ /* By: whaffman +#+ */ /* +#+ */ /* Created: 2025/02/05 15:52:33 by whaffman #+# #+# */ -/* Updated: 2025/02/05 15:52:34 by whaffman ######## odam.nl */ +/* Updated: 2025/02/11 17:18:43 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ diff --git a/src/environment/environment_print.c b/src/environment/environment_print.c index 77c513c..e5c7b52 100644 --- a/src/environment/environment_print.c +++ b/src/environment/environment_print.c @@ -6,7 +6,7 @@ /* By: willem +#+ */ /* +#+ */ /* Created: 2025/02/08 13:52:08 by willem #+# #+# */ -/* Updated: 2025/02/08 14:24:20 by willem ######## odam.nl */ +/* Updated: 2025/02/11 17:05:10 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -14,8 +14,8 @@ void environment_print(t_list *environment) { - char **arr; - int i; + char **arr; + int i; arr = environment_get_arr(environment); if (arr == NULL) @@ -30,4 +30,4 @@ void environment_print(t_list *environment) i++; } ft_free_arr(arr); -} \ No newline at end of file +} diff --git a/src/executor/executor_absolute_path.c b/src/executor/executor_absolute_path.c index db23a7a..396dbb2 100644 --- a/src/executor/executor_absolute_path.c +++ b/src/executor/executor_absolute_path.c @@ -6,18 +6,18 @@ /* By: willem +#+ */ /* +#+ */ /* Created: 2025/02/08 17:00:24 by willem #+# #+# */ -/* Updated: 2025/02/11 16:45:17 by whaffman ######## odam.nl */ +/* Updated: 2025/02/11 17:20:17 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ #include "minishell.h" -char *executor_absolute_path(t_list *env, char *cmd) +char *executor_absolute_path(t_list *env, char *cmd) { - char **path; - t_environment *path_env; - char *executable; - int i; + char **path; + t_environment *path_env; + char *executable; + int i; if (cmd[0] == '/' || cmd[0] == '.') { diff --git a/src/utils/simple_builtins.c b/src/utils/simple_builtins.c index 5fa3c7c..11169fb 100644 --- a/src/utils/simple_builtins.c +++ b/src/utils/simple_builtins.c @@ -6,17 +6,17 @@ /* By: whaffman +#+ */ /* +#+ */ /* Created: 2025/02/05 16:21:39 by whaffman #+# #+# */ -/* Updated: 2025/02/11 14:30:38 by whaffman ######## odam.nl */ +/* Updated: 2025/02/11 17:11:16 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ #include "minishell.h" -void builtin_export(t_minishell *minishell) +void builtin_export(t_minishell *minishell) { - t_list *tmp; + t_list *tmp; t_environment *env; - char **arr; + char **arr; tmp = minishell->tokens->next; while (tmp != NULL) @@ -41,7 +41,6 @@ void builtin_export(t_minishell *minishell) } } - static int cmp_value(t_list *list, char *str) { if (list != NULL @@ -53,7 +52,7 @@ static int cmp_value(t_list *list, char *str) return (FALSE); } -void fork_execve(t_minishell *minishell, char *path, char **argv) +void fork_execve(t_minishell *minishell, char *path, char **argv) { pid_t pid; int status; @@ -83,6 +82,7 @@ void fork_execve(t_minishell *minishell, char *path, char **argv) void simple_builtins(t_minishell *minishell) { char *path; + if (!minishell->tokens) return ; if (cmp_value(minishell->tokens, "clear")) @@ -109,5 +109,4 @@ void simple_builtins(t_minishell *minishell) fork_execve(minishell, path, ft_split(((t_token *)minishell->tokens->content)->value, ' ')); } } - }