-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_utils10.c
104 lines (95 loc) · 1.5 KB
/
ft_utils10.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "minishell.h"
char *del_plus_egal(char *str)
{
char *res;
int i;
int k;
int j;
i = 0;
k = 0;
j = 0;
res = malloc(ft_strlen(str));
while (str[k] && str[k] != '+')
k++;
while (str[i])
{
if (i != k)
res[j++] = str[i];
i++;
}
res[j] = '\0';
return (res);
}
void del_cell(t_list *l, int index)
{
int i;
t_elem *courant;
courant = l->first;
i = 0;
while (i < index)
{
courant = courant->next;
i++;
}
if (courant->next == NULL)
courant->prec->next = NULL;
else if (courant->prec == NULL)
courant->next->prec = NULL;
else
{
courant->next->prec = courant->prec;
courant->prec->next = courant->next;
}
free_str(courant->data);
free(courant);
}
void del_cell_nofree(t_list *l, int index)
{
int i;
t_elem *courant;
courant = l->first;
i = 0;
while (i < index)
{
courant = courant->next;
i++;
}
if (courant->next == NULL)
courant->prec->next = NULL;
else if (courant->prec == NULL)
courant->next->prec = NULL;
else
{
courant->next->prec = courant->prec;
courant->prec->next = courant->next;
}
free(courant);
}
int ft_strlen_twochar(char **str)
{
int i;
i = 0;
while (str[i])
i++;
return (i);
}
void init_struct(t_struct *d)
{
d->env = NULL;
d->my_envp = NULL;
d->str = NULL;
d->cd = NULL;
d->line = NULL;
d->l.arg_chev = NULL;
d->l.tmp = NULL;
d->l.chevrons = NULL;
d->l.line = NULL;
d->l.line2 = NULL;
d->l.cmd = NULL;
d->l.echo = NULL;
d->l.str1 = NULL;
g_global.g_build_error_exec = 0;
d->l.pos = 0;
d->l.fd = 0;
d->l.fd2 = 0;
}