aboutsummaryrefslogtreecommitdiff
path: root/src/tokenizer.c
diff options
context:
space:
mode:
authorDominik Kaiser2025-01-20 20:14:32 +0100
committerGitHub2025-01-20 20:14:32 +0100
commitbd8c817797d5f2b1affe6957ffc51846a38e70ec (patch)
tree2fc0f567b1c4f2f168a931ad0bff69e52c6c226c /src/tokenizer.c
parenta9aba07b52cbf98eb9c52cd8ee0cd5f5021d2931 (diff)
parentdc6a4f2d0de92984c2584ef905011e2a60792850 (diff)
downloadminishell-bd8c817797d5f2b1affe6957ffc51846a38e70ec.tar.gz
minishell-bd8c817797d5f2b1affe6957ffc51846a38e70ec.zip
Merge interpreter changes into main
Miau
Diffstat (limited to 'src/tokenizer.c')
-rw-r--r--src/tokenizer.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/tokenizer.c b/src/tokenizer.c
index d7a96f7..e202de6 100644
--- a/src/tokenizer.c
+++ b/src/tokenizer.c
@@ -13,6 +13,26 @@
#include "minishell.h"
#include "token.h"
+t_token *reverse_token_list(t_token *head)
+{
+ t_token *prev;
+ t_token *current;
+ t_token *next;
+
+ prev = NULL;
+ current = head;
+ next = NULL;
+ while (current != NULL)
+ {
+ next = current->previous;
+ current->next = prev;
+ current->previous = next;
+ prev = current;
+ current = next;
+ }
+ return (prev);
+}
+
void print_token(t_token *token)
{
if (DEBUG)
@@ -77,11 +97,11 @@ void handle_special_chars(char *s, int *i, int *start, t_token **token_list)
*token_list = new_token(PIPE_TOKEN, *token_list, NULL);
else if (s[*i] == '\n')
*token_list = new_token(NEWLINE_TOKEN, *token_list, NULL);
- print_token(*token_list);
if (s[*i] == '<' && s[*i + 1] == '<')
(*i)++;
if (s[*i] == '>' && s[*i + 1] == '>')
(*i)++;
+ print_token(*token_list);
*start = *i + 1;
}
@@ -111,6 +131,5 @@ void tokenizer(char *s, t_token **token_list, char quote_check)
pos = i + 1;
}
}
- while ((*token_list)->previous)
- *token_list = (*token_list)->previous;
+ *token_list = reverse_token_list(*token_list);
}