diff --git a/Makefile b/Makefile index 350889b..1546611 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: qmennen +#+ # # +#+ # # Created: 2024/10/15 11:48:46 by whaffman #+# #+# # -# Updated: 2025/02/23 13:34:57 by willem ######## odam.nl # +# Updated: 2025/02/25 18:15:50 by whaffman ######## odam.nl # # # # **************************************************************************** # @@ -38,7 +38,7 @@ endif BUILD_CONFIGS = release debug asan tsan release_CFLAGS = -Wall -Werror -Werror -O2 -debug_CFLAGS = -Wall -Werror -Werror -g3 +debug_CFLAGS = -Wall -Werror -Werror -g3 -DDEBUG asan_CFLAGS = -Wall -Werror -Werror -fsanitize=address,leak,undefined -g3 tsan_CFLAGS = -Wall -Werror -Werror -fsanitize=thread -g3 diff --git a/README.md b/README.md index 7ba4ee1..deeb689 100644 --- a/README.md +++ b/README.md @@ -5,15 +5,15 @@ A lot of amazing shell stuff - libncurses-dev ## TODO --[x] Find absolute path for command input ('/', './', 'cmd') -- Add heredoc to tokenizer --[x] Environment to `t_list` --[x] Get environment array (export) --[x] Set environment variable (export) --[x] Simple builtin export --[x] builtins --[x] Preliminary signals --[x] Define struct for commands, something like ( +- [x] Find absolute path for command input ('/', './', 'cmd') +- [x]Add heredoc to tokenizer +- [x] Environment to `t_list` +- [x] Get environment array (export) +- [x] Set environment variable (export) +- [x] Simple builtin export +- [x] builtins +- [x] Preliminary signals +- [x] Define struct for commands, something like ( ```c typedef struct s_command { diff --git a/inc/minishell.h b/inc/minishell.h index 78bc2cf..1697e7f 100644 --- a/inc/minishell.h +++ b/inc/minishell.h @@ -45,6 +45,12 @@ # define PROMPT RESET "🐚" GREEN "minishell" RESET ": " # define PROMPT_LEN 51 +# ifdef DEBUG +# define DEBUG 1 +# else +# define DEBUG 0 +# endif // DEBUG + void token_print(void *param); #endif diff --git a/src/debug/print_commands.c b/src/debug/print_commands.c index e52ca8f..c41bfa2 100644 --- a/src/debug/print_commands.c +++ b/src/debug/print_commands.c @@ -17,6 +17,8 @@ void print_commands(void *param) t_command *command; int i; + if (!DEBUG) + return ; command = (t_command *)param; if (!command) return ; @@ -46,6 +48,8 @@ void token_print(void *param) { t_token *token; + if (!DEBUG) + return ; token = (t_token *)param; printf("token type %i, value %s\n", token->type, token->value); } diff --git a/src/debug/print_freelist.c b/src/debug/print_freelist.c index fb11d2e..b9b1e6e 100644 --- a/src/debug/print_freelist.c +++ b/src/debug/print_freelist.c @@ -6,7 +6,7 @@ /* By: whaffman +#+ */ /* +#+ */ /* Created: 2025/02/25 15:46:03 by whaffman #+# #+# */ -/* Updated: 2025/02/25 15:55:41 by whaffman ######## odam.nl */ +/* Updated: 2025/02/25 18:17:13 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -17,6 +17,8 @@ void print_freelist(t_minishell *minishell) t_list *freelist; int i; + if (!DEBUG) + return ; i = 0; freelist = minishell->freelist; while (freelist) diff --git a/src/utils/free_safe.c b/src/utils/free_safe.c index e5070ec..bae7ef2 100644 --- a/src/utils/free_safe.c +++ b/src/utils/free_safe.c @@ -6,7 +6,7 @@ /* By: whaffman +#+ */ /* +#+ */ /* Created: 2025/02/25 15:09:34 by whaffman #+# #+# */ -/* Updated: 2025/02/25 17:35:39 by whaffman ######## odam.nl */ +/* Updated: 2025/02/25 18:06:06 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -16,28 +16,8 @@ #include #include -/* Obtain a backtrace and print it to stdout. */ -void -print_trace (void) -{ - void *array[10]; - char **strings; - int size, i; - size = backtrace (array, 10); - strings = backtrace_symbols (array, size); - if (strings != NULL) - { - - printf ("Obtained %d stack frames.\n", size); - for (i = 0; i < size; i++) - fprintf (stderr, "%s\n", strings[i]); - } - - free (strings); -} - -void free_safe(t_minishell *minishell, void **ptr) +void free_safe(t_minishell *minishell, void **ptr) { t_list *prev; t_list *current; @@ -56,13 +36,12 @@ void free_safe(t_minishell *minishell, void **ptr) minishell->freelist = current->next; free(*ptr); free(current); - return; + return ; } prev = current; current = current->next; } error_msg("free_safe", "pointer not found in freelist"); - // print_trace(); } *ptr = NULL; }