diff --git a/Filelist.sh.mk b/Filelist.sh.mk index 1056a031..e53a653b 100644 --- a/Filelist.sh.mk +++ b/Filelist.sh.mk @@ -1,13 +1,8 @@ SRC_FILES = \ env \ -ft_cmd \ -ft_echo \ ft_exit \ -ft_pwd \ main \ node/node \ -operation/ft_classic_op \ -operation/ft_hard_op \ signal_handler \ GEN_FILES = \ diff --git a/Makefile b/Makefile index 5ed2a6bf..d0f3c028 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: rparodi +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/12 11:05:05 by rparodi #+# #+# # -# Updated: 2024/07/26 14:04:45 by maiboyer ### ########.fr # +# Updated: 2024/07/31 17:20:47 by maiboyer ### ########.fr # # # # **************************************************************************** # @@ -47,6 +47,10 @@ endif CFLAGS_ADDITIONAL += -DPRINT_BACKTRACE CFLAGS_ADDITIONAL += -gcolumn-info CFLAGS_ADDITIONAL += '-DERROR=((void)printf("ERROR HERE: " __FILE__ ":%d in %s\n", __LINE__, __func__), 1)' +# CFLAGS_ADDITIONAL += -fuse-ld=gold -Wl,--print-symbol-counts -Wl,/tmp/symbols.count.log + +export CFLAGS_ADDITIONAL +export CC # All (make all) all: diff --git a/Minishell.mk b/Minishell.mk index e6f5e019..9912b339 100644 --- a/Minishell.mk +++ b/Minishell.mk @@ -6,7 +6,7 @@ # By: maiboyer +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2024/04/28 17:28:30 by maiboyer #+# #+# # -# Updated: 2024/07/26 14:04:41 by maiboyer ### ########.fr # +# Updated: 2024/07/31 17:18:34 by maiboyer ### ########.fr # # # # **************************************************************************** # @@ -18,10 +18,14 @@ link_group = -Wl,--start-group $(1) -Wl,--end-group ANAME = sh BUILD_DIR ?= $(shell realpath ./build/) +export CFLAGS_ADDITIONAL +export CC + # Flags -CFLAGS = -Werror -Wextra -Wall -Wno-unused-command-line-argument -g3 -MMD -I./includes -I./output/include -I./stdme/output/include -rdynamic -Wl,-E +CFLAGS = -Werror -Wextra -Wall -Wno-unused-command-line-argument -g3 -MMD -I./includes -I./output/include -I./stdme/output/include -rdynamic -Wl,-E CFLAGS += $(CFLAGS_ADDITIONAL) + SRC_DIR = sources GEN_DIR = output diff --git a/sources/ft_cmd.c b/sources/ft_cmd.c deleted file mode 100644 index 3ac81c89..00000000 --- a/sources/ft_cmd.c +++ /dev/null @@ -1,52 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_cmd.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: rparodi +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/04/13 20:26:13 by rparodi #+# #+# */ -/* Updated: 2024/05/04 18:59:58 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "../includes/minishell.h" - -// void ft_exec_cmd(t_state *utils, t_str cmd, t_str cmd_args[]) -// { -// if (execve(cmd, cmd_args, utils->envp) == -1) -// { -// printf("ERROR >\n execve\n %s\n", cmd); -// ft_free_strs((char **)cmd_args); -// ft_exit(utils, 1); -// } -// } -// -// void ft_other_cmd(t_state *shcat, t_usize i, t_usize prev_i) -// { -// pid_t pid; -// t_i32 options; -// t_str *args; -// t_usize k; -// // t_str cmd; -// -// k = prev_i; -// args = (t_str *)malloc(sizeof(t_str) * (i + 2)); -// while (prev_i < i) -// { -// printf("ft_other_cmd = %s\n", shcat->strs_input[prev_i]); -// args[k] = malloc(ft_strlen(shcat->strs_input[prev_i])); -// ft_strlcpy(args[k], shcat->strs_input[prev_i], ft_strlen(shcat->strs_input[prev_i])); -// prev_i++; -// k++; -// } -// args[k] = NULL; -// // cmd = ft_check_cmds(shcat, args[tmp]); -// options = 0; -// pid = fork(); -// if (pid == -1) -// ft_exit(shcat, 1); -// // if (pid == 0) -// // ft_exec_cmd(shcat, cmd, args); -// waitpid(pid, NULL, options); -// } diff --git a/sources/ft_echo.c b/sources/ft_echo.c deleted file mode 100644 index a97fe83d..00000000 --- a/sources/ft_echo.c +++ /dev/null @@ -1,21 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_echo.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: rparodi +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/31 21:48:04 by rparodi #+# #+# */ -/* Updated: 2024/05/25 16:09:28 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "../includes/minishell.h" -#include "me/str/str.h" - -void ft_echo(t_str txt, t_str flag) -{ - printf("%s", txt); - if (!str_compare(flag, "-n")) - printf("\n"); -} diff --git a/sources/ft_exit.c b/sources/ft_exit.c index 4383af4d..5ac413c5 100644 --- a/sources/ft_exit.c +++ b/sources/ft_exit.c @@ -6,15 +6,14 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/29 11:35:51 by rparodi #+# #+# */ -/* Updated: 2024/05/29 16:39:24 by maiboyer ### ########.fr */ +/* Updated: 2024/07/31 17:08:05 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ -#include "../includes/minishell.h" -#include "app/env.h" +#include "app/state.h" #include "me/hashmap/hashmap_env.h" #include "me/mem/mem.h" - +#include "parser/api.h" void ts_parser_delete(t_first_parser *self); diff --git a/sources/ft_pwd.c b/sources/ft_pwd.c deleted file mode 100644 index a91555df..00000000 --- a/sources/ft_pwd.c +++ /dev/null @@ -1,38 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_pwd.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: rparodi +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/31 22:14:33 by rparodi #+# #+# */ -/* Updated: 2024/05/25 16:08:50 by maiboyer ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "me/mem/mem.h" -#include "minishell.h" - -void ft_pwd(void) -{ - t_str str; - t_usize size; - - size = 1024; - str = (t_str)mem_alloc_array((size + 1), sizeof(t_i8)); - if (str == NULL) - ft_exit(NULL, 0); - while (getcwd(str, size) == NULL) - { - if (str) - free(str); - size *= 2; - str = (t_str)mem_alloc_array(sizeof(t_i8), size); - if (str == NULL) - { - ft_exit(NULL, 0); - } - } - printf("%s\n", str); - free(str); -} diff --git a/sources/main.c b/sources/main.c index 71c5b5b6..ed437338 100644 --- a/sources/main.c +++ b/sources/main.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/28 14:40:38 by rparodi #+# #+# */ -/* Updated: 2024/07/23 22:16:02 by maiboyer ### ########.fr */ +/* Updated: 2024/07/31 17:07:37 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,19 +14,20 @@ #include "app/env.h" #include "app/node.h" #include "app/signal_handler.h" +#include "app/state.h" #include "ast/ast.h" #include "line/line.h" #include "me/hashmap/hashmap_env.h" #include "me/str/str.h" #include "me/string/string.h" #include "me/types.h" -#include "minishell.h" #include "parser/api.h" #include #include t_error ast_from_node(t_parse_node node, t_str input, t_ast_node *out); void ast_print_node(t_ast_node self); +void ft_exit(t_state *maiboyerlpb, t_u8 exit_status); // Foutre envp dans env // Chaque elemenet d'envp split au premier = @@ -177,7 +178,7 @@ void free_myparser(t_parser self) t_i32 main(t_i32 argc, t_str argv[], t_str envp[]) { t_state state; - //char truc[] = COLB_YELLOW "42sh" COL_GREEN ">" COL_WHITE "$ " RESET; + // char truc[] = COLB_YELLOW "42sh" COL_GREEN ">" COL_WHITE "$ " RESET; (void)argc; (void)argv; diff --git a/sources/operation/ft_classic_op.c b/sources/operation/ft_classic_op.c deleted file mode 100644 index 631b515c..00000000 --- a/sources/operation/ft_classic_op.c +++ /dev/null @@ -1,61 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_classic_op.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: rparodi +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/30 15:33:53 by rparodi #+# #+# */ -/* Updated: 2024/05/30 16:12:59 by rparodi ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "operation.h" - -t_error ft_add(t_i32 first, t_i32 second, t_i64 *result) -{ - (*result) = first + second; - if ((*result) - first != second) - return (ERROR); - else - return (NO_ERROR); -} - -t_error ft_subtract(t_i32 first, t_i32 second, t_i64 *result) -{ - (*result) = first - second; - if ((*result) + first != second) - return (ERROR); - else - return (NO_ERROR); -} - -t_error ft_multiply(t_i32 first, t_i32 second, t_i64 *result) -{ - if (first == 0 || second == 0) - return (0); - (*result) = first * second; - if ((*result) / first != second) - return (ERROR); - else - return (NO_ERROR); -} - -t_error ft_divide(t_i32 first, t_i32 second, t_i64 *result) -{ - if (second == 0) - return (ERROR); - (*result) = first / second; - if ((*result) * first != second) - return (ERROR); - else - return (NO_ERROR); -} - -t_error ft_modulo(t_i32 first, t_i32 second, t_i64 *result) -{ - if (second == 0) - return (ERROR); - *result = first % second; - return (NO_ERROR); -} diff --git a/sources/operation/ft_hard_op.c b/sources/operation/ft_hard_op.c deleted file mode 100644 index 528b380d..00000000 --- a/sources/operation/ft_hard_op.c +++ /dev/null @@ -1,55 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_hard_op.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: rparodi +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/30 15:51:55 by rparodi #+# #+# */ -/* Updated: 2024/05/30 16:14:04 by rparodi ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "operation.h" - -t_error ft_power(t_i32 base, t_i32 exponent, t_i64 *result) -{ - t_i32 i; - t_i64 tmp; - - i = 0; - tmp = base; - if (exponent < 0) - return (ERROR); - while (i < exponent) - { - (*result) *= base; - if ((*result) / base != tmp) - return (ERROR); - tmp = (*result); - i++; - } - return (NO_ERROR); -} - -t_error ft_decrimented(t_i64 *value) -{ - t_i64 tmp; - - tmp = *value; - (*value)--; - if ((*value) + 1 != tmp) - return (ERROR); - return (NO_ERROR); -} - -t_error ft_incrimented(t_i64 *value) -{ - t_i64 tmp; - - tmp = *value; - (*value)++; - if ((*value) - 1 != tmp) - return (ERROR); - return (NO_ERROR); -} diff --git a/sources/operation/operation.h b/sources/operation/operation.h deleted file mode 100644 index 2909f71a..00000000 --- a/sources/operation/operation.h +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* operation.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: rparodi +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/30 16:03:29 by rparodi #+# #+# */ -/* Updated: 2024/05/30 16:14:22 by rparodi ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef OPERATION_H -# define OPERATION_H - -# include "minishell.h" -# include "me/types.h" - -t_error ft_add(t_i32 first, t_i32 second, t_i64 *result); -t_error ft_subtract(t_i32 first, t_i32 second, t_i64 *result); -t_error ft_multiply(t_i32 first, t_i32 second, t_i64 *result); -t_error ft_divide(t_i32 first, t_i32 second, t_i64 *result); -t_error ft_modulo(t_i32 first, t_i32 second, t_i64 *result); -t_error ft_power(t_i32 base, t_i32 exponent, t_i64 *result); -t_error ft_incrimented(t_i64 *value); -t_error ft_decrimented(t_i64 *value); - -#endif