-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_utils21.c
83 lines (74 loc) · 1.08 KB
/
ft_utils21.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
#include "minishell.h"
int is_char(char *str)
{
int i;
i = 0;
while (str[i])
{
if ((str[i] >= 'a' && str[i] <= 'z')
|| (str[i] >= 'A' && str[i] <= 'Z'))
return (1);
i++;
}
return (0);
}
int is_char_c(char c)
{
if ((c >= 'a' && c <= 'z')
|| (c >= 'A' && c <= 'Z'))
return (1);
return (0);
}
int check_char(char *str)
{
int i;
i = 0;
while (str[i])
{
if (i == 0 && str[i] == '-')
i++;
if ((str[i] < 'a' || str[i] > 'z')
&& (str[i] < 'A' || str[i] > 'Z')
&& (str[i] < '0' || str[i] > '9'))
return (1);
i++;
}
return (0);
}
void mal_cpy_echo(t_struct *d)
{
int j;
int tmp;
int mal;
j = find_str_echo(d);
tmp = j;
mal = 0;
while (d->l.line[j])
{
j++;
mal++;
}
j = 0;
d->l.echo = malloc(sizeof (char) * (mal + 1));
while (d->l.line[tmp])
{
d->l.echo[j] = d->l.line[tmp];
tmp++;
j++;
}
d->l.echo[j] = '\0';
}
int find_str_echo(t_struct *d)
{
int j;
int tiret;
int count;
j = 0;
count = 0;
tiret = count_arg(d->l.line);
while (d->l.line[j] && d->l.line[j] != ' ')
j++;
j++;
j = find_str_echo_1(d, j, tiret);
return (j);
}