Merge commit, fixed warnings
This commit is contained in:
commit
13bc603a59
13 changed files with 158 additions and 113 deletions
|
|
@ -1,17 +1,17 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* arith.h :+: :+: :+: */
|
/* _run_arith.h :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/07/27 21:13:15 by rparodi #+# #+# */
|
/* Created: 2024/07/27 21:13:15 by rparodi #+# #+# */
|
||||||
/* Updated: 2024/08/01 06:21:37 by maiboyer ### ########.fr */
|
/* Updated: 2024/08/14 16:38:32 by rparodi ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef ARITH_H
|
#ifndef _RUN_ARITH_H
|
||||||
# define ARITH_H
|
# define _RUN_ARITH_H
|
||||||
|
|
||||||
# include "app/state.h"
|
# include "app/state.h"
|
||||||
# include "ast/ast.h"
|
# include "ast/ast.h"
|
||||||
|
|
|
||||||
|
|
@ -5,92 +5,78 @@
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/02 14:41:48 by rparodi #+# #+# */
|
/* Created: 2024/08/14 17:57:57 by rparodi #+# #+# */
|
||||||
/* Updated: 2024/08/14 17:41:41 by maiboyer ### ########.fr */
|
/* Updated: 2024/08/14 18:16:02 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef _RUN_AST_H
|
#ifndef _RUN_AST_H
|
||||||
#define _RUN_AST_H
|
# define _RUN_AST_H
|
||||||
|
|
||||||
#include "app/state.h"
|
# include "app/state.h"
|
||||||
#include "ast/ast.h"
|
# include "ast/ast.h"
|
||||||
#include "me/fs/fs.h"
|
# include "me/fs/fs.h"
|
||||||
#include "me/os/os.h"
|
# include "me/os/os.h"
|
||||||
#include "me/types.h"
|
# include "me/types.h"
|
||||||
#include "me/vec/vec_estr.h"
|
# include "me/vec/vec_estr.h"
|
||||||
|
|
||||||
#define NOT_DONE \
|
typedef struct s_expansion_result t_expansion_result;
|
||||||
{ \
|
|
||||||
printf("function `%s` isn't done !\n", __func__); \
|
|
||||||
return (ERROR); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
|
||||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
|
||||||
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
|
|
||||||
#pragma GCC diagnostic ignored "-Wempty-body"
|
|
||||||
#pragma clang diagnostic ignored "-Wunknown-pragmas"
|
|
||||||
#pragma clang diagnostic ignored "-Wunused-parameter"
|
|
||||||
#pragma clang diagnostic ignored "-Wunused-variable"
|
|
||||||
|
|
||||||
typedef struct s_expansion_result t_expansion_result;
|
|
||||||
|
|
||||||
struct s_expansion_result
|
struct s_expansion_result
|
||||||
{
|
{
|
||||||
bool exists;
|
bool exists;
|
||||||
t_str value;
|
t_str value;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct s_command_result t_command_result;
|
typedef struct s_command_result t_command_result;
|
||||||
|
|
||||||
struct s_command_result
|
struct s_command_result
|
||||||
{
|
{
|
||||||
int exit;
|
int exit;
|
||||||
t_process process;
|
t_process process;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct s_word_result t_word_result;
|
typedef struct s_word_result t_word_result;
|
||||||
struct s_word_result
|
struct s_word_result
|
||||||
{
|
{
|
||||||
bool has_error;
|
bool has_error;
|
||||||
t_vec_estr value;
|
t_vec_estr value;
|
||||||
t_ast_word_kind kind;
|
t_ast_word_kind kind;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct s_word_iterator t_word_iterator;
|
typedef struct s_word_iterator t_word_iterator;
|
||||||
struct s_word_iterator
|
struct s_word_iterator
|
||||||
{
|
{
|
||||||
t_word_result res;
|
t_word_result res;
|
||||||
t_state *state;
|
t_state *state;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct s_cmd_pipe t_cmd_pipe;
|
typedef struct s_cmd_pipe t_cmd_pipe;
|
||||||
struct s_cmd_pipe
|
struct s_cmd_pipe
|
||||||
{
|
{
|
||||||
t_fd *input;
|
t_fd *input;
|
||||||
bool create_output;
|
bool create_output;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct s_program_result t_program_result;
|
typedef struct s_program_result t_program_result;
|
||||||
struct s_program_result
|
struct s_program_result
|
||||||
{
|
{
|
||||||
int exit;
|
int exit;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct s_pipeline_result t_pipeline_result;
|
typedef struct s_pipeline_result t_pipeline_result;
|
||||||
struct s_pipeline_result
|
struct s_pipeline_result
|
||||||
{
|
{
|
||||||
int exit;
|
int exit;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct s_list_result t_list_result;
|
typedef struct s_list_result t_list_result;
|
||||||
struct s_list_result
|
struct s_list_result
|
||||||
{
|
{
|
||||||
int exit;
|
int exit;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct s_subshell_result t_subshell_result;
|
typedef struct s_subshell_result t_subshell_result;
|
||||||
struct s_subshell_result
|
struct s_subshell_result
|
||||||
{
|
{
|
||||||
t_pid pid;
|
t_pid pid;
|
||||||
|
|
@ -100,33 +86,61 @@ struct s_subshell_result
|
||||||
t_fd *stderr;
|
t_fd *stderr;
|
||||||
};
|
};
|
||||||
|
|
||||||
t_error run_arithmetic_expansion(t_ast_arithmetic_expansion *arithmetic_expansion, t_state *state, t_i64 *out);
|
t_error run_arithmetic_expansion(\
|
||||||
t_error run_command(t_ast_command *command, t_state *state, t_cmd_pipe cmd_pipe, t_command_result *out);
|
t_ast_arithmetic_expansion *arithmetic_expansion, t_state *state, t_i64 *out);
|
||||||
t_error run_expansion(t_ast_expansion *self, t_state *state, t_expansion_result *out);
|
t_error run_command(\
|
||||||
t_error run_word(t_ast_word *word, t_state *state, t_word_result *out);
|
t_ast_command *command, t_state *state, t_cmd_pipe cmd_pipe, \
|
||||||
t_error run_program(t_ast_program *program, t_state *state, t_program_result *out);
|
t_command_result *out);
|
||||||
t_error run_pipeline(t_ast_pipeline *pipeline, t_state *state, t_pipeline_result *out);
|
t_error run_expansion(\
|
||||||
t_error run_list(t_ast_list *list, t_state *state, t_list_result *out);
|
t_ast_expansion *self, t_state *state, t_expansion_result *out);
|
||||||
t_error run_subshell(t_ast_subshell *subshell, t_state *state, t_cmd_pipe cmd_pipe, t_subshell_result *out);
|
t_error run_word(\
|
||||||
|
t_ast_word *word, t_state *state, t_word_result *out);
|
||||||
|
t_error run_program(\
|
||||||
|
t_ast_program *program, t_state *state, t_program_result *out);
|
||||||
|
t_error run_pipeline(\
|
||||||
|
t_ast_pipeline *pipeline, t_state *state, t_pipeline_result *out);
|
||||||
|
t_error run_list(\
|
||||||
|
t_ast_list *list, t_state *state, t_list_result *out);
|
||||||
|
t_error run_subshell(\
|
||||||
|
t_ast_subshell *subshell, t_state *state, t_cmd_pipe cmd_pipe,\
|
||||||
|
t_subshell_result *out);
|
||||||
|
t_error run_case_(\
|
||||||
|
t_ast_case *case_, t_state *state, void *out);
|
||||||
|
t_error run_case_item(\
|
||||||
|
t_ast_case_item *case_item, t_state *state, void *out);
|
||||||
|
t_error run_command_substitution(\
|
||||||
|
t_ast_command_substitution *command_substitution, t_state *state, void *out);
|
||||||
|
t_error run_compound_statement(\
|
||||||
|
t_ast_compound_statement *compound_statement, t_state *state, void *out);
|
||||||
|
t_error run_elif(\
|
||||||
|
t_ast_elif *elif, t_state *state, void *out);
|
||||||
|
t_error run_else_(\
|
||||||
|
t_ast_else *else_, t_state *state, void *out);
|
||||||
|
t_error run_extglob(\
|
||||||
|
t_ast_extglob *extglob, t_state *state, void *out);
|
||||||
|
t_error run_for_(\
|
||||||
|
t_ast_for *for_, t_state *state, void *out);
|
||||||
|
t_error run_function_definition(\
|
||||||
|
t_ast_function_definition *function_definition, t_state *state, void *out);
|
||||||
|
t_error run_if_(\
|
||||||
|
t_ast_if *if_, t_state *state, void *out);
|
||||||
|
t_error run_regex(\
|
||||||
|
t_ast_regex *regex, t_state *state, void *out);
|
||||||
|
t_error run_until(\
|
||||||
|
t_ast_until *until, t_state *state, void *out);
|
||||||
|
t_error run_variable_assignment(\
|
||||||
|
t_ast_variable_assignment *variable_assignment, t_state *state, \
|
||||||
|
bool is_temporary, void *out);
|
||||||
|
t_error run_while_(\
|
||||||
|
t_ast_while *while_, t_state *state, void *out);
|
||||||
|
|
||||||
t_error run_case_(t_ast_case *case_, t_state *state, void *out);
|
t_error run_heredoc_redirection(\
|
||||||
t_error run_case_item(t_ast_case_item *case_item, t_state *state, void *out);
|
t_ast_heredoc_redirection *heredoc_redirection, t_state *state, void *out);
|
||||||
t_error run_command_substitution(t_ast_command_substitution *command_substitution, t_state *state, void *out);
|
t_error run_file_redirection(\
|
||||||
t_error run_compound_statement(t_ast_compound_statement *compound_statement, t_state *state, void *out);
|
t_ast_file_redirection *file_redirection, t_state *state, void *out);
|
||||||
t_error run_elif(t_ast_elif *elif, t_state *state, void *out);
|
t_error run_empty(\
|
||||||
t_error run_else_(t_ast_else *else_, t_state *state, void *out);
|
t_ast_empty *empty, t_state *state, void *out);
|
||||||
t_error run_extglob(t_ast_extglob *extglob, t_state *state, void *out);
|
t_error run_raw_string(\
|
||||||
t_error run_for_(t_ast_for *for_, t_state *state, void *out);
|
t_ast_raw_string *raw_string, t_state *state, void *out);
|
||||||
t_error run_function_definition(t_ast_function_definition *function_definition, t_state *state, void *out);
|
|
||||||
t_error run_if_(t_ast_if *if_, t_state *state, void *out);
|
|
||||||
t_error run_regex(t_ast_regex *regex, t_state *state, void *out);
|
|
||||||
t_error run_until(t_ast_until *until, t_state *state, void *out);
|
|
||||||
t_error run_variable_assignment(t_ast_variable_assignment *variable_assignment, t_state *state, bool is_temporary, void *out);
|
|
||||||
t_error run_while_(t_ast_while *while_, t_state *state, void *out);
|
|
||||||
|
|
||||||
t_error run_heredoc_redirection(t_ast_heredoc_redirection *heredoc_redirection, t_state *state, void *out);
|
|
||||||
t_error run_file_redirection(t_ast_file_redirection *file_redirection, t_state *state, void *out);
|
|
||||||
t_error run_empty(t_ast_empty *empty, t_state *state, void *out);
|
|
||||||
t_error run_raw_string(t_ast_raw_string *raw_string, t_state *state, void *out);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -6,39 +6,48 @@
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/10 18:43:56 by maiboyer #+# #+# */
|
/* Created: 2024/08/10 18:43:56 by maiboyer #+# #+# */
|
||||||
/* Updated: 2024/08/11 12:01:18 by maiboyer ### ########.fr */
|
/* Updated: 2024/08/14 16:42:10 by rparodi ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef BUILTINS_H
|
#ifndef BUILTINS_H
|
||||||
#define BUILTINS_H
|
# define BUILTINS_H
|
||||||
|
|
||||||
#include "app/env.h"
|
# include "app/env.h"
|
||||||
#include "app/state.h"
|
# include "app/state.h"
|
||||||
#include "exec/_run_ast.h"
|
# include "exec/_run_ast.h"
|
||||||
#include "me/os/os.h"
|
# include "me/os/os.h"
|
||||||
#include "me/types.h"
|
# include "me/types.h"
|
||||||
#include "me/vec/vec_str.h"
|
# include "me/vec/vec_str.h"
|
||||||
|
|
||||||
typedef struct s_builtin_spawn_info t_builtin_spawn_info;
|
typedef struct s_builtin_spawn_info t_builtin_spawn_info;
|
||||||
|
|
||||||
struct s_builtin_spawn_info
|
struct s_builtin_spawn_info
|
||||||
{
|
{
|
||||||
t_vec_str args;
|
t_vec_str args;
|
||||||
t_fd *stdin;
|
t_fd *stdin;
|
||||||
t_fd *stdout;
|
t_fd *stdout;
|
||||||
t_fd *stderr;
|
t_fd *stderr;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef t_error (*t_builtin_func)(t_state *state, t_builtin_spawn_info info, t_i32 *exit_code);
|
typedef t_error (*t_builtin_func)(\
|
||||||
|
t_state *state, t_builtin_spawn_info info, t_i32 *exit_code);
|
||||||
|
|
||||||
t_error builtin_cd____(t_state *state, t_builtin_spawn_info info, t_i32 *exit_code);
|
t_error builtin_cd____(\
|
||||||
t_error builtin_echo__(t_state *state, t_builtin_spawn_info info, t_i32 *exit_code);
|
t_state *state, t_builtin_spawn_info info, t_i32 *exit_code);
|
||||||
t_error builtin_env___(t_state *state, t_builtin_spawn_info info, t_i32 *exit_code);
|
t_error builtin_echo__(\
|
||||||
t_error builtin_exit__(t_state *state, t_builtin_spawn_info info, t_i32 *exit_code);
|
t_state *state, t_builtin_spawn_info info, t_i32 *exit_code);
|
||||||
t_error builtin_export(t_state *state, t_builtin_spawn_info info, t_i32 *exit_code);
|
t_error builtin_env___(\
|
||||||
t_error builtin_pwd___(t_state *state, t_builtin_spawn_info info, t_i32 *exit_code);
|
t_state *state, t_builtin_spawn_info info, t_i32 *exit_code);
|
||||||
t_error builtin_unset_(t_state *state, t_builtin_spawn_info info, t_i32 *exit_code);
|
t_error builtin_exit__(\
|
||||||
t_error builtin_debug_(t_state *state, t_builtin_spawn_info info, t_i32 *exit_code);
|
t_state *state, t_builtin_spawn_info info, t_i32 *exit_code);
|
||||||
|
t_error builtin_export(\
|
||||||
|
t_state *state, t_builtin_spawn_info info, t_i32 *exit_code);
|
||||||
|
t_error builtin_pwd___(\
|
||||||
|
t_state *state, t_builtin_spawn_info info, t_i32 *exit_code);
|
||||||
|
t_error builtin_unset_(\
|
||||||
|
t_state *state, t_builtin_spawn_info info, t_i32 *exit_code);
|
||||||
|
t_error builtin_debug_(\
|
||||||
|
t_state *state, t_builtin_spawn_info info, t_i32 *exit_code);
|
||||||
|
|
||||||
#endif /* BUILTINS_H */
|
#endif /* BUILTINS_H */
|
||||||
|
|
|
||||||
|
|
@ -6,15 +6,13 @@
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/07/11 17:23:24 by maiboyer #+# #+# */
|
/* Created: 2024/07/11 17:23:24 by maiboyer #+# #+# */
|
||||||
/* Updated: 2024/07/11 17:38:05 by maiboyer ### ########.fr */
|
/* Updated: 2024/08/14 16:36:15 by rparodi ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef RUN_H
|
#ifndef RUN_H
|
||||||
#define RUN_H
|
# define RUN_H
|
||||||
|
|
||||||
#include "me/types.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
# include "me/types.h"
|
||||||
|
|
||||||
#endif /* RUN_H */
|
#endif /* RUN_H */
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/10 18:43:18 by maiboyer #+# #+# */
|
/* Created: 2024/08/10 18:43:18 by maiboyer #+# #+# */
|
||||||
/* Updated: 2024/08/11 12:11:43 by maiboyer ### ########.fr */
|
/* Updated: 2024/08/14 18:14:27 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -26,6 +26,7 @@ static t_error _debug_fd(t_state *state, t_builtin_spawn_info info, t_i32 *exit_
|
||||||
const t_fd_array *fds = get_fd_arrays();
|
const t_fd_array *fds = get_fd_arrays();
|
||||||
t_usize i;
|
t_usize i;
|
||||||
|
|
||||||
|
(void)(state);
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < FILE_SLOT_LEN)
|
while (i < FILE_SLOT_LEN)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/10 18:43:18 by maiboyer #+# #+# */
|
/* Created: 2024/08/10 18:43:18 by maiboyer #+# #+# */
|
||||||
/* Updated: 2024/08/13 15:13:11 by maiboyer ### ########.fr */
|
/* Updated: 2024/08/14 18:15:22 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -24,6 +24,7 @@ t_error builtin_cd____(t_state *state, t_builtin_spawn_info info, t_i32 *exit_co
|
||||||
t_str *home;
|
t_str *home;
|
||||||
t_str path;
|
t_str path;
|
||||||
|
|
||||||
|
(void)(state);
|
||||||
if (info.args.len <= 1)
|
if (info.args.len <= 1)
|
||||||
{
|
{
|
||||||
home = hmap_env_get(state->tmp_var, (t_str *)&key);
|
home = hmap_env_get(state->tmp_var, (t_str *)&key);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/10 18:43:18 by maiboyer #+# #+# */
|
/* Created: 2024/08/10 18:43:18 by maiboyer #+# #+# */
|
||||||
/* Updated: 2024/08/11 11:30:09 by maiboyer ### ########.fr */
|
/* Updated: 2024/08/14 18:15:30 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -22,6 +22,7 @@ t_error builtin_echo__(t_state *state, t_builtin_spawn_info info, t_i32 *exit_co
|
||||||
bool print_line;
|
bool print_line;
|
||||||
t_string s;
|
t_string s;
|
||||||
|
|
||||||
|
(void)(state);
|
||||||
print_line = true;
|
print_line = true;
|
||||||
i = 1;
|
i = 1;
|
||||||
s = string_new(1024);
|
s = string_new(1024);
|
||||||
|
|
@ -39,7 +40,6 @@ t_error builtin_echo__(t_state *state, t_builtin_spawn_info info, t_i32 *exit_co
|
||||||
string_push(&s, info.args.buffer[i]);
|
string_push(&s, info.args.buffer[i]);
|
||||||
if (print_line)
|
if (print_line)
|
||||||
string_push_char(&s, '\n');
|
string_push_char(&s, '\n');
|
||||||
// TODO: change the null to the actual redirection thingy, this needs to be done in the handle_builtin function beforehand
|
|
||||||
me_printf_fd(info.stdout, "%s", s.buf);
|
me_printf_fd(info.stdout, "%s", s.buf);
|
||||||
string_free(s);
|
string_free(s);
|
||||||
return (*exit_code = 0, NO_ERROR);
|
return (*exit_code = 0, NO_ERROR);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/07 14:22:50 by rparodi #+# #+# */
|
/* Created: 2024/08/07 14:22:50 by rparodi #+# #+# */
|
||||||
/* Updated: 2024/08/12 14:16:45 by rparodi ### ########.fr */
|
/* Updated: 2024/08/14 18:14:46 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -26,6 +26,7 @@ static t_error _print_env(t_usize _idx, const t_str *key, t_str *value, void *vc
|
||||||
const struct s_print_env_state *ctx = vctx;
|
const struct s_print_env_state *ctx = vctx;
|
||||||
t_str *val;
|
t_str *val;
|
||||||
|
|
||||||
|
(void)(_idx);
|
||||||
val = hmap_env_get(ctx->state->tmp_var, (t_str *)key);
|
val = hmap_env_get(ctx->state->tmp_var, (t_str *)key);
|
||||||
if (val == NULL)
|
if (val == NULL)
|
||||||
val = value;
|
val = value;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/10 18:43:18 by maiboyer #+# #+# */
|
/* Created: 2024/08/10 18:43:18 by maiboyer #+# #+# */
|
||||||
/* Updated: 2024/08/11 12:41:07 by maiboyer ### ########.fr */
|
/* Updated: 2024/08/14 18:15:05 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -18,6 +18,7 @@ t_error builtin_exit__(t_state *state, t_builtin_spawn_info info, t_i32 *exit_co
|
||||||
{
|
{
|
||||||
t_i32 actual_exit_code;
|
t_i32 actual_exit_code;
|
||||||
|
|
||||||
|
(void)(state);
|
||||||
if (info.args.len < 2)
|
if (info.args.len < 2)
|
||||||
actual_exit_code = 0;
|
actual_exit_code = 0;
|
||||||
else if (str_to_i32(info.args.buffer[1], 10, &actual_exit_code))
|
else if (str_to_i32(info.args.buffer[1], 10, &actual_exit_code))
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/07 14:13:41 by rparodi #+# #+# */
|
/* Created: 2024/08/07 14:13:41 by rparodi #+# #+# */
|
||||||
/* Updated: 2024/08/12 15:58:55 by maiboyer ### ########.fr */
|
/* Updated: 2024/08/14 18:16:28 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -53,6 +53,7 @@ static t_error _print_export(t_usize _idx, const t_str *key, t_str *value, void
|
||||||
t_str *val;
|
t_str *val;
|
||||||
t_str true_val;
|
t_str true_val;
|
||||||
|
|
||||||
|
(void)(_idx);
|
||||||
val = hmap_env_get(ctx->state->tmp_var, (t_str *)key);
|
val = hmap_env_get(ctx->state->tmp_var, (t_str *)key);
|
||||||
if (val == NULL)
|
if (val == NULL)
|
||||||
val = value;
|
val = value;
|
||||||
|
|
@ -69,6 +70,8 @@ t_error builtin_export(t_state *state, t_builtin_spawn_info info, t_i32 *exit_co
|
||||||
{
|
{
|
||||||
struct s_print_export_state print_ctx;
|
struct s_print_export_state print_ctx;
|
||||||
struct s_assign_export_state assign_ctx;
|
struct s_assign_export_state assign_ctx;
|
||||||
|
|
||||||
|
(void)(state);
|
||||||
print_ctx.info = &info;
|
print_ctx.info = &info;
|
||||||
print_ctx.state = state;
|
print_ctx.state = state;
|
||||||
assign_ctx.info = &info;
|
assign_ctx.info = &info;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/07 13:58:37 by rparodi #+# #+# */
|
/* Created: 2024/08/07 13:58:37 by rparodi #+# #+# */
|
||||||
/* Updated: 2024/08/13 15:14:47 by maiboyer ### ########.fr */
|
/* Updated: 2024/08/14 18:15:16 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -20,6 +20,7 @@ t_error builtin_pwd___(t_state *state, t_builtin_spawn_info info, t_i32 *exit_co
|
||||||
{
|
{
|
||||||
t_string s;
|
t_string s;
|
||||||
|
|
||||||
|
(void)(state);
|
||||||
s = string_new(1024);
|
s = string_new(1024);
|
||||||
while (getcwd(s.buf, s.capacity - 1) == NULL)
|
while (getcwd(s.buf, s.capacity - 1) == NULL)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/10 18:43:18 by maiboyer #+# #+# */
|
/* Created: 2024/08/10 18:43:18 by maiboyer #+# #+# */
|
||||||
/* Updated: 2024/08/12 17:11:12 by maiboyer ### ########.fr */
|
/* Updated: 2024/08/14 18:15:19 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -21,6 +21,7 @@ t_error builtin_unset_(t_state *state, t_builtin_spawn_info info, t_i32 *exit_co
|
||||||
{
|
{
|
||||||
t_usize i;
|
t_usize i;
|
||||||
|
|
||||||
|
(void)(state);
|
||||||
i = 1;
|
i = 1;
|
||||||
while (i < info.args.len)
|
while (i < info.args.len)
|
||||||
hmap_env_remove(state->env, &info.args.buffer[i++]);
|
hmap_env_remove(state->env, &info.args.buffer[i++]);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/07/11 17:22:29 by maiboyer #+# #+# */
|
/* Created: 2024/07/11 17:22:29 by maiboyer #+# #+# */
|
||||||
/* Updated: 2024/08/14 18:07:51 by maiboyer ### ########.fr */
|
/* Updated: 2024/08/14 18:13:54 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -34,6 +34,20 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define NOT_DONE \
|
||||||
|
{ \
|
||||||
|
printf("function `%s` isn't done !\n", __func__); \
|
||||||
|
return (ERROR); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||||
|
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
|
||||||
|
#pragma GCC diagnostic ignored "-Wempty-body"
|
||||||
|
#pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||||
|
#pragma clang diagnostic ignored "-Wunused-parameter"
|
||||||
|
#pragma clang diagnostic ignored "-Wunused-variable"
|
||||||
|
|
||||||
bool _is_special_var(t_ast_expansion *self)
|
bool _is_special_var(t_ast_expansion *self)
|
||||||
{
|
{
|
||||||
char name;
|
char name;
|
||||||
|
|
@ -509,6 +523,7 @@ t_error _ast_into_str(t_ast_node self, t_state *state, t_vec_str *append)
|
||||||
// t_error run_heredoc_redirection(t_ast_heredoc_redirection *heredoc_redirection, t_state *state, void *out) NOT_DONE;
|
// t_error run_heredoc_redirection(t_ast_heredoc_redirection *heredoc_redirection, t_state *state, void *out) NOT_DONE;
|
||||||
// t_error run_raw_string(t_ast_raw_string *raw_string, t_state *state, void *out) NOT_DONE;
|
// t_error run_raw_string(t_ast_raw_string *raw_string, t_state *state, void *out) NOT_DONE;
|
||||||
|
|
||||||
|
|
||||||
t_error run_case_(t_ast_case *case_, t_state *state, void *out) NOT_DONE;
|
t_error run_case_(t_ast_case *case_, t_state *state, void *out) NOT_DONE;
|
||||||
t_error run_case_item(t_ast_case_item *case_item, t_state *state, void *out) NOT_DONE;
|
t_error run_case_item(t_ast_case_item *case_item, t_state *state, void *out) NOT_DONE;
|
||||||
t_error run_command_substitution(t_ast_command_substitution *command_substitution, t_state *state, void *out) NOT_DONE;
|
t_error run_command_substitution(t_ast_command_substitution *command_substitution, t_state *state, void *out) NOT_DONE;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue