mirror of
https://github.com/DavidGailleton/42-Push_Swap.git
synced 2026-01-27 00:41:57 +00:00
finish the checker error
This commit is contained in:
51
checker/verif_overflow.c
Normal file
51
checker/verif_overflow.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* verif_overflow.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mteriier <mteriier@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/01/09 10:30:39 by mteriier #+# #+# */
|
||||
/* Updated: 2026/01/09 10:30:40 by mteriier ### ########lyon.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "parsing.h"
|
||||
|
||||
static int verif_atoi(const char *nptr)
|
||||
{
|
||||
size_t i;
|
||||
int tmp;
|
||||
int before;
|
||||
|
||||
i = 0;
|
||||
tmp = 0;
|
||||
before = 0;
|
||||
while ((nptr[i] >= 9 && nptr[i] <= 13) || nptr[i] == ' ')
|
||||
i++;
|
||||
if (nptr[i] == '-' || nptr[i] == '+')
|
||||
i++;
|
||||
while (nptr[i] >= '0' && nptr[i] <= '9')
|
||||
{
|
||||
before = tmp;
|
||||
tmp = tmp * 10 + nptr[i] - '0';
|
||||
if (before > tmp)
|
||||
return (0);
|
||||
i++;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
int verif_overflow(char **tab, int mod)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = wich_mod(mod);
|
||||
while (tab[i])
|
||||
{
|
||||
if (!verif_atoi(tab[i]))
|
||||
return (0);
|
||||
i++;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
Reference in New Issue
Block a user