Compare commits

..

No commits in common. "882a39fc94c714bb2815ce9b22fb71ace975026a" and "058c96849b25c27ab4f11f08f011cf5a3f974605" have entirely different histories.

View File

@ -6,7 +6,7 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/11 14:50:26 by erey-bet #+# #+# */
/* Updated: 2023/04/14 15:53:49 by erey-bet ### ########.fr */
/* Updated: 2023/04/14 14:14:25 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
@ -30,38 +30,30 @@ int get_strs(const char *to_split, const char *charset, char ***strs, int *i)
int j;
int x;
int y;
int check;
x = -1;
j = 0;
while (to_split[++x])
{
y = -1;
check = 1;
while (charset[++y])
{
if (to_split[x] == charset[y] && !ft_is_in_quote(to_split, x))
{
check = 0;
if (new_strs(strs, to_split, i, &j))
return (1);
y = 0;
if (to_split[x + 1])
{
x++;
if (new_strs(strs, to_split, i, &j))
return (1);
}
}
}
if (check)
(*strs)[(*i)][j++] = to_split[x];
(*strs)[(*i)][j++] = to_split[x];
}
return (0);
}
void free_set_null(char ***strs, int i)
{
if (ft_strlen((*strs)[i]) == 0)
{
free((*strs)[i]);
(*strs)[i] = NULL;
}
}
char **ft_split_charset_quoted(const char *to_split, const char *charset)
{
char **strs;
@ -85,6 +77,18 @@ char **ft_split_charset_quoted(const char *to_split, const char *charset)
free(strs);
return (NULL);
}
free_set_null(&strs, i);
return (strs);
}
/*#include <stdio.h>
int main(int argc, char **argv)
{
char **strs;
if (argc == 3)
strs = ft_split_charset_quoted(argv[1], argv[2]);
int i = -1;
while (strs[++i])
printf("%s\n", strs[i]);
return (0);
}*/