-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpansions_empty_nodes_1.c
66 lines (60 loc) · 1.84 KB
/
expansions_empty_nodes_1.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
57
58
59
60
61
62
63
64
65
66
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* expansions_special_chars_0.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ngasco <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/21 16:54:43 by ngasco #+# #+# */
/* Updated: 2022/03/21 16:54:44 by ngasco ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void ft_join_spaceless_nodes(t_cdata *t_cdata)
{
while (1)
{
if (ft_found_spaceless_nodes(t_cdata) == 0)
break ;
}
}
int ft_found_spaceless_nodes(t_cdata *t_cdata)
{
struct s_qnode *curr;
curr = t_cdata->t_qdata->quotes_list;
while (1)
{
if (curr->next)
{
if (!curr->is_spaced && !ft_found_one_special_char(curr->str)
&& !ft_found_one_special_char(curr->next->str))
{
ft_join_nodes(curr);
return (1);
}
}
if (curr->next == NULL)
break ;
curr = curr->next;
}
return (0);
}
void ft_join_nodes(struct s_qnode *curr)
{
char *temp;
struct s_qnode *node_temp;
temp = ft_strdup(curr->str);
free(curr->str);
curr->str = ft_strjoin(temp, curr->next->str);
free(temp);
curr->is_spaced = curr->next->is_spaced;
curr->length = ft_strlen(curr->str);
curr->q_type = '\0';
node_temp = curr->next;
if (!curr->next->next)
curr->next = NULL;
else
curr->next = curr->next->next;
free(node_temp->str);
free(node_temp);
}