lazy week-end stuff B)
started conversion of functions to data structure system still WIP added first iteration of int parser does not check for int overflow
This commit is contained in:
@@ -6,18 +6,28 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/02/21 16:07:55 by tmaze #+# #+# */
|
||||
/* Updated: 2019/02/21 16:26:22 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/02/23 15:19:59 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "push_swap.h"
|
||||
|
||||
void ps_rot(t_stack **s)
|
||||
void ps_rot(t_psdata *data, char c)
|
||||
{
|
||||
t_stack *s;
|
||||
t_stack *tmp;
|
||||
t_stack *ind;
|
||||
size_t size;
|
||||
|
||||
if (*s != NULL && ps_stksize(*s) > 2)
|
||||
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)
|
||||
{
|
||||
tmp = ps_stkpop(s);
|
||||
ind = *s;
|
||||
@@ -25,12 +35,12 @@ void ps_rot(t_stack **s)
|
||||
ind = ind->next;
|
||||
ind->next = tmp;
|
||||
}
|
||||
else if (*s != NULL && ps_stksize(*s) == 2)
|
||||
else if (*s != NULL && size == 2)
|
||||
ps_swap(s);
|
||||
}
|
||||
|
||||
void ps_rrot(t_stack **a, t_stack **b)
|
||||
void ps_rrot(t_psdata *data)
|
||||
{
|
||||
ps_rot(a);
|
||||
ps_rot(b);
|
||||
ps_rot(data, 'a');
|
||||
ps_rot(data, 'b');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user