Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete #34

Merged
merged 87 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
940d5e5
add: get local_vars using $
Sep 3, 2024
317fe06
add: heredoc now returns expanded env_arvs and loc_args
Sep 3, 2024
eefb005
fix: norminette for heredoc env_var functionality
Sep 3, 2024
c892c1a
fix: working on interpreting $a$b together
Sep 4, 2024
b0c6094
fix: done echo a$a$b
Sep 4, 2024
62be926
fix: norminette after a$a$b fix
Sep 4, 2024
7e70340
refactoring
Sep 3, 2024
a0aa1fa
new: errors
Sep 3, 2024
7822901
add: exit_status
Sep 4, 2024
7c63191
fix:compilation issues
dimadem Sep 5, 2024
f99bb3b
fix: removed error check for | at end of input
romanmikh Sep 5, 2024
586ef37
fix: removed error check for | at end of input
romanmikh Sep 5, 2024
d279ed3
fix: opened 'ls -la |' readline functionality
romanmikh Sep 6, 2024
6731a41
fix: opened 'ls -la |' readline functionality
romanmikh Sep 6, 2024
11cecef
add: CTRL+C sigint in heredocs
romanmikh Sep 6, 2024
6384d71
fix: CTRL+C in heredocs, working on norminette
romanmikh Sep 6, 2024
fa3e54f
fix: CTRL+D functionality passing norminette
romanmikh Sep 6, 2024
a5ab44b
fix: heredoc norminette
romanmikh Sep 6, 2024
ba2925b
Dnew backup branch
romanmikh Sep 6, 2024
fbfff18
Merge branch 'roman_6sept' into dev
dimadem Sep 6, 2024
fdb70a0
Dev (#29)
dimadem Sep 6, 2024
2f188ed
Dev (#29) (#30)
dimadem Sep 6, 2024
9e97378
fix: cat << eof (issue 4)
romanmikh Sep 6, 2024
c31a369
fix: exit statuses showing again
romanmikh Sep 6, 2024
dacdc4a
fix: error codes (issue 1)
romanmikh Sep 6, 2024
c9c287c
fix: history file deleted on exit or sig quit
romanmikh Sep 6, 2024
65cf07d
fix: single and double quotes workgit add .git add .! in heredocs too…
romanmikh Sep 6, 2024
cc1450e
fix: heredoc quotation marks match bash behaviour
romanmikh Sep 6, 2024
0787eb9
fix: echo rocky 'rocky' rocky USER 0 0 '0'
romanmikh Sep 7, 2024
a233ce2
fix: echo rocky 'rocky' rocky USER 0 0 '0'
romanmikh Sep 7, 2024
73678a8
fix: CTRL+C add new line after on grep 'we'
romanmikh Sep 7, 2024
b3e8792
Dimadem valgrind (#31)
dimadem Sep 7, 2024
743a349
fix: 5. message for CTRL+\ on exit.
romanmikh Sep 7, 2024
c282902
Merge branch 'dev' into roman_7sept
romanmikh Sep 7, 2024
e55e923
merged branches
romanmikh Sep 7, 2024
4036360
fix: 3 memory leaks with no input, only exit after start
romanmikh Sep 7, 2024
68db54a
reset to working version (exit error)
Sep 7, 2024
a75fc32
fix: 2 leaks, (signal and path in execute.c
Sep 7, 2024
f564d85
fix:valgrind exit
Sep 7, 2024
d2579d6
fix: add_env leak, add_shell_var leak
Sep 7, 2024
1b54b63
SAFE TO REVERT TO - improved structuring of files only
romanmikh Sep 8, 2024
3ac7583
mid-debugging, still works well. Revert to here if necessary
romanmikh Sep 8, 2024
2d5fe8a
about to refactor new_ast_node & tree, safe to RESET to here
romanmikh Sep 8, 2024
c5e2643
restructured AST, safe to roll back to here
romanmikh Sep 8, 2024
55712a7
restructured AST, safe to roll back to here
romanmikh Sep 8, 2024
f0f59f7
restructured AST, safe to roll back to here
romanmikh Sep 8, 2024
050d58f
pipe giving double free but I think this is the right way forward
romanmikh Sep 8, 2024
574eeae
pipe giving double free but I think this is the right way forward
romanmikh Sep 8, 2024
50c1995
got through tokenizer, pipe still doesn't work but made changes i wan…
romanmikh Sep 8, 2024
b1570cb
I think I'm close but there are errors. Fixing ast vs tokens list fre…
romanmikh Sep 8, 2024
19d7ba4
AST & TOKENS FREE CONFLICT RESOLVED BITCHEZZZZZZZZZZ
romanmikh Sep 8, 2024
41674e0
debugging pipe malloc (and mayeb functionality) issue
romanmikh Sep 8, 2024
6abf6e5
FIXED PIPE & TOKEN AST DISCONTINUITYYYYYYYY
romanmikh Sep 8, 2024
7c17c2e
FIXED PIPE & TOKEN AST DISCONTINUITYYYYYYYY
romanmikh Sep 8, 2024
11d0d78
fix: many things. I have become one with minishell. Tomorrow we fix e…
romanmikh Sep 8, 2024
70a57b1
Roman 7sept (#32)
dimadem Sep 9, 2024
bd6cb3b
Merge branch 'roman_7sept' into dev
Sep 9, 2024
7d0ecb4
fix: env valgrind
Sep 9, 2024
5764fbe
fix: valgrind shell_var
Sep 9, 2024
4d15af3
fix
Sep 9, 2024
515caf7
merged with dimas work from today (9th) from dev
Sep 9, 2024
6add453
added malloc debugger statements
Sep 9, 2024
2a9f691
no leak checks with echo simple arg
Sep 9, 2024
2da1a82
fixed memory leaks for echo multiple simple args
Sep 9, 2024
69a84f9
env vars are working (without echo)
Sep 9, 2024
126f360
Dimadem norminette (#33)
dimadem Sep 9, 2024
11d0ecc
fix:issues
Sep 9, 2024
67934ce
rmikhayl 'rmikhayl' rmikhayl USER 0 0 '0' worksgit add . loc args, le…
Sep 9, 2024
83a2513
almost there, just some env/loc/exit vars to iron out in heredoc
Sep 9, 2024
7a6d35f
holy shit I think all the memory leaks are fixed
Sep 9, 2024
eeab221
everything works except for loc vars in heredocs
Sep 9, 2024
0550181
EVERY MEMORY LEAK FIXED OH MAA GAAAWD
Sep 9, 2024
a52f40b
YAAAAAAAAAAAAAAAAAAS THIS IS ALL HEALTHY
Sep 9, 2024
ab0a80c
Co-authored-by: Dima Dem <[email protected]>
Sep 9, 2024
641bd8e
only norminette for the 2 loc_env files left to dogit add .git add .g…
Sep 9, 2024
1f064ff
working on norminette, so far no leaks
Sep 9, 2024
6e8c03a
split functions across files, preparing for refactoring. Reset to her…
Sep 9, 2024
1dc979b
loc_env_var_heredoc_utils norminette passing! safe to revert to here
Sep 10, 2024
1f88895
new checkpoint, loc_env_car_handler is fine
Sep 10, 2024
f6116c1
new checkpoint, loc_env_car_handler is fine
Sep 10, 2024
fd2b8d0
new checkpoint, loc_env_car_handler & utils_utils are fine
Sep 10, 2024
bd0025e
one function left to go
Sep 10, 2024
8b1bb74
one function left to go
Sep 10, 2024
105cd19
think all checks are still passed, manually split up expand_variable
Sep 10, 2024
8712a46
is it done?
Sep 10, 2024
94eb900
its done
Sep 10, 2024
5b758d1
tidied up non-ft functions
Sep 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ NAME = minishell
# Comands
COMPILER = cc
DFLAGS = -g3 -gdwarf-2
CFLAGS = -Wall -Wextra -Werror $(DFLAGS)
CFLAGS = -Wall -Wextra -Werror $(DFLAGS) -g -O0
AR = ar rcs
RM = rm -rf
MAKEFLAGS += --silent
Expand All @@ -51,6 +51,7 @@ EXECUTE_DIR = $(SRC_DIR)/execute
EXIT_STATUS_DIR = $(SRC_DIR)/exit_status
TEST_DIR = $(SRC_DIR)/test
SIGNALS_DIR = $(SRC_DIR)/signals
CHECK_TOKENISE_DIR = $(SRC_DIR)/check_tokenise

INCLUDES = -I./inc \
-I $(LIB_DIR)/libft/inc \
Expand All @@ -73,6 +74,8 @@ BUILTINS_SOURCES = $(wildcard $(BUILTINS_DIR)/*.c)
EXECUTE_SOURCES = $(wildcard $(EXECUTE_DIR)/*.c)
EXIT_STATUS_SOURCES = $(wildcard $(EXIT_STATUS_DIR)/*.c)
SIGNALS_SOURCES = $(wildcard $(SIGNALS_DIR)/*.c)
CHECK_TOKENISE_SOURCES = $(wildcard $(CHECK_TOKENISE_DIR)/*.c)


MAIN_TEST_SOURCE = $(wildcard $(TEST_DIR)/*.c)
ENV_TEST_SOURCES = $(wildcard $(TEST_DIR)/env/*.c)
Expand All @@ -94,7 +97,8 @@ SOURCES = $(MAIN_SOURCE) \
$(ENV_TEST_SOURCES) \
$(PIPE_TEST_SOURCES) \
$(REDIRECTION_SOURCES) \
$(SIGNALS_SOURCES)
$(SIGNALS_SOURCES) \
$(CHECK_TOKENISE)
# Building
BUILD_DIR = ./build
MAIN_OBJECT = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/src/%.o, $(MAIN_SOURCE))
Expand All @@ -113,6 +117,7 @@ SIGNALS_OBJECTS = $(patsubst $(SIGNALS_DIR)/%.c, $(BUILD_DIR)/src/signals/%.o
MAIN_TEST_OBJECT = $(patsubst $(TEST_DIR)/%.c, $(BUILD_DIR)/src/test/%.o, $(MAIN_TEST_SOURCE))
ENV_TEST_OBJECTS = $(patsubst $(TEST_DIR)/env/%.c, $(BUILD_DIR)/src/test/env/%.o, $(ENV_TEST_SOURCES))
PIPE_TEST_OBJECTS = $(patsubst $(TEST_DIR)/pipe/%.c, $(BUILD_DIR)/src/test/pipe/%.o, $(PIPE_TEST_SOURCES))
CHECK_TOKENISE_OBJECTS = $(patsubst $(CHECK_TOKENISE_DIR)/check_tokenise/%.c, $(BUILD_DIR)/src/check_tokenise/%.o, $(CHECK_TOKENISE_SOURCES))

OBJECTS = $(MAIN_OBJECT) \
$(APP_OBJECTS) \
Expand All @@ -127,7 +132,8 @@ OBJECTS = $(MAIN_OBJECT) \
$(PARSER_OBJECTS) \
$(PIPE_OBJECTS) \
$(REDIRECTION_OBJECTS) \
$(SIGNALS_OBJECTS)
$(SIGNALS_OBJECTS) \
$(CHECK_TOKENISE_OBJECTS)

TEST_OBJECTS = $(APP_OBJECTS) \
$(ENV_OBJECTS) \
Expand All @@ -139,7 +145,8 @@ TEST_OBJECTS = $(APP_OBJECTS) \
$(PIPE_OBJECTS) \
$(MAIN_TEST_OBJECT) \
$(ENV_TEST_OBJECTS) \
$(PIPE_TEST_OBJECTS)
$(PIPE_TEST_OBJECTS) \
$(CHECK_TOKENISE_OBJECTS)

# Processing
all: $(NAME)
Expand Down Expand Up @@ -234,6 +241,6 @@ test: $(TEST_OBJECTS) $(LIBFT)
@./test

valgrind: $(NAME)
@valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --suppressions=readline.supp --log-file=valgrind-out.txt ./minishell
@valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --track-fds=yes --trace-children=yes --suppressions=readline.supp --num-callers=20 --log-file=valgrind-out.txt ./minishell

.PHONY: all bonus clean fclean re test
File renamed without changes.
3 changes: 2 additions & 1 deletion inc/execute.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: dmdemirk <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/03 16:34:42 by dmdemirk #+# #+# */
/* Updated: 2024/09/06 12:31:40 by dmdemirk ### ########.fr */
/* Updated: 2024/09/09 13:19:58 by dmdemirk ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -26,6 +26,7 @@ void ft_free_2d_arr(char **arr);
int ft_perror(char *str);
void close_fds(int in, int out);
void handle_io_fd(t_ms_data *data);
void handle_std_io(int *std_io, int std_fileno);

/* shell variable execution */
int handle_shell_variable(t_ast *node, t_ms_data *data);
Expand Down
3 changes: 2 additions & 1 deletion inc/exit_status.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: dmdemirk <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/06 12:29:24 by dmdemirk #+# #+# */
/* Updated: 2024/09/06 12:31:02 by dmdemirk ### ########.fr */
/* Updated: 2024/09/09 13:20:14 by dmdemirk ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -37,5 +37,6 @@ void set_exit_status(int *exit_status, int status_code);
/* exit_status_utils */
int ft_perror(char *str);
int ft_isnumber(char *str);
void free_shell_var_list(t_env *shell_var);

#endif
14 changes: 8 additions & 6 deletions inc/redirection.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: dmdemirk <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/11 14:59:47 by dmdemirk #+# #+# */
/* Updated: 2024/07/11 15:00:25 by dmdemirk ### ########.fr */
/* Updated: 2024/09/09 13:49:13 by dmdemirk ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -17,12 +17,14 @@
# include "tokens.h"

/* redirect_in */
int redirect_in(t_ast *node, t_ms_data *data);
int redirect_out(t_ast *node, t_ms_data *data);
int redirect_append(t_ast *node, t_ms_data *data);
int redirect_here_doc(t_ast *node, t_ms_data *data);
int redirect_in(t_ast *node, t_ms_data *data);
int redirect_out(t_ast *node, t_ms_data *data);
int redirect_append(t_ast *node, t_ms_data *data);
int redirect_here_doc(t_ast *node, t_ms_data *data);
char *process_and_reassemble(char *line, t_ms_data *data);

/* utils */
int open_file(t_ast *node, char *direction);
int open_file(t_ast *node, char *direction);
int open_tmp_file(const char *type);

#endif
7 changes: 6 additions & 1 deletion inc/signals.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: dmdemirk <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/17 14:07:19 by dmdemirk #+# #+# */
/* Updated: 2024/07/18 15:59:38 by dmdemirk ### ########.fr */
/* Updated: 2024/09/09 13:20:52 by dmdemirk ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -19,12 +19,17 @@
# include <signal.h>
# include "shell.h"

// GLOBAL VAR
extern volatile sig_atomic_t g_heredoc_interrupted;

/* signals */
void signal_reset_prompt(int signo);
void set_signals_interactive(void);
void signal_print_newline(int signal);
void sigquit_ignore(void);
void set_signals_noninteractive(void);
void handle_sigint_heredoc(int signo);

int ft_perror(char *str);

#endif
36 changes: 25 additions & 11 deletions inc/tokens.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ typedef enum e_token_type
REDIR_IN,
REDIR_OUT,
REDIR_APPEND,
REDIR_HEREDOC
REDIR_HEREDOC,
NONE
} t_token_type;

typedef struct s_token
Expand Down Expand Up @@ -73,26 +74,22 @@ int calc_stack_size(t_token *stack);
char **list_to_array(t_token *head);
void build_linked_list(t_token **tokens, char **argv);
void handle_quotes(char **tokens, int *pos, char **input);
void handle_special_chars(char **str, t_token **tokens);
void handle_regular_chars(char **tokens, int *pos, char **input, \
char *delim);
char *handle_special_chars(char *str, t_token **tokens);
void skip_delimiters(char **input, char *delim);
void reallocate_tokens(char ***tokens, int *bufsize);
void parse_loop(char **input, char **tokens, int *pos, int *bufsize);
char **parse_input(char *input);
// char *generate_prompt(void);
char *generate_prompt(t_ms_data *data);
void make_history(char *line);
void loop_cleanup(char *line, t_token *tokens, \
char *prompt, t_ast *tree);
void loop_cleanup(t_loop_data *loop_data, t_token *tokens_head);
void free_ms_data(t_ms_data *data);
char *check_heredoc(char *line);
char *heredoc(char *eof);
void init_ms_data(t_ms_data *data, char **argv, char **envp);
void initialise(int argc, char **argv);
void execute_command(char **parsed_text, t_token **tokens);
void print_maxishell(void);
int input_error_checks(const char *str);
int input_error_checks(t_loop_data *loop_data);
t_token *tokenise(char *str);
void print_tokens(t_token *tokens);
t_ast *parse_tokens(t_token **tokens, t_ms_data *data);
Expand All @@ -103,11 +100,11 @@ void free_all_tokens(t_token *tokens);
t_token *new_token(char *value, t_token_type type);
void append_token(t_token **tokens, t_token *new_token);
int valid_operator(const char **str);
t_ast *new_ast_node(t_token_type type);
t_ast *new_ast_node(void);
t_ast *create_redir(t_token **tokens, t_token *tmp, t_ms_data *data);
int arg_len(t_token *current);
void set_command_args(t_ast *command_node, t_token **tokens, \
int arg_count);
int arg_count);
t_ast *manage_commands(t_token **tokens, t_ms_data *data);
t_ast *create_redir_node(t_token *token);
int is_redir_node(t_token *tokens);
Expand All @@ -119,5 +116,22 @@ void execute_tree(t_ast *node, t_ms_data *data);
char *expand_env_and_loc_var(char *arg, t_ms_data *data);
char *append_literal(char **start, char *processed_arg);
char *process_argument(char *arg, t_ms_data *data);
char *expand_variable(char **start, t_ms_data *data);
void clear_history_file(void);
int is_in_single_quotes(char *arg);
void print_ast_args(t_ast *node);
void append_word_if_valid(char *start, char *str, t_token **tokens);
char *exit_status_adj(char *arg);
char *str_start_adj(char *arg);
char *tmp_adj(char *arg);
int cmd_arg_len(t_token *current);
char *exit_status_adj(char *arg);
int is_in_single_quotes(char *arg);
char *str_start_adj(char *arg);
char *tmp_adj(char *arg);
char *append_literal(char **start, char *processed_arg);
char *expand_variable(char **start, t_ms_data *data);
char *expand_env_and_loc_var(char *arg, t_ms_data *data);
void final_quote_removal(int arg_count, t_ast *command_node);

#endif
#endif
6 changes: 5 additions & 1 deletion lib/libft/inc/libft.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,19 @@ char *ft_strchr(const char *s, int c);
char *ft_strcat(char *dest, char *src);
char *ft_strrchr(const char *s, int c);
char **ft_split(char const *s, char c);
char *ft_strcpy(char *dest, const char *src);
char *ft_strndup(const char *s, size_t n);
char *ft_strjoin_free(char *s1, char *s2);
char *ft_strcpy(char *dest, const char *src);
char *ft_strjoin(char const *s1, char const *s2);
char *ft_strtrim(char const *s1, char const *set);
char *ft_strstr(const char *big, const char *little);
char *ft_strcat_const(const char *dest, const char *src);
char *ft_strmapi(char const *s, char (*f)(unsigned int, char));
char *ft_substr(char const *s, unsigned int start, size_t len);
char *ft_strnstr(const char *haystack, const char *needle, size_t len);

void ft_free_2d_arr(char **arr);
void ft_print_2d_arr(char **arr);
void ft_bzero(void *s, size_t n);
void ft_putnbr_fd(int n, int fd);
void ft_putchar_fd(char c, int fd);
Expand Down
25 changes: 25 additions & 0 deletions lib/libft/src/ft_free_2d_arr.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_free_2d_arr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rmikhayl <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/09 19:37:13 by rmikhayl #+# #+# */
/* Updated: 2024/09/09 19:37:16 by rmikhayl ### ########.fr */
/* */
/* ************************************************************************** */

#include "libft.h"

void ft_free_2d_arr(char **arr)
{
int i;

if (!arr)
return ;
i = -1;
while (arr[++i] != NULL)
free(arr[i]);
free(arr);
}
22 changes: 22 additions & 0 deletions lib/libft/src/ft_print_2d_arr.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_2d_arr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rmikhayl <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/09 19:37:13 by rmikhayl #+# #+# */
/* Updated: 2024/09/09 19:37:16 by rmikhayl ### ########.fr */
/* */
/* ************************************************************************** */

#include "libft.h"

void ft_print_2d_arr(char **arr)
{
int i;

i = -1;
while (arr[++i] != NULL)
ft_printf("arr[%d]: %s at add: %p \n", i, arr[i], arr[i]);
}
48 changes: 20 additions & 28 deletions src/parser/tokeniser_helpers.c → lib/libft/src/ft_strcat_const.c
Original file line number Diff line number Diff line change
@@ -1,46 +1,38 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* tokeniser_helpers.c :+: :+: :+: */
/* ft_strcat_const.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rocky <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/14 10:38:28 by rocky #+# #+# */
/* Updated: 2024/06/14 10:38:30 by rocky ### ########.fr */
/* Created: 2024/09/06 12:15:55 by rocky #+# #+# */
/* Updated: 2024/09/06 12:15:59 by rocky ### ########.fr */
/* */
/* ************************************************************************** */

#include "tokens.h"
#include "libft.h"

t_token *new_token(char *value, t_token_type type)
char *ft_strcat_const(const char *dest, const char *src)
{
t_token *token;
int i;
int j;
char *result;

token = malloc(sizeof(t_token));
if (!token)
result = malloc(sizeof(char) * (ft_strlen(dest) + ft_strlen(src) + 1));
if (!result)
return (NULL);
token->data = ft_strdup(value);
if (!token->data)
i = 0;
while (dest[i] != '\0')
{
free(token);
return (NULL);
result[i] = dest[i];
i++;
}
token->type = type;
token->next = NULL;
return (token);
}

void append_token(t_token **tokens, t_token *new_token)
{
t_token *prev;

if (!*tokens)
*tokens = new_token;
else
j = 0;
while (src[j] != '\0')
{
prev = *tokens;
while (prev->next)
prev = prev->next;
prev->next = new_token;
result[i + j] = src[j];
j++;
}
result[i + j] = '\0';
return (result);
}
Loading