modified some files like all files in stack utils and adding main.c and modified atoi and parssing

This commit is contained in:
Maoake
2025-12-08 20:44:03 +00:00
parent 8e8ca5cfdc
commit 30b306d2c2
10 changed files with 87 additions and 26 deletions

View File

@@ -6,25 +6,25 @@
/* By: mteriier <mteriier@student.42lyon.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/08 15:09:40 by mteriier #+# #+# */
/* Updated: 2025/12/08 15:35:23 by mteriier ### ########lyon.fr */
/* Updated: 2025/12/08 19:37:01 by mteriier ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
#include "../push_swap.h"
void pa(t_stacks *stacks)
{
t_stack a;
t_stack *a;
if (!stacks || !stacks->b)
return ;
a = stack->a;
a = stacks->a;
a->value = stacks->b->value;
}
void pb(t_stacks *stacks)
{
t_stack b;
t_stack *b;
if (!stacks || !stacks->a)
return ;

View File

@@ -6,11 +6,11 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/08 14:43:45 by dgaillet #+# #+# */
/* Updated: 2025/12/08 14:52:53 by dgaillet ### ########lyon.fr */
/* Updated: 2025/12/08 19:37:26 by mteriier ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
#include "../push_swap.h"
void rra(t_stacks *stacks)
{

View File

@@ -6,11 +6,11 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/08 14:32:10 by dgaillet #+# #+# */
/* Updated: 2025/12/08 14:52:37 by dgaillet ### ########lyon.fr */
/* Updated: 2025/12/08 19:37:44 by mteriier ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
#include "../push_swap.h"
void ra(t_stacks *stacks)
{

View File

@@ -6,11 +6,11 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/08 15:52:40 by dgaillet #+# #+# */
/* Updated: 2025/12/08 16:03:54 by dgaillet ### ########lyon.fr */
/* Updated: 2025/12/08 20:33:58 by mteriier ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
#include "../push_swap.h"
#include <stdlib.h>
t_stack *new_stack(int value)
@@ -26,11 +26,13 @@ t_stack *new_stack(int value)
return (new);
}
#include <stdio.h>
void stack_add_back(t_stack **stack, t_stack *new)
{
if (!stack || !new)
return ;
if (!(*stack))
if (*stack == NULL)
{
(*stack) = new;
new->next = new;
@@ -39,7 +41,7 @@ void stack_add_back(t_stack **stack, t_stack *new)
else
{
(*stack)->previous->next = new;
new->previous = *(stack)->previous;
new->previous = (*stack)->previous;
(*stack)->previous = new;
new->next = *stack;
}
@@ -47,7 +49,7 @@ void stack_add_back(t_stack **stack, t_stack *new)
void stack_add_front(t_stack **stack, t_stack *new)
{
if (!stack || *new)
if (!stack || !new)
return ;
stack_add_back(stack, new);
*stack = new;

View File

@@ -6,11 +6,11 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/08 16:05:27 by dgaillet #+# #+# */
/* Updated: 2025/12/08 16:15:28 by dgaillet ### ########lyon.fr */
/* Updated: 2025/12/08 19:40:01 by mteriier ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
#include "../push_swap.h"
#include <stdlib.h>
void stack_clear_all(t_stack *stack, t_stack *first)

View File

@@ -6,15 +6,15 @@
/* By: mteriier <mteriier@student.42lyon.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/08 14:48:44 by mteriier #+# #+# */
/* Updated: 2025/12/08 15:04:39 by mteriier ### ########lyon.fr */
/* Updated: 2025/12/08 19:40:49 by mteriier ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
#include "../push_swap.h"
void sa(t_stacks *stacks)
{
t_stack a;
t_stack *a;
int stock;
if (!stacks || !stacks->a || !stacks->a->next)
@@ -27,7 +27,7 @@ void sa(t_stacks *stacks)
void sb(t_stacks *stacks)
{
t_stack b;
t_stack *b;
int stock;
if (!stacks || !stacks->b || !stacks->b->next)