forked from MaroIsLife/Minishell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse_three.c
56 lines (51 loc) · 901 Bytes
/
parse_three.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
#include "minishell.h"
int find_space(t_source *src, int i)
{
int c;
c = 0;
while (src->redsplit[i][c] == ' ' && src->redsplit[i][c] != '\0')
c++;
while (src->redsplit[i][c] != ' ' && src->redsplit[i][c] != '\0')
c++;
return (c);
}
void init_arg(t_node *head, char **arg, int tmp2)
{
int b;
int i;
char c;
i = 0;
b = 0;
if (tmp2 == 1)
c = 0;
else
c = 127;
while (arg[i] != NULL)
{
if (arg[i++][0] != c)
b++;
}
head->arg = malloc((b + 1) * sizeof(char *));
i = 0;
b = 0;
while (arg[i] != NULL)
{
if (arg[i][0] != c)
head->arg[b++] = ft_strdup(arg[i]);
i++;
}
head->arg[b] = NULL;
}
int parse_check(t_node *head, t_source *src)
{
free(src->ra);
if (head->cmd[0] == 0 && src->tmp2 == 1)
src->dollarused = 1;
if (src->aslash == 1 || src->dquotes == 1 || src->squotes == 1)
{
src->dollarused = 1;
head->arg = NULL;
return (1);
}
return (0);
}