-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess_initial_string.c
More file actions
58 lines (51 loc) · 2.17 KB
/
Copy pathprocess_initial_string.c
File metadata and controls
58 lines (51 loc) · 2.17 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* process_initial_string.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: pchowdry <pchowdry@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/08/12 19:09:37 by chikoh #+# #+# */
/* Updated: 2025/08/27 22:56:23 by pchowdry ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
#include "libft/libft.h"
extern int g_ret_code;
int process_initial_quotes_or_variable(t_token *cur_tok,
t_ast_node **current, t_variable_context *context)
{
if (cur_tok->type == DOUBLE_QUOTE_STRING)
cur_tok->string = process_double_quote(cur_tok->string, context);
else if (cur_tok->type == SINGLE_QUOTE_STRING)
cur_tok->string = process_single_quote(cur_tok->string);
else if (cur_tok->type == VARIABLE)
cur_tok->string = process_variable(cur_tok->string, context);
ft_lstadd_back(&((*current)->command),
ft_lstnew(ft_strdup(cur_tok->string)));
return (COMMAND_STRING);
}
int process_initial_redirection(t_token *cur_tok, t_ast_node **current)
{
ft_lstadd_back(&((*current)->command),
ft_lstnew(ft_strdup(cur_tok->string)));
return (COMMAND_REDIRECT);
}
int process_initial_spaces(t_token *cur_tok, t_ast_node **current)
{
ft_lstadd_back(&((*current)->command),
ft_lstnew(ft_strdup(cur_tok->string)));
return (COMMAND_SPACE);
}
int process_initial_else(t_token *cur_tok, t_ast_node **current)
{
ft_lstadd_back(&((*current)->command),
ft_lstnew(ft_strdup(cur_tok->string)));
return (EXIT);
}
int process_initial_assignment(t_token *cur_tok, t_ast_node **current)
{
ft_lstadd_back(&((*current)->assignment),
ft_lstnew(ft_strdup(cur_tok->string)));
return (ASSIGN_OP);
}