diff --git a/Makefile b/Makefile index c96ba98..58a2f02 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ CC = cc RM = rm -rf INCLUDES = -I./$(INC_PATH) -I./$(LIBFT_INC_PATH) -CFLAGS = -Wall -Wextra -Werror -g +CFLAGS = -Wall -Wextra -Werror LDFLAGS = -L./libft LDLIBS = -lft @@ -89,4 +89,4 @@ debug: fclean @$(MAKE) -C libft debug @$(MAKE) -s -.PHONY: all bonus clean fclean re +.PHONY: all bonus clean fclean re run debug diff --git a/inc/push_swap.h b/inc/push_swap.h index b841f6b..d8e3351 100644 --- a/inc/push_swap.h +++ b/inc/push_swap.h @@ -21,6 +21,8 @@ typedef struct s_state t_list *b; } t_state; +typedef void (*t_move)(t_state *, int); + int *longest_incremental_subsequence(t_list *stack, int *lis_size); int *lis_lengths(t_list *stack, int size); int *lis_indices(int *lengths, int size, int max_len); diff --git a/src/checker.c b/src/checker.c index f940842..8a05fbf 100644 --- a/src/checker.c +++ b/src/checker.c @@ -14,13 +14,15 @@ #include #include -void execute_move(const char *move, t_state *state) +void execute_move(const char *move, t_state *state) { - void (*const moves[])(t_state *, int) = {&sa, &sb, &ss, &pa, &pb, \ - &ra, &rb, &rr, &rra, &rrb, &rrr}; - const char *moves_names[] = {"sa\n", "sb\n", "ss\n", "pa\n", "pb\n", \ - "ra\n", "rb\n", "rr\n", "rra\n", "rrb\n", "rrr\n"}; - int i; + const t_move moves[11] = {&sa, &sb, &ss, &pa, &pb, \ + &ra, &rb, &rr, &rra, &rrb, &rrr}; + const char *moves_names[] = {"sa\n", "sb\n", "ss\n", \ + "pa\n", "pb\n", \ + "ra\n", "rb\n", "rr\n", \ + "rra\n", "rrb\n", "rrr\n"}; + int i; i = 0; while (i < 11) @@ -28,7 +30,7 @@ void execute_move(const char *move, t_state *state) if (ft_strcmp(move, moves_names[i]) == 0) { moves[i](state, 1); - return; + return ; } i++; } @@ -37,7 +39,7 @@ void execute_move(const char *move, t_state *state) int main(int argc, char *argv[]) { - int size; + int size; t_state *state; char *move; @@ -47,9 +49,9 @@ int main(int argc, char *argv[]) { if (!new_element(&(state->a), argv[argc])) return (error(state)); - if (has_duplicates(state->a)) - return (error(state)); } + if (has_duplicates(state->a)) + return (error(state)); size = ft_lstsize(state->a); move = get_next_line(STDIN_FILENO); while (move)