/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ps_rerot.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: tmaze +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/02/21 16:32:04 by tmaze #+# #+# */ /* Updated: 2019/02/23 16:08:12 by tmaze ### ########.fr */ /* */ /* ************************************************************************** */ #include "push_swap.h" void ps_rerot(t_psdata *data, char c) { t_stack *s; t_stack *prec; t_stack *tmp; size_t size; if (c == 'a') s = data->a; if (c == 'a') size = data->size_a; else if (c == 'b') s = data->b; if (c == 'b') size = data->size_b; if (*s != NULL && size > 2) { prec = *s; tmp = (*s)->next; while (tmp->next != NULL) { tmp = tmp->next; prec = prec->next; } prec->next = NULL; ps_stkpsh(s, tmp); } else if (*s != NULL && ps_stksize(*s) == 2) ps_swap(s); } void ps_rrerot(t_stack **a, t_stack **b) { ps_rerot(a); ps_rerot(b); }