1
0
This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
2023-08-06 20:12:38 +02:00

59 lines
1.5 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_parser.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lvincent <lvincent@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/30 17:19:40 by lvincent #+# #+# */
/* Updated: 2022/07/31 16:20:45 by lvincent ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
#define UI_MAX 4294967295
int ft_parse(char *str)
{
int i;
int len;
i = 0;
while (ft_is_whitespace(str[i]) && str[i])
i++;
if (i >= ft_strlen(str))
return (0);
while (str[i])
{
if (ft_is_whitespace(str[i]))
break ;
else if ((str[i] < '0' || str[i] > '9') && !ft_is_whitespace(str[i]))
return (0);
i++;
}
while (str[i])
{
if (!ft_is_whitespace(str[i]))
return (0);
i++;
}
return (1);
}
char *ft_trim(char *str)
{
int i;
int j;
i = 0;
while (str[i] && ft_is_whitespace(str[i]))
i++;
j = i;
while (str[i] && !ft_is_whitespace(str[i]))
i++;
if (i < ft_strlen(str))
str[i] = '\0';
return (str + j);
}