-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove_red.c
More file actions
47 lines (43 loc) · 1.34 KB
/
remove_red.c
File metadata and controls
47 lines (43 loc) · 1.34 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* remove_red.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mamoussa <mamoussa@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/26 11:33:43 by mamoussa #+# #+# */
/* Updated: 2020/12/10 18:01:30 by mamoussa ### ########.fr */
/* */
/* ************************************************************************** */
#include "shell.h"
t_cmd *remove_red(t_cmd *ptr)
{
t_cmd *tmp;
if (ptr)
{
tmp = ptr->next;
ptr->next = NULL;
ptr = tmp;
}
while (ptr && (ptr->type != semicolumn) && (ptr->type != pipee))
{
tmp = ptr->next;
simple_pointer_free(ptr->string);
free(ptr);
ptr = NULL;
ptr = tmp;
}
return (ptr);
}
void add_back_cmd(t_cmd *head, t_cmd *new_node)
{
while (head)
{
if (!(head->next))
{
head->next = new_node;
break ;
}
head = head->next;
}
}