From 1ff9504c6b6f4c8bcebb75935b2d999f6c7b018c Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 1 Apr 2020 18:10:56 +0200 Subject: Norm compliant comment format, dirty script for doxygen comments --- src/eval/eval.c | 32 ++++++++++++++++++++++---------- src/eval/exec.c | 20 ++++++++++++++++---- src/eval/pipe.c | 18 +++++++++++++++--- 3 files changed, 53 insertions(+), 17 deletions(-) (limited to 'src/eval') diff --git a/src/eval/eval.c b/src/eval/eval.c index d2fab39..c90618c 100644 --- a/src/eval/eval.c +++ b/src/eval/eval.c @@ -1,18 +1,30 @@ -/** +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* eval.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/01 17:05:21 by charles #+# #+# */ +/* Updated: 2020/04/01 17:09:36 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* ** \file eval.c ** \brief Evaluation of an AST */ #include "eval.h" -/** +/* ** \brief Evaluate a line ** \param state State of the evaluation ** \param line Line to evaluate ** \return Last Executed command status or -1 on error */ -static int eval_line(t_eval_state *state, t_line *line) +static int eval_line(t_eval_state *state, t_line *line) { int status; @@ -26,14 +38,14 @@ static int eval_line(t_eval_state *state, t_line *line) return (eval(state, line->right)); } -/** +/* ** \brief Evaluate a command ** \param state Evaluation state ** \param cmd Command to evaluate ** \return Executable status or -1 on error */ -static int eval_cmd(t_eval_state *state, t_cmd *cmd) +static int eval_cmd(t_eval_state *state, t_cmd *cmd) { int child_pid; char *exec_path; @@ -54,7 +66,7 @@ static int eval_cmd(t_eval_state *state, t_cmd *cmd) pipe_setup_child(state->pipe_in, state->pipe_out); if (is_builtin) exit(builtin_dispatch_run(cmd->argv, state->env)); - else if (execve(exec_path, cmd->argv, NULL /*env_array*/) == -1) + else if (execve(exec_path, cmd->argv, NULL) == -1) exit(EXIT_FAILURE); exit(EXIT_SUCCESS); } @@ -62,19 +74,19 @@ static int eval_cmd(t_eval_state *state, t_cmd *cmd) return (WEXITSTATUS(child_pid)); } -/** +/* ** \brief Evaluate an AST ** \param state State of the evaluation ** \param ast Abstract syntax tree to evaluate ** \return Executable status or -1 on error */ -int eval(t_eval_state *state, t_ast *ast) +int eval(t_eval_state *state, t_ast *ast) { errno = 0; if (ast->tag == TAG_LINE) - return eval_line(state, &ast->data.line); + return (eval_line(state, &ast->data.line)); if (ast->tag == TAG_CMD) - return eval_cmd(state, &ast->data.cmd); + return (eval_cmd(state, &ast->data.cmd)); return (-1); } diff --git a/src/eval/exec.c b/src/eval/exec.c index 1ac9754..e41f994 100644 --- a/src/eval/exec.c +++ b/src/eval/exec.c @@ -1,11 +1,23 @@ -/** +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* exec.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/01 17:06:11 by charles #+# #+# */ +/* Updated: 2020/04/01 17:06:12 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* ** \file exec.c ** \brief Executable name and path */ #include "eval.h" -/** +/* ** \brief Check if executable name is already a path ** \param exec_name Executable name ** \return True if valid @@ -18,7 +30,7 @@ bool exec_is_path(char *exec_name) || ft_strncmp(exec_name, "/", 1) == 0); } -/** +/* ** \brief Check if executable path is valid ** \param exec_path Executable path ** \return True if valid @@ -36,7 +48,7 @@ bool exec_is_valid(char *exec_path) return (true); } -/** +/* ** \brief Search executable name in path ** \param path Path hash table ** \param path_var Path environment string in case we need to update path diff --git a/src/eval/pipe.c b/src/eval/pipe.c index 897a5f2..125c013 100644 --- a/src/eval/pipe.c +++ b/src/eval/pipe.c @@ -1,11 +1,23 @@ -/** +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* pipe.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/01 17:05:58 by charles #+# #+# */ +/* Updated: 2020/04/01 17:05:59 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* ** \file pipe.c ** \brief Pipes setup */ #include "eval.h" -/** +/* ** \brief Setup STDIN and STDOUT pipe in the parent process ** \param cmd Command to setup ** \param pipe_in STDIN pipe @@ -29,7 +41,7 @@ int pipe_setup_parent(t_cmd *cmd, int pipe_in[2], int pipe_out[2]) return (0); } -/** +/* ** \brief Setup STDIN and STDOUT pipe in the child process ** \param pipe_in STDIN pipe ** \param pipe_out STDOUT pipe -- cgit