installed plugin norminette

This commit is contained in:
hugogogo
2021-06-27 14:06:36 +02:00
parent aa65191b11
commit f3c660cfd5
4 changed files with 19 additions and 27 deletions

View File

@@ -1,19 +1,18 @@
#include "push_swap.h" #include "push_swap.h"
// check more error
void is_valid(int ac, char **av) void is_valid(int ac, char **av)
{ {
if (ac < 2) if (ac < 2)
ps_stop(NULL, NULL, 1); ps_stop(NULL, NULL, 1);
(void)av; (void)av;
// check more error
} }
int check_flag(int *ac, char ***av) int check_flag(int *ac, char ***av)
{ {
if (ft_strcmp((*av)[1], "-p") != 0) if (ft_strcmp((*av)[1], "-p") != 0)
return (0); return (0);
(*av)++;; (*av)++;
(*ac)--; (*ac)--;
return (1); return (1);
} }
@@ -26,7 +25,8 @@ t_stack *init_stack(int ac, char **av)
tmp = NULL; tmp = NULL;
while (--ac) while (--ac)
{ {
if (!(start = ft_calloc(1, sizeof(t_stack)))) start = ft_calloc(1, sizeof(t_stack));
if (!start)
ps_stop(NULL, NULL, 2); ps_stop(NULL, NULL, 2);
start->n = ft_atoi(av[ac]); start->n = ft_atoi(av[ac]);
start->next = tmp; start->next = tmp;
@@ -35,14 +35,10 @@ t_stack *init_stack(int ac, char **av)
return (start); return (start);
} }
/* // the chained list "solution" is created with specials first two elements :
** the chained list "solution" is created with specials first two elements : // they are pointers to stack a and b, so it can be accessed by fill_solution()
** they are pointers to stack a and b, so it can be accessed by fill_solution()
** // bubble_sort(&a, &b, solution);
** because when an action like sa() is called it desn't get stack_b as a parameter
** so when it calls fill_solution(), this function needs an access to stack_b in
** case of flag -p, to fill the state of the stacks
*/
t_list *launch_algo(t_stack **a, t_stack **b, int flag) t_list *launch_algo(t_stack **a, t_stack **b, int flag)
{ {
t_list *solution; t_list *solution;
@@ -52,7 +48,6 @@ t_list *launch_algo(t_stack **a, t_stack **b, int flag)
if (flag) if (flag)
fill_solution(solution, "start"); fill_solution(solution, "start");
hugo_sort(a, b, solution); hugo_sort(a, b, solution);
//bubble_sort(&a, &b, solution);
return (solution); return (solution);
} }
@@ -70,5 +65,5 @@ int main(int ac, char **av)
solution = launch_algo(&a, &b, flag); solution = launch_algo(&a, &b, flag);
print_result(solution, flag); print_result(solution, flag);
ps_stop(NULL, solution, 0); ps_stop(NULL, solution, 0);
return(0); return (0);
} }

View File

@@ -1,4 +1,3 @@
#include "push_swap.h" #include "push_swap.h"
void reverse_rotate(t_stack **stack) void reverse_rotate(t_stack **stack)

View File

@@ -1,4 +1,3 @@
#include "push_swap.h" #include "push_swap.h"
void ps_usage(void) void ps_usage(void)

View File

@@ -1,4 +1,3 @@
#include "push_swap.h" #include "push_swap.h"
void swap(t_stack **stack) void swap(t_stack **stack)