-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparse_red_utils.c
42 lines (38 loc) · 1.72 KB
/
parse_red_utils.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parse_red_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ggiannit <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/15 17:54:56 by ggiannit #+# #+# */
/* Updated: 2023/04/15 17:54:58 by ggiannit ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void ft_parse_red_else_1(char *line, char **newline, t_prs *prs)
{
while (line[prs->i + prs->n] && line[prs->i + prs->n] != SQUT
&& line[prs->i + prs->n] != DQUT && line[prs->i + prs->n] != '$')
prs->n += 1;
*newline = ft_linejoin(*newline, &line[prs->i], prs->n);
prs->i += prs->n;
prs->n = 0;
}
void ft_parse_red_else_2(char *line, t_mish *meta,
char **newline, t_prs *prs)
{
(prs->i)++;
prs->value = ft_env_value(&line[prs->i], meta->env, meta, 0);
*newline = ft_linejoin(*newline, prs->value, ft_strlen(prs->value));
while (line[prs->i] && ft_isenv(line[prs->i]))
(prs->i)++;
}
void ft_parse_red_else_3(char *line, char **newline, t_prs *prs)
{
(prs->i)++;
while (line[prs->i + prs->n] && line[prs->i + prs->n] != SQUT)
prs->n += 1;
*newline = ft_linejoin(*newline, &line[prs->i], prs->n);
prs->i += (prs->n + 1);
}