mirror of
https://github.com/DavidGailleton/42-Push_Swap.git
synced 2026-01-27 00:41:57 +00:00
FIX: parsing cleanup
This commit is contained in:
@@ -46,14 +46,10 @@ void complex(t_stacks *stacks)
|
||||
radix(stacks);
|
||||
}
|
||||
|
||||
void adaptive(t_stacks *stacks, char **tab)
|
||||
void adaptive(t_stacks *stacks)
|
||||
{
|
||||
int i;
|
||||
float disorder;
|
||||
|
||||
i = 0;
|
||||
while (!ft_isdigit(tab[i][0]) && tab[i])
|
||||
i++;
|
||||
disorder = stacks->disorder;
|
||||
if (disorder < 0.2)
|
||||
simple(stacks);
|
||||
@@ -61,5 +57,4 @@ void adaptive(t_stacks *stacks, char **tab)
|
||||
medium(stacks);
|
||||
else
|
||||
complex(stacks);
|
||||
return ;
|
||||
}
|
||||
|
||||
57
flags/flag.c
57
flags/flag.c
@@ -26,61 +26,14 @@ int calcul_mod(int argc, char **argv)
|
||||
return (mod);
|
||||
}
|
||||
|
||||
int pos_flag(char **argv, int mod)
|
||||
void flags(t_stacks *stacks)
|
||||
{
|
||||
if (mod == 1 || mod == 4)
|
||||
{
|
||||
if (!ft_strncmp(argv[1], "--bench", 20))
|
||||
return (1);
|
||||
}
|
||||
else if (mod == 2 || mod == 5)
|
||||
{
|
||||
if (!ft_strncmp(argv[1], "--bench", 20))
|
||||
return (1);
|
||||
else
|
||||
return (2);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int pos_bench(char **argv, int mod)
|
||||
{
|
||||
if (mod == 1 || mod == 4)
|
||||
{
|
||||
if (ft_strncmp(argv[1], "--bench", 20))
|
||||
return (1);
|
||||
}
|
||||
else if (mod == 2 || mod == 5)
|
||||
{
|
||||
if (ft_strncmp(argv[1], "--bench", 20))
|
||||
return (1);
|
||||
else
|
||||
return (2);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
void flags(int pos, int pos_b, char **argv, t_stacks *stacks)
|
||||
{
|
||||
if (ft_strncmp(argv[pos], "--simple", 30) && pos > 0)
|
||||
{
|
||||
stacks->algo = 1;
|
||||
if (stacks->algo == 1)
|
||||
simple(stacks);
|
||||
}
|
||||
else if (ft_strncmp(argv[pos], "--medium", 30) && pos > 0)
|
||||
{
|
||||
stacks->algo = 2;
|
||||
if (stacks->algo == 1)
|
||||
medium(stacks);
|
||||
}
|
||||
else if (ft_strncmp(argv[pos], "--complex", 30) && pos > 0)
|
||||
{
|
||||
stacks->algo = 3;
|
||||
if (stacks->algo == 1)
|
||||
complex(stacks);
|
||||
}
|
||||
else if (ft_strncmp(argv[pos], "--adaptive", 30) && pos > 0)
|
||||
adaptive(stacks, argv);
|
||||
else
|
||||
adaptive(stacks, argv);
|
||||
if (pos_b > 0)
|
||||
stacks->bench = 1;
|
||||
adaptive(stacks);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user