-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcounters.c
More file actions
57 lines (50 loc) · 1.42 KB
/
counters.c
File metadata and controls
57 lines (50 loc) · 1.42 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* counters.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ferenc <ferenc@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/17 07:46:05 by elavrich #+# #+# */
/* Updated: 2025/07/16 20:59:09 by ferenc ### ########.fr */
/* */
/* ************************************************************************** */
#include "Minishell.h"
int size_args(t_token *tokens)
{
t_token *tmp;
int count;
count = 0;
if (tokens == NULL)
return (0);
tmp = tokens;
while (tmp)
{
if (tmp->com && tmp->com[0] != '\0')
count++;
tmp = tmp->next;
}
return (count);
}
int size_cmd_arg(char **cmd)
{
int i;
i = 0;
while (cmd[i])
i++;
return (i);
}
int count_args(t_token *tokens)
{
int count;
count = 0;
while (tokens)
{
if (!is_redir(tokens->com))
count++;
else if (tokens->next)
tokens = tokens->next;
tokens = tokens->next;
}
return (count);
}