Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
yabtaour
GitHub Repository: yabtaour/Minishell-42
Path: blob/main/lexer/ft_add_and.c
1407 views
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* ft_add_and.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: yabtaour <[email protected]> +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2022/07/26 18:16:33 by yabtaour #+# #+# */
9
/* Updated: 2022/07/26 18:16:34 by yabtaour ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
13
#include "../minishell.h"
14
15
int ft_add_and(t_data *data, int i)
16
{
17
int origin;
18
int len;
19
char *command;
20
21
origin = i;
22
len = 0;
23
command = NULL;
24
while (data->cmd[i] && data->cmd[i] == '&')
25
{
26
i++;
27
len++;
28
}
29
command = ft_substr(data->cmd, origin, len);
30
data->lst_lexer = ft_add_lexer_back(data->lst_lexer, command, AND);
31
free(command);
32
return (i);
33
}
34
35