mirror of
https://github.com/DavidGailleton/42-Push_Swap.git
synced 2026-01-27 00:41:57 +00:00
fix conflict
This commit is contained in:
63
parsing/checker.c
Normal file
63
parsing/checker.c
Normal file
@@ -0,0 +1,63 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* checker.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/01/08 12:37:12 by dgaillet #+# #+# */
|
||||
/* Updated: 2026/01/08 13:17:36 by dgaillet ### ########lyon.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "push_swap.h"
|
||||
|
||||
static int check_digits(char *str)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (str[i])
|
||||
{
|
||||
if (!ft_isdigit(str[i]) && str[i] != ' ')
|
||||
return (0);
|
||||
i++;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int check_flags(char *str)
|
||||
{
|
||||
if (!ft_strncmp("--simple", str, ft_strlen(str)))
|
||||
return (1);
|
||||
else if (!ft_strncmp("--medium", str, ft_strlen(str)))
|
||||
return (1);
|
||||
else if (!ft_strncmp("--complex", str, ft_strlen(str)))
|
||||
return (1);
|
||||
else if (!ft_strncmp("--adaptative", str, ft_strlen(str)))
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int checker(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int methods_flag;
|
||||
int bench;
|
||||
|
||||
bench = 0;
|
||||
methods_flag = 0;
|
||||
i = 0;
|
||||
while (++i < argc)
|
||||
{
|
||||
if (check_flags(argv[1]) && !methods_flag)
|
||||
methods_flag = 1;
|
||||
else if (!ft_strncmp("--bench", argv[1], ft_strlen(argv[1])) && !bench)
|
||||
bench = 1;
|
||||
else if (check_digits(argv[1]))
|
||||
continue ;
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
@@ -21,3 +21,13 @@ size_t ft_strlen(const char *s)
|
||||
i++;
|
||||
return (i);
|
||||
}
|
||||
|
||||
int len_split(char **tab)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (tab[i])
|
||||
i++;
|
||||
return (i);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: mteriier <mteriier@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/12/08 16:21:05 by mteriier #+# #+# */
|
||||
/* Updated: 2025/12/09 10:19:17 by mteriier ### ########lyon.fr */
|
||||
/* Updated: 2026/01/08 14:01:23 by dgaillet ### ########lyon.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -25,16 +25,6 @@ static int wich_mod(int mod)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int len_split(char **tab)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (tab[i])
|
||||
i++;
|
||||
return (i);
|
||||
}
|
||||
|
||||
static t_stack *parsing(int argc, char **argv, int mod)
|
||||
{
|
||||
int i;
|
||||
@@ -78,16 +68,35 @@ static t_stack *special_parsing(char **argv, int mod)
|
||||
return (a);
|
||||
}
|
||||
|
||||
static void set_t_stacks(t_stacks *stacks)
|
||||
{
|
||||
stacks->a = NULL;
|
||||
stacks->b = NULL;
|
||||
stacks->algo = 0;
|
||||
stacks->bench = 0;
|
||||
stacks->disorder = 0;
|
||||
stacks->sa = 0;
|
||||
stacks->sb = 0;
|
||||
stacks->ss = 0;
|
||||
stacks->pa = 0;
|
||||
stacks->pb = 0;
|
||||
stacks->ra = 0;
|
||||
stacks->rb = 0;
|
||||
stacks->rr = 0;
|
||||
stacks->rra = 0;
|
||||
stacks->rrb = 0;
|
||||
stacks->rrr = 0;
|
||||
}
|
||||
|
||||
t_stacks *init_piles(int argc, char **argv, int mod)
|
||||
{
|
||||
t_stacks *stacks;
|
||||
t_stack *a;
|
||||
|
||||
stacks = malloc(sizeof(t_stacks));
|
||||
stacks->a = NULL;
|
||||
stacks->b = NULL;
|
||||
if (!stacks)
|
||||
return (NULL);
|
||||
set_t_stacks(stacks);
|
||||
if (mod == 0 || mod == 1 || mod == 2)
|
||||
a = parsing(argc, argv, mod);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user