From f3c660cfd538128b06abc1f3b6869b14c3be8de1 Mon Sep 17 00:00:00 2001 From: hugogogo Date: Sun, 27 Jun 2021 14:06:36 +0200 Subject: [PATCH] installed plugin norminette --- srcs/push_swap.c | 27 +++++++++++---------------- srcs/reverse_rotate.c | 9 ++++----- srcs/stop.c | 3 +-- srcs/swap.c | 7 +++---- 4 files changed, 19 insertions(+), 27 deletions(-) diff --git a/srcs/push_swap.c b/srcs/push_swap.c index 3e104cd..63051e9 100644 --- a/srcs/push_swap.c +++ b/srcs/push_swap.c @@ -1,19 +1,18 @@ - #include "push_swap.h" +// check more error void is_valid(int ac, char **av) { if (ac < 2) ps_stop(NULL, NULL, 1); (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) return (0); - (*av)++;; + (*av)++; (*ac)--; return (1); } @@ -26,7 +25,8 @@ t_stack *init_stack(int ac, char **av) tmp = NULL; while (--ac) { - if (!(start = ft_calloc(1, sizeof(t_stack)))) + start = ft_calloc(1, sizeof(t_stack)); + if (!start) ps_stop(NULL, NULL, 2); start->n = ft_atoi(av[ac]); start->next = tmp; @@ -35,14 +35,10 @@ t_stack *init_stack(int ac, char **av) return (start); } -/* -** 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() -** -** 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 -*/ +// 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() + +// bubble_sort(&a, &b, solution); t_list *launch_algo(t_stack **a, t_stack **b, int flag) { t_list *solution; @@ -52,11 +48,10 @@ t_list *launch_algo(t_stack **a, t_stack **b, int flag) if (flag) fill_solution(solution, "start"); hugo_sort(a, b, solution); - //bubble_sort(&a, &b, solution); return (solution); } -int main(int ac, char **av) +int main(int ac, char **av) { t_stack *a; t_stack *b; @@ -70,5 +65,5 @@ int main(int ac, char **av) solution = launch_algo(&a, &b, flag); print_result(solution, flag); ps_stop(NULL, solution, 0); - return(0); + return (0); } diff --git a/srcs/reverse_rotate.c b/srcs/reverse_rotate.c index 6d1c73a..57a61bb 100644 --- a/srcs/reverse_rotate.c +++ b/srcs/reverse_rotate.c @@ -1,7 +1,6 @@ - #include "push_swap.h" -void reverse_rotate(t_stack **stack) +void reverse_rotate(t_stack **stack) { t_stack *tmp; t_stack *before; @@ -19,21 +18,21 @@ void reverse_rotate(t_stack **stack) before->next = NULL; } -t_list *rra(t_stack **a, t_list **lst) +t_list *rra(t_stack **a, t_list **lst) { reverse_rotate(a); fill_solution(*lst, "rra"); return (NULL); } -t_list *rrb(t_stack **b, t_list **lst) +t_list *rrb(t_stack **b, t_list **lst) { reverse_rotate(b); fill_solution(*lst, "rrb"); return (NULL); } -t_list *rrr(t_stack **a, t_stack **b, t_list **lst) +t_list *rrr(t_stack **a, t_stack **b, t_list **lst) { reverse_rotate(a); reverse_rotate(b); diff --git a/srcs/stop.c b/srcs/stop.c index cdde4e8..e8dafe2 100644 --- a/srcs/stop.c +++ b/srcs/stop.c @@ -1,4 +1,3 @@ - #include "push_swap.h" void ps_usage(void) @@ -12,7 +11,7 @@ void ps_error(int err) if (err == 1) ps_usage(); if (err == 2) - ft_printf("error\n"); + ft_printf("error\n"); exit(0); } diff --git a/srcs/swap.c b/srcs/swap.c index d2c7afe..9fd4048 100644 --- a/srcs/swap.c +++ b/srcs/swap.c @@ -1,4 +1,3 @@ - #include "push_swap.h" void swap(t_stack **stack) @@ -13,21 +12,21 @@ void swap(t_stack **stack) (*stack)->next = tmp; } -t_list *sa(t_stack **a, t_list **solution) +t_list *sa(t_stack **a, t_list **solution) { swap(a); fill_solution(*solution, "sa"); return (NULL); } -t_list *sb(t_stack **b, t_list **solution) +t_list *sb(t_stack **b, t_list **solution) { swap(b); fill_solution(*solution, "sb"); return (NULL); } -t_list *ss(t_stack **a, t_stack **b, t_list **solution) +t_list *ss(t_stack **a, t_stack **b, t_list **solution) { swap(a); swap(b);