-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew_utils.c
More file actions
54 lines (49 loc) · 1.41 KB
/
new_utils.c
File metadata and controls
54 lines (49 loc) · 1.41 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* new_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hyeyeom <hyeyeom@42student.gyeongsan.kr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/12 23:40:21 by yuhyoon #+# #+# */
/* Updated: 2025/04/14 00:38:35 by hyeyeom ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int pipex_get_size(char *s, int len)
{
int i;
int cnt;
i = 0;
cnt = 0;
while (i < len)
{
if (s[i] != '\0')
{
cnt++;
while (i < len && s[i] != '\0')
i++;
}
if (i >= len)
break ;
i++;
}
return (cnt);
}
char **pipex_splited(char *s_dup, int w, char **abs)
{
int cnt;
int index_jump;
cnt = 0;
while (cnt < w)
{
while (*s_dup == '\0')
s_dup++;
abs[cnt] = ft_strdup(s_dup);
index_jump = ft_strlen(abs[cnt]);
s_dup = s_dup + index_jump;
cnt++;
}
abs[cnt] = NULL;
return (abs);
}