rra fonctionne
This commit is contained in:
4
Makefile
4
Makefile
@@ -55,6 +55,10 @@ $(ODIR):
|
||||
$(ODIR)/%.o: %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
libft:
|
||||
make re -C $(LDIR)
|
||||
make $(NAME)
|
||||
|
||||
clean:
|
||||
/bin/rm -f $(OBJS)
|
||||
|
||||
|
||||
BIN
builds/algo.o
BIN
builds/algo.o
Binary file not shown.
BIN
builds/print.o
BIN
builds/print.o
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
builds/rotate.o
BIN
builds/rotate.o
Binary file not shown.
BIN
builds/stop.o
BIN
builds/stop.o
Binary file not shown.
@@ -30,7 +30,7 @@ t_list *launch_algo(t_stack *stack);
|
||||
*/
|
||||
void ps_usage(void);
|
||||
void ps_error(int i);
|
||||
void ps_stop(t_stack *a, t_stack *b, t_list *lst, int i);
|
||||
void ps_stop(t_stack *stack, t_list *lst, int i);
|
||||
|
||||
/*
|
||||
** algo.c
|
||||
|
||||
@@ -13,5 +13,6 @@ void hugo_sort(t_stack **a, t_stack **b, t_list *solution)
|
||||
sa(a, &solution);
|
||||
sb(b, &solution);
|
||||
sa(a, &solution);
|
||||
rra(a, &solution);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,5 +62,6 @@ void print_result(t_list *result, int flag)
|
||||
ft_printf(" %s\n", part[2]);
|
||||
}
|
||||
result = result->next;
|
||||
free(part);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
void is_valid(int ac, char **av)
|
||||
{
|
||||
if (ac < 2)
|
||||
ps_stop(NULL, NULL, NULL, 1);
|
||||
ps_stop(NULL, NULL, 1);
|
||||
(void)av;
|
||||
// check more error
|
||||
}
|
||||
@@ -39,7 +39,7 @@ t_stack *init_stack(int ac, char **av)
|
||||
while (--ac)
|
||||
{
|
||||
if (!(start = ft_calloc(1, sizeof(t_stack))))
|
||||
ps_stop(start, NULL, NULL, 2);
|
||||
ps_stop(NULL, NULL, 2);
|
||||
start->n = ft_atoi(av[ac]);
|
||||
start->next = tmp;
|
||||
tmp = start;
|
||||
@@ -90,5 +90,6 @@ int main(int ac, char **av)
|
||||
stack = init_stack(ac, av);
|
||||
result = launch_algo(stack);
|
||||
print_result(result, flag);
|
||||
ps_stop(NULL, result, 0);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,31 @@
|
||||
|
||||
#include "push_swap.h"
|
||||
|
||||
t_list *rra(t_stack **stack, t_list **lst);
|
||||
t_list *rrb(t_stack **stack, t_list **lst);
|
||||
t_list *rra(t_stack **stack, t_list **lst)
|
||||
{
|
||||
t_stack *tmp;
|
||||
t_stack *before;
|
||||
|
||||
tmp = *stack;
|
||||
if (!tmp || !(tmp->next))
|
||||
return (NULL);
|
||||
while (tmp->next)
|
||||
{
|
||||
before = tmp;
|
||||
tmp = tmp->next;
|
||||
}
|
||||
tmp->next = *stack;
|
||||
*stack = tmp;
|
||||
before->next = NULL;
|
||||
fill_solution(*lst, ft_strdup("rra"));
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
t_list *rrb(t_stack **stack, t_list **lst)
|
||||
{
|
||||
t_stack *tmp;
|
||||
|
||||
tmp = *stack;
|
||||
return (NULL);
|
||||
}
|
||||
t_list *rrr(t_stack **a, t_stack **b, t_list **lst);
|
||||
|
||||
28
srcs/stop.c
28
srcs/stop.c
@@ -13,19 +13,33 @@ void ps_error(int err)
|
||||
ps_usage();
|
||||
if (err == 2)
|
||||
ft_printf("error\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void ps_stop(t_stack *stack_a, t_stack *stack_b, t_list *solution, int err)
|
||||
void ps_stop(t_stack *stack, t_list *lst, int err)
|
||||
{
|
||||
if (stack_a)
|
||||
ft_lstclear((t_list **)&stack_a, NULL);
|
||||
if (stack_b)
|
||||
ft_lstclear((t_list **)&stack_b, NULL);
|
||||
if (solution)
|
||||
t_stack **a;
|
||||
t_stack **b;
|
||||
t_list *solution;
|
||||
|
||||
(void)stack;
|
||||
(void)a;
|
||||
(void)b;
|
||||
(void)solution;
|
||||
(void)lst;
|
||||
if (stack)
|
||||
ft_lstclear((t_list **)&stack, NULL);
|
||||
if (lst)
|
||||
{
|
||||
a = lst->content;
|
||||
b = lst->next->content;
|
||||
solution = lst->next->next;
|
||||
ft_lstclear((t_list **)a, NULL);
|
||||
ft_lstclear((t_list **)b, NULL);
|
||||
ft_lstclear(&solution, free);
|
||||
}
|
||||
if (err < 0)
|
||||
return ;
|
||||
else if (err > 0)
|
||||
ps_error(err);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user