actually it's not =(

This commit is contained in:
Tanguy MAZE 2019-03-18 17:38:27 +01:00
parent e0f584fd30
commit 0b3ba46116
6 changed files with 19 additions and 8 deletions

2
libft

@ -1 +1 @@
Subproject commit d5eecbed888ecaa348527f7bd18302ed2f9a276b Subproject commit 75ebffddeadd84c4330e6348e097456ccb4abe19

View File

@ -6,7 +6,7 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */ /* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/23 13:35:15 by tmaze #+# #+# */ /* Created: 2019/02/23 13:35:15 by tmaze #+# #+# */
/* Updated: 2019/03/18 12:28:54 by tmaze ### ########.fr */ /* Updated: 2019/03/18 17:24:12 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -77,6 +77,7 @@ int read_ops(t_psdata *data)
ft_bzero(tmp, 4); ft_bzero(tmp, 4);
while ((ret = ft_getline(&buff)) > 0) while ((ret = ft_getline(&buff)) > 0)
{ {
ft_printf("checker read '%s'\n");
ft_strncpy(tmp, buff, 3); ft_strncpy(tmp, buff, 3);
if (ft_strlen(buff) > 4 || !is_op(buff) if (ft_strlen(buff) > 4 || !is_op(buff)
|| (nop = ft_lstnew(tmp, 4)) == NULL) || (nop = ft_lstnew(tmp, 4)) == NULL)

View File

@ -6,7 +6,7 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */ /* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/16 13:14:52 by tmaze #+# #+# */ /* Created: 2019/03/16 13:14:52 by tmaze #+# #+# */
/* Updated: 2019/03/16 13:29:57 by tmaze ### ########.fr */ /* Updated: 2019/03/18 15:19:06 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -6,7 +6,7 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */ /* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/16 13:21:02 by tmaze #+# #+# */ /* Created: 2019/03/16 13:21:02 by tmaze #+# #+# */
/* Updated: 2019/03/16 13:27:43 by tmaze ### ########.fr */ /* Updated: 2019/03/18 17:36:47 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,6 +15,8 @@
static int join_lists(t_psdata *data, t_stack **last, int inds, int inds2) static int join_lists(t_psdata *data, t_stack **last, int inds, int inds2)
{ {
while ((*last)->ind == inds2 || data->size_b > 0) while ((*last)->ind == inds2 || data->size_b > 0)
{
ft_printf("last nb %d ind %d inds2 %d\n", (*last)->nb, (*last)->ind, inds2);
if (((*last)->ind != inds2 && data->size_b > 0) if (((*last)->ind != inds2 && data->size_b > 0)
|| (data->size_b > 0 && data->b->nb > (*last)->nb)) || (data->size_b > 0 && data->b->nb > (*last)->nb))
{ {
@ -31,6 +33,7 @@ static int join_lists(t_psdata *data, t_stack **last, int inds, int inds2)
data->a->ind = inds; data->a->ind = inds;
(*last) = get_last_a(data); (*last) = get_last_a(data);
} }
}
return (1); return (1);
} }
@ -64,9 +67,16 @@ int sort(t_psdata *data)
t_stack *last; t_stack *last;
int inds; int inds;
int inds2; int inds2;
t_stack *ptr;
last = get_last_a(data); last = get_last_a(data);
inds = last->ind + 1; inds = last->ind + 1;
ptr = data->a;
while (ptr)
{
ft_printf("nb: %d ind %d\n", ptr->nb, ptr->ind);
ptr = ptr->next;
}
while (data->a->ind != last->ind) while (data->a->ind != last->ind)
{ {
inds2 = data->a->ind; inds2 = data->a->ind;

View File

@ -6,7 +6,7 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */ /* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/25 12:44:08 by tmaze #+# #+# */ /* Created: 2019/02/25 12:44:08 by tmaze #+# #+# */
/* Updated: 2019/03/15 15:36:06 by tmaze ### ########.fr */ /* Updated: 2019/03/18 15:13:10 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -6,7 +6,7 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */ /* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/03 11:41:49 by tmaze #+# #+# */ /* Created: 2019/03/03 11:41:49 by tmaze #+# #+# */
/* Updated: 2019/03/16 13:23:53 by tmaze ### ########.fr */ /* Updated: 2019/03/18 15:18:04 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -19,7 +19,7 @@ void print_ops(t_psdata *data)
it = data->op; it = data->op;
while (it) while (it)
{ {
ft_printf("%s\n", (char*)(it->content)); ft_printf("%s\n", it->content);
it = it->next; it = it->next;
} }
} }
@ -41,7 +41,7 @@ int main(int ac, char **av)
{ {
mark_groups(&data); mark_groups(&data);
if (sort(&data) == 0) if (sort(&data) == 0)
ft_putendl_fd("Error\n", 2); ft_putendl_fd("Error", 2);
else else
{ {
clean_op(&data); clean_op(&data);