This commit is contained in:
whaffman 2025-02-25 18:31:14 +01:00
parent 8e5f90436a
commit 7b1951bf85
6 changed files with 27 additions and 36 deletions

View File

@ -6,7 +6,7 @@
# By: qmennen <qmennen@student.codam.nl> +#+ # # By: qmennen <qmennen@student.codam.nl> +#+ #
# +#+ # # +#+ #
# Created: 2024/10/15 11:48:46 by whaffman #+# #+# # # 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 BUILD_CONFIGS = release debug asan tsan
release_CFLAGS = -Wall -Werror -Werror -O2 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 asan_CFLAGS = -Wall -Werror -Werror -fsanitize=address,leak,undefined -g3
tsan_CFLAGS = -Wall -Werror -Werror -fsanitize=thread -g3 tsan_CFLAGS = -Wall -Werror -Werror -fsanitize=thread -g3

View File

@ -5,15 +5,15 @@ A lot of amazing shell stuff
- libncurses-dev - libncurses-dev
## TODO ## TODO
-[x] Find absolute path for command input ('/', './', 'cmd') - [x] Find absolute path for command input ('/', './', 'cmd')
- Add heredoc to tokenizer - [x]Add heredoc to tokenizer
-[x] Environment to `t_list` - [x] Environment to `t_list`
-[x] Get environment array (export) - [x] Get environment array (export)
-[x] Set environment variable (export) - [x] Set environment variable (export)
-[x] Simple builtin export - [x] Simple builtin export
-[x] builtins - [x] builtins
-[x] Preliminary signals - [x] Preliminary signals
-[x] Define struct for commands, something like ( - [x] Define struct for commands, something like (
```c ```c
typedef struct s_command typedef struct s_command
{ {

View File

@ -45,6 +45,12 @@
# define PROMPT RESET "🐚" GREEN "minishell" RESET ": " # define PROMPT RESET "🐚" GREEN "minishell" RESET ": "
# define PROMPT_LEN 51 # define PROMPT_LEN 51
# ifdef DEBUG
# define DEBUG 1
# else
# define DEBUG 0
# endif // DEBUG
void token_print(void *param); void token_print(void *param);
#endif #endif

View File

@ -17,6 +17,8 @@ void print_commands(void *param)
t_command *command; t_command *command;
int i; int i;
if (!DEBUG)
return ;
command = (t_command *)param; command = (t_command *)param;
if (!command) if (!command)
return ; return ;
@ -46,6 +48,8 @@ void token_print(void *param)
{ {
t_token *token; t_token *token;
if (!DEBUG)
return ;
token = (t_token *)param; token = (t_token *)param;
printf("token type %i, value %s\n", token->type, token->value); printf("token type %i, value %s\n", token->type, token->value);
} }

View File

@ -6,7 +6,7 @@
/* By: whaffman <whaffman@student.codam.nl> +#+ */ /* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/02/25 15:46:03 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; t_list *freelist;
int i; int i;
if (!DEBUG)
return ;
i = 0; i = 0;
freelist = minishell->freelist; freelist = minishell->freelist;
while (freelist) while (freelist)

View File

@ -6,7 +6,7 @@
/* By: whaffman <whaffman@student.codam.nl> +#+ */ /* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/02/25 15:09:34 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,26 +16,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
/* 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)
{ {
@ -56,13 +36,12 @@ void free_safe(t_minishell *minishell, void **ptr)
minishell->freelist = current->next; minishell->freelist = current->next;
free(*ptr); free(*ptr);
free(current); free(current);
return; return ;
} }
prev = current; prev = current;
current = current->next; current = current->next;
} }
error_msg("free_safe", "pointer not found in freelist"); error_msg("free_safe", "pointer not found in freelist");
// print_trace();
} }
*ptr = NULL; *ptr = NULL;
} }