diff --git a/.clang-format b/.clang-format deleted file mode 100644 index b344245..0000000 --- a/.clang-format +++ /dev/null @@ -1,31 +0,0 @@ -Language: C - -AlignConsecutiveDeclarations: false -AlignConsecutiveMacros: false -AlignEscapedNewlinesLeft: true -AllowAllParametersOfDeclarationOnNextLine: false -AllowShortBlocksOnASingleLine: false -AllowShortFunctionsOnASingleLine: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -BinPackArguments: true -BinPackParameters: true -BreakBeforeBraces: Allman -BreakBeforeTernaryOperators: false -ColumnLimit: 80 -IndentWidth: 4 -KeepEmptyLinesAtTheStartOfBlocks: false -MaxEmptyLinesToKeep: 1 -PointerAlignment: Right -PenaltyBreakBeforeFirstCallParameter: 1 -PenaltyBreakString: 1 -PenaltyExcessCharacter: 0 -SpaceAfterCStyleCast: true -SpaceBeforeAssignmentOperators: true -SpaceBeforeParens: ControlStatements -SpaceInEmptyParentheses: false -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -TabWidth: 4 -UseTab: Always diff --git a/Makefile b/Makefile index e1662ef..8a19551 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ INCLUDES = includes # ALL FILES WITHOUT PATH #============================ -SRC = main.c test_one.c ft_putnbr.c secure_write.c +SRC = main.c ft_putnbr.c secure_write.c INSERTION = insertion.c diff --git a/algorithms/radix/radix.c b/algorithms/radix/radix.c index 249c2d5..0aebce6 100644 --- a/algorithms/radix/radix.c +++ b/algorithms/radix/radix.c @@ -33,15 +33,8 @@ static void push_by_number_to_b(t_stacks *stacks, int unit, int nb) { int i; int s_len; - t_stack *temp; - temp = stacks->a; - s_len = 1; - while (temp && temp->next != stacks->a) - { - s_len++; - temp = temp->next; - } + s_len = stack_a_len(stacks); i = 0; while (i < s_len && still_unit_index(stacks, unit)) { diff --git a/flags/bench.c b/flags/bench.c index 7a399bd..fda966f 100644 --- a/flags/bench.c +++ b/flags/bench.c @@ -34,6 +34,7 @@ static void print_disorder(t_stacks *stacks) secure_write(2, "0", 1); secure_write(2, &str[ft_strlen(str) - 2], ft_strlen(str) - 2); secure_write(2, "%\n", 2); + stacks->disorder /= 10000; free(str); } diff --git a/main.c b/main.c index b4e75b5..44544dd 100644 --- a/main.c +++ b/main.c @@ -16,6 +16,30 @@ #include "flags.h" #include +static int push_swap(char **tab, int len, int mod) +{ + t_stacks *stacks; + + stacks = NULL; + if (mod == -1) + return (0); + stacks = init_stacks(len, tab, mod); + indexer(stacks); + if (!stacks) + return (0); + if (check_order(stacks->a)) + { + free_all(stacks); + return (0); + } + stacks->disorder = compute_disorder(tab, wich_mod(mod)); + flags(pos_flag(tab, mod), pos_bench(tab, mod), tab, stacks); + if (stacks->bench == 1) + print_bench(stacks); + free_all(stacks); + return (0); +} + int main(int argc, char **argv) { char **tab; @@ -30,7 +54,7 @@ int main(int argc, char **argv) len = len_split(tab); mod = calcul_mod(len, tab); if (check_error(tab, mod)) - test1(tab, len, mod); + push_swap(tab, len, mod); else write(2, "Error\n", 6); free_tab(tab); diff --git a/test_one.c b/test_one.c deleted file mode 100644 index 885422b..0000000 --- a/test_one.c +++ /dev/null @@ -1,40 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_one.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: mteriier +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2025/12/22 12:33:58 by mteriier #+# #+# */ -/* Updated: 2026/01/08 15:35:43 by dgaillet ### ########lyon.fr */ -/* */ -/* ************************************************************************** */ - -#include "push_swap.h" -#include "flags.h" -#include "parsing.h" -#include "medium_headers.h" - -int test1(char **tab, int len, int mod) -{ - t_stacks *stacks; - - stacks = NULL; - if (mod == -1) - return (0); - stacks = init_stacks(len, tab, mod); - indexer(stacks); - if (!stacks) - return (0); - if (check_order(stacks->a)) - { - free_all(stacks); - return (0); - } - stacks->disorder = compute_disorder(tab, wich_mod(mod)); - flags(pos_flag(tab, mod), pos_bench(tab, mod), tab, stacks); - if (stacks->bench == 1) - print_bench(stacks); - free_all(stacks); - return (0); -}