🔨」 fix: Fixed merge conflict on main

This commit is contained in:
2024-06-29 15:35:28 +02:00
parent 5e68b7342d
commit 26b8603933
7 changed files with 83 additions and 39 deletions

View File

@ -6,52 +6,75 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/05 13:48:57 by adjoly #+# #+# */
/* Updated: 2024/06/10 16:29:12 by adjoly ### ########.fr */
/* Updated: 2024/06/29 15:29:48 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include "parsing.h"
#include <stdio.h>
/*char *end_of_arg(char *readline)
size_t __get_len_arg(char *s)
{
char *tmp;
tmp = readline;
while (*tmp)
{
if (*tmp == 32 && is_inquote(readline, tmp - readline))
break ;
if (*s == SINGLE || *s == DOUBLE)
return (search_for_next_quote((s + 1), __is_quote(*s)) - s + 1);
tmp = s;
while (*tmp && *tmp != ' ')
tmp++;
}
return (tmp);
return (tmp - s);
}
size_t count_args(char *readline)
size_t __cpy_arg(char *dst, char *src)
{
size_t sizeof_arg;
sizeof_arg = __get_len_arg(src);
ft_strlcpy(dst, src, sizeof_arg + 1);
return (sizeof_arg);
}
size_t __count_args(char *s)
{
size_t i;
char *tmp;
tmp = readline;
tmp = s;
i = 0;
while (*tmp)
{
tmp++;
if (*tmp == ' ')
tmp++;
else
{
tmp += __get_len_arg(tmp);
i++;
}
}
return (i);
}
char **split_argv(char *readline)
{
char *tmp;
char **argv;
char **tmp_av;
char *tmp;
tmp = readline;
ft_putnbr_fd(count_args(readline), STDOUT_FILENO);
argv = ft_calloc(count_args(readline), sizof(char *));
argv = ft_calloc(__count_args(readline) + 1, sizeof(char *));
tmp_av = argv;
while (*tmp)
{
tmp++;
if (*tmp == ' ')
tmp++;
else
{
*tmp_av = ft_calloc(__get_len_arg(tmp), sizeof(char));
tmp += __cpy_arg(*tmp_av, tmp);
tmp_av++;
}
}
*tmp_av = NULL;
return (argv);
}
*/