-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_tkn_count.c
30 lines (27 loc) · 1.2 KB
/
ft_tkn_count.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_tkn_count.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abenamar <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/11 00:56:23 by abenamar #+# #+# */
/* Updated: 2023/09/13 03:13:52 by abenamar ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
size_t ft_tkn_count(t_list *lst, char *str, uint8_t all)
{
const size_t n = ft_strlen(str) + 1;
size_t count;
count = 0;
while (lst)
{
if (lst->content && !ft_strncmp(lst->content, str, n))
++count;
if (!all && !ft_strncmp(lst->content, "|", 2))
break ;
lst = lst->next;
}
return (count);
}