Created file for builtins and fixed a bug about expansion not working correctly

This commit is contained in:
Maix0 2024-08-10 19:50:26 +02:00
parent 1ecfba4340
commit 3f08544384
15 changed files with 243 additions and 429 deletions

View file

@ -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 \

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 <stdio.h>
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)
{

View file

@ -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 \

View file

@ -0,0 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* builtins.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */

22
exec/src/builtins/cd.c Normal file
View file

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

45
exec/src/builtins/echo.c Normal file
View file

@ -0,0 +1,45 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* echo.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -6,31 +6,14 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 <cstddef>
#include <stdlib.h>
#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);
}

23
exec/src/builtins/exit.c Normal file
View file

@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* exit.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -6,31 +6,22 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 <cstddef>
#include <stdlib.h>
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);
}

View file

@ -6,40 +6,23 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 <stdlib.h>
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);
}

22
exec/src/builtins/unset.c Normal file
View file

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* unset.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
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)
{
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);
}

298
flake.lock generated
View file

@ -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",

View file

@ -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";
};
}
);

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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)
{