From 3f08544384b079f1593940d2113622fbc6d5ec21 Mon Sep 17 00:00:00 2001 From: Maix0 Date: Sat, 10 Aug 2024 19:50:26 +0200 Subject: [PATCH] Created file for builtins and fixed a bug about expansion not working correctly --- ast/Filelist.ast.mk | 7 +- ast/src/from_node/file_node.c | 38 +-- exec/Filelist.exec.mk | 7 + exec/include/exec/builtins.h | 33 ++ exec/src/builtins/cd.c | 22 ++ exec/src/builtins/echo.c | 45 +++ {sources/builtin => exec/src/builtins}/env.c | 25 +- exec/src/builtins/exit.c | 23 ++ .../builtin => exec/src/builtins}/export.c | 29 +- {sources/builtin => exec/src/builtins}/pwd.c | 39 +-- exec/src/builtins/unset.c | 22 ++ exec/src/run_ast.c | 46 ++- flake.lock | 298 +----------------- flake.nix | 34 +- stdme/src/os/process.c | 4 +- 15 files changed, 243 insertions(+), 429 deletions(-) create mode 100644 exec/include/exec/builtins.h create mode 100644 exec/src/builtins/cd.c create mode 100644 exec/src/builtins/echo.c rename {sources/builtin => exec/src/builtins}/env.c (65%) create mode 100644 exec/src/builtins/exit.c rename {sources/builtin => exec/src/builtins}/export.c (65%) rename {sources/builtin => exec/src/builtins}/pwd.c (57%) create mode 100644 exec/src/builtins/unset.c diff --git a/ast/Filelist.ast.mk b/ast/Filelist.ast.mk index 50a5712c..50ffecff 100644 --- a/ast/Filelist.ast.mk +++ b/ast/Filelist.ast.mk @@ -1,4 +1,6 @@ SRC_FILES = \ +_not_done_function \ +_not_done_print \ ast_alloc/ast_alloc \ ast_alloc/ast_alloc_scripting \ ast_free/ast_free \ @@ -7,14 +9,15 @@ from_node/arithmetic_node2 \ from_node/artihmetic_node \ from_node/boucle_node \ from_node/condition_node \ +from_node/dev_node \ +from_node/expand_node \ from_node/expansion_node \ +from_node/file_node \ from_node/from_node \ from_node/node_utils \ from_node/node_utils2 \ from_node/redirect_node \ from_node/scripting_node \ -_not_done_function \ -_not_done_print \ print_ast/ast_print_command \ print_ast/ast_print_global \ print_ast/ast_print_node \ diff --git a/ast/src/from_node/file_node.c b/ast/src/from_node/file_node.c index 72a55ead..f19e1428 100644 --- a/ast/src/from_node/file_node.c +++ b/ast/src/from_node/file_node.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/09 16:25:02 by rparodi #+# #+# */ -/* Updated: 2024/08/09 16:26:09 by rparodi ### ########.fr */ +/* Updated: 2024/08/10 18:26:15 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,42 +22,6 @@ #include "parser/api.h" #include -t_error build_sym_file_redirect(\ - t_parse_node self, t_const_str input, t_ast_node *out) -{ - t_ast_node ret; - t_ast_node tmp; - t_usize i; - - (void)(out); - (void)(input); - (void)(self); - if (out == NULL) - return (ERROR); - if (ts_node_symbol(self) != sym_file_redirect) - return (ERROR); - ret = ast_alloc(AST_FILE_REDIRECTION); - i = 0; - while (i < ts_node_child_count(self)) - { - if (!ts_node_is_named(ts_node_child(self, i)) && (i++, true)) - continue ; - if (ts_node_field_id_for_child(self, i) == field_op) - { - ret->data.file_redirection.op = \ - _get_redirection_op(ts_node_child(self, i)); - } - if (ts_node_field_id_for_child(self, i) == field_dest) - { - if (ast_from_node(ts_node_child(self, i), input, &tmp)) - return (ast_free(ret), ERROR); - ret->data.file_redirection.output = tmp; - } - i++; - } - return (*out = ret, NO_ERROR); -} - t_error build_sym_number(\ t_parse_node self, t_const_str input, t_ast_node *out) { diff --git a/exec/Filelist.exec.mk b/exec/Filelist.exec.mk index a7da6d03..4bb119e2 100644 --- a/exec/Filelist.exec.mk +++ b/exec/Filelist.exec.mk @@ -1,4 +1,11 @@ SRC_FILES = \ +builtins/cd \ +builtins/echo \ +builtins/env \ +builtins/exit \ +builtins/export \ +builtins/pwd \ +builtins/unset \ run_arithmetic/arithmetic \ run_arithmetic/arithmetic_operation \ run_ast \ diff --git a/exec/include/exec/builtins.h b/exec/include/exec/builtins.h new file mode 100644 index 00000000..c1f88668 --- /dev/null +++ b/exec/include/exec/builtins.h @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* builtins.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/08/10 18:43:56 by maiboyer #+# #+# */ +/* Updated: 2024/08/10 19:36:59 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef BUILTINS_H +#define BUILTINS_H + +#include "app/env.h" +#include "app/state.h" +#include "exec/_run_ast.h" +#include "me/os/os.h" +#include "me/types.h" +#include "me/vec/vec_str.h" + +typedef t_error (*t_builtin_func)(t_state *state, t_spawn_info info); + +t_error builtin_cd____(t_state *state, t_spawn_info info); +t_error builtin_echo__(t_state *state, t_spawn_info info); +t_error builtin_env___(t_state *state, t_spawn_info info); +t_error builtin_exit__(t_state *state, t_spawn_info info); +t_error builtin_export(t_state *state, t_spawn_info info); +t_error builtin_pwd___(t_state *state, t_spawn_info info); +t_error builtin_unset_(t_state *state, t_spawn_info info); + +#endif /* BUILTINS_H */ diff --git a/exec/src/builtins/cd.c b/exec/src/builtins/cd.c new file mode 100644 index 00000000..6c999f43 --- /dev/null +++ b/exec/src/builtins/cd.c @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* cd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/08/10 18:43:18 by maiboyer #+# #+# */ +/* Updated: 2024/08/10 19:48:59 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "exec/builtins.h" +#include "me/printf/printf.h" +#include "me/str/str.h" +#include "me/string/string.h" +#include "me/types.h" + +t_error builtin_cd____(t_state *state, t_spawn_info info) +{ + return (ERROR); +} diff --git a/exec/src/builtins/echo.c b/exec/src/builtins/echo.c new file mode 100644 index 00000000..22d9eaaa --- /dev/null +++ b/exec/src/builtins/echo.c @@ -0,0 +1,45 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* echo.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/08/10 18:43:18 by maiboyer #+# #+# */ +/* Updated: 2024/08/10 19:47:34 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "exec/builtins.h" +#include "me/printf/printf.h" +#include "me/str/str.h" +#include "me/string/string.h" +#include "me/types.h" + +t_error builtin_echo__(t_state *state, t_spawn_info info) +{ + t_usize i; + bool print_line; + t_string s; + + print_line = true; + i = 1; + s = string_new(1024); + if (i < info.arguments.len && str_compare(info.arguments.buffer[i], "-n")) + { + print_line = false; + i++; + } + while (i < info.arguments.len - 1) + { + string_push(&s, info.arguments.buffer[i++]); + string_push_char(&s, ' '); + } + if (i < info.arguments.len) + string_push(&s, info.arguments.buffer[i]); + if (print_line) + 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(NULL, "%s", s.buf); + return (NO_ERROR); +} diff --git a/sources/builtin/env.c b/exec/src/builtins/env.c similarity index 65% rename from sources/builtin/env.c rename to exec/src/builtins/env.c index 21cb66bb..4f58deae 100644 --- a/sources/builtin/env.c +++ b/exec/src/builtins/env.c @@ -6,31 +6,14 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/07 14:22:50 by rparodi #+# #+# */ -/* Updated: 2024/08/07 14:23:14 by rparodi ### ########.fr */ +/* Updated: 2024/08/10 19:44:43 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ -#include "app/env.h" -#include "me/string/string.h" -#include "me/hash/hasher.h" -#include "me/hashmap/hashmap_env.h" -#include "me/mem/mem.h" -#include "me/str/str.h" -#include "me/str/str.h" -#include "me/str/str.h" #include "me/types.h" -#include "me/vec/vec_str.h" -#include -#include +#include "exec/builtins.h" -void env(t_str *envp) +t_error builtin_env___(t_state *state, t_spawn_info info) { - size_t i; - - i = 0; - while (envp[i] != NULL) - { - printf("%s\n", envp[i]); - i++; - } + return (NO_ERROR); } diff --git a/exec/src/builtins/exit.c b/exec/src/builtins/exit.c new file mode 100644 index 00000000..37722bb0 --- /dev/null +++ b/exec/src/builtins/exit.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* exit.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/08/10 18:43:18 by maiboyer #+# #+# */ +/* Updated: 2024/08/10 19:49:14 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "exec/builtins.h" +#include "me/printf/printf.h" +#include "me/str/str.h" +#include "me/string/string.h" +#include "me/types.h" + +t_error builtin_exit__(t_state *state, t_spawn_info info) +{ + return (ERROR); +} + diff --git a/sources/builtin/export.c b/exec/src/builtins/export.c similarity index 65% rename from sources/builtin/export.c rename to exec/src/builtins/export.c index 4862a524..6341c5d5 100644 --- a/sources/builtin/export.c +++ b/exec/src/builtins/export.c @@ -6,31 +6,22 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/07 14:13:41 by rparodi #+# #+# */ -/* Updated: 2024/08/07 14:22:23 by rparodi ### ########.fr */ +/* Updated: 2024/08/10 19:43:58 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ -#include "app/env.h" -#include "me/string/string.h" -#include "me/hash/hasher.h" -#include "me/hashmap/hashmap_env.h" -#include "me/mem/mem.h" -#include "me/str/str.h" -#include "me/str/str.h" -#include "me/str/str.h" +#include "exec/builtins.h" #include "me/types.h" -#include "me/vec/vec_str.h" -#include -#include -void export(t_str *envp) +t_error builtin_export(t_state *state, t_spawn_info info) { - size_t i; - - i = 0; - while (envp[i] != NULL) + if (info.arguments.len == 1) { - printf("%s\n", envp[i]); - i++; + // print env } + else + { + // assign variable + } + return (NO_ERROR); } diff --git a/sources/builtin/pwd.c b/exec/src/builtins/pwd.c similarity index 57% rename from sources/builtin/pwd.c rename to exec/src/builtins/pwd.c index 8303ff95..2d79525c 100644 --- a/sources/builtin/pwd.c +++ b/exec/src/builtins/pwd.c @@ -6,40 +6,23 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/07 13:58:37 by rparodi #+# #+# */ -/* Updated: 2024/08/07 14:07:39 by rparodi ### ########.fr */ +/* Updated: 2024/08/10 19:44:12 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ -#include "app/env.h" -#include "me/string/string.h" -#include "me/hash/hasher.h" -#include "me/hashmap/hashmap_env.h" +#include "exec/builtins.h" #include "me/mem/mem.h" -#include "me/str/str.h" -#include "me/str/str.h" -#include "me/str/str.h" +#include "me/string/string.h" #include "me/types.h" -#include "me/vec/vec_str.h" -#include -void pwd(void) +t_error builtin_pwd___(t_state *state, t_spawn_info info) { - t_str str; - t_usize size; + t_string s; - size = 1024; - str = (t_str)mem_alloc((size + 1) * sizeof(t_i8)); - if (str == NULL) - me_abort("Error allocating for pwd builtin"); - while (getcwd(str, size) == NULL) - { - if (str) - free(str); - size *= 2; - str = (t_str)mem_alloc(sizeof(t_i8) * size); - if (str == NULL) - me_abort("Error allocating for pwd builtin"); - } - printf("%s\n", str); - free(str); + s = string_new(1024); + while (getcwd(s.buf, s.capacity - 1) == NULL) + string_reserve(&s, s.capacity * 2); + printf("%s\n", s.buf); + string_free(s); + return (NO_ERROR); } diff --git a/exec/src/builtins/unset.c b/exec/src/builtins/unset.c new file mode 100644 index 00000000..4184cbe2 --- /dev/null +++ b/exec/src/builtins/unset.c @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* unset.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/08/10 18:43:18 by maiboyer #+# #+# */ +/* Updated: 2024/08/10 19:49:25 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "exec/builtins.h" +#include "me/printf/printf.h" +#include "me/str/str.h" +#include "me/string/string.h" +#include "me/types.h" + +t_error builtin_unset_(t_state *state, t_spawn_info info) +{ + return (ERROR); +} diff --git a/exec/src/run_ast.c b/exec/src/run_ast.c index bef609de..ccf9dc30 100644 --- a/exec/src/run_ast.c +++ b/exec/src/run_ast.c @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/07/11 17:22:29 by maiboyer #+# #+# */ -/* Updated: 2024/08/05 17:32:25 by maiboyer ### ########.fr */ +/* Updated: 2024/08/10 19:43:19 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,6 +14,7 @@ #include "app/state.h" #include "ast/ast.h" #include "exec/_run_ast.h" +#include "exec/builtins.h" #include "exec/run.h" #include "me/convert/numbers_to_str.h" #include "me/fs/fs.h" @@ -84,10 +85,10 @@ t_error _get_expansion_value(t_ast_expansion *self, t_state *state, t_expansion_ hmap_ret = hmap_env_get(state->tmp_var, &self->var_name); if (hmap_ret == NULL) hmap_ret = hmap_env_get(state->env, &self->var_name); - ret = (t_expansion_result){.exists = hmap_ret == NULL, .value = NULL}; + ret = (t_expansion_result){.exists = (hmap_ret != NULL), .value = NULL}; if (ret.exists) ret.value = str_clone(*hmap_ret); - return (NO_ERROR); + return (*out = ret, NO_ERROR); } t_error _handle_len_operator(t_ast_expansion *self, t_state *state, t_expansion_result *value) @@ -521,8 +522,6 @@ t_error run_pipeline(t_ast_pipeline *pipeline, t_state *state, t_pipeline_result close_fd(cmd_pipe.input); if (cmd_result.process.stdout != NULL) cmd_pipe.input = cmd_result.process.stdout; - else - (printf("WTF ???\n")); if (cmd_result.process.stdin != NULL) close_fd(cmd_result.process.stdin); if (cmd_result.process.stderr != NULL) @@ -643,14 +642,38 @@ void _ffree_func(struct s_ffree_state *state) hmap_env_free(state->state->env); hmap_env_free(state->state->tmp_var); close_fd(state->cmd_pipe.input); + me_exit(127); } -bool _is_builtin(t_const_str argv0); -t_error _handle_builtin(t_spawn_info info, t_state *state); +bool _is_builtin(t_const_str argv0); -t_error _handle_builtin(t_spawn_info info, t_state *state) +t_error _handle_builtin(t_spawn_info info, t_state *state, t_cmd_pipe cmd_pipe, t_command_result *out) { - return (ERROR); + t_usize i; + const t_const_str argv0 = info.binary_path; + const t_str value[] = {"cd", "echo", "env", "exit", "export", "pwd", "unset", NULL}; + const t_builtin_func funcs[] = {builtin_cd____, builtin_echo__, builtin_env___, builtin_exit__, + builtin_export, builtin_pwd___, builtin_unset_, NULL}; + t_builtin_func actual_func; + + i = 0; + if (argv0 == NULL) + return (ERROR); + actual_func = NULL; + while (value[i] != NULL) + { + if (str_compare(argv0, value[i])) + { + actual_func = funcs[i]; + break; + } + i++; + } + if (actual_func == NULL) + return (me_abort("Builtin found but no function found..."), ERROR); + // we need to check if we have to fork ! + + return (NO_ERROR); } t_error _spawn_cmd_and_run(t_vec_str args, t_vec_ast redirection, t_state *state, t_cmd_pipe cmd_pipe, t_command_result *out) @@ -756,7 +779,7 @@ t_error _spawn_cmd_and_run(t_vec_str args, t_vec_ast redirection, t_state *state if (args.len == 0) return (vec_str_free(args), ERROR); if (_is_builtin(args.buffer[0])) - return (_handle_builtin(info, state)); + return (_handle_builtin(info, state, cmd_pipe, out)); if (build_envp(state->env, state->tmp_var, &info.environement)) return (ERROR); info.binary_path = str_clone(info.arguments.buffer[0]); @@ -780,6 +803,7 @@ bool _is_builtin(t_const_str argv0) { t_usize i; const t_str value[] = {"cd", "echo", "env", "exit", "export", "pwd", "unset", NULL}; + const t_str funcs[] = {"cd", "echo", "env", "exit", "export", "pwd", "unset", NULL}; i = 0; if (argv0 == NULL) @@ -834,7 +858,7 @@ t_error run_command(t_ast_command *command, t_state *state, t_cmd_pipe cmd_pipe, i++; } if (_spawn_cmd_and_run(args, redirection, state, cmd_pipe, out)) - return (vec_str_free(args), vec_ast_free(redirection), ERROR); + return (ERROR); return (NO_ERROR); } diff --git a/flake.lock b/flake.lock index e26c76dc..2804b574 100644 --- a/flake.lock +++ b/flake.lock @@ -1,41 +1,5 @@ { "nodes": { - "c_formatter_42": { - "inputs": { - "c_formatter_42_src": "c_formatter_42_src", - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - }, - "locked": { - "lastModified": 1718446391, - "narHash": "sha256-1YWHbvi5Bn90wRR0nOKxODDgdE13NxR8t7EZ1E0MqZk=", - "owner": "Maix0", - "repo": "c_formatter_42-flake", - "rev": "bf7e7fac053e5a4cd0b193390b9a6b0c701d400d", - "type": "github" - }, - "original": { - "owner": "Maix0", - "repo": "c_formatter_42-flake", - "type": "github" - } - }, - "c_formatter_42_src": { - "flake": false, - "locked": { - "lastModified": 1696506114, - "narHash": "sha256-jUScF2lAHhjTWOWZsIAocE6FN8+HG+kLdpbYsEA1SZs=", - "owner": "dawnbeen", - "repo": "c_formatter_42", - "rev": "ef91ff383966885374695c327fa6015f9cfbc364", - "type": "github" - }, - "original": { - "owner": "dawnbeen", - "repo": "c_formatter_42", - "type": "github" - } - }, "flake-utils": { "inputs": { "systems": "systems" @@ -54,164 +18,13 @@ "type": "github" } }, - "flake-utils_2": { - "inputs": { - "systems": "systems_2" - }, - "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_3": { - "inputs": { - "systems": "systems_3" - }, - "locked": { - "lastModified": 1705309234, - "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_4": { - "inputs": { - "systems": "systems_4" - }, - "locked": { - "lastModified": 1705309234, - "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "generic_c": { - "inputs": { - "flake-utils": "flake-utils_3", - "naersk": "naersk", - "nixpkgs": "nixpkgs_3", - "rust-overlay": "rust-overlay" - }, - "locked": { - "lastModified": 1706829609, - "narHash": "sha256-A0imQ9AIJafdL1/+j/1b3G7bm2j+N+VhzTsvKikKjz4=", - "owner": "Maix0", - "repo": "generic_c", - "rev": "a470c2c5a8c8aadc852a7a50d72853f2a3873595", - "type": "github" - }, - "original": { - "owner": "Maix0", - "repo": "generic_c", - "type": "github" - } - }, - "naersk": { - "inputs": { - "nixpkgs": "nixpkgs_2" - }, - "locked": { - "lastModified": 1698420672, - "narHash": "sha256-/TdeHMPRjjdJub7p7+w55vyABrsJlt5QkznPYy55vKA=", - "owner": "nix-community", - "repo": "naersk", - "rev": "aeb58d5e8faead8980a807c840232697982d47b9", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "naersk", - "type": "github" - } - }, "nixpkgs": { "locked": { - "lastModified": 0, - "narHash": "sha256-yZKhxVIKd2lsbOqYd5iDoUIwsRZFqE87smE2Vzf6Ck0=", - "path": "/nix/store/5jgh89kgmrb687c254wxdac4cj5hqjw8-source", - "type": "path" - }, - "original": { - "id": "nixpkgs", - "type": "indirect" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1706683685, - "narHash": "sha256-FtPPshEpxH/ewBOsdKBNhlsL2MLEFv1hEnQ19f/bFsQ=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "5ad9903c16126a7d949101687af0aa589b1d7d3d", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "type": "indirect" - } - }, - "nixpkgs_3": { - "locked": { - "lastModified": 1706683685, - "narHash": "sha256-FtPPshEpxH/ewBOsdKBNhlsL2MLEFv1hEnQ19f/bFsQ=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "5ad9903c16126a7d949101687af0aa589b1d7d3d", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_4": { - "locked": { - "lastModified": 1706487304, - "narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "90f456026d284c22b3e3497be980b2e47d0b28ac", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_5": { - "locked": { - "lastModified": 1722775820, - "narHash": "sha256-2+P7be2JqEXHxamkqkrBZQU1kiz22I7znFESFgljmFg=", + "lastModified": 1723047874, + "narHash": "sha256-i6shgus4+OUD8vg0TZ1qhDvKBfvaWi+SK1xbBSY0z+c=", "owner": "nixos", "repo": "nixpkgs", - "rev": "7f38c2488573835f1bc0455712253f7346fd4e7c", + "rev": "472701edc3fc64e8c5a36a98e6f61146eea37c69", "type": "github" }, "original": { @@ -220,66 +33,10 @@ "type": "github" } }, - "nixpkgs_6": { - "locked": { - "lastModified": 1718428119, - "narHash": "sha256-WdWDpNaq6u1IPtxtYHHWpl5BmabtpmLnMAx0RdJ/vo8=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "e6cea36f83499eb4e9cd184c8a8e823296b50ad5", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "root": { "inputs": { - "c_formatter_42": "c_formatter_42", - "flake-utils": "flake-utils_2", - "generic_c": "generic_c", - "nixpkgs": "nixpkgs_5", - "rust-overlay": "rust-overlay_2" - } - }, - "rust-overlay": { - "inputs": { - "flake-utils": "flake-utils_4", - "nixpkgs": "nixpkgs_4" - }, - "locked": { - "lastModified": 1706753617, - "narHash": "sha256-ZKqTFzhFwSWFEpQTJ0uXnfJBs5Y/po9/8TK4bzssdbs=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "58be43ae223034217ea1bd58c73210644031b687", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" - } - }, - "rust-overlay_2": { - "inputs": { - "nixpkgs": "nixpkgs_6" - }, - "locked": { - "lastModified": 1722738111, - "narHash": "sha256-cWD5pCs9AYb+512/yCx9D0Pl5KcmyuXHeJpsDw/D1vs=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "27ec296d93cb4b2d03e8cbd019b1b4cde8c34280", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" } }, "systems": { @@ -296,51 +53,6 @@ "repo": "default", "type": "github" } - }, - "systems_2": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "systems_3": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "systems_4": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index a703b118..30c3bd37 100644 --- a/flake.nix +++ b/flake.nix @@ -3,21 +3,22 @@ inputs.nixpkgs.url = "github:nixos/nixpkgs"; inputs.flake-utils.url = "github:numtide/flake-utils"; - inputs.generic_c.url = "github:Maix0/generic_c"; - inputs.c_formatter_42.url = "github:Maix0/c_formatter_42-flake"; - inputs.rust-overlay.url = "github:oxalica/rust-overlay"; + # inputs.generic_c.url = "github:Maix0/generic_c"; + # inputs.c_formatter_42.url = "github:Maix0/c_formatter_42-flake"; + # inputs.rust-overlay.url = "github:oxalica/rust-overlay"; outputs = { self, nixpkgs, flake-utils, - generic_c, - c_formatter_42, - rust-overlay, + # generic_c, + # c_formatter_42, + # rust-overlay, }: flake-utils.lib.eachDefaultSystem ( system: let - pkgs = import nixpkgs { + pkgs = nixpkgs.legacyPackages.${system}; + /*import nixpkgs { inherit system; overlays = [ (import rust-overlay) @@ -28,21 +29,22 @@ }; }) ]; - }; + };*/ in { devShell = pkgs.mkShell { packages = with pkgs; [ - clang-analyzer + # clang-analyzer clang gnumake - generic_c.packages.${system}.default - c_formatter_42.packages.${system}.default - llvmPackages.bintools - norminette - tokei - coreutils + # generic_c.packages.${system}.default + # c_formatter_42.packages.${system}.default + # llvmPackages.bintools + # norminette + # tokei + # coreutils + #]; ] ++ (if system == "x86_64-linux" then [valgrind valgrind.dev] else []); - ASAN_OPTIONS = "strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1"; + #ASAN_OPTIONS = "strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1"; }; } ); diff --git a/stdme/src/os/process.c b/stdme/src/os/process.c index 2f14cf92..10f2c222 100644 --- a/stdme/src/os/process.c +++ b/stdme/src/os/process.c @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/03 16:22:41 by maiboyer #+# #+# */ -/* Updated: 2024/08/05 15:46:09 by maiboyer ### ########.fr */ +/* Updated: 2024/08/10 18:41:56 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -83,7 +83,7 @@ t_error find_binary(t_spawn_info *info, t_process *process) if (vec_str_find(&info->environement, _find_path, &p_idx)) return (string_free(s), ERROR); if (in_path(info, process, info->environement.buffer[p_idx], &s)) - return (ERROR); + return (string_free(s), ERROR); } if (access(s.buf, X_OK | R_OK) == 0) {