segfault bizare dans la fonctions qui verifie que la liste est ordonnee
This commit is contained in:
BIN
builds/print.o
BIN
builds/print.o
Binary file not shown.
Binary file not shown.
@@ -86,7 +86,6 @@ void print_flags(char **part, int flag)
|
|||||||
void print_result(t_list *result, int flag)
|
void print_result(t_list *result, int flag)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int j;
|
|
||||||
char **part;
|
char **part;
|
||||||
|
|
||||||
i = -1;
|
i = -1;
|
||||||
@@ -99,13 +98,7 @@ void print_result(t_list *result, int flag)
|
|||||||
print_flags(part, flag);
|
print_flags(part, flag);
|
||||||
ft_putchar('\n');
|
ft_putchar('\n');
|
||||||
result = result->next;
|
result = result->next;
|
||||||
j = 0;
|
ft_free_tab(part);
|
||||||
while (part[j] != NULL)
|
|
||||||
{
|
|
||||||
free(part[j]);
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
free(part);
|
|
||||||
}
|
}
|
||||||
if (flag)
|
if (flag)
|
||||||
ft_putnbrendl(i);
|
ft_putnbrendl(i);
|
||||||
|
|||||||
@@ -1,5 +1,21 @@
|
|||||||
#include "push_swap.h"
|
#include "push_swap.h"
|
||||||
|
|
||||||
|
int is_ordered(t_stack *list)
|
||||||
|
{
|
||||||
|
int cmp;
|
||||||
|
|
||||||
|
cmp = list->n;
|
||||||
|
while (list->next != NULL)
|
||||||
|
{
|
||||||
|
list = list->next;
|
||||||
|
ft_printf("n:%i cmp:%i\n", cmp, list->n);
|
||||||
|
if (list->n < cmp)
|
||||||
|
return (0);
|
||||||
|
cmp = list->n;
|
||||||
|
}
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
int check_flag(int *ac, char ***av)
|
int check_flag(int *ac, char ***av)
|
||||||
{
|
{
|
||||||
if (ft_strcmp((*av)[1], "-p") == 0)
|
if (ft_strcmp((*av)[1], "-p") == 0)
|
||||||
@@ -55,6 +71,7 @@ t_stack *init_stack(int ac, char **av)
|
|||||||
i++;
|
i++;
|
||||||
while (--i >= 0)
|
while (--i >= 0)
|
||||||
list = fill_stack(list, split[i]);
|
list = fill_stack(list, split[i]);
|
||||||
|
ft_free_tab(split);
|
||||||
}
|
}
|
||||||
return (list);
|
return (list);
|
||||||
}
|
}
|
||||||
@@ -96,8 +113,11 @@ int main(int ac, char **av)
|
|||||||
flag = check_flag(&ac, &av);
|
flag = check_flag(&ac, &av);
|
||||||
a = init_stack(ac, av);
|
a = init_stack(ac, av);
|
||||||
b = NULL;
|
b = NULL;
|
||||||
solution = launch_algo(&a, &b, flag);
|
if (is_ordered(a) == 1)
|
||||||
print_result(solution, flag);
|
{
|
||||||
|
solution = launch_algo(&a, &b, flag);
|
||||||
|
print_result(solution, flag);
|
||||||
|
}
|
||||||
ps_stop(solution, 0);
|
ps_stop(solution, 0);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ else
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PRGM=push_swap # path to program
|
PRGM="push_swap" # path to program
|
||||||
# range of random numbers
|
# range of random numbers
|
||||||
RANGE=$(($SIZE * 2))
|
RANGE=$(($SIZE * 2))
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ LIST=($(shuf -i 0-$RANGE -n $SIZE))
|
|||||||
echo -e "${WHITE}test lancé avec la liste de nombres suivantes :${NC}"
|
echo -e "${WHITE}test lancé avec la liste de nombres suivantes :${NC}"
|
||||||
echo -e "${LIST[@]}"
|
echo -e "${LIST[@]}"
|
||||||
|
|
||||||
OUTPUT=`./$PRGM ${LIST[@]}`
|
OUTPUT=$(./$PRGM ${LIST[@]})
|
||||||
COUNT=$(echo "$OUTPUT" | wc -l)
|
COUNT=$(echo "$OUTPUT" | wc -l)
|
||||||
RESULT=$(echo "$OUTPUT" | ./checker ${LIST[@]})
|
RESULT=$(echo "$OUTPUT" | ./checker ${LIST[@]})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user