-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_utils7.c
76 lines (68 loc) · 1.01 KB
/
ft_utils7.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
#include "minishell.h"
int search_space(t_struct *d)
{
int i;
i = 2;
while (d->l.line2[i])
{
if (d->l.line2[i] != ' ')
return (1);
i++;
}
return (0);
}
int search_space_cd(t_struct *d)
{
int i;
i = 2;
while (d->l.chetab_cd[0][i])
{
if (d->l.chetab_cd[0][i] != ' ')
return (1);
i++;
}
return (0);
}
char *ft_strcat_malloc(char *dest, char *src)
{
int i;
int j;
int len;
int len2;
char *res;
len = ft_strlen(dest);
len2 = ft_strlen(src);
res = malloc(len + len2 + 1);
i = 0;
j = 0;
while (dest[i])
{
res[i] = dest[i];
i++;
}
while (src[j])
{
res[i] = src[j];
i++;
j++;
}
res[i] = '\0';
return (res);
}
void del_space_end_che(t_struct *d)
{
int i;
char *str;
i = 0;
while (d->l.chetab[i])
{
str = malloc(sizeof (char) * (ft_len_wspa_end(d->l.chetab[i]) + 1));
ft_strcpy_wspa_end(d->l.chetab[i], str);
free(d->l.chetab[i]);
d->l.chetab[i] = malloc(sizeof (char) * ft_strlen(str) + 1);
ft_strcpy(d->l.chetab[i], str);
free(str);
str = NULL;
i++;
}
}