Skip to content

Commit

Permalink
I think all works, fixing leaks for quote issues
Browse files Browse the repository at this point in the history
  • Loading branch information
romanmikh committed Sep 26, 2024
1 parent dff13ce commit 379ae84
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 6 deletions.
3 changes: 1 addition & 2 deletions inc/tokens.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ void execute_command(char **parsed_text, t_token **tokens);
void print_maxishell(void);
int input_error_checks(t_loop_data *loop_data);
t_token *tokenise(char *str);
void print_tokens(t_token *tokens);
void print_tokens(t_token *tokens, char *name);
t_ast *parse_tokens(t_token **tokens, t_ms_data *data);
void print_tokens(t_token *tokens);
void visualize_ast(t_ast *root);
void free_ast(t_ast *node);
void free_all_tokens(t_token *tokens);
Expand Down
Binary file added minishell
Binary file not shown.
8 changes: 5 additions & 3 deletions src/check_tokenise/tokeniser_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,22 @@

#include "tokens.h"

void print_tokens(t_token *tokens);
void print_tokens(t_token *tokens, char *name);
void print_ast_args(t_ast *node);
void append_word_if_valid(char *start, char *str, t_token **tokens);

void print_tokens(t_token *tokens)
void print_tokens(t_token *tokens, char *name)
{
t_token *token;
int i;

i = 0;
token = tokens;
if (ft_strlen(name) > 0)
ft_printf(GRN"----- %s[] -----\n"RESET, name);
while (token != NULL)
{
ft_printf("input[%d] -> %s at add: %p\n", \
ft_printf(GRN"input[%d] -> %s at add: %p\n"RESET, \
i, token->data, &token->data);
token = token->next;
i++;
Expand Down
1 change: 1 addition & 0 deletions src/parser/AST_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ t_ast *manage_commands(t_token **tokens, t_ms_data *data)
return (NULL);
set_command_args(command_node, tokens, cmd_arg_count);
post_process_command_args(command_node, cmd_arg_count, data);
// ft_print_2d_arr(command_node->args, "manage_commands, after ppca");
return (command_node);
}

Expand Down
11 changes: 10 additions & 1 deletion src/parser/loc_env_var_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,20 @@ void post_process_command_args(t_ast *command_node, int arg_count, \
processed_arg = ft_substr(command_node->args[i], 1, \
ft_strlen(command_node->args[i]) - 2);
free(command_node->args[i]);
ft_printf("processed_arg: %s\n", processed_arg);
processed_arg = ft_remove_quotes(processed_arg, '\"');
ft_printf("processed_arg: %s\n", processed_arg);
split_loc_vars(command_node, processed_arg, &current_size, &i);
free(processed_arg);
}
command_node->args[current_size] = NULL;
final_quote_removal(current_size, command_node);
for (i=0; i < current_size; i++)
{
command_node->args[i] = ft_remove_quotes(command_node->args[i], '\"');
}

//final_quote_removal(current_size, command_node);
ft_print_2d_arr(command_node->args, "ppca after final-quote_removal");
}

char *append_expanded_var(char *processed_arg, char *tmp_ad, \
Expand Down
1 change: 1 addition & 0 deletions src/parser/loc_env_var_handler_utils_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ void final_quote_removal(int arg_count, t_ast *command_node)
char *trimmed_arg;

i = 0;
ft_print_2d_arr(command_node->args, "final-quote_removal");
while (i < arg_count)
{
arg = command_node->args[i];
Expand Down
Empty file added tokens);
Empty file.

0 comments on commit 379ae84

Please sign in to comment.