-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstr_checkers.c
61 lines (56 loc) · 1.44 KB
/
str_checkers.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
60
61
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_checkers.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sguilher <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/25 13:28:39 by lalex-ku #+# #+# */
/* Updated: 2022/06/14 16:58:00 by sguilher ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int is_empty(char *str)
{
if (!str)
return (1);
while (*str)
{
if (*str != ' ')
return (0);
str++;
}
return (1);
}
int is_quote(char c)
{
return (c == '\'' || c == '"');
}
int has_pipe(char *str)
{
while (*str)
{
if (*str == '\'')
{
str++;
while (*str != '\'')
str++;
}
if (*str == '"')
{
str++;
while (*str != '"')
str++;
}
if (*str == '|')
return (1);
str++;
}
return (0);
}
int is_name_delimeter(char c)
{
if (c == ' ' || c == '>' || c == '<' || c == '|' || c == '\t')
return (1);
return (0);
}