-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.c
59 lines (54 loc) · 1.57 KB
/
parser.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parser.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aouhadou <aouhadou@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/25 13:55:23 by aouhadou #+# #+# */
/* Updated: 2022/07/03 21:28:04 by aouhadou ### ########.fr */
/* */
/* ************************************************************************** */
#include "../../includes/minishell.h"
int ft_strcmp1(char *s1, char *s2)
{
int i;
int j;
i = 0;
j = 0;
while (s1[i] != '\0' || s2[j] != '\0')
{
if (s1[i] > s2[j])
return (s1[i] - s2[j]);
else if (s1[i] < s2[j])
return ((s1[i] - s2[j]));
i++;
j++;
}
return (0);
}
t_command *creat_cmds(t_token *node)
{
t_command *cmds;
t_command *ptr;
int lst_size;
int start;
lst_size = lstsize(node);
start = 0;
cmds = NULL;
while (start < lst_size)
{
add_cmd_to_end(&cmds, remplir_tab(node, start));
start += count_size(node, start) + 1;
}
list_clear(&node);
ptr = cmds;
while (ptr)
{
ptr->infile = 0;
ptr->outfile = 1;
ptr->herdoc = 0;
ptr = ptr->next;
}
return (cmds);
}