-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse_step-1_utils.c
More file actions
executable file
·62 lines (55 loc) · 1.54 KB
/
parse_step-1_utils.c
File metadata and controls
executable file
·62 lines (55 loc) · 1.54 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
59
60
61
62
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parse_step-1_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hyeyeom <hyeyeom@42student.gyeongsan.kr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/23 17:18:37 by yuhyoon #+# #+# */
/* Updated: 2025/04/14 00:38:35 by hyeyeom ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int ft_strlen_delim(char *s, char delim)
{
int i;
i = 0;
while (s[i] != delim)
{
i++;
}
return (i);
}
void init_char_state(t_char_state *state, char *s)
{
state->current = s;
state->quote = 0;
state->quote_seq = -1;
}
int is_whitespace(char c)
{
if ((c >= '\t' && c <= '\r') || c == ' ' )
return (1);
return (0);
}
int is_quote(char c)
{
if (c == '\'')
return ('\'');
else if (c == '\"')
return ('\"');
return (0);
}
int ft_ismeta(char *input)
{
if (*input == '<')
return (IN_RD);
else if (*input == '>')
return (OUT_RD);
else if (*input == '$')
return (DOLLAR);
else if (*input == '|')
return (PIPE);
else
return (0);
}