-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpansions_tokens.c
56 lines (51 loc) · 1.78 KB
/
expansions_tokens.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* tokens.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ngasco <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/21 16:01:13 by ngasco #+# #+# */
/* Updated: 2022/03/21 16:01:15 by ngasco ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void ft_create_tokens_list(t_cdata *t_cdata)
{
struct s_qnode *curr;
curr = t_cdata->t_qdata->quotes_list;
while (1)
{
ft_add_token_to_list(t_cdata, curr);
if (curr->next == NULL)
break ;
curr = curr->next;
}
}
void ft_add_token_to_list(t_cdata *t_cdata, struct s_qnode *origin)
{
struct s_tnode *new_node;
struct s_tnode *curr;
curr = t_cdata->tokens_list;
new_node = (struct s_tnode *)malloc(sizeof(struct s_tnode));
memset(new_node, 0, sizeof(struct s_tnode));
if (new_node == NULL)
exit(1);
new_node->str = ft_strdup(origin->str);
new_node->len = ft_strlen(origin->str);
new_node->q_type = origin->q_type;
new_node->is_spaced = origin->is_spaced;
new_node->next = NULL;
while (curr && curr->next != NULL)
curr = curr->next;
if (curr)
{
new_node->prev = curr;
curr->next = new_node;
}
else
{
new_node->prev = NULL;
t_cdata->tokens_list = new_node;
}
}