-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpansions_special_chars_2.c
56 lines (51 loc) · 2.02 KB
/
expansions_special_chars_2.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* expansions_special_chars_1.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ngasco <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/29 11:36:09 by ngasco #+# #+# */
/* Updated: 2022/03/29 11:36:11 by ngasco ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
/* Adding new nodes with the single parts of the split string with s char */
void ft_add_special_char_nodes(struct s_qnode *curr,
char *curr_str, char *next_str, char *rest)
{
struct s_qnode *new_node1;
new_node1 = (struct s_qnode *)malloc(sizeof(struct s_qnode));
memset(new_node1, 0, sizeof(struct s_qnode));
free(curr->str);
curr->str = curr_str;
curr->length = ft_strlen(curr_str);
new_node1->str = next_str;
new_node1->length = ft_strlen(new_node1->str);
if (*rest)
{
ft_populate_new_node_2(new_node1, curr, rest);
curr->is_spaced = 0;
new_node1->is_spaced = 0;
}
else
{
new_node1->next = curr->next;
new_node1->is_spaced = curr->is_spaced;
curr->is_spaced = 0;
free(rest);
}
curr->next = new_node1;
}
void ft_populate_new_node_2(struct s_qnode *new_node1,
struct s_qnode *curr, char *rest)
{
struct s_qnode *new_node2;
new_node2 = (struct s_qnode *)malloc(sizeof(struct s_qnode));
memset(new_node2, 0, sizeof(struct s_qnode));
new_node2->str = rest;
new_node2->length = ft_strlen(new_node2->str);
new_node2->next = curr->next;
new_node2->is_spaced = curr->is_spaced;
new_node1->next = new_node2;
}